@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.
Files changed (95) hide show
  1. package/README.md +50 -203
  2. package/cli/dist/commands/config-models.js +175 -126
  3. package/cli/dist/commands/config.js +96 -15
  4. package/cli/dist/commands/configure.js +165 -138
  5. package/cli/dist/commands/install.js +161 -217
  6. package/cli/dist/commands/migrate.js +23 -48
  7. package/cli/dist/commands/update.js +203 -30
  8. package/cli/dist/lib/agents-md.js +102 -0
  9. package/cli/dist/lib/bindings.js +227 -386
  10. package/cli/dist/lib/detect.js +7 -2
  11. package/cli/dist/lib/generate.js +56 -75
  12. package/cli/dist/lib/harness.js +0 -3
  13. package/cli/dist/lib/migrate-plan.js +3 -3
  14. package/cli/dist/lib/reader.js +20 -0
  15. package/cli/dist/lib/upstream.js +0 -17
  16. package/cli/dist/lib/vendor-write.js +9 -56
  17. package/cli/dist/reins.js +59 -270
  18. package/docs/README.ko.md +31 -204
  19. package/harness/CHANGELOG.md +7 -3
  20. package/harness/VERSION +1 -1
  21. package/harness/policy/common-red-lines.yaml +4 -4
  22. package/harness/roles/advisor.md +10 -14
  23. package/harness/roles/auditor.md +17 -0
  24. package/harness/roles/executor.md +32 -0
  25. package/harness/roles/implementer.md +23 -21
  26. package/harness/roles/pl.md +44 -21
  27. package/harness/roles/planner.md +17 -19
  28. package/harness/roles/pm.md +16 -21
  29. package/harness/schemas/bindings.schema.json +55 -0
  30. package/harness/schemas/install.schema.json +1 -2
  31. package/harness/schemas/intent.schema.json +1 -13
  32. package/harness/templates/agents-md-blocks.md +52 -17
  33. package/harness/templates/audit.md +25 -0
  34. package/harness/templates/history.md +14 -0
  35. package/harness/templates/intent.md +5 -0
  36. package/harness/templates/spec.md +4 -2
  37. package/package.json +1 -2
  38. package/skills/audit/SKILL.md +28 -0
  39. package/skills/implement/SKILL.md +30 -0
  40. package/skills/intent/SKILL.md +28 -0
  41. package/skills/merge/SKILL.md +26 -0
  42. package/skills/onboard/SKILL.md +29 -0
  43. package/skills/reins-setup/SKILL.md +16 -25
  44. package/skills/release/SKILL.md +26 -0
  45. package/skills/retro/SKILL.md +30 -0
  46. package/skills/review/SKILL.md +27 -0
  47. package/skills/roadmap/SKILL.md +29 -0
  48. package/skills/spec/SKILL.md +27 -0
  49. package/skills/test/SKILL.md +26 -0
  50. package/cli/dist/commands/check.js +0 -379
  51. package/cli/dist/commands/gate.js +0 -136
  52. package/cli/dist/commands/knowledge.js +0 -111
  53. package/cli/dist/commands/metrics.js +0 -138
  54. package/cli/dist/commands/new.js +0 -190
  55. package/cli/dist/commands/retro.js +0 -7
  56. package/cli/dist/commands/stages.js +0 -562
  57. package/cli/dist/commands/status.js +0 -281
  58. package/cli/dist/lib/enforcement.js +0 -125
  59. package/cli/dist/lib/memory.js +0 -96
  60. package/cli/dist/lib/metrics.js +0 -223
  61. package/cli/dist/lib/retro.js +0 -179
  62. package/cli/dist/lib/verdict.js +0 -15
  63. package/cli/dist/lib/work.js +0 -106
  64. package/cli/dist/scripts/enforcement.js +0 -24
  65. package/harness/policy/budget.yaml +0 -13
  66. package/harness/policy/enforcement.yaml +0 -98
  67. package/harness/policy/stops.yaml +0 -29
  68. package/harness/policy/transitions.yaml +0 -13
  69. package/harness/roles/code-review.md +0 -27
  70. package/harness/roles/deploy.md +0 -50
  71. package/harness/roles/docs.md +0 -19
  72. package/harness/roles/lookup.md +0 -22
  73. package/harness/roles/qa-design.md +0 -22
  74. package/harness/roles/qa-run.md +0 -19
  75. package/harness/roles/verify-tool.md +0 -21
  76. package/harness/schemas/bindings-local.schema.json +0 -21
  77. package/harness/schemas/bus-request.schema.json +0 -17
  78. package/harness/schemas/bus-response.schema.json +0 -14
  79. package/harness/schemas/enforcement.schema.json +0 -22
  80. package/harness/schemas/plan.schema.json +0 -10
  81. package/harness/schemas/ticket.schema.json +0 -15
  82. package/harness/templates/bus/request.yaml +0 -20
  83. package/harness/templates/bus/response.yaml +0 -10
  84. package/harness/templates/plan.md +0 -23
  85. package/harness/templates/ticket.md +0 -29
  86. package/skills/reins-implement/SKILL.md +0 -20
  87. package/skills/reins-intent/SKILL.md +0 -26
  88. package/skills/reins-loop/SKILL.md +0 -26
  89. package/skills/reins-loop/references/vendor-cli.md +0 -41
  90. package/skills/reins-release/SKILL.md +0 -18
  91. package/skills/reins-retro/SKILL.md +0 -20
  92. package/skills/reins-review/SKILL.md +0 -23
  93. package/skills/reins-roadmap/SKILL.md +0 -17
  94. package/skills/reins-spec/SKILL.md +0 -22
  95. package/skills/reins-test/SKILL.md +0 -18
