@bluenyang/reins 0.1.5-rc.2 → 0.2.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 CHANGED
@@ -14,12 +14,13 @@ loop that works only with Claude. The full list (P1–P6) is in [docs/proposal.m
14
14
 
15
15
  ## Status
16
16
 
17
- Version 0.1.4 is on npm: `npx @bluenyang/reins <command>`. It is round one of the plan — the graph
17
+ Version 0.1.5 is on npm: `npx @bluenyang/reins <command>`. It is round one of the plan — the graph
18
18
  tier, with generated vendor files verified for Claude Code only; the loop and harness tiers are
19
19
  carved out of it in 0.2. 0.1.3 split the loop into stage skills with a PR → CI → rc release flow,
20
20
  0.1.4 prepares large repositories (release settings, monorepo gates, migrate fixes), and 0.1.5
21
- (in rc) states which rules are enforced and which are only advised, splits model bindings into a team
22
- and a per-user layer, and runs CI on Ubuntu, Windows and macOS with Node 22 and 24. What
21
+ states which rules are enforced and which are only advised, splits model bindings into a team
22
+ and a per-user layer, and runs CI on Ubuntu, Windows and macOS with Node 22 and 24. 0.2.0 (in rc) adds `reins config`,
23
+ a terminal screen for models and roles, and asks install and update questions as screens. What
23
24
  changed in each version is in [CHANGELOG.md](CHANGELOG.md); what comes next is in the roadmap.
24
25
 
25
26
  reins develops itself through its own loop: intents 001 (`reins status`), 002 (`reins metrics`) and
@@ -190,10 +191,11 @@ To work on reins itself: `git clone https://github.com/bluenyang/reins.git`, the
190
191
 
191
192
  | Command | State | Does |
192
193
  |---|---|---|
193
- | `install <harness\|loop\|graph>` | implemented | places the harness; `--mode manual\|auto`, `--hooks`, `--dry-run`, `--json` |
194
+ | `install <harness\|loop\|graph>` | implemented | places the harness; on a terminal `--mode manual` asks vendors, language, gates and subdirectory gates as screens; `--mode manual\|auto`, `--hooks`, `--dry-run`, `--json` |
194
195
  | `migrate <tier>` | implemented | moves an existing harness or `.ai/` workspace to this layout |
195
- | `update` | implemented | re-applies the packaged harness without touching project sections |
196
- | `configure bindings` | implemented | `--set role=model ...` or `--vendors claude,openai`; no options asks |
196
+ | `update` | implemented | re-applies the packaged harness without touching project sections; on a terminal it shows the plan and asks first (`--yes` skips the question) |
197
+ | `config` | implemented | settings screen on a terminal (`models and roles configuration`, `exit`); without a terminal it prints the resolved bindings table and how to change it; `--json` |
198
+ | `configure bindings` | implemented | `--set role=model ...` or `--vendors claude,openai`; `--disable <role...>` / `--enable <role...>` switch roles off or on (`--local` for you only; pm, implementer and verify-tool cannot be switched off); no options asks |
197
199
  | `gate [names...]` | implemented | runs `gates.yaml` as declared and keeps the raw output in `.loctx/reports/` |
198
200
  | `status` | implemented | read-only view of harness, intents, tickets, bus and last history |
199
201
  | `check` | implemented | `--stage ticket-start\|pre-commit\|verdict\|pre-push\|rc-close`, or `--drift` |
@@ -0,0 +1,193 @@
1
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { CONFIRMED_MODELS, listModels, vendorOf, } from '../lib/detect.js';
4
+ import { FIXED_ROLES, readLocal, teamEnabled, resolveBindings, } from '../lib/bindings.js';
5
+ import { BACK, EXIT } from '../lib/prompter.js';
6
+ import { splitFrontmatter } from '../lib/skills.js';
7
+ import { configureBindings } from './configure.js';
8
+ const LISTER_CLI = { google: 'agy', cursor: 'cursor-agent' };
9
+ /** One line per role: `[ON] planner claude claude-opus-5-5 (team)`; `(local)` marks a value of this user's own. */
10
+ export function roleLine(b, scope) {
11
+ const mark = scope === 'local' && b.enabled_source === 'local' ? ' state (local)' : '';
12
+ const fixed = b.enabled_source === 'fixed' ? ' always on' : '';
13
+ return `[${b.enabled ? 'ON ' : 'OFF'}] ${b.role.padEnd(12)} ${b.vendor.padEnd(7)} ${b.model} (${b.source})${mark}${fixed}`;
14
+ }
15
+ /** Models of `vendor` already known to this repository: role defaults and fallbacks, confirmed, current. */
16
+ export function knownModels(root, vendor, current) {
17
+ const out = [];
18
+ const dir = join(root, '.agents/harness/roles');
19
+ if (existsSync(dir))
20
+ for (const f of readdirSync(dir)
21
+ .filter((x) => x.endsWith('.md'))
22
+ .toSorted()) {
23
+ const { data } = splitFrontmatter(readFileSync(join(dir, f), 'utf8'));
24
+ for (const k of ['default_binding', 'fallback_binding'])
25
+ if (typeof data?.[k] === 'string')
26
+ out.push(data[k]);
27
+ }
28
+ out.push(...CONFIRMED_MODELS, ...current);
29
+ return [...new Set(out)].filter((m) => vendorOf(m) === vendor);
30
+ }
31
+ /**
32
+ * The models and roles screen (spec S-3) and the role screen under it (S-5). Every choice is written at
33
+ * once through `configureBindings` (the same writer as `reins configure bindings`); EXIT writes nothing more.
34
+ * Returns `exit` when the user left reins config, `back` for `< Configuration`.
35
+ */
36
+ export async function modelsScreen(o) {
37
+ const { root, prompter } = o;
38
+ let scope = 'local';
39
+ 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
+ });
47
+ if (r.refused)
48
+ prompter.note(`not changed: ${r.refused}`);
49
+ else if (r.changed.length === 0)
50
+ prompter.note(`${label}: already so — nothing changed`);
51
+ else if (scope === 'local')
52
+ prompter.note(`${label}: written to .loctx/bindings.local.yaml (this user only)`);
53
+ else
54
+ prompter.note(`${label}: written to .agents/harness/bindings.yaml, vendor files regenerated — commit bindings.yaml`);
55
+ };
56
+ for (;;) {
57
+ const rows = resolveBindings(root, o.detectVendors);
58
+ const options = [
59
+ { value: 'back', label: '< Configuration' },
60
+ { value: 'exit', label: 'exit' },
61
+ {
62
+ value: 'scope',
63
+ label: `scope: ${scope === 'local' ? 'local | global' : 'global | local'}`,
64
+ },
65
+ { value: 'toggle', label: 'switch roles on or off' },
66
+ ...rows.map((b) => ({ value: b.role, label: roleLine(b, scope) })),
67
+ ];
68
+ const v = await prompter.select({ message: 'Models and roles', options });
69
+ if (v === EXIT)
70
+ return 'exit';
71
+ if (v === BACK || v === 'back')
72
+ return 'back';
73
+ if (v === 'exit')
74
+ return 'exit';
75
+ if (v === 'scope') {
76
+ const s = await prompter.select({
77
+ message: 'Write changes to',
78
+ initial: scope,
79
+ options: [
80
+ { value: 'local', label: 'local', hint: '.loctx/bindings.local.yaml, this user only' },
81
+ { value: 'global', label: 'global', hint: 'bindings.yaml, committed, regenerates files' },
82
+ ],
83
+ });
84
+ if (s === EXIT)
85
+ return 'exit';
86
+ if (s !== BACK)
87
+ scope = s;
88
+ continue;
89
+ }
90
+ if (v === 'toggle') {
91
+ const names = rows.filter((b) => !FIXED_ROLES.includes(b.role));
92
+ prompter.note(`always on: ${FIXED_ROLES.join(', ')}`);
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)
101
+ return 'exit';
102
+ if (on === BACK)
103
+ continue;
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(', ')}`);
111
+ continue;
112
+ }
113
+ const row = rows.find((b) => b.role === v);
114
+ if (!row)
115
+ continue;
116
+ const r = await roleScreen(o, row, scope);
117
+ if (r === EXIT)
118
+ return 'exit';
119
+ if (r !== undefined)
120
+ await write({ set: [`${row.role}=${r}`] }, `${row.role} → ${r}`);
121
+ }
122
+ }
123
+ /** S-5: vendor (detected only), then model. Returns the chosen model ID, `undefined` for back, or EXIT. */
124
+ async function roleScreen(o, row, scope) {
125
+ const { prompter } = o;
126
+ const detected = o.detectVendors().filter((v) => v.detected || v.name === 'claude');
127
+ for (;;) {
128
+ const vendor = await prompter.select({
129
+ message: `${row.role} (${scope}): vendor`,
130
+ initial: row.vendor,
131
+ options: [
132
+ { value: 'back', label: '< back' },
133
+ ...detected.map((v) => ({ value: v.name, label: v.name })),
134
+ ],
135
+ });
136
+ if (vendor === EXIT)
137
+ return EXIT;
138
+ if (vendor === BACK || vendor === 'back')
139
+ return undefined;
140
+ const model = await modelPicker(o, row, vendor);
141
+ if (model === EXIT)
142
+ return EXIT;
143
+ if (model === undefined)
144
+ continue; // back to the vendor list
145
+ return model;
146
+ }
147
+ }
148
+ async function modelPicker(o, row, vendor) {
149
+ const { prompter, root } = o;
150
+ const team = (await configureBindings({ cwd: root, show: true, detectVendors: o.detectVendors })).table.map((t) => t.model);
151
+ const local = Object.values(readLocal(root).roles).flatMap((r) => (r.model ? [r.model] : []));
152
+ let ids = knownModels(root, vendor, [...team, ...local, row.model]);
153
+ if (vendor === 'google' || vendor === 'cursor') {
154
+ let res;
155
+ try {
156
+ res = listModels(vendor, o.modelCache.run);
157
+ }
158
+ catch (e) {
159
+ res = { failed: e.message };
160
+ }
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
+ }
193
+ }
@@ -0,0 +1,42 @@
1
+ import { resolveBindings, stateLabel } from '../lib/bindings.js';
2
+ import { newModelCache, vendors } from '../lib/detect.js';
3
+ import { repoRoot } from '../lib/git.js';
4
+ import { modelsScreen } from './config-models.js';
5
+ import { clackPrompter, isInteractive } from '../lib/prompter.js';
6
+ export const CONFIG_HINT = 'change with: reins configure bindings --set <role>=<model> [--local] (see: reins configure bindings --help)';
7
+ export function formatBindings(rows) {
8
+ return rows
9
+ .map((t) => ` ${t.role.padEnd(12)} ${t.vendor.padEnd(7)} ${t.model} (${t.source}: ${t.reason})${stateLabel(t) ? ` ${stateLabel(t)}` : ''}`)
10
+ .join('\n');
11
+ }
12
+ /** `reins config` (design §9): the settings screen on a terminal, the resolved table otherwise. Returns the exit code. */
13
+ export async function runConfig(o = {}) {
14
+ const write = o.write ?? ((s) => void process.stdout.write(s));
15
+ const root = repoRoot(o.cwd ?? process.cwd());
16
+ const interactive = o.interactive ?? isInteractive();
17
+ if (!interactive || o.json) {
18
+ const bindings = resolveBindings(root, o.detectVendors);
19
+ if (o.json)
20
+ write(`${JSON.stringify({ bindings }, null, 2)}\n`);
21
+ else
22
+ write(`${formatBindings(bindings)}\n${CONFIG_HINT}\n`);
23
+ return 0;
24
+ }
25
+ const prompter = o.prompter ?? (await clackPrompter());
26
+ const modelCache = o.modelCache ?? newModelCache();
27
+ const detect = o.detectVendors ?? vendors;
28
+ for (;;) {
29
+ const v = await prompter.select({
30
+ message: 'Configuration',
31
+ options: [
32
+ { value: 'models', label: 'models and roles configuration' },
33
+ { value: 'exit', label: 'exit' },
34
+ ],
35
+ });
36
+ if (v !== 'models')
37
+ return 0; // exit, EXIT (Ctrl-C) or BACK: nothing more is written
38
+ const r = await modelsScreen({ root, prompter, detectVendors: detect, modelCache });
39
+ if (r === 'exit')
40
+ return 0;
41
+ }
42
+ }
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { parse, parseDocument, stringify } from 'yaml';
4
4
  import { CONFIRMED_MODELS, checkBinding, newModelCache, subdirProposals, vendorOf, vendors, } from '../lib/detect.js';
5
- import { readLocal, recordDetection, resolveBindings, writeLocal, } from '../lib/bindings.js';
5
+ import { readLocal, recordDetection, resolveBindings, roleEnabledRefusal, setRoleEnabled, teamRoles, writeLocal, } from '../lib/bindings.js';
6
6
  import { generateVendorFiles } from '../lib/generate.js';
7
7
  import { repoRoot } from '../lib/git.js';
8
8
  import { writeGenerated } from '../lib/vendor-write.js';
@@ -26,6 +26,32 @@ export async function configureBindings(o) {
26
26
  .toSorted((a, b) => a.role.localeCompare(b.role));
27
27
  if (o.show)
28
28
  return { changed, table: teamTable(), resolved: resolveBindings(root, detect) };
29
+ // on/off requests are checked as a whole before anything is written
30
+ const wanted = [
31
+ ...(o.disable ?? []).map((role) => ({ role, enabled: false })),
32
+ ...(o.enable ?? []).map((role) => ({ role, enabled: true })),
33
+ ];
34
+ for (const w of wanted) {
35
+ const why = roleEnabledRefusal(root, w.role, w.enabled);
36
+ if (why)
37
+ return { refused: why, code: 1, changed: [], table: [] };
38
+ }
39
+ if ((o.disable ?? []).some((r) => (o.enable ?? []).includes(r)))
40
+ return {
41
+ refused: 'a role cannot be both --disable and --enable',
42
+ code: 1,
43
+ changed: [],
44
+ table: [],
45
+ };
46
+ const toggled = [];
47
+ const toggle = (scope) => {
48
+ for (const w of wanted)
49
+ if (setRoleEnabled(root, w.role, w.enabled, scope).changed) {
50
+ toggled.push(w);
51
+ if (!changed.includes(w.role))
52
+ changed.push(w.role);
53
+ }
54
+ };
29
55
  if (o.local) {
30
56
  // per-user overrides: roles only; the team file and generated files stay untouched
31
57
  const local = readLocal(root);
@@ -39,14 +65,26 @@ export async function configureBindings(o) {
39
65
  changed: [],
40
66
  table: [],
41
67
  };
42
- if (local.roles[role]?.model !== model) {
43
- local.roles[role] = { model };
68
+ if (teamRoles(root)[role]?.model === model) {
69
+ // the same as the team: no override to keep (the role follows the team again)
70
+ if (local.roles[role]?.model !== undefined) {
71
+ const { model: _drop, ...rest } = local.roles[role];
72
+ if (Object.keys(rest).length)
73
+ local.roles[role] = rest;
74
+ else
75
+ delete local.roles[role];
76
+ changed.push(role);
77
+ }
78
+ }
79
+ else if (local.roles[role]?.model !== model) {
80
+ local.roles[role] = { ...local.roles[role], model };
44
81
  changed.push(role);
45
82
  }
46
83
  }
47
84
  if (changed.length)
48
85
  writeLocal(root, local);
49
- return { changed, table: teamTable(), resolved: resolveBindings(root, detect) };
86
+ toggle('local');
87
+ return { changed, toggled, table: teamTable(), resolved: resolveBindings(root, detect) };
50
88
  }
51
89
  if (o.vendors?.length) {
52
90
  const vs = detect();
@@ -56,6 +94,11 @@ export async function configureBindings(o) {
56
94
  ...o.vendors.filter((v) => ['openai', 'google', 'cursor'].includes(v)),
57
95
  ]);
58
96
  const rebuilt = parse(buildBindings(packageHarness(), avail, vs, doc.mode ?? 'manual', cache));
97
+ for (const r of Object.keys(rebuilt.roles)) {
98
+ const kept = doc.roles[r]?.['enabled'];
99
+ if (typeof kept === 'boolean')
100
+ rebuilt.roles[r]['enabled'] = kept;
101
+ }
59
102
  for (const r of Object.keys(rebuilt.roles))
60
103
  if (JSON.stringify(rebuilt.roles[r]) !== JSON.stringify(doc.roles[r]))
61
104
  changed.push(r);
@@ -80,6 +123,8 @@ export async function configureBindings(o) {
80
123
  table: [],
81
124
  };
82
125
  const entry = { vendor: vendorOf(model), model };
126
+ if (typeof doc.roles[role]?.['enabled'] === 'boolean')
127
+ entry['enabled'] = doc.roles[role]['enabled'];
83
128
  if (role === 'implementer')
84
129
  entry['parallel'] = doc.roles[role]?.['parallel'] ?? 4;
85
130
  const chk = checkBinding(model, entry.vendor, cache);
@@ -99,10 +144,18 @@ export async function configureBindings(o) {
99
144
  }
100
145
  if (changed.length)
101
146
  writeFileSync(path, `# generated by reins — change with \`reins configure bindings\`\n${stringify(doc)}`);
