Skip to content

feat(jcode): add jcode target - #4002

Merged
dyoshikawa merged 5 commits into
mainfrom
resolve-issue-3412-jcode-target
Nov 26, 2026
Merged

dyoshikawa merged 5 commits into
mainfrom
resolve-issue-3412-jcode-target

Conversation

@dyoshikawa

@dyoshikawa dyoshikawa commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds a jcode target 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

  • rules: the root rule goes to .jcode/prompt-overlay.md (project) / ~/.jcode/prompt-overlay.md (global), and non-root rules are folded into it (SingleRootFileRule, collisionPolicy: "fold").
  • mcp: .jcode/mcp.json (project) / ~/.jcode/mcp.json (global), in Claude Code spelling: stdio command/args/env, remote type/url/headers (http, streamable-http, sse), plus disabled. ws servers and servers with neither a command nor a URL are skipped with a warning, and other fields are dropped with a warning. Declared in SHARED_CONFIG_OWNERSHIP, so a malformed file is refused rather than overwritten.
  • skills: .jcode/skills/<name>/SKILL.md in both scopes (reuses AgentsSkillsSkill).
  • hooks (global only): the [hooks] table of ~/.jcode/config.toml. The mapping is sessionStart→session_start, sessionEnd→session_end, preToolUse→pre_tool, postToolUse→post_tool, beforeSubmitPrompt→turn_start and stop→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.
  • Registration (tuples, display name, processors, jcode keys 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.md notes, generated tables, docs-content, .gitignore and cspell.

Design decisions

  • Hook matchers: jcode hooks have no matcher, so a matcher can't be translated into anything. A matcher-scoped hook is therefore widened to every tool, with a warning, and never dropped. For a preToolUse guard (for example Bash), dropping it would fail open. Widening is safe because jcode runs pre_tool before every tool call, which includes every shell-executing tool. The warning tells users to filter on JCODE_HOOK_TOOL_NAME. The factory declares supportsMatcher: true so the processor's generic "Skipped matcher hook(s)" message, which would be wrong here, isn't shown.
  • Unsupported hook options: timeout (jcode has no per-hook timeout) and failClosed (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.toml ownership: 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-written pre_tool gate 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_ms settings, mapped keys no hook maps to this time, and hand-written pre_tool_transform / post_tool_feedback. The trade-off, which is documented, is that a hook removed from the sources stays in config.toml until it is deleted by hand. pre_tool_transform / post_tool_feedback can be authored, and are imported, under jcode.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 of config.toml is untouched, and the file is never deleted.
  • Matcher widening also covers updatedInput: a widened pre_tool hook that returns updatedInput rewrites 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.
  • MCP server-map key: jcode reads mcpServers as a serde alias of its historical servers key, which jcode mcp itself writes, and refuses a file that contains both. Rulesync keeps whichever key the file already uses and removes the other one.
  • Unknown MCP server keys are preserved: when a server with the same name already exists, keys rulesync doesn't manage (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 folds enabled: false into disabled: true.
  • Project MCP path: the project file is .jcode/mcp.json rather 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 the claudecode target's .mcp.json. Neither file is removed by --delete, because jcode mcp add writes them too.
  • JCODE_HOME is 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.md and swarm-prompt.md: no rulesync feature maps onto them cleanly.
  • preserveUnownedHooks support for jcode: it is opt-in elsewhere and built around JSON hook lists plus a lock file. It could be added later.
  • Commands, subagents, permissions and ignore: jcode documents no such surfaces.

Closes #3412

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 5 commits November 26, 2026 17:47
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
@dyoshikawa
dyoshikawa merged commit 5acfebf into main Nov 26, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3412-jcode-target branch November 26, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Propose a jcode target: .jcode/ prompt overlay, mcp.json, skills, and global config.toml hooks

1 participant