Repository navigation
Description
Overview
A session NodeSpace launches is meant to be the same in every harness that has a plugin. The Claude Code plugin opens such a session with the context of the task it was launched for, and reports the harness's own session id back to NodeSpace. The Pi extension and the OpenCode plugin do neither. This issue adds both to the module they share. It also moves the module's way of telling a session's own writes from someone else's onto the write journal the CLI keeps, as the Claude Code plugin now does.
Problem Statement
- A session launched for a task in Pi or OpenCode starts with the orientation and the skill list only. The agent has to be told which task it is for, or find it, although the launch already named it in
NODESPACE_LAUNCHED_FOR. - That task is not watched until the agent happens to read its context, so a change to it under the session is not noticed before then.
- Neither plugin reports the harness's session id, so the session's
ai-chat-ptynode ends with an emptysession_idand the conversation cannot be resumed from NodeSpace. NODESPACE_SESSIONandNODESPACE_LAUNCHED_FORstay in the environment of every process the agent starts. A second harness started from the agent's shell would take itself for the launched session.- The shared module still reads the agent's shell lines to guess whether a command wrote (
mayWrite,isRead, a count of writes in flight and of moves the session made). A write it cannot see, from a script or a command left running in the background, is read as someone else's change and stops the session, and in a session with nobody at the prompt that ends the work. A write made while a command runs is also absorbed into the baseline. - A context read of a deleted item fails like an unreachable daemon, so a deleted item never stops the session.
Proposed Solution
Do in packages/skill/plugins/shared/nodespace-session.ts what the Claude Code plugin does in plugins/claude-code/hooks/register.ts (readLaunch, takeOpening, dropLaunchVariables, and the session report-harness-session call), through the same harness-neutral interface the module already has:
- At session start read the launch from the environment. When there is one, report the harness's own session id with
nodespace session report-harness-session <id>, and report it again when the harness starts a new conversation in the same process. - When the launch named a task, read that task's context once and hand it to the agent with its first prompt, marked as graph data. The task becomes the item the session watches.
- A launch for the session's own chat node opens with nothing.
- Keep the launch variables out of what the agent starts, where the harness lets a plugin set the environment of the commands it runs.
- Attribute writes through the CLI's journal, as the Claude Code plugin does (Record a session's own writes in a CLI journal so the Claude Code plugin stops reading shell lines, and report a deleted item apart from a failed read #3642). Set
NODESPACE_WRITE_JOURNALto the harness's session id in the same command environment as step 4, and again when a new conversation starts. When the watched item's version differs from the one last seen, read<NodeSpace home>/.nodespace/journals/<session>.jsonl: a version it holds for the item is the session's own, any other is a change under the session, and a journal that cannot be read reports nothing.nodespace node context <id> --version-only --jsonprinting{"error": "not_found", ...}is a deleted item and stops the session; any other failed read still says nothing. Runnodespace journal end <session>at session start and end. DeletemayWrite,isRead, the forced check before a write, the re-read after one, and the in-flight and moves counters; reading the shell line to learn which item is worked on stays.
Each harness file supplies what the module cannot know: the harness's session id, and how a first-prompt message and a command environment are set there.
Documentation
- ADR-093 §8 - what a launched session gets: the database and launched-for values, and the plugin reporting the harness's session id; §5 - what every plugin does
- Agent Session, How a Session Gets NodeSpace's Context - the opening context and the watch; Environment - the four variables; Session Resumption - the reported id
- Prompt and Skill System, Harness plugins - the behaviour the plugins share
- Updates:
architecture/agent-session.md(the per-harness delivery table: which harness opens with the launched task and reports its session id),packages/skill/README.md(the Pi and OpenCode table)
Architecture Impact
Implements ADR-093 §8 for two more harnesses. No decision is reversed and no ADR change is needed.
Acceptance Criteria
- In a Pi session and in an OpenCode session launched by NodeSpace,
nodespace session report-harness-sessionis run once at session start with that harness's own session id, and again when a new conversation starts in the same process - A session started from a terminal (no
NODESPACE_SESSION) reports nothing - A session launched for a task receives that task's context with its first prompt, once, inside the graph-data marker, and nothing on later prompts
- The launched task is the watched item from the first prompt: a change to it under the session refuses the next tool call, with no context read by the agent in between
- A session launched for its own chat node opens with nothing and watches nothing
- A launched task that cannot be read adds nothing and blocks nothing
-
NODESPACE_SESSIONandNODESPACE_LAUNCHED_FORdo not reach a command the agent runs, in each harness where a plugin can set that; where it cannot, the README says so - Each plugin sets the session-naming variable where the harness lets it set a command's environment; where it cannot, the README says that a write from a script is read as someone else's
- A write made from a script, from a loop and from a command left running in the background is recognised as the session's own through the journal, with a test for each; a change made by another process while the session's own write is running is still reported
- The shared module holds no list of read or write commands and makes no extra CLI call before or after the agent's own commands; a failed journal read or write never blocks a tool call
- The watched item no longer existing refuses tool calls, and a read that failed for any other reason says nothing
- The behaviour lives in the shared module, with tests in
packages/skill/src/tests/plugin-session.test.tsover the fake CLI for each criterion above - Each plugin still type-checks against its harness's published types (
bun run --cwd packages/skill quality:check) - Each plugin is run once in its harness with the launch variables set, and the PR says what was seen
- Docs updated as listed under Documentation
- Code passes
bun run quality:fix - Tests pass (
bun run test:changed)
Technical Specifications
Reference Files
packages/skill/plugins/claude-code/hooks/register.ts-readLaunch,dropLaunchVariables,takeOpeningand thereport-harness-sessioncall: the behaviour to matchpackages/skill/plugins/shared/nodespace-session.ts-createSession, itsHostinterface andstart/prompt: where it goes;mayWrite,isReadand the write counters: what the journal replacespackages/skill/plugins/claude-code/hooks/register.ts-nameSession,readJournal,endJournal,isDeleted,refuse: the journal behaviour to matchpackages/cli/src/journal.rs- the journal's file format and thejournal endcommandpackages/skill/plugins/pi/index.ts,packages/skill/plugins/opencode/nodespace.ts- the harness filespackages/skill/src/tests/plugin-session.test.ts- the fake CLI and the fake Pi and OpenCode inputspackages/skill/README.md- "The Pi extension and the OpenCode plugin", including how to try one in its harness
Implementation Details
- The harness's session id: Pi's
ctx.sessionManagerinsession_start(which also fires withreasonnew,resumeandfork); OpenCode'ssession.createdevent carriesinfo.id, and a resumed session is first seen in another hook. Verify both against the current published types before writing. - The first-prompt hand-over can use what each file already uses for the skill-list note: the message returned from Pi's
before_agent_start, and the text part pushed in OpenCode'schat.message. - OpenCode has a
shell.envhook that sets the environment of the commands it runs. Check whether Pi offers the same before deciding how steps 4 and 5 are met there. Without a way to set it, a Pi session's writes cannot be journaled and the shell-line guess cannot be kept as a fallback (no dual mode): the plugin then reports no change as its own and the README says so. - The journal's path is
<NodeSpace home>/.nodespace/journals/<session>.jsonl, with the home fromNODESPACE_HOME, else the user's home. It holds ids and versions only. The session id must match[A-Za-z0-9_-]{1,128}, as the CLI refuses any other. - OpenCode serves several sessions from one plugin instance, child sessions among them. Only the session the launch started is the launched one.
- The Claude Code plugin keeps the launch in session state so a
/clearstill knows it. The shared module keeps its state in the closurecreateSessionreturns; decide what survives Pi'ssession_startwith reasonnew.
Dependencies
- Ship Pi and OpenCode plugins that list NodeSpace's skills in the session, and an instructions block for harnesses without one #3546 (the two plugins and their shared module)
- Run launched agent sessions in the project's checkout with the session plugin; delete the context assembler #3647 (the Claude Code plugin's launched-session behaviour, and the CLI command)
Related Issues
- Record a session's own writes in a CLI journal so the Claude Code plugin stops reading shell lines, and report a deleted item apart from a failed read #3642 (the CLI's write journal and the Claude Code plugin's use of it, merged: this module does the same)
Non-Goals
- Launched-session behaviour for Codex and Antigravity, which have no plugin
- Changing what the Claude Code plugin does
Activity
[-]Open launched Pi and OpenCode sessions with the launched task's context, and report their harness session id[/-][+]Open launched Pi and OpenCode sessions with the launched task's context, report their harness session id, and attribute their writes through the CLI journal[/+]malibio commentedon Oct 7, 2026
Frontend: 5863 passed
Open launched Pi and OpenCode sessions with the task's context, repor…