Water Code is a clean-room terminal coding agent project built from architecture research on Claude Code, but intentionally re-designed as a simpler, zero-dependency Node MVP.
Detailed Chinese usage guide:
docs/user-manual-zh.mddocs/github-publish-guide.mddocs/github-release-v0.1.0.md
The first version focuses on the core loop:
- CLI entrypoint
- interactive REPL
- session persistence
- agent loop
- tool registry
- pluggable providers
- explicit permission handling for dangerous tools
This repo does not try to clone every advanced subsystem on day one. It starts with a practical minimal core that can grow into a larger product.
The research showed that the most durable Claude Code idea is not any single hidden feature. It is the product skeleton:
main -> commands/tools -> REPL -> query loop -> state/extensions
Water Code uses that skeleton as inspiration while keeping the first implementation much smaller and easier to evolve.
Current MVP includes:
- one-shot or interactive CLI
- first-class slash commands
- project context loading
- git-aware project state and worktree awareness
- formal JSON tool-calling protocol
- diff preview and exact patch editing
- structured tool result rendering
- richer permission modes
- approval history and remembered approvals for dangerous tools
- project custom commands
- project custom agents
- project skills
- project plugins
- project-level
WATER.mdinstructions - local MCP server loading
- sequential multi-agent orchestration
- background tasks
- local HTTP bridge surface
- bridge request timeouts and stream heartbeats
- provider abstraction
- planner provider for local testing
- optional Anthropic-backed provider via environment variables
- tools:
list_filesread_filegit_statusgit_worktreespreview_diffpatch_filewrite_filelist_background_tasksget_background_taskstart_background_taskcancel_background_taskbash
- session storage in
.water-code/sessions
cd water-code
npm startInstall / package options:
npm link
water-code --version
water-code --init
water-code --onboard
water-code --doctor
water-code --json --doctor
water-code --json --stream -p "read README.md"
water-code adapter state
water-code adapter project --input ../other-project
water-code adapter prompt --input "read README.md"
npm run package
npm install -g ./dist/water-code-0.1.0.tgz
npm run real-world-smoke
npm run release-check
npm run ship-checkIf you want to verify the packaged tarball really installs and runs:
npm run package-smokeTo bootstrap Water Code into a project:
water-code --cwd /path/to/project --init
water-code --cwd /path/to/project --init --force
water-code --cwd /path/to/project --onboardOne-shot examples:
node ./bin/water-code.js --provider planner -p "list files in src"
node ./bin/water-code.js --provider planner -p "git status"
node ./bin/water-code.js --provider planner -p "read README.md"
node ./bin/water-code.js --permission-mode accept-edits -p "/patch README.md ::: old >>> new"
node ./bin/water-code.js --yolo --provider planner -p "run pwd"
node ./bin/water-code.js --bridge --provider planner --bridge-port 8765
node ./bin/water-code.js --remote-url http://127.0.0.1:8765 --doctor
node ./bin/water-code.js --json --provider planner -p "read README.md"
node ./bin/water-code.js --json --stream --provider planner -p "read README.md"
node ./bin/water-code.js adapter state
node ./bin/water-code.js adapter prompt --provider planner --stream --input "read README.md"Interactive slash command examples:
/help
/mcp
/mcp-call local_echo echo_note ::: {"note":"hi"}
/commands
/readme-snapshot
/plugins
/plugin-status
/skills
/skill repo-cartographer,safe-editor
/agents
/agent reviewer
/delegate reviewer ::: read README.md
/swarm reviewer,architect ::: read README.md
/tasks
/task-run "repo scan" ::: read README.md
/task-show wctask-...
/permissions
/approvals
/onboard
/doctor
/init
/sessions
/session new
/project
/project ../other-project
/worktree-use feature/review
/git
/worktrees
/context
/instructions
/ls src --depth 1
/read README.md --lines 60
/diff README.md ::: # Water Code\n\nA smaller terminal agent.
/patch README.md ::: Water Code >>> Water Code MVP
/run pwd
/write notes.txt ::: first draft
Use Anthropic if you have credentials:
export ANTHROPIC_API_KEY=...
export WATER_CODE_ANTHROPIC_MODEL=...
node ./bin/water-code.js --provider anthropicThe Anthropic provider now uses native Claude tool use instead of forcing the JSON protocol path, so the same Water Code tools are exposed as first-class Claude tools when credentials are present.
Smoke check:
npm test
npm run verify
npm run package
npm run package-smoke
npm run smoke
npm run bridge-smoke
npm run provider-smoke
npm run vscode-shim-smokenpm run verify covers npm test, npm run smoke, npm run provider-smoke, and npm run vscode-shim-smoke. Add -- --bridge when you also want the localhost bridge smoke run.
The bridge now reports timeout metadata on /health, emits stream.heartbeat events during streamed prompts, and exposes explicit remote session recovery surfaces through /sessions.
For final release readiness:
npm run package-smoke: validate install-from-tarball behaviornpm run real-world-smoke: validate Water Code against a temporary Git repo and worktree workflownpm run release-check: validate release docs, versioning, and packaged file contentsnpm run ship-check: run the recommended release gate end-to-end
docs/water-code-blueprint.md: product blueprint and architecture roadmapdocs/release-playbook.md: release checklist and shipping guidancedocs/github-publish-guide.md: step-by-step GitHub publishing guidedocs/github-release-v0.1.0.md: GitHub Release notes template for v0.1.0docs/user-manual-zh.md: detailed Chinese user manualCHANGELOG.md: shipped release notesLICENSE: MIT license for source distribution.water-code/commands/: project custom command templates.water-code/agents/: project custom agent templates.water-code/skills/: project skill templates.water-code/plugins/: project plugin modulesWATER.md: optional project-level instructions loaded into the system prompt.water-code/tasks/: background task metadata and logs.water-code/mcp.json: project MCP server configsrc/cli/: argument parsing and REPLsrc/commands/: slash command layersrc/core/: agent loop and runtime assemblysrc/core/git-state.js: Git branch, dirty state, and worktree inspectionsrc/bridge/: local HTTP bridge servereditor/vscode-water-code/: minimal VS Code shim built on the adapter contractsrc/plugins/: project plugin loading and prompt renderingsrc/skills/: project skill loading and prompt renderingsrc/tasks/: background task store and workersrc/provider/: provider adapterssrc/tools/: local tool implementationssrc/session/: session persistencescripts/smoke.js: local regression smoke checksscripts/bridge-smoke.js: bridge regression smoke checksscripts/verify.js: combined verification entrypointscripts/package.js: create an installable tarball indist/scripts/package-smoke.js: install the tarball into a temp prefix and verify the CLI startsscripts/real-world-smoke.js: validate Water Code against a temporary Git-backed projectscripts/release-check.js: validate release metadata, docs, and tarball contentsscripts/ship-check.js: run the full release-readiness gate
Tool results are now normalized into title + summary + sections before rendering, so direct commands and model-driven tool loops share the same terminal presentation.
Water Code now includes a minimal VS Code integration shim in editor/vscode-water-code.
It intentionally stays thin:
- VS Code commands shell out to
water-code adapter ... - streamed prompts use the adapter's line-delimited JSON event mode
- local or remote runtimes are chosen by normal Water Code settings, not a separate editor-only protocol
The shim exposes these commands:
Water Codeexplorer panel with project, git, session, extension, and runtime stateWater Code: Refresh PanelWater Code: Project StateWater Code: DoctorWater Code: OnboardWater Code: Rewrite SelectionWater Code: Resume SessionWater Code: New SessionWater Code: Clear SessionWater Code: Prompt SelectionWater Code: Prompt InputWater Code: Open Output
For content changes, the safer path is now:
/readto inspect the file/diffto preview a full replacement/patchfor an exact snippet replacement/writeonly when you truly want a direct overwrite
ask: prompt before dangerous tools when interactive; deny them in one-shot modeaccept-edits: auto-allow edit tools likewrite_fileandpatch_file, but still gate shell commandsread-only: block all dangerous toolsyolo: allow all dangerous tools without confirmation
Use /permissions in the REPL to inspect or change the current mode, or start directly with --permission-mode.
Water Code now loads project command templates from .water-code/commands/.
Commands are loaded from the active project root, so cd water-code first or pass --cwd water-code if you launch from a parent directory.
- each
.mdor.txtfile becomes a slash command named after the filename - optional frontmatter keys:
descriptionargumentHint
- template placeholders:
{{args}}{{cwd}}{{project_summary}}{{permission_mode}}
Built-ins:
/commands: list loaded custom commands/refresh-commands: reload them from disk
Example:
---
description: Review the current project with an optional focus.
argumentHint: [focus]
---
Summarize this repository for an engineer joining the project.
Project context:
{{project_summary}}
Extra focus:
{{args}}That file saved as .water-code/commands/project-brief.md becomes /project-brief.
Water Code also loads reusable project personas from .water-code/agents/.
- each
.mdor.txtfile becomes an agent named after the filename - the file body is injected into the system prompt when that agent is active
- placeholders supported in agent files:
{{cwd}}{{project_summary}}{{permission_mode}}
Built-ins:
/agents: list loaded agents/agent [name|none]: show or switch the active agent/refresh-agents: reload them from disk
You can also start directly with --agent reviewer.
Water Code now loads project skills from .water-code/skills/.
- skills are reusable instruction blocks that can be activated together
- active skills are injected into the system prompt alongside the current agent
- each
.mdor.txtfile becomes a skill named after the filename - optional frontmatter keys:
descriptionwhenToUse
- placeholders supported in skill files:
{{cwd}}{{project_summary}}{{permission_mode}}{{active_agent}}{{active_skills}}
Built-ins:
/skills: list loaded skills/skill [name[,name2,...]|none]: show or switch the active skill set/refresh-skills: reload them from disk
CLI:
node ./bin/water-code.js --skill repo-cartographer --skill safe-editorWater Code now loads WATER.md from the project root, or .water-code/WATER.md as a fallback.
- project instructions are injected into the system prompt before tool use
/instructionsshows the currently loaded file/refresh-instructionsreloads it from diskWATER.mdis also surfaced through the bridge state payload
Water Code now loads project plugins from .water-code/plugins/.
- plugins are JavaScript modules that can extend Water Code with commands, tools, and prompt blocks
- loaded plugins are active immediately for the current project root
- plugin commands appear in
/helpalongside built-ins and custom commands - plugin tools are bridged into the normal tool registry
Built-ins:
/plugins: list loaded plugins/refresh-plugins: reload them from disk
The repo includes a working sample in workspace-tools.js.
Water Code can now run prompts and slash commands as detached background jobs.
- tasks are stored under
.water-code/tasks/ - each task keeps JSON metadata plus stdout and stderr logs
- tasks run through the normal Water Code runtime, so they still use the selected provider, agent, skills, permissions, tools, plugins, and MCP setup
- task control is available both through slash commands and through model-driven tool calls
Built-ins:
/tasks: list recent tasks/task-run [label] [--agent name] [--skills a,b] ::: <prompt>: start a detached task/task-show <id> [--lines N]: inspect one task and tail its logs/task-cancel <id>: stop a running task
Planner examples:
node ./bin/water-code.js --provider planner -p "list background tasks"
node ./bin/water-code.js --provider planner --yolo -p "start background task ::: read README.md"
node ./bin/water-code.js --provider planner -p "show background task wctask-..."Water Code can now run prompts through multiple custom agents without changing the main active agent.
/delegate <agent> ::: <prompt>runs one isolated delegated turn/swarm <agent1,agent2,...> ::: <prompt>runs the same prompt through multiple agents in sequence and collects their outputs- each delegated run gets its own session id, which is included in the output
This is intentionally a small sequential orchestration layer, but it already supports real reviewer/architect style workflows.
Water Code now loads local stdio MCP servers from .water-code/mcp.json.
- the active project root decides which MCP config is loaded
- config is project-scoped, just like custom commands and agents
- discovered MCP tools are bridged into the normal Water Code tool registry
- built-ins:
/mcp: list configured servers and discovered tools/refresh-mcp: reconnect servers and reload tools/mcp-call <server> <tool> ::: <json>: call a discovered MCP tool directly
The repo includes a working sample in example-mcp-server.js and config in .water-code/mcp.json.
Water Code now exposes a small local HTTP bridge for remote control and editor integration.
- start it with
node ./bin/water-code.js --bridge - it binds to
127.0.0.1by default - use
--bridge-hostand--bridge-portto change the listen address - the bridge shares the same runtime, tools, MCP connections, custom commands, custom agents, skills, plugins, and background task state as the terminal session
Current endpoints:
GET /health: simple liveness checkGET /state: runtime snapshot including tools, agents, skills, plugins, commands, background tasks, and MCP serversGET /project: concise project snapshot with cwd, git, and instruction previewGET /doctor: structured self-check report for the active runtime and projectGET /git: current Git branch, dirty state, and sync summaryGET /worktrees: known Git worktrees for the current repositoryGET /onboard: recommended next steps for the current project and runtime stateGET /sessions: list saved sessions with recent summariesPOST /sessions: create a new active session, switch the active session, or clear itGET /sessions/:id: inspect one saved session and return a tail of its transcriptPOST /init: create Water Code starter files in the active project rootPOST /project: switch the active project root bycwd/path, or byworktreePOST /prompt: run a normal user prompt through the agent loopPOST /prompt/stream: stream prompt lifecycle events over SSEPOST /command: execute a slash commandPOST /tool: call a tool directly
Remote client notes:
water-code --remote-url http://127.0.0.1:8765 --doctorruns the same report through an existing bridgewater-code --remote-url http://127.0.0.1:8765 --onboardprints project onboarding from the remote runtimewater-code --remote-url http://127.0.0.1:8765 --inittriggers scaffold creation remotelywater-code --remote-url http://127.0.0.1:8765 -p "/project"shows the remote runtime's current project rootwater-code --remote-url http://127.0.0.1:8765 -p "/plugins"runs a slash command against the bridgewater-code --remote-url http://127.0.0.1:8765 -p "read README.md"sends a normal prompt to the remote runtime- add
--jsonto any of those one-shot calls for a machine-readable envelope that editors can parse directly - add
--streamwith--jsonand a normal prompt to receive line-delimited prompt events for adapter use
Adapter notes:
water-code adapter statereturns the current runtime snapshot as JSONwater-code adapter project --input ../other-projectswitches the active runtime project and returns the new statewater-code adapter doctorreturns the doctor report as JSONwater-code adapter onboardreturns onboarding guidance as JSONwater-code adapter init --forceruns scaffold creation and returns the report as JSONwater-code adapter prompt --input "read README.md"runs one prompt and returns a single JSON envelopewater-code adapter prompt --stream --input "read README.md"emits line-delimited JSON events for editor integrations- add
--remote-url http://127.0.0.1:8765to point the same adapter contract at an existing bridge runtime
Bridge session notes:
POST /promptaccepts an optionalsessionId- set
"activate": falseto run against that session without changing the bridge runtime's current active session - bridge state now includes
recentSessionsandgitso an editor or client can resume prior conversations with repository context
Example:
node ./bin/water-code.js --bridge --provider planner --bridge-port 8765
curl http://127.0.0.1:8765/health
curl http://127.0.0.1:8765/doctor
curl http://127.0.0.1:8765/onboard
curl http://127.0.0.1:8765/state
curl http://127.0.0.1:8765/project
curl http://127.0.0.1:8765/sessions
curl -X POST http://127.0.0.1:8765/project -H 'content-type: application/json' -d '{"cwd":"."}'
curl -X POST http://127.0.0.1:8765/prompt/stream -H 'content-type: application/json' -d '{"prompt":"read README.md"}'
curl -X POST http://127.0.0.1:8765/sessions -H 'content-type: application/json' -d '{"create":true}'
curl -X POST http://127.0.0.1:8765/command \
-H 'content-type: application/json' \
-d '{"command":"/commands"}'- zero external runtime dependencies for the first working version
- honest permission model
- explicit provider boundary
- small tool surface first
- architecture that can later support commands, extensions, and agents
- a project context snapshot available to both runtime and slash commands
Water Code now includes a built-in self-check surface:
water-code --doctor: run a one-shot environment and project diagnostic/doctor: inspect the current runtime from inside REPL or one-shot slash modeGET /doctor: retrieve the same report over the bridge
The report currently checks:
- Node version against the package engine
- project-root read/write access
.water-codestate-dir readiness- provider readiness
- extension and MCP loading
- recent session visibility
- whether
WATER.mdinstructions are present
Water Code now includes a built-in onboarding surface:
water-code --onboard: print recommended first steps for the current project/onboard: show the same guidance from REPL or one-shot slash modeGET /onboard: retrieve onboarding guidance over the bridge
The onboarding report currently highlights:
- whether the project is already initialized for Water Code
- whether README context is available
- whether recent sessions can be resumed
- which next command is most useful right now
Water Code now includes a starter scaffold flow:
water-code --init: create starter Water Code files in the current projectwater-code --init --force: overwrite the starter files Water Code manages/init: run the same scaffold flow from inside the REPL or one-shot slash modePOST /init: trigger scaffold creation over the bridge
The scaffold currently creates:
WATER.md.water-code/commands/readme-snapshot.md.water-code/agents/reviewer.md.water-code/skills/repo-cartographer.md.water-code/plugins/workspace-tools.js.water-code/mcp.json