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