@bluenyang/reins 0.1.4 → 0.1.5-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 +84 -6
- package/cli/dist/commands/check.js +1 -1
- package/cli/dist/commands/configure.js +32 -5
- package/cli/dist/commands/gate.js +1 -1
- package/cli/dist/commands/install.js +7 -5
- package/cli/dist/commands/knowledge.js +1 -1
- package/cli/dist/commands/migrate.js +3 -2
- package/cli/dist/commands/new.js +3 -6
- package/cli/dist/commands/stages.js +70 -10
- package/cli/dist/commands/status.js +8 -0
- package/cli/dist/commands/update.js +1 -1
- package/cli/dist/lib/bindings.js +167 -0
- package/cli/dist/lib/enforcement.js +125 -0
- package/cli/dist/lib/fsx.js +16 -2
- package/cli/dist/lib/generate.js +24 -5
- package/cli/dist/lib/git.js +2 -2
- package/cli/dist/lib/metrics.js +1 -1
- package/cli/dist/lib/release.js +48 -0
- package/cli/dist/lib/retro.js +1 -1
- package/cli/dist/reins.js +21 -4
- package/cli/dist/scripts/enforcement.js +24 -0
- package/cli/dist/scripts/sync-version.js +2 -2
- package/docs/README.ko.md +83 -6
- package/harness/policy/enforcement.yaml +98 -0
- package/harness/roles/deploy.md +5 -1
- package/harness/schemas/bindings-local.schema.json +20 -0
- package/harness/schemas/enforcement.schema.json +22 -0
- package/harness/schemas/install.schema.json +11 -1
- package/package.json +7 -3
- package/skills/reins-loop/SKILL.md +2 -0
- package/skills/reins-loop/references/vendor-cli.md +1 -0
- package/skills/reins-release/SKILL.md +2 -1
- package/skills/reins-setup/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -14,10 +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.
|
|
17
|
+
Version 0.1.4 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
|
-
carved out of it in 0.2.
|
|
20
|
-
|
|
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
|
+
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
|
|
23
|
+
changed in each version is in [CHANGELOG.md](CHANGELOG.md); what comes next is in the roadmap.
|
|
21
24
|
|
|
22
25
|
reins develops itself through its own loop: intents 001 (`reins status`), 002 (`reins metrics`) and
|
|
23
26
|
003 (violation scenarios) each went intent → spec → plan → tickets, with the checks at T1 to T5
|
|
@@ -46,10 +49,12 @@ separation is not model separation: every role can run on one model, and `bindin
|
|
|
46
49
|
vendor and model per role. By design, a role bound to a vendor that is not detected falls back to its
|
|
47
50
|
fallback, else to the pm model, so all twelve roles can run on Claude alone.
|
|
48
51
|
|
|
49
|
-
**Red lines.** Ten rules (C1–C10) apply to every role
|
|
52
|
+
**Red lines.** Ten rules (C1–C10) apply to every role, for
|
|
50
53
|
example: no implementing "to pass" (C1), no editing managed blocks, policy or roles (C2), no
|
|
51
54
|
editing one's own permission file (C3), no reading secrets (C4), no bypassing hooks (C5), and no
|
|
52
|
-
push, PR, merge or release outside the deploy role (C6). The list is in [docs/design.md](docs/design.md) section 2.
|
|
55
|
+
push, PR, merge or release outside the deploy role (C6). The list is in [docs/design.md](docs/design.md) section 2. How
|
|
56
|
+
each rule is actually held is in [Enforced versus advised](#enforced-versus-advised) below: some are blocked, some are checked at a
|
|
57
|
+
transition, and some are only written in a role or skill.
|
|
53
58
|
|
|
54
59
|
**The verifier.** `reins check` runs at transition points and prints one verdict. It does not call
|
|
55
60
|
a model; roles write their judgement to a handoff file and the verifier applies it.
|
|
@@ -78,6 +83,79 @@ reviewed by roles. Verification output is pasted as produced; a bare "passed" is
|
|
|
78
83
|
| `.claude/` | yes | generated from `.agents/`; do not edit |
|
|
79
84
|
| `.loctx/` | no (gitignored) | tickets, reports, handoff `bus/`, `history/`, local roadmap |
|
|
80
85
|
|
|
86
|
+
## Enforced versus advised
|
|
87
|
+
|
|
88
|
+
Not every rule is enforced. Each one is held in one of three ways, and `harness/policy/enforcement.yaml` says which, one line per rule.
|
|
89
|
+
|
|
90
|
+
- **blocked**: a script, hook or permission deny stops the action before it happens.
|
|
91
|
+
- **checked**: a transition check, the drift check or CI catches it afterwards.
|
|
92
|
+
- **advised**: it is written in a role or skill only; nothing in code catches it.
|
|
93
|
+
|
|
94
|
+
The grade is the strongest part that really holds, and the `gap` column says what is left open. Hooks apply only when they are installed, and deny rules and agent tool limits exist for Claude Code only. Rule ids are in [docs/design.md](docs/design.md) sections 2 and 3, and the evidence is in [docs/violations.md](docs/violations.md). The advised rules are the input for [0.2](docs/ROADMAP.md).
|
|
95
|
+
|
|
96
|
+
<!-- enforcement:begin -->
|
|
97
|
+
| id | held | by | gap |
|
|
98
|
+
|---|---|---|---|
|
|
99
|
+
| C1 | advised | `role` | judged by reviewers only; nothing detects a hard-coded pass |
|
|
100
|
+
| C2 | blocked | `hook:pre-commit`, `check:drift` | only when the hook is installed; the edit itself is not prevented |
|
|
101
|
+
| C3 | blocked | `hook:pre-commit`, `check:drift` | only when the hook is installed; no deny rule covers .claude/settings.json itself |
|
|
102
|
+
| C4 | blocked | `deny`, `hook:pre-commit` | Claude Code only; .env.* is a finite list, so names such as .env.custom have no deny rule; the hook sees staged paths, not reads |
|
|
103
|
+
| C5 | blocked | `deny`, `gate`, `check:verdict` | combined or later-position forms such as git commit -nm are not denied |
|
|
104
|
+
| C6 | advised | `role` | pre-push holds pushes to the default branch (A4) and the deny rules stop force and --no-verify pushes; any other push, PR, merge, release or tag is not blocked |
|
|
105
|
+
| C7 | advised | `role` | — |
|
|
106
|
+
| C8 | advised | `role` | — |
|
|
107
|
+
| C9 | advised | `role` | — |
|
|
108
|
+
| C10 | advised | `role` | T2 lists it but the pre-commit check does not compare the diff with plan.md |
|
|
109
|
+
| A1 | blocked | `deny`, `hook:pre-push` | moving a published tag forward to a descendant passes the ancestry test |
|
|
110
|
+
| A2 | advised | `role` | — |
|
|
111
|
+
| A3 | advised | `role` | — |
|
|
112
|
+
| A4 | blocked | `hook:pre-push` | only a push to the default branch is held; other ways of leaving the machine are not detected |
|
|
113
|
+
| B1 | checked | `check:ticket-start` | — |
|
|
114
|
+
| B2 | advised | `role` | — |
|
|
115
|
+
| B3 | advised | `role`, `check:ticket-start` | the scope conflict is a role's judgement; ticket-start checks only the approval chain |
|
|
116
|
+
| B4 | advised | `role` | — |
|
|
117
|
+
| B5 | advised | `role` | — |
|
|
118
|
+
| P1 | advised | `role` | — |
|
|
119
|
+
| P2 | checked | `check:ticket-start`, `check:rc-close` | only ticket-in-plan; a diff is not compared with plan.md |
|
|
120
|
+
| D1 | checked | `check:verdict` | does not tell a ticket before rc.1 from an rc after |
|
|
121
|
+
| D2 | advised | `role` | no memory across runs |
|
|
122
|
+
| D3 | advised | `role` | no alone-versus-full-run comparison |
|
|
123
|
+
| D4 | blocked | `gate`, `check:verdict` | an empty gate output is only a WARN |
|
|
124
|
+
| D5 | checked | `check:verdict` | — |
|
|
125
|
+
| E1 | advised | `role` | nothing reads a budget or a token count |
|
|
126
|
+
| E2 | advised | `role` | nothing reads a budget or a token count |
|
|
127
|
+
| E3 | advised | `role` | T5 lists it but nothing reads a budget or a token count |
|
|
128
|
+
| F1 | advised | `role` | the deny rules stop some attempts in Claude Code, but no stop is recorded |
|
|
129
|
+
| F2 | blocked | `hook:pre-commit`, `check:drift`, `check:ticket-start`, `check:rc-close` | — |
|
|
130
|
+
| F3 | advised | `role` | — |
|
|
131
|
+
| G1 | advised | `role` | no signal handler and no resume record on an interrupt |
|
|
132
|
+
| G2 | advised | `role` | — |
|
|
133
|
+
| T1 | checked | `check:ticket-start` | budget-left is not implemented |
|
|
134
|
+
| T2 | blocked | `hook:pre-commit` | only when the hook is installed; the P2 and C10 diff checks do not exist |
|
|
135
|
+
| T3 | checked | `check:verdict` | — |
|
|
136
|
+
| T4 | blocked | `hook:pre-push` | implements A1 and the default-branch push (A4); A2, A3, C6 and the loop-step check do not exist |
|
|
137
|
+
| T5 | checked | `check:rc-close` | E3 is not implemented |
|
|
138
|
+
| T6 | advised | `role` | no code runs on an interrupt or a violation signal |
|
|
139
|
+
|
|
140
|
+
| role | blocked | checked | advised | blocked items |
|
|
141
|
+
|---|---|---|---|---|
|
|
142
|
+
| advisor | 0 | 0 | 2 | — |
|
|
143
|
+
| code-review | 1 | 0 | 2 | edit code |
|
|
144
|
+
| deploy | 1 | 0 | 2 | force-push, delete or move tags, rewrite main |
|
|
145
|
+
| docs | 0 | 0 | 3 | — |
|
|
146
|
+
| implementer | 0 | 0 | 5 | — |
|
|
147
|
+
| lookup | 3 | 0 | 0 | write any file; produce reports or context files; run gates or tests |
|
|
148
|
+
| planner | 0 | 0 | 3 | — |
|
|
149
|
+
| pl | 0 | 0 | 3 | — |
|
|
150
|
+
| pm | 0 | 1 | 2 | — |
|
|
151
|
+
| qa-design | 0 | 0 | 3 | — |
|
|
152
|
+
| qa-run | 0 | 0 | 2 | — |
|
|
153
|
+
| verify-tool | 0 | 2 | 1 | — |
|
|
154
|
+
| budget scopes | 0 | 0 | 6 | — |
|
|
155
|
+
<!-- enforcement:end -->
|
|
156
|
+
|
|
157
|
+
The tables are rendered by `pnpm docs:enforcement` and a test keeps them equal to the YAML.
|
|
158
|
+
|
|
81
159
|
## Quick start
|
|
82
160
|
|
|
83
161
|
In Claude Code, install the plugin and let it set the repository up:
|
|
@@ -88,7 +166,7 @@ In Claude Code, install the plugin and let it set the repository up:
|
|
|
88
166
|
/reins:reins-setup
|
|
89
167
|
```
|
|
90
168
|
|
|
91
|
-
For Codex, Antigravity, Cursor or a plain terminal, use the CLI. It requires Node
|
|
169
|
+
For Codex, Antigravity, Cursor or a plain terminal, use the CLI. It requires Node 22 or later. Run it from the root of the repository you want to set up; the repository
|
|
92
170
|
needs at least one commit (`check` fails on an empty history in 0.1.0):
|
|
93
171
|
|
|
94
172
|
```sh
|
|
@@ -370,7 +370,7 @@ export function runCheck(opts) {
|
|
|
370
370
|
: verdictCheck(root, opts.ticket)));
|
|
371
371
|
}
|
|
372
372
|
else if (opts.stage === 'rc-close')
|
|
373
|
-
findings.push(...rcClose(root, opts.release));
|
|
373
|
+
findings.push(...rcClose(root, opts.release, opts.stable));
|
|
374
374
|
if (opts.drift || !opts.stage)
|
|
375
375
|
findings.push(...driftFormat(root), ...driftConvention(root), ...driftMatch(root), ...driftBlocks(root), ...driftGenerated(root));
|
|
376
376
|
if (!currentBranch(root))
|
|
@@ -2,6 +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
6
|
import { generateVendorFiles } from '../lib/generate.js';
|
|
6
7
|
import { repoRoot } from '../lib/git.js';
|
|
7
8
|
import { writeGenerated } from '../lib/vendor-write.js';
|
|
@@ -19,8 +20,37 @@ export async function configureBindings(o) {
|
|
|
19
20
|
let doc = parse(readFileSync(path, 'utf8'));
|
|
20
21
|
const changed = [];
|
|
21
22
|
const cache = o.modelCache ?? newModelCache();
|
|
23
|
+
const detect = o.detectVendors ?? vendors;
|
|
24
|
+
const teamTable = () => Object.entries(doc.roles)
|
|
25
|
+
.map(([role, b]) => ({ role, vendor: b.vendor, model: b.model }))
|
|
26
|
+
.toSorted((a, b) => a.role.localeCompare(b.role));
|
|
27
|
+
if (o.show)
|
|
28
|
+
return { changed, table: teamTable(), resolved: resolveBindings(root, detect) };
|
|
29
|
+
if (o.local) {
|
|
30
|
+
// per-user overrides: roles only; the team file and generated files stay untouched
|
|
31
|
+
const local = readLocal(root);
|
|
32
|
+
for (const pair of o.set ?? []) {
|
|
33
|
+
const [role, model] = pair.split('=').map((s) => s.trim());
|
|
34
|
+
if (!role || !model)
|
|
35
|
+
return { refused: `"${pair}" is not role=model`, changed: [], table: [] };
|
|
36
|
+
if (!roles.has(role))
|
|
37
|
+
return {
|
|
38
|
+
refused: `unknown role "${role}" — roles: ${[...roles].toSorted().join(', ')}`,
|
|
39
|
+
changed: [],
|
|
40
|
+
table: [],
|
|
41
|
+
};
|
|
42
|
+
if (local.roles[role]?.model !== model) {
|
|
43
|
+
local.roles[role] = { model };
|
|
44
|
+
changed.push(role);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (changed.length)
|
|
48
|
+
writeLocal(root, local);
|
|
49
|
+
return { changed, table: teamTable(), resolved: resolveBindings(root, detect) };
|
|
50
|
+
}
|
|
22
51
|
if (o.vendors?.length) {
|
|
23
|
-
const vs = (
|
|
52
|
+
const vs = detect();
|
|
53
|
+
recordDetection(root, vs);
|
|
24
54
|
const avail = new Set([
|
|
25
55
|
'claude',
|
|
26
56
|
...o.vendors.filter((v) => ['openai', 'google', 'cursor'].includes(v)),
|
|
@@ -72,10 +102,7 @@ export async function configureBindings(o) {
|
|
|
72
102
|
const generated = changed.length
|
|
73
103
|
? writeGenerated(root, generateVendorFiles(root), false)
|
|
74
104
|
: undefined;
|
|
75
|
-
|
|
76
|
-
.map(([role, b]) => ({ role, vendor: b.vendor, model: b.model }))
|
|
77
|
-
.toSorted((a, b) => a.role.localeCompare(b.role));
|
|
78
|
-
return { changed, table, generated };
|
|
105
|
+
return { changed, table: teamTable(), generated, resolved: resolveBindings(root, detect) };
|
|
79
106
|
}
|
|
80
107
|
/** `reins configure gates [--add <name>…]` (spec S-7): subdirectory proposals, appended after the existing gates. */
|
|
81
108
|
export function configureGates(o = {}) {
|
|
@@ -56,7 +56,7 @@ export function runGates(o) {
|
|
|
56
56
|
}
|
|
57
57
|
/** One line per failing gate for stdout: the first failure signature and the first file:line in the raw report. */
|
|
58
58
|
export function failureSummary(report) {
|
|
59
|
-
const lines = report.split(
|
|
59
|
+
const lines = report.split(/\r?\n/).filter((l) => l.trim() && !l.startsWith('$ '));
|
|
60
60
|
const sig = lines.find((l) => /\b(error|fail(ed|ure)?|assertion|✗|×)\b/i.test(l) && !/^exit \d+$/.test(l)) ??
|
|
61
61
|
lines.find((l) => !/^exit \d+$/.test(l)) ??
|
|
62
62
|
'';
|
|
@@ -10,6 +10,7 @@ import { repoRoot } from '../lib/git.js';
|
|
|
10
10
|
import { SKILLS_INDEX_HEADER, skillsIndex, splitFrontmatter } from '../lib/skills.js';
|
|
11
11
|
import { harnessVersion, packageHarness, packageSkills, packageVersion, tierSkills, } from '../lib/upstream.js';
|
|
12
12
|
import { generateVendorFiles } from '../lib/generate.js';
|
|
13
|
+
import { recordDetection } from '../lib/bindings.js';
|
|
13
14
|
import { writeGenerated } from '../lib/vendor-write.js';
|
|
14
15
|
/** Which upstream harness files a tier installs (design §1, tier table). */
|
|
15
16
|
export function tierFiles(all, tier) {
|
|
@@ -89,10 +90,7 @@ export function buildBindings(harness, available, vs, mode, cache) {
|
|
|
89
90
|
const doc = {
|
|
90
91
|
schema: 'reins/bindings@1',
|
|
91
92
|
mode,
|
|
92
|
-
vendors: Object.fromEntries(vs.map((v) => [
|
|
93
|
-
v.name,
|
|
94
|
-
{ cli: v.cli, detected: v.detected, available: available.has(v.name) },
|
|
95
|
-
])),
|
|
93
|
+
vendors: Object.fromEntries(vs.map((v) => [v.name, { cli: v.cli, available: available.has(v.name) }])),
|
|
96
94
|
roles,
|
|
97
95
|
escalation: ['pl', 'pm', 'advisor', 'user'],
|
|
98
96
|
limits: {},
|
|
@@ -201,8 +199,12 @@ export async function runInstall(o) {
|
|
|
201
199
|
add('.agents/harness/gates.yaml', buildGates(root, [...(/^y/i.test(okGates) ? proposal.gates : []), ...chosen]), 'declared gates');
|
|
202
200
|
}
|
|
203
201
|
// 3. generated configuration
|
|
204
|
-
if (o.tier === 'graph' && !hasBindings)
|
|
202
|
+
if (o.tier === 'graph' && !hasBindings) {
|
|
203
|
+
// detection results are per-user: .loctx/bindings.local.yaml, never the committed file
|
|
204
|
+
if (!o.dryRun)
|
|
205
|
+
recordDetection(root, vs);
|
|
205
206
|
add('.agents/harness/bindings.yaml', buildBindings(up, avail, vs, o.mode, o.modelCache ?? newModelCache()), 'role ↔ model bindings');
|
|
207
|
+
}
|
|
206
208
|
add('.agents/harness/install.yaml', `# version pin and install settings (R25) — read by reins update\n${stringify({ ...pinned, schema: 'reins/install@1', tier: o.tier, version, cli: packageVersion(), mode: o.mode, language })}`, 'version pin');
|
|
207
209
|
// 4. layout skeleton (design §1); never overwrite project files
|
|
208
210
|
if (o.tier !== 'harness') {
|
|
@@ -35,7 +35,7 @@ export function proposeKnowledge(key, o = {}) {
|
|
|
35
35
|
for (const f of o.from ?? []) {
|
|
36
36
|
const abs = resolve(root, f.includes('/') ? f : join('.loctx', 'history', f));
|
|
37
37
|
const rel = relative(hist, abs);
|
|
38
|
-
if (rel.startsWith('..') || rel
|
|
38
|
+
if (rel.startsWith('..') || /[\\/]/.test(rel) || !existsSync(abs))
|
|
39
39
|
return { refused: `--from ${f}: not a page under .loctx/history/` };
|
|
40
40
|
const text = readFileSync(abs, 'utf8');
|
|
41
41
|
const lines = [...text.matchAll(/^(?:decisions|reasons):\s*(.+)$/gm)].flatMap((m) => m[1].split(',').map((x) => x.trim()));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmdirSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { applyBlocks, parseBlocks, swapSections } from '../lib/blocks.js';
|
|
4
|
+
import { relPath } from '../lib/fsx.js';
|
|
4
5
|
import { generation } from '../lib/detect.js';
|
|
5
6
|
import { repoRoot } from '../lib/git.js';
|
|
6
7
|
import { convertWorkToTicket, planMigration } from '../lib/migrate-plan.js';
|
|
@@ -112,8 +113,8 @@ export async function runMigrate(o) {
|
|
|
112
113
|
else {
|
|
113
114
|
const alt = to.replace(/(\.[^./]+)?$/, '.from-ai$1');
|
|
114
115
|
renameSync(from, alt);
|
|
115
|
-
res.moves.push({ ...m, to:
|
|
116
|
-
res.report.push(`${m.to} already existed — the old file is next to it as ${
|
|
116
|
+
res.moves.push({ ...m, to: relPath(root, alt), result: 'kept-both' });
|
|
117
|
+
res.report.push(`${m.to} already existed — the old file is next to it as ${relPath(root, alt)}`);
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
if (!o.dryRun)
|
package/cli/dist/commands/new.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { dirname, join } from 'node:path';
|
|
2
|
+
import { basename, dirname, join } from 'node:path';
|
|
3
3
|
import { harnessDir } from '../lib/harness.js';
|
|
4
4
|
import { loadSchemas, validateFile } from '../lib/schema.js';
|
|
5
5
|
import { intentDir, intentFile, intentIds, openTickets } from '../lib/work.js';
|
|
@@ -41,7 +41,7 @@ function historyTicketIds(root, intent) {
|
|
|
41
41
|
const out = [];
|
|
42
42
|
for (const f of ls(dir).filter((e) => e.endsWith('.md'))) {
|
|
43
43
|
const head = readFileSync(join(dir, f), 'utf8')
|
|
44
|
-
.split(
|
|
44
|
+
.split(/\r?\n/)
|
|
45
45
|
.find((l) => l.startsWith('# ')) ?? '';
|
|
46
46
|
for (const m of `${f}\n${head}`.matchAll(re))
|
|
47
47
|
out.push(m[1]);
|
|
@@ -129,10 +129,7 @@ export function newTicket(root, intent, step, slug, o = {}) {
|
|
|
129
129
|
: [];
|
|
130
130
|
const open = openTickets(root).map((f) => String(f.data['id'] ?? ''));
|
|
131
131
|
const n = ticketNumber(intent, planned, [...open, ...historyTicketIds(root, intent)]);
|
|
132
|
-
const iSlug = idir
|
|
133
|
-
.split('/')
|
|
134
|
-
.pop()
|
|
135
|
-
.replace(/^\d{3}_/, '');
|
|
132
|
+
const iSlug = basename(idir).replace(/^\d{3}_/, '');
|
|
136
133
|
const branch = typeof plan.data['branch'] === 'string' ? plan.data['branch'] : `feat/${intent}-${iSlug}`;
|
|
137
134
|
const depends = (o.depends ?? '')
|
|
138
135
|
.split(',')
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { isAbsolute, join, relative, sep } from 'node:path';
|
|
3
|
+
import { isWithin, realPath } from '../lib/fsx.js';
|
|
3
4
|
import { harnessDir, readYaml } from '../lib/harness.js';
|
|
4
|
-
import { dispatchLines, readRelease } from '../lib/release.js';
|
|
5
|
+
import { checkDoc, dispatchLines, readRelease, readReleaseDocs } from '../lib/release.js';
|
|
5
6
|
import { loadSchemas, validateFile } from '../lib/schema.js';
|
|
6
7
|
import { compound } from './gate.js';
|
|
7
8
|
import { approvedBy, busFor, historyPages, intentFile, intentIds, openTickets, recordedDecisions, ticketFile, } from '../lib/work.js';
|
|
@@ -189,10 +190,9 @@ export function ticketStart(root, id) {
|
|
|
189
190
|
export function readEvidence(root, evidence) {
|
|
190
191
|
const tokens = evidence.split(/\s+/).filter(Boolean);
|
|
191
192
|
// an absolute path inside the repository reads like a relative one; outside it is refused
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
};
|
|
193
|
+
// macOS: tmpdir() is /var/... while git reports /private/var/...; Windows: RUNNER~1 vs the long name
|
|
194
|
+
const real = realPath;
|
|
195
|
+
const inside = (t) => isWithin(real(root), real(t));
|
|
196
196
|
const outside = tokens.filter((t) => isAbsolute(t) && !inside(t));
|
|
197
197
|
const resolve = (t) => (isAbsolute(t) ? t : join(root, t));
|
|
198
198
|
const files = tokens.length > 0 && tokens.every((t) => existsSync(resolve(t)));
|
|
@@ -200,7 +200,7 @@ export function readEvidence(root, evidence) {
|
|
|
200
200
|
? outside.map((t) => ({ source: t, text: '', outside: true }))
|
|
201
201
|
: files
|
|
202
202
|
? tokens.map((t) => ({
|
|
203
|
-
source: isAbsolute(t) ? relative(root, t) : t,
|
|
203
|
+
source: isAbsolute(t) ? relative(real(root), real(t)).split(sep).join('/') : t,
|
|
204
204
|
text: readFileSync(resolve(t), 'utf8'),
|
|
205
205
|
}))
|
|
206
206
|
: [{ source: 'inline', text: evidence }];
|
|
@@ -366,7 +366,7 @@ export function verdictCheck(root, id) {
|
|
|
366
366
|
return findings;
|
|
367
367
|
}
|
|
368
368
|
/** T5 — an rc closes: every planned ticket of the release's intents is done and recorded. */
|
|
369
|
-
export function rcClose(root, release) {
|
|
369
|
+
export function rcClose(root, release, stable = false) {
|
|
370
370
|
if (!release)
|
|
371
371
|
return [
|
|
372
372
|
{
|
|
@@ -433,11 +433,34 @@ export function rcClose(root, release) {
|
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
435
|
if (findings.length === 0)
|
|
436
|
-
findings.push(...nextRc(root, release));
|
|
436
|
+
findings.push(...(stable ? noRcRecorded(root, release) : nextRc(root, release)));
|
|
437
437
|
if (findings.every((f) => f.verdict === 'WARN'))
|
|
438
|
-
findings.push(...dispatchFindings(root, findings));
|
|
438
|
+
findings.push(...(stable ? stableFindings(root, release) : dispatchFindings(root, findings)));
|
|
439
|
+
findings.push(...docsFindings(root, release, stable ? 'stable' : 'rc'));
|
|
439
440
|
return findings;
|
|
440
441
|
}
|
|
442
|
+
/** One F2 WARN per `release.docs` file that still describes the previous state (S-7); never a STOP. */
|
|
443
|
+
export function docsFindings(root, release, stage) {
|
|
444
|
+
const out = [];
|
|
445
|
+
for (const d of readReleaseDocs(root)) {
|
|
446
|
+
let text = null;
|
|
447
|
+
try {
|
|
448
|
+
text = readFileSync(join(root, d.file), 'utf8');
|
|
449
|
+
}
|
|
450
|
+
catch {
|
|
451
|
+
// missing, a directory or unreadable: the same advisory warning, and the other documents are still checked
|
|
452
|
+
}
|
|
453
|
+
if (text !== null && checkDoc(text, d.check, release, stage))
|
|
454
|
+
continue;
|
|
455
|
+
out.push({
|
|
456
|
+
reason: 'F2',
|
|
457
|
+
verdict: 'WARN',
|
|
458
|
+
path: d.file,
|
|
459
|
+
message: `docs: ${d.file} still describes the previous state (${d.check})`,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
return out;
|
|
463
|
+
}
|
|
441
464
|
/** The rc dispatch lines (S-3) from install.yaml `release:`; the rc number comes from the ledger finding. */
|
|
442
465
|
function dispatchFindings(root, found) {
|
|
443
466
|
const rc = found.map((f) => /^next rc: (\S+)$/.exec(f.message)?.[1]).find(Boolean);
|
|
@@ -455,7 +478,44 @@ function dispatchFindings(root, found) {
|
|
|
455
478
|
return [
|
|
456
479
|
{ reason: 'F2', verdict: 'WARN', message: 'no release workflow is set for the rc stage' },
|
|
457
480
|
];
|
|
458
|
-
return
|
|
481
|
+
return [
|
|
482
|
+
...lines.map((l) => ({ reason: 'F2', verdict: 'WARN', message: `dispatch: ${l}` })),
|
|
483
|
+
{
|
|
484
|
+
reason: 'F2',
|
|
485
|
+
verdict: 'WARN',
|
|
486
|
+
message: "stable: rerun with --stable on the user's instruction",
|
|
487
|
+
},
|
|
488
|
+
];
|
|
489
|
+
}
|
|
490
|
+
/** The stable dispatch lines (S-9): printed only under --stable, labelled so an agent does not run them unasked. */
|
|
491
|
+
function stableFindings(root, release) {
|
|
492
|
+
const ws = readRelease(root);
|
|
493
|
+
if (!ws)
|
|
494
|
+
return [
|
|
495
|
+
{
|
|
496
|
+
reason: 'F2',
|
|
497
|
+
verdict: 'WARN',
|
|
498
|
+
message: 'no release settings (install.yaml has no release:) — merge only',
|
|
499
|
+
},
|
|
500
|
+
];
|
|
501
|
+
const lines = dispatchLines(ws, 'stable', release);
|
|
502
|
+
if (lines.length === 0)
|
|
503
|
+
return [
|
|
504
|
+
{ reason: 'F2', verdict: 'WARN', message: 'no release workflow is set for the stable stage' },
|
|
505
|
+
];
|
|
506
|
+
return lines.map((l) => ({
|
|
507
|
+
reason: 'F2',
|
|
508
|
+
verdict: 'WARN',
|
|
509
|
+
message: `dispatch (stable — user's instruction only, A2): ${l}`,
|
|
510
|
+
}));
|
|
511
|
+
}
|
|
512
|
+
/** A stable normally follows an rc: WARN when the ledger records none. */
|
|
513
|
+
function noRcRecorded(root, release) {
|
|
514
|
+
const path = join(root, '.loctx', 'release', `${release}.md`);
|
|
515
|
+
const has = existsSync(path) && /^\s*[-*]\s*rc\.\d+\b/m.test(readFileSync(path, 'utf8'));
|
|
516
|
+
return has
|
|
517
|
+
? []
|
|
518
|
+
: [{ reason: 'F2', verdict: 'WARN', path, message: `no rc recorded for ${release}` }];
|
|
459
519
|
}
|
|
460
520
|
/**
|
|
461
521
|
* The next rc number from the local ledger `.loctx/release/<V>.md` (one `- rc.N …` line per rc):
|
|
@@ -1,6 +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
5
|
import { repoRoot } from '../lib/git.js';
|
|
5
6
|
import { harnessVersion, packageHarness, packageVersion } from '../lib/upstream.js';
|
|
6
7
|
import { candidateCount } from '../lib/retro.js';
|
|
@@ -213,6 +214,7 @@ export function collectStatus(root) {
|
|
|
213
214
|
bus: safe(() => busCount(root), 0),
|
|
214
215
|
lastHistory: pages.length ? basename(pages[pages.length - 1].path) : null,
|
|
215
216
|
knowledgeCandidates: safe(() => candidateCount(root), 0),
|
|
217
|
+
bindings: safe(() => (existsSync(join(root, '.agents/harness/bindings.yaml')) ? resolveBindings(root) : []), []),
|
|
216
218
|
};
|
|
217
219
|
}
|
|
218
220
|
/** The text view of the same object `--json` prints. */
|
|
@@ -252,6 +254,12 @@ export function formatStatus(d) {
|
|
|
252
254
|
out.push(`bus: ${d.bus} file${d.bus === 1 ? '' : 's'}`);
|
|
253
255
|
out.push(`last history: ${d.lastHistory ?? '—'}`);
|
|
254
256
|
out.push(`knowledge candidates: ${d.knowledgeCandidates}`);
|
|
257
|
+
if (d.bindings.length) {
|
|
258
|
+
out.push('');
|
|
259
|
+
out.push('bindings (resolved):');
|
|
260
|
+
for (const b of d.bindings)
|
|
261
|
+
out.push(` ${b.role.padEnd(12)} ${b.vendor.padEnd(7)} ${b.model} (${b.source})`);
|
|
262
|
+
}
|
|
255
263
|
return `${out.join('\n')}\n`;
|
|
256
264
|
}
|
|
257
265
|
/** `reins status [--json]`: exit 0 anywhere inside a git repository, 2 outside one. */
|
|
@@ -21,7 +21,7 @@ export function newer(a, b) {
|
|
|
21
21
|
export function changesBetween(changelog, from, to) {
|
|
22
22
|
const out = [];
|
|
23
23
|
let take = false;
|
|
24
|
-
for (const line of changelog.split(
|
|
24
|
+
for (const line of changelog.split(/\r?\n/)) {
|
|
25
25
|
const h = /^## (\S+)/.exec(line);
|
|
26
26
|
if (h)
|
|
27
27
|
take = newer(h[1] ?? '0', from) && !newer(h[1] ?? '0', to);
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { parse, stringify } from 'yaml';
|
|
4
|
+
import { Ajv2020 } from 'ajv/dist/2020.js';
|
|
5
|
+
import { vendorOf, vendors } from './detect.js';
|
|
6
|
+
import { packageHarness } from './upstream.js';
|
|
7
|
+
import { splitFrontmatter } from './skills.js';
|
|
8
|
+
/** The git-ignored per-user layer (design §5): detection results and role overrides. */
|
|
9
|
+
export const LOCAL_BINDINGS = '.loctx/bindings.local.yaml';
|
|
10
|
+
/** Used only when pm itself has no usable binding. */
|
|
11
|
+
export const DEFAULT_MODEL = 'claude-opus-5-5';
|
|
12
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
13
|
+
let validateLocal;
|
|
14
|
+
function localValid(doc) {
|
|
15
|
+
validateLocal ??= (() => {
|
|
16
|
+
const schema = JSON.parse(readFileSync(join(packageHarness(), 'schemas/bindings-local.schema.json'), 'utf8'));
|
|
17
|
+
return new Ajv2020({ allErrors: true, strict: false }).compile(schema);
|
|
18
|
+
})();
|
|
19
|
+
if (validateLocal(doc))
|
|
20
|
+
return null;
|
|
21
|
+
const errs = validateLocal.errors;
|
|
22
|
+
return (errs ?? [])
|
|
23
|
+
.map((e) => `${e.instancePath || '(root)'} ${e.message ?? 'invalid'}`)
|
|
24
|
+
.join('; ');
|
|
25
|
+
}
|
|
26
|
+
/** Tolerant: a missing file reads as empty; an invalid one is ignored with a warning, never a crash. */
|
|
27
|
+
export function readLocal(root) {
|
|
28
|
+
const out = { schema: 'reins/bindings-local@1', vendors: {}, roles: {} };
|
|
29
|
+
const path = join(root, LOCAL_BINDINGS);
|
|
30
|
+
if (!existsSync(path))
|
|
31
|
+
return out;
|
|
32
|
+
let doc;
|
|
33
|
+
try {
|
|
34
|
+
doc = parse(readFileSync(path, 'utf8'));
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
process.stderr.write(`warning: ${LOCAL_BINDINGS} cannot be read (${e.message}) — ignored\n`);
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
const bad = isObj(doc) ? localValid(doc) : 'not a mapping';
|
|
41
|
+
if (bad !== null || !isObj(doc)) {
|
|
42
|
+
process.stderr.write(`warning: ${LOCAL_BINDINGS} is invalid (${bad}) — ignored\n`);
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
if (isObj(doc['vendors']))
|
|
46
|
+
for (const [k, v] of Object.entries(doc['vendors']))
|
|
47
|
+
if (isObj(v) && typeof v['detected'] === 'boolean')
|
|
48
|
+
out.vendors[k] = {
|
|
49
|
+
detected: v['detected'],
|
|
50
|
+
...(typeof v['at'] === 'string' ? { at: v['at'] } : {}),
|
|
51
|
+
};
|
|
52
|
+
if (isObj(doc['roles']))
|
|
53
|
+
for (const [k, v] of Object.entries(doc['roles']))
|
|
54
|
+
if (isObj(v) && typeof v['model'] === 'string' && v['model'])
|
|
55
|
+
out.roles[k] = { model: v['model'] };
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
export function writeLocal(root, doc) {
|
|
59
|
+
const path = join(root, LOCAL_BINDINGS);
|
|
60
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
61
|
+
writeFileSync(path, `# per-user, git-ignored — change with \`reins configure bindings --local\`\n${stringify(doc)}`);
|
|
62
|
+
}
|
|
63
|
+
/** Records a detection run in the local file; `roles` and other vendors' entries are kept. */
|
|
64
|
+
export function recordDetection(root, vs, now = new Date()) {
|
|
65
|
+
const doc = readLocal(root);
|
|
66
|
+
for (const v of vs)
|
|
67
|
+
doc.vendors[v.name] = { detected: v.detected, at: now.toISOString() };
|
|
68
|
+
writeLocal(root, doc);
|
|
69
|
+
}
|
|
70
|
+
function roleMeta(root) {
|
|
71
|
+
const dir = join(root, '.agents/harness/roles');
|
|
72
|
+
const meta = new Map();
|
|
73
|
+
if (!existsSync(dir))
|
|
74
|
+
return meta;
|
|
75
|
+
for (const f of readdirSync(dir)
|
|
76
|
+
.filter((x) => x.endsWith('.md'))
|
|
77
|
+
.toSorted()) {
|
|
78
|
+
const { data } = splitFrontmatter(readFileSync(join(dir, f), 'utf8'));
|
|
79
|
+
meta.set(f.slice(0, -3), {
|
|
80
|
+
def: typeof data?.['default_binding'] === 'string' ? data['default_binding'] : undefined,
|
|
81
|
+
fb: typeof data?.['fallback_binding'] === 'string' ? data['fallback_binding'] : undefined,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return meta;
|
|
85
|
+
}
|
|
86
|
+
function teamRoles(root) {
|
|
87
|
+
const path = join(root, '.agents/harness/bindings.yaml');
|
|
88
|
+
if (!existsSync(path))
|
|
89
|
+
return {};
|
|
90
|
+
try {
|
|
91
|
+
const doc = parse(readFileSync(path, 'utf8'));
|
|
92
|
+
const out = {};
|
|
93
|
+
for (const [r, b] of Object.entries(doc?.roles ?? {}))
|
|
94
|
+
if (isObj(b) && typeof b['model'] === 'string')
|
|
95
|
+
out[r] = {
|
|
96
|
+
vendor: typeof b['vendor'] === 'string' ? b['vendor'] : vendorOf(b['model']),
|
|
97
|
+
model: b['model'],
|
|
98
|
+
};
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The model each role actually runs on (design §5). Per role: local override → team binding when its
|
|
107
|
+
* vendor is detected → the role file's `fallback_binding` when its vendor is detected → the pm model.
|
|
108
|
+
* A vendor missing from the local file is detected live (`detect`) and not written back. claude is the floor.
|
|
109
|
+
*/
|
|
110
|
+
export function resolveBindings(root, detect = vendors) {
|
|
111
|
+
const local = readLocal(root);
|
|
112
|
+
const team = teamRoles(root);
|
|
113
|
+
const meta = roleMeta(root);
|
|
114
|
+
let live;
|
|
115
|
+
const detected = (v) => {
|
|
116
|
+
if (v === 'claude')
|
|
117
|
+
return true;
|
|
118
|
+
const known = local.vendors[v];
|
|
119
|
+
if (known)
|
|
120
|
+
return known.detected;
|
|
121
|
+
live ??= new Map(detect().map((x) => [x.name, x.detected]));
|
|
122
|
+
return live.get(v) ?? false;
|
|
123
|
+
};
|
|
124
|
+
const roles = [...new Set([...Object.keys(team), ...meta.keys()])].toSorted();
|
|
125
|
+
const one = (role, last) => {
|
|
126
|
+
const l = local.roles[role]?.model;
|
|
127
|
+
if (l)
|
|
128
|
+
return { role, vendor: vendorOf(l), model: l, source: 'local', reason: 'local override' };
|
|
129
|
+
const t = team[role];
|
|
130
|
+
if (t && detected(t.vendor))
|
|
131
|
+
return { role, ...t, source: 'team', reason: 'team binding' };
|
|
132
|
+
const fb = meta.get(role)?.fb;
|
|
133
|
+
const why = t ? `${t.vendor} not detected` : 'no team binding';
|
|
134
|
+
if (fb && detected(vendorOf(fb)))
|
|
135
|
+
return {
|
|
136
|
+
role,
|
|
137
|
+
vendor: vendorOf(fb),
|
|
138
|
+
model: fb,
|
|
139
|
+
source: 'fallback',
|
|
140
|
+
reason: `${why} — fallback_binding`,
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
role,
|
|
144
|
+
vendor: last.vendor,
|
|
145
|
+
model: last.model,
|
|
146
|
+
source: last.source,
|
|
147
|
+
reason: `${why} — ${last.label}`,
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
// pm first, through the same order; its last resort is the claude default model
|
|
151
|
+
const pmRes = one('pm', {
|
|
152
|
+
vendor: vendorOf(DEFAULT_MODEL),
|
|
153
|
+
model: DEFAULT_MODEL,
|
|
154
|
+
source: 'default',
|
|
155
|
+
label: 'default model',
|
|
156
|
+
});
|
|
157
|
+
const pm = {
|
|
158
|
+
vendor: pmRes.vendor,
|
|
159
|
+
model: pmRes.model,
|
|
160
|
+
source: 'pm',
|
|
161
|
+
label: "pm's model",
|
|
162
|
+
};
|
|
163
|
+
const out = [];
|
|
164
|
+
for (const role of roles)
|
|
165
|
+
out.push(role === 'pm' ? pmRes : one(role, pm));
|
|
166
|
+
return out;
|
|
167
|
+
}
|