@bluenyang/reins 0.2.0 → 0.3.0-rc.1
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 +175 -126
- package/cli/dist/commands/config.js +96 -15
- package/cli/dist/commands/configure.js +165 -138
- 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 +102 -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/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 +7 -3
- package/harness/VERSION +1 -1
- 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 +29 -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
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
1
|
import { CONFIRMED_MODELS, listModels, vendorOf, } from '../lib/detect.js';
|
|
4
|
-
import {
|
|
2
|
+
import { GROUP_ROLES, GROUPS, effectiveBindings, readLocalBindings, readTeam, } from '../lib/bindings.js';
|
|
5
3
|
import { BACK, EXIT } from '../lib/prompter.js';
|
|
6
|
-
import { splitFrontmatter } from '../lib/skills.js';
|
|
7
4
|
import { configureBindings } from './configure.js';
|
|
8
5
|
const LISTER_CLI = { google: 'agy', cursor: 'cursor-agent' };
|
|
9
|
-
/**
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
/** When switching a group on pays for itself (design §9; Anthropic 2026-10-22). */
|
|
7
|
+
export const WHEN_TO_SWITCH_ON = 'switch a group on when the PM context degrades, independent work can run in parallel, or review/audit should run on another model';
|
|
8
|
+
const show = (b) => (b ? `${b.vendor} ${b.model}` : 'off (PM)');
|
|
9
|
+
/** One line per group: `pl claude claude-sonnet-5-5, openai gpt-6.1-terra +1 role`. */
|
|
10
|
+
export function groupLine(group, spec) {
|
|
11
|
+
if (!spec)
|
|
12
|
+
return `${group.padEnd(12)} off — the PM does it`;
|
|
13
|
+
const models = spec.models?.length
|
|
14
|
+
? spec.models.map(show).join(', ')
|
|
15
|
+
: spec.vendor && spec.model
|
|
16
|
+
? show({ vendor: spec.vendor, model: spec.model })
|
|
17
|
+
: '—';
|
|
18
|
+
const n = Object.keys(spec.roles ?? {}).length;
|
|
19
|
+
return `${group.padEnd(12)} ${models}${n ? ` +${n} role${n > 1 ? 's' : ''}` : ''}`;
|
|
14
20
|
}
|
|
15
|
-
/** Models of `vendor` already known
|
|
16
|
-
export function knownModels(
|
|
17
|
-
const out = [];
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
/** Models of `vendor` already known here: confirmed ones and those in the current files. */
|
|
22
|
+
export function knownModels(vendor, current) {
|
|
23
|
+
const out = [...CONFIRMED_MODELS];
|
|
24
|
+
for (const d of current) {
|
|
25
|
+
if (d.default)
|
|
26
|
+
out.push(d.default.model);
|
|
27
|
+
for (const g of Object.values(d.groups ?? {})) {
|
|
28
|
+
if (!g)
|
|
29
|
+
continue;
|
|
30
|
+
if (g.model)
|
|
31
|
+
out.push(g.model);
|
|
32
|
+
for (const m of g.models ?? [])
|
|
33
|
+
out.push(m.model);
|
|
34
|
+
for (const r of Object.values(g.roles ?? {}))
|
|
35
|
+
out.push(r.model);
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
return [...new Set(out)].filter((m) => vendorOf(m) === vendor);
|
|
37
|
+
}
|
|
38
|
+
return [...new Set(out)].filter((m) => vendorOf(m) === vendor || !vendorOf(m));
|
|
30
39
|
}
|
|
31
40
|
/**
|
|
32
|
-
* The models
|
|
33
|
-
*
|
|
41
|
+
* The models-and-roles screen (design §9): scope, the PM's model, each group (off, one model, several for
|
|
42
|
+
* pl and advisor, per-role models). Every choice is written at once through `configureBindings`.
|
|
34
43
|
* Returns `exit` when the user left reins config, `back` for `< Configuration`.
|
|
35
44
|
*/
|
|
36
45
|
export async function modelsScreen(o) {
|
|
37
46
|
const { root, prompter } = o;
|
|
38
47
|
let scope = 'local';
|
|
39
48
|
const write = async (opts, label) => {
|
|
40
|
-
const r = await configureBindings({
|
|
41
|
-
cwd: root,
|
|
42
|
-
local: scope === 'local',
|
|
43
|
-
detectVendors: o.detectVendors,
|
|
44
|
-
modelCache: o.modelCache,
|
|
45
|
-
...opts,
|
|
46
|
-
});
|
|
49
|
+
const r = await configureBindings({ cwd: root, local: scope === 'local', ...opts });
|
|
47
50
|
if (r.refused)
|
|
48
51
|
prompter.note(`not changed: ${r.refused}`);
|
|
49
52
|
else if (r.changed.length === 0)
|
|
@@ -51,10 +54,15 @@ export async function modelsScreen(o) {
|
|
|
51
54
|
else if (scope === 'local')
|
|
52
55
|
prompter.note(`${label}: written to .loctx/bindings.local.yaml (this user only)`);
|
|
53
56
|
else
|
|
54
|
-
prompter.note(`${label}: written to .agents/harness/bindings.yaml,
|
|
57
|
+
prompter.note(`${label}: written to .agents/harness/bindings.yaml, generated files and AGENTS.md refreshed — commit them`);
|
|
55
58
|
};
|
|
56
59
|
for (;;) {
|
|
57
|
-
const
|
|
60
|
+
const doc = effectiveBindings(root);
|
|
61
|
+
if (!doc) {
|
|
62
|
+
prompter.note('no version-2 bindings.yaml here — run `reins install` or `reins update`');
|
|
63
|
+
return 'back';
|
|
64
|
+
}
|
|
65
|
+
prompter.note(WHEN_TO_SWITCH_ON);
|
|
58
66
|
const options = [
|
|
59
67
|
{ value: 'back', label: '< Configuration' },
|
|
60
68
|
{ value: 'exit', label: 'exit' },
|
|
@@ -62,16 +70,17 @@ export async function modelsScreen(o) {
|
|
|
62
70
|
value: 'scope',
|
|
63
71
|
label: `scope: ${scope === 'local' ? 'local | global' : 'global | local'}`,
|
|
64
72
|
},
|
|
65
|
-
{ value: '
|
|
66
|
-
...
|
|
73
|
+
{ value: 'default', label: `${'PM'.padEnd(12)} ${show(doc.default)}` },
|
|
74
|
+
...GROUPS.map((g) => ({ value: g, label: groupLine(g, doc.groups?.[g]) })),
|
|
67
75
|
];
|
|
68
|
-
const v = await prompter.select({
|
|
69
|
-
|
|
76
|
+
const v = await prompter.select({
|
|
77
|
+
message: `Models and roles (mode: ${doc.mode ?? 'single'})`,
|
|
78
|
+
options,
|
|
79
|
+
});
|
|
80
|
+
if (v === EXIT || v === 'exit')
|
|
70
81
|
return 'exit';
|
|
71
82
|
if (v === BACK || v === 'back')
|
|
72
83
|
return 'back';
|
|
73
|
-
if (v === 'exit')
|
|
74
|
-
return 'exit';
|
|
75
84
|
if (v === 'scope') {
|
|
76
85
|
const s = await prompter.select({
|
|
77
86
|
message: 'Write changes to',
|
|
@@ -87,107 +96,147 @@ export async function modelsScreen(o) {
|
|
|
87
96
|
scope = s;
|
|
88
97
|
continue;
|
|
89
98
|
}
|
|
90
|
-
if (v === '
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const on = await prompter.multiselect({
|
|
94
|
-
message: 'Roles that are on',
|
|
95
|
-
initial: names
|
|
96
|
-
.filter((b) => (scope === 'global' ? (teamEnabled(root)[b.role] ?? true) : b.enabled))
|
|
97
|
-
.map((b) => b.role),
|
|
98
|
-
options: names.map((b) => ({ value: b.role, label: b.role })),
|
|
99
|
-
});
|
|
100
|
-
if (on === EXIT)
|
|
99
|
+
if (v === 'default') {
|
|
100
|
+
const b = await pickModel(o, 'PM', doc.default);
|
|
101
|
+
if (b === EXIT)
|
|
101
102
|
return 'exit';
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
// the list and the diff use the chosen scope's own value: global = the team file, local = effective
|
|
105
|
-
const team = teamEnabled(root);
|
|
106
|
-
const isOn = (b) => scope === 'global' ? (team[b.role] ?? true) : b.enabled;
|
|
107
|
-
const enable = names.filter((b) => !isOn(b) && on.includes(b.role)).map((b) => b.role);
|
|
108
|
-
const disable = names.filter((b) => isOn(b) && !on.includes(b.role)).map((b) => b.role);
|
|
109
|
-
if (enable.length + disable.length > 0)
|
|
110
|
-
await write({ enable, disable }, `roles ${[...enable, ...disable].join(', ')}`);
|
|
103
|
+
if (b)
|
|
104
|
+
await write({ set: [`default=${b.vendor}:${b.model}`] }, `PM → ${show(b)}`);
|
|
111
105
|
continue;
|
|
112
106
|
}
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
115
|
-
continue;
|
|
116
|
-
const r = await roleScreen(o, row, scope);
|
|
117
|
-
if (r === EXIT)
|
|
107
|
+
const r = await groupScreen(o, v, doc.groups?.[v], write);
|
|
108
|
+
if (r === 'exit')
|
|
118
109
|
return 'exit';
|
|
119
|
-
if (r !== undefined)
|
|
120
|
-
await write({ set: [`${row.role}=${r}`] }, `${row.role} → ${r}`);
|
|
121
110
|
}
|
|
122
111
|
}
|
|
123
|
-
|
|
124
|
-
async function roleScreen(o, row, scope) {
|
|
112
|
+
async function groupScreen(o, group, spec, write) {
|
|
125
113
|
const { prompter } = o;
|
|
126
|
-
const
|
|
114
|
+
const many = group === 'pl' || group === 'advisor';
|
|
115
|
+
const roles = GROUP_ROLES[group];
|
|
116
|
+
const pick = await prompter.select({
|
|
117
|
+
message: `${group}: ${groupLine(group, spec).slice(12).trim()}`,
|
|
118
|
+
options: [
|
|
119
|
+
{ value: 'back', label: '< back' },
|
|
120
|
+
{ value: 'one', label: many ? 'one model' : 'set the model' },
|
|
121
|
+
...(many ? [{ value: 'many', label: 'several models', hint: 'first = control (pl)' }] : []),
|
|
122
|
+
...(roles.length ? [{ value: 'role', label: 'a model for one role' }] : []),
|
|
123
|
+
{ value: 'off', label: 'switch off', hint: 'the PM does it' },
|
|
124
|
+
],
|
|
125
|
+
});
|
|
126
|
+
if (pick === EXIT)
|
|
127
|
+
return 'exit';
|
|
128
|
+
if (pick === BACK || pick === 'back')
|
|
129
|
+
return 'back';
|
|
130
|
+
if (pick === 'off') {
|
|
131
|
+
await write({ off: [group] }, `${group} off`);
|
|
132
|
+
return 'back';
|
|
133
|
+
}
|
|
134
|
+
if (pick === 'one') {
|
|
135
|
+
const b = await pickModel(o, group, spec?.vendor && spec.model ? { vendor: spec.vendor, model: spec.model } : spec?.models?.[0]);
|
|
136
|
+
if (b === EXIT)
|
|
137
|
+
return 'exit';
|
|
138
|
+
if (b)
|
|
139
|
+
await write({ set: [`${group}=${b.vendor}:${b.model}`] }, `${group} → ${show(b)}`);
|
|
140
|
+
return 'back';
|
|
141
|
+
}
|
|
142
|
+
if (pick === 'many') {
|
|
143
|
+
const list = [];
|
|
144
|
+
for (;;) {
|
|
145
|
+
const b = await pickModel(o, `${group} #${list.length + 1}`, undefined);
|
|
146
|
+
if (b === EXIT)
|
|
147
|
+
return 'exit';
|
|
148
|
+
if (!b)
|
|
149
|
+
break;
|
|
150
|
+
list.push(b);
|
|
151
|
+
const more = await prompter.confirm({ message: 'Add another model?', initial: false });
|
|
152
|
+
if (more === EXIT)
|
|
153
|
+
return 'exit';
|
|
154
|
+
if (more !== true)
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (list.length)
|
|
158
|
+
await write({ models: [`${group}=${list.map((b) => `${b.vendor}:${b.model}`).join(',')}`] }, `${group} → ${list.map(show).join(', ')}`);
|
|
159
|
+
return 'back';
|
|
160
|
+
}
|
|
161
|
+
const role = await prompter.select({
|
|
162
|
+
message: `${group}: which role`,
|
|
163
|
+
options: [
|
|
164
|
+
{ value: 'back', label: '< back' },
|
|
165
|
+
...roles.map((r) => ({ value: r, label: r, hint: show(spec?.roles?.[r]) })),
|
|
166
|
+
],
|
|
167
|
+
});
|
|
168
|
+
if (role === EXIT)
|
|
169
|
+
return 'exit';
|
|
170
|
+
if (role === BACK || role === 'back')
|
|
171
|
+
return 'back';
|
|
172
|
+
const b = await pickModel(o, `${group}.${role}`, spec?.roles?.[role]);
|
|
173
|
+
if (b === EXIT)
|
|
174
|
+
return 'exit';
|
|
175
|
+
if (b)
|
|
176
|
+
await write({ set: [`${group}.${role}=${b.vendor}:${b.model}`] }, `${group}.${role} → ${show(b)}`);
|
|
177
|
+
return 'back';
|
|
178
|
+
}
|
|
179
|
+
/** Tool (used tools only), then model. Returns the binding, `undefined` for back, or EXIT. */
|
|
180
|
+
async function pickModel(o, label, current) {
|
|
181
|
+
const { prompter, root } = o;
|
|
182
|
+
const team = readTeam(root).doc;
|
|
183
|
+
const local = readLocalBindings(root);
|
|
184
|
+
const docs = [team, local].filter((d) => !!d);
|
|
185
|
+
const used = Object.entries(effectiveBindings(root)?.tools ?? { claude: { use: true } })
|
|
186
|
+
.filter(([, t]) => t?.use !== false)
|
|
187
|
+
.map(([n]) => n);
|
|
188
|
+
if (!used.includes('claude'))
|
|
189
|
+
used.unshift('claude');
|
|
127
190
|
for (;;) {
|
|
128
191
|
const vendor = await prompter.select({
|
|
129
|
-
message: `${
|
|
130
|
-
initial:
|
|
131
|
-
options: [
|
|
132
|
-
{ value: 'back', label: '< back' },
|
|
133
|
-
...detected.map((v) => ({ value: v.name, label: v.name })),
|
|
134
|
-
],
|
|
192
|
+
message: `${label}: tool`,
|
|
193
|
+
initial: current?.vendor,
|
|
194
|
+
options: [{ value: 'back', label: '< back' }, ...used.map((v) => ({ value: v, label: v }))],
|
|
135
195
|
});
|
|
136
196
|
if (vendor === EXIT)
|
|
137
197
|
return EXIT;
|
|
138
198
|
if (vendor === BACK || vendor === 'back')
|
|
139
199
|
return undefined;
|
|
140
|
-
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (vendor === 'google' || vendor === 'cursor') {
|
|
154
|
-
let res;
|
|
155
|
-
try {
|
|
156
|
-
res = listModels(vendor, o.modelCache.run);
|
|
200
|
+
let ids = knownModels(vendor, docs);
|
|
201
|
+
if (vendor === 'google' || vendor === 'cursor') {
|
|
202
|
+
let res;
|
|
203
|
+
try {
|
|
204
|
+
res = listModels(vendor, o.modelCache.run);
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
res = { failed: e.message };
|
|
208
|
+
}
|
|
209
|
+
if ('failed' in res)
|
|
210
|
+
prompter.note(`${LISTER_CLI[vendor]} models failed (${res.failed}) — showing known models`);
|
|
211
|
+
else
|
|
212
|
+
ids = res.ids;
|
|
157
213
|
}
|
|
158
|
-
|
|
159
|
-
|
|
214
|
+
for (;;) {
|
|
215
|
+
const pick = await prompter.select({
|
|
216
|
+
message: `${label}: ${vendor} model`,
|
|
217
|
+
initial: current?.model,
|
|
218
|
+
options: [
|
|
219
|
+
{ value: 'back', label: '< back' },
|
|
220
|
+
...ids.map((m) => ({
|
|
221
|
+
value: m,
|
|
222
|
+
label: m,
|
|
223
|
+
...(m === current?.model ? { hint: 'current' } : {}),
|
|
224
|
+
})),
|
|
225
|
+
{ value: 'other', label: 'other (type a model ID)' },
|
|
226
|
+
],
|
|
227
|
+
});
|
|
228
|
+
if (pick === EXIT)
|
|
229
|
+
return EXIT;
|
|
230
|
+
if (pick === BACK || pick === 'back')
|
|
231
|
+
break;
|
|
232
|
+
if (pick !== 'other')
|
|
233
|
+
return { vendor, model: pick };
|
|
234
|
+
const t = await prompter.text({ message: 'Model ID' });
|
|
235
|
+
if (t === EXIT)
|
|
236
|
+
return EXIT;
|
|
237
|
+
if (t === BACK || !t.trim())
|
|
238
|
+
continue;
|
|
239
|
+
return { vendor, model: t.trim() };
|
|
160
240
|
}
|
|
161
|
-
if ('failed' in res)
|
|
162
|
-
prompter.note(`${LISTER_CLI[vendor]} models failed (${res.failed}) — showing known models`);
|
|
163
|
-
else
|
|
164
|
-
ids = res.ids;
|
|
165
|
-
}
|
|
166
|
-
for (;;) {
|
|
167
|
-
const pick = await prompter.select({
|
|
168
|
-
message: `${row.role}: ${vendor} model`,
|
|
169
|
-
initial: row.model,
|
|
170
|
-
options: [
|
|
171
|
-
{ value: 'back', label: '< back' },
|
|
172
|
-
...ids.map((m) => ({
|
|
173
|
-
value: m,
|
|
174
|
-
label: m,
|
|
175
|
-
...(m === row.model ? { hint: 'current' } : {}),
|
|
176
|
-
})),
|
|
177
|
-
{ value: 'other', label: 'other (type a model ID)' },
|
|
178
|
-
],
|
|
179
|
-
});
|
|
180
|
-
if (pick === EXIT)
|
|
181
|
-
return EXIT;
|
|
182
|
-
if (pick === BACK || pick === 'back')
|
|
183
|
-
return undefined;
|
|
184
|
-
if (pick !== 'other')
|
|
185
|
-
return pick;
|
|
186
|
-
const t = await prompter.text({ message: 'Model ID' });
|
|
187
|
-
if (t === EXIT)
|
|
188
|
-
return EXIT;
|
|
189
|
-
if (t === BACK || !t.trim())
|
|
190
|
-
continue;
|
|
191
|
-
return t.trim();
|
|
192
241
|
}
|
|
193
242
|
}
|
|
@@ -1,42 +1,123 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { effectiveBindings, resolveRoles } from '../lib/bindings.js';
|
|
2
2
|
import { newModelCache, vendors } from '../lib/detect.js';
|
|
3
3
|
import { repoRoot } from '../lib/git.js';
|
|
4
4
|
import { modelsScreen } from './config-models.js';
|
|
5
|
+
import { configureBindings } from './configure.js';
|
|
5
6
|
import { clackPrompter, isInteractive } from '../lib/prompter.js';
|
|
6
|
-
export const CONFIG_HINT = 'change with: reins
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.
|
|
7
|
+
export const CONFIG_HINT = 'change with: reins config bindings --set <default|group|group.role>=<model> [--local] (see: reins config bindings --help)';
|
|
8
|
+
/** The effective settings as text: mode, audit, the PM, each role that is on. */
|
|
9
|
+
export function formatBindings(doc) {
|
|
10
|
+
const lines = [
|
|
11
|
+
` mode: ${doc.mode ?? 'single'}`,
|
|
12
|
+
` audit: ${doc.audit?.required === false ? 'off (switched off by the user)' : 'required every version'}`,
|
|
13
|
+
` PM: ${doc.default ? `${doc.default.vendor} ${doc.default.model}` : 'claude claude-opus-5-5'}`,
|
|
14
|
+
];
|
|
15
|
+
const on = resolveRoles(doc).filter((r) => r.on);
|
|
16
|
+
if (on.length === 0)
|
|
17
|
+
lines.push(' every role: the PM');
|
|
18
|
+
for (const r of on)
|
|
19
|
+
lines.push(` ${`${r.group}/${r.role}`.padEnd(26)} ${r.models.map((b) => `${b.vendor} ${b.model}`).join(', ')} (${r.source})`);
|
|
20
|
+
const tools = Object.entries(doc.tools ?? {})
|
|
21
|
+
.map(([n, t]) => `${n}${t?.use === false ? ' (unused)' : ''}`)
|
|
22
|
+
.join(', ');
|
|
23
|
+
if (tools)
|
|
24
|
+
lines.push(` tools: ${tools}`);
|
|
25
|
+
return lines.join('\n');
|
|
11
26
|
}
|
|
12
|
-
/** `reins config` (design §9): the settings screen on a terminal, the
|
|
27
|
+
/** `reins config` (design §9): the settings screen on a terminal, the effective table otherwise. Returns the exit code. */
|
|
13
28
|
export async function runConfig(o = {}) {
|
|
14
29
|
const write = o.write ?? ((s) => void process.stdout.write(s));
|
|
15
30
|
const root = repoRoot(o.cwd ?? process.cwd());
|
|
16
31
|
const interactive = o.interactive ?? isInteractive();
|
|
17
32
|
if (!interactive || o.json) {
|
|
18
|
-
const
|
|
33
|
+
const doc = effectiveBindings(root);
|
|
34
|
+
if (!doc) {
|
|
35
|
+
write('no version-2 bindings.yaml — run `reins install` or `reins update`\n');
|
|
36
|
+
return 2;
|
|
37
|
+
}
|
|
19
38
|
if (o.json)
|
|
20
|
-
write(`${JSON.stringify({ bindings }, null, 2)}\n`);
|
|
39
|
+
write(`${JSON.stringify({ bindings: doc, roles: resolveRoles(doc) }, null, 2)}\n`);
|
|
21
40
|
else
|
|
22
|
-
write(`${formatBindings(
|
|
41
|
+
write(`${formatBindings(doc)}\n${CONFIG_HINT}\n`);
|
|
23
42
|
return 0;
|
|
24
43
|
}
|
|
25
44
|
const prompter = o.prompter ?? (await clackPrompter());
|
|
26
45
|
const modelCache = o.modelCache ?? newModelCache();
|
|
27
46
|
const detect = o.detectVendors ?? vendors;
|
|
28
47
|
for (;;) {
|
|
48
|
+
const doc = effectiveBindings(root);
|
|
29
49
|
const v = await prompter.select({
|
|
30
50
|
message: 'Configuration',
|
|
31
51
|
options: [
|
|
32
52
|
{ value: 'models', label: 'models and roles configuration' },
|
|
53
|
+
{ value: 'tools', label: 'agent tools', hint: 'detect again, use or not' },
|
|
54
|
+
{ value: 'mode', label: `mode: ${doc?.mode ?? 'single'}` },
|
|
55
|
+
{
|
|
56
|
+
value: 'audit',
|
|
57
|
+
label: `audit: ${doc?.audit?.required === false ? 'off' : 'required'}`,
|
|
58
|
+
},
|
|
33
59
|
{ value: 'exit', label: 'exit' },
|
|
34
60
|
],
|
|
35
61
|
});
|
|
36
|
-
if (v !== '
|
|
37
|
-
return 0; //
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
if (typeof v !== 'string' || v === 'exit')
|
|
63
|
+
return 0; // EXIT (Ctrl-C) or BACK: nothing more is written
|
|
64
|
+
if (v === 'models') {
|
|
65
|
+
const r = await modelsScreen({ root, prompter, detectVendors: detect, modelCache });
|
|
66
|
+
if (r === 'exit')
|
|
67
|
+
return 0;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (v === 'tools') {
|
|
71
|
+
const found = detect();
|
|
72
|
+
const picked = await prompter.multiselect({
|
|
73
|
+
message: 'Agent tools to use (detected tools are marked)',
|
|
74
|
+
options: found.map((t) => ({
|
|
75
|
+
value: t.name,
|
|
76
|
+
label: t.name,
|
|
77
|
+
hint: t.detected ? `detected (${t.cli})` : `not found (${t.cli})`,
|
|
78
|
+
})),
|
|
79
|
+
initial: found.filter((t) => doc?.tools?.[t.name]?.use ?? t.detected).map((t) => t.name),
|
|
80
|
+
});
|
|
81
|
+
if (typeof picked === 'symbol')
|
|
82
|
+
return 0;
|
|
83
|
+
const r = await configureBindings({
|
|
84
|
+
cwd: root,
|
|
85
|
+
detect: true,
|
|
86
|
+
detectVendors: () => found,
|
|
87
|
+
tools: found.map((t) => `${t.name}=${picked.includes(t.name) ? 'on' : 'off'}`),
|
|
88
|
+
});
|
|
89
|
+
prompter.note(r.refused ? `not changed: ${r.refused}` : 'agent tools written — commit bindings.yaml');
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (v === 'mode') {
|
|
93
|
+
const m = await prompter.select({
|
|
94
|
+
message: 'Mode',
|
|
95
|
+
initial: doc?.mode ?? 'single',
|
|
96
|
+
options: [
|
|
97
|
+
{ value: 'single', label: 'single', hint: 'the PM does every role (default)' },
|
|
98
|
+
{ value: 'multi', label: 'multi', hint: 'role groups with a model do their work' },
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
if (typeof m === 'symbol')
|
|
102
|
+
return 0;
|
|
103
|
+
const r = await configureBindings({ cwd: root, mode: m });
|
|
104
|
+
prompter.note(r.refused
|
|
105
|
+
? `not changed: ${r.refused}`
|
|
106
|
+
: r.reconcile
|
|
107
|
+
? `mode ${m}: AGENTS.md has a reconcile note — the PM merges it in the next conversation`
|
|
108
|
+
: `mode ${m}: already so`);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const off = doc?.audit?.required !== false;
|
|
112
|
+
if (off) {
|
|
113
|
+
const sure = await prompter.confirm({
|
|
114
|
+
message: 'Switch the per-version audit off? Nothing will check that the flow was followed.',
|
|
115
|
+
initial: false,
|
|
116
|
+
});
|
|
117
|
+
if (sure !== true)
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const r = await configureBindings({ cwd: root, audit: off ? 'off' : 'on' });
|
|
121
|
+
prompter.note(r.refused ? `not changed: ${r.refused}` : `audit ${off ? 'off' : 'required'}`);
|
|
41
122
|
}
|
|
42
123
|
}
|