102
- const generated = changed.length
103
- ? writeGenerated(root, generateVendorFiles(root), false)
104
- : undefined;
105
- return { changed, table: teamTable(), generated, resolved: resolveBindings(root, detect) };
147
+ const wrote = changed.length > 0;
148
+ toggle('global');
149
+ if (toggled.length > 0)
150
+ doc = parse(readFileSync(path, 'utf8'));
151
+ const generated = wrote || toggled.length ? writeGenerated(root, generateVendorFiles(root), false) : undefined;
152
+ return {
153
+ changed,
154
+ toggled,
155
+ table: teamTable(),
156
+ generated,
157
+ resolved: resolveBindings(root, detect),
158
+ };
106
159
  }
107
160
  /** `reins configure gates [--add <name>…]` (spec S-7): subdirectory proposals, appended after the existing gates. */
108
161
  export function configureGates(o = {}) {
@@ -1,6 +1,7 @@
1
1
  import { existsSync, readFileSync, readdirSync, rmdirSync, rmSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import { parse, stringify } from 'yaml';
4
+ import { askerPrompter, BACK, EXIT } from '../lib/prompter.js';
4
5
  import { planMemoryProposals } from '../lib/memory.js';
5
6
  import { draftRelease, releaseDraftNotes } from '../lib/release.js';
6
7
  import { applyBlocks, parseBlocks } from '../lib/blocks.js';
@@ -161,29 +162,102 @@ export async function runInstall(o) {
161
162
  const vs = (o.detectVendors ?? vendors)();
162
163
  const detected = vs.filter((v) => v.detected).map((v) => v.name);
163
164
  const avail = new Set(['claude']); // claude is the floor (R22)
165
+ const screens = o.mode === 'manual' ? o.prompter : undefined;
166
+ const line = askerPrompter(o.asker); // the piped, line-based form: today's strings and parsing
167
+ const cancelled = () => ({ root, generation: gen, notes, cancelled: true });
168
+ const isNav = (v) => v === BACK || v === EXIT;
169
+ const VENDOR_NAMES = ['claude', 'openai', 'google', 'cursor'];
164
170
  if (o.tier === 'graph' && !hasBindings) {
165
- const ans = await o.asker.ask(`vendors you can use (claude,openai,google,cursor) — detected: ${detected.join(',') || 'none'}`, ['claude', ...detected.filter((d) => d !== 'claude')].join(','));
166
- for (const v of ans.split(',').map((s) => s.trim()))
167
- if (['claude', 'openai', 'google', 'cursor'].includes(v))
171
+ if (screens) {
172
+ const picked = await screens.multiselect({
173
+ message: 'Vendors you can use (claude is always on)',
174
+ options: VENDOR_NAMES.map((n) => ({
175
+ value: n,
176
+ label: n,
177
+ hint: n === 'claude' ? 'always' : detected.includes(n) ? 'detected' : undefined,
178
+ })),
179
+ initial: ['claude', ...detected.filter((d) => d !== 'claude')],
180
+ });
181
+ if (isNav(picked))
182
+ return cancelled();
183
+ for (const v of picked)
168
184
  avail.add(v);
185
+ }
186
+ else {
187
+ const ans = await line.text({
188
+ message: `vendors you can use (claude,openai,google,cursor) — detected: ${detected.join(',') || 'none'}`,
189
+ initial: ['claude', ...detected.filter((d) => d !== 'claude')].join(','),
190
+ });
191
+ for (const v of String(ans)
192
+ .split(',')
193
+ .map((s) => s.trim()))
194
+ if (VENDOR_NAMES.includes(v))
195
+ avail.add(v);
196
+ }
197
+ }
198
+ let language = pinned?.language;
199
+ if (language === undefined) {
200
+ if (screens) {
201
+ const pick = await screens.select({
202
+ message: 'Language of documents you read',
203
+ options: [
204
+ { value: 'ko', label: 'ko' },
205
+ { value: 'en', label: 'en' },
206
+ { value: 'other', label: 'other', hint: 'type a language code' },
207
+ ],
208
+ initial: 'ko',
209
+ });
210
+ if (isNav(pick))
211
+ return cancelled();
212
+ if (pick === 'other') {
213
+ const typed = await screens.text({ message: 'Language code (ko, en, …)', initial: 'ko' });
214
+ if (isNav(typed))
215
+ return cancelled();
216
+ language = typed.trim() || 'ko';
217
+ }
218
+ else
219
+ language = pick;
220
+ }
221
+ else
222
+ language = String(await line.text({
223
+ message: 'language of documents the user reads (ko, en, …)',
224
+ initial: 'ko',
225
+ }));
169
226
  }
170
- const language = pinned?.language ??
171
- (await o.asker.ask('language of documents the user reads (ko, en, …)', 'ko'));
172
227
  if (!hasGates) {
173
228
  const proposal = discoverGates(root);
174
229
  const gateList = proposal.gates.map((g) => `${g.name}=${g.cmd}`).join(', ') || 'none found';
175
- const okGates = await o.asker.ask(`gates found: ${gateList} — use them? (y/n)`, 'y');
176
- if (!/^y/i.test(okGates))
230
+ const gateQ = `gates found: ${gateList} — use them?`;
231
+ const gateAns = await (screens ?? line).confirm({ message: gateQ, initial: true });
232
+ if (isNav(gateAns))
233
+ return cancelled();
234
+ if (!gateAns)
177
235
  notes.push('gates not confirmed — edit .agents/harness/gates.yaml, then `reins check --dry-run`');
178
236
  let chosen = [];
179
237
  if (proposal.proposals.length) {
180
238
  const listing = proposal.proposals.map((g) => `${g.name}=${g.cmd}`).join('; ');
181
239
  if (o.mode === 'manual') {
182
- const pick = await o.asker.ask(`subdirectory gates (names, comma-separated; empty: none) — ${listing}`, '');
183
- const names = new Set(pick
184
- .split(',')
185
- .map((x) => x.trim())
186
- .filter(Boolean));
240
+ let names;
241
+ if (screens) {
242
+ const picked = await screens.multiselect({
243
+ message: 'Subdirectory gates to add',
244
+ options: proposal.proposals.map((g) => ({ value: g.name, label: g.name, hint: g.cmd })),
245
+ initial: [],
246
+ });
247
+ if (isNav(picked))
248
+ return cancelled();
249
+ names = new Set(picked);
250
+ }
251
+ else {
252
+ const pick = String(await line.text({
253
+ message: `subdirectory gates (names, comma-separated; empty: none) — ${listing}`,
254
+ initial: '',
255
+ }));
256
+ names = new Set(pick
257
+ .split(',')
258
+ .map((x) => x.trim())
259
+ .filter(Boolean));
260
+ }
187
261
  chosen = proposal.proposals.filter((g) => names.has(g.name));
188
262
  if (o.dryRun)
189
263
  notes.push(`subdirectory gates offered (names are asked in a real run): ${listing}`);
@@ -196,7 +270,7 @@ export async function runInstall(o) {
196
270
  }
197
271
  for (const x of proposal.excluded)
198
272
  notes.push(`excluded from gates: ${x.name} (${x.why})`);
199
- add('.agents/harness/gates.yaml', buildGates(root, [...(/^y/i.test(okGates) ? proposal.gates : []), ...chosen]), 'declared gates');
273
+ add('.agents/harness/gates.yaml', buildGates(root, [...(gateAns ? proposal.gates : []), ...chosen]), 'declared gates');
200
274
  }
201
275
  // 3. generated configuration
202
276
  if (o.tier === 'graph' && !hasBindings) {
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
2
2
  import { isAbsolute, join, relative, sep } from 'node:path';
3
+ import { roleStates } from '../lib/bindings.js';
3
4
  import { isWithin, realPath } from '../lib/fsx.js';
4
5
  import { harnessDir, readYaml } from '../lib/harness.js';
5
6
  import { checkDoc, dispatchLines, readRelease, readReleaseDocs } from '../lib/release.js';
@@ -183,6 +184,19 @@ export function ticketStart(root, id) {
183
184
  message: `role "${role}" has no binding`,
184
185
  resume: `reins configure bindings --set ${role}=<model>`,
185
186
  });
187
+ else {
188
+ // an off role is not refused yet (the loop's stage cutting is 0.2); the covering role does the work.
189
+ // F2: a check without its own stop id reports as F2 (design §3)
190
+ const st = roleStates(root).states.get(role);
191
+ if (st && !st.enabled)
192
+ findings.push({
193
+ reason: 'F2',
194
+ verdict: 'WARN',
195
+ path: t.path,
196
+ message: `role ${role} is off — covered by ${st.covered_by ?? 'the next role in the chain'}`,
197
+ resume: `reins configure bindings --enable ${role} [--local], or let ${st.covered_by ?? 'the next role'} do it`,
198
+ });
199
+ }
186
200
  }
187
201
  return findings;
188
202
  }
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
2
2
  import { basename, join } from 'node:path';
3
3
  import { parse } from 'yaml';
4
- import { resolveBindings } from '../lib/bindings.js';
4
+ import { resolveBindings, roleStates, stateLabel } from '../lib/bindings.js';
5
5
  import { repoRoot } from '../lib/git.js';
6
6
  import { harnessVersion, packageHarness, packageVersion } from '../lib/upstream.js';
7
7
  import { candidateCount } from '../lib/retro.js';
@@ -258,7 +258,7 @@ export function formatStatus(d) {
258
258
  out.push('');
259
259
  out.push('bindings (resolved):');
260
260
  for (const b of d.bindings)
261
- out.push(` ${b.role.padEnd(12)} ${b.vendor.padEnd(7)} ${b.model} (${b.source})`);
261
+ out.push(` ${b.role.padEnd(12)} ${b.vendor.padEnd(7)} ${b.model} (${b.source})${stateLabel(b) ? ` ${stateLabel(b)}` : ''}`);
262
262
  }
263
263
  return `${out.join('\n')}\n`;
264
264
  }
@@ -272,9 +272,10 @@ export function runStatus(opts = {}) {
272
272
  return { code: 2, stdout: '', stderr: 'reins status: not inside a git repository\n' };
273
273
  }
274
274
  const data = collectStatus(root);
275
+ const warnings = safe(() => roleStates(root).warnings, []);
275
276
  return {
276
277
  code: 0,
277
278
  stdout: opts.json ? `${JSON.stringify(data, null, 2)}\n` : formatStatus(data),
278
- stderr: '',
279
+ stderr: warnings.map((w) => `${w}\n`).join(''),
279
280
  };
280
281
  }
@@ -5,6 +5,7 @@ import { defaultsAsker } from '../lib/ask.js';
5
5
  import { migrateDetected } from '../lib/bindings.js';
6
6
  import { overrides } from '../lib/blocks.js';
7
7
  import { repoRoot } from '../lib/git.js';
8
+ import { BACK, EXIT } from '../lib/prompter.js';
8
9
  import { harnessVersion, packageHarness, packageVersion } from '../lib/upstream.js';
9
10
  import { runInstall } from './install.js';
10
11
  /** Numeric dotted-version compare; pre-release suffixes are ignored. */
@@ -37,6 +38,23 @@ export function changesBetween(changelog, from, to) {
37
38
  * When the changelog says a project section needs changing, it points to the /reins-update skill.
38
39
  */
39
40
  export async function runUpdate(o) {
41
+ if (o.prompter && !o.dryRun) {
42
+ const plan = await runUpdate({ ...o, prompter: undefined, dryRun: true });
43
+ if (plan.refused)
44
+ return plan;
45
+ const a = plan.install?.applied;
46
+ const nothing = !plan.bindingsMoved && (!a || a.created.length + a.changed.length + a.removed.length === 0);
47
+ if (nothing)
48
+ return plan;
49
+ o.show?.(plan);
50
+ const ok = await o.prompter.confirm({ message: 'Apply this update?', initial: true });
51
+ if (ok === BACK || ok === EXIT || !ok)
52
+ return { ...plan, declined: true };
53
+ return runUpdate({ ...o, prompter: undefined });
54
+ }
55
+ return updateNow(o);
56
+ }
57
+ async function updateNow(o) {
40
58
  const root = repoRoot(o.cwd ?? process.cwd());
41
59
  const res = { root, changes: [], needsSkill: false, overrides: [] };
42
60
  const pinPath = join(root, '.agents/harness/install.yaml');
@@ -75,3 +93,33 @@ export async function runUpdate(o) {
75
93
  });
76
94
  return res;
77
95
  }
96
+ /** The report `reins update` prints; with `dry` it is the plan shown before the confirmation. */
97
+ export function formatUpdate(r, dry) {
98
+ const out = [];
99
+ const a = r.install?.applied;
100
+ out.push(`reins update — cli ${r.cliFrom === 'none' ? 'none' : `v${r.cliFrom}`} → v${r.cliTo}, harness v${r.from} → v${r.to}${dry ? ' (dry run)' : ''}`);
101
+ for (const c of r.changes)
102
+ out.push(` · ${c}`);
103
+ if (r.bindingsMoved)
104
+ out.push(`bindings: ${dry ? 'would move' : 'moved'} detected vendors (${r.bindingsMoved.join(', ')}) to .loctx/bindings.local.yaml`);
105
+ if (a && a.created.length + a.changed.length + a.removed.length === 0)
106
+ out.push('already up to date');
107
+ else if (a) {
108
+ out.push(`${dry ? 'would write' : 'wrote'}: ${a.created.length} new, ${a.changed.length} changed${a.removed.length ? `, ${a.removed.length} removed` : ''}`);
109
+ for (const p of a.created)
110
+ out.push(` + ${p}`);
111
+ for (const p of a.changed)
112
+ out.push(` ~ ${p}`);
113
+ for (const p of a.removed)
114
+ out.push(` - ${p} (no longer installed by this tier)`);
115
+ }
116
+ for (const n of r.overrides)
117
+ out.push(`• block "${n}" is overridden by the project — compare it with the new upstream block`);
118
+ for (const n of r.install?.notes.filter((x) => x.startsWith('left alone')) ?? [])
119
+ out.push(`• ${n}`);
120
+ if (r.needsSkill)
121
+ out.push('• this update needs project sections changed: run /reins-update in your agent');
122
+ if (r.install?.history)
123
+ out.push(`recorded: ${r.install.history}`);
124
+ return `${out.join('\n')}\n`;
125
+ }