@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
|
@@ -11,8 +11,18 @@ const fs = require('fs');
|
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const { assertSafeDest } = require('./safe-path');
|
|
13
13
|
const { ENGINE_SCRIPTS, ENGINE_SOURCE_RELATIVE } = require('./engine-scripts');
|
|
14
|
+
const { runTemplateDrift } = require('./ai-local-drift');
|
|
14
15
|
|
|
15
16
|
const LEGACY_TOOLS = ['cursor', 'claude', 'mavis', 'opencode'];
|
|
17
|
+
/** Content of `.ai.local/.gitignore`; also the template digest the record tracks. */
|
|
18
|
+
const AI_LOCAL_GITIGNORE = [
|
|
19
|
+
'# Files written by the in-task self-learning engine and by legacy-team',
|
|
20
|
+
'# migration backups. Local safety net — never commit.',
|
|
21
|
+
'*.lock',
|
|
22
|
+
'*.tmp',
|
|
23
|
+
'.rollback/',
|
|
24
|
+
'',
|
|
25
|
+
].join('\n');
|
|
16
26
|
const POINTER_README = `# Agent team artifacts moved
|
|
17
27
|
|
|
18
28
|
Runtime artifacts now live at \`.ai.local/team/\` (shared across Cursor, Claude, Mavis, and OpenCode).
|
|
@@ -230,32 +240,33 @@ function ensureAiLocalIgnored(aiLocalRoot) {
|
|
|
230
240
|
return false;
|
|
231
241
|
}
|
|
232
242
|
fs.mkdirSync(aiLocalRoot, { recursive: true });
|
|
233
|
-
fs.writeFileSync(
|
|
234
|
-
ignoreFile,
|
|
235
|
-
[
|
|
236
|
-
'# Files written by the in-task self-learning engine and by legacy-team',
|
|
237
|
-
'# migration backups. Local safety net — never commit.',
|
|
238
|
-
'*.lock',
|
|
239
|
-
'*.tmp',
|
|
240
|
-
'.rollback/',
|
|
241
|
-
'',
|
|
242
|
-
].join('\n'),
|
|
243
|
-
);
|
|
243
|
+
fs.writeFileSync(ignoreFile, AI_LOCAL_GITIGNORE);
|
|
244
244
|
return true;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Preset-root-relative directory holding the shipped engine scripts.
|
|
249
|
+
* `presetTeamSrc` is `<presetBase>/team`, so three levels up is the preset root.
|
|
250
|
+
*/
|
|
251
|
+
function engineSourceDir(presetTeamSrc) {
|
|
252
|
+
if (!presetTeamSrc) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
return path.resolve(presetTeamSrc, '..', '..', '..', ...ENGINE_SOURCE_RELATIVE.split('/'));
|
|
256
|
+
}
|
|
257
|
+
|
|
247
258
|
/**
|
|
248
259
|
* Seed the shipped self-learning engine (`presets/_shared/ai-local/scripts/`)
|
|
249
260
|
* into `<cwd>/.ai.local/scripts/`. Skip-if-exists: a consumer edit is never
|
|
250
261
|
* overwritten and there is no `--force`. Returns the absolute paths this call
|
|
251
|
-
* created so an init rollback removes exactly those.
|
|
262
|
+
* created so an init rollback removes exactly those, plus the rels it wrote.
|
|
252
263
|
*/
|
|
253
264
|
function seedEngineScripts({ cwd, presetTeamSrc }) {
|
|
254
|
-
const result = { seeded: 0, skipped: 0, created: [] };
|
|
265
|
+
const result = { seeded: 0, skipped: 0, created: [], written: [] };
|
|
255
266
|
if (!presetTeamSrc) {
|
|
256
267
|
return result;
|
|
257
268
|
}
|
|
258
|
-
const sourceDir =
|
|
269
|
+
const sourceDir = engineSourceDir(presetTeamSrc);
|
|
259
270
|
if (!fs.existsSync(sourceDir) || !fs.statSync(sourceDir).isDirectory()) {
|
|
260
271
|
return result;
|
|
261
272
|
}
|
|
@@ -276,6 +287,7 @@ function seedEngineScripts({ cwd, presetTeamSrc }) {
|
|
|
276
287
|
copyFile(source, dest);
|
|
277
288
|
result.seeded += 1;
|
|
278
289
|
result.created.push(dest);
|
|
290
|
+
result.written.push(`.ai.local/scripts/${name}`);
|
|
279
291
|
}
|
|
280
292
|
if (!destExisted && result.created.length > 0) {
|
|
281
293
|
result.created.unshift(destDir);
|
|
@@ -291,43 +303,53 @@ function seedEngineScripts({ cwd, presetTeamSrc }) {
|
|
|
291
303
|
return result;
|
|
292
304
|
}
|
|
293
305
|
|
|
306
|
+
/** Rewrite `team/README.md` and `team/fixtures/`; returns the rels it wrote. */
|
|
294
307
|
function copyTemplates(presetTeamSrc, dest) {
|
|
308
|
+
const written = [];
|
|
295
309
|
if (!presetTeamSrc || !fs.existsSync(presetTeamSrc)) {
|
|
296
|
-
return;
|
|
310
|
+
return written;
|
|
297
311
|
}
|
|
298
312
|
const readme = path.join(presetTeamSrc, 'README.md');
|
|
299
313
|
if (fs.existsSync(readme)) {
|
|
300
314
|
copyFile(readme, path.join(dest, 'README.md'));
|
|
315
|
+
written.push('.ai.local/team/README.md');
|
|
301
316
|
}
|
|
302
317
|
const fixturesSrc = path.join(presetTeamSrc, 'fixtures');
|
|
303
318
|
if (fs.existsSync(fixturesSrc)) {
|
|
304
|
-
copyTree(fixturesSrc, path.join(dest, 'fixtures'));
|
|
319
|
+
const copied = copyTree(fixturesSrc, path.join(dest, 'fixtures')).copied;
|
|
320
|
+
for (const rel of copied) {
|
|
321
|
+
written.push(`.ai.local/team/fixtures/${rel}`);
|
|
322
|
+
}
|
|
305
323
|
}
|
|
306
324
|
const gitkeepSrc = path.join(presetTeamSrc, 'tasks', '.gitkeep');
|
|
307
325
|
if (fs.existsSync(gitkeepSrc) && !hasConsumerTaskSlugs(path.join(dest, 'tasks'))) {
|
|
308
326
|
copyFile(gitkeepSrc, path.join(dest, 'tasks', '.gitkeep'));
|
|
327
|
+
written.push('.ai.local/team/tasks/.gitkeep');
|
|
309
328
|
}
|
|
329
|
+
return written;
|
|
310
330
|
}
|
|
311
331
|
|
|
312
332
|
/**
|
|
313
333
|
* Seed `.ai.local/conventions.md` (the living-conventions file the overlay probes)
|
|
314
334
|
* from the preset template. Never overwrites an existing consumer file.
|
|
335
|
+
*
|
|
336
|
+
* @returns {string | null} the rel this call wrote
|
|
315
337
|
*/
|
|
316
338
|
function seedConventions(presetTeamSrc, cwd) {
|
|
317
339
|
if (!presetTeamSrc) {
|
|
318
|
-
return
|
|
340
|
+
return null;
|
|
319
341
|
}
|
|
320
342
|
const template = path.join(path.dirname(presetTeamSrc), 'ai-local', 'conventions.md');
|
|
321
343
|
if (!fs.existsSync(template)) {
|
|
322
|
-
return
|
|
344
|
+
return null;
|
|
323
345
|
}
|
|
324
346
|
const dest = path.join(cwd, '.ai.local', 'conventions.md');
|
|
325
347
|
if (fs.existsSync(dest)) {
|
|
326
|
-
return
|
|
348
|
+
return null;
|
|
327
349
|
}
|
|
328
350
|
copyFile(template, dest);
|
|
329
351
|
console.log('Seeded .ai.local/conventions.md');
|
|
330
|
-
return
|
|
352
|
+
return '.ai.local/conventions.md';
|
|
331
353
|
}
|
|
332
354
|
|
|
333
355
|
/**
|
|
@@ -340,7 +362,7 @@ function seedConventions(presetTeamSrc, cwd) {
|
|
|
340
362
|
*/
|
|
341
363
|
function seedAiLocalRules(presetTeamSrc, cwd) {
|
|
342
364
|
if (!presetTeamSrc) {
|
|
343
|
-
return { seeded: false, created: [] };
|
|
365
|
+
return { seeded: false, created: [], written: [] };
|
|
344
366
|
}
|
|
345
367
|
const libraryDir = path.join(path.dirname(presetTeamSrc), 'ai-local', 'rules-library');
|
|
346
368
|
if (!fs.existsSync(libraryDir) || !fs.statSync(libraryDir).isDirectory()) {
|
|
@@ -348,6 +370,7 @@ function seedAiLocalRules(presetTeamSrc, cwd) {
|
|
|
348
370
|
}
|
|
349
371
|
const destDir = path.join(cwd, '.ai.local', 'rules-library');
|
|
350
372
|
assertSafeDest(cwd, destDir, '.ai.local/rules-library');
|
|
373
|
+
const written = [];
|
|
351
374
|
let copied = 0;
|
|
352
375
|
let skipped = 0;
|
|
353
376
|
for (const entry of fs.readdirSync(libraryDir)) {
|
|
@@ -360,13 +383,21 @@ function seedAiLocalRules(presetTeamSrc, cwd) {
|
|
|
360
383
|
}
|
|
361
384
|
copyFile(src, dest);
|
|
362
385
|
copied += 1;
|
|
386
|
+
written.push(`.ai.local/rules-library/${entry}`);
|
|
363
387
|
}
|
|
364
388
|
if (copied > 0) {
|
|
365
389
|
console.log(`Seeded .ai.local/rules-library/ (${copied} rules; ${skipped} already present)`);
|
|
366
390
|
}
|
|
367
|
-
activateRouterPagesSeed(cwd, libraryDir);
|
|
391
|
+
const activated = activateRouterPagesSeed(cwd, libraryDir);
|
|
392
|
+
if (activated) {
|
|
393
|
+
written.push(activated);
|
|
394
|
+
}
|
|
368
395
|
const active = seedActiveOverlayRules(presetTeamSrc, cwd);
|
|
369
|
-
return {
|
|
396
|
+
return {
|
|
397
|
+
seeded: copied > 0 || active.seeded,
|
|
398
|
+
created: active.created,
|
|
399
|
+
written: [...written, ...active.written],
|
|
400
|
+
};
|
|
370
401
|
}
|
|
371
402
|
|
|
372
403
|
/**
|
|
@@ -375,15 +406,16 @@ function seedAiLocalRules(presetTeamSrc, cwd) {
|
|
|
375
406
|
*/
|
|
376
407
|
function seedActiveOverlayRules(presetTeamSrc, cwd) {
|
|
377
408
|
if (!presetTeamSrc) {
|
|
378
|
-
return { seeded: false, created: [] };
|
|
409
|
+
return { seeded: false, created: [], written: [] };
|
|
379
410
|
}
|
|
380
411
|
const rulesDir = path.join(path.dirname(presetTeamSrc), 'ai-local', 'rules');
|
|
381
412
|
if (!fs.existsSync(rulesDir) || !fs.statSync(rulesDir).isDirectory()) {
|
|
382
|
-
return { seeded: false, created: [] };
|
|
413
|
+
return { seeded: false, created: [], written: [] };
|
|
383
414
|
}
|
|
384
415
|
const destDir = path.join(cwd, '.ai.local', 'rules');
|
|
385
416
|
assertSafeDest(cwd, destDir, '.ai.local/rules');
|
|
386
417
|
const created = [];
|
|
418
|
+
const written = [];
|
|
387
419
|
for (const entry of fs.readdirSync(rulesDir)) {
|
|
388
420
|
if (!entry.endsWith('.md')) continue;
|
|
389
421
|
const src = path.join(rulesDir, entry);
|
|
@@ -392,11 +424,12 @@ function seedActiveOverlayRules(presetTeamSrc, cwd) {
|
|
|
392
424
|
if (fs.existsSync(dest)) continue;
|
|
393
425
|
copyFile(src, dest);
|
|
394
426
|
created.push(dest);
|
|
427
|
+
written.push(`.ai.local/rules/${entry}`);
|
|
395
428
|
}
|
|
396
429
|
if (created.length > 0) {
|
|
397
430
|
console.log(`Activated .ai.local/rules/ (${created.length} rule${created.length === 1 ? '' : 's'})`);
|
|
398
431
|
}
|
|
399
|
-
return { seeded: created.length > 0, created };
|
|
432
|
+
return { seeded: created.length > 0, created, written };
|
|
400
433
|
}
|
|
401
434
|
|
|
402
435
|
function hasStaticExport(cwd) {
|
|
@@ -418,14 +451,16 @@ function hasPagesApp(cwd) {
|
|
|
418
451
|
].some((rel) => fs.existsSync(path.join(cwd, rel)));
|
|
419
452
|
}
|
|
420
453
|
|
|
454
|
+
/** @returns {string | null} the rel written when the Pages Router seed activates */
|
|
421
455
|
function activateRouterPagesSeed(cwd, libraryDir) {
|
|
422
456
|
const seed = path.join(libraryDir, 'router-pages.md');
|
|
423
|
-
if (!fs.existsSync(seed) || !hasStaticExport(cwd) || !hasPagesApp(cwd)) return;
|
|
457
|
+
if (!fs.existsSync(seed) || !hasStaticExport(cwd) || !hasPagesApp(cwd)) return null;
|
|
424
458
|
const dest = path.join(cwd, '.ai.local', 'rules', 'router-pages.md');
|
|
425
459
|
assertSafeDest(cwd, dest, '.ai.local/rules/router-pages.md');
|
|
426
|
-
if (fs.existsSync(dest)) return;
|
|
460
|
+
if (fs.existsSync(dest)) return null;
|
|
427
461
|
copyFile(seed, dest);
|
|
428
462
|
console.log('Activated .ai.local/rules/router-pages.md (static export + Pages Router)');
|
|
463
|
+
return '.ai.local/rules/router-pages.md';
|
|
429
464
|
}
|
|
430
465
|
|
|
431
466
|
/**
|
|
@@ -564,13 +599,78 @@ function migrateLegacyTeams(cwd, dest) {
|
|
|
564
599
|
}
|
|
565
600
|
|
|
566
601
|
/**
|
|
567
|
-
*
|
|
602
|
+
* Every rel the preset can seed into `.ai.local/`, mapped to the template bytes.
|
|
603
|
+
* This is the allowlist the record and the merge use: it is built from the
|
|
604
|
+
* preset tree, never by walking the consumer's `.ai.local/`, so `team/tasks/**`,
|
|
605
|
+
* `requirements/**`, `adr/**`, and engine runtime state are unreachable.
|
|
606
|
+
*
|
|
607
|
+
* `.ai.local/team/**` is absent on purpose: `copyTemplates` rewrites
|
|
608
|
+
* `team/README.md` and `team/fixtures/**` unconditionally before anything can be
|
|
609
|
+
* classified, and `team/tasks/**` is consumer-owned, so recording any of them
|
|
610
|
+
* would promise a protection the seed does not give.
|
|
611
|
+
*
|
|
612
|
+
* @returns {Map<string, Buffer>} rel → template bytes
|
|
613
|
+
*/
|
|
614
|
+
function templateEntries(presetTeamSrc) {
|
|
615
|
+
const out = new Map();
|
|
616
|
+
const addFile = (rel, abs) => {
|
|
617
|
+
let stat;
|
|
618
|
+
try {
|
|
619
|
+
stat = fs.lstatSync(abs);
|
|
620
|
+
} catch {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
if (!stat.isFile()) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
out.set(rel, fs.readFileSync(abs));
|
|
627
|
+
};
|
|
628
|
+
const addDir = (relPrefix, dir, accept) => {
|
|
629
|
+
let stat;
|
|
630
|
+
try {
|
|
631
|
+
stat = fs.lstatSync(dir);
|
|
632
|
+
} catch {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
if (!stat.isDirectory()) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
for (const name of fs.readdirSync(dir).sort()) {
|
|
639
|
+
if (!accept(name)) continue;
|
|
640
|
+
addFile(`${relPrefix}${name}`, path.join(dir, name));
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
if (!presetTeamSrc) {
|
|
645
|
+
return out;
|
|
646
|
+
}
|
|
647
|
+
const presetBase = path.dirname(presetTeamSrc);
|
|
648
|
+
const libraryDir = path.join(presetBase, 'ai-local', 'rules-library');
|
|
649
|
+
addFile('.ai.local/conventions.md', path.join(presetBase, 'ai-local', 'conventions.md'));
|
|
650
|
+
addDir('.ai.local/rules-library/', libraryDir, (name) => name.endsWith('.md'));
|
|
651
|
+
// The activation seed is a template byte too: `activateRouterPagesSeed` copies it
|
|
652
|
+
// into `rules/` when the repo shape matches, and an active copy shipped by the
|
|
653
|
+
// preset keeps precedence because it is added after this line.
|
|
654
|
+
addFile('.ai.local/rules/router-pages.md', path.join(libraryDir, 'router-pages.md'));
|
|
655
|
+
addDir('.ai.local/rules/', path.join(presetBase, 'ai-local', 'rules'), (name) => name.endsWith('.md'));
|
|
656
|
+
const engineDir = engineSourceDir(presetTeamSrc);
|
|
657
|
+
if (engineDir) {
|
|
658
|
+
for (const name of ENGINE_SCRIPTS) {
|
|
659
|
+
addFile(`.ai.local/scripts/${name}`, path.join(engineDir, name));
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
out.set('.ai.local/.gitignore', Buffer.from(AI_LOCAL_GITIGNORE));
|
|
663
|
+
return out;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @param {{ cwd: string, presetTeamSrc?: string, source?: string, packageVersion?: string, mergeAiLocal?: boolean, writeFile?: (dest: string, content: string | Buffer, label: string) => void, trackFile?: (dest: string, label: string) => void }} options
|
|
568
668
|
* `createdPaths` lists what an init rollback may remove: the fresh-seed tree
|
|
569
669
|
* plus every engine module / ignore file this call created (never a path that
|
|
570
670
|
* already existed, never a consumer-modified file).
|
|
571
671
|
* @returns {{ created: boolean, createdPaths: string[], migrated: boolean, refreshed: boolean, conventionsSeeded: boolean, rulesLibrarySeeded: boolean, engineSeeded: boolean }}
|
|
572
672
|
*/
|
|
573
|
-
function seedAiLocalTeam({ cwd, presetTeamSrc }) {
|
|
673
|
+
function seedAiLocalTeam({ cwd, presetTeamSrc, source, packageVersion, mergeAiLocal, writeFile, trackFile }) {
|
|
574
674
|
const dest = destTeamRoot(cwd);
|
|
575
675
|
const aiLocalRoot = path.join(cwd, '.ai.local');
|
|
576
676
|
const empty = {
|
|
@@ -623,14 +723,32 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
|
|
|
623
723
|
...engine.created,
|
|
624
724
|
];
|
|
625
725
|
const migrated = migrateLegacyTeams(cwd, dest);
|
|
626
|
-
copyTemplates(presetTeamSrc, dest);
|
|
627
|
-
const
|
|
726
|
+
const templateWritten = copyTemplates(presetTeamSrc, dest);
|
|
727
|
+
const conventionsRel = seedConventions(presetTeamSrc, cwd);
|
|
628
728
|
const rulesSeed = seedAiLocalRules(presetTeamSrc, cwd);
|
|
629
729
|
const rulesLibrarySeeded = rulesSeed.seeded;
|
|
630
730
|
if (!freshPaths.includes(path.join(aiLocalRoot, 'rules'))) {
|
|
631
731
|
for (const created of rulesSeed.created) createdPaths.push(created);
|
|
632
732
|
}
|
|
633
733
|
|
|
734
|
+
const written = [
|
|
735
|
+
...templateWritten,
|
|
736
|
+
...(conventionsRel ? [conventionsRel] : []),
|
|
737
|
+
...rulesSeed.written,
|
|
738
|
+
...engine.written,
|
|
739
|
+
...(ignoreCreated ? ['.ai.local/.gitignore'] : []),
|
|
740
|
+
];
|
|
741
|
+
runTemplateDrift({
|
|
742
|
+
cwd,
|
|
743
|
+
written,
|
|
744
|
+
templates: templateEntries(presetTeamSrc),
|
|
745
|
+
source,
|
|
746
|
+
packageVersion,
|
|
747
|
+
mergeAiLocal,
|
|
748
|
+
writeFile,
|
|
749
|
+
trackFile,
|
|
750
|
+
});
|
|
751
|
+
|
|
634
752
|
if (migrated) {
|
|
635
753
|
console.log('Migrated legacy .{tool}/team → .ai.local/team');
|
|
636
754
|
}
|
|
@@ -642,7 +760,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
|
|
|
642
760
|
createdPaths,
|
|
643
761
|
migrated: false,
|
|
644
762
|
refreshed: false,
|
|
645
|
-
conventionsSeeded,
|
|
763
|
+
conventionsSeeded: Boolean(conventionsRel),
|
|
646
764
|
rulesLibrarySeeded,
|
|
647
765
|
engineSeeded: engine.seeded > 0,
|
|
648
766
|
};
|
|
@@ -659,7 +777,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
|
|
|
659
777
|
createdPaths,
|
|
660
778
|
migrated,
|
|
661
779
|
refreshed: true,
|
|
662
|
-
conventionsSeeded,
|
|
780
|
+
conventionsSeeded: Boolean(conventionsRel),
|
|
663
781
|
rulesLibrarySeeded,
|
|
664
782
|
engineSeeded: engine.seeded > 0,
|
|
665
783
|
};
|
|
@@ -670,7 +788,7 @@ function seedAiLocalTeam({ cwd, presetTeamSrc }) {
|
|
|
670
788
|
createdPaths,
|
|
671
789
|
migrated,
|
|
672
790
|
refreshed: false,
|
|
673
|
-
conventionsSeeded,
|
|
791
|
+
conventionsSeeded: Boolean(conventionsRel),
|
|
674
792
|
rulesLibrarySeeded,
|
|
675
793
|
engineSeeded: engine.seeded > 0,
|
|
676
794
|
};
|
package/bin/mavis-install.js
CHANGED
|
@@ -160,6 +160,7 @@ function cmdInitMavis({ preset, cwdOption, helpers }) {
|
|
|
160
160
|
seedAiLocalTeam,
|
|
161
161
|
installMcpJson,
|
|
162
162
|
getPackageRoot,
|
|
163
|
+
mergeAiLocal,
|
|
163
164
|
} = helpers;
|
|
164
165
|
const packageRoot = getPackageRoot();
|
|
165
166
|
const cwd = resolveTargetCwd(cwdOption);
|
|
@@ -250,6 +251,11 @@ function cmdInitMavis({ preset, cwdOption, helpers }) {
|
|
|
250
251
|
const teamResult = seedAiLocalTeam({
|
|
251
252
|
cwd,
|
|
252
253
|
presetTeamSrc: path.join(sourceBase, 'team'),
|
|
254
|
+
source: `mavis/${stack}`,
|
|
255
|
+
packageVersion: packageVersion(packageRoot),
|
|
256
|
+
mergeAiLocal: Boolean(mergeAiLocal),
|
|
257
|
+
writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
|
|
258
|
+
trackFile: (dest, label) => tx.track(dest, label),
|
|
253
259
|
});
|
|
254
260
|
for (const created of teamResult.createdPaths || []) {
|
|
255
261
|
tx.addCreated(created);
|
package/bin/opencode-install.js
CHANGED
|
@@ -337,8 +337,14 @@ function installOpencodeJson(mcpFrom, mcpDestAbs, destLabel, tx, priorRecord) {
|
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
function cmdInitOpencode({ preset, cwdOption, helpers }) {
|
|
340
|
-
const {
|
|
341
|
-
|
|
340
|
+
const {
|
|
341
|
+
resolveTargetCwd,
|
|
342
|
+
validatePresetName,
|
|
343
|
+
seedDocsSpecsIfAbsent,
|
|
344
|
+
seedAiLocalTeam,
|
|
345
|
+
getPackageRoot,
|
|
346
|
+
mergeAiLocal,
|
|
347
|
+
} = helpers;
|
|
342
348
|
const packageRoot = getPackageRoot();
|
|
343
349
|
const cwd = resolveTargetCwd(cwdOption);
|
|
344
350
|
const contract = loadContract(packageRoot);
|
|
@@ -424,6 +430,11 @@ function cmdInitOpencode({ preset, cwdOption, helpers }) {
|
|
|
424
430
|
const teamResult = seedAiLocalTeam({
|
|
425
431
|
cwd,
|
|
426
432
|
presetTeamSrc: path.join(sourceBase, 'team'),
|
|
433
|
+
source: `opencode/${stack}`,
|
|
434
|
+
packageVersion: packageVersion(packageRoot),
|
|
435
|
+
mergeAiLocal: Boolean(mergeAiLocal),
|
|
436
|
+
writeFile: (dest, content, label) => tx.writeFile(dest, content, label),
|
|
437
|
+
trackFile: (dest, label) => tx.track(dest, label),
|
|
427
438
|
});
|
|
428
439
|
for (const created of teamResult.createdPaths || []) {
|
|
429
440
|
tx.addCreated(created);
|
package/docs/LOCAL-OVERLAY.md
CHANGED
|
@@ -19,6 +19,8 @@ Put a `.ai.local/` directory in your repo. Write rules as plain markdown. The `a
|
|
|
19
19
|
└── tasks/<slug>/
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
`init` and `update` write `.ai.local/.template-base.json` — the digest of every `.ai.local/` file that holds a shipped template byte — so `update` can tell a file you edited from a file the preset moved. Your own bytes never become a base. See [Template drift](#template-drift).
|
|
23
|
+
|
|
22
24
|
No IDE config, no `@include`, no codegen. Same files work in Cursor, Claude Code, Mavis, and OpenCode.
|
|
23
25
|
|
|
24
26
|
## How it works
|
|
@@ -31,7 +33,7 @@ No IDE config, no `@include`, no codegen. Same files work in Cursor, Claude Code
|
|
|
31
33
|
|
|
32
34
|
## Seed library (`.ai.local/rules-library/`)
|
|
33
35
|
|
|
34
|
-
`init` copies `presets/<tool>/<stack>/ai-local/rules/*.md` into `.ai.local/rules
|
|
36
|
+
`init` copies `presets/<tool>/<stack>/ai-local/rules/*.md` into `.ai.local/rules/`; an existing consumer file is never overwritten by seeding. The one exception is opt-in and hash-gated: `update --merge-ai-local` may replace a file whose recorded base still matches — see [Template drift](#template-drift). The next stack ships `task-levels` there, so L0–L3 selection applies on install.
|
|
35
37
|
|
|
36
38
|
`init` also seeds **staged-inactive** rule templates into `.ai.local/rules-library/`. They ship with every install but **do not apply** until you move a matching file into `.ai.local/rules/`.
|
|
37
39
|
|
|
@@ -44,6 +46,80 @@ The `ai-local-overlay` rule instructs the model to treat a matching seed as the
|
|
|
44
46
|
git mv .ai.local/rules-library/router-pages.md .ai.local/rules/router-pages.md
|
|
45
47
|
```
|
|
46
48
|
|
|
49
|
+
## Template drift
|
|
50
|
+
|
|
51
|
+
Your `.ai.local/` is yours. The preset still ships those files, so their text moves between releases — and until now nothing told you which of your files had moved and which you had edited.
|
|
52
|
+
|
|
53
|
+
`init` and `update` write **`.ai.local/.template-base.json`**:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"schemaVersion": 1,
|
|
58
|
+
"packageVersion": "0.2.50",
|
|
59
|
+
"files": {
|
|
60
|
+
".ai.local/rules/task-levels.md": {
|
|
61
|
+
"sha256": "<digest of the seeded bytes>",
|
|
62
|
+
"normSha256": "<digest with line endings and trailing newlines normalised>",
|
|
63
|
+
"source": "cursor/next"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- One entry per `.ai.local/` rel whose current bytes are a shipped template byte — the rels the seed wrote plus a file that already holds the current template. No tree walk, so `.ai.local/team/**`, `.ai.local/requirements/**`, `.ai.local/adr/**`, and the engine's runtime files are never recorded, never compared, and never written by the merge. `team/README.md` and `team/fixtures/**` are absent too: the seed refreshes them on every run, so a record of them would promise a protection it cannot give. **A file you edited is never recorded**: your bytes never become a base, so no later run can mistake them for an untouched template copy.
|
|
70
|
+
- Sorted keys, no timestamp, `source` = `<tool>/<preset>` (the tool that wrote the file keeps the attribution).
|
|
71
|
+
- The record is **not** in `<tool>/.ai-rules-install.json`, so `clean <tool>` still removes nothing under `.ai.local/`. Commit it: it is small and the next `update` rewrites it deterministically.
|
|
72
|
+
|
|
73
|
+
### The default summary line
|
|
74
|
+
|
|
75
|
+
Plain `update` prints one line per tree when anything drifted — one, not one per installed tool:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
.ai.local drift: 3 behind template, 1 edited locally (run with --merge-ai-local to fast-forward the untouched ones)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
*Behind* means the preset text moved and your file still holds the recorded base — only those files are ever fast-forwarded. *Edited locally* means your bytes differ from both the base and the current template: you changed the file, or the file predates the record and cannot be attributed. The line writes nothing to a consumer file; it is a report.
|
|
82
|
+
|
|
83
|
+
Every installed tool's pass classifies its own template map. Each rel is counted once per tree: the first pass reports it, and a later pass does not add it again or replace its proposal. A later pass whose template already matches the file adopts it and drops that proposal. Files two tools own separately still both appear, so `init claude` followed by `init cursor` reports the same rels as a `cursor`-first tree. The line itself is printed once per tree, after the last pass of the command.
|
|
84
|
+
|
|
85
|
+
### `update --merge-ai-local`
|
|
86
|
+
|
|
87
|
+
The flag is opt-in, and it never touches a file you edited:
|
|
88
|
+
|
|
89
|
+
| Your file | Outcome | What the run does |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| Still holds the recorded base, preset moved | fast-forward | writes the preset bytes, re-records both digests, prints `merge-ai-local: fast-forward <rel>` |
|
|
92
|
+
| Already equals the current template, but has no base or a stale one (installed before this feature, the seed skipped it, or you applied a proposal yourself) | adopt | records the **template** digests as the base, **writes nothing**, prints `merge-ai-local: adopt <rel>` |
|
|
93
|
+
| Differs from both the base and the current template — you edited it | drift | keeps your file byte-identical, writes a unified diff and the preset copy to `.ai.local/.rollback/template-drift/`, prints `merge-ai-local: drift <rel> → <diff>` |
|
|
94
|
+
| Recorded by another tool or preset | noop | this pass leaves it alone; a `source` of `claude/next` is never fast-forwarded by a `cursor/next` run — the writing tool's own pass decides it, so a tool you `clean`ed stops reporting its files until you install it again (see limits below) |
|
|
95
|
+
|
|
96
|
+
The sink is `<rel with / → __>.diff` plus `<…>.template-new`. No sink entry ends in `.md` and nothing is created under `rules/` or beside `conventions.md`: the overlay probe loads every `*.md` under `rules/`, so a sidecar there would be read as instruction text. **No conflict marker is ever written under `.ai.local/**`** — a divergence is a diff you apply, never a `<<<<<<<` you clean up.
|
|
97
|
+
|
|
98
|
+
Two consecutive flagged runs leave the tree byte-identical; the second reports zero fast-forwards. A file that is still drifted keeps its `kept edited locally` count and its proposal, so a still-drifted tree repeats the line rather than going silent. A four-tool `update` merges once per tree, because `.ai.local/` is one tree with one record. Apply the proposal yourself and the next `update` (flagged or not) adopts the file instead of reporting it again.
|
|
99
|
+
|
|
100
|
+
### First run on a pre-feature tree
|
|
101
|
+
|
|
102
|
+
The record only exists from the release that introduced it. On a tree installed earlier, the first `update` (the flag is not required for this step) records every file that already holds the shipped template; nothing is overwritten, and a file that differs is reported as *edited locally* instead of being recorded. `init` records the base immediately, so a fresh install needs no adoption step. The next release then has something to compare against.
|
|
103
|
+
|
|
104
|
+
Recording is deliberately conservative: a file whose bytes differ from the current template is never adopted, because a base equal to your bytes would make the *next* preset release fast-forward over your edit.
|
|
105
|
+
|
|
106
|
+
### Limits — what stays manual
|
|
107
|
+
|
|
108
|
+
- **`conventions.md` body edits.** Your prose is the part the preset cannot know. Only line-ending and trailing-newline churn is normalised away; a wording change stays a reported diff.
|
|
109
|
+
- **A rule you rewrote.** Local rules win by contract; replacing one changes precedence, not just bytes. It is reported as *edited locally*, never fast-forwarded, and never becomes a base — apply the proposal if you want the preset text, and the next run records the result.
|
|
110
|
+
- **A file whose owning tool you `clean`ed.** The record keeps the `source` of the tool that wrote a file, and only that tool's pass classifies it. `clean claude` leaves the record and that `source` in place, so a file attributed to `claude` is neither reported nor merged — even when another installed tool ships a newer copy — until you run `init claude` again. Deleting the entry from `.ai.local/.template-base.json` re-attributes the file to the next pass that ships it: if it already matches that preset's template, the next `update` records it; if not, the flagged run offers a diff instead, and applying it completes the re-attribution.
|
|
111
|
+
- **Both sides changed.** The sink shows the diff; resolution is yours.
|
|
112
|
+
- **`override: kill` and `i18n-keep` disagreements.** A fast-forward copies the preset file whole, so it can neither move nor duplicate a marker — and a disagreement is reported rather than resolved.
|
|
113
|
+
- **`.ai.local/team/**`, `.ai.local/requirements/**`, `.ai.local/adr/**`, engine runtime state.** Out of scope by allowlist. `team/README.md` and `team/fixtures/**` are refreshed by the seed on every run before any comparison, so edit them and your edit is gone — they are seed-owned, not drift-tracked, and never reported.
|
|
114
|
+
- **A file you deleted, or a preset that dropped a file.** Absence is intent; nothing is re-seeded or removed. A rel the owning preset no longer ships loses its record entry and its proposal on the next flagged run, so the record does not accumulate dead keys.
|
|
115
|
+
- **A record written by a newer CLI.** A `schemaVersion` above this CLI's own makes it skip the record and the merge with a warning rather than rewrite the file as v1.
|
|
116
|
+
- **An activated seed** (`rules-library/X.md` → `rules/X.md`). Activation stays a judgement call; the pair is not auto-merged.
|
|
117
|
+
- **Three-way merge.** Not implemented: without a stored copy of the old preset bytes a line merge would invent conflicts inside files that load on every turn.
|
|
118
|
+
|
|
119
|
+
### Git noise
|
|
120
|
+
|
|
121
|
+
On a tree installed before `.ai.local/.gitignore` carried `.rollback/`, the sink shows up as untracked files. That is noise, not data loss: the directory is a tool-owned proposal area, safe to delete, and a fresh install ignores it from the start. The root `.gitignore` is never edited.
|
|
122
|
+
|
|
47
123
|
## How to write `.ai.local/rules/*.md`
|
|
48
124
|
|
|
49
125
|
One file = one rule. Plain markdown. **No YAML frontmatter** — the format is shared across IDEs, so each file uses a tiny markdown header for scoping.
|
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@ const QUALITY_OUTCOMES = new Set(['changes_requested', 'validation_failed']);
|
|
|
50
50
|
// `seed-staged`/`staged`/`proposed`/`rejected` never act; `rollback` removes
|
|
51
51
|
// the rule. None of the non-applied actions may form a `t0`/cohort verdict.
|
|
52
52
|
const APPLIED_ACTIONS = new Set(['rule-created', 'conventions-added', 'applied']);
|
|
53
|
-
const ROLLED_BACK_ACTIONS = new Set(['rollback', 'rolled_back']);
|
|
53
|
+
const ROLLED_BACK_ACTIONS = new Set(['rollback', 'rolled_back', 'unloaded']);
|
|
54
54
|
|
|
55
55
|
// --- Pure helpers -------------------------------------------------------------
|
|
56
56
|
|