feat(rules): support installing rules from local files (closes #105)#107
Merged
Conversation
Adds a `local` rule type so rule content can live in a separate file instead
of inline YAML, e.g.:
rules:
- id: typescript-conventions
type: local
appliesTo: ["**/*.ts", "**/*.tsx"]
path: rules/typescript.md
`path` is resolved relative to the directory containing the capabilities file,
matching the existing `local` convention for agents and hooks.
- Add 'local' to the Rule type union and a `path` field (src/types/rules.ts).
- Extract per-rule body resolution into an exported, testable resolveRuleBody()
and add the `local` branch (reads the file, descriptive error if missing).
- Document the new type with an example in the README rules block.
- Add unit tests covering local resolution (incl. relative-to-capabilities-file
resolution), missing path/file errors, inline regression, and unknown type.
Closes #105
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #105.
What
Adds a
localrule type so rule content can be managed in a separate file instead of inline YAML:pathis resolved relative to the directory containing the capabilities file — the same convention already used bylocalagents and hooks, so it's consistent across the config.How
src/types/rules.ts— add'local'to theRuletype union and a documentedpathfield.src/cli/commands/install-tasks/install-rules.ts— extract the per-rule body resolution into an exported, unit-testableresolveRuleBody()and add thelocalbranch (reads the file off disk; throws a descriptive error ifpathis missing or the file doesn't exist). The writer (installRules) is content-agnostic and needed no change.README.md— document the new type with an example in the rules block.Tests
New
install-rules.test.tscovers: local resolution, resolution relative to the capabilities file (not cwd), missing-patherror, missing-file error, inline regression, and unknown-type error. Full suite: 1046 pass / 0 fail.🤖 Generated with Claude Code