Repository navigation
fix(import): write sources to ./.rulesync for every --output-root import - #3997
Merged
Merged
Conversation
`import --output-root <dir>` reads the tool files from <dir>, but the features disagreed on where the converted sources went: MCP, hooks, permissions, skills and the Claude Code / Copilot adapters wrote to <dir>/.rulesync/, the rest to ./.rulesync/. Rebase every converted file and directory to the current working directory in project mode, as the docs already state, where `generate` reads them. Global mode keeps the root each adapter chose. Also, from the same follow-up issue: - hooks import skips an unmapped native key spelled like a canonical event the tool does not read (e.g. camelCase `preToolUse` in a Goose file) with a warning, instead of activating it on the next generate - permissions importers warn when they drop a rule whose category or pattern is `__proto__` / `constructor` / `prototype` Closes #3773 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
Contributor
|
@dyoshikawa The CI checks on this pull request are currently failing. Please review the failing checks and push a fix. If you need help, leave a comment and a maintainer will follow up. |
…port-output-root # Conflicts: # src/generated/docs-content.ts
…ort fixtures The codexcli and factorydroid hooks-import E2E fixtures spelled the event as camelCase `sessionStart`, which neither tool reads (both use `SessionStart`). The import now skips such inert canonical-looking keys, so the fixtures use the native spelling, and a unit test pins that the real converter configs keep `SessionStart` and skip `sessionStart`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…port-output-root # 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
Resolves the remaining items of #3773: where
import --output-root <dir>writes rulesync sources, plus the two low notes collected in the issue (canonical-looking unknown hook keys, silent drops of reserved permission names).Changes
1.
import -o <dir>always writes sources to./.rulesync/(project mode)Probing
mainshowed the inconsistency is wider than the issue listed. With-o sub:sub/.rulesync/./.rulesync/Instead of patching ~20 adapters one by one,
src/lib/import.tsnow rebases every converted rulesync file and directory toprocess.cwd()before it is written (and before the MCP / hooks / permissions source-path resolution and the permissions merge, which read the existing file there). This replaces the packaging-only rebasing (getPackagingImportOutputRootand theRulesyncSkillrebuild inimportSkillsCore).AiFile.withOutputRoot()/AiDir.withOutputRoot(): a copy of the file/directory written under another output root, every other field unchanged.docs/reference/cli-commands.md: new short "Import Command" section stating the rule.src/lib/import.test.ts(project mode rebases, global mode keeps),AiFile/AiDirunit tests, and a new E2E specsrc/e2e/e2e-import-output-root.spec.tscovering all eight Claude Code features plus Copilot commands and Codex CLI rules with--output-root sub.Behavior change: users who ran
import -o <dir>and relied on MCP/hooks/permissions/skills (or Claude Code rules/ignore, Copilot commands) landing in<dir>/.rulesync/now get them in./.rulesync/, wheregenerateactually reads them.2. Hooks: canonical-looking unknown native keys
toolHooksToCanonicalused to pass an unmapped key through unchanged, so camelCasepreToolUsein a Goose file (inert in Goose) landed in the canonical block and became active aftergenerate, even merging into the real mappedPreToolUsehooks. Now such a key is skipped with a warning when it is a canonical event name the tool does not read verbatim (not supported, or supported under a different native name). Non-canonical unknown keys (e.g.PostFileSave,PreToolUseResult) still go to the<tool>.hooksoverride block as before.3. Permissions: warn on dropped reserved names
New helper
skipsReservedPermissionName(src/features/permissions/reserved-permission-name.ts) replaces the silentisPrototypePollutionKeyskips in the import paths of amp, antigravity (cli/ide), claudecode, codebuddy, continue, crush, cursor, devin, goose, lettacode, pool, qoder, qwencode, reasonix and trae. Wording followsbuildImportedHooksConfig:Skipping imported <Tool> permission rule for "<category>" pattern "<pattern>": reserved key names cannot be used as permission categories or patterns.Design decisions
./.rulesync/in cwd, not<dir>/.rulesync/. Already documented (docs/guide/declarative-sources.md,docs/guide/plugin-packaging.md), andgeneratereads sources from its input roots (default./.rulesync), never from the output root, so<dir>/.rulesync/was never read back.ClaudecodeIgnore,CopilotCommand.getRulesyncOutputRoot) are left as they are because they now only matter in global mode (see below).~/.rulesync/, Codex CLI rules and commands to./.rulesync/), and the tool-home helpers (getToolRulesyncOutputRoot) deliberately send global sources to the home directory. Changing that is a separate decision, outside "import -o" (global mode ignoresoutputRoots).<tool>.hooks, but generate reads canonical names in an override block as overrides of the canonical event, so the inertpreToolUsethen replaced Goose's realPreToolUsehooks. Since the tool ignores the key anyway, dropping it with a warning loses nothing that runs. I checked every converter config used bytoolHooksToCanonical: each supported event already has an explicit native-name mapping, so no real native event is affected; the "supported and written verbatim" check is a safety net.warnWithFallback. Most of these converters have no logger in scope; the fallback logger honorssilent, like the existing Command Code import warnings.Skipped items
toolHooksToCanonical(e.g. Cursor, Kiro, Copilot) were not changed; the note in the issue concerned the shared converter.Closes #3773
🤖 Generated with Claude Code
https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4