github mksglu/context-mode v1.0.107

2 hours ago

v1.0.107

The biggest single release since v1.0.100 — comprehensive 14-adapter parity audit with line-by-line clone verification, 22 verified P0 gaps closed, and 9 fabricated claims caught and retracted before they could ship.

Why this release exists

Mickey @mikij retested v1.0.106 and surfaced the next gap: "routing block is not injected and everything rely on AGENTS.md which btw is sadly unreliable. I find instruction in AGENTS.md file often omitted by models. My focus was to inject such thing no matter what into prompt on session start and guarantee context-mode will be used by model."

That report — combined with a maintainer mandate to verify all 14 adapters in one shot rather than fix bug-by-bug — triggered a comprehensive audit:

  • Phase 7: 1 main agent built a CC canonical feature catalog (77 items across 7 categories), then 13 parallel adapter agents read fresh --depth=1 clones line-by-line
  • Phase 8: 9 parallel staff-engineer agents implemented TDD red→green per slice
  • 2 architect grills caught remaining issues (including a critical platform-detect.mjs PLATFORM_ENV_VARS misalignment)
  • Code-driven verification (no agent narrative claims) caught 9 fabrications before ship

Mickey-class routing block — the headline fix

grep "ROUTING_BLOCK\|createRoutingBlock" src/opencode-plugin.ts returned 0 hits in v1.0.106. Confirmed real gap — Mickey was right.

Fixed in 3 plugin-paradigm adapters with the same pattern (evidence-based, not invented):

  • OpenCode (src/opencode-plugin.ts): experimental.chat.system.transform now splices createRoutingBlock(createToolNamer("opencode")) at index 1 with a visible marker <!-- context-mode v1.0.107: routing block injected (sessionID=...) -->. Separate routingInjected: Set<string> (NOT the same as resumeInjected) so routing fires even without prior snapshot. splice(1, 0, ...) preserves OpenCode's system[0] cache-fold header per agentisd/refs/opencode/packages/opencode/src/session/llm.ts:117-128.
  • OpenClaw (src/openclaw-plugin.ts): replaced static readFileSync(configs/openclaw/AGENTS.md) with dynamic createRoutingBlock(createToolNamer("openclaw")). Same visible marker pattern.
  • Pi (src/pi-extension.ts): before_agent_start handler prepends routing block via dynamic-import getRoutingBlock(pluginRoot). Same visible marker.

Verification path: OPENCODE_DEBUG=1 opencodegrep "<!-- context-mode v1.0.107: routing block" ~/.cache/opencode/log/*.log. The marker proves the injection landed at the system-prompt level (not user-message level like AGENTS.md).

Per-adapter P0 fixes

OpenCode (4 P0 — Mickey-class)

  • OC-1 ROUTING_BLOCK injection (above)
  • OC-2 chat.message hook wired (was missing — SDK has it at agentisd/refs/opencode/packages/plugin/src/index.ts:233); captures user prompts + extractUserEvents + inline <system-reminder> filter
  • OC-3 buildAutoInjection (P1/P2/P3/P4 priority bands, 500-token cap) in experimental.session.compacting (was raw buildResumeSnapshot)
  • OC-4 captureAgentsMd() in tool.execute.after — captures AGENTS.md / CLAUDE.md / CONTEXT.md as rule_content events. FILES order verified against agentisd/refs/opencode/packages/opencode/src/session/instruction.ts

OpenClaw (6 critical)

  • OClaw-1 NEW src/openclaw/mcp-tools.ts — registers 11 ctx_* MCP tools via api.registerTool (mirrors swarmvault standard MCP at refs/plugin-examples/openclaw/swarmvault/packages/engine/src/mcp.ts:46-51). The routing block was telling agents to use tools that DIDN'T EXIST in OpenClaw sessions. This is the single most severe gap closed.
  • OClaw-2 dynamic createRoutingBlock (above)
  • OClaw-3 isSystemReminderMessage 4-prefix filter in before_model_resolve (Mickey-class false-positive guard)
  • OClaw-4 session_end handler finalizes resume snapshot (per refs/platforms/openclaw/docs/plugins/hooks.md:110)
  • OClaw-5 subagent_spawning handler injects routing block via inputOverride.prompt
  • OClaw-6 F6 retraction confirmed: closure flag at lines 239,483,564,568 is fine per-register() singleton scope (NOT a bug)

Pi (1 P0 + 3 P1)

  • Pi-1 routing block injection (above)
  • Pi-2 before_provider_response handler (was unregistered — captures {model, provider, latencyMs, tokens})
  • Pi-3 active_memory always-built (removed compact_count===0 early-return)
  • Pi-4 buildAutoInjection 500-token cap

Qwen Code (4 silent bugs — wire identical at PAYLOAD level only)

  • Qwen-1 NEW hooks/core/platform-detect.mjs — env-var detection mirrors PLATFORM_ENV_VARS in src/adapters/detect.ts (single source of truth). Replaces hardcoded createToolNamer("claude-code") in hooks/sessionstart.mjs:22 → Qwen agents now see correct tool names instead of CC-prefix namespace
  • Qwen-2 configureAllHooks 2 → 5 hooks (was dropping PostToolUse, PreCompact, UserPromptSubmit)
  • Qwen-3 hooks/core/routing.mjs TOOL_ALIASES extended with Qwen native (write_file, edit, glob, todo_write, ask_user_question, list_directory, save_memory, skill, exit_plan_mode) + OpenClaw native (exec/read/grep/search) + Codex native (shell, local_shell, etc) — curl/wget/build redirects now work on all platforms
  • Qwen-4 src/session/extract.ts TOOL_NAME_NORMALIZE shim normalizes platform-native tool names → CC equivalents at extractEvents entry → no more silently-dropped events on Qwen

Kiro (3 P0)

  • Kiro-1 NEW hooks/kiro/userpromptsubmit.mjs — was declared in HOOK_TYPES but no script existed
  • Kiro-2 NEW hooks/kiro/agentspawn.mjs — Kiro's SessionStart-equivalent. Capability flipped to true, parser added, routing block injected via additionalContext

VSCode Copilot (1 P0 + 1 path bug)

  • A1 hooks.ts:98 path bug — was resolving to Claude-Code generic hooks/pretooluse.mjs instead of hooks/vscode-copilot/.... Plus created missing hooks/vscode-copilot/sessionstart.mjs (mirror of jetbrains-copilot pattern, captures .github/copilot-instructions.md as rule_content events)
  • Z13 HOOK_TYPES STOP/SUBAGENT_START/SUBAGENT_STOP orphan removed (declared but never had scripts). copilot-base made these optional

Cursor (3 P0)

  • C-1 sessionStart capability flag flipped true (script + dispatcher already existed, capability said false)
  • C-2 NEW hooks/cursor/afteragentresponse.mjs (74 lines, mirrors stop.mjs); was registered in HOOK_TYPES with no script (dangling)
  • C-3 Task-tool deferral comment (closed-source unknown, no probe data)

Gemini CLI (1 P1)

  • G-1 NEW hooks/gemini-cli/beforeagent.mjs — Gemini's UserPromptSubmit analog per refs/platforms/gemini-cli/packages/core/src/hooks/types.ts:580-602 + hookRunner.ts:215-228 (additionalContext appended to prompt)

Antigravity (1 P0)

  • A-1 configs/antigravity/GEMINI.md prepended trigger: always_on frontmatter — confirmed via refs/plugin-examples/antigravity/antigravity-kit/.agent/rules/GEMINI.md:1

Zed (1 LOW)

  • Z-1 configs/zed/AGENTS.md added "NEVER use ctx_execute/shell to create files" clause (was missing per CC routing-block.mjs:46-50)

Kilo (1 LOW)

  • K-1 src/adapters/opencode/index.ts paths() includes .kilocode/kilo.json and .kilocode/kilo.jsonc (Kilo runtime accepts these per refs/platforms/kilo/packages/.../config.ts:50,408)

Codex / JetBrains Copilot (0 P0)

Both confirmed at parity. Codex 33/33 catalog items verified — F1 fabrication confirmed (claim "hooks not registered" was wrong; all 5 already registered at src/adapters/codex/index.ts:244-276). JetBrains closed-source ceiling — mcp-jetbrains is pure stdio↔HTTP proxy with no IDE injection surface (F5 retraction).

9 fabrications retracted (honest discipline)

# Original claim Verified truth
F1 V1: "Codex hooks not registered, 10-line fix needed" Already at src/adapters/codex/index.ts:244-276, all 5 registered
F2 V1+V2: "GEMINI_PROJECT_DIR invented by us" REVERSEDgemini-cli/packages/core/src/hooks/hookRunner.ts:355 SETS it (plus 4 more env vars)
F3 V2: "Add KIRO_API_REGION to detection" Only in kiro-gateway test fixtures, NOT IDE source — detect.ts:76 comment was correct
F4 V1: "VSCode system priority injection exists" Only User/Assistant in chat API; systemMessage field is UI warning-only
F5 V1: "mcp-jetbrains exposes IDE injection" Pure stdio↔HTTP proxy
F6 V1: "OpenClaw closure-flag bad per community" Sample size 0 — actually fine per-register() singleton
F7 V1: "swarmvault is OpenClaw-specific MCP" Standard @modelcontextprotocol/sdk only
F8 V1: "pi/awesome-agent-skills shows routing patterns" Empty repo (4 scaffold files only)
F9 V1: "Zed has zero chat-influence APIs" REVERSEDslash_command + context_server_command traits CONFIRMED at extension.wit:151-160, wasm_host.rs:306-340/351-386

Plus during commit review: 10-file Kiro generic SDD scaffold (cc-sdd mirror) was caught as project-template content (NOT adapter wiring) and reverted.

Validation discipline

3-tier verification per gap:

  1. Code-driven grep against fresh --depth=1 clones in refs/platforms/
  2. Re-grep against community plugin examples in refs/plugin-examples/
  3. WebSearch + gh code search for closed-source platforms (Cursor, JetBrains AI Assistant, Antigravity, Kiro IDE)

Rejected approach: agent narrative claims (V1+V2 audits had 9 fabrications detected via this discipline). Phase 7 used 1 main + 13 parallel adapter agents reading line-by-line; Phase 8 used 9 parallel staff-engineer agents writing TDD red→green per slice.

Test counts (cumulative post-Phase-8)

  • 32/32 OpenCode (8 new + 8 updated cache-fold tests)
  • 95/95 OpenClaw (12 new)
  • 36/36 Pi (7 new)
  • 17 new Qwen + 165 regression
  • 49/49 Kiro
  • 32/32 Cursor (2 new)
  • 67/67 VSCode + Gemini (4 new)
  • 297/297 across 8 adapter test suites in main worktree
  • Full repo suite: 2268 pass / 9 fail (pre-existing baseline: opencode-adapter tsx subprocess infra issue, .cw worktree node_modules/tsx missing — verified pre-existing via stash)
  • TypeScript: clean

Out of scope (deferred — not v1.0.108 either, real follow-ups)

  • Companion VSIX extension for VSCode (CC12 / vscode.lm.registerMcpServerDefinitionProvider) — STABLE API, ready when prioritized
  • Zed wasm32 extension (CC10 / slash_command + context_server_command) — viable per code evidence, requires Rust+wasm32 build pipeline
  • JetBrains companion plugin via postStartupActivity — closed-source IDE testing required
  • Qwen 7 enhancement events (Stop / SubagentStart / SubagentStop / StopFailure / SessionEnd / PostToolUseFailure / PostCompact) — Qwen has 12 hooks vs CC's 5; we ship CC parity, the extras are pure upside
  • Cursor Task-tool integration — closed-source unknown, needs probe data

Contributors

  • Mickey @mikij — for retesting v1.0.106 and explicitly demanding "guarantee context-mode will be used by model". Without that pressure, we'd have shipped working-but-invisible routing for OpenCode/OpenClaw/Pi, and OpenClaw would still be telling agents to call ctx_* tools that didn't exist
  • #407 contributor — handle batch env prefix by shell (merged into v1.0.107)
  • Phase 7 + Phase 8 sub-agent army — 1 catalog + 13 line-by-line + 9 staff engineers + 2 architects executed the verification + implementation in parallel

Upgrade

npm update -g context-mode

Or use the in-product ctx_upgrade MCP tool. The version-check refresh shipped in v1.0.106 means long-running MCP sessions catch this release within an hour automatically.

What ships in this commit

39 files changed, +2613/-351 lines:

  • 6 new hook scripts (Cursor afteragentresponse, Gemini beforeagent, Kiro userpromptsubmit, Kiro agentspawn, VSCode sessionstart, OpenClaw mcp-tools)
  • 1 new shared module (hooks/core/platform-detect.mjs)
  • 13 modified adapter source files
  • 11 modified test files (all in EXISTING locations per CONTRIBUTING.md L275)
  • 4 rebuilt bundles (server.bundle.mjs, cli.bundle.mjs, hooks/session-extract.bundle.mjs, hooks/session-db.bundle.mjs)
  • 2 modified configs (Antigravity GEMINI.md frontmatter, Zed AGENTS.md clause)

Zero PRDs, zero clones, zero dev artifacts shipped. Code only.

Don't miss a new context-mode release

NewReleases is sending notifications on new releases.