Repository navigation
Description
Overview
Build the thin extension shims that register @nodespace/agent-tools functions as native tools in each of the five supported PTY agents: Claude Code (hooks), Codex (plugin), Gemini CLI (tools directory), OpenCode (plugin), and Pi (registerTool()). Each shim is agent-specific glue code; the tool logic lives entirely in @nodespace/agent-tools.
Problem Statement
@nodespace/agent-tools exports the tool functions but agents cannot discover or call them automatically. Each agent has its own extension mechanism: Claude Code uses a hooks system, Gemini CLI reads from a tools directory, Pi has a registerTool() API, and so on. A shim per agent bridges the gap between the agent's native extension API and the shared tool package.
Proposed Solution
One shim per agent, each as minimal as possible. The shim's only job is to translate the agent's native tool-registration API into calls to @nodespace/agent-tools functions. No business logic lives in shims. The GraphContextAssembler writes the appropriate shim activation instructions into the context file (CLAUDE.md / AGENTS.md) at session start so the agent picks up the shim automatically.
Acceptance Criteria
Claude Code shim
- Hooks-based shim registered in
.claude/hooks/within the session temp directory - Agent sees
nodespace_search,nodespace_get_node,nodespace_create_node,nodespace_update_node,nodespace_get_childrenas native tools - Tool call from Claude Code reaches
nodespacedand returns a result
Codex shim
- Plugin shim installed in the Codex plugin directory for the session
- Same five tool names registered
- Tool call from Codex reaches
nodespacedand returns a result
Gemini CLI shim
- Tool definitions written to Gemini's tools directory for the session
- Same five tool names registered
- Tool call from Gemini CLI reaches
nodespacedand returns a result
OpenCode shim
- OpenCode plugin adapter installed for the session
- Same five tool names registered
- Tool call from OpenCode reaches
nodespacedand returns a result
Pi shim
-
registerTool()adapter calls made at session startup - Same five tool names registered
- Tool call from Pi reaches
nodespacedand returns a result
Cross-cutting
-
GraphContextAssemblerwrites shim activation instructions into context files for all five agents - Shim files are written into the session temp directory (not globally installed); cleaned up on session end
- All shims handle
ToolErrorfrom@nodespace/agent-toolsand surface it as a tool error to the agent - Code passes
bun run quality:fix
Technical Specifications
Shim location
Each shim lives in packages/agent-tools/shims/<agent-name>/:
packages/agent-tools/shims/
├── claude-code/
│ └── nodespace-hook.ts # Claude Code hooks shim
├── codex/
│ └── nodespace-plugin.ts # Codex plugin shim
├── gemini/
│ └── nodespace-tools.json # Gemini tool definitions + loader
├── opencode/
│ └── nodespace-plugin.ts # OpenCode plugin shim
└── pi/
└── nodespace-adapter.ts # Pi registerTool() adapter
Tool names (consistent across all agents)
nodespace_search_semantic
nodespace_get_node
nodespace_create_node
nodespace_update_node
nodespace_get_children
Claude Code shim pattern
Claude Code's hooks system allows registering tool handlers. The shim file is written to <session_dir>/.claude/hooks/nodespace.ts and activated via a CLAUDE.md directive:
// nodespace-hook.ts
import { searchSemantic, getNode, createNode, updateNode, getChildren }
from '@nodespace/agent-tools';
// Register via Claude Code hooks API
hook('nodespace_search_semantic', async ({ query, limit }) =>
JSON.stringify(await searchSemantic(query, limit)));
// ... repeat for other toolsGemini CLI shim pattern
Gemini reads tool definitions from a directory. The shim writes a JSON tool spec file plus a handler script to the session temp dir and sets the GEMINI_TOOLS_DIR env var before spawning:
// nodespace-tools.json
{
"tools": [{
"name": "nodespace_search_semantic",
"description": "Search the NodeSpace knowledge graph using natural language",
"parameters": { "query": { "type": "string" }, "limit": { "type": "number" } },
"handler": "./nodespace-handler.js"
}]
}Context file activation
GraphContextAssembler appends shim activation instructions to the context file. For Claude Code (CLAUDE.md):
## NodeSpace Tools
NodeSpace knowledge graph tools are available. Use them to search documentation,
create notes, and update the graph during this session.
Tools available: nodespace_search_semantic, nodespace_get_node, nodespace_create_node,
nodespace_update_node, nodespace_get_childrenFor other agents (AGENTS.md): equivalent section with tool names and brief descriptions.
Reference files
packages/agent-tools/src/tools.ts— tool function implementations (from Build @nodespace/agent-tools TypeScript gRPC client package #1122)packages/agent/src/acp/context_assembly.rs— context file writer (from Delete ACP transport and MCP server; adapt GraphContextAssembler to write context files #1117); needs updating to write shim files alongside context filespackages/agent/src/acp/registry.rs— agent catalog (from Delete ACP transport and MCP server; adapt GraphContextAssembler to write context files #1117)
Dependencies
- Build @nodespace/agent-tools TypeScript gRPC client package #1122
- Delete ACP transport and MCP server; adapt GraphContextAssembler to write context files #1117
- Implement PtySessionManager and PtySession in packages/agent #1118
Non-Goals
- Tool schema evolution or versioning (shims always use the current
@nodespace/agent-toolsversion from the running daemon install) - Supporting agent versions other than current stable releases
- Shim auto-update (shims are written fresh per session from the installed package)
Activity
malibio commentedon May 18, 2026
Frontend: 17 agent-tools tests passed (tools.test.ts: 12, client.test.ts: 4, connection-error.test.ts: 1). TypeScript: clean in agent-tools and desktop-app.
Address review: populate shims, fix preinstall, fix installer bugs
Add @nodespaceai/skill npm package (closes #1184) (#1191)
Implement per-agent extension shims for all five PTY agents (#1123) (#…
Add @nodespaceai/skill npm package (closes #1184) (#1191)