Skip to content

feat: 可插拔协作注入(运行时载体取代静态文档写入)/ pluggable collaboration injection#235

Open
bikeread wants to merge 1 commit into
raysonmeng:masterfrom
bikeread:feat/pluggable-injection
Open

feat: 可插拔协作注入(运行时载体取代静态文档写入)/ pluggable collaboration injection#235
bikeread wants to merge 1 commit into
raysonmeng:masterfrom
bikeread:feat/pluggable-injection

Conversation

@bikeread

Copy link
Copy Markdown

摘要 / Summary

abg init 不再默认写入项目的 CLAUDE.md / AGENTS.md;协作契约改为桥接期运行时下发,项目保持零静态足迹。
abg init no longer writes static sections into project docs by default — the collaboration contract is delivered at runtime, only while a bridge is actually attached.

Codex 侧载体 / Codex carrier

  • 新线程:proxy 改写 thread/start.params.developerInstructions(合并、不覆盖客户端已有值)。
  • 既有线程:thread/resume 成功响应被扣住,thread/inject_items(role=developer)注入成功且 pair state 原子落账后才放行;失败/超时以显式错误终结请求,resume 不悬挂。
  • 幂等:(threadId, contractHash) 账本(有界 256 条、原子写、仅收 12 位 hex);hash 变化重发带取代头的完整合同。
  • 旧协议(< 0.144.1)显式兼容性报错,绝不静默回退写 AGENTS.md

Claude 侧载体 / Claude carrier

  • 插件 SessionStart hook 经 bridge-server.js --print-session-context 在 daemon 健康 + Codex TUI 已连时注入会话上下文(承重内容,绕过通知冷却);桥不在时仅保留原有运营短提示。
  • --check 模式让 shell 与 TS 共用同一份配置判定(不在 shell 重写 JSON 解析)。

CLI / 配置

  • abg init --inject-docs 保留旧静态注入;新增 abg deinit 摘除存量注入块(upsert→remove 往返无损,畸形 marker 拒绝操作)。
  • injection.runtime(默认 true):双侧同源开关,false 时 Codex 侧完全旁路、Claude hook 对该工作区全静默。

已知硬边界 / Known hard limit

codex-cli 0.144.1 不存在"模型可见但可撤销、不入历史"的指令通道:桥接过的线程在其自身 rollout 中保留合同,脱桥 resume 会重放。缓解:合同开头失效条款("仅在当前会话有真实桥消息时生效,绝不因本合同等待 Claude")。实测 developer_instructions 配置键在 remote TUI 拓扑不透传、additionalContext 同样入 rollout——均已排除。

验证 / Verification

  • bun run check 全绿:typecheck + 1685 tests / 0 fail(97 files)+ plugin bundle 同步 + 版本对齐。
  • 真实 codex-cli 0.144.1 协议级 E2E:resume 扣住→注入→落账→放行(200ms);合并不覆盖客户端 sentinel;同 hash 再 resume 79ms 且 rollout 合同计数保持 1。
  • E2E 手工测试计划:docs/test-plans/pluggable-injection.md

协作 / Collaboration

由 AgentBridge 自身桥接的 Claude × Codex 结对完成:Claude(契约模块、hook 载体、CLI init/deinit、文档)× Codex(proxy 载体、幂等账本、配置布线、协议 E2E),会话内完成双向交叉 review(6 项 findings 全部闭环)。
Built by a Claude × Codex pair bridged by AgentBridge itself; cross-reviewed in-session.

…ation injection via runtime carriers

abg init 不再默认写入项目文档;协作契约改为桥接期运行时下发:
- Codex 侧:proxy 在 thread/start 合并 developerInstructions;既有线程 resume 后
  经 thread/inject_items 注入 developer contract item;(threadId, contractHash)
  幂等落 pair state;hash 变化重发带取代头的完整合同;旧协议显式报错不静默回退。
- Claude 侧:插件 SessionStart hook 经 bridge-server.js --print-session-context
  在 daemon 健康 + TUI 已连时注入会话上下文(绕过通知冷却)。
- CLI:init 默认零写入(--inject-docs 保留旧行为);新增 deinit 摘除存量注入块。
- 配置:injection.runtime 双侧同源开关(false 时 Codex 侧旁路、Claude hook 全静默)。

EN: abg init no longer writes CLAUDE.md/AGENTS.md by default. The collaboration
contract is delivered at runtime while a bridge is attached: the codex proxy
merges thread/start.developerInstructions (thread/inject_items for resumed
threads, idempotent per (threadId, contractHash), full-supersede on hash change,
explicit compatibility error on old protocols — never a silent AGENTS.md
fallback); the plugin SessionStart hook emits the Claude-side context only while
the daemon is healthy and the TUI is attached. `init --inject-docs` keeps the
legacy static sections; new `abg deinit` removes previously injected blocks;
`injection.runtime` is the shared opt-out for both carriers.

Verified on real codex-cli 0.144.1: resume hold → inject → persist → release
(200ms), non-destructive merge alongside client instructions, idempotent
re-resume (contract count stays 1). Gate: typecheck + 1685 tests + plugin sync.

分工 / Split: Claude(contract module, hook carrier, CLI init/deinit, docs) ×
Codex(proxy carriers, ledger, config wiring, protocol E2E) — cross-reviewed
in-session.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the PR! Before we can merge it, please sign our lightweight Contributor License Agreement — it keeps the project able to offer a future commercial edition alongside the open-source one. Reply here with:


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant