Skip to content

feat(ruler): distribute a profile's rules into every agent's native rule file#95

Merged
NagyVikt merged 2 commits into
mainfrom
worktree-feat-cue-ruler
Jul 1, 2026
Merged

feat(ruler): distribute a profile's rules into every agent's native rule file#95
NagyVikt merged 2 commits into
mainfrom
worktree-feat-cue-ruler

Conversation

@NagyVikt

@NagyVikt NagyVikt commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What

Adds cue ruler — distributes the active profile's rules[] (from resources/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 while materialize already fanned skills+MCPs to 10 agents. The good idea from intellectronica/ruler, made cue-native.

Phase 1 — the cue ruler command

  • gatherRulesconcatRules (<!-- Source: --> markers) → applyRuler / revertRuler in new src/lib/ruler.ts.
  • src/commands/ruler.ts mirrors materialize.ts: --all / --agents / --dir / --dry-run / --gitignore / --revert / --profile.
  • Adds rulesFile() to the AgentAdapter interface + all 10 adapters.
  • whole-file write + .bak; --revert marker-gated; shared-file agents (codex+amp → AGENTS.md) written once; refs path-confined to resources/rules/.

Phase 2 — auto on cue launch (gated, safe)

  • CUE_RULER_AUTO=1 (1|true|on|auto) → cue launch mirrors the profile's rules into the project's agent files after materialize, before exec. OFF by default = zero behavior change.
  • Safe mode: writes only when the target is absent or cue-generated (marker must be at file START), so a hand-written file is never clobbered (skip-foreign-safe); idempotent (skip-current); no .bak churn; fail-open (never blocks/slows launch); honors --dry-run.

Tests / review

31 unit tests; biome + tsc clean. 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.

NagyVikt 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.
@NagyVikt NagyVikt merged commit c1b75b0 into main Jul 1, 2026
2 of 4 checks passed
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.

1 participant