feat(ruler): distribute a profile's rules into every agent's native rule file#95
Merged
Conversation
added 2 commits
June 30, 2026 12:25
…ule file Add `cue ruler` — concatenates the active profile's rules[] (from resources/rules/) with `<!-- Source: -->` markers and writes them into each target agent's native rule file (CLAUDE.md, AGENTS.md, .cursorrules, .clinerules, ...). The good idea from intellectronica/ruler, made cue-native. - whole-file write + .bak backup; `--revert` restores/removes (marker-gated, so a hand-written file is never deleted) - agents sharing a file (codex+amp -> AGENTS.md) are written once - path-confined to resources/rules/ (no ../ or absolute escape) - adds rulesFile() to all 10 agent adapters - flags: --all / --agents / --dir / --dry-run / --gitignore / --revert / --profile 20 unit tests; biome + typecheck clean.
Phase 2: when CUE_RULER_AUTO is set (1|true|on|auto), `cue launch` mirrors the profile's rules into the project's agent rule files after materialize, before exec — so other agents stay in sync without a manual `cue ruler`. Safe mode (never clobbers a hand-written file): - writes only when the target is absent or cue-generated (marker must be at the file START, so a file that merely quotes the marker is treated as foreign) - idempotent (skip-current); no .bak churn; fail-open (a ruler error never blocks or slows launch); honors --dry-run (previews "would sync", no writes) - OFF by default — unset env = zero behavior change Adds applyRuler mode:'safe', runAutoRuler, isRulerAutoEnabled, isCueGenerated helper. 11 new tests (31 total). biome + typecheck clean.
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.
What
Adds
cue ruler— distributes the active profile'srules[](fromresources/rules/) into every target agent's native rule file (CLAUDE.md, AGENTS.md,.cursorrules,.clinerules, …). Closes the gap where cue's rule library only reached Claude whilematerializealready fanned skills+MCPs to 10 agents. The good idea from intellectronica/ruler, made cue-native.Phase 1 — the
cue rulercommandgatherRules→concatRules(<!-- Source: -->markers) →applyRuler/revertRulerin newsrc/lib/ruler.ts.src/commands/ruler.tsmirrorsmaterialize.ts:--all/--agents/--dir/--dry-run/--gitignore/--revert/--profile.rulesFile()to theAgentAdapterinterface + all 10 adapters..bak;--revertmarker-gated; shared-file agents (codex+amp → AGENTS.md) written once; refs path-confined toresources/rules/.Phase 2 — auto on
cue launch(gated, safe)CUE_RULER_AUTO=1(1|true|on|auto) →cue launchmirrors the profile's rules into the project's agent files after materialize, before exec. OFF by default = zero behavior change.skip-foreign-safe); idempotent (skip-current); no.bakchurn; fail-open (never blocks/slows launch); honors--dry-run.Tests / review
31 unit tests;
biome+tscclean. Two independent code reviews (phase 1 + phase 2): all CRITICAL/HIGH/MEDIUM findings fixed (dry-run-revert, gitignore revert, traversal guard, conformance test, marker-at-START false-positive guard). Additive only — no change to existing commands when the env gate is unset.