Repository navigation
Description
Overview
The Claude Code plugin watches the item a session is working on and refuses tool calls when that item changes under the session. To do that it has to know whether the session itself made a change. Today it guesses by parsing the agent's shell lines. This issue replaces the guess with a record the CLI keeps, and makes a deleted item distinguishable from a failed read.
Problem Statement
- The plugin reads each Bash command to decide whether it may have written to NodeSpace (
nodespaceInvocations,mayWrite,isReadin the hooks module). A write it cannot see is read as someone else's change and stops the session: a write inside a script (./scripts/finish-task.sh), or by a command left running in the background. - In a session with nobody at the prompt, a false stop ends the work, since tool calls stay refused until the user replies.
- After any command that may write, the plugin re-reads the item and takes it as the baseline. A change someone else makes while that command runs is absorbed.
- A context read of a deleted node fails with
Error: Not found: <id>on stderr and exit 1, the same exit as an unreachable daemon. The plugin treats every failed check as "say nothing", so a deleted item never stops the session.
Proposed Solution
A write journal kept by the CLI.
- The plugin sets one environment variable at session start that names the session. Every command the harness starts inherits it.
- A
nodespacecommand that writes a node while the variable is set appends{node_id, version}to that session's journal: a file on this machine under the NodeSpace home, holding ids and versions and no content. - When the watched item's own version differs from the one last seen, the plugin reads the journal. A version the journal holds is the session's own; any other is a change made under it.
- The journal is removed when the session ends, and a stale one is removed by the next session start.
The shell-line parsing that exists only to attribute writes (mayWrite, isRead, the forced check before a write, the re-read after one) is deleted. Reading the shell line to learn which item the session is working on, and which skills it fetched, stays.
A deleted item. node context <id> --version-only --json on a node that does not exist prints {"error": "not_found", "node_id": "<id>"} and exits non-zero, in the shape version_conflict already uses. The plugin treats that as the item changing under the session. Any other failure still blocks nothing.
Core records nothing about who changed a node: the journal is the CLI's own file, outside the database.
Documentation
- Prompt and Skill System, Harness plugins - the journal and the deleted-item rule this issue implements
- ADR-093 §5 - what the plugin does during a turn; Consequences - plugins are thin, the CLI operations are a contract
- ADR-081 - why the record is a local CLI file and not a field on the node
- ADR-053 - the journal entry names the database the write went to
- Updates:
packages/skill/references/cli.md(the not-found output of a context read),packages/skill/README.md(the paragraph on writes the plugin cannot see)
Architecture Impact
Extends ADR-093 §5 item 4 without changing it: the plugin still compares the context version and refuses tool calls when the item changed under the session. Only how it attributes a change moves, from the plugin to the CLI. No decision is reversed and no ADR change is needed.
Acceptance Criteria
- The plugin sets a session-naming environment variable at session start, and again after a
/clear - Every CLI command that changes a node's version appends the node id, the database and the new version to the session's journal when the variable is set, and writes nothing when it is not set
- 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, with a test for each through the journal
- A change made by another process while the session's own write is running is still reported
- The plugin holds no list of read or write commands, and makes no extra CLI call before or after the agent's own commands
- The journal holds ids and versions only, lives under the NodeSpace home, and is removed at session end; a journal left by a crashed session is removed at the next session start
- A failed journal read or write never fails the agent's command and never blocks a tool call
- A context read of a missing node prints
{"error": "not_found", "node_id": ...}with--jsonand exits non-zero - The plugin refuses tool calls when the watched item no longer exists, and still says nothing when the read failed for any other reason
-
packages/skill/README.mdno longer says a write inside a script stops the session -
bun run --cwd packages/skill test:pluginpasses - Code passes
bun run quality:fix - Tests pass (
bun run test:changed)
Technical Specifications
Reference Files
packages/skill/plugins/claude-code/hooks/register.ts-mayWrite,isRead,beforeTool,learn,checkItempackages/skill/plugins/claude-code/tests/register.test.ts- the item-watch tests, which run underclaude plugin testpackages/cli/src/commands/- the write commands (node update,set-status,move,delete,batch-update,create), andnode contextpackages/cli/src/output.rs-print_node_context_version, and theversion_conflicterror shape to followpackages/daemon/src/lib.rs- how the NodeSpace home is resolved (NODESPACE_HOME)
Implementation Details
- The plugin API gives
$.env.set(name, value)with a literal name,$.session.id(), and$.fsfor reading the journal. No Node API is available in the hooks module. - A write's new version is in the response every write command already prints, so the CLI needs no extra request to journal it.
- Append one line per write; a reader takes the last entry for a node id. Appends from concurrent commands must not corrupt a line.
- The plugin's check stays one
--version-onlycall per interval. It reads the journal only when the version differs.
Related Issues
- Ship a Claude Code plugin that lists NodeSpace's skills in the session and tracks changes; slim the static skill and remove the tool shims #3545 (the plugin this changes)
- Ship Pi and OpenCode plugins that list NodeSpace's skills in the session, and an instructions block for harnesses without one #3546 (the Pi and OpenCode plugins need the same attribution)
- Run NodeSpace-launched agent sessions in the project's checkout with the session plugin, and delete the context assembler #3547 (NodeSpace-launched sessions, where a false stop has nobody to answer it)
Non-Goals
- Recording who changed a node in the database
- Handing the system prompt section to subagents
Activity
malibio commentedon Oct 5, 2026
A second copy of this logic now exists
#3546 shipped a Pi extension and an OpenCode plugin. They share one module,
packages/skill/plugins/shared/nodespace-session.ts, which is a port of the Claude Code plugin's watch: it holds its ownnodespaceInvocations,mayWriteandisRead, the forced check before a write and the re-read after one. Everything this issue says of the Claude Code plugin's shell-line reading is true of that module too.Two things for whoever takes this:
session_start; OpenCode has ashell.envhook for the commands it runs).finallyinregister.ts) and a counter of baseline moves made by its own writes. The journal makes all of it unnecessary, in both files. The shared module's tests for those cases are inpackages/skill/src/tests/plugin-session.test.ts.The deleted-item rule applies to the shared module as it stands: its
checkItemalso says nothing when a read fails.malibio commentedon Oct 6, 2026
Frontend: 5880 passed
Record a session's own writes in a CLI journal so the Claude Code plu…