@bluenyang/reins 0.1.0-rc.1 → 0.1.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,14 +14,16 @@ 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.0, pre-release, round one of the plan. It is not on npm yet and has no Claude Code
18
- plugin manifest, so `npx @bluenyang/reins` does not work today; build it from source (see
19
- [Quick start](#quick-start-from-source)). Generated vendor files are verified for Claude Code only.
17
+ Version 0.1.0 is on npm: `npx @bluenyang/reins <command>`. It is round one of the plan — the graph
18
+ tier, with generated vendor files verified for Claude Code only; the loop and harness tiers are
19
+ carved out of it in 0.2. Known issues are listed in [CHANGELOG.md](CHANGELOG.md); their fixes ship
20
+ as 0.1.1, and 0.1.2 adds a Claude Code plugin.
20
21
 
21
- reins develops itself through its own loop. Intent 001 (`reins status`) went intent → spec → plan →
22
- tickets; the checks at T1 to T5 passed, and Codex did the code review. Roles bound to other vendors
23
- ran through their CLIs (`codex exec`, `agy -p`) in that run: the lead agent called them following
24
- the `reins-loop` skill. The CLI does not dispatch to vendors by itself yet.
22
+ reins develops itself through its own loop: intents 001 (`reins status`), 002 (`reins metrics`) and
23
+ 003 (violation scenarios) each went intent → spec → plan → tickets, with the checks at T1 to T5
24
+ passing and Codex doing the code review. Roles bound to other vendors ran through their CLIs
25
+ (`codex exec`, `agy -p`): the lead agent called them following the `reins-loop` skill. The CLI does
26
+ not dispatch to vendors by itself yet.
25
27
 
26
28
  ## The ladder
27
29
 
@@ -76,30 +78,27 @@ reviewed by roles. Verification output is pasted as produced; a bare "passed" is
76
78
  | `.claude/` | yes | generated from `.agents/`; do not edit |
77
79
  | `.loctx/` | no (gitignored) | tickets, reports, handoff `bus/`, `history/`, local roadmap |
78
80
 
79
- ## Quick start from source
81
+ ## Quick start
80
82
 
81
- Requires Node 20 or later and pnpm.
83
+ Requires Node 20 or later. Run it from the root of the repository you want to set up; the repository
84
+ needs at least one commit (`check` fails on an empty history in 0.1.0):
82
85
 
83
86
  ```sh
84
- git clone https://github.com/bluenyang/reins.git
85
- cd reins
86
- pnpm install
87
- pnpm build
87
+ npx @bluenyang/reins install graph --dry-run # show what would be written
88
+ npx @bluenyang/reins install graph --mode auto # place files, detect CLIs, take defaults
89
+ npx @bluenyang/reins check --drift # prints "drift: ok" when sources and output match
90
+ npx @bluenyang/reins status # intents, tickets, bus, last history entry
88
91
  ```
89
92
 
90
- Run the CLI from the root of the repository you want to set up. The repository needs at least one
91
- commit (`check` fails on an empty history in 0.1.0):
93
+ `install` refuses over a 3rd or 4th generation harness and points to `migrate`. Hooks are proposed
94
+ in the install notes and added only with `--hooks`.
92
95
 
93
- ```sh
94
- node /path/to/reins/cli/dist/reins.js install graph --dry-run # show what would be written
95
- node /path/to/reins/cli/dist/reins.js install graph --mode auto # place files, detect CLIs, take defaults
96
- node /path/to/reins/cli/dist/reins.js check --drift # prints "drift: ok" when sources and output match
97
- node /path/to/reins/cli/dist/reins.js status # intents, tickets, bus, last history entry
98
- ```
96
+ After the install, work goes through the agent: in Claude Code run `/reins-setup` once, then
97
+ `/reins-intent` for each new request; Codex, Antigravity and Cursor read the same skills from
98
+ `.agents/skills/`. The skills call the CLI themselves.
99
99
 
100
- `install` refuses over a 3rd or 4th generation harness and points to `migrate`. Hooks are proposed
101
- in the install notes and added only with `--hooks`. Once published, the same commands are meant to
102
- run as `npx @bluenyang/reins <command>`.
100
+ To work on reins itself: `git clone https://github.com/bluenyang/reins.git`, then `pnpm install`,
101
+ `pnpm build`, and run `node cli/dist/reins.js <command>` (see [CONTRIBUTING.md](CONTRIBUTING.md)).
103
102
 
104
103
  ## Commands
105
104
 
@@ -134,9 +133,9 @@ Three skills are the entry points for an agent; they follow the `SKILL.md` stand
134
133
 
135
134
  | Version | Content |
136
135
  |---|---|
137
- | 0.1 | graph design, self-install and self-migrate of this repository, the verifier, three skills, README; 0.1.0 is published to npm |
136
+ | 0.1 | graph design, self-install and self-migrate of this repository, the verifier, three skills, metrics, violation scenarios. 0.1.0 published; 0.1.1 stabilisation (fixes the loop found); 0.1.2 Claude Code plugin (marketplace install) |
138
137
  | 0.2 | carve the loop and harness tiers out of the graph; generated files for Codex, Gemini and Cursor; `recall`, `doctor`, budget stops; trial migration of older harnesses |
139
- | 0.3 | Claude Code plugin; application to Team Croffle repositories |
138
+ | 0.3 | application to Team Croffle repositories |
140
139
  | 1.0 | not scheduled: reins stays on 0.x and gains features until the maintainer considers the system settled; stabilising alone does not make it 1.0 |
141
140
 
142
141
  ## Documents
@@ -1,13 +1,15 @@
1
- import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { basename, join } from 'node:path';
3
+ import { hasOwnSection, overrides, parseBlocks } from '../lib/blocks.js';
3
4
  import { currentBranch, isAncestor, repoRoot, stagedFiles } from '../lib/git.js';
4
- import { harnessDir, secretPolicy } from '../lib/harness.js';
5
- import { loadSchemas, schemaFor, validateFile } from '../lib/schema.js';
5
+ import { harnessRel, secretPolicy } from '../lib/harness.js';
6
+ import { loadSchemasFrom, schemaFor, validateFile } from '../lib/schema.js';
6
7
  import { DEFAULT_ALLOWED, DEFAULT_SECRET_PATTERNS, isSecretPath } from '../lib/secrets.js';
7
- import { findSkillFiles, splitFrontmatter, validateSkillFile } from '../lib/skills.js';
8
+ import { splitFrontmatter, validateSkillFile } from '../lib/skills.js';
8
9
  import { harnessVersion, packageHarness, packageSkills, tierSkills } from '../lib/upstream.js';
9
10
  import { listFiles, relPath } from '../lib/fsx.js';
10
11
  import { driftGenerated } from '../lib/vendor-write.js';
12
+ import { indexReader, workTreeReader } from '../lib/reader.js';
11
13
  import { rcClose, ticketStart, verdictCheck } from './stages.js';
12
14
  import { parse } from 'yaml';
13
15
  import { report } from '../lib/verdict.js';
@@ -27,7 +29,8 @@ function gitignoreHas(root, entry) {
27
29
  /** T2 — before a commit. */
28
30
  export function preCommit(root) {
29
31
  const findings = [];
30
- const policy = secretPolicy(root);
32
+ const rd = indexReader(root);
33
+ const policy = secretPolicy(root, rd);
31
34
  const patterns = policy?.patterns ?? DEFAULT_SECRET_PATTERNS;
32
35
  const allowed = policy?.allowed ?? DEFAULT_ALLOWED;
33
36
  const staged = stagedFiles(root);
@@ -59,12 +62,15 @@ export function preCommit(root) {
59
62
  message: 'local workspace exists but is not in .gitignore',
60
63
  resume: 'add ".loctx/" (or ".ai/") to .gitignore',
61
64
  });
62
- findings.push(...driftFormat(root, staged), ...driftConvention(root, staged));
65
+ // S-1: the checks read the content the commit would contain (the index), not the working tree
66
+ findings.push(...driftFormat(root, staged, rd), ...driftConvention(root, staged, rd));
63
67
  const under = (...dirs) => staged.some((f) => dirs.some((d) => f.startsWith(d)));
64
68
  if (under('harness/', '.agents/harness/', 'skills/', '.agents/skills/'))
65
- findings.push(...driftMatch(root));
69
+ findings.push(...driftMatch(root, rd));
70
+ if (staged.includes('AGENTS.md'))
71
+ findings.push(...driftBlocks(root, rd));
66
72
  if (under('.claude/', '.agents/harness/', '.agents/skills/'))
67
- findings.push(...driftGenerated(root));
73
+ findings.push(...driftGenerated(root, rd));
68
74
  return findings;
69
75
  }
70
76
  /** T4 — before leaving the machine. */
@@ -75,8 +81,18 @@ export function prePush(root, refs) {
75
81
  const [localRef, localSha, remoteRef, remoteSha] = line.trim().split(/\s+/);
76
82
  if (!localSha || !remoteSha || !remoteRef)
77
83
  continue;
84
+ if (ZERO.test(localSha) && remoteRef.startsWith('refs/tags/')) {
85
+ findings.push({
86
+ reason: 'A1',
87
+ verdict: 'HOLD',
88
+ path: remoteRef,
89
+ message: `push deletes tag ${remoteRef.slice('refs/tags/'.length)}`,
90
+ resume: 'deleting a published tag is irreversible — the user must run it explicitly',
91
+ });
92
+ continue;
93
+ }
78
94
  if (ZERO.test(remoteSha) || ZERO.test(localSha))
79
- continue; // new branch or deletion
95
+ continue; // new ref or branch deletion
80
96
  if (!isAncestor(remoteSha, localSha, root))
81
97
  findings.push({
82
98
  reason: 'A1',
@@ -89,10 +105,10 @@ export function prePush(root, refs) {
89
105
  return findings;
90
106
  }
91
107
  /** Drift, format layer — Agent Skills spec on SKILL.md files. */
92
- export function driftFormat(root, only) {
93
- const files = findSkillFiles(SKILL_ROOTS.map((r) => join(root, r)));
94
- const chosen = only ? files.filter((f) => only.includes(relPath(root, f))) : files;
95
- return chosen.flatMap((f) => validateSkillFile(f).map((i) => ({
108
+ export function driftFormat(root, only, rd = workTreeReader(root)) {
109
+ const files = SKILL_ROOTS.flatMap((r) => rd.list(r).filter((p) => /^[^/]+\/SKILL\.md$/.test(p.slice(r.length + 1))));
110
+ const chosen = only ? files.filter((f) => only.includes(f)) : files;
111
+ return chosen.flatMap((f) => validateSkillFile(join(root, f), rd.read(f)).map((i) => ({
96
112
  reason: 'F2',
97
113
  verdict: 'STOP',
98
114
  path: relPath(root, i.path),
@@ -100,45 +116,34 @@ export function driftFormat(root, only) {
100
116
  resume: 'fix the SKILL.md frontmatter; see agentskills.io/specification',
101
117
  })));
102
118
  }
103
- /** Files the convention layer looks at: harness sources plus the installed project's agent files. */
104
- function walk(dir, out = []) {
105
- if (!existsSync(dir))
106
- return out;
107
- for (const e of readdirSync(dir)) {
108
- const p = join(dir, e);
109
- if (statSync(p).isDirectory())
110
- walk(p, out);
111
- else
112
- out.push(p);
113
- }
114
- return out;
115
- }
116
119
  /** Drift, convention layer — frontmatter schemas and role files (design §6). */
117
- export function driftConvention(root, only) {
118
- const dir = harnessDir(root);
119
- if (!dir)
120
+ export function driftConvention(root, only, rd = workTreeReader(root)) {
121
+ const hrel = harnessRel(rd);
122
+ if (!hrel)
120
123
  return [];
121
- const schemas = loadSchemas(dir);
124
+ const schemas = loadSchemasFrom(rd, hrel);
122
125
  const findings = [];
123
126
  const candidates = [
124
- ...walk(join(dir, 'templates')),
125
- ...walk(join(dir, 'knowledge-seeds')),
126
- ...walk(join(root, '.agents', 'intent')),
127
- ...walk(join(root, '.agents', 'knowledge')),
128
- ...walk(join(root, '.loctx', 'ticket')),
129
- ...walk(join(root, '.loctx', 'bus')),
127
+ ...rd.list(`${hrel}/templates`),
128
+ ...rd.list(`${hrel}/knowledge-seeds`),
129
+ ...rd.list('.agents/intent'),
130
+ ...rd.list('.agents/knowledge'),
131
+ ...rd.list('.loctx/ticket'),
132
+ ...rd.list('.loctx/bus'),
130
133
  ];
131
- for (const abs of candidates) {
132
- const rel = relPath(root, abs);
134
+ for (const rel of candidates) {
133
135
  if (only && !only.includes(rel))
134
136
  continue;
137
+ const text = rd.read(rel);
138
+ if (text === undefined)
139
+ continue;
135
140
  const m = schemaFor(rel);
136
141
  if (!m)
137
142
  continue;
138
143
  const v = schemas.get(m.schema);
139
144
  if (!v)
140
145
  continue;
141
- for (const i of validateFile(v, abs, m.whole))
146
+ for (const i of validateFile(v, join(root, rel), m.whole, text))
142
147
  findings.push({
143
148
  reason: 'F2',
144
149
  verdict: 'STOP',
@@ -148,45 +153,43 @@ export function driftConvention(root, only) {
148
153
  });
149
154
  }
150
155
  // role files: role == file name, must_not present
151
- const roles = join(dir, 'roles');
152
- if (existsSync(roles))
153
- for (const f of readdirSync(roles).filter((x) => x.endsWith('.md'))) {
154
- const rel = relPath(root, join(roles, f));
155
- if (only && !only.includes(rel))
156
- continue;
157
- const { data, error } = splitFrontmatter(readFileSync(join(roles, f), 'utf8'));
158
- const name = basename(f, '.md');
159
- if (error)
160
- findings.push({
161
- reason: 'F2',
162
- verdict: 'STOP',
163
- path: rel,
164
- message: `frontmatter is not valid YAML: ${error}`,
165
- });
166
- else if (!data || data['role'] !== name)
167
- findings.push({
168
- reason: 'F2',
169
- verdict: 'STOP',
170
- path: rel,
171
- message: `role file must declare role: ${name}`,
172
- });
173
- else if (!Array.isArray(data['must_not']) || data['must_not'].length === 0)
174
- findings.push({
175
- reason: 'F2',
176
- verdict: 'STOP',
177
- path: rel,
178
- message: 'must_not is the enforced source and cannot be empty',
179
- });
180
- }
156
+ const roles = `${hrel}/roles`;
157
+ for (const rel of rd.list(roles).filter((x) => /^[^/]+\.md$/.test(x.slice(roles.length + 1)))) {
158
+ if (only && !only.includes(rel))
159
+ continue;
160
+ const { data, error } = splitFrontmatter(rd.read(rel) ?? '');
161
+ const name = basename(rel, '.md');
162
+ if (error)
163
+ findings.push({
164
+ reason: 'F2',
165
+ verdict: 'STOP',
166
+ path: rel,
167
+ message: `frontmatter is not valid YAML: ${error}`,
168
+ });
169
+ else if (!data || data['role'] !== name)
170
+ findings.push({
171
+ reason: 'F2',
172
+ verdict: 'STOP',
173
+ path: rel,
174
+ message: `role file must declare role: ${name}`,
175
+ });
176
+ else if (!Array.isArray(data['must_not']) || data['must_not'].length === 0)
177
+ findings.push({
178
+ reason: 'F2',
179
+ verdict: 'STOP',
180
+ path: rel,
181
+ message: 'must_not is the enforced source and cannot be empty',
182
+ });
183
+ }
181
184
  return findings;
182
185
  }
183
186
  /** Files in an installed harness that belong to the project, not upstream. */
184
187
  const PROJECT_OWNED = new Set(['bindings.yaml', 'gates.yaml', 'install.yaml', 'generated.yaml']);
185
188
  /** Drift, match layer — the installed `.agents/harness/` against the packaged upstream at the pinned version (design §6). */
186
- export function driftMatch(root) {
187
- const installed = join(root, '.agents', 'harness');
188
- const pinPath = join(installed, 'install.yaml');
189
- if (!existsSync(pinPath))
189
+ export function driftMatch(root, rd = workTreeReader(root)) {
190
+ const installed = '.agents/harness';
191
+ const pinText = rd.read(`${installed}/install.yaml`);
192
+ if (pinText === undefined)
190
193
  return [];
191
194
  let up;
192
195
  try {
@@ -195,7 +198,7 @@ export function driftMatch(root) {
195
198
  catch {
196
199
  return [];
197
200
  }
198
- const pinned = parse(readFileSync(pinPath, 'utf8'));
201
+ const pinned = parse(pinText);
199
202
  const pin = pinned.version;
200
203
  const upVersion = harnessVersion(up);
201
204
  if (pin !== upVersion)
@@ -209,14 +212,14 @@ export function driftMatch(root) {
209
212
  },
210
213
  ];
211
214
  const findings = [];
212
- for (const abs of walk(installed)) {
213
- const rel = relPath(installed, abs);
215
+ for (const entry of rd.list(installed)) {
216
+ const rel = entry.slice(installed.length + 1);
214
217
  if (PROJECT_OWNED.has(rel))
215
218
  continue;
216
219
  const src = join(up, rel);
217
220
  if (!existsSync(src))
218
221
  continue;
219
- if (readFileSync(src, 'utf8') !== readFileSync(abs, 'utf8'))
222
+ if (readFileSync(src, 'utf8') !== rd.read(entry))
220
223
  findings.push({
221
224
  reason: 'F2',
222
225
  verdict: 'STOP',
@@ -228,13 +231,11 @@ export function driftMatch(root) {
228
231
  // installed skill entry points = the packaged ones
229
232
  const skillsUp = packageSkills();
230
233
  for (const name of tierSkills(pinned.tier ?? 'graph')) {
231
- const dir = join(root, '.agents', 'skills', name);
232
- if (!existsSync(dir))
234
+ const dir = `.agents/skills/${name}`;
235
+ if (rd.list(dir).length === 0)
233
236
  continue;
234
237
  for (const f of listFiles(join(skillsUp, name))) {
235
- const mine = join(dir, f);
236
- if (!existsSync(mine) ||
237
- readFileSync(mine, 'utf8') !== readFileSync(join(skillsUp, name, f), 'utf8'))
238
+ if (rd.read(`${dir}/${f}`) !== readFileSync(join(skillsUp, name, f), 'utf8'))
238
239
  findings.push({
239
240
  reason: 'F2',
240
241
  verdict: 'STOP',
@@ -246,6 +247,63 @@ export function driftMatch(root) {
246
247
  }
247
248
  return findings;
248
249
  }
250
+ /** Compare a block for drift: CRLF to LF, trailing whitespace per line, blank lines around the content. */
251
+ function normBlock(s) {
252
+ return s
253
+ .replace(/\r\n/g, '\n')
254
+ .split('\n')
255
+ .map((l) => l.replace(/\s+$/, ''))
256
+ .join('\n')
257
+ .replace(/^\n+|\n+$/g, '');
258
+ }
259
+ /** Drift, managed blocks — AGENTS.md blocks against the packaged ones at the pinned version (design §5). */
260
+ export function driftBlocks(root, rd = workTreeReader(root)) {
261
+ const text = rd.read('AGENTS.md');
262
+ if (text === undefined)
263
+ return [];
264
+ const pinText = rd.read('.agents/harness/install.yaml');
265
+ if (pinText === undefined)
266
+ return [];
267
+ let upBlocks;
268
+ try {
269
+ const up = packageHarness();
270
+ if (parse(pinText).version !== harnessVersion(up))
271
+ return []; // driftMatch warns
272
+ upBlocks = new Map(parseBlocks(readFileSync(join(up, 'templates/agents-md-blocks.md'), 'utf8')).map((b) => [
273
+ b.name,
274
+ b,
275
+ ]));
276
+ }
277
+ catch {
278
+ return [];
279
+ }
280
+ const over = overrides(text);
281
+ const findings = [];
282
+ const have = parseBlocks(text);
283
+ for (const [name, up] of upBlocks)
284
+ if (!over.has(name) && !have.some((b) => b.name === name) && !hasOwnSection(text, up))
285
+ findings.push({
286
+ reason: 'F2',
287
+ verdict: 'STOP',
288
+ path: 'AGENTS.md',
289
+ message: `managed block "${name}" is missing`,
290
+ resume: `run \`reins update\`, or add <!-- reins:override ${name} -->`,
291
+ });
292
+ for (const b of have) {
293
+ const want = upBlocks.get(b.name);
294
+ if (!want || over.has(b.name))
295
+ continue;
296
+ if (normBlock(b.body) !== normBlock(want.body))
297
+ findings.push({
298
+ reason: 'F2',
299
+ verdict: 'STOP',
300
+ path: 'AGENTS.md',
301
+ message: `managed block "${b.name}" was edited by hand`,
302
+ resume: `run \`reins update\`, or add <!-- reins:override ${b.name} -->`,
303
+ });
304
+ }
305
+ return findings;
306
+ }
249
307
  export function runCheck(opts) {
250
308
  const root = repoRoot(opts.cwd ?? process.cwd());
251
309
  const findings = [];
@@ -269,7 +327,7 @@ export function runCheck(opts) {
269
327
  else if (opts.stage === 'rc-close')
270
328
  findings.push(...rcClose(root, opts.release));
271
329
  if (opts.drift || !opts.stage)
272
- findings.push(...driftFormat(root), ...driftConvention(root), ...driftMatch(root), ...driftGenerated(root));
330
+ findings.push(...driftFormat(root), ...driftConvention(root), ...driftMatch(root), ...driftBlocks(root), ...driftGenerated(root));
273
331
  if (!currentBranch(root))
274
332
  findings.push({ reason: 'F2', verdict: 'STOP', message: 'not a git repository' });
275
333
  return report(stage, findings);
@@ -1,20 +1,12 @@
1
1
  import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { parse, stringify } from 'yaml';
4
- import { vendors } from '../lib/detect.js';
4
+ import { CONFIRMED_MODELS, checkBinding, newModelCache, vendorOf, vendors, } from '../lib/detect.js';
5
5
  import { generateVendorFiles } from '../lib/generate.js';
6
6
  import { repoRoot } from '../lib/git.js';
7
7
  import { writeGenerated } from '../lib/vendor-write.js';
8
8
  import { packageHarness } from '../lib/upstream.js';
9
9
  import { buildBindings } from './install.js';
10
- const CONFIRMED = new Set(['claude-opus-5-5', 'claude-fable-5-1']);
11
- const vendorOf = (model) => model.startsWith('gpt')
12
- ? 'openai'
13
- : model.startsWith('gemini')
14
- ? 'google'
15
- : model.startsWith('cursor')
16
- ? 'cursor'
17
- : 'claude';
18
10
  /** `reins configure bindings` (R57–R59): any role, any model, any vendor; then the vendor files follow. */
19
11
  export async function configureBindings(o) {
20
12
  const root = repoRoot(o.cwd ?? process.cwd());
@@ -26,13 +18,14 @@ export async function configureBindings(o) {
26
18
  .map((f) => f.slice(0, -3)));
27
19
  let doc = parse(readFileSync(path, 'utf8'));
28
20
  const changed = [];
21
+ const cache = o.modelCache ?? newModelCache();
29
22
  if (o.vendors?.length) {
30
23
  const vs = (o.detectVendors ?? vendors)();
31
24
  const avail = new Set([
32
25
  'claude',
33
26
  ...o.vendors.filter((v) => ['openai', 'google', 'cursor'].includes(v)),
34
27
  ]);
35
- const rebuilt = parse(buildBindings(packageHarness(), avail, vs, doc.mode ?? 'manual'));
28
+ const rebuilt = parse(buildBindings(packageHarness(), avail, vs, doc.mode ?? 'manual', cache));
36
29
  for (const r of Object.keys(rebuilt.roles))
37
30
  if (JSON.stringify(rebuilt.roles[r]) !== JSON.stringify(doc.roles[r]))
38
31
  changed.push(r);
@@ -59,7 +52,14 @@ export async function configureBindings(o) {
59
52
  const entry = { vendor: vendorOf(model), model };
60
53
  if (role === 'implementer')
61
54
  entry['parallel'] = doc.roles[role]?.['parallel'] ?? 4;
62
- if (!CONFIRMED.has(model))
55
+ const chk = checkBinding(model, entry.vendor, cache);
56
+ if (chk) {
57
+ if (chk.unverified)
58
+ entry['unverified'] = true;
59
+ if (chk.note)
60
+ entry['note'] = chk.note;
61
+ }
62
+ else if (!CONFIRMED_MODELS.has(model))
63
63
  entry['unverified'] = true;
64
64
  if (JSON.stringify(doc.roles[role]) !== JSON.stringify(entry)) {
65
65
  doc.roles[role] = entry;
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, readdirSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { parse, stringify } from 'yaml';
4
4
  import { applyBlocks, parseBlocks } from '../lib/blocks.js';
5
- import { discoverGates, generation, stacks, vendors, } from '../lib/detect.js';
5
+ import { CONFIRMED_MODELS, checkBinding, discoverGates, newModelCache, vendorOf, generation, stacks, vendors, } from '../lib/detect.js';
6
6
  import { apply, listFiles } from '../lib/fsx.js';
7
7
  import { repoRoot } from '../lib/git.js';
8
8
  import { SKILLS_INDEX_HEADER, skillsIndex, splitFrontmatter } from '../lib/skills.js';
@@ -29,10 +29,8 @@ function tierFiles(all, tier) {
29
29
  return tier === 'graph'; // roles/, schemas/
30
30
  });
31
31
  }
32
- const VENDOR_OF = (model) => model.startsWith('gpt') ? 'openai' : model.startsWith('gemini') ? 'google' : 'claude';
33
- const CONFIRMED_MODELS = new Set(['claude-opus-5-5', 'claude-fable-5-1']); // seen working in this environment
34
32
  /** bindings.yaml (design §5): defaults from role files; an unavailable vendor falls back, else to pm's model. */
35
- export function buildBindings(harness, available, vs, mode) {
33
+ export function buildBindings(harness, available, vs, mode, cache) {
36
34
  const roles = {};
37
35
  const files = readdirSync(join(harness, 'roles'))
38
36
  .filter((f) => f.endsWith('.md'))
@@ -49,14 +47,21 @@ export function buildBindings(harness, available, vs, mode) {
49
47
  for (const [role, m] of meta) {
50
48
  let model = m.def;
51
49
  let note;
52
- if (!available.has(VENDOR_OF(model))) {
53
- note = `${VENDOR_OF(model)} not available — default was ${model}`;
54
- model = m.fb && available.has(VENDOR_OF(m.fb)) ? m.fb : pm;
50
+ if (!available.has(vendorOf(model))) {
51
+ note = `${vendorOf(model)} not available — default was ${model}`;
52
+ model = m.fb && available.has(vendorOf(m.fb)) ? m.fb : pm;
55
53
  }
56
- const entry = { vendor: VENDOR_OF(model), model };
54
+ const entry = { vendor: vendorOf(model), model };
57
55
  if (role === 'implementer')
58
56
  entry['parallel'] = 4;
59
- if (!CONFIRMED_MODELS.has(model))
57
+ const chk = cache ? checkBinding(model, entry['vendor'], cache) : null;
58
+ if (chk) {
59
+ if (chk.unverified)
60
+ entry['unverified'] = true;
61
+ if (chk.note)
62
+ note = note ? `${note}; ${chk.note}` : chk.note;
63
+ }
64
+ else if (!CONFIRMED_MODELS.has(model))
60
65
  entry['unverified'] = true;
61
66
  if (note)
62
67
  entry['note'] = note;
@@ -159,7 +164,7 @@ export async function runInstall(o) {
159
164
  }
160
165
  // 3. generated configuration
161
166
  if (o.tier === 'graph' && !hasBindings)
162
- add('.agents/harness/bindings.yaml', buildBindings(up, avail, vs, o.mode), 'role ↔ model bindings');
167
+ add('.agents/harness/bindings.yaml', buildBindings(up, avail, vs, o.mode, o.modelCache ?? newModelCache()), 'role ↔ model bindings');
163
168
  add('.agents/harness/install.yaml', `# version pin and install settings (R25) — read by reins update\n${stringify({ schema: 'reins/install@1', tier: o.tier, version, mode: o.mode, language })}`, 'version pin');
164
169
  // 4. layout skeleton (design §1); never overwrite project files
165
170
  if (o.tier !== 'harness') {