Skip to content

feat(cli): carry a session-start answer to the model on opencode and kilo - #1354

Closed
blafourcade wants to merge 6 commits into
nextfrom
feat/session-start-context-opencode-kilo
Closed

blafourcade wants to merge 6 commits into
nextfrom
feat/session-start-context-opencode-kilo

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

SessionStart context never reached the model on OpenCode and Kilo: the bridges ran the hook with its output ignored. This wires the hook's additionalContext into the system prompt on both hosts. Partial work on #1348, which stays open.

🛠️ How it works

  • Both bridges read SessionStart's additionalContext (exit 0 stdout, same answerFrom as PostToolUse) and push it onto output.system through experimental.chat.system.transform.
  • OpenCode: applied once per server at init, since no session id is available there.
  • Kilo: applied per session, from the session.created run, and only to that sessionID.
  • The fire-and-forget runHook (stdio ignored) is removed from both bridges.
  • Kilo answerOf: a spawn failure emitted two warnings (error and close). It now reports once. The existing "SessionStart spawn failure" test caught this once SessionStart moved onto answerOf.
  • Probe: OpenCode 1.19.3 (opencode/big-pickle) and Kilo 7.7.5 (kilo/kilo-auto/free) in a throwaway HOME. Text pushed onto the V1 output.system reached the model on both. Vendor types checked in @opencode-ai/plugin and @kilocode/plugin dist/index.d.ts. Fixtures are captured verbatim from the probe, scrubbed of paths and session id.
  • Why V1: it is the API the probe proved on both hosts, so no design decision is pending.

🧪 How to verify

  • cd cli && pnpm exec vitest run tests/contexts/tools/hooks-runtime-bridges.integration.test.ts
  • Mutations, each red on its named test only: drop the if (context) guard, drop the OpenCode push, look up the last session's context instead of input.sessionID (test "leaves another session's system prompt alone"), remove the Kilo failed guard.
  • Gates on 7c8f709f1: make validate 0, pre-commit --all-files 0, cli pre-push 0 (9907 passed, 1 expected fail, 15 skipped), pnpm build 0. Bundle 879.0 KB / 897 KB.

⚠️ Heads-up

Goldens moved, all because the generated bridge text changed:

  • tests/fixtures/hooks-routes/{kilo,opencode}/ flat-translate, plugin-install, plugin-install-twice, plugin-remove, setup-plugins-reinstall (10 files)
  • cli/tests/golden/snapshots/framework-build/golden.json and translate-install/golden.json (opencode and kilo aidd-context-hooks.js hashes)
  • cli/type-assertions-baseline.json: hooks-runtime-bridges.integration.test.ts lowered 10 to 8 (typed captured<T> removed casts)

Limits, stated and not coded:

  • V2 path (ctx.session.instructions) is not probed or wired. The V2 adapter exposes no system hook.
  • On OpenCode the pushed text also reaches the title-generation call of the same session, since the plugin cannot tell callers apart.
  • A SessionStart script delays the first model call until it ends (5 s spawn timeout).
  • Only Kilo 7.7.5 is probed on this path.
  • A plugin recreated by the host re-runs SessionStart on OpenCode, as before.
  • Docs: cli/docs and aidd_docs/memory/internal/cli do not exist on origin/next, so the only docs are the bridge doc comments and the fixture README. docs/COMPATIBILITY.md is untouched.

🔗 Linked issue

Refs #1348

✅ I certify

  • I DO CERTIFY I READ EACH LINE OF THE PULL REQUEST BECAUSE I AM A SOFTWARE ENGINEER, NOT A AI PUPPY.

🤖 Generated with Claude Code

blafourcade and others added 5 commits November 25, 2026 14:55
…kilo

The OpenCode and Kilo bridges ran SessionStart with its output ignored.
Probed on OpenCode 1.19.3 and Kilo 7.7.5: text pushed onto the V1
experimental.chat.system.transform output reaches the model. The bridges
now read the hook's additionalContext and add it to the system prompt,
per server on OpenCode and per created session on Kilo.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bridges

One generated capture spawns the script, collects its output and settles to a failure instead of rejecting. Both hosts build answerOf, stopReasonOf, the failure warning, the follow-up warning and the PostToolUse call mapping on it, so only the host name and whether a failed script is reported stay per host.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…code and kilo bridges

Both host templates now pass only a session id and a directory; the payload,
the run and the join live in the shared bridge, as does the dispatch warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…session-start hand-over

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ge reports

The Stop call builder moves to the shared event bridge like SessionStart and PostToolUse,
the dispatch warning is written only for the host that uses it, the host flag is named for
what it decides, and the call builders nobody read are no longer exposed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@blafourcade

Copy link
Copy Markdown
Contributor Author

Superseded by #1378, which consolidates the five OpenCode and Kilo bridge branches into one shared runtime (V1 and V2) and is merged on next.

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