@bonesofspring/ai-rules 0.2.50 → 0.2.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -1
- package/README.md +3 -1
- package/bin/cli.js +52 -13
- package/bin/lib/ai-local-drift.js +665 -0
- package/bin/lib/seed-ai-local-team.js +153 -35
- package/bin/mavis-install.js +6 -0
- package/bin/opencode-install.js +13 -2
- package/docs/LOCAL-OVERLAY.md +77 -1
- package/package.json +1 -1
- package/presets/_shared/ai-local/scripts/efficacy-oracle.mjs +1 -1
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +491 -55
- package/presets/_shared/ai-local/scripts/run.mjs +56 -1
- package/presets/_shared/ai-local/scripts/signals.mjs +119 -6
- package/presets/_shared/core/quality/anti-hallucination-contract.md +2 -0
- package/presets/_shared/core/review/code-review-mr.md +20 -1
- package/presets/_shared/core/review/receiving-code-review.md +7 -0
- package/presets/claude/android-kotlin/agents/code-reviewer.md +14 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/code-review.md +20 -1
- package/presets/claude/android-kotlin/skills/code-review/SKILL.md +11 -1
- package/presets/claude/go/agents/code-reviewer.md +36 -2
- package/presets/claude/go/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/go/rules/tooling-and-review/code-review.md +20 -1
- package/presets/claude/go/skills/code-review/SKILL.md +10 -1
- package/presets/claude/ios-swift/agents/code-reviewer.md +14 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +20 -1
- package/presets/claude/ios-swift/skills/code-review/SKILL.md +11 -1
- package/presets/claude/java/agents/code-reviewer.md +36 -2
- package/presets/claude/java/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/java/rules/tooling-and-review/code-review.md +20 -1
- package/presets/claude/java/skills/code-review/SKILL.md +10 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +20 -1
- package/presets/claude/mcp-ts/skills/code-review/SKILL.md +8 -0
- package/presets/claude/next/agents/code-reviewer.md +14 -0
- package/presets/claude/next/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +20 -1
- package/presets/claude/next/skills/code-review/SKILL.md +12 -2
- package/presets/claude/nuxt/agents/code-reviewer.md +14 -0
- package/presets/claude/nuxt/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/nuxt/rules/tooling-and-review/code-review-mr.md +20 -1
- package/presets/claude/nuxt/skills/code-review/SKILL.md +11 -1
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +36 -2
- package/presets/claude/php-hexagonal/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/code-review.md +20 -1
- package/presets/claude/php-hexagonal/skills/code-review/SKILL.md +10 -1
- package/presets/claude/php-laravel/agents/code-reviewer.md +36 -2
- package/presets/claude/php-laravel/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/code-review.md +20 -1
- package/presets/claude/php-laravel/skills/code-review/SKILL.md +10 -1
- package/presets/claude/svelte/agents/code-reviewer.md +14 -0
- package/presets/claude/svelte/rules/tooling-and-review/anti-hallucination-contract.md +2 -0
- package/presets/claude/svelte/rules/tooling-and-review/code-review-mr.md +20 -1
- package/presets/claude/svelte/skills/code-review/SKILL.md +11 -1
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +14 -0
- package/presets/cursor/android-kotlin/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/android-kotlin/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/android-kotlin/skills/code-review/SKILL.md +11 -1
- package/presets/cursor/go/agents/code-reviewer.md +36 -2
- package/presets/cursor/go/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/go/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/go/skills/code-review/SKILL.md +10 -1
- package/presets/cursor/ios-swift/agents/code-reviewer.md +14 -0
- package/presets/cursor/ios-swift/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/ios-swift/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/ios-swift/skills/code-review/SKILL.md +11 -1
- package/presets/cursor/java/agents/code-reviewer.md +36 -2
- package/presets/cursor/java/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/java/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/java/skills/code-review/SKILL.md +10 -1
- package/presets/cursor/mcp-ts/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/mcp-ts/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/mcp-ts/skills/code-review/SKILL.md +8 -0
- package/presets/cursor/next/agents/code-reviewer.md +14 -0
- package/presets/cursor/next/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/next/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/next/skills/code-review/SKILL.md +12 -2
- package/presets/cursor/nuxt/agents/code-reviewer.md +14 -0
- package/presets/cursor/nuxt/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/nuxt/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/nuxt/skills/code-review/SKILL.md +11 -1
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +36 -2
- package/presets/cursor/php-hexagonal/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/php-hexagonal/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/php-hexagonal/skills/code-review/SKILL.md +10 -1
- package/presets/cursor/php-laravel/agents/code-reviewer.md +36 -2
- package/presets/cursor/php-laravel/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/php-laravel/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/php-laravel/skills/code-review/SKILL.md +10 -1
- package/presets/cursor/svelte/agents/code-reviewer.md +14 -0
- package/presets/cursor/svelte/rules/anti-hallucination-contract.mdc +2 -0
- package/presets/cursor/svelte/rules/code-review-mr.mdc +20 -1
- package/presets/cursor/svelte/skills/code-review/SKILL.md +11 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +14 -0
- package/presets/mavis/android-kotlin/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/android-kotlin/rules/code-review-mr.md +20 -1
- package/presets/mavis/android-kotlin/skills/code-review/SKILL.md +11 -1
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +36 -2
- package/presets/mavis/go/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/go/rules/code-review-mr.md +20 -1
- package/presets/mavis/go/skills/code-review/SKILL.md +10 -1
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +14 -0
- package/presets/mavis/ios-swift/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/ios-swift/rules/code-review-mr.md +20 -1
- package/presets/mavis/ios-swift/skills/code-review/SKILL.md +11 -1
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +36 -2
- package/presets/mavis/java/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/java/rules/code-review-mr.md +20 -1
- package/presets/mavis/java/skills/code-review/SKILL.md +10 -1
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/mcp-ts/rules/code-review-mr.md +20 -1
- package/presets/mavis/mcp-ts/skills/code-review/SKILL.md +8 -0
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/agents/code-reviewer.md +14 -0
- package/presets/mavis/next/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/next/rules/code-review-mr.md +20 -1
- package/presets/mavis/next/skills/code-review/SKILL.md +12 -2
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +14 -0
- package/presets/mavis/nuxt/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/nuxt/rules/code-review-mr.md +20 -1
- package/presets/mavis/nuxt/skills/code-review/SKILL.md +11 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +36 -2
- package/presets/mavis/php-hexagonal/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/php-hexagonal/rules/code-review-mr.md +20 -1
- package/presets/mavis/php-hexagonal/skills/code-review/SKILL.md +10 -1
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +36 -2
- package/presets/mavis/php-laravel/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/php-laravel/rules/code-review-mr.md +20 -1
- package/presets/mavis/php-laravel/skills/code-review/SKILL.md +10 -1
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +14 -0
- package/presets/mavis/svelte/rules/anti-hallucination-contract.md +2 -0
- package/presets/mavis/svelte/rules/code-review-mr.md +20 -1
- package/presets/mavis/svelte/skills/code-review/SKILL.md +11 -1
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +14 -0
- package/presets/opencode/android-kotlin/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/android-kotlin/rules/code-review-mr.md +20 -1
- package/presets/opencode/android-kotlin/skills/code-review/SKILL.md +11 -1
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +36 -2
- package/presets/opencode/go/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/go/rules/code-review-mr.md +20 -1
- package/presets/opencode/go/skills/code-review/SKILL.md +10 -1
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +14 -0
- package/presets/opencode/ios-swift/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/ios-swift/rules/code-review-mr.md +20 -1
- package/presets/opencode/ios-swift/skills/code-review/SKILL.md +11 -1
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +36 -2
- package/presets/opencode/java/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/java/rules/code-review-mr.md +20 -1
- package/presets/opencode/java/skills/code-review/SKILL.md +10 -1
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/mcp-ts/rules/code-review-mr.md +20 -1
- package/presets/opencode/mcp-ts/skills/code-review/SKILL.md +8 -0
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/agents/code-reviewer.md +14 -0
- package/presets/opencode/next/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/next/rules/code-review-mr.md +20 -1
- package/presets/opencode/next/skills/code-review/SKILL.md +12 -2
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +14 -0
- package/presets/opencode/nuxt/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/nuxt/rules/code-review-mr.md +20 -1
- package/presets/opencode/nuxt/skills/code-review/SKILL.md +11 -1
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +36 -2
- package/presets/opencode/php-hexagonal/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/php-hexagonal/rules/code-review-mr.md +20 -1
- package/presets/opencode/php-hexagonal/skills/code-review/SKILL.md +10 -1
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +36 -2
- package/presets/opencode/php-laravel/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/php-laravel/rules/code-review-mr.md +20 -1
- package/presets/opencode/php-laravel/skills/code-review/SKILL.md +10 -1
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +14 -0
- package/presets/opencode/svelte/rules/anti-hallucination-contract.md +2 -0
- package/presets/opencode/svelte/rules/code-review-mr.md +20 -1
- package/presets/opencode/svelte/skills/code-review/SKILL.md +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.2.
|
|
3
|
+
## 0.2.51
|
|
4
|
+
|
|
5
|
+
### A shared `.ai.local/` rel is counted once
|
|
6
|
+
|
|
7
|
+
- **One file, one count.** A rel that several installed tools ship is reported by the first pass of the command. A later pass does not add it again and does not replace its proposal. A later pass whose template already matches the file adopts it and drops that proposal.
|
|
8
|
+
- **Fast-forward still needs a base.** `update --merge-ai-local` rewrites a file only when the recorded base still matches. An edit, and a file that predates `.template-base.json`, stays put.
|
|
9
|
+
|
|
10
|
+
### The self-learning loop writes a lesson only when a path exists
|
|
11
|
+
|
|
12
|
+
- **No slogan bullets.** Two tasks that share `correction:prefer-at-imports` and no `paths` leave `conventions.md` unchanged (`pending-lesson` in `--status`).
|
|
13
|
+
- **Slots.** A signal may carry `paths` (1–8 repo-relative paths) and `command` (a package script name). The bullet names the path and, when agreed, the script.
|
|
14
|
+
- **Aliases and catalog.** `.ai.local/signature-aliases.json` merges signatures. `.ai.local/signature-catalog.json` may supply the path. Neither file is created by `init`.
|
|
15
|
+
- **Unload.** Two later tasks with the same signature remove that bullet (`unloaded`) without restoring the rest of `conventions.md`. The printed report lists `unloaded` on its own, and a pathless repeat is `pending lesson`, not a dedup no-op.
|
|
16
|
+
|
|
17
|
+
### `.ai.local/` template drift is recorded, reported, and optionally fast-forwarded
|
|
18
|
+
|
|
19
|
+
- **Record.** `init` / `update` write `.ai.local/.template-base.json` — `{schemaVersion, packageVersion, files: {rel: {sha256, normSha256, source}}}` — for exactly the rels whose bytes are a shipped template byte: the ones the seed wrote plus a file that already holds the current template. Sorted, no timestamp, `source` = `<tool>/<preset>`. Your own bytes are never recorded as a base, so a later release cannot mistake an edit made before the record existed for an untouched copy. A record whose `schemaVersion` is newer than the CLI is left untouched with a warning. It stays out of `<tool>/.ai-rules-install.json`, so `clean <tool>` still removes nothing under `.ai.local/`.
|
|
20
|
+
- **Default report.** Plain `update` prints one tree-level line when anything drifted (`.ai.local drift: 3 behind template, 1 edited locally (run with --merge-ai-local to fast-forward the untouched ones)`), once per tree rather than once per installed tool. Every installed tool's pass classifies its own map. Each rel is counted once, so a tree seeded first by `claude` or `mavis` reports the same files as a `cursor`-first one. The line is printed once, after the last pass of the command.
|
|
21
|
+
- **Opt-in merge.** `update --merge-ai-local` (and `init … --merge-ai-local`) rewrites a file only when its EOL- and trailing-newline-normalised digest still matches the recorded base. A file that already holds the current template but is not recorded is **adopted**: the run records the template digests and writes nothing — including on a plain `update`, which is how a pre-feature tree and a manually applied proposal converge. A file that differs from both the base and the current template is kept byte-identical, reported as edited, and its unified diff plus the preset copy land in `.ai.local/.rollback/template-drift/` (`*.diff`, `*.template-new`, never a `.md`, never a conflict marker). A base written by another tool or preset is a noop. A rel with no base gets one proposal, from the first pass, not one per tool.
|
|
22
|
+
- **Guards.** Every new path passes `assertSafeDest` (a symlinked or escaping destination warns, skips the merge, and still exits 0), the record, every fast-forward and every sink clear go through the install transaction so a failed install restores them, and the rel allowlist comes from the preset tree and excludes `.ai.local/team/**` — `team/README.md` and `team/fixtures/**` are refreshed by the seed, `team/tasks/**`, `requirements/**`, `adr/**`, and engine runtime files are never read for a decision or written.
|
|
23
|
+
- **Goldens.** The new rel is captured with `packageVersion` pinned in `scripts/lib/cli-golden.mjs`, so the 40 CLI fixtures do not churn on every version bump.
|
|
24
|
+
- **Documented.** `docs/LOCAL-OVERLAY.md` § Template drift covers the record, the summary line, the flag, the sink, the first-run adoption and what stays manual; the "never overwritten" sentence is qualified, not removed.
|
|
25
|
+
|
|
26
|
+
### The manifest writer follows the task directory's slug
|
|
27
|
+
|
|
28
|
+
- **Foreign slug.** The task directory now owns the slug: `upsert` rewrites `manifest.slug` instead of preserving whatever a copied manifest carried, which used to fail `check` with no repair path.
|
|
29
|
+
- **Documented.** The package README lists `manifest.mjs` as the seventh seeded script and shows the `init` / `upsert` / `check` forms; producers merge their receipt with it rather than editing the JSON by hand.
|
|
30
|
+
|
|
31
|
+
### The self-learning ledger keeps repo-relative paths
|
|
32
|
+
|
|
33
|
+
- **No host paths in a committed file.** `rule-improver` serialized the absolute `target` into `.ai.local/rule-changes.jsonl`, which is committed — so the machine layout leaked into the repo (`agent-artifacts-no-local-paths`). The ledger now stores a project-relative path (`toLedgerTarget`) and resolves it back for file I/O (`resolveLedgerTarget`); a target that escapes the project root is rejected instead of written. The improver's printed report renders the same relative form.
|
|
34
|
+
- **Legacy rows still roll back.** A row written by an older engine keeps its absolute `target` and is resolved as-is, so `--rollback` works on ledgers that predate the change.
|
|
35
|
+
- **Gate.** `test-rule-improver-ledger.mjs` covers the serialization, the escape rejection and the legacy path, is wired into `check-preset-structure.sh`, and runs as `yarn test:rule-improver`.
|
|
36
|
+
|
|
37
|
+
### Retro findings carry a category
|
|
38
|
+
|
|
39
|
+
- **Ledger field.** A signal may set `finding_category` — `correctness`, `contract`, `perf`, `hygiene`, or `process` — validated by `signals.mjs` when present and absent on rows written before the field existed. Gate-derived signals default to `process` (`derive-gate-signals.mjs`).
|
|
40
|
+
- **Why.** A repeated `gate-changes-requested` row only said that some gate rejected something; without the defect class it cannot be turned into a rule. A retro that classifies a finding appends its own categorized row instead of rewriting the gate row.
|
|
41
|
+
|
|
42
|
+
### The review contract is what a consumer installs
|
|
43
|
+
|
|
44
|
+
- **No local registry in the agent.** `code-reviewer` no longer tells every consumer to write a 28-row table from `.ai.local/rules/preset-development-requirements.md`. That file is this repository's overlay, not a shipped preset.
|
|
45
|
+
- **Skills carry the new review rules.** Re-review, depth passes, `confidence`, and `## Not verified` are in each stack's `code-review` skill. The shared `receiving-code-review` stem is marker-only, so the four re-review rules are copied into the skill.
|
|
46
|
+
|
|
47
|
+
### Upgrade
|
|
48
|
+
|
|
49
|
+
- The ledger fix is seeded skip-if-exists: delete `.ai.local/scripts/rule-improver.mjs` to take the relative-path version. Ledger rows written with an absolute `target` keep working, so no migration is needed.
|
|
50
|
+
- The hook side (`<platform>/hooks/chain-team-phases.sh`) is managed, so `update` replaces it; an entry whose `status` was written as a receipt outcome now stalls with the rewrite command instead of a generic missing receipt.
|
|
51
|
+
- `update --merge-ai-local` fast-forwards a file whose recorded base still matches. It does not refresh a pre-record engine script; delete that script to take the seeded copy.
|
|
52
|
+
|
|
53
|
+
## 0.2.50
|
|
54
|
+
|
|
55
|
+
`0.2.49` was never published (no tag, no npm version) — its notes ship as `0.2.50`.
|
|
4
56
|
|
|
5
57
|
### Interactive questions: the free-form answer is mandatory, the “Other” option is not
|
|
6
58
|
|
|
@@ -48,6 +100,7 @@
|
|
|
48
100
|
- Run `npx @bonesofspring/ai-rules update`. The writer is seeded skip-if-exists — delete `.ai.local/scripts/manifest.mjs` to take the hardened copy, then run `node .ai.local/scripts/manifest.mjs check --slug <slug>` on every task with an open entry: a manifest written before 0.2.46 can carry `status: "changes_requested"` or a stale receipt, and `check` names the entry and the repair command.
|
|
49
101
|
- The new requestable stem `interactive-questions` ships with the preset; the always-on quality rule points at it. No always-on slot added, no install-path change.
|
|
50
102
|
|
|
103
|
+
|
|
51
104
|
## 0.2.48
|
|
52
105
|
|
|
53
106
|
### Interactive questions are the preferred way to ask the user
|
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ Presets for **Cursor**, **Claude Code**, **Mavis** (MiniMax `mcode`), and **Open
|
|
|
5
5
|
```bash
|
|
6
6
|
npx @bonesofspring/ai-rules init multi --preset next
|
|
7
7
|
npx @bonesofspring/ai-rules update # reinstall tools already recorded in this repo
|
|
8
|
+
npx @bonesofspring/ai-rules update --merge-ai-local # fast-forward files whose recorded base still matches; edits and pre-record files stay put
|
|
8
9
|
npx @bonesofspring/ai-rules clean cursor # never deletes .ai.local/
|
|
9
10
|
```
|
|
10
11
|
|
|
@@ -21,6 +22,7 @@ Run `init` from the **app root** (`--cwd` if needed). Default `--preset` is `nex
|
|
|
21
22
|
| MCP | `.cursor/mcp.json` (merge) | **`.mcp.json`** (merge) | `.mavis/mcp.json` (merge) | `opencode.json` (merge) |
|
|
22
23
|
| Root agents | `REPO_AGENTS.md` → `AGENTS.md` (same file on all four) | | | |
|
|
23
24
|
| `/task` artifacts | **`.ai.local/team/`** (shared; templates refreshed; `tasks/<slug>/` never overwritten) | | | |
|
|
25
|
+
| Template drift | **`.ai.local/.template-base.json`** (shared; one record per tree of files that hold a shipped template byte; `update` prints one drift line, `update --merge-ai-local` fast-forwards a file only when its recorded base still matches and reports the rest) | | | |
|
|
24
26
|
| Self-learning engine | **`.ai.local/scripts/`** (shared; seven scripts — the engine plus `manifest.mjs`, the manifest writer; existing files never overwritten) | | | |
|
|
25
27
|
| Specs seed | `docs/specs/` copied only if the directory is **absent** | | | |
|
|
26
28
|
|
|
@@ -50,7 +52,7 @@ node .ai.local/scripts/manifest.mjs check --slug <slug>
|
|
|
50
52
|
|
|
51
53
|
Producers merge their receipt with it — the manifest is a whole-file merge target, never a fragment edit.
|
|
52
54
|
|
|
53
|
-
Living exceptions: **`.ai.local/rules/`** and **`.ai.local/conventions.md`** (`init` does not overwrite them). Overlay does not load `.ai.local/team/**` as rules.
|
|
55
|
+
Living exceptions: **`.ai.local/rules/`** and **`.ai.local/conventions.md`** (`init` does not overwrite them). The only exception is opt-in and hash-gated: `update --merge-ai-local` fast-forwards a file whose recorded base in `.ai.local/.template-base.json` still matches, keeps an edited file byte-identical, and diverts its unified diff to `.ai.local/.rollback/template-drift/` (never a `.md`, never a conflict marker). Plain `update` only prints one drift line and records the files that already hold the shipped template; your own bytes never become a base. Overlay does not load `.ai.local/team/**` as rules; see [`docs/LOCAL-OVERLAY.md`](docs/LOCAL-OVERLAY.md#template-drift).
|
|
54
56
|
|
|
55
57
|
**`clean <tool>`** removes only CLI-managed paths under that tool root. It does **not** wipe the whole `.cursor/` / `.claude/` tree, and it **never** deletes `.ai.local/`. Root `AGENTS.md` is removed only when no other tool install remains.
|
|
56
58
|
|
package/bin/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ const path = require('path');
|
|
|
7
7
|
const { cmdInitMavis, cmdCleanMavis } = require('./mavis-install');
|
|
8
8
|
const { cmdInitOpencode, cmdCleanOpencode } = require('./opencode-install');
|
|
9
9
|
const { seedAiLocalTeam } = require('./lib/seed-ai-local-team');
|
|
10
|
+
const { flushAiLocalDriftSummary, flushAllAiLocalDriftSummaries } = require('./lib/ai-local-drift');
|
|
10
11
|
const { assertSafeDest, escapesRoot, resolveManagedPath } = require('./lib/safe-path');
|
|
11
12
|
const {
|
|
12
13
|
createInstallTransaction,
|
|
@@ -26,6 +27,10 @@ const {
|
|
|
26
27
|
stripMergedConfigs,
|
|
27
28
|
} = require('./lib/merged-config');
|
|
28
29
|
|
|
30
|
+
// A pass that fails before the command boundary (`cmdInit` exits the process)
|
|
31
|
+
// must still print the drift line its completed passes accumulated.
|
|
32
|
+
process.on('exit', flushAllAiLocalDriftSummaries);
|
|
33
|
+
|
|
29
34
|
const FAIL_PHASE_ENV = 'AI_RULES_CLI_FAIL_PHASE';
|
|
30
35
|
const MANIFEST_SCHEMA_VERSION = 2;
|
|
31
36
|
|
|
@@ -81,12 +86,15 @@ function printHelp() {
|
|
|
81
86
|
Usage:
|
|
82
87
|
ai-rules init <cursor|claude|mavis|opencode|multi> [--preset <name>]
|
|
83
88
|
ai-rules init <cursor|claude|mavis|opencode|multi> <preset-name>
|
|
84
|
-
ai-rules update [--cwd <dir>]
|
|
89
|
+
ai-rules update [--merge-ai-local] [--cwd <dir>]
|
|
85
90
|
ai-rules clean <cursor|claude|mavis|opencode> [--cwd <dir>]
|
|
86
91
|
|
|
87
92
|
Options:
|
|
88
|
-
--preset <name>
|
|
89
|
-
--cwd <dir>
|
|
93
|
+
--preset <name> Preset name (default: ${DEFAULT_PRESET})
|
|
94
|
+
--cwd <dir> Target project directory (default: current working directory)
|
|
95
|
+
--merge-ai-local Fast-forward .ai.local/ files whose recorded base still matches
|
|
96
|
+
the preset template; a file you edited is kept and its diff is
|
|
97
|
+
written to .ai.local/.rollback/template-drift/
|
|
90
98
|
|
|
91
99
|
Notes:
|
|
92
100
|
init merges into the target directory; same-named preset files are overwritten (no backups are kept).
|
|
@@ -101,6 +109,11 @@ Notes:
|
|
|
101
109
|
init refuses to write through a symlinked destination (tool dirs, AGENTS.md, rules dirs, ...).
|
|
102
110
|
All init targets seed .ai.local/team/ (shared pipeline artifacts; never overwritten task slugs; not removed by clean)
|
|
103
111
|
and .ai.local/conventions.md (living gotchas; seeded from the preset template only when absent, never overwritten).
|
|
112
|
+
.ai.local/.template-base.json records the digest of every .ai.local/ rel that holds a shipped template byte; it
|
|
113
|
+
stays out of the install manifest, so clean never removes it. Plain update prints one drift line per tree and
|
|
114
|
+
records a file that already holds the template; update --merge-ai-local rewrites only the files whose recorded base
|
|
115
|
+
still matches it, keeps an edited file byte-identical, and diverts its unified diff plus the template copy to
|
|
116
|
+
.ai.local/.rollback/template-drift/ (never a .md, never a conflict marker).
|
|
104
117
|
Because .ai.local/team/ is shared, ANY init consolidates every legacy .cursor|.claude|.mavis|.opencode/team/ into it,
|
|
105
118
|
not just the tool being installed. Consolidation is non-destructive: every non-README.md entry is migrated and copied
|
|
106
119
|
to a timestamped .ai.local/.rollback/legacy-team-<stamp>/ backup before it is removed, colliding task slugs are kept
|
|
@@ -111,7 +124,7 @@ Notes:
|
|
|
111
124
|
OpenCode init copies into .opencode/ plus REPO_AGENTS.md → <cwd>/AGENTS.md; MCP merges into <cwd>/opencode.json (never ~/.config/opencode/**).
|
|
112
125
|
All init targets also copy REPO_AGENTS.md → <cwd>/AGENTS.md (repo-root cross-tool agents file; overwrite; all next platforms ship the same file).
|
|
113
126
|
init multi installs every platform that has released the preset (cursor, claude, plus mavis/opencode when listed in releasedStacks). Not a clean target.
|
|
114
|
-
update reinstalls each tool that already has <tool>/.ai-rules-install.json, using the preset field that init wrote. Tools without a manifest stay uninstalled. The recorded preset is kept. update does not accept --preset or a tool name.
|
|
127
|
+
update reinstalls each tool that already has <tool>/.ai-rules-install.json, using the preset field that init wrote. Tools without a manifest stay uninstalled. The recorded preset is kept. update does not accept --preset or a tool name; --merge-ai-local is allowed on update and on init.
|
|
115
128
|
When <cwd>/docs/specs/ is absent, init also seeds INDEX.md stub + _templates/* from package assets (never overwrites an existing INDEX).
|
|
116
129
|
clean removes only files the last init copied and that are unchanged since; consumer files are kept.
|
|
117
130
|
Merged configs are never deleted wholesale: clean strips the entries init added (shipped MCP servers, preset
|
|
@@ -201,6 +214,10 @@ function parseArgs(argv) {
|
|
|
201
214
|
args.help = true;
|
|
202
215
|
continue;
|
|
203
216
|
}
|
|
217
|
+
if (a === '--merge-ai-local') {
|
|
218
|
+
args.mergeAiLocal = true;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
204
221
|
if (a.startsWith('-') && a !== '-') {
|
|
205
222
|
args.unknownOption = a;
|
|
206
223
|
continue;
|
|
@@ -662,7 +679,7 @@ function loadReleasedStacks(platform) {
|
|
|
662
679
|
}
|
|
663
680
|
}
|
|
664
681
|
|
|
665
|
-
function cmdInitMulti(preset, cwdOption) {
|
|
682
|
+
function cmdInitMulti(preset, cwdOption, opts) {
|
|
666
683
|
const presetName = preset === undefined || preset === '' ? DEFAULT_PRESET : preset;
|
|
667
684
|
const invalid = validatePresetName(presetName);
|
|
668
685
|
if (invalid) {
|
|
@@ -670,6 +687,9 @@ function cmdInitMulti(preset, cwdOption) {
|
|
|
670
687
|
process.exit(1);
|
|
671
688
|
}
|
|
672
689
|
|
|
690
|
+
const cwd = resolveTargetCwd(cwdOption);
|
|
691
|
+
// One command, one tree, one summary: each pass accumulates, the loop end prints.
|
|
692
|
+
const passOpts = { ...opts, deferAiLocalSummary: true };
|
|
673
693
|
const installed = [];
|
|
674
694
|
const skipped = [];
|
|
675
695
|
for (const tool of MULTI_INSTALL_ORDER) {
|
|
@@ -682,13 +702,14 @@ function cmdInitMulti(preset, cwdOption) {
|
|
|
682
702
|
continue;
|
|
683
703
|
}
|
|
684
704
|
console.log(`\n=== init ${tool} --preset ${presetName} ===`);
|
|
685
|
-
cmdInit(tool, presetName, cwdOption);
|
|
705
|
+
cmdInit(tool, presetName, cwdOption, passOpts);
|
|
686
706
|
installed.push(tool);
|
|
687
707
|
}
|
|
688
708
|
if (installed.length === 0) {
|
|
689
709
|
console.error(`multi: no platforms installed for preset "${presetName}".`);
|
|
690
710
|
process.exit(1);
|
|
691
711
|
}
|
|
712
|
+
flushAiLocalDriftSummary(cwd);
|
|
692
713
|
const skipNote = skipped.length > 0 ? `; skipped ${skipped.join(', ')}` : '';
|
|
693
714
|
console.log(`\nDone. multi installed ${installed.join(', ')}${skipNote}`);
|
|
694
715
|
}
|
|
@@ -718,7 +739,7 @@ function updatePresetReady(tool, presetName) {
|
|
|
718
739
|
* Reinstall every tool that has an install manifest, using the preset recorded there.
|
|
719
740
|
* Validates the whole plan before the first init so a bad manifest does not partially update.
|
|
720
741
|
*/
|
|
721
|
-
function cmdUpdate(cwdOption) {
|
|
742
|
+
function cmdUpdate(cwdOption, opts) {
|
|
722
743
|
const cwd = resolveTargetCwd(cwdOption);
|
|
723
744
|
const errors = [];
|
|
724
745
|
const found = [];
|
|
@@ -774,14 +795,19 @@ function cmdUpdate(cwdOption) {
|
|
|
774
795
|
|
|
775
796
|
const plan = found.map((item) => `${item.tool} (${item.preset})`).join(', ');
|
|
776
797
|
console.log(`update: reinstalling ${plan}`);
|
|
798
|
+
// One command, one tree, one summary: each tool's pass accumulates, this flushes.
|
|
799
|
+
const passOpts = { ...opts, deferAiLocalSummary: true };
|
|
777
800
|
for (const item of found) {
|
|
778
801
|
console.log(`\n=== update ${item.tool} --preset ${item.preset} ===`);
|
|
779
|
-
cmdInit(item.tool, item.preset, cwdOption);
|
|
802
|
+
cmdInit(item.tool, item.preset, cwdOption, passOpts);
|
|
780
803
|
}
|
|
804
|
+
flushAiLocalDriftSummary(cwd);
|
|
781
805
|
console.log(`\nDone. update reinstalled ${plan}`);
|
|
782
806
|
}
|
|
783
807
|
|
|
784
|
-
function cmdInit(tool, preset, cwdOption) {
|
|
808
|
+
function cmdInit(tool, preset, cwdOption, opts) {
|
|
809
|
+
const mergeAiLocal = Boolean(opts && opts.mergeAiLocal);
|
|
810
|
+
const deferSummary = Boolean(opts && opts.deferAiLocalSummary);
|
|
785
811
|
if (tool === 'mavis') {
|
|
786
812
|
cmdInitMavis({
|
|
787
813
|
preset,
|
|
@@ -793,8 +819,10 @@ function cmdInit(tool, preset, cwdOption) {
|
|
|
793
819
|
seedAiLocalTeam,
|
|
794
820
|
installMcpJson,
|
|
795
821
|
getPackageRoot,
|
|
822
|
+
mergeAiLocal,
|
|
796
823
|
},
|
|
797
824
|
});
|
|
825
|
+
if (!deferSummary) flushAiLocalDriftSummary(resolveTargetCwd(cwdOption));
|
|
798
826
|
return;
|
|
799
827
|
}
|
|
800
828
|
if (tool === 'opencode') {
|
|
@@ -807,8 +835,10 @@ function cmdInit(tool, preset, cwdOption) {
|
|
|
807
835
|
seedDocsSpecsIfAbsent,
|
|
808
836
|
seedAiLocalTeam,
|
|
809
837
|
getPackageRoot,
|
|
838
|
+
mergeAiLocal,
|
|
810
839
|
},
|
|
811
840
|
});
|
|
841
|
+
if (!deferSummary) flushAiLocalDriftSummary(resolveTargetCwd(cwdOption));
|
|
812
842
|
return;
|
|
813
843
|
}
|
|
814
844
|
const cfg = PRESETS[tool];
|
|
@@ -900,7 +930,15 @@ function cmdInit(tool, preset, cwdOption) {
|
|
|
900
930
|
if (seedDocsSpecsIfAbsent(packageRoot, cwd) && !docsSpecsExisted) {
|
|
901
931
|
tx.addCreated(docsSpecsDir);
|
|
902
932
|
}
|
|
903
|
-
const teamResult = seedAiLocalTeam({
|
|
933
|
+
const teamResult = seedAiLocalTeam({
|
|
934
|
+
cwd,
|
|
935
|
+
presetTeamSrc: path.join(base, 'team'),
|
|
936
|
+
source: `${tool}/${presetName}`,
|
|
937
|
+
packageVersion: getPackageVersion(packageRoot),
|
|
938
|
+
mergeAiLocal,
|
|
939
|
+
writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
|
|
940
|
+
trackFile: (dest, label) => tx.track(dest, label),
|
|
941
|
+
});
|
|
904
942
|
for (const created of teamResult.createdPaths || []) {
|
|
905
943
|
tx.addCreated(created);
|
|
906
944
|
}
|
|
@@ -959,6 +997,7 @@ function cmdInit(tool, preset, cwdOption) {
|
|
|
959
997
|
process.exit(1);
|
|
960
998
|
}
|
|
961
999
|
|
|
1000
|
+
if (!deferSummary) flushAiLocalDriftSummary(cwd);
|
|
962
1001
|
console.log(`Done. ${toolRoot} installed at ${toolRootAbs} (preset: ${presetName})`);
|
|
963
1002
|
}
|
|
964
1003
|
|
|
@@ -1118,10 +1157,10 @@ function main() {
|
|
|
1118
1157
|
process.exit(1);
|
|
1119
1158
|
}
|
|
1120
1159
|
if (tool === 'multi') {
|
|
1121
|
-
cmdInitMulti(preset, parsed.cwd);
|
|
1160
|
+
cmdInitMulti(preset, parsed.cwd, parsed);
|
|
1122
1161
|
return;
|
|
1123
1162
|
}
|
|
1124
|
-
cmdInit(tool, preset, parsed.cwd);
|
|
1163
|
+
cmdInit(tool, preset, parsed.cwd, parsed);
|
|
1125
1164
|
return;
|
|
1126
1165
|
}
|
|
1127
1166
|
if (command === 'update') {
|
|
@@ -1135,7 +1174,7 @@ function main() {
|
|
|
1135
1174
|
);
|
|
1136
1175
|
process.exit(1);
|
|
1137
1176
|
}
|
|
1138
|
-
cmdUpdate(parsed.cwd);
|
|
1177
|
+
cmdUpdate(parsed.cwd, parsed);
|
|
1139
1178
|
return;
|
|
1140
1179
|
}
|
|
1141
1180
|
if (command === 'clean') {
|