用途:清理 AI 编码助手会话文件中的拒绝回复,替换为可协作内容,便于恢复中断的对话;同时向配置层注入 CTF/安全测试上下文,用于 CTF、渗透测试与逆向工程工作流。
主要能力:支持 Codex CLI(JSONL)、Claude Code(JSONL)、OpenCode(SQLite)三种会话格式;提供拒绝检测(强短语+弱前缀两级)与替换、备份与恢复、CTF 配置安装/卸载/状态查询、提示重写、Web UI。可选用 AI 生成上下文相关替换内容。
必要用法:安装:git clone https://github.com/ryfineZ/codex-session-patcher.git,cd 后执行 pip install -e .;含 Web UI 时用 pip install -e ".[web]" 并在 web/frontend 下 npm install && npm run build。核心命令:codex-patcher --dry-run --show-content(预览)、--latest、--all、--format codex|claude-code|opencode、--session-dir、--no-backup、--keep-reasoning。CTF:codex-patcher --install-ctf-config 后 codex -p ctf;--install-claude-ctf 后 cd ~/.claude-ctf-workspace && claude;--install-opencode-ctf 后 cd ~/.opencode-ctf-workspace && opencode;--ctf-status 查询。Web:codex-patcher --web。配置文件位于 ~/.codex-patcher/config.json,可设 mock_response、ai_enabled、ai_endpoint、ai_key、ai_model、custom_keywords、ctf_prompts。Python API 需从 codex_session_patcher.core 导入 SessionParser、RefusalDetector、SessionPatcher、SessionFormatFactory、Config、BackupManager 等模块使用。
适用场景:本机 AI 编码助手会话的中断恢复与拒绝内容处理,以及授权的安全测试环境。
限制:该工具定位为修改本地会话与注入安全测试提示,具体平台兼容版本、许可与安全边界资料暂未提供;它可能改变会话记录,默认会创建备份,建议先使用 --dry-run 预览。AI 清理需自行提供端点与密钥。