@bluenyang/reins 0.3.4 → 0.4.0-rc.2
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/README.md +164 -39
- package/cli/dist/commands/config-gates.js +64 -6
- package/cli/dist/commands/config-models.js +19 -0
- package/cli/dist/commands/config.js +40 -16
- package/cli/dist/commands/configure.js +207 -47
- package/cli/dist/commands/install.js +91 -31
- package/cli/dist/commands/migrate.js +17 -20
- package/cli/dist/commands/update.js +164 -12
- package/cli/dist/lib/agents-md.js +55 -13
- package/cli/dist/lib/bindings.js +7 -10
- package/cli/dist/lib/blocks.js +82 -18
- package/cli/dist/lib/detect.js +88 -3
- package/cli/dist/lib/gate-refresh.js +35 -5
- package/cli/dist/lib/gate-script.js +303 -25
- package/cli/dist/lib/generate.js +48 -6
- package/cli/dist/lib/git.js +33 -0
- package/cli/dist/lib/migrate-plan.js +1 -1
- package/cli/dist/lib/profile.js +101 -0
- package/cli/dist/lib/prompter.js +2 -1
- package/cli/dist/lib/release.js +1 -1
- package/cli/dist/lib/schema.js +6 -3
- package/cli/dist/lib/upstream.js +1 -1
- package/cli/dist/reins.js +40 -14
- package/docs/README.ko.md +113 -23
- package/harness/CHANGELOG.md +12 -0
- package/harness/VERSION +1 -1
- package/harness/policy/common-red-lines.yaml +7 -5
- package/harness/roles/advisor.md +1 -1
- package/harness/roles/auditor.md +12 -11
- package/harness/roles/executor.md +4 -3
- package/harness/roles/implementer.md +5 -5
- package/harness/roles/pl.md +4 -4
- package/harness/roles/planner.md +7 -8
- package/harness/roles/pm.md +7 -8
- package/harness/schemas/bindings.schema.json +2 -0
- package/harness/schemas/install.schema.json +1 -0
- package/harness/schemas/intent.schema.json +9 -1
- package/harness/schemas/plan.schema.json +18 -0
- package/harness/schemas/spec.schema.json +9 -6
- package/harness/templates/agents-md-blocks.md +19 -54
- package/harness/templates/agents-md-guide.md +11 -10
- package/harness/templates/audit.md +14 -41
- package/harness/templates/history.md +1 -5
- package/harness/templates/intent.md +8 -19
- package/harness/templates/plan.md +23 -0
- package/harness/templates/spec.md +21 -16
- package/package.json +1 -1
- package/skills/audit/SKILL.md +27 -33
- package/skills/gates/SKILL.md +41 -0
- package/skills/implement/SKILL.md +33 -22
- package/skills/implement/references/procedure.md +51 -0
- package/skills/intent/SKILL.md +29 -20
- package/skills/intent/references/procedure.md +60 -0
- package/skills/onboard/SKILL.md +39 -28
- package/skills/plan/SKILL.md +35 -0
- package/skills/plan/references/procedure.md +52 -0
- package/skills/reins-setup/SKILL.md +4 -4
- package/skills/release/SKILL.md +18 -20
- package/skills/retro/SKILL.md +21 -26
- package/skills/review/SKILL.md +33 -17
- package/skills/review/references/procedure.md +50 -0
- package/skills/spec/SKILL.md +25 -19
- package/skills/spec/references/procedure.md +67 -0
- package/skills/merge/SKILL.md +0 -32
- package/skills/roadmap/SKILL.md +0 -29
- package/skills/test/SKILL.md +0 -26
|
@@ -6,16 +6,17 @@ import { draftRelease, releaseDraftNotes } from '../lib/release.js';
|
|
|
6
6
|
import { applyBlocks } from '../lib/blocks.js';
|
|
7
7
|
import { discoverGates, generation, stacks, vendors, } from '../lib/detect.js';
|
|
8
8
|
import { apply, listFiles } from '../lib/fsx.js';
|
|
9
|
-
import { repoRoot } from '../lib/git.js';
|
|
9
|
+
import { defaultBranch, repoRoot } from '../lib/git.js';
|
|
10
10
|
import { harnessVersion, packageHarness, packageSkills, packageVersion } from '../lib/upstream.js';
|
|
11
11
|
import { generateVendorFiles } from '../lib/generate.js';
|
|
12
12
|
import { GATE_SCRIPT, hookLine, requiredGates } from '../lib/gate-script.js';
|
|
13
13
|
import { defaultBindings, readTeam } from '../lib/bindings.js';
|
|
14
14
|
import { overlayReader, workTreeReader } from '../lib/reader.js';
|
|
15
|
-
import { LOCAL_DELEGATION, ONBOARDING_PENDING, RECONCILE_PENDING, onboardingNote, placeNote, renderBlocks, tidyNote, } from '../lib/agents-md.js';
|
|
15
|
+
import { LOCAL_DELEGATION, ONBOARDING_PENDING, RECONCILE_PENDING, onboardingNote, placeNote, refreshNote, renderBlocks, tidyNote, } from '../lib/agents-md.js';
|
|
16
16
|
import { syncLocalDelegation } from '../lib/local-delegation.js';
|
|
17
17
|
import { readManifest, writeGenerated } from '../lib/vendor-write.js';
|
|
18
18
|
import { applyLocalForcePush, FORCE_WITH_LEASE_QUESTION, recordedForceWithLease, } from '../lib/local-settings.js';
|
|
19
|
+
import { harnessInProfile, outOfProfile, PLUGIN_ONLY, profileOf, removeFiles, skillFileInProfile, } from '../lib/profile.js';
|
|
19
20
|
/** Upstream harness files installed into `.agents/harness/` (design §1): everything but seeds and the changelog. */
|
|
20
21
|
export function harnessFiles(all) {
|
|
21
22
|
return all.filter((f) => !f.startsWith('knowledge-seeds/') && f !== 'CHANGELOG.md');
|
|
@@ -36,8 +37,6 @@ export function retiredFiles(installed, upstream) {
|
|
|
36
37
|
!PROJECT_OWNED.has(f) &&
|
|
37
38
|
(f === 'CHANGELOG.md' || UPSTREAM_DIRS.some((d) => f.startsWith(d))));
|
|
38
39
|
}
|
|
39
|
-
/** Skills that ship with the plugin only and are not installed into a project. */
|
|
40
|
-
const PLUGIN_ONLY = new Set(['reins-setup', 'setup']);
|
|
41
40
|
/** The hook tool the project already uses (design §6), if any. */
|
|
42
41
|
export function hookTool(root) {
|
|
43
42
|
if (existsSync(join(root, '.husky')))
|
|
@@ -48,19 +47,29 @@ export function hookTool(root) {
|
|
|
48
47
|
return 'pre-commit';
|
|
49
48
|
return null;
|
|
50
49
|
}
|
|
51
|
-
|
|
50
|
+
/**
|
|
51
|
+
* `gates.yaml` as install writes it (design §5, spec 025 D-2): schema 2, the areas, then each gate with the
|
|
52
|
+
* area of where it was found (none: it always runs), in order. Block style only: the gate script reads no other.
|
|
53
|
+
*/
|
|
54
|
+
export function buildGates(root, gates, areas = {}) {
|
|
52
55
|
const doc = {
|
|
53
|
-
schema: 'reins/gates@
|
|
56
|
+
schema: 'reins/gates@2',
|
|
57
|
+
...(Object.keys(areas).length ? { areas } : {}),
|
|
54
58
|
gates: Object.fromEntries(gates.map((g) => [
|
|
55
59
|
g.name,
|
|
56
|
-
{
|
|
60
|
+
{
|
|
61
|
+
cmd: g.cmd,
|
|
62
|
+
from: g.from,
|
|
63
|
+
...(g.optional ? { optional: true } : {}),
|
|
64
|
+
...(g.areas?.length ? { areas: g.areas } : {}),
|
|
65
|
+
},
|
|
57
66
|
])),
|
|
58
67
|
order: gates.map((g) => g.name),
|
|
59
68
|
mutating_forbidden: true,
|
|
60
69
|
evidence: 'raw',
|
|
61
70
|
};
|
|
62
71
|
void root;
|
|
63
|
-
return `# discovered by reins install — the
|
|
72
|
+
return `# discovered by reins install — the gate script reads only this file (design §5); a gate without areas always runs\n${stringify(doc, { lineWidth: 0 })}`;
|
|
64
73
|
}
|
|
65
74
|
/** The stub install leaves; migrate may replace it with the project's real raw roadmap. */
|
|
66
75
|
export const ROADMAP_STUB = '# ROADMAP (local)\n\n— 산발적 아이디어를 여기에. 확정되면 docs/ROADMAP.md\n';
|
|
@@ -68,10 +77,11 @@ const LOCTX_README = `# .loctx — 이 머신·이 개발자만 (gitignore)
|
|
|
68
77
|
|
|
69
78
|
| 경로 | 무엇 | 지우는 때 |
|
|
70
79
|
|---|---|---|
|
|
80
|
+
| intent/<date>_<slug>.md | 아이디어 하나의 메모 (조사, 반론, 질문과 답). 상태는 idea, adopted, dropped | 사용자 |
|
|
71
81
|
| ROADMAP.local.md | 날 것의 아이디어. 사용자와 정리되면 docs/ROADMAP.md | 사용자 |
|
|
72
|
-
| history/<version>.md | 버전마다 한 장:
|
|
73
|
-
| reports/<version>/ |
|
|
74
|
-
| reports/gates/<tree>.log | 훅이 돌린 검사의 출력 (.agents/harness/run-gates.sh; 커밋의 트리 해시가 파일 이름) | 회고
|
|
82
|
+
| history/<version>.md | 버전마다 한 장: 결정(decisions:)과 재개 지점 | 지우지 않음 |
|
|
83
|
+
| reports/<version>/ | 검사 원본 로그, 다른 모델에 보낸 요청과 답 | 회고 뒤 (history에 요약한 다음), 회고를 하지 않으면 사용자 |
|
|
84
|
+
| reports/gates/<tree>.log | 훅이 돌린 검사의 출력 (.agents/harness/run-gates.sh; 커밋의 트리 해시가 파일 이름) | 회고 뒤, 회고를 하지 않으면 사용자 |
|
|
75
85
|
| context/ | 개인 컨텍스트 — 대화·메모 | 사용자 |
|
|
76
86
|
| bindings.local.yaml | 나만 쓰는 모델 할당 (있으면 팀 설정보다 우선) | 사용자 |
|
|
77
87
|
`;
|
|
@@ -161,6 +171,8 @@ export function configRunsGateScript(docs, tool, stage) {
|
|
|
161
171
|
}
|
|
162
172
|
/** A command that runs reins: what 0.x put into hooks and settings. */
|
|
163
173
|
export const RUNS_REINS = /@bluenyang\/reins|reins\.js\b|(^|[\s;&|])reins\s+(check|hook|gate|status)\b/;
|
|
174
|
+
/** A back or exit answer from a prompt. */
|
|
175
|
+
const isNav = (v) => v === BACK || v === EXIT;
|
|
164
176
|
/** `reins install` (design §9): place the harness, ask, propose hooks, mark onboarding. Never writes history. */
|
|
165
177
|
export async function runInstall(o) {
|
|
166
178
|
const root = repoRoot(o.cwd ?? process.cwd());
|
|
@@ -181,10 +193,7 @@ export async function runInstall(o) {
|
|
|
181
193
|
if (!existsSync(join(root, path)))
|
|
182
194
|
add(path, content, why);
|
|
183
195
|
};
|
|
184
|
-
// 1.
|
|
185
|
-
for (const f of harnessFiles(listFiles(up)))
|
|
186
|
-
add(`.agents/harness/${f}`, readFileSync(join(up, f), 'utf8'), 'upstream harness');
|
|
187
|
-
// 2. questions (manual) / detection (auto) — only for what does not exist yet
|
|
196
|
+
// 1. questions (manual) / detection (auto) — only for what does not exist yet
|
|
188
197
|
const pendingBindings = o.pending?.find((p) => p.path === '.agents/harness/bindings.yaml');
|
|
189
198
|
const team = pendingBindings
|
|
190
199
|
? { doc: parse(pendingBindings.content) }
|
|
@@ -201,7 +210,6 @@ export async function runInstall(o) {
|
|
|
201
210
|
const screens = o.mode === 'manual' ? o.prompter : undefined;
|
|
202
211
|
const line = askerPrompter(o.asker); // the piped, line-based form
|
|
203
212
|
const cancelled = () => ({ root, generation: gen, notes, cancelled: true });
|
|
204
|
-
const isNav = (v) => v === BACK || v === EXIT;
|
|
205
213
|
if (!hasBindings && !team.v1) {
|
|
206
214
|
if (screens) {
|
|
207
215
|
const picked = await screens.multiselect({
|
|
@@ -230,6 +238,32 @@ export async function runInstall(o) {
|
|
|
230
238
|
use.add(v);
|
|
231
239
|
}
|
|
232
240
|
}
|
|
241
|
+
// the profile of a new bindings file: asked on a terminal only; piped and non-interactive runs take light
|
|
242
|
+
let profile = o.profile ?? profileOf(team.doc);
|
|
243
|
+
if (!hasBindings && !team.v1 && !o.profile && screens) {
|
|
244
|
+
const pick = await screens.select({
|
|
245
|
+
message: 'Profile of the harness',
|
|
246
|
+
options: [
|
|
247
|
+
{ value: 'light', label: 'light', hint: 'skill bodies only (default)' },
|
|
248
|
+
{
|
|
249
|
+
value: 'full',
|
|
250
|
+
label: 'full',
|
|
251
|
+
hint: 'adds step-by-step references, role files and rs-* agents — for smaller models',
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
initial: 'light',
|
|
255
|
+
});
|
|
256
|
+
if (isNav(pick))
|
|
257
|
+
return cancelled();
|
|
258
|
+
profile = pick;
|
|
259
|
+
}
|
|
260
|
+
if (hasBindings && o.profile && o.profile !== profileOf(team.doc)) {
|
|
261
|
+
profile = profileOf(team.doc);
|
|
262
|
+
notes.push(`profile stays ${profile} (bindings.yaml) — change it with \`reins config\` (profile)`);
|
|
263
|
+
}
|
|
264
|
+
// 2. upstream harness files of this profile (the role files only in full)
|
|
265
|
+
for (const f of harnessFiles(listFiles(up)).filter((x) => harnessInProfile(x, profile)))
|
|
266
|
+
add(`.agents/harness/${f}`, readFileSync(join(up, f), 'utf8'), 'upstream harness');
|
|
233
267
|
let language = pinned?.language;
|
|
234
268
|
if (language === undefined) {
|
|
235
269
|
if (screens) {
|
|
@@ -313,19 +347,27 @@ export async function runInstall(o) {
|
|
|
313
347
|
// what another script or gate already runs is shown, never chosen (024 S-9, S-10)
|
|
314
348
|
for (const c of proposal.candidates.filter((x) => x.status === 'covered'))
|
|
315
349
|
notes.push(`not a gate of its own: ${c.name} — ${c.reasons.join('; ')}`);
|
|
316
|
-
|
|
350
|
+
const written = [...(gateAns ? proposal.gates : []), ...chosen];
|
|
351
|
+
add('.agents/harness/gates.yaml', buildGates(root, written, proposal.areas), 'declared gates');
|
|
352
|
+
const areaNames = Object.keys(proposal.areas);
|
|
353
|
+
if (areaNames.length)
|
|
354
|
+
notes.push(`gate areas: ${areaNames.join(', ')} — a gate without areas always runs; set them with \`reins config gates --area <gate>=<area,…>\` or the gates skill`);
|
|
317
355
|
}
|
|
318
356
|
// 3. settings: a new bindings file in single mode (an old one is converted by update)
|
|
319
357
|
let doc = team.doc;
|
|
320
358
|
if (!doc && !team.v1) {
|
|
321
|
-
doc = defaultBindings(vs.map((v) => ({ name: v.name, cli: v.cli, use: use.has(v.name) })));
|
|
322
|
-
add('.agents/harness/bindings.yaml', `# reins model assignment (design §5) — the user changes it with \`reins config\`; nothing reads it while you work\n${stringify(doc)}`,
|
|
359
|
+
doc = defaultBindings(vs.map((v) => ({ name: v.name, cli: v.cli, use: use.has(v.name) })), profile);
|
|
360
|
+
add('.agents/harness/bindings.yaml', `# reins model assignment (design §5) — the user changes it with \`reins config\`; nothing reads it while you work\n${stringify(doc)}`, `model assignment (single mode, profile ${profile})`);
|
|
323
361
|
}
|
|
324
362
|
const { tier: _tier, ...keep } = pinned ?? {};
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
363
|
+
// the default branch, for the deny rules on pushing to it (design §6): read once, then kept
|
|
364
|
+
const branch = typeof keep['default_branch'] === 'string' ? keep['default_branch'] : defaultBranch(root);
|
|
365
|
+
if (!branch)
|
|
366
|
+
notes.push('default branch not found (no origin/HEAD, no single main or master) — pushes to both main and master are denied; set `default_branch:` in .agents/harness/install.yaml and run `reins update`');
|
|
367
|
+
add('.agents/harness/install.yaml', `# version pin and install settings (R25) — read by reins update\n${stringify({ ...keep, schema: 'reins/install@1', version, cli: packageVersion(), mode: o.mode, language, ...(branch ? { default_branch: branch } : {}) })}`, 'version pin');
|
|
368
|
+
// 4. layout skeleton (design §1); never overwrite project files. `.agents/intent/` and `.agents/audit/`
|
|
369
|
+
// are 0.3's records: kept where they are, never made anew (an audit a person asks for makes its folder)
|
|
370
|
+
addIfMissing('.agents/spec/.gitkeep', '', 'specs and plans');
|
|
329
371
|
addIfMissing('.agents/knowledge/.gitkeep', '', 'explicit knowledge');
|
|
330
372
|
for (const s of stacks(root)) {
|
|
331
373
|
const seeds = join(up, 'knowledge-seeds', s);
|
|
@@ -336,13 +378,13 @@ export async function runInstall(o) {
|
|
|
336
378
|
add('.loctx/.gitignore', '*\n', 'double ignore');
|
|
337
379
|
add('.loctx/README.md', LOCTX_README, 'local workspace layout and lifetimes');
|
|
338
380
|
addIfMissing('.loctx/ROADMAP.local.md', ROADMAP_STUB, 'raw roadmap');
|
|
339
|
-
//
|
|
381
|
+
// skills: upstream-owned copies under the Agent Skills path (references/ in the full profile only)
|
|
340
382
|
const skillsUp = packageSkills();
|
|
341
383
|
if (existsSync(skillsUp))
|
|
342
384
|
for (const name of readdirSync(skillsUp).toSorted()) {
|
|
343
385
|
if (PLUGIN_ONLY.has(name) || !existsSync(join(skillsUp, name, 'SKILL.md')))
|
|
344
386
|
continue;
|
|
345
|
-
for (const f of listFiles(join(skillsUp, name)))
|
|
387
|
+
for (const f of listFiles(join(skillsUp, name)).filter((x) => skillFileInProfile(x, profile)))
|
|
346
388
|
add(`.agents/skills/${name}/${f}`, readFileSync(join(skillsUp, name, f), 'utf8'), 'upstream skill');
|
|
347
389
|
}
|
|
348
390
|
const gi = existsSync(join(root, '.gitignore'))
|
|
@@ -378,16 +420,16 @@ export async function runInstall(o) {
|
|
|
378
420
|
addHooks = yes === true;
|
|
379
421
|
}
|
|
380
422
|
for (const { stage, cur } of files) {
|
|
381
|
-
const
|
|
423
|
+
const gateLine = hookLine(stage);
|
|
382
424
|
if (cur.includes('# reins:begin hooks')) {
|
|
383
425
|
// a block an earlier reins wrote: its body becomes the one line. A block that runs reins is 0.x
|
|
384
426
|
// and `update` removes it as a whole; one that already is the line stays.
|
|
385
427
|
const held = [];
|
|
386
428
|
const next = cur.replace(HOOK_BLOCK, (block, body) => {
|
|
387
|
-
if (RUNS_REINS.test(body) || body.trim() ===
|
|
429
|
+
if (RUNS_REINS.test(body) || body.trim() === gateLine)
|
|
388
430
|
return block;
|
|
389
431
|
held.push(...body.split('\n').filter((l) => l.trim()));
|
|
390
|
-
return `# reins:begin hooks\n${
|
|
432
|
+
return `# reins:begin hooks\n${gateLine}\n# reins:end hooks`;
|
|
391
433
|
});
|
|
392
434
|
if (next === cur)
|
|
393
435
|
continue;
|
|
@@ -395,7 +437,7 @@ export async function runInstall(o) {
|
|
|
395
437
|
notes.push(`.husky/${stage}: the reins hooks block now calls the gate script — it held: ${held.join(' && ')} (move a line of your own outside the block)`);
|
|
396
438
|
}
|
|
397
439
|
else if (addHooks && !runsGateScript(cur, stage))
|
|
398
|
-
add(`.husky/${stage}`, `${cur.replace(/\s*$/, '')}\n# reins:begin hooks\n${
|
|
440
|
+
add(`.husky/${stage}`, `${cur.replace(/\s*$/, '')}\n# reins:begin hooks\n${gateLine}\n# reins:end hooks\n`.replace(/^\n/, ''), 'hook: the gate script');
|
|
399
441
|
}
|
|
400
442
|
if (missing.length && !addHooks)
|
|
401
443
|
notes.push(`hook proposal (husky): add \`${hookLine('pre-commit')}\` to .husky/pre-commit and \`${hookLine('pre-push')}\` to .husky/pre-push; re-run with --hooks to add them`);
|
|
@@ -429,8 +471,18 @@ export async function runInstall(o) {
|
|
|
429
471
|
agents = placeNote(agents, tidyNote(), 'tidy');
|
|
430
472
|
notes.push('AGENTS.md has a note about the AGENTS.md guide — the PM sorts the project sections with the user in the next conversation');
|
|
431
473
|
}
|
|
474
|
+
// a pending tidy or reset note gets this version's wording (the marker stays pending)
|
|
475
|
+
if (agents.includes('<!-- reins:tidy pending -->'))
|
|
476
|
+
agents = refreshNote(agents, tidyNote(), 'tidy');
|
|
477
|
+
if (o.resetNote)
|
|
478
|
+
agents = refreshNote(agents, o.resetNote, 'reset');
|
|
479
|
+
// an update from 0.3 leaves the reset to-do once, whatever else is pending: onboard handles each marker
|
|
480
|
+
if (o.resetNote && !agents.includes('<!-- reins:reset')) {
|
|
481
|
+
agents = placeNote(agents, o.resetNote, 'reset');
|
|
482
|
+
notes.push('AGENTS.md has a reins:reset note — the onboard skill goes through its to-do list with the user in the next conversation');
|
|
483
|
+
}
|
|
432
484
|
if (agents !== before)
|
|
433
|
-
add('AGENTS.md', agents, `managed blocks: ${[...br.inserted, ...br.replaced].join(', ') || 'onboarding'}`);
|
|
485
|
+
add('AGENTS.md', agents, `managed blocks: ${[...br.inserted, ...br.replaced].join(', ') || (br.moved ? 'put in order' : 'onboarding')}${br.removed.length ? `; removed: ${br.removed.join(', ')}` : ''}`);
|
|
434
486
|
for (const s of br.skipped)
|
|
435
487
|
notes.push(`AGENTS.md block "${s.name}" not placed: ${s.why}`);
|
|
436
488
|
const claude = join(root, 'CLAUDE.md');
|
|
@@ -448,7 +500,7 @@ export async function runInstall(o) {
|
|
|
448
500
|
if (o.retire) {
|
|
449
501
|
const harnessDir = join(root, '.agents/harness');
|
|
450
502
|
const here = existsSync(harnessDir) ? listFiles(harnessDir) : [];
|
|
451
|
-
for (const f of retiredFiles(here, listFiles(up))) {
|
|
503
|
+
for (const f of retiredFiles(here, listFiles(up).filter((x) => harnessInProfile(x, profile)))) {
|
|
452
504
|
retired.push(`.agents/harness/${f}`);
|
|
453
505
|
applied.removed.push(`.agents/harness/${f}`);
|
|
454
506
|
if (o.dryRun)
|
|
@@ -464,6 +516,14 @@ export async function runInstall(o) {
|
|
|
464
516
|
}
|
|
465
517
|
}
|
|
466
518
|
}
|
|
519
|
+
// 8b. update: what this profile leaves out — the skills' references/ in light (the role files retire above)
|
|
520
|
+
if (o.retire)
|
|
521
|
+
for (const p of outOfProfile(root, profile).filter((x) => !applied.removed.includes(x))) {
|
|
522
|
+
retired.push(p);
|
|
523
|
+
applied.removed.push(p);
|
|
524
|
+
if (!o.dryRun)
|
|
525
|
+
removeFiles(root, [p]);
|
|
526
|
+
}
|
|
467
527
|
// 9. generated files from the installed harness (design §6) — never over a file reins did not write
|
|
468
528
|
// a dry run computes the same plan without writing, so update can show hand-edited files first
|
|
469
529
|
const rd = o.dryRun
|
|
@@ -16,11 +16,15 @@ function removeEmptyDirs(dir) {
|
|
|
16
16
|
if (readdirSync(dir).length === 0)
|
|
17
17
|
rmdirSync(dir);
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* A local intent note (design §4) that lists the migrated work — only when this run moved work and no such
|
|
21
|
+
* note exists. It is an idea, not a plan: the person decides what of it becomes a spec.
|
|
22
|
+
*/
|
|
23
|
+
function writeMigratedIntent(root, moves, now = new Date()) {
|
|
21
24
|
const made = moves.filter((m) => m.result === 'converted');
|
|
22
|
-
const dir = join(root, '.
|
|
23
|
-
if (made.length === 0 ||
|
|
25
|
+
const dir = join(root, '.loctx/intent');
|
|
26
|
+
if (made.length === 0 ||
|
|
27
|
+
(existsSync(dir) && readdirSync(dir).some((e) => e.endsWith('_migrated.md'))))
|
|
24
28
|
return null;
|
|
25
29
|
let version = '0.0.0';
|
|
26
30
|
try {
|
|
@@ -36,21 +40,14 @@ function writeMigratedIntent(root, moves) {
|
|
|
36
40
|
.map((m) => `- ${m.to.slice('.loctx/context/migrated-work/'.length, m.to.indexOf('_'))} — from .ai/work/${m.from.slice('.ai/work/'.length)} (${m.to})`)
|
|
37
41
|
.join('\n');
|
|
38
42
|
const text = body
|
|
39
|
-
.replace(/##
|
|
40
|
-
.replace(/##
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
'approvals: []',
|
|
48
|
-
'supersedes: null',
|
|
49
|
-
].join('\n');
|
|
50
|
-
const out = join(dir, '000_migrated/intent.md');
|
|
51
|
-
mkdirSync(dirname(out), { recursive: true });
|
|
52
|
-
writeFileSync(out, `---\n${yaml}\n---\n${text}`);
|
|
53
|
-
return '.agents/intent/000_migrated/intent.md written as a draft whose plan lists the migrated work — the user approves it before any of it starts';
|
|
43
|
+
.replace(/## 아이디어\n—/, () => `## 아이디어\nOpen work items that \`reins migrate\` moved out of \`.ai/work/\` (version ${version}). The person decides which of them become a spec.`)
|
|
44
|
+
.replace(/## 무엇을, 어떻게, 결국 어떻게 되어야 하나\n—/, (h) => `${h.slice(0, -1)}${list}`);
|
|
45
|
+
const date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
|
46
|
+
const yaml = ['slug: migrated', `date: ${JSON.stringify(date)}`, 'status: idea'].join('\n');
|
|
47
|
+
const rel = `.loctx/intent/${date}_migrated.md`;
|
|
48
|
+
mkdirSync(dir, { recursive: true });
|
|
49
|
+
writeFileSync(join(root, rel), `---\n${yaml}\n---\n${text}`);
|
|
50
|
+
return `${rel} written as an idea that lists the migrated work — the person decides which of it becomes a spec`;
|
|
54
51
|
}
|
|
55
52
|
/** `reins migrate` (design §7): install, move the old workspace, set AGENTS.md aside for the PM to reconcile. Idempotent. */
|
|
56
53
|
export async function runMigrate(o) {
|
|
@@ -122,7 +119,7 @@ export async function runMigrate(o) {
|
|
|
122
119
|
if (!o.dryRun)
|
|
123
120
|
removeEmptyDirs(join(root, '.ai'));
|
|
124
121
|
if (!o.dryRun) {
|
|
125
|
-
const made = writeMigratedIntent(root, res.moves);
|
|
122
|
+
const made = writeMigratedIntent(root, res.moves, o.now);
|
|
126
123
|
if (made)
|
|
127
124
|
res.report.push(made);
|
|
128
125
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { parse, stringify } from 'yaml';
|
|
3
|
+
import { isMap, isScalar, parse, parseDocument, stringify } from 'yaml';
|
|
4
4
|
import { defaultsAsker } from '../lib/ask.js';
|
|
5
|
-
import { convertV1, readTeam, writeBindings } from '../lib/bindings.js';
|
|
6
|
-
import { placeNote, reconcileNote } from '../lib/agents-md.js';
|
|
5
|
+
import { convertV1, readTeam, TEAM_BINDINGS, writeBindings } from '../lib/bindings.js';
|
|
6
|
+
import { placeNote, reconcileNote, RESET_PENDING, resetNote } from '../lib/agents-md.js';
|
|
7
7
|
import { overrides } from '../lib/blocks.js';
|
|
8
|
+
import { listFiles } from '../lib/fsx.js';
|
|
9
|
+
import { sha } from '../lib/generate.js';
|
|
8
10
|
import { repoRoot } from '../lib/git.js';
|
|
9
11
|
import { BACK, EXIT } from '../lib/prompter.js';
|
|
10
12
|
import { harnessVersion, packageHarness, packageVersion } from '../lib/upstream.js';
|
|
@@ -161,7 +163,114 @@ function planLegacy(root) {
|
|
|
161
163
|
}
|
|
162
164
|
return out;
|
|
163
165
|
}
|
|
164
|
-
/**
|
|
166
|
+
/** The skills 0.4 no longer ships (design §7), and what takes each one's place. */
|
|
167
|
+
export const RETIRED_SKILLS = {
|
|
168
|
+
roadmap: 'the `intent` skill takes its place',
|
|
169
|
+
test: "the plan's checks and the `implement` skill take its place",
|
|
170
|
+
merge: 'a person merges',
|
|
171
|
+
};
|
|
172
|
+
/** A pin from the 0.3 line (rcs included): `update` moves it to 0.4 (design §7). */
|
|
173
|
+
export const isV03 = (version) => /^0\.3\.\d/.test(version);
|
|
174
|
+
/**
|
|
175
|
+
* The hashes (`sha`, as generated.yaml keeps them) of every `SKILL.md` of the retired skills that a 0.3
|
|
176
|
+
* release or rc shipped (v0.3.0-rc.1 to v0.3.4). `generated.yaml` cannot tell a hand edit here: each update
|
|
177
|
+
* copies `.agents/skills/` into `.claude/skills/` and records the copy's hash, an edited one included.
|
|
178
|
+
*/
|
|
179
|
+
export const SHIPPED_03 = {
|
|
180
|
+
roadmap: ['a6a922decb9492e1', '14cec09ae397a796', '06d5464ca1c9acab', '17fcd23a059ffdb5'],
|
|
181
|
+
test: ['ef9f90fbb0e73bf4', '1f2c2489ea92d39a', '4b278cdfd53b7333'],
|
|
182
|
+
merge: ['59323f2f811b746d', '2defd979d33e9707', 'bd66f6d992957ad5', '8e7975b09c258539'],
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Whether a retired skill is as a 0.3 reins shipped it: its folder in `.agents/skills/` and the
|
|
186
|
+
* `.claude/skills/` copy hold only a `SKILL.md` that some 0.3 version shipped. Anything else counts as an
|
|
187
|
+
* edit, so a skill changed or extended by hand is never deleted without --force.
|
|
188
|
+
*/
|
|
189
|
+
function skillUntouched(root, name) {
|
|
190
|
+
for (const dir of ['.agents/skills', '.claude/skills']) {
|
|
191
|
+
const base = join(root, dir, name);
|
|
192
|
+
for (const f of listFiles(base))
|
|
193
|
+
if (f !== 'SKILL.md' || !SHIPPED_03[name]?.includes(sha(readFileSync(join(base, f), 'utf8'))))
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* What moving a 0.3.x install to 0.4 changes (design §7), computed without writing: the retired skills go
|
|
200
|
+
* (a hand-edited one only with `force`), `audit.required` leaves bindings.yaml and the profile is written to
|
|
201
|
+
* keep how the harness worked (`full` when there are `rs-*` agents), gates.yaml becomes schema 2 without
|
|
202
|
+
* areas. The blocks and the reset note are install's. Records, knowledge, `.loctx/` and the project's text
|
|
203
|
+
* are never touched. Running it again on its own result changes nothing. It runs while the pin is 0.3.x, or
|
|
204
|
+
* while the reset note is still pending.
|
|
205
|
+
*/
|
|
206
|
+
export function planReset(root, pin, force = false) {
|
|
207
|
+
// a pending reset note keeps it on, so `update --force` can still take a kept skill once the pin moved
|
|
208
|
+
const ap = join(root, 'AGENTS.md');
|
|
209
|
+
const pending = existsSync(ap) && readFileSync(ap, 'utf8').includes(RESET_PENDING);
|
|
210
|
+
if (!isV03(pin) && !pending)
|
|
211
|
+
return null;
|
|
212
|
+
const out = { writes: [], deletes: [], kept: [], profile: 'light', lines: [] };
|
|
213
|
+
for (const [name, why] of Object.entries(RETIRED_SKILLS)) {
|
|
214
|
+
const mine = `.agents/skills/${name}`;
|
|
215
|
+
// a lone copy is the generator's to take (when reins wrote it) or the project's own
|
|
216
|
+
if (!existsSync(join(root, mine)))
|
|
217
|
+
continue;
|
|
218
|
+
const untouched = skillUntouched(root, name);
|
|
219
|
+
if (!untouched && !force) {
|
|
220
|
+
out.kept.push(mine);
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
out.deletes.push(mine);
|
|
224
|
+
out.lines.push(`- ${mine} and its .claude/skills/ copy — 0.4 has no \`${name}\` skill; ${why}${untouched ? '' : ' (edited by hand; --force)'}`);
|
|
225
|
+
}
|
|
226
|
+
// bindings.yaml: comments and order stay; only these two keys change
|
|
227
|
+
const bp = join(root, TEAM_BINDINGS);
|
|
228
|
+
if (existsSync(bp)) {
|
|
229
|
+
const doc = parseDocument(readFileSync(bp, 'utf8'));
|
|
230
|
+
const top = doc.contents;
|
|
231
|
+
if (isMap(top) && doc.get('schema') === 'reins/bindings@2') {
|
|
232
|
+
let changed = false;
|
|
233
|
+
if (doc.hasIn(['audit', 'required'])) {
|
|
234
|
+
doc.deleteIn(['audit', 'required']);
|
|
235
|
+
const a = doc.get('audit', true);
|
|
236
|
+
if (!isMap(a) || a.items.length === 0)
|
|
237
|
+
doc.delete('audit');
|
|
238
|
+
changed = true;
|
|
239
|
+
out.lines.push(`~ ${TEAM_BINDINGS}: audit.required removed — an audit is optional and a person starts it; the auditor's model stays`);
|
|
240
|
+
}
|
|
241
|
+
const had = doc.get('profile');
|
|
242
|
+
if (had === 'light' || had === 'full')
|
|
243
|
+
out.profile = had;
|
|
244
|
+
else {
|
|
245
|
+
const agents = join(root, '.claude/agents');
|
|
246
|
+
const rs = existsSync(agents) && readdirSync(agents).some((n) => /^rs-.*\.md$/.test(n));
|
|
247
|
+
out.profile = rs ? 'full' : 'light';
|
|
248
|
+
const at = top.items.findIndex((p) => isScalar(p.key) && p.key.value === 'mode');
|
|
249
|
+
const pair = doc.createPair('profile', out.profile);
|
|
250
|
+
if (at >= 0)
|
|
251
|
+
top.items.splice(at + 1, 0, pair);
|
|
252
|
+
else
|
|
253
|
+
top.items.push(pair);
|
|
254
|
+
changed = true;
|
|
255
|
+
out.lines.push(`~ ${TEAM_BINDINGS}: profile: ${out.profile} — ${rs ? 'the rs-* agents and the role files stay' : 'there were no rs-* agents; the role files under .agents/harness/roles/ go'}; \`reins config\` changes it`);
|
|
256
|
+
}
|
|
257
|
+
if (changed)
|
|
258
|
+
out.writes.push({ path: TEAM_BINDINGS, content: doc.toString() });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// gates.yaml: only the schema line, so the file is otherwise byte for byte the project's
|
|
262
|
+
const gp = '.agents/harness/gates.yaml';
|
|
263
|
+
if (existsSync(join(root, gp))) {
|
|
264
|
+
const text = readFileSync(join(root, gp), 'utf8');
|
|
265
|
+
const next = text.replace(/^(schema:[ \t]*["']?)reins\/gates@1(["']?[ \t]*)$/m, '$1reins/gates@2$2');
|
|
266
|
+
if (next !== text) {
|
|
267
|
+
out.writes.push({ path: gp, content: next });
|
|
268
|
+
out.lines.push(`~ ${gp}: schema reins/gates@2 without areas — every gate still runs as before; split the gates into areas with the \`gates\` skill or \`reins config gates\``);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
/** `reins update` (design §6, §7): sources → generated files, hand-edit confirmation, moving 0.x and 0.3 installs. */
|
|
165
274
|
export async function runUpdate(o) {
|
|
166
275
|
if (o.prompter && !o.dryRun) {
|
|
167
276
|
const plan = await runUpdate({ ...o, prompter: undefined, dryRun: true });
|
|
@@ -170,6 +279,7 @@ export async function runUpdate(o) {
|
|
|
170
279
|
const a = plan.install?.applied;
|
|
171
280
|
const nothing = !plan.converted &&
|
|
172
281
|
plan.removed.length === 0 &&
|
|
282
|
+
!plan.reset?.length &&
|
|
173
283
|
plan.cleanup.length === 0 &&
|
|
174
284
|
plan.handEdited.length === 0 &&
|
|
175
285
|
(!a || a.created.length + a.changed.length + a.removed.length === 0);
|
|
@@ -194,7 +304,9 @@ export async function runUpdate(o) {
|
|
|
194
304
|
let force = o.force;
|
|
195
305
|
if (plan.handEdited.length && !force) {
|
|
196
306
|
const over = await o.prompter.confirm({
|
|
197
|
-
message:
|
|
307
|
+
message: plan.keptSkills?.length
|
|
308
|
+
? `Overwrite or delete ${plan.handEdited.length} file(s) edited by hand (${plan.handEdited.join(', ')})?`
|
|
309
|
+
: `Overwrite ${plan.handEdited.length} generated file(s) edited by hand (${plan.handEdited.join(', ')})?`,
|
|
198
310
|
initial: false,
|
|
199
311
|
});
|
|
200
312
|
if (over === EXIT)
|
|
@@ -255,6 +367,17 @@ async function updateNow(o) {
|
|
|
255
367
|
else
|
|
256
368
|
pending.push({ path: '.agents/harness/bindings.yaml', content: stringify(doc) });
|
|
257
369
|
}
|
|
370
|
+
// 0.3 → 0.4 (design §7): retired skills, bindings, gates schema; the blocks and the note follow in install
|
|
371
|
+
const reset = planReset(root, String(pin.version), !!o.force);
|
|
372
|
+
if (reset) {
|
|
373
|
+
if (o.dryRun)
|
|
374
|
+
pending.push(...reset.writes);
|
|
375
|
+
res.reset = [...reset.lines];
|
|
376
|
+
if (reset.kept.length) {
|
|
377
|
+
res.keptSkills = reset.kept;
|
|
378
|
+
res.handEdited.push(...reset.kept);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
258
381
|
// 0.x pieces
|
|
259
382
|
const legacy = planLegacy(root);
|
|
260
383
|
res.removed.push(...legacy.deletes, ...legacy.writes.map((w) => `~ ${w.path}`), ...legacy.notes);
|
|
@@ -280,6 +403,10 @@ async function updateNow(o) {
|
|
|
280
403
|
writeFileSync(join(root, w.path), w.content);
|
|
281
404
|
for (const d of legacy.deletes)
|
|
282
405
|
rmSync(join(root, d), { recursive: true, force: true });
|
|
406
|
+
for (const w of reset?.writes ?? [])
|
|
407
|
+
writeFileSync(join(root, w.path), w.content);
|
|
408
|
+
for (const d of reset?.deletes ?? [])
|
|
409
|
+
rmSync(join(root, d), { recursive: true, force: true });
|
|
283
410
|
if (o.yes && res.cleanup.length) {
|
|
284
411
|
for (const d of res.cleanup)
|
|
285
412
|
rmSync(join(root, d), { recursive: true, force: true });
|
|
@@ -297,18 +424,31 @@ async function updateNow(o) {
|
|
|
297
424
|
retire: true,
|
|
298
425
|
force: o.force,
|
|
299
426
|
pending,
|
|
300
|
-
pendingDeletes: o.dryRun ? legacy.deletes : [],
|
|
427
|
+
pendingDeletes: o.dryRun ? [...legacy.deletes, ...(reset?.deletes ?? [])] : [],
|
|
301
428
|
tidy: beforeGuide(pin.version),
|
|
429
|
+
...(reset ? { resetNote: resetNote(reset.profile) } : {}),
|
|
302
430
|
});
|
|
303
|
-
res.handEdited
|
|
431
|
+
res.handEdited.push(...(res.install.generated?.refused ?? [])
|
|
304
432
|
.filter((r) => r.why.startsWith('edited by hand'))
|
|
305
|
-
.map((r) => r.path);
|
|
433
|
+
.map((r) => r.path));
|
|
434
|
+
if (reset && res.install.notes.some((n) => n.startsWith('AGENTS.md has a reins:reset note')))
|
|
435
|
+
res.reset?.push('~ AGENTS.md: the 0.3 blocks replaced (delegation first); a reins:reset note leaves the to-do for the `onboard` skill');
|
|
436
|
+
if (res.reset?.length)
|
|
437
|
+
res.reset.push('• .agents/intent/, .agents/audit/, .agents/knowledge/ and .loctx/ are left as they were: a spec in progress can be continued');
|
|
438
|
+
if (reset && !o.dryRun)
|
|
439
|
+
// the generator took the copies' files; the folders they leave empty go too
|
|
440
|
+
for (const d of reset.deletes) {
|
|
441
|
+
const copy = join(root, '.claude/skills', d.slice('.agents/skills/'.length));
|
|
442
|
+
if (existsSync(copy) && listFiles(copy).length === 0)
|
|
443
|
+
rmSync(copy, { recursive: true, force: true });
|
|
444
|
+
}
|
|
306
445
|
return res;
|
|
307
446
|
}
|
|
308
447
|
/**
|
|
309
448
|
* What the install step said that someone running `update` has to see (design §6): a hooks block that was
|
|
310
|
-
* rewritten and what it held, the hook line to add where reins does not add it,
|
|
311
|
-
* alone for another reason than a hand edit (those have a line of their own)
|
|
449
|
+
* rewritten and what it held, the hook line to add where reins does not add it, a generated file left
|
|
450
|
+
* alone for another reason than a hand edit (those have a line of their own), and an AGENTS.md block not
|
|
451
|
+
* placed. The rest of the install
|
|
312
452
|
* notes (onboarding, the first conversation) is for `install`.
|
|
313
453
|
*/
|
|
314
454
|
export function updateNotes(r) {
|
|
@@ -316,6 +456,8 @@ export function updateNotes(r) {
|
|
|
316
456
|
n.startsWith('hook proposal') ||
|
|
317
457
|
n.startsWith('no hook tool found') ||
|
|
318
458
|
(n.startsWith('left alone ') && !n.includes(': edited by hand')) ||
|
|
459
|
+
// a block the project's own section stands in for (croffle's `## Layout`, found applying 0.4)
|
|
460
|
+
n.startsWith('AGENTS.md block ') ||
|
|
319
461
|
// the personal force-with-lease line and its migration from the team file (024 S-26a, review 6)
|
|
320
462
|
n.startsWith('force push with lease') ||
|
|
321
463
|
n.startsWith('.claude/settings.local.json'));
|
|
@@ -340,9 +482,17 @@ export function formatUpdate(r, dry) {
|
|
|
340
482
|
for (const p of r.removed)
|
|
341
483
|
out.push(` - ${p}`);
|
|
342
484
|
}
|
|
485
|
+
if (r.reset?.length) {
|
|
486
|
+
out.push(`0.3 → 0.4: ${dry ? 'would change' : 'changed'}`);
|
|
487
|
+
for (const l of r.reset)
|
|
488
|
+
out.push(` ${l}`);
|
|
489
|
+
}
|
|
343
490
|
if (r.cleanup.length)
|
|
344
491
|
out.push(`.loctx 0.x working files (${dry ? 'deleted on confirmation' : r.cleaned ? 'deleted' : 'listed; --yes deletes them'}): ${r.cleanup.join(', ')}`);
|
|
345
|
-
if (a &&
|
|
492
|
+
if (a &&
|
|
493
|
+
a.created.length + a.changed.length + a.removed.length === 0 &&
|
|
494
|
+
!r.removed.length &&
|
|
495
|
+
!r.reset?.length)
|
|
346
496
|
out.push('already up to date');
|
|
347
497
|
else if (a) {
|
|
348
498
|
out.push(`${dry ? 'would write' : 'wrote'}: ${a.created.length} new, ${a.changed.length} changed${a.removed.length ? `, ${a.removed.length} removed` : ''}`);
|
|
@@ -356,7 +506,9 @@ export function formatUpdate(r, dry) {
|
|
|
356
506
|
for (const n of r.overrides)
|
|
357
507
|
out.push(`• block "${n}" is overridden by the project — compare it with the new upstream block`);
|
|
358
508
|
for (const p of r.handEdited)
|
|
359
|
-
out.push(
|
|
509
|
+
out.push(r.keptSkills?.includes(p)
|
|
510
|
+
? `• ${p} was edited by hand — kept, though 0.4 no longer ships it; run with --force to delete it`
|
|
511
|
+
: `• ${p} was edited by hand — not overwritten; run with --force to overwrite it`);
|
|
360
512
|
for (const n of updateNotes(r))
|
|
361
513
|
out.push(`• ${n}`);
|
|
362
514
|
return `${out.join('\n')}\n`;
|