Repository navigation
feat(jcode): add jcode target - #4002
Merged
Merged
Conversation
jcode (the Rust coding-agent harness) reads its own .jcode/ project tree and ~/.jcode/ home on top of the shared AGENTS.md. The new `jcode` target writes the documented surfaces: - rules: the root rule to .jcode/prompt-overlay.md (project and global), with non-root rules folded in. system-prompt.md is not written. - mcp: the server map of .jcode/mcp.json / ~/.jcode/mcp.json in Claude Code spelling (stdio, http/streamable-http, sse). The existing map key (`mcpServers` or the historical `servers`) is kept, never both; other top-level keys and unmanaged keys of existing servers (shared, timeout_secs, ...) are preserved. - skills: .jcode/skills/<name>/SKILL.md (Agent Skills layout). - hooks (global only): the [hooks] table of ~/.jcode/config.toml. sessionStart/sessionEnd/preToolUse/postToolUse/beforeSubmitPrompt/stop map to session_start/session_end/pre_tool/post_tool/turn_start/ turn_end. jcode hooks have no matcher, so a matcher-scoped hook is widened to every tool with a warning instead of dropped (a pre_tool guard is never lost). Table settings and hand-written pre_tool_transform/post_tool_feedback keys are kept; those two can be authored and imported under the jcode.hooks override block. Closes #3412 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
- hooks: a [hooks] key is replaced only when the sources generate a value for it, with a warning naming the old value when that changes it; keys rulesync does not generate (such as a hand-written pre_tool gate) are kept instead of being retracted, so a generate with no preToolUse can no longer make a gate fail open. The matcher-widening warning and docs now say an updatedInput rewrite applies to every tool. - mcp: a file with both mcpServers and servers is read as their union (mcpServers wins) with a warning and written under mcpServers only; transport names are normalized the way jcode reads them (trimmed, case-insensitive, streamable_http/streamablehttp -> streamable-http) and entries with a type jcode does not run are not imported; .jcode/mcp.json is never deleted, since `jcode mcp add` writes it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ode-target # Conflicts: # docs/reference/file-formats.md # src/features/rules/rules-processor.test.ts # src/generated/docs-content.ts
…ode-target # Conflicts: # docs/reference/file-formats.md # src/features/rules/rules-processor.test.ts # src/generated/docs-content.ts
…ode-target # Conflicts: # docs/reference/file-formats.md # 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
jcodetarget for jcode (MIT, stable v1.1.x), covering the surfaces jcode documents: the prompt overlay (rules),mcp.json(MCP),.jcode/skills/(skills) and the global[hooks]table (hooks).Changes
.jcode/prompt-overlay.md(project) /~/.jcode/prompt-overlay.md(global), and non-root rules are folded into it (SingleRootFileRule,collisionPolicy: "fold")..jcode/mcp.json(project) /~/.jcode/mcp.json(global), in Claude Code spelling: stdiocommand/args/env, remotetype/url/headers(http,streamable-http,sse), plusdisabled.wsservers and servers with neither a command nor a URL are skipped with a warning, and other fields are dropped with a warning. Declared inSHARED_CONFIG_OWNERSHIP, so a malformed file is refused rather than overwritten..jcode/skills/<name>/SKILL.mdin both scopes (reusesAgentsSkillsSkill).[hooks]table of~/.jcode/config.toml. The mapping issessionStart→session_start,sessionEnd→session_end,preToolUse→pre_tool,postToolUse→post_tool,beforeSubmitPrompt→turn_startandstop→turn_end. One hook is written as a string and several as a list. A project-scope generate skips jcode hooks with the processor's existing "only in global scope" warning.jcodekeys in the hooks and mcp schemas), unit tests for each new class, E2E happy paths (rules/mcp/skills in project and global scope, global hooks generate and import),file-formats.mdnotes, generated tables, docs-content,.gitignoreand cspell.Design decisions
preToolUseguard (for exampleBash), dropping it would fail open. Widening is safe because jcode runspre_toolbefore every tool call, which includes every shell-executing tool. The warning tells users to filter onJCODE_HOOK_TOOL_NAME. The factory declaressupportsMatcher: trueso the processor's generic "Skipped matcher hook(s)" message, which would be wrong here, isn't shown.timeout(jcode has no per-hook timeout) andfailClosed(jcode always fails open) are dropped with a warning. jcode runs commands directly, not through a shell, so a command that uses shell syntax (| & ; < > $or a backtick) gets a warning.config.tomlownership: rulesync never removes a[hooks]key. Without an ownership record it can't tell its own value from a hand-written one, and silently dropping a hand-writtenpre_toolgate would make that gate fail open. A key is replaced only when the sources generate a value for it, with a warning naming the old value when that changes the file. Every other key is kept: the*_timeout_mssettings, mapped keys no hook maps to this time, and hand-writtenpre_tool_transform/post_tool_feedback. The trade-off, which is documented, is that a hook removed from the sources stays inconfig.tomluntil it is deleted by hand.pre_tool_transform/post_tool_feedbackcan be authored, and are imported, underjcode.hooks(overrideOnlyEvents). When the override sets one, it replaces the existing key rather than being appended, so running import and then generate doesn't duplicate it (covered by a unit test). The rest ofconfig.tomlis untouched, and the file is never deleted.updatedInput: a widenedpre_toolhook that returnsupdatedInputrewrites the input of every tool. The warning and the docs say so; the hook is still widened rather than skipped so that a guard is never lost.mcpServersas a serde alias of its historicalserverskey, whichjcode mcpitself writes, and refuses a file that contains both. Rulesync keeps whichever key the file already uses and removes the other one.shared,timeout_secs, keys added later) are kept. Import doesn't copy those into.rulesync/mcp.json, so they don't leak to other tools, and foldsenabled: falseintodisabled: true..jcode/mcp.jsonrather than.mcp.json. jcode's CLI help (src/cli/mcp.rs: "Add servers to ~/.jcode/mcp.json or .jcode/mcp.json") and its loader (crates/jcode-base/src/mcp/protocol.rs) load it first, ahead of.mcp.json. Using it also avoids sharing theclaudecodetarget's.mcp.json. Neither file is removed by--delete, becausejcode mcp addwrites them too.JCODE_HOMEis not followed; rulesync always writes~/.jcode/. This is documented.Skipped items
system-prompt.md(it replaces jcode's base prompt, which is too destructive),preferred-tools.mdandswarm-prompt.md: no rulesync feature maps onto them cleanly.preserveUnownedHookssupport for jcode: it is opt-in elsewhere and built around JSON hook lists plus a lock file. It could be added later.Closes #3412
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4