session_start hook cannot inject context into the model (observer-only)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19.9k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 30
Description
Problem
jcode's session_start lifecycle hook is observer-only: per docs/HOOKS.md, observer hooks are "spawned detached, fire-and-forget" and their stdout is discarded. The only synchronous hook, pre_tool, can block a tool call (exit 2) but cannot inject prompt text either.
As a result, there is no way for an external hook to add per-session context into the model's prompt in jcode.
Claude Code, by contrast, lets a SessionStart hook return additionalContext that is injected into the conversation. Tools built on that pattern (e.g. the caveman skill's always-on activation hook, or any "inject git state / rotating rules / mode flag each session" hook) work in Claude Code but have no jcode equivalent.
Today the only jcode mechanism for per-session instructions is a static ~/AGENTS.md, which cannot be computed or made conditional per session.
Impact
- No dynamic/computed per-session context injection (git state, pending reviews, mode flags, rotating guidance).
- Cross-harness tools that rely on hook-injected context silently degrade to "static file only" on jcode.
Possible solution
Add an injecting hook path, opt-in and back-compat:
- Option A: let a new
session_contexthook's stdout (capped, e.g. 16 KB likeJCODE_HOOK_PAYLOAD) be appended to the session as system/context injection. - Option B: extend
session_startwith an opt-in mode where stdout is captured and injected, leaving the default observer behavior unchanged.
Keep the existing observer session_start semantics intact so nothing breaks; gate the new behavior behind a distinct config key.
Environment
- jcode (docs/HOOKS.md, master)
- Observed while wiring an always-on caveman-style context injection across Claude Code + jcode; only Claude Code could do it via hook.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/HOOKS.md to understand the current session_start observer semantics and the JCODE_HOOK_PAYLOAD size convention. Trace the session_start hook entry point, then implement an opt-in captured-output path that injects bounded context while preserving the default detached behavior; done means dynamic session context is available without breaking existing observer hooks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100