Repository navigation
feat(zero): add Zero target - #3992
Merged
Merged
Conversation
Add a `zero` target for Zero (Twigpine/zero) covering rules, MCP, subagents (specialists), hooks and global-only skills, following the documented `.zero/` / `~/.config/zero/` layout and Zero's source. - rules: `ZERO.md` at the project root and `<user config dir>/zero/ZERO.md`; topic and localRoot rules fold into it, with a warning when an `AGENTS.md` shadows it and an 8 KiB budget warning. - mcp: `mcp.servers` of `.zero/config.json` / the user `config.json`, merged without touching other keys (stdio and http only). - subagents: `.zero/specialists/*.md` with one-line frontmatter and `tools` always written as a list. - hooks: flat `hooks.json` list with `sh -c` commands, matchers translated to Zero's lowercase tool names (`Bash` -> `bash`, alternations split per tool), scope-prefixed ids, and hand-written entries kept. - skills: `~/.local/share/zero/skills/` (Zero has no project skills). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
- Map `Bash` to all of Zero's default shell tools (`bash`, `exec_command`, `write_stdin`) so a shared guard is not bypassed. - Expand `*` globs over the canonical names; a `preToolUse` guard whose matcher Zero cannot express or whose glob matches no Zero tool is written without a matcher (runs on every tool) instead of skipped. - Do not generate an entry identical to a kept hand-written hook, so import followed by generate does not run it twice. - Never add a top-level `enabled` to hooks.json, which would override the user layer's flag. - Round-trip Zero's MCP `oauth` as the namespaced `zeroOauth` key and keep unmanaged keys of existing servers. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ro-target # Conflicts: # src/generated/docs-content.ts
- Cover `terminal_session` with `Bash` and map `Agent` to `Task`. - Fail closed for a `preToolUse` guard naming an exact tool Zero lacks. - Warn that a native `bash` guard leaves the other shell tools uncovered. - Keep a lowercase glob beside its canonical expansion. - Drop an existing MCP `oauth` block when the server url changed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ro-target # Conflicts: # src/generated/docs-content.ts
…ro-target # Conflicts: # src/generated/docs-content.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
zerotarget for Zero (Twigpine/zero, MIT, Go terminal coding agent). It covers rules, MCP, subagents (Zero's "specialists"), hooks and skills (global only). Paths and formats were checked againstdocs/EXTENDING.md,docs/SPECIALISTS.mdand the Go source:internal/agent/system_prompt.go,internal/config/paths.go,internal/mcp/config.go,internal/hooks/hooks.go,internal/agent/loop.go,internal/specialist/manifest.go,internal/skills/skills.goandinternal/tools/*.Changes
--global)ZERO.md~/.config/zero/ZERO.md.zero/config.json→mcp.servers~/.config/zero/config.json.zero/specialists/<name>.md~/.config/zero/specialists/<name>.md.zero/hooks.json~/.config/zero/hooks.json~/.local/share/zero/skills/<name>/SKILL.mdOn Windows the user config dir is
%AppData%\zero(~/AppData/Roaming/zero). Zero uses~/.configon macOS as well. The skills root is~/.local/share/zero/skillson every platform.src/constants/zero-paths.ts, pluszero-rule.ts,zero-mcp.ts,zero-subagent.ts,zero-hooks.tsandzero-skill.ts, each with unit tests.types/hooks.ts(event map and thezero.hooksoverride key), the shared-config ownership table andSHARED_USER_MANAGED_CONFIG_PATHS.file-formats.md. The README / supported-tools tables, the docs content,.gitignoreand cspell are regenerated.Design decisions
Hook matchers are translated, so a shared
Bashguard does not fail open. In Zero a matcher is an exact, case-sensitive name or a*glob, with no regex and no alternation (matchesHookMatcherininternal/hooks/hooks.go). It is checked against Zero's lowercase tool names. The translations are:Bash→bash+exec_command+write_stdin(all of Zero's default shell tools)Read→read_file+read_minified_fileWrite→write_fileEdit/MultiEdit→edit_file+apply_patchGlob/Grep→glob/grepLS→list_directoryWebFetch/WebSearch→web_fetch/web_searchSkill→skillAskUserQuestion→ask_usermcp__srv__tool→mcp_srv_tool.*→*, and a glob is expanded over the canonical names (Bash.*covers the same shell tools)An alternation such as
Write|Editbecomes one Zero hook per name, and import folds those back into one matcher. ApreToolUseguard fails closed: when its matcher needs regex syntax Zero cannot express, or is a glob matching no Zero tool, it is written without a matcher (so it runs before every tool call), with a warning. On other events such a matcher is skipped with a warning. An exact name with no Zero counterpart is written as-is with a warning.Hook commands are written as
command: "sh", args: ["-c", <cmd>], because Zero handscommand/argstoexec.CommandContextwithout a shell. Import unwraps them.Hook ids are
rulesync-<project|user>-<event>-<NNN>. Zero merges the user and project layers by id, and the project wins (mergeLayers), so identical ids would let a project hook silently replace a user hook. Zero also runs hooks in id order, and the zero-padded counter keeps that order equal to the authored order.hooks.jsonis merged, never deleted.zero hookswrites the same file, so generation keeps every entry whose id does not start withrulesync-, and it does not generate an entry identical (event, matcher, command line, enabled) to one of them, so import followed by generate never runs a hand-written hook twice. The top-levelenabledis kept as found and never added, because a layer that states it overrides the other layer. It refuses to rewrite unparseable JSON, andisDeletable()is false in both scopes. The project file is listed as user-managed, so it is not gitignored.localRootfolds intoZERO.md, not.zero/AGENTS.md(refines the triage plan). Zero reads only the first ofAGENTS.md,ZERO.mdand.zero/AGENTS.mdper directory (findProjectContextFile). A.zero/AGENTS.mdnext to the generatedZERO.mdwould never be read.Root
ZERO.mdis always written. Generation warns when anAGENTS.mdalready sits next to it, because Zero would read that file instead. An 8 KiBprojectInstructionBudgetmatches Zero's per-file cap.MCP: rulesync owns the
mcpkey ofconfig.json(siblings are carried over) and keeps every other key. The file is never deleted. Only the documented transports (stdio,http) are written; SSE and WebSocket servers are skipped with a warning. Names outside Zero's^[A-Za-z0-9._-]+$are skipped too, because one invalid server makes Zero refuse all of them.${VAR}references get a "written literally" warning, since Zero does no env expansion.auth: "oauth"anddisabledround-trip; a server'soauthblock is imported as the namespacedzeroOauthkey (stripped from other tools, likezcodeOauth) and written back asoauth, and unmanaged keys of a same-named existing server are carried over.Subagents: only
name,descriptionand thezero:section'sextends,model,reasoningEffortandtoolsare written. A sharedmodelis not passed through, because Zero rejects unknown models. Zero's frontmatter parser is line-based and acceptstoolsonly as a list. Thetools: read-only,planexample in EXTENDING.md would actually fail with "tools must be an array". So values are kept on one line, and a comma string inzero.toolsis split into a list. rulesync warns when a name is not a lowercase id or a required description is missing.Skills: global-only (
supportsProject: false), reusingAgentsSkillsSkill. The skills processor writes one-line frontmatter forzero, as it does for Cursor, because Zero's skill frontmatter parser is line-based.Skipped
.zero/plugins/<id>/plugin.jsonbundles: possibly a laterzero-plugintarget.timeout: Zero has no per-hook timeout, so it is ignored with a warning.sseMCP transport (it exists ininternal/mcp/config.go): skipped to stay on documented surfaces.$XDG_CONFIG_HOME/$XDG_DATA_HOME/$ZERO_SKILLS_DIRoverrides are not followed; global output goes to the default locations.Closes #3807
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4