Repository navigation
feat(sources): install commands and subagents from declarative sources - #4005
Merged
Merged
Conversation
Declarative sources could only install skills and rules. Add `commands` / `commandsPath` and `subagents` / `subagentsPath` to source entries, following the rules precedent (#2349): direct `.md` files of the path are fetched into `.rulesync/commands/.curated/` and `.rulesync/subagents/.curated/` over every transport (GitHub, git, npm), locked with optional fields in `rulesync.lock` / `rulesync-npm.lock.json` (no lockfile version bump), covered by `--frozen`, `rulesync add` flags, the MCP add tool and gitignore, and read by `generate` with local files taking precedence. The rule-only helpers are generalized to a per-file feature so rules, commands and subagents share one code path. Locked names are checked to stay inside the curated directory before anything is read, removed or restored under them. MCP servers, hooks and permissions stay out of sources: installing them from a remote source would run commands or widen permissions. Refs #3423 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ubagents A command or subagent installed from a declared source could carry tool section keys such as `permissionMode: bypassPermissions`, `hooks`, `mcpServers` or `allowed-tools`, which the tool adapters copy verbatim into the generated file, so a source could still widen permissions or run commands. When `generate` reads a file from `commands/.curated/` or `subagents/.curated/`, drop those keys at the root and in every tool section and warn with what was dropped. Narrowing keys (`tools`, `disallowedTools`) are kept. A local copy of the file keeps them. Also mention `.curated/` in the simulated command and subagent instructions, list the new curated directories in the global mode guide, remove the now-unused `shouldSkipRule` / `getLockedRuleNames`, and share `mapFileFeatures` instead of duplicating it. Refs #3423 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
… subagents The denylist of privileged keys could not keep up with every tool's settings: Kiro `toolsSettings` / `includeMcpJson`, Codex `notify` and `model_providers`, OpenCode `tools` and others still reached the generated files. Switch to an allowlist: a file read from `commands/.curated/` or `subagents/.curated/` keeps only `targets` and `description` (plus `name` for a subagent) and drops every tool section, with one warning per file naming what was dropped and pointing to a local copy for tool-specific settings. Refs #3423 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…urces-commands-subagents # Conflicts: # src/generated/docs-content.ts
This was referenced Nov 26, 2026
Open
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
Declarative
sourcescan now install commands and subagents, in addition to skills and rules. This follows the rules precedent (#2349): one optional selection field and one optional path field per feature, the same lock shape, and the same curated-directory model.{ "sources": [ { "source": "acme/ai-assets", "commands": ["review", "release"], "commandsPath": "exports/commands", // default: "commands" "subagents": ["*"], // subagentsPath default: "subagents" }, ], }Changes
commands/commandsPathandsubagents/subagentsPathon source entries. The path fields reuse therulesPathvalidation (relative, no.., no control characters). A source that declares only commands and/or subagents takes no skills, as for rules.replaceCuratedRules,canReuseLockedRules,selectDeclaredRules,fetchRulesViaGithub/fetchRulesViaGit, npmfetchNpmRules, the GitHub prefetch claims, frozen coverage, stale-entry cleanup, lock key migration) are generalized to a per-file feature (rules|commands|subagents), so all three share one code path over the GitHub, git and npm transports. Rules behave exactly as before (same messages, same lock shape).--update(generalizing the existing skills+rules rule).commands/commandSelection/commandsPath/resolvedCommandNamesand the subagent counterparts on bothrulesync.lockandrulesync-npm.lock.jsonentries.LOCKFILE_VERSIONstays 1; old lockfiles parse unchanged. Lock keys of a repository declared several times are qualified bycommandsPath/subagentsPathas well asrulesPath.commands/.curated/andsubagents/.curated/; a local file of the same name wins (case-only collisions warn, via a sharedfilterCuratedShadowedByLocalhelper).rulesync add --commands --subagents --commands-path --subagents-path, the MCPaddtool schema, install/add summaries and--jsoncounts (commandsFetched,subagentsFetched).--mode ghrejects the new fields like it rejectsrules..rulesync/commands/.curated/and.rulesync/subagents/.curated/.src/generated/docs-content.tsregenerated.Safety: fetched content stays inside
.rulesync//,\,.., hidden/control characters, or__proto__-like names are skipped with a warning (same gate as rules), and every write goes throughcheckPathTraversalagainst the feature's curated directory.install/addrefuse to run when any curated directory (now including the commands and subagents ones) resolves outside the project root, is not a directory, or contains a symlink..., absolute paths and control characters at config parse time.generatereads a file fromcommands/.curated/orsubagents/.curated/, it keeps onlytargetsanddescription(plusnamefor a subagent; the schemas have no canonicalmodel) and drops every other key, including every tool section, with one warning per file listing what was dropped and pointing to a local copy for tool-specific settings. An allowlist replaces the round-1 denylist because tool sections are copied into generated files and each tool has its own privileged settings (Claude CodepermissionMode/hooks/mcpServers/allowed-tools, KirotoolsSettings/includeMcpJson, Codexnotify/sandbox_*/model_providers, OpenCodepermission/tools, ...). This runs at generate time, so lock integrity still covers the fetched bytes.Design decisions
lockfileVersionbump: only additive optional fields, so existing lockfiles and older readers keep working..mdchildren ofcommandsPath/subagentsPathare installed, matching rules. Nested commands are not fetched..rulesync/commands/<name>.md/.rulesync/subagents/<name>.mdmakes the remote one skipped at install time and shadowed at generate time, like skills and rules.relativeDirPath.rulesync/commands/.curated), which keeps the loader simple; tool outputs depend only on the file name.allowed-toolsusage. The docs say to review skill sources as code.ResolveAndFetchSourcesOptions/Resultgain command/subagent counterparts of the rule options;getInstalledSourceRuleNamesbecamegetInstalledSourceFileNames({ feature }).Skipped items and why
sources. MCP servers and hooks run commands on each developer's machine, and permissions widen what agents may do without asking; pulling them from a remote source oninstallis a safety risk that needs its own opt-in design. The docs point to a reviewed, pinned checkout ininputRootsfor those. The issue stays open for them, henceRefs.featureslock schema (issue comment): not chosen, see decision 1.Verification
--frozencoverage, removing a feature clears its curated files and lock fields, empty-list message; lock round-trip without version bump and key qualifiers; config validation; gh-mode rejection; curated loading in both processors.file://git source withcommands/andsubagents/→installwrites the curated files and lock,generateemits.claude/commands/*and.claude/agents/planner.mdwith the local command winning,install --frozenreports up to date.pnpm cicheck(full) passed locally on the first commit (625 test files, 17540 tests, content checks clean). The review-round commits were checked with targeted suites (src/lib, commands, subagents, config, utils: 3797 tests), fmt, oxlint, typecheck andcicheck:content.Refs #3423
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4