@bluenyang/reins 0.1.3 → 0.1.4-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 +2 -1
- package/cli/dist/commands/check.js +15 -1
- package/cli/dist/commands/configure.js +34 -2
- package/cli/dist/commands/install.js +74 -7
- package/cli/dist/commands/migrate.js +49 -4
- package/cli/dist/commands/stages.js +22 -0
- package/cli/dist/commands/status.js +16 -2
- package/cli/dist/commands/update.js +4 -1
- package/cli/dist/lib/detect.js +114 -1
- package/cli/dist/lib/fsx.js +1 -1
- package/cli/dist/lib/memory.js +96 -0
- package/cli/dist/lib/migrate-plan.js +162 -35
- package/cli/dist/lib/release.js +124 -0
- package/cli/dist/lib/schema.js +2 -0
- package/cli/dist/lib/secrets.js +1 -0
- package/cli/dist/reins.js +42 -5
- package/docs/README.ko.md +2 -1
- package/harness/policy/common-red-lines.yaml +1 -1
- package/harness/roles/deploy.md +15 -8
- package/harness/schemas/install.schema.json +29 -0
- package/package.json +1 -1
- package/skills/reins-release/SKILL.md +2 -2
- package/skills/reins-setup/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -122,7 +122,8 @@ To work on reins itself: `git clone https://github.com/bluenyang/reins.git`, the
|
|
|
122
122
|
| `metrics` | implemented | summary of `.loctx/reports/metrics.jsonl`: tokens by role, vendor, ticket and intent, knowledge stops per ticket; `metrics record` adds a role run's tokens |
|
|
123
123
|
| `recall` | not implemented | search past decisions by symptom |
|
|
124
124
|
| `doctor` | not implemented | — |
|
|
125
|
-
| `configure
|
|
125
|
+
| `configure gates` | implemented | lists subdirectory gate proposals; `--add <name>...` appends them to gates.yaml |
|
|
126
|
+
| `configure budget\|language` | not implemented | — |
|
|
126
127
|
|
|
127
128
|
`install`, `migrate`, `update`, `gate`, `status`, `check` and `metrics` take `--json`. Every `check` and `gate` run also appends a line to `.loctx/reports/metrics.jsonl`. `check` stages map to
|
|
128
129
|
T1 (`ticket-start`), T2 (`pre-commit`), T3 (`verdict`), T4 (`pre-push`) and T5 (`rc-close`).
|
|
@@ -10,6 +10,7 @@ import { harnessVersion, packageHarness, packageSkills, tierSkills } from '../li
|
|
|
10
10
|
import { listFiles, relPath } from '../lib/fsx.js';
|
|
11
11
|
import { driftGenerated } from '../lib/vendor-write.js';
|
|
12
12
|
import { indexReader, workTreeReader } from '../lib/reader.js';
|
|
13
|
+
import { PROJECT_OWNED, tierFiles } from './install.js';
|
|
13
14
|
import { rcClose, ticketStart, verdictCheck } from './stages.js';
|
|
14
15
|
import { parse } from 'yaml';
|
|
15
16
|
import { report } from '../lib/verdict.js';
|
|
@@ -142,6 +143,7 @@ export function driftConvention(root, only, rd = workTreeReader(root)) {
|
|
|
142
143
|
const schemas = loadSchemasFrom(rd, hrel);
|
|
143
144
|
const findings = [];
|
|
144
145
|
const candidates = [
|
|
146
|
+
`${hrel}/install.yaml`,
|
|
145
147
|
...rd.list(`${hrel}/templates`),
|
|
146
148
|
...rd.list(`${hrel}/knowledge-seeds`),
|
|
147
149
|
...rd.list('.agents/intent'),
|
|
@@ -215,7 +217,6 @@ export function driftConvention(root, only, rd = workTreeReader(root)) {
|
|
|
215
217
|
return findings;
|
|
216
218
|
}
|
|
217
219
|
/** Files in an installed harness that belong to the project, not upstream. */
|
|
218
|
-
const PROJECT_OWNED = new Set(['bindings.yaml', 'gates.yaml', 'install.yaml', 'generated.yaml']);
|
|
219
220
|
/** Drift, match layer — the installed `.agents/harness/` against the packaged upstream at the pinned version (design §6). */
|
|
220
221
|
export function driftMatch(root, rd = workTreeReader(root)) {
|
|
221
222
|
const installed = '.agents/harness';
|
|
@@ -243,6 +244,9 @@ export function driftMatch(root, rd = workTreeReader(root)) {
|
|
|
243
244
|
},
|
|
244
245
|
];
|
|
245
246
|
const findings = [];
|
|
247
|
+
// only files this tier installs are compared; an upstream file it no longer installs (e.g. CHANGELOG.md
|
|
248
|
+
// from a 0.1.0 install) is a leftover that `reins update` removes, not a hand edit
|
|
249
|
+
const installs = new Set(tierFiles(listFiles(up), (pinned.tier ?? 'graph')));
|
|
246
250
|
for (const entry of rd.list(installed)) {
|
|
247
251
|
const rel = entry.slice(installed.length + 1);
|
|
248
252
|
if (PROJECT_OWNED.has(rel))
|
|
@@ -250,6 +254,16 @@ export function driftMatch(root, rd = workTreeReader(root)) {
|
|
|
250
254
|
const src = join(up, rel);
|
|
251
255
|
if (!existsSync(src))
|
|
252
256
|
continue;
|
|
257
|
+
if (!installs.has(rel)) {
|
|
258
|
+
findings.push({
|
|
259
|
+
reason: 'F2',
|
|
260
|
+
verdict: 'WARN',
|
|
261
|
+
path: `.agents/harness/${rel}`,
|
|
262
|
+
message: `upstream v${upVersion} no longer installs this file for the ${pinned.tier ?? 'graph'} tier`,
|
|
263
|
+
resume: 'run `reins update` to remove it',
|
|
264
|
+
});
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
253
267
|
if (readFileSync(src, 'utf8') !== rd.read(entry))
|
|
254
268
|
findings.push({
|
|
255
269
|
reason: 'F2',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { parse, stringify } from 'yaml';
|
|
4
|
-
import { CONFIRMED_MODELS, checkBinding, newModelCache, vendorOf, vendors, } from '../lib/detect.js';
|
|
3
|
+
import { parse, parseDocument, stringify } from 'yaml';
|
|
4
|
+
import { CONFIRMED_MODELS, checkBinding, newModelCache, subdirProposals, vendorOf, vendors, } from '../lib/detect.js';
|
|
5
5
|
import { generateVendorFiles } from '../lib/generate.js';
|
|
6
6
|
import { repoRoot } from '../lib/git.js';
|
|
7
7
|
import { writeGenerated } from '../lib/vendor-write.js';
|
|
@@ -77,3 +77,35 @@ export async function configureBindings(o) {
|
|
|
77
77
|
.toSorted((a, b) => a.role.localeCompare(b.role));
|
|
78
78
|
return { changed, table, generated };
|
|
79
79
|
}
|
|
80
|
+
/** `reins configure gates [--add <name>…]` (spec S-7): subdirectory proposals, appended after the existing gates. */
|
|
81
|
+
export function configureGates(o = {}) {
|
|
82
|
+
const root = repoRoot(o.cwd ?? process.cwd());
|
|
83
|
+
const path = join(root, '.agents/harness/gates.yaml');
|
|
84
|
+
if (!existsSync(path))
|
|
85
|
+
return { refused: 'no gates.yaml — run reins install', code: 2, available: [], added: [] };
|
|
86
|
+
const doc = parseDocument(readFileSync(path, 'utf8'));
|
|
87
|
+
const have = new Set(Object.keys(doc.toJS()?.gates ?? {}));
|
|
88
|
+
const available = subdirProposals(root).filter((g) => !have.has(g.name));
|
|
89
|
+
const names = o.add ?? [];
|
|
90
|
+
const unknown = names.filter((n) => !available.some((g) => g.name === n));
|
|
91
|
+
if (unknown.length)
|
|
92
|
+
return {
|
|
93
|
+
refused: `no such proposal: ${unknown.join(', ')} — available: ${available.map((g) => g.name).join(', ') || 'none'}`,
|
|
94
|
+
code: 1,
|
|
95
|
+
available,
|
|
96
|
+
added: [],
|
|
97
|
+
};
|
|
98
|
+
const added = [];
|
|
99
|
+
for (const n of new Set(names)) {
|
|
100
|
+
const g = available.find((x) => x.name === n);
|
|
101
|
+
doc.setIn(['gates', g.name], doc.createNode({ cmd: g.cmd, from: g.from }));
|
|
102
|
+
if (doc.has('order'))
|
|
103
|
+
doc.addIn(['order'], g.name);
|
|
104
|
+
else
|
|
105
|
+
doc.set('order', doc.createNode([g.name]));
|
|
106
|
+
added.push(g.name);
|
|
107
|
+
}
|
|
108
|
+
if (added.length)
|
|
109
|
+
writeFileSync(path, doc.toString());
|
|
110
|
+
return { available: available.filter((g) => !added.includes(g.name)), added };
|
|
111
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, rmdirSync, rmSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
3
|
import { parse, stringify } from 'yaml';
|
|
4
|
+
import { planMemoryProposals } from '../lib/memory.js';
|
|
5
|
+
import { draftRelease, releaseDraftNotes } from '../lib/release.js';
|
|
4
6
|
import { applyBlocks, parseBlocks } from '../lib/blocks.js';
|
|
5
7
|
import { CONFIRMED_MODELS, checkBinding, discoverGates, newModelCache, vendorOf, generation, stacks, vendors, } from '../lib/detect.js';
|
|
6
8
|
import { apply, listFiles } from '../lib/fsx.js';
|
|
@@ -10,7 +12,7 @@ import { harnessVersion, packageHarness, packageSkills, packageVersion, tierSkil
|
|
|
10
12
|
import { generateVendorFiles } from '../lib/generate.js';
|
|
11
13
|
import { writeGenerated } from '../lib/vendor-write.js';
|
|
12
14
|
/** Which upstream harness files a tier installs (design §1, tier table). */
|
|
13
|
-
function tierFiles(all, tier) {
|
|
15
|
+
export function tierFiles(all, tier) {
|
|
14
16
|
return all.filter((f) => {
|
|
15
17
|
if (f.startsWith('knowledge-seeds/'))
|
|
16
18
|
return false; // copied into knowledge/, not harness/
|
|
@@ -29,6 +31,23 @@ function tierFiles(all, tier) {
|
|
|
29
31
|
return tier === 'graph'; // roles/, schemas/
|
|
30
32
|
});
|
|
31
33
|
}
|
|
34
|
+
/** Harness files the project owns; update and drift never touch them. */
|
|
35
|
+
export const PROJECT_OWNED = new Set([
|
|
36
|
+
'bindings.yaml',
|
|
37
|
+
'gates.yaml',
|
|
38
|
+
'install.yaml',
|
|
39
|
+
'generated.yaml',
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* Files installed under `.agents/harness/` that upstream still ships but this tier no longer installs
|
|
43
|
+
* (e.g. `CHANGELOG.md`): in upstream, outside `tierFiles(tier)`, not project-owned. Anything not in
|
|
44
|
+
* upstream is the project's and is never listed.
|
|
45
|
+
*/
|
|
46
|
+
export function retiredFiles(installed, upstream, tier) {
|
|
47
|
+
const up = new Set(upstream);
|
|
48
|
+
const keep = new Set(tierFiles(upstream, tier));
|
|
49
|
+
return installed.filter((f) => up.has(f) && !keep.has(f) && !PROJECT_OWNED.has(f));
|
|
50
|
+
}
|
|
32
51
|
/** bindings.yaml (design §5): defaults from role files; an unavailable vendor falls back, else to pm's model. */
|
|
33
52
|
export function buildBindings(harness, available, vs, mode, cache) {
|
|
34
53
|
const roles = {};
|
|
@@ -158,14 +177,33 @@ export async function runInstall(o) {
|
|
|
158
177
|
const okGates = await o.asker.ask(`gates found: ${gateList} — use them? (y/n)`, 'y');
|
|
159
178
|
if (!/^y/i.test(okGates))
|
|
160
179
|
notes.push('gates not confirmed — edit .agents/harness/gates.yaml, then `reins check --dry-run`');
|
|
180
|
+
let chosen = [];
|
|
181
|
+
if (proposal.proposals.length) {
|
|
182
|
+
const listing = proposal.proposals.map((g) => `${g.name}=${g.cmd}`).join('; ');
|
|
183
|
+
if (o.mode === 'manual') {
|
|
184
|
+
const pick = await o.asker.ask(`subdirectory gates (names, comma-separated; empty: none) — ${listing}`, '');
|
|
185
|
+
const names = new Set(pick
|
|
186
|
+
.split(',')
|
|
187
|
+
.map((x) => x.trim())
|
|
188
|
+
.filter(Boolean));
|
|
189
|
+
chosen = proposal.proposals.filter((g) => names.has(g.name));
|
|
190
|
+
if (o.dryRun)
|
|
191
|
+
notes.push(`subdirectory gates offered (names are asked in a real run): ${listing}`);
|
|
192
|
+
for (const n of names)
|
|
193
|
+
if (!chosen.some((g) => g.name === n))
|
|
194
|
+
notes.push(`no such subdirectory gate: ${n}`);
|
|
195
|
+
}
|
|
196
|
+
else
|
|
197
|
+
notes.push(`subdirectory gates not added (auto mode): ${listing} — add with \`reins configure gates --add <name>\``);
|
|
198
|
+
}
|
|
161
199
|
for (const x of proposal.excluded)
|
|
162
200
|
notes.push(`excluded from gates: ${x.name} (${x.why})`);
|
|
163
|
-
add('.agents/harness/gates.yaml', buildGates(root, /^y/i.test(okGates) ? proposal.gates : []), 'declared gates');
|
|
201
|
+
add('.agents/harness/gates.yaml', buildGates(root, [...(/^y/i.test(okGates) ? proposal.gates : []), ...chosen]), 'declared gates');
|
|
164
202
|
}
|
|
165
203
|
// 3. generated configuration
|
|
166
204
|
if (o.tier === 'graph' && !hasBindings)
|
|
167
205
|
add('.agents/harness/bindings.yaml', buildBindings(up, avail, vs, o.mode, o.modelCache ?? newModelCache()), 'role ↔ model bindings');
|
|
168
|
-
add('.agents/harness/install.yaml', `# version pin and install settings (R25) — read by reins update\n${stringify({ schema: 'reins/install@1', tier: o.tier, version, cli: packageVersion(), mode: o.mode, language })}`, 'version pin');
|
|
206
|
+
add('.agents/harness/install.yaml', `# version pin and install settings (R25) — read by reins update\n${stringify({ ...pinned, schema: 'reins/install@1', tier: o.tier, version, cli: packageVersion(), mode: o.mode, language })}`, 'version pin');
|
|
169
207
|
// 4. layout skeleton (design §1); never overwrite project files
|
|
170
208
|
if (o.tier !== 'harness') {
|
|
171
209
|
addIfMissing('.agents/intent/.gitkeep', '', 'intent folders live here');
|
|
@@ -210,6 +248,15 @@ export async function runInstall(o) {
|
|
|
210
248
|
: '';
|
|
211
249
|
if (!/^\/?\.loctx\/?$/m.test(gi))
|
|
212
250
|
add('.gitignore', `${gi.replace(/\s*$/, '')}\n\n# reins local workspace\n.loctx/\n`, 'keep .loctx out of git');
|
|
251
|
+
// 4b. .claude/memory is never moved: each file becomes a knowledge draft (design §7)
|
|
252
|
+
{
|
|
253
|
+
const d = o.now ?? new Date();
|
|
254
|
+
const memory = planMemoryProposals(root, `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`);
|
|
255
|
+
writes.push(...memory.writes);
|
|
256
|
+
notes.push(...memory.notes);
|
|
257
|
+
}
|
|
258
|
+
// 4c. a release: draft from dispatchable workflows — proposal only, never written
|
|
259
|
+
notes.push(...releaseDraftNotes(draftRelease(root)));
|
|
213
260
|
// 5. AGENTS.md managed blocks, CLAUDE.md pointer
|
|
214
261
|
const agentsPath = join(root, 'AGENTS.md');
|
|
215
262
|
const agents = existsSync(agentsPath) ? readFileSync(agentsPath, 'utf8') : '# AGENTS.md\n';
|
|
@@ -244,6 +291,25 @@ export async function runInstall(o) {
|
|
|
244
291
|
notes.push('next: in your agent, run the setup skill (/reins-setup) — the PM reads the project and proposes AGENTS.md project sections');
|
|
245
292
|
// 8. apply, then record (only when something changed)
|
|
246
293
|
const applied = apply(root, writes, !!o.dryRun);
|
|
294
|
+
if (o.retire) {
|
|
295
|
+
const harnessDir = join(root, '.agents/harness');
|
|
296
|
+
const here = existsSync(harnessDir) ? listFiles(harnessDir) : [];
|
|
297
|
+
for (const f of retiredFiles(here, listFiles(up), o.tier)) {
|
|
298
|
+
applied.removed.push(`.agents/harness/${f}`);
|
|
299
|
+
if (o.dryRun)
|
|
300
|
+
continue;
|
|
301
|
+
rmSync(join(harnessDir, f), { force: true });
|
|
302
|
+
// prune directories the removal left empty, never the harness root
|
|
303
|
+
for (let d = dirname(join(harnessDir, f)); d !== harnessDir; d = dirname(d)) {
|
|
304
|
+
try {
|
|
305
|
+
rmdirSync(d);
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
247
313
|
// 9. vendor files from the installed harness (design §6) — never over a file reins did not write
|
|
248
314
|
const generated = o.dryRun ? undefined : writeGenerated(root, generateVendorFiles(root), false);
|
|
249
315
|
if (generated) {
|
|
@@ -254,7 +320,7 @@ export async function runInstall(o) {
|
|
|
254
320
|
notes.push(`left alone ${r.path}: ${r.why}`);
|
|
255
321
|
}
|
|
256
322
|
let history;
|
|
257
|
-
const changedAny = applied.created.length + applied.changed.length > 0;
|
|
323
|
+
const changedAny = applied.created.length + applied.changed.length + applied.removed.length > 0;
|
|
258
324
|
if (changedAny && !o.dryRun && o.tier !== 'harness') {
|
|
259
325
|
const now = o.now ?? new Date();
|
|
260
326
|
// local time, like every other history file name (<YYYY-MM-DD-HHmm>)
|
|
@@ -267,9 +333,10 @@ export async function runInstall(o) {
|
|
|
267
333
|
`# reins install ${o.tier} (${o.mode}) — v${version}`,
|
|
268
334
|
'',
|
|
269
335
|
`- generation before: ${gen}`,
|
|
270
|
-
`- created: ${applied.created.length} · changed: ${applied.changed.length} · unchanged: ${applied.unchanged.length}`,
|
|
336
|
+
`- created: ${applied.created.length} · changed: ${applied.changed.length} · unchanged: ${applied.unchanged.length} · removed: ${applied.removed.length}`,
|
|
271
337
|
...applied.created.map((p) => ` - + ${p}`),
|
|
272
338
|
...applied.changed.map((p) => ` - ~ ${p}`),
|
|
339
|
+
...applied.removed.map((p) => ` - - ${p}`),
|
|
273
340
|
'',
|
|
274
341
|
'## notes',
|
|
275
342
|
...notes.map((n) => `- ${n}`),
|
|
@@ -4,6 +4,7 @@ import { applyBlocks, parseBlocks, swapSections } from '../lib/blocks.js';
|
|
|
4
4
|
import { generation } from '../lib/detect.js';
|
|
5
5
|
import { repoRoot } from '../lib/git.js';
|
|
6
6
|
import { convertWorkToTicket, planMigration } from '../lib/migrate-plan.js';
|
|
7
|
+
import { splitFrontmatter } from '../lib/skills.js';
|
|
7
8
|
import { packageHarness } from '../lib/upstream.js';
|
|
8
9
|
import { ROADMAP_STUB, runInstall } from './install.js';
|
|
9
10
|
const pad = (n) => String(n).padStart(2, '0');
|
|
@@ -16,6 +17,40 @@ function removeEmptyDirs(dir) {
|
|
|
16
17
|
if (readdirSync(dir).length === 0)
|
|
17
18
|
rmdirSync(dir);
|
|
18
19
|
}
|
|
20
|
+
/** Intent 000 (draft) that the migrated tickets point at — only when this run made tickets and none exists. */
|
|
21
|
+
function writeMigratedIntent(root, moves) {
|
|
22
|
+
const made = moves.filter((m) => m.result === 'converted');
|
|
23
|
+
const dir = join(root, '.agents/intent');
|
|
24
|
+
if (made.length === 0 || (existsSync(dir) && readdirSync(dir).some((e) => e.startsWith('000_'))))
|
|
25
|
+
return null;
|
|
26
|
+
let version = '0.0.0';
|
|
27
|
+
try {
|
|
28
|
+
const v = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version;
|
|
29
|
+
if (typeof v === 'string' && v)
|
|
30
|
+
version = v;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// no package.json — keep the default
|
|
34
|
+
}
|
|
35
|
+
const { body } = splitFrontmatter(readFileSync(join(packageHarness(), 'templates/intent.md'), 'utf8'));
|
|
36
|
+
const list = made
|
|
37
|
+
.map((m) => `- ${m.to.slice('.loctx/ticket/'.length, m.to.indexOf('_'))} — from .ai/work/${m.from.slice('.ai/work/'.length)}`)
|
|
38
|
+
.join('\n');
|
|
39
|
+
const text = body.replace(/## 문제\n—/, () => `## 문제\nOpen work items that \`reins migrate\` moved out of \`.ai/work/\`. They point at this intent until the PL plans them again:\n\n${list}`);
|
|
40
|
+
const yaml = [
|
|
41
|
+
'id: "000"',
|
|
42
|
+
'slug: migrated',
|
|
43
|
+
`version: ${JSON.stringify(version)}`,
|
|
44
|
+
'status: draft',
|
|
45
|
+
'origin: user',
|
|
46
|
+
'approvals: []',
|
|
47
|
+
'supersedes: null',
|
|
48
|
+
].join('\n');
|
|
49
|
+
const out = join(dir, '000_migrated/intent.md');
|
|
50
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
51
|
+
writeFileSync(out, `---\n${yaml}\n---\n${text}`);
|
|
52
|
+
return '.agents/intent/000_migrated/intent.md written as a draft listing the migrated tickets — the user approves it before any of them starts';
|
|
53
|
+
}
|
|
19
54
|
/** `reins migrate <tier>` (design §7): install if needed, move the old workspace, swap AGENTS.md sections. Idempotent. */
|
|
20
55
|
export async function runMigrate(o) {
|
|
21
56
|
const root = repoRoot(o.cwd ?? process.cwd());
|
|
@@ -30,7 +65,7 @@ export async function runMigrate(o) {
|
|
|
30
65
|
if (gen === 'none')
|
|
31
66
|
return { ...res, refused: 'no existing harness or workspace here — use `reins install`' };
|
|
32
67
|
// 1. make sure the target layout exists (install is idempotent)
|
|
33
|
-
|
|
68
|
+
{
|
|
34
69
|
const inst = await runInstall({
|
|
35
70
|
tier: o.tier,
|
|
36
71
|
mode: o.mode,
|
|
@@ -39,13 +74,14 @@ export async function runMigrate(o) {
|
|
|
39
74
|
detectVendors: o.detectVendors,
|
|
40
75
|
now: o.now,
|
|
41
76
|
overExisting: true,
|
|
77
|
+
dryRun: o.dryRun, // plans only: gate proposals and memory drafts show up as notes
|
|
42
78
|
});
|
|
43
79
|
if (inst.refused)
|
|
44
80
|
return { ...res, refused: inst.refused };
|
|
45
81
|
res.report.push(...inst.notes.filter((n) => !n.startsWith('next:') && !n.includes('managed') && !n.includes('not placed')));
|
|
46
82
|
}
|
|
47
83
|
// 2. move the old workspace
|
|
48
|
-
const plan = planMigration(root);
|
|
84
|
+
const plan = planMigration(root, { legacy: o.legacy });
|
|
49
85
|
res.report.push(...plan.report);
|
|
50
86
|
for (const m of plan.moves) {
|
|
51
87
|
const from = join(root, m.from);
|
|
@@ -56,8 +92,12 @@ export async function runMigrate(o) {
|
|
|
56
92
|
}
|
|
57
93
|
mkdirSync(dirname(to), { recursive: true });
|
|
58
94
|
const src = readFileSync(from);
|
|
59
|
-
if (m.action === 'ticket') {
|
|
60
|
-
|
|
95
|
+
if (m.action === 'ticket' && m.existing) {
|
|
96
|
+
unlinkSync(from); // converted by an earlier run
|
|
97
|
+
res.moves.push({ ...m, result: 'same' });
|
|
98
|
+
}
|
|
99
|
+
else if (m.action === 'ticket') {
|
|
100
|
+
writeFileSync(to, convertWorkToTicket(src.toString('utf8'), m.from.slice('.ai/work/'.length), m.n ?? 1, m.idMap, m.dropped, m.group));
|
|
61
101
|
unlinkSync(from);
|
|
62
102
|
res.moves.push({ ...m, result: 'converted' });
|
|
63
103
|
}
|
|
@@ -78,6 +118,11 @@ export async function runMigrate(o) {
|
|
|
78
118
|
}
|
|
79
119
|
if (!o.dryRun)
|
|
80
120
|
removeEmptyDirs(join(root, '.ai'));
|
|
121
|
+
if (!o.dryRun) {
|
|
122
|
+
const made = writeMigratedIntent(root, res.moves);
|
|
123
|
+
if (made)
|
|
124
|
+
res.report.push(made);
|
|
125
|
+
}
|
|
81
126
|
// 3. AGENTS.md: sections reins owns become managed blocks; the originals are kept locally
|
|
82
127
|
const agentsPath = join(root, 'AGENTS.md');
|
|
83
128
|
if (existsSync(agentsPath)) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
3
3
|
import { harnessDir, readYaml } from '../lib/harness.js';
|
|
4
|
+
import { dispatchLines, readRelease } from '../lib/release.js';
|
|
4
5
|
import { loadSchemas, validateFile } from '../lib/schema.js';
|
|
5
6
|
import { compound } from './gate.js';
|
|
6
7
|
import { approvedBy, busFor, historyPages, intentFile, intentIds, openTickets, recordedDecisions, ticketFile, } from '../lib/work.js';
|
|
@@ -433,8 +434,29 @@ export function rcClose(root, release) {
|
|
|
433
434
|
}
|
|
434
435
|
if (findings.length === 0)
|
|
435
436
|
findings.push(...nextRc(root, release));
|
|
437
|
+
if (findings.every((f) => f.verdict === 'WARN'))
|
|
438
|
+
findings.push(...dispatchFindings(root, findings));
|
|
436
439
|
return findings;
|
|
437
440
|
}
|
|
441
|
+
/** The rc dispatch lines (S-3) from install.yaml `release:`; the rc number comes from the ledger finding. */
|
|
442
|
+
function dispatchFindings(root, found) {
|
|
443
|
+
const rc = found.map((f) => /^next rc: (\S+)$/.exec(f.message)?.[1]).find(Boolean);
|
|
444
|
+
const ws = readRelease(root);
|
|
445
|
+
if (!rc || !ws)
|
|
446
|
+
return [
|
|
447
|
+
{
|
|
448
|
+
reason: 'F2',
|
|
449
|
+
verdict: 'WARN',
|
|
450
|
+
message: 'no release settings (install.yaml has no release:) — merge only',
|
|
451
|
+
},
|
|
452
|
+
];
|
|
453
|
+
const lines = dispatchLines(ws, 'rc', rc);
|
|
454
|
+
if (lines.length === 0)
|
|
455
|
+
return [
|
|
456
|
+
{ reason: 'F2', verdict: 'WARN', message: 'no release workflow is set for the rc stage' },
|
|
457
|
+
];
|
|
458
|
+
return lines.map((l) => ({ reason: 'F2', verdict: 'WARN', message: `dispatch: ${l}` }));
|
|
459
|
+
}
|
|
438
460
|
/**
|
|
439
461
|
* The next rc number from the local ledger `.loctx/release/<V>.md` (one `- rc.N …` line per rc):
|
|
440
462
|
* rc.1 when there is no ledger, else the last recorded rc + 1. A number already recorded is F2.
|
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
|
2
2
|
import { basename, join } from 'node:path';
|
|
3
3
|
import { parse } from 'yaml';
|
|
4
4
|
import { repoRoot } from '../lib/git.js';
|
|
5
|
-
import { harnessVersion, packageHarness } from '../lib/upstream.js';
|
|
5
|
+
import { harnessVersion, packageHarness, packageVersion } from '../lib/upstream.js';
|
|
6
6
|
import { candidateCount } from '../lib/retro.js';
|
|
7
7
|
import { driftGenerated } from '../lib/vendor-write.js';
|
|
8
8
|
import { report } from '../lib/verdict.js';
|
|
@@ -34,6 +34,8 @@ function harnessStatus(root) {
|
|
|
34
34
|
tier: null,
|
|
35
35
|
installedVersion: null,
|
|
36
36
|
packageVersion: null,
|
|
37
|
+
cliInstalled: null,
|
|
38
|
+
cliPackage: null,
|
|
37
39
|
drift: none,
|
|
38
40
|
};
|
|
39
41
|
const y = safe(() => parse(readFileSync(pin, 'utf8')) ?? {}, {});
|
|
@@ -43,6 +45,8 @@ function harnessStatus(root) {
|
|
|
43
45
|
tier: str(y['tier']) || null,
|
|
44
46
|
installedVersion: str(y['version']) || null,
|
|
45
47
|
packageVersion: safe(() => harnessVersion(packageHarness()), null),
|
|
48
|
+
cliInstalled: str(y['cli']) || null,
|
|
49
|
+
cliPackage: safe(() => packageVersion(), null),
|
|
46
50
|
drift: {
|
|
47
51
|
ok: findings.length === 0,
|
|
48
52
|
reasons: distinct(findings.map((f) => f.reason)),
|
|
@@ -76,6 +80,15 @@ export function nextForIntent(s) {
|
|
|
76
80
|
s.open === 0 &&
|
|
77
81
|
s.planned.some((t) => closed(t) && !recorded(t)))
|
|
78
82
|
return 'pl: create tickets';
|
|
83
|
+
const first = [...(s.openTickets ?? [])].sort((a, b) => a.id.localeCompare(b.id, 'en', { numeric: true }))[0];
|
|
84
|
+
if (s.open > 0 && first) {
|
|
85
|
+
if (first.status === 'done')
|
|
86
|
+
return `reins-review: close ${first.id}`;
|
|
87
|
+
if (first.status === 'blocked')
|
|
88
|
+
return `pl: unblock ${first.id}`;
|
|
89
|
+
if (first.status === 'todo' || first.status === 'doing')
|
|
90
|
+
return `implementer: ${first.id} (reins-implement)`;
|
|
91
|
+
}
|
|
79
92
|
if (s.broken.length > 0)
|
|
80
93
|
return `invalid frontmatter (F2): ${s.broken.join(', ')}`;
|
|
81
94
|
return '—';
|
|
@@ -113,6 +126,7 @@ function intentsStatus(root, tickets) {
|
|
|
113
126
|
plan: statusOf(plan),
|
|
114
127
|
open,
|
|
115
128
|
openIds: tickets.map(ticketId),
|
|
129
|
+
openTickets: mine.map((t) => ({ id: ticketId(t), status: str(t.data['status']) || null })),
|
|
116
130
|
planned,
|
|
117
131
|
history,
|
|
118
132
|
broken: [i, spec, plan].filter((f) => !!f?.error).map((f) => f.path),
|
|
@@ -208,7 +222,7 @@ export function formatStatus(d) {
|
|
|
208
222
|
if (!h.installed)
|
|
209
223
|
out.push('harness: not installed — run reins install');
|
|
210
224
|
else
|
|
211
|
-
out.push(`harness: ${h.tier ?? '?'}
|
|
225
|
+
out.push(`harness: ${h.tier ?? '?'} v${h.installedVersion ?? '?'} (package harness v${h.packageVersion ?? '?'}) · cli ${h.cliInstalled ?? 'none'} (running ${h.cliPackage ?? '?'}) · drift: ${h.drift.ok ? 'ok' : h.drift.reasons.join(', ')}${h.drift.ok ? '' : ' (reins check --drift)'}`);
|
|
212
226
|
out.push('');
|
|
213
227
|
out.push('intents:');
|
|
214
228
|
if (d.intents.length === 0)
|
|
@@ -4,7 +4,7 @@ import { parse } from 'yaml';
|
|
|
4
4
|
import { defaultsAsker } from '../lib/ask.js';
|
|
5
5
|
import { overrides } from '../lib/blocks.js';
|
|
6
6
|
import { repoRoot } from '../lib/git.js';
|
|
7
|
-
import { harnessVersion, packageHarness } from '../lib/upstream.js';
|
|
7
|
+
import { harnessVersion, packageHarness, packageVersion } from '../lib/upstream.js';
|
|
8
8
|
import { runInstall } from './install.js';
|
|
9
9
|
/** Numeric dotted-version compare; pre-release suffixes are ignored. */
|
|
10
10
|
export function newer(a, b) {
|
|
@@ -48,6 +48,8 @@ export async function runUpdate(o) {
|
|
|
48
48
|
const up = packageHarness();
|
|
49
49
|
res.from = pin.version;
|
|
50
50
|
res.to = harnessVersion(up);
|
|
51
|
+
res.cliFrom = pin.cli ? String(pin.cli) : 'none';
|
|
52
|
+
res.cliTo = packageVersion();
|
|
51
53
|
const cl = join(up, 'CHANGELOG.md');
|
|
52
54
|
if (existsSync(cl) && newer(res.to, res.from)) {
|
|
53
55
|
res.changes = changesBetween(readFileSync(cl, 'utf8'), res.from, res.to);
|
|
@@ -65,6 +67,7 @@ export async function runUpdate(o) {
|
|
|
65
67
|
now: o.now,
|
|
66
68
|
detectVendors: o.detectVendors,
|
|
67
69
|
recordAs: 'update',
|
|
70
|
+
retire: true,
|
|
68
71
|
});
|
|
69
72
|
return res;
|
|
70
73
|
}
|
package/cli/dist/lib/detect.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
3
|
+
import { compound } from '../commands/gate.js';
|
|
3
4
|
import { join } from 'node:path';
|
|
4
5
|
export function generation(root) {
|
|
5
6
|
const agents = join(root, 'AGENTS.md');
|
|
@@ -66,7 +67,7 @@ const MUTATING = /--fix\b|--write\b|\bfmt\b(?!:check)|(^|\s)format(\s|$)/;
|
|
|
66
67
|
* prefer the aggregate `check` the hooks and CI already call.
|
|
67
68
|
*/
|
|
68
69
|
export function discoverGates(root) {
|
|
69
|
-
const res = { gates: [], excluded: [] };
|
|
70
|
+
const res = { gates: [], excluded: [], proposals: subdirProposals(root) };
|
|
70
71
|
const run = runner(root);
|
|
71
72
|
const pkgPath = join(root, 'package.json');
|
|
72
73
|
if (run && run !== 'make' && existsSync(pkgPath)) {
|
|
@@ -103,6 +104,118 @@ export function discoverGates(root) {
|
|
|
103
104
|
}
|
|
104
105
|
return res;
|
|
105
106
|
}
|
|
107
|
+
const SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'build', 'vendor', '.loctx', '.agents']);
|
|
108
|
+
const MAX_DEPTH = 3;
|
|
109
|
+
const SAFE_DIR = /^[\w@.+-]+(\/[\w@.+-]+)*$/;
|
|
110
|
+
const ROOT_GATE_NAMES = ['check', 'test', 'build', 'e2e'];
|
|
111
|
+
const NODE_SCRIPTS = ['check', 'verify', 'ci', 'typecheck', 'lint', 'test', 'build'];
|
|
112
|
+
function dirRunner(root, dir, rootRunner) {
|
|
113
|
+
if (existsSync(join(root, dir, 'pnpm-lock.yaml')))
|
|
114
|
+
return 'pnpm';
|
|
115
|
+
if (existsSync(join(root, dir, 'yarn.lock')))
|
|
116
|
+
return 'yarn';
|
|
117
|
+
if (existsSync(join(root, dir, 'package-lock.json')))
|
|
118
|
+
return 'npm';
|
|
119
|
+
return rootRunner === 'pnpm' || rootRunner === 'yarn' ? rootRunner : 'npm';
|
|
120
|
+
}
|
|
121
|
+
const SOURCE_ORDER = ['npm', 'make', 'go'];
|
|
122
|
+
/**
|
|
123
|
+
* Gate candidates below the root (spec S-5): package.json scripts, Makefile targets and go.mod,
|
|
124
|
+
* to depth 3. One command each, using the tool's own directory option. The caller chooses.
|
|
125
|
+
*/
|
|
126
|
+
export function subdirProposals(root) {
|
|
127
|
+
const cands = [];
|
|
128
|
+
const rootRunner = runner(root);
|
|
129
|
+
const walk = (dir, depth) => {
|
|
130
|
+
let entries;
|
|
131
|
+
try {
|
|
132
|
+
entries = readdirSync(join(root, dir), { withFileTypes: true });
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
for (const e of entries) {
|
|
138
|
+
if (!e.isDirectory() || SKIP_DIRS.has(e.name))
|
|
139
|
+
continue;
|
|
140
|
+
const rel = dir ? `${dir}/${e.name}` : e.name;
|
|
141
|
+
if (!SAFE_DIR.test(rel))
|
|
142
|
+
continue;
|
|
143
|
+
const pkg = join(root, rel, 'package.json');
|
|
144
|
+
if (existsSync(pkg)) {
|
|
145
|
+
let scripts = {};
|
|
146
|
+
try {
|
|
147
|
+
scripts =
|
|
148
|
+
JSON.parse(readFileSync(pkg, 'utf8'))
|
|
149
|
+
.scripts ?? {};
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// unreadable package.json: no proposals from it
|
|
153
|
+
}
|
|
154
|
+
const run = dirRunner(root, rel, rootRunner);
|
|
155
|
+
for (const sc of NODE_SCRIPTS)
|
|
156
|
+
if (sc in scripts && !MUTATING.test(scripts[sc] ?? '') && /^[\w:.-]+$/.test(sc)) {
|
|
157
|
+
const cmd = run === 'npm'
|
|
158
|
+
? `npm --prefix ${rel} run ${sc}`
|
|
159
|
+
: run === 'yarn'
|
|
160
|
+
? `yarn --cwd ${rel} ${sc}`
|
|
161
|
+
: `pnpm --dir ${rel} ${sc}`;
|
|
162
|
+
cands.push({
|
|
163
|
+
rel,
|
|
164
|
+
source: 'npm',
|
|
165
|
+
script: sc,
|
|
166
|
+
cmd,
|
|
167
|
+
from: `${rel}/package.json#scripts.${sc}`,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const mk = join(root, rel, 'Makefile');
|
|
172
|
+
if (existsSync(mk)) {
|
|
173
|
+
const text = readFileSync(mk, 'utf8');
|
|
174
|
+
for (const t of ['check', 'test', 'build'])
|
|
175
|
+
if (new RegExp(`^${t}:`, 'm').test(text))
|
|
176
|
+
cands.push({
|
|
177
|
+
rel,
|
|
178
|
+
source: 'make',
|
|
179
|
+
script: t,
|
|
180
|
+
cmd: `make -C ${rel} ${t}`,
|
|
181
|
+
from: `${rel}/Makefile:${t}`,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (existsSync(join(root, rel, 'go.mod')))
|
|
185
|
+
for (const t of ['test', 'vet'])
|
|
186
|
+
cands.push({
|
|
187
|
+
rel,
|
|
188
|
+
source: 'go',
|
|
189
|
+
script: t,
|
|
190
|
+
cmd: `go -C ${rel} ${t} ./...`,
|
|
191
|
+
from: `${rel}/go.mod`,
|
|
192
|
+
});
|
|
193
|
+
if (depth < MAX_DEPTH)
|
|
194
|
+
walk(rel, depth + 1);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
walk('', 1);
|
|
198
|
+
// Every candidate is kept. Names are settled in a fixed order (path, source, script): the first
|
|
199
|
+
// keeps `<dir-slug>-<script>`, a later one takes a source suffix, then -2, -3 … until free.
|
|
200
|
+
cands.sort((a, b) => (a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0) ||
|
|
201
|
+
SOURCE_ORDER.indexOf(a.source) - SOURCE_ORDER.indexOf(b.source) ||
|
|
202
|
+
(a.script < b.script ? -1 : a.script > b.script ? 1 : 0));
|
|
203
|
+
const taken = new Set(ROOT_GATE_NAMES);
|
|
204
|
+
const out = [];
|
|
205
|
+
for (const c of cands) {
|
|
206
|
+
if (compound(c.cmd))
|
|
207
|
+
continue;
|
|
208
|
+
const base = `${c.rel.replace(/\//g, '-')}-${c.script}`;
|
|
209
|
+
let name = base;
|
|
210
|
+
if (taken.has(name))
|
|
211
|
+
name = `${base}-${c.source}`;
|
|
212
|
+
for (let i = 2; taken.has(name); i++)
|
|
213
|
+
name = `${base}-${c.source}-${i}`;
|
|
214
|
+
taken.add(name);
|
|
215
|
+
out.push({ name, cmd: c.cmd, from: c.from });
|
|
216
|
+
}
|
|
217
|
+
return out;
|
|
218
|
+
}
|
|
106
219
|
/** Vendor of a model ID by prefix, in order: gpt, gemini, cursor-, else claude (spec S-2). */
|
|
107
220
|
export function vendorOf(model) {
|
|
108
221
|
if (model.startsWith('gpt'))
|
package/cli/dist/lib/fsx.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join, relative, sep } from 'node:path';
|
|
3
3
|
export function apply(root, writes, dryRun) {
|
|
4
|
-
const out = { created: [], changed: [], unchanged: [] };
|
|
4
|
+
const out = { created: [], changed: [], unchanged: [], removed: [] };
|
|
5
5
|
for (const w of writes) {
|
|
6
6
|
const abs = join(root, w.path);
|
|
7
7
|
const exists = existsSync(abs);
|