@bluenyang/reins 0.2.0 → 0.3.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 +50 -203
- package/cli/dist/commands/config-models.js +206 -127
- package/cli/dist/commands/config.js +104 -16
- package/cli/dist/commands/configure.js +166 -134
- package/cli/dist/commands/install.js +161 -217
- package/cli/dist/commands/migrate.js +23 -48
- package/cli/dist/commands/update.js +203 -30
- package/cli/dist/lib/agents-md.js +111 -0
- package/cli/dist/lib/bindings.js +227 -386
- package/cli/dist/lib/detect.js +7 -2
- package/cli/dist/lib/generate.js +56 -75
- package/cli/dist/lib/harness.js +0 -3
- package/cli/dist/lib/migrate-plan.js +3 -3
- package/cli/dist/lib/prompter.js +4 -4
- package/cli/dist/lib/reader.js +20 -0
- package/cli/dist/lib/upstream.js +0 -17
- package/cli/dist/lib/vendor-write.js +9 -56
- package/cli/dist/reins.js +59 -270
- package/docs/README.ko.md +31 -204
- package/harness/CHANGELOG.md +8 -3
- package/harness/VERSION +1 -1
- package/harness/models.yaml +8 -0
- package/harness/policy/common-red-lines.yaml +4 -4
- package/harness/roles/advisor.md +10 -14
- package/harness/roles/auditor.md +17 -0
- package/harness/roles/executor.md +32 -0
- package/harness/roles/implementer.md +23 -21
- package/harness/roles/pl.md +44 -21
- package/harness/roles/planner.md +17 -19
- package/harness/roles/pm.md +16 -21
- package/harness/schemas/bindings.schema.json +55 -0
- package/harness/schemas/install.schema.json +1 -2
- package/harness/schemas/intent.schema.json +1 -13
- package/harness/templates/agents-md-blocks.md +52 -17
- package/harness/templates/audit.md +25 -0
- package/harness/templates/history.md +14 -0
- package/harness/templates/intent.md +5 -0
- package/harness/templates/spec.md +4 -2
- package/package.json +1 -2
- package/skills/audit/SKILL.md +28 -0
- package/skills/implement/SKILL.md +30 -0
- package/skills/intent/SKILL.md +28 -0
- package/skills/merge/SKILL.md +26 -0
- package/skills/onboard/SKILL.md +31 -0
- package/skills/reins-setup/SKILL.md +16 -25
- package/skills/release/SKILL.md +26 -0
- package/skills/retro/SKILL.md +30 -0
- package/skills/review/SKILL.md +27 -0
- package/skills/roadmap/SKILL.md +29 -0
- package/skills/spec/SKILL.md +27 -0
- package/skills/test/SKILL.md +26 -0
- package/cli/dist/commands/check.js +0 -379
- package/cli/dist/commands/gate.js +0 -136
- package/cli/dist/commands/knowledge.js +0 -111
- package/cli/dist/commands/metrics.js +0 -138
- package/cli/dist/commands/new.js +0 -190
- package/cli/dist/commands/retro.js +0 -7
- package/cli/dist/commands/stages.js +0 -562
- package/cli/dist/commands/status.js +0 -281
- package/cli/dist/lib/enforcement.js +0 -125
- package/cli/dist/lib/memory.js +0 -96
- package/cli/dist/lib/metrics.js +0 -223
- package/cli/dist/lib/retro.js +0 -179
- package/cli/dist/lib/verdict.js +0 -15
- package/cli/dist/lib/work.js +0 -106
- package/cli/dist/scripts/enforcement.js +0 -24
- package/harness/policy/budget.yaml +0 -13
- package/harness/policy/enforcement.yaml +0 -98
- package/harness/policy/stops.yaml +0 -29
- package/harness/policy/transitions.yaml +0 -13
- package/harness/roles/code-review.md +0 -27
- package/harness/roles/deploy.md +0 -50
- package/harness/roles/docs.md +0 -19
- package/harness/roles/lookup.md +0 -22
- package/harness/roles/qa-design.md +0 -22
- package/harness/roles/qa-run.md +0 -19
- package/harness/roles/verify-tool.md +0 -21
- package/harness/schemas/bindings-local.schema.json +0 -21
- package/harness/schemas/bus-request.schema.json +0 -17
- package/harness/schemas/bus-response.schema.json +0 -14
- package/harness/schemas/enforcement.schema.json +0 -22
- package/harness/schemas/plan.schema.json +0 -10
- package/harness/schemas/ticket.schema.json +0 -15
- package/harness/templates/bus/request.yaml +0 -20
- package/harness/templates/bus/response.yaml +0 -10
- package/harness/templates/plan.md +0 -23
- package/harness/templates/ticket.md +0 -29
- package/skills/reins-implement/SKILL.md +0 -20
- package/skills/reins-intent/SKILL.md +0 -26
- package/skills/reins-loop/SKILL.md +0 -26
- package/skills/reins-loop/references/vendor-cli.md +0 -41
- package/skills/reins-release/SKILL.md +0 -18
- package/skills/reins-retro/SKILL.md +0 -20
- package/skills/reins-review/SKILL.md +0 -23
- package/skills/reins-roadmap/SKILL.md +0 -17
- package/skills/reins-spec/SKILL.md +0 -22
- package/skills/reins-test/SKILL.md +0 -18
package/cli/dist/reins.js
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readFileSync } from 'node:fs';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import { runCheck, STAGES } from './commands/check.js';
|
|
5
4
|
import { runInstall } from './commands/install.js';
|
|
6
5
|
import { runMigrate } from './commands/migrate.js';
|
|
7
|
-
import { acceptKnowledge, dismissKnowledge, proposeKnowledge } from './commands/knowledge.js';
|
|
8
|
-
import { formatRetro, runRetro } from './commands/retro.js';
|
|
9
|
-
import { runStatus } from './commands/status.js';
|
|
10
6
|
import { formatUpdate, runUpdate } from './commands/update.js';
|
|
11
7
|
import { configureBindings, configureGates } from './commands/configure.js';
|
|
12
|
-
import { runConfig } from './commands/config.js';
|
|
13
|
-
import { stateLabel } from './lib/bindings.js';
|
|
14
|
-
import { respondRefusal, runGates, writeResponse } from './commands/gate.js';
|
|
15
|
-
import { newIntent, newRequest, newTicket } from './commands/new.js';
|
|
16
|
-
import { collectMetrics, formatMetrics, logCheck, logGates, recordUsage, } from './commands/metrics.js';
|
|
17
|
-
import { repoRoot } from './lib/git.js';
|
|
8
|
+
import { formatBindings, runConfig } from './commands/config.js';
|
|
18
9
|
import { defaultsAsker, stdinAsker } from './lib/ask.js';
|
|
19
10
|
import { clackPrompter, isInteractive } from './lib/prompter.js';
|
|
20
|
-
import { EXIT } from './lib/verdict.js';
|
|
21
11
|
// the version npm installed — cli/dist/reins.js sits two levels below package.json
|
|
22
12
|
const VERSION = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version;
|
|
23
13
|
// every command: a reader that went away (`| head`) ends the run quietly with the exit code already set
|
|
@@ -28,36 +18,27 @@ process.stdout.on('error', (e) => {
|
|
|
28
18
|
});
|
|
29
19
|
const program = new Command()
|
|
30
20
|
.name('reins')
|
|
31
|
-
.description('agent harness — install, migrate, update;
|
|
21
|
+
.description('manages an agent harness — install, migrate, update, config; never called while a project works')
|
|
32
22
|
.version(VERSION)
|
|
33
23
|
.enablePositionalOptions();
|
|
34
|
-
const notYet = (name) => () => {
|
|
35
|
-
process.stderr.write(`reins ${name}: not implemented yet (see docs/design.md §11)\n`);
|
|
36
|
-
process.exit(2);
|
|
37
|
-
};
|
|
38
24
|
program
|
|
39
25
|
.command('install')
|
|
40
|
-
.description('install the harness
|
|
41
|
-
.argument('<tier>', 'harness | loop | graph')
|
|
26
|
+
.description('install the harness: settings, roles, stage skills, AGENTS.md blocks, hook proposals')
|
|
42
27
|
.option('--mode <mode>', 'manual (ask) | auto (detect and apply defaults)', 'manual')
|
|
43
|
-
.option('--hooks', 'add the
|
|
28
|
+
.option('--hooks', 'add the project gate commands to existing husky hooks (otherwise only proposed)')
|
|
44
29
|
.option('--dry-run', 'show what would be written')
|
|
45
30
|
.option('--json')
|
|
46
|
-
.action(async (
|
|
47
|
-
if (!['harness', 'loop', 'graph'].includes(tier)) {
|
|
48
|
-
process.stderr.write(`reins install: tier must be harness, loop or graph (got "${tier}")\n`);
|
|
49
|
-
process.exit(2);
|
|
50
|
-
}
|
|
31
|
+
.action(async (o) => {
|
|
51
32
|
// screens only on a terminal, in manual mode, without --json; otherwise the line-based questions
|
|
52
33
|
const screens = o.mode === 'manual' && !o.json && isInteractive();
|
|
53
34
|
const asker = o.mode === 'auto' || screens ? defaultsAsker : await stdinAsker();
|
|
54
35
|
const r = await runInstall({
|
|
55
|
-
tier: tier,
|
|
56
36
|
mode: o.mode,
|
|
57
37
|
hooks: o.hooks,
|
|
58
38
|
dryRun: o.dryRun,
|
|
59
39
|
asker,
|
|
60
40
|
prompter: screens ? await clackPrompter() : undefined,
|
|
41
|
+
confirmHooks: !o.json && !o.dryRun && isInteractive() ? await clackPrompter() : undefined,
|
|
61
42
|
});
|
|
62
43
|
asker.close();
|
|
63
44
|
if (o.json) {
|
|
@@ -74,7 +55,7 @@ program
|
|
|
74
55
|
}
|
|
75
56
|
const a = r.applied;
|
|
76
57
|
const verb = o.dryRun ? 'would write' : 'wrote';
|
|
77
|
-
process.stdout.write(`reins install
|
|
58
|
+
process.stdout.write(`reins install — generation before: ${r.generation}\n`);
|
|
78
59
|
process.stdout.write(`${verb}: ${a.created.length} new, ${a.changed.length} changed; ${a.unchanged.length} already up to date\n`);
|
|
79
60
|
for (const p of a.created)
|
|
80
61
|
process.stdout.write(` + ${p}\n`);
|
|
@@ -82,29 +63,21 @@ program
|
|
|
82
63
|
process.stdout.write(` ~ ${p}\n`);
|
|
83
64
|
for (const n of r.notes)
|
|
84
65
|
process.stdout.write(`• ${n}\n`);
|
|
85
|
-
if (r.history)
|
|
86
|
-
process.stdout.write(`recorded: ${r.history}\n`);
|
|
87
66
|
});
|
|
88
67
|
program
|
|
89
68
|
.command('migrate')
|
|
90
69
|
.description('move an existing harness or .ai/ workspace onto the reins layout')
|
|
91
|
-
.argument('<tier>', 'harness | loop | graph')
|
|
92
70
|
.option('--mode <mode>', 'manual | auto', 'manual')
|
|
93
71
|
.option('--legacy <where>', 'local (.loctx/_legacy/) | committed (.agents/legacy/)', 'local')
|
|
94
72
|
.option('--dry-run', 'show the moves without touching anything')
|
|
95
73
|
.option('--json')
|
|
96
|
-
.action(async (
|
|
74
|
+
.action(async (o) => {
|
|
97
75
|
if (!['local', 'committed'].includes(o.legacy)) {
|
|
98
76
|
process.stderr.write(`reins migrate: --legacy must be local or committed (got "${o.legacy}")\n`);
|
|
99
77
|
process.exit(2);
|
|
100
78
|
}
|
|
101
|
-
if (!['harness', 'loop', 'graph'].includes(tier)) {
|
|
102
|
-
process.stderr.write(`reins migrate: tier must be harness, loop or graph (got "${tier}")\n`);
|
|
103
|
-
process.exit(2);
|
|
104
|
-
}
|
|
105
79
|
const asker = o.mode === 'auto' || o.dryRun ? defaultsAsker : await stdinAsker();
|
|
106
80
|
const r = await runMigrate({
|
|
107
|
-
tier: tier,
|
|
108
81
|
mode: o.mode,
|
|
109
82
|
dryRun: o.dryRun,
|
|
110
83
|
legacy: o.legacy,
|
|
@@ -120,36 +93,36 @@ program
|
|
|
120
93
|
process.exit(2);
|
|
121
94
|
}
|
|
122
95
|
const by = (k) => r.moves.filter((m) => m.result === k).length;
|
|
123
|
-
process.stdout.write(`reins migrate
|
|
96
|
+
process.stdout.write(`reins migrate — from ${r.generation}${o.dryRun ? ' (dry run)' : ''}\n`);
|
|
124
97
|
process.stdout.write(o.dryRun
|
|
125
98
|
? `would move ${r.moves.length} files\n`
|
|
126
|
-
: `moved ${by('moved')} ·
|
|
99
|
+
: `moved ${by('moved')} · converted ${by('converted')} · identical ${by('same')} · kept both ${by('kept-both')}\n`);
|
|
127
100
|
if (o.dryRun)
|
|
128
101
|
for (const m of r.moves)
|
|
129
102
|
process.stdout.write(` ${m.action === 'move' ? ' ' : m.action[0]} ${m.from} → ${m.to}\n`);
|
|
130
|
-
process.stdout.write(`AGENTS.md: swapped ${r.agents.swapped.join(', ') || 'none'}; inserted ${r.agents.inserted.join(', ') || 'none'}\n`);
|
|
131
103
|
for (const n of r.report)
|
|
132
104
|
process.stdout.write(`• ${n}\n`);
|
|
133
|
-
if (r.history)
|
|
134
|
-
process.stdout.write(`recorded: ${r.history}\n`);
|
|
135
105
|
});
|
|
136
106
|
program
|
|
137
107
|
.command('update')
|
|
138
|
-
.description('re-apply the packaged harness
|
|
108
|
+
.description('re-apply the packaged harness; ask before overwriting hand-edited files; move 0.x installs to 0.3')
|
|
139
109
|
.option('--dry-run', 'show what would change')
|
|
140
|
-
.option('--yes', 'do not ask for confirmation')
|
|
110
|
+
.option('--yes', 'do not ask for confirmation (also deletes the listed 0.x working files)')
|
|
111
|
+
.option('--force', 'overwrite generated files edited by hand')
|
|
141
112
|
.option('--json')
|
|
142
113
|
.action(async (o) => {
|
|
143
114
|
// on a terminal, show the plan and ask first (design §9); otherwise run as before
|
|
144
115
|
const confirm = !o.yes && !o.dryRun && !o.json && isInteractive();
|
|
145
116
|
const r = await runUpdate({
|
|
146
117
|
dryRun: o.dryRun,
|
|
118
|
+
force: o.force,
|
|
119
|
+
yes: o.yes,
|
|
147
120
|
prompter: confirm ? await clackPrompter() : undefined,
|
|
148
121
|
show: (plan) => process.stdout.write(formatUpdate(plan, true)),
|
|
149
122
|
});
|
|
150
123
|
if (o.json) {
|
|
151
124
|
process.stdout.write(`${JSON.stringify(r, null, 2)}\n`);
|
|
152
|
-
process.exit(r.refused ? 2 : 0);
|
|
125
|
+
process.exit(r.refused ? 2 : r.handEdited.length && !o.dryRun ? 1 : 0);
|
|
153
126
|
}
|
|
154
127
|
if (r.refused) {
|
|
155
128
|
process.stderr.write(`reins update: ${r.refused}\n`);
|
|
@@ -160,55 +133,66 @@ program
|
|
|
160
133
|
process.exit(0);
|
|
161
134
|
}
|
|
162
135
|
process.stdout.write(formatUpdate(r, !!o.dryRun));
|
|
136
|
+
if (r.handEdited.length && !o.dryRun)
|
|
137
|
+
process.exit(1);
|
|
163
138
|
});
|
|
164
|
-
program
|
|
139
|
+
const config = program
|
|
165
140
|
.command('config')
|
|
166
|
-
.
|
|
167
|
-
.
|
|
141
|
+
.alias('configure')
|
|
142
|
+
.description('settings: models and roles, agent tools, mode, audit; a screen on a terminal');
|
|
143
|
+
config
|
|
144
|
+
.command('screen', { isDefault: true, hidden: true })
|
|
145
|
+
.option('--json', 'print the effective settings as JSON (no screen)')
|
|
168
146
|
.action(async (o) => {
|
|
169
147
|
process.exit(await runConfig({ json: o.json }));
|
|
170
148
|
});
|
|
171
|
-
|
|
172
|
-
configure
|
|
149
|
+
config
|
|
173
150
|
.command('bindings')
|
|
174
|
-
.description('
|
|
175
|
-
.option('--set <pairs...>', 'role
|
|
176
|
-
.option('--
|
|
177
|
-
.option('--
|
|
178
|
-
.option('--
|
|
179
|
-
.option('--
|
|
180
|
-
.option('--
|
|
151
|
+
.description('change the model assignment without a screen')
|
|
152
|
+
.option('--set <pairs...>', 'default|<group>|<group>.<role>=<model> or =<vendor>:<model>')
|
|
153
|
+
.option('--models <pairs...>', '<pl|advisor>=<model>,<model>,… (several models)')
|
|
154
|
+
.option('--off <groups...>', 'switch groups off (the PM does their work)')
|
|
155
|
+
.option('--mode <mode>', 'single | multi')
|
|
156
|
+
.option('--audit <state>', 'on | off — the per-version audit')
|
|
157
|
+
.option('--tools <pairs...>', '<tool>=on|off')
|
|
158
|
+
.option('--detect', 'detect the agent tools again')
|
|
159
|
+
.option('--local', 'write your own override to .loctx/bindings.local.yaml')
|
|
160
|
+
.option('--show', 'print the effective settings')
|
|
181
161
|
.option('--json')
|
|
182
162
|
.action(async (o) => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
163
|
+
if (o.mode && o.mode !== 'single' && o.mode !== 'multi') {
|
|
164
|
+
process.stderr.write(`reins config bindings: --mode must be single or multi\n`);
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
if (o.audit && o.audit !== 'on' && o.audit !== 'off') {
|
|
168
|
+
process.stderr.write(`reins config bindings: --audit must be on or off\n`);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
}
|
|
186
171
|
const r = await configureBindings({
|
|
172
|
+
set: o.set,
|
|
173
|
+
models: o.models,
|
|
174
|
+
off: o.off,
|
|
175
|
+
mode: o.mode,
|
|
176
|
+
audit: o.audit,
|
|
177
|
+
tools: o.tools,
|
|
178
|
+
detect: o.detect,
|
|
187
179
|
local: o.local,
|
|
188
180
|
show: o.show,
|
|
189
|
-
set: o.set,
|
|
190
|
-
disable: o.disable,
|
|
191
|
-
enable: o.enable,
|
|
192
|
-
vendors: o.vendors?.split(',').map((s) => s.trim()),
|
|
193
|
-
asker,
|
|
194
181
|
});
|
|
195
|
-
asker?.close();
|
|
196
182
|
if (o.json) {
|
|
197
183
|
process.stdout.write(`${JSON.stringify(r, null, 2)}\n`);
|
|
198
184
|
process.exit(r.refused ? (r.code ?? 2) : 0);
|
|
199
185
|
}
|
|
200
186
|
if (r.refused) {
|
|
201
|
-
process.stderr.write(`reins
|
|
187
|
+
process.stderr.write(`reins config bindings: ${r.refused}\n`);
|
|
202
188
|
process.exit(r.code ?? 2);
|
|
203
189
|
}
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
process.stdout.write(` ${r.changed.includes(t.role) ? '*' : ' '} ${t.role.padEnd(12)} ${t.vendor.padEnd(7)} ${t.model}\n`);
|
|
211
|
-
process.stdout.write(r.changed.length ? `changed: ${r.changed.join(', ')}\n` : 'no change\n');
|
|
190
|
+
if (r.doc)
|
|
191
|
+
process.stdout.write(`${formatBindings(r.doc)}\n`);
|
|
192
|
+
if (!o.show)
|
|
193
|
+
process.stdout.write(r.changed.length ? `changed: ${r.changed.join(', ')}\n` : 'no change\n');
|
|
194
|
+
if (r.modeChanged)
|
|
195
|
+
process.stdout.write('• AGENTS.md has a mode-changed note — the PM checks the project sections in the next conversation\n');
|
|
212
196
|
const g = r.generated;
|
|
213
197
|
if (g) {
|
|
214
198
|
for (const p of g.written)
|
|
@@ -219,7 +203,7 @@ configure
|
|
|
219
203
|
process.stdout.write(`• left alone ${x.path}: ${x.why}\n`);
|
|
220
204
|
}
|
|
221
205
|
});
|
|
222
|
-
|
|
206
|
+
config
|
|
223
207
|
.command('gates')
|
|
224
208
|
.description('subdirectory gate proposals not in gates.yaml; --add <name>… appends them')
|
|
225
209
|
.option('--add <names...>', 'proposal names to append after the existing gates')
|
|
@@ -231,7 +215,7 @@ configure
|
|
|
231
215
|
process.exit(r.code ?? 0);
|
|
232
216
|
}
|
|
233
217
|
if (r.refused) {
|
|
234
|
-
process.stderr.write(`reins
|
|
218
|
+
process.stderr.write(`reins config gates: ${r.refused}\n`);
|
|
235
219
|
process.exit(r.code ?? 2);
|
|
236
220
|
}
|
|
237
221
|
for (const n of r.added)
|
|
@@ -241,199 +225,4 @@ configure
|
|
|
241
225
|
for (const g of r.available)
|
|
242
226
|
process.stdout.write(` ${g.name} ${g.cmd} (${g.from})\n`);
|
|
243
227
|
});
|
|
244
|
-
program
|
|
245
|
-
.command('gate')
|
|
246
|
-
.description('run gates.yaml gates as declared; raw output goes to .loctx/reports/ as T3 evidence')
|
|
247
|
-
.argument('[names...]', 'gates to run (default: the declared order)')
|
|
248
|
-
.option('--ticket <id>', 'name the reports after this ticket')
|
|
249
|
-
.option('--all', 'keep going after a failure')
|
|
250
|
-
.option('--respond', 'with --ticket: write the bus response for the open verify request (one line per gate on stdout)')
|
|
251
|
-
.option('--json')
|
|
252
|
-
.action((names, o) => {
|
|
253
|
-
const refusal = o.respond ? respondRefusal(names) : null;
|
|
254
|
-
if (refusal) {
|
|
255
|
-
process.stderr.write(`reins gate: ${refusal}\n`);
|
|
256
|
-
process.exit(2);
|
|
257
|
-
}
|
|
258
|
-
if (o.respond && !o.ticket) {
|
|
259
|
-
process.stderr.write('reins gate: --respond needs --ticket <id>\n');
|
|
260
|
-
process.exit(2);
|
|
261
|
-
}
|
|
262
|
-
const r = runGates({ names, ticket: o.ticket, all: o.all });
|
|
263
|
-
logGates(r.runs, { ticket: o.ticket });
|
|
264
|
-
const resp = o.respond && o.ticket && !r.refused
|
|
265
|
-
? writeResponse(repoRoot(process.cwd()), o.ticket, r.runs)
|
|
266
|
-
: null;
|
|
267
|
-
if (o.json)
|
|
268
|
-
process.stdout.write(`${JSON.stringify(resp ? { ...r, respond: resp } : r, null, 2)}\n`);
|
|
269
|
-
else if (r.refused)
|
|
270
|
-
process.stderr.write(`reins gate: ${r.refused}\n`);
|
|
271
|
-
else
|
|
272
|
-
for (const g of r.runs)
|
|
273
|
-
process.stdout.write(` ${g.skipped ? '-' : g.exit === 0 ? 'ok' : 'FAIL'} ${g.gate.padEnd(10)} ${g.skipped ?? `exit ${g.exit} → ${g.report}`}\n`);
|
|
274
|
-
if (resp && !o.json) {
|
|
275
|
-
for (const [gate, s] of Object.entries(resp.summaries))
|
|
276
|
-
process.stdout.write(` ! ${gate}: ${s}\n`);
|
|
277
|
-
if (resp.response)
|
|
278
|
-
process.stdout.write(`response: ${resp.response} (${resp.verdict})\n`);
|
|
279
|
-
else
|
|
280
|
-
process.stderr.write(`reins gate: no response written — ${resp.refused}\n`);
|
|
281
|
-
}
|
|
282
|
-
process.exit(r.refused ? 2 : resp?.refused ? 1 : r.runs.every((g) => g.exit === 0) ? 0 : 1);
|
|
283
|
-
});
|
|
284
|
-
const done = (r) => {
|
|
285
|
-
process.stdout.write(r.stdout);
|
|
286
|
-
process.stderr.write(r.stderr);
|
|
287
|
-
process.exit(r.code);
|
|
288
|
-
};
|
|
289
|
-
const nw = program
|
|
290
|
-
.command('new')
|
|
291
|
-
.description('create an intent, ticket or bus request from the templates (no prompts, never overwrites)');
|
|
292
|
-
nw.command('intent')
|
|
293
|
-
.argument('<slug>')
|
|
294
|
-
.option('--version <v>', 'target version')
|
|
295
|
-
.option('--origin <o>', 'user | agent | incident')
|
|
296
|
-
.action((slug, o) => done(newIntent(process.cwd(), slug, o)));
|
|
297
|
-
nw.command('ticket')
|
|
298
|
-
.argument('<intent>')
|
|
299
|
-
.argument('<step>', "the plan's order-of-work step")
|
|
300
|
-
.argument('<slug>')
|
|
301
|
-
.option('--title <t>')
|
|
302
|
-
.option('--depends <ids>', 'comma separated ticket ids')
|
|
303
|
-
.option('--role <r>')
|
|
304
|
-
.option('--release <r>', 'planned | stabilization')
|
|
305
|
-
.action((intent, step, slug, o) => done(newTicket(process.cwd(), intent, step, slug, o)));
|
|
306
|
-
nw.command('request')
|
|
307
|
-
.argument('<ticket>')
|
|
308
|
-
.argument('<kind>', 'implement | verify | review | question | stop-report')
|
|
309
|
-
.option('--from <r>')
|
|
310
|
-
.option('--to <r>')
|
|
311
|
-
.action((ticket, kind, o) => done(newRequest(process.cwd(), ticket, kind, o)));
|
|
312
|
-
program
|
|
313
|
-
.command('status')
|
|
314
|
-
.description('where the project stands: harness, intents, tickets, bus, last history (read-only)')
|
|
315
|
-
.option('--json')
|
|
316
|
-
.action((o) => {
|
|
317
|
-
const r = runStatus({ json: o.json });
|
|
318
|
-
process.stdout.write(r.stdout);
|
|
319
|
-
process.stderr.write(r.stderr);
|
|
320
|
-
process.exit(r.code);
|
|
321
|
-
});
|
|
322
|
-
const metrics = program
|
|
323
|
-
.command('metrics')
|
|
324
|
-
.enablePositionalOptions()
|
|
325
|
-
.description('what the loop cost and where it stopped: counts, tokens by role and vendor, per ticket and intent')
|
|
326
|
-
.option('--intent <NNN>', 'only this intent')
|
|
327
|
-
.option('--json')
|
|
328
|
-
.action((o) => {
|
|
329
|
-
const m = collectMetrics({ intent: o.intent });
|
|
330
|
-
process.stdout.write(o.json ? `${JSON.stringify(m, null, 2)}\n` : formatMetrics(m));
|
|
331
|
-
});
|
|
332
|
-
metrics
|
|
333
|
-
.command('record')
|
|
334
|
-
.description('append a usage line: tokens a role run used (the caller reports; reins calls no model)')
|
|
335
|
-
.requiredOption('--role <role>', 'a role in bindings.yaml')
|
|
336
|
-
.requiredOption('--tokens <n>', 'whole number ≥ 0')
|
|
337
|
-
.option('--ticket <id>', 'the ticket the run served (fills the intent)')
|
|
338
|
-
.option('--intent <NNN>', 'the intent, when there is no ticket')
|
|
339
|
-
.option('--vendor <v>', 'default: the binding of --role')
|
|
340
|
-
.option('--model <m>', 'default: the binding of --role')
|
|
341
|
-
.option('--note <text>')
|
|
342
|
-
.option('--json')
|
|
343
|
-
.action((o) => {
|
|
344
|
-
const r = recordUsage(o);
|
|
345
|
-
if (r.refused) {
|
|
346
|
-
process.stderr.write(`reins metrics record: ${r.refused}\n`);
|
|
347
|
-
process.exit(2);
|
|
348
|
-
}
|
|
349
|
-
const u = r.record;
|
|
350
|
-
process.stdout.write(o.json
|
|
351
|
-
? `${JSON.stringify(u, null, 2)}\n`
|
|
352
|
-
: `recorded: ${u.role} (${u.vendor}/${u.model}) ${u.tokens} tokens${u.ticket ? ` · ticket ${u.ticket}` : ''}${u.intent ? ` · intent ${u.intent}` : ''}\n`);
|
|
353
|
-
});
|
|
354
|
-
program
|
|
355
|
-
.command('retro')
|
|
356
|
-
.description('what repeated: stop ids, review reasons, decisions, failed rounds, tokens; knowledge candidates')
|
|
357
|
-
.option('--release <v>', 'only the intents whose version is v')
|
|
358
|
-
.option('--json')
|
|
359
|
-
.action((o) => {
|
|
360
|
-
const r = runRetro({ release: o.release });
|
|
361
|
-
process.stdout.write(o.json ? `${JSON.stringify(r, null, 2)}\n` : formatRetro(r));
|
|
362
|
-
});
|
|
363
|
-
const knowledge = program
|
|
364
|
-
.command('knowledge')
|
|
365
|
-
.description('promote a repeated key to a knowledge entry');
|
|
366
|
-
const knowledgeDone = (verb, r) => {
|
|
367
|
-
if (r.refused) {
|
|
368
|
-
process.stderr.write(`reins knowledge ${verb}: ${r.refused}\n`);
|
|
369
|
-
process.exit(1);
|
|
370
|
-
}
|
|
371
|
-
process.stdout.write(`${r.path}\n`);
|
|
372
|
-
};
|
|
373
|
-
knowledge
|
|
374
|
-
.command('propose')
|
|
375
|
-
.description('write a draft to .loctx/knowledge-proposals/ (records no approval)')
|
|
376
|
-
.argument('<key>', 'a retro key (decision:<slug>) or a slug')
|
|
377
|
-
.option('--from <history...>', 'history pages that back it')
|
|
378
|
-
.action((key, o) => knowledgeDone('propose', proposeKnowledge(key, o)));
|
|
379
|
-
knowledge
|
|
380
|
-
.command('accept')
|
|
381
|
-
.description('after the user approves: write .agents/knowledge/<date>_<slug>.md with approved')
|
|
382
|
-
.argument('<draft>', 'the draft slug')
|
|
383
|
-
.action((draft) => knowledgeDone('accept', acceptKnowledge(draft)));
|
|
384
|
-
knowledge
|
|
385
|
-
.command('dismiss')
|
|
386
|
-
.description('record that a candidate is not a lesson; it returns when it repeats further')
|
|
387
|
-
.argument('<key>', 'a candidate key as reins retro prints it')
|
|
388
|
-
.requiredOption('--reason <text>', 'why it is not a lesson')
|
|
389
|
-
.action((key, o) => knowledgeDone('dismiss', dismissKnowledge(key, o)));
|
|
390
|
-
for (const n of ['recall', 'doctor'])
|
|
391
|
-
program.command(n).allowUnknownOption().allowExcessArguments().action(notYet(n));
|
|
392
|
-
program
|
|
393
|
-
.command('check')
|
|
394
|
-
.description(`harness verifier: --stage ${STAGES.join('|')}, or --drift`)
|
|
395
|
-
.option('--stage <stage>', 'T1 ticket-start · T2 pre-commit · T3 verdict · T4 pre-push · T5 rc-close')
|
|
396
|
-
.option('--ticket <id>', 'ticket-start, verdict: the ticket id')
|
|
397
|
-
.option('--release <version>', 'rc-close: the version the rc closes')
|
|
398
|
-
.option('--stable', "rc-close: print the stable dispatch lines (the user's instruction only)")
|
|
399
|
-
.option('--drift')
|
|
400
|
-
.option('--json')
|
|
401
|
-
.action(async (o) => {
|
|
402
|
-
if (o.stage && !STAGES.includes(o.stage)) {
|
|
403
|
-
process.stderr.write(`reins check: unknown stage "${o.stage}" (${STAGES.join(', ')})\n`);
|
|
404
|
-
process.exit(2);
|
|
405
|
-
}
|
|
406
|
-
const stage = o.stage;
|
|
407
|
-
let pushRefs = [];
|
|
408
|
-
if (stage === 'pre-push' && !process.stdin.isTTY) {
|
|
409
|
-
const chunks = [];
|
|
410
|
-
for await (const c of process.stdin)
|
|
411
|
-
chunks.push(c);
|
|
412
|
-
pushRefs = Buffer.concat(chunks).toString('utf8').split('\n').filter(Boolean);
|
|
413
|
-
}
|
|
414
|
-
const r = runCheck({
|
|
415
|
-
stage,
|
|
416
|
-
drift: o.drift,
|
|
417
|
-
pushRefs,
|
|
418
|
-
ticket: o.ticket,
|
|
419
|
-
release: o.release,
|
|
420
|
-
stable: o.stable,
|
|
421
|
-
});
|
|
422
|
-
// S-8: the verdict code is set before anything is printed, so a closed pipe cannot change it
|
|
423
|
-
process.exitCode = EXIT[r.verdict];
|
|
424
|
-
process.stdout.on('error', (e) => {
|
|
425
|
-
if (e.code === 'EPIPE')
|
|
426
|
-
process.exit(process.exitCode ?? 0);
|
|
427
|
-
throw e;
|
|
428
|
-
});
|
|
429
|
-
logCheck(r, { ticket: o.ticket });
|
|
430
|
-
if (o.json)
|
|
431
|
-
process.stdout.write(`${JSON.stringify(r, null, 2)}\n`);
|
|
432
|
-
else {
|
|
433
|
-
process.stdout.write(`${r.summary}\n`);
|
|
434
|
-
for (const f of r.findings)
|
|
435
|
-
process.stdout.write(` [${f.reason} ${f.verdict}] ${f.path ? `${f.path}: ` : ''}${f.message}${f.resume ? `\n → ${f.resume}` : ''}\n`);
|
|
436
|
-
}
|
|
437
|
-
process.exit(EXIT[r.verdict]);
|
|
438
|
-
});
|
|
439
228
|
program.parseAsync(process.argv);
|