1实现原理 · 为什么它能做到
两段式修正循环:Stage 1 用确定性词典规则批量应用已知修正,Native AI Correction(Claude/Codex 内建,无需外部 key)通读全文修一次性错误并沉淀可复用修正;Stage 3 API 只服务无 agent 的自动化。
1. Stage 1 applies deterministic, already-known corrections. 2. Native AI Correction reads the complete transcript, fixes one-off errors, verifies uncertain entities, and compounds reusable fixes.
个人化修正数据库:SQLite(~/.transcript-fixer/corrections.db)存词典/上下文规则/人名名册/审核队列,目录 chmod 0o700、config 0o600,域上下文文件按 ~/.transcript-fixer/contexts/<domain>.md 约定。
# Filesystem security CONFIG_DIR_MODE: Final[int] = 0o700 CONFIG_FILE_MODE: Final[int] = 0o600
人名修正门禁:改人名前必须同时读全局 people roster 与项目显式身份名册;roster 只存 ASR 变体、不自动加载项目册、频率永远不是身份证据。
Before correcting any person name, directly read both the configured global people roster and the owning project's explicit identity roster or alias ledger. … Never use occurrence frequency as identity evidence.
Safe mode + 多层匹配防护:默认只自动应用低风险规则,中/高风险 defer 到 *_needs_review.md 与持久化 review queue;匹配期三层检查(超集/常见词边界/词边界)再拒一轮。
Safe mode is the Stage 1 default: low-risk rules apply; medium/high-risk matches defer to `*_needs_review.md` and the persistent review queue. `Applied: 0` is a valid result, not proof that the transcript is clean.
审核队列 + 本地 dashboard:队列行 {file, line, original, suggested, kind, context, evidence};review-dashboard/server.py 起 FastAPI 于 127.0.0.1:8767,只读连同一 SQLite,CLI 与人共用同一裁决源。
anchor guards, and audit logging stay the single source of truth — this UI never mutates the database itself. Agent (CLI) and human (this page) are equal writers of the same queue.
AI 增强路由(agent-less):仅当无 Claude/Codex 可用时走 GLM——anthropic 兼容端点 open.bigmodel.cn/api/anthropic,x-api-key 认证,/v1/messages,模型 GLM-5.2(fallback GLM-5-turbo)。
API_PROVIDER: Final[str] = "GLM" DEFAULT_MODEL: Final[str] = "GLM-5.2" FALLBACK_MODEL: Final[str] = "GLM-5-turbo" API_BASE_URL: Final[str] = "https://open.bigmodel.cn/api/anthropic" AUTH_HEADER_NAME: Final[str] = "x-api-key"
证据链与关闭契约:修正要有 from_text/to_text 溯源、asr_note 行掩码保护、--close-sidecars 只有在所有队列行裁决/规则停用/文件零 pending 时才报告 closed(exit 1 open/exit 2 blocked)。
`--close-sidecars --input "<absolute-canonical-file>"` reports `closed`: every entry reads applied in the file (or the original form no longer appears anywhere in the ledger-masked transcript) or is answered by a decided queue row for this exact file
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| network | open.bigmodel.cn(GLM/智谱,anthropic 兼容) |
| cli | uv / python3(PEP 723 入口,uv run) |
| package | httpx/filelock/aiofiles(ensure_deps 的共享 venv) |
| package | jieba / rapidfuzz(fix_transcription.py PEP 723 依赖,词边界/模糊匹配) |
| cli | lark-cli(飞书 CLI,音频取证;需已登录 profile) |
| cli | curl / ffprobe / sqlite3(工具链) |
4风险提醒 风险提醒:橙色 · 评估后使用
- 词典/域规则本身是高风险数据 — 一条错误/恶意规则会在整域批量误改正文('绿点→绿电' 类真实词);有 veto/探针/false-positive 撤销缓解,但规则入库需要本地信任与人工把关。
- Stage 3/取证面接触凭证与外发 — GLM key(env/config.json 明文)与文本外发智谱、lark-cli 飞书会话与音频下载——只在自动化或需音频证据时触发,但接触即需用户知情。
- 复杂度与维护负担高 — 90+ 脚本文件、23 份 references、迁移系统与多版本 schema——新用户学习曲线陡;文档与代码版本错位会直接导致错误使用(skill 自建大量测试应对)。
- 直接编辑原文件 — Native 模式就地改 transcript 并留 sidecar;若宿主无版本控制或 sidecar 被误删,误改难以回退(有 --close-sidecars/diff 建议缓解)。
- dashboard 自动开浏览器与后台服务 — server.py 起本地 HTTP 服务并自动 webbrowser.open;宿主需注意长驻进程与端口占用(REVIEW_DASHBOARD_PORT 可改)。
5第二遍独立确认
- [ok] SQLite 数据库与 0o700/0o600 权限 — defaults.py CONFIG_DIR_MODE=0o700/CONFIG_FILE_MODE=0o600;config.py DatabaseConfig/PathConfig __post_init__ 逐目录 mkdir+chmod;默认路径 Path.home()/'.transcript-fixer'/corrections.db。
- [ok] 凭证读取面(GLM/ANTHROPIC key 与 config.json) — config.py from_env 读 GLM_API_KEY/ANTHROPIC_API_KEY/ANTHROPIC_BASE_URL;from_file 读 config.json api.api_key;get_config 全局 env 覆盖 file。无其他 key/token 读取。
- [ok] 网络调用点仅 open.bigmodel.cn(+dashboard 本机) — ai_processor.py _process_chunk url=f'{base_url}/v1/messages' httpx POST;全目录 https?:// 扫描无其他外发端点;astral.sh 仅 ensure_deps 报错文案。
- [ok] 人名门禁(roster 双读/频率非证据) — commands.py 715-719/1330-1333 roster_path = getenv('TRANSCRIPT_FIXER_PEOPLE_ROSTER') or config…people_roster_path 存在;SKILL.md 操作契约原文存在;Stage1 只加载全局 ASR 变体。
- [ok] Safe mode 与 defer 行为 — SKILL.md『Safe mode is the Stage 1 default』;commands.py 1401 附近『Stage 1 defaults to conservative safe mode: only auto-apply low-risk』代码注释相符。
- [ok] review queue 结构(file/line/original/suggested/kind/context/evidence) — SKILL.md 最小条目 JSON 逐字段存在;review_queue.py 以 sqlite 实现(--init 后 db 必须存在)。
- [ok] dashboard 只读连库且仅本机 — server.py _connect_ro 用 'file:{DB_PATH}?mode=ro';uvicorn.run(host='127.0.0.1', port=PORT);docstring『never mutates the database itself』。
- [ok] fetch_minute_audio 网络/CLI 行为 — lark-cli minutes +download --url-only → json 取 download_url → curl -sSL --noproxy '*' 下载;LARK_CLI_NO_PROXY=1 防代理带走凭证。
6结论
1621eed101bbd789…d5c4678cb5