@@ -1,6 +1,5 @@
1
1
  import { execFileSync, spawnSync } from 'node:child_process';
2
2
  import { existsSync, readFileSync, readdirSync } from 'node:fs';
3
- import { compound } from '../commands/gate.js';
4
3
  import { join } from 'node:path';
5
4
  export function generation(root) {
6
5
  const agents = join(root, 'AGENTS.md');
@@ -34,7 +33,9 @@ export function vendors() {
34
33
  return [
35
34
  { name: 'claude', cli: 'claude', detected: onPath('claude') },
36
35
  { name: 'openai', cli: 'codex', detected: onPath('codex') },
37
- { name: 'google', cli: 'agy', detected: onPath('agy') || onPath('gemini') },
36
+ { name: 'google', cli: 'agy', detected: onPath('agy') },
37
+ { name: 'gemini', cli: 'gemini', detected: onPath('gemini') },
38
+ { name: 'copilot', cli: 'copilot', detected: onPath('copilot') },
38
39
  { name: 'cursor', cli: 'cursor-agent', detected: onPath('cursor-agent') },
39
40
  ];
40
41
  }
@@ -306,3 +307,7 @@ export function checkBinding(model, vendor, cache) {
306
307
  cache.warn(`${model} is not in \`${cli} models\` — recorded as unverified`);
307
308
  return { unverified: true, note: `not in ${cli} models` };
308
309
  }
310
+ /** A command with a pipe, list, redirect or substitution: a gate must be one plain command. */
311
+ export function compound(cmd) {
312
+ return /[|;&<>`]|\$\(/.test(cmd.replace(/'[^']*'|"[^"]*"/g, ''));
313
+ }
@@ -1,69 +1,63 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { parse, stringify } from 'yaml';
3
3
  import { workTreeReader } from './reader.js';
4
- import { FIXED_ROLES } from './bindings.js';
5
- import { vendorOf } from './detect.js';
4
+ import { resolveRoles } from './bindings.js';
5
+ import { agentName, claudeAgents } from './agents-md.js';
6
6
  import { splitFrontmatter } from './skills.js';
7
7
  /**
8
- * Vendor files generated from `.agents/harness/` (design §6). Round one generates Claude Code only:
9
- * `.claude/agents/reins-<role>.md` for roles bound to Claude, and `.claude/settings.json` deny rules.
8
+ * Files generated from `.agents/harness/` (design §6): `.claude/agents/rs-<group>-<role>.md` for roles
9
+ * switched on in multi mode on a Claude model, the `.claude/skills/` copy, and `.claude/settings.json` deny
10
+ * rules. Generated from the committed team file only, so no personal override makes drift.
10
11
  */
11
12
  export const MANIFEST = '.agents/harness/generated.yaml';
12
13
  export const sha = (s) => createHash('sha256').update(s).digest('hex').slice(0, 16);
13
- function readRole(text) {
14
+ export function readGroup(text) {
14
15
  const { data, body } = splitFrontmatter(text);
15
16
  const d = data ?? {};
16
17
  return {
17
- role: String(d['role']),
18
+ group: String(d['group']),
18
19
  summary: String(d['summary'] ?? ''),
19
- may: d['may'] ?? [],
20
- mustNot: d['must_not'] ?? [],
21
- capabilities: d['capabilities'] ?? {},
22
- fallback: typeof d['fallback_binding'] === 'string' ? d['fallback_binding'] : undefined,
20
+ roles: d['roles'] ?? {},
23
21
  body: body.trim(),
24
22
  };
25
23
  }
26
- /** Capabilities → Claude Code tool names to withhold. Path-level limits are not expressible here; T2 (C10) is the backstop. */
27
- function disallowed(c) {
24
+ /** Tool permissions → Claude Code tools to withhold. A push cannot be withheld by tool; it stays a must_not. */
25
+ function disallowed(t) {
28
26
  const out = [];
29
- if (c.write === false)
27
+ if (t.write === false)
30
28
  out.push('Edit', 'Write', 'NotebookEdit');
31
- if (c.shell === false)
29
+ if (t.shell === false)
32
30
  out.push('Bash');
33
31
  return out;
34
32
  }
35
- export function claudeAgent(r, b, version, fallbackFor) {
33
+ export function claudeAgent(g, role, model, version, name = agentName(g.group, role)) {
34
+ const r = g.roles[role];
36
35
  const fm = {
37
- name: `reins-${r.role}`,
38
- description: `reins ${r.role} role. ${r.summary}`,
39
- model: b.model,
36
+ name,
37
+ description: `${g.group}/${role}: ${r.does}`,
38
+ model,
40
39
  };
41
- const dis = disallowed(r.capabilities);
40
+ const dis = disallowed(r.tools ?? {});
42
41
  if (dis.length)
43
42
  fm['disallowedTools'] = dis.join(', ');
44
43
  return [
45
44
  '---',
46
45
  stringify(fm).trimEnd(),
47
46
  '---',
48
- `<!-- generated by reins ${version} from .agents/harness/roles/${r.role}.md and bindings.yaml — do not edit; run \`reins update\` -->`,
49
- ...(fallbackFor
50
- ? [`<!-- fallback for ${fallbackFor} — the team binds this role to another vendor -->`]
51
- : []),
47
+ `<!-- generated by reins ${version} from .agents/harness/roles/${g.group}.md and bindings.yaml — do not edit -->`,
52
48
  '',
53
- `You are the **${r.role}** role of the reins harness in this repository. ${r.summary}`,
49
+ `You are **${g.group}/${role}** in this repository. ${r.does}`,
54
50
  '',
55
- '## You must never',
56
- ...r.mustNot.map((m) => `- ${m}`),
57
- '- break any common red line in `.agents/harness/policy/common-red-lines.yaml` (C1–C10)',
51
+ 'The PM gave you a task and the files and decisions you need. Mark any assumption beyond them. Return your result with its evidence (file:line, commit, raw log path) to the PM; never call another model.',
58
52
  '',
59
- '## You may',
60
- ...r.may.map((m) => `- ${m}`),
53
+ '## You must not',
54
+ ...r.must_not.map((m) => `- ${m}`),
55
+ ...(r.tools?.push === false ? ['- push, open PRs, merge, release or tag'] : []),
56
+ '- do anything in `.agents/harness/policy/common-red-lines.yaml`',
61
57
  '',
62
- '## Procedure',
58
+ '## How',
63
59
  '',
64
- r.body.replace(/^# .*\n+/, ''),
65
- '',
66
- 'When a stop condition in `.agents/harness/policy/stops.yaml` applies, stop and report its id. `reins check` is the verifier.',
60
+ g.body.replace(/^# .*\n+/, ''),
67
61
  '',
68
62
  ].join('\n');
69
63
  }
@@ -89,7 +83,7 @@ export function denyRules(lines) {
89
83
  for (const g of globs)
90
84
  for (const t of ['Read', 'Edit'])
91
85
  rules.push(`${t}(${g.startsWith('**/') ? g : `**/${g}`})`);
92
- // A1 force push and C5 hook bypass: the user runs these explicitly, never an agent
86
+ // force push and hook bypass: the user runs these explicitly, never an agent
93
87
  rules.push('Bash(git push --force *)', 'Bash(git push -f *)', 'Bash(git push --force-with-lease *)', 'Bash(git commit --no-verify *)', 'Bash(git commit -n *)', 'Bash(git push --no-verify *)');
94
88
  return rules;
95
89
  }
@@ -97,50 +91,37 @@ export function denyRules(lines) {
97
91
  export function generateVendorFiles(root, rd = workTreeReader(root)) {
98
92
  const harness = '.agents/harness';
99
93
  const version = rd.read(`${harness}/VERSION`)?.trim() ?? '?';
100
- const out = { writes: [], skipped: [] };
94
+ const out = { writes: [] };
101
95
  if (rd.list(harness).length === 0)
102
96
  return out;
103
- const bindingsText = rd.read(`${harness}/bindings.yaml`);
104
- const bindings = bindingsText
105
- ? (parse(bindingsText).roles ?? {})
106
- : {};
107
- const rolesDir = `${harness}/roles`;
108
- for (const p of rd
109
- .list(rolesDir)
110
- .filter((x) => /^[^/]+\.md$/.test(x.slice(rolesDir.length + 1)))
111
- .toSorted()) {
112
- const r = readRole(rd.read(p) ?? '');
113
- const b = bindings[r.role];
114
- if (!b)
115
- continue;
116
- // a role the team switched off gets no agent file (fixed roles cannot be off); the local file never counts
117
- if (b.enabled === false && !FIXED_ROLES.includes(r.role))
118
- continue;
119
- // Committed team defaults only (never the local file), so no user's override makes drift.
120
- // A role bound to another vendor still gets a Claude file on its fallback model, else pm's.
121
- let model = b.model;
122
- let fallbackFor;
123
- if (b.vendor !== 'claude') {
124
- const pm = bindings['pm'];
125
- const fb = r.fallback && vendorOf(r.fallback) === 'claude'
126
- ? r.fallback
127
- : pm && pm.vendor === 'claude'
128
- ? pm.model
129
- : undefined;
130
- if (!fb) {
131
- out.skipped.push(`${r.role} → ${b.vendor} ${b.model}`);
132
- continue;
97
+ const text = rd.read(`${harness}/bindings.yaml`);
98
+ const doc = text ? parse(text) : null;
99
+ if (doc?.schema === 'reins/bindings@2') {
100
+ const groups = new Map();
101
+ for (const r of resolveRoles(doc).filter((x) => x.on)) {
102
+ const agents = claudeAgents(r);
103
+ if (!agents.length)
104
+ continue; // other vendors are called through the delegation table
105
+ let g = groups.get(r.group);
106
+ if (!g) {
107
+ const src = rd.read(`${harness}/roles/${r.group}.md`);
108
+ if (src === undefined)
109
+ continue;
110
+ g = readGroup(src);
111
+ groups.set(r.group, g);
133
112
  }
134
- model = fb;
135
- fallbackFor = b.vendor;
113
+ const role = r.group === 'auditor' ? 'auditor' : r.role;
114
+ if (!g.roles[role])
115
+ continue;
116
+ for (const a of agents)
117
+ out.writes.push({
118
+ path: `.claude/agents/${a.name}.md`,
119
+ content: claudeAgent(g, role, a.model, version, a.name),
120
+ why: `role ${r.group}/${role} on ${a.model}`,
121
+ });
136
122
  }
137
- out.writes.push({
138
- path: `.claude/agents/reins-${r.role}.md`,
139
- content: claudeAgent(r, { vendor: 'claude', model }, version, fallbackFor),
140
- why: fallbackFor ? `role ${r.role} (fallback for ${fallbackFor})` : `role ${r.role}`,
141
- });
142
123
  }
143
- // skills: Codex, Gemini and Cursor read .agents/skills/ directly; Claude Code reads a byte-identical copy
124
+ // skills: other agents read .agents/skills/ directly; Claude Code reads a byte-identical copy
144
125
  const skills = '.agents/skills';
145
126
  const names = [
146
127
  ...new Set(rd.list(skills).map((p) => p.slice(skills.length + 1).split('/')[0] ?? '')),
@@ -156,11 +137,11 @@ export function generateVendorFiles(root, rd = workTreeReader(root)) {
156
137
  });
157
138
  }
158
139
  const redText = rd.read(`${harness}/policy/common-red-lines.yaml`);
159
- if (rd.list(`${harness}/policy`).length > 0 && redText !== undefined)
140
+ if (redText !== undefined)
160
141
  out.writes.push({
161
142
  path: '.claude/settings.json',
162
143
  content: `${JSON.stringify({ $schema: 'https://json.schemastore.org/claude-code-settings.json', permissions: { deny: denyRules(parse(redText).rules) } }, null, 2)}\n`,
163
- why: 'C4 secrets, A1 force push, C5 hook bypass',
144
+ why: 'secrets, force push, hook bypass',
164
145
  });
165
146
  return out;
166
147
  }
@@ -26,9 +26,6 @@ export function readYaml(path) {
26
26
  export function redLines(dir) {
27
27
  return readYaml(join(dir, 'policy', 'common-red-lines.yaml')).rules;
28
28
  }
29
- export function stops(dir) {
30
- return readYaml(join(dir, 'policy', 'stops.yaml')).stops;
31
- }
32
29
  /** Secret patterns from red line C4, or null when there is no harness to read. */
33
30
  export function secretPolicy(root, rd = workTreeReader(root)) {
34
31
  const rel = harnessRel(rd);
@@ -48,7 +48,7 @@ function workItem(root, path, dir) {
48
48
  function existingTickets(root) {
49
49
  const list = [];
50
50
  let max = 0;
51
- const dir = '.loctx/ticket';
51
+ const dir = '.loctx/context/migrated-work';
52
52
  for (const f of existsSync(join(root, dir)) ? readdirSync(join(root, dir)) : []) {
53
53
  const m = /^000-(\d+)_/.exec(f);
54
54
  if (!m)
@@ -108,7 +108,7 @@ function planTickets(root, ai, files, moves) {
108
108
  from: it.path,
109
109
  to: '',
110
110
  action: 'ticket',
111
- why: 'open work item → ticket',
111
+ why: 'open work item → intent 000 plan',
112
112
  group: it.group,
113
113
  };
114
114
  if (was)
@@ -116,7 +116,7 @@ function planTickets(root, ai, files, moves) {
116
116
  else {
117
117
  next += 1;
118
118
  m.n = next;
119
- m.to = `.loctx/ticket/000-${next}_${slugOf(it.path)}.md`;
119
+ m.to = `.loctx/context/migrated-work/000-${next}_${slugOf(it.path)}.md`;
120
120
  numberOf.set(it.path, `000-${next}`);
121
121
  }
122
122
  moves.push(m);
@@ -45,3 +45,23 @@ export function indexReader(root) {
45
45
  .filter(Boolean),
46
46
  };
47
47
  }
48
+ /**
49
+ * The working tree as it will be once `writes` land and `deletes` go: a dry run plans the generated
50
+ * files from this, so its preview matches the real run (design §6).
51
+ */
52
+ export function overlayReader(base, writes, deletes = []) {
53
+ const added = new Map(writes.map((w) => [w.path, w.content]));
54
+ // a deleted path takes everything under it (update deletes whole skill folders)
55
+ const isGone = (rel) => deletes.some((d) => rel === d || rel.startsWith(`${d}/`));
56
+ return {
57
+ read: (rel) => (isGone(rel) ? undefined : (added.get(rel) ?? base.read(rel))),
58
+ list: (relDir) => {
59
+ const dir = `${relDir.replace(/\/$/, '')}/`;
60
+ const all = new Set(base.list(relDir));
61
+ for (const p of added.keys())
62
+ if (p.startsWith(dir))
63
+ all.add(p);
64
+ return [...all].filter((p) => !isGone(p));
65
+ },
66
+ };
67
+ }
@@ -23,20 +23,3 @@ export function harnessVersion(dir) {
23
23
  export function packageSkills() {
24
24
  return join(packageHarness(), '..', 'skills');
25
25
  }
26
- /** Which packaged skills a tier installs: the harness tier has no loop to run. */
27
- export function tierSkills(tier) {
28
- return tier === 'harness'
29
- ? ['reins-setup']
30
- : [
31
- 'reins-setup',
32
- 'reins-roadmap',
33
- 'reins-intent',
34
- 'reins-spec',
35
- 'reins-implement',
36
- 'reins-review',
37
- 'reins-test',
38
- 'reins-release',
39
- 'reins-retro',
40
- 'reins-loop',
41
- ];
42
- }
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
3
  import { parse, stringify } from 'yaml';
4
- import { MANIFEST, generateVendorFiles, sha } from './generate.js';
4
+ import { MANIFEST, sha } from './generate.js';
5
5
  import { workTreeReader } from './reader.js';
6
6
  export function readManifest(root, rd = workTreeReader(root)) {
7
7
  const text = rd.read(MANIFEST);
@@ -11,16 +11,16 @@ export function readManifest(root, rd = workTreeReader(root)) {
11
11
  return { schema: 'reins/generated@1', files: m?.files ?? {} };
12
12
  }
13
13
  /**
14
- * Write generated vendor files without trampling anyone (design §6, red line C3):
15
- * reins overwrites only what it wrote and nobody touched since; a file it never wrote is left alone.
14
+ * Write generated files without trampling anyone (design §6): reins overwrites only what it wrote and
15
+ * nobody touched since; a hand-edited one is refused (listed) unless `force`; a file it never wrote is
16
+ * always left alone.
16
17
  */
17
- export function writeGenerated(root, gen, dryRun) {
18
+ export function writeGenerated(root, gen, dryRun, force = false) {
18
19
  const res = {
19
20
  written: [],
20
21
  removed: [],
21
22
  unchanged: [],
22
23
  refused: [],
23
- skipped: gen.skipped,
24
24
  };
25
25
  const before = readManifest(root).files;
26
26
  const after = {};
@@ -42,7 +42,7 @@ export function writeGenerated(root, gen, dryRun) {
42
42
  res.unchanged.push(w.path);
43
43
  after[w.path] = next;
44
44
  }
45
- else if (before[w.path] === disk) {
45
+ else if (before[w.path] === disk || (force && before[w.path])) {
46
46
  if (!dryRun)
47
47
  writeFileSync(abs, w.content);
48
48
  res.written.push(w.path);
@@ -52,7 +52,7 @@ export function writeGenerated(root, gen, dryRun) {
52
52
  res.refused.push({
53
53
  path: w.path,
54
54
  why: before[w.path]
55
- ? 'edited by hand since reins generated it (C3) — move the change into .agents/harness and run `reins update`'
55
+ ? 'edited by hand since reins generated it — keep the change in .agents/harness, or run `reins update --force` to overwrite it'
56
56
  : 'exists and was not generated by reins — merge it by hand, or delete it and run `reins update`',
57
57
  });
58
58
  const prior = before[w.path];
@@ -60,14 +60,14 @@ export function writeGenerated(root, gen, dryRun) {
60
60
  after[w.path] = prior;
61
61
  }
62
62
  }
63
- // files reins wrote earlier that are no longer generated (a role re-bound to another vendor)
63
+ // files reins wrote earlier that are no longer generated (a group switched off, a role moved to another vendor)
64
64
  for (const [path, hash] of Object.entries(before)) {
65
65
  if (wanted.has(path))
66
66
  continue;
67
67
  const abs = join(root, path);
68
68
  if (!existsSync(abs))
69
69
  continue;
70
- if (sha(readFileSync(abs, 'utf8')) === hash) {
70
+ if (sha(readFileSync(abs, 'utf8')) === hash || force) {
71
71
  if (!dryRun)
72
72
  unlinkSync(abs);
73
73
  res.removed.push(path);
@@ -87,50 +87,3 @@ export function writeGenerated(root, gen, dryRun) {
87
87
  }
88
88
  return res;
89
89
  }
90
- /** Drift, match layer for generated files: on disk = what reins wrote = what it would write now. */
91
- export function driftGenerated(root, rd = workTreeReader(root)) {
92
- if (rd.read(MANIFEST) === undefined)
93
- return [];
94
- const findings = [];
95
- const recorded = readManifest(root, rd).files;
96
- const now = new Map(generateVendorFiles(root, rd).writes.map((w) => [w.path, sha(w.content)]));
97
- for (const [path, hash] of Object.entries(recorded)) {
98
- const onDisk = rd.read(path);
99
- if (onDisk === undefined) {
100
- findings.push({
101
- reason: 'F2',
102
- verdict: 'STOP',
103
- path,
104
- message: 'generated file is missing',
105
- resume: 'run `reins update`',
106
- });
107
- continue;
108
- }
109
- if (sha(onDisk) !== hash)
110
- findings.push({
111
- reason: 'C3',
112
- verdict: 'STOP',
113
- path,
114
- message: 'generated file was edited by hand',
115
- resume: 'change .agents/harness instead, then `reins update`',
116
- });
117
- else if (now.has(path) && now.get(path) !== hash)
118
- findings.push({
119
- reason: 'F2',
120
- verdict: 'STOP',
121
- path,
122
- message: 'stale — the harness changed since it was generated',
123
- resume: 'run `reins update`',
124
- });
125
- }
126
- for (const path of now.keys())
127
- if (!(path in recorded) && !existsSync(join(root, path)))
128
- findings.push({
129
- reason: 'F2',
130
- verdict: 'STOP',
131
- path,
132
- message: 'should be generated but is not',
133
- resume: 'run `reins update`',
134
- });
135
- return findings;
136
- }