@bluenyang/reins 0.2.0 → 0.3.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -203
- package/cli/dist/commands/config-models.js +206 -127
- package/cli/dist/commands/config.js +104 -16
- package/cli/dist/commands/configure.js +166 -134
- package/cli/dist/commands/install.js +161 -217
- package/cli/dist/commands/migrate.js +23 -48
- package/cli/dist/commands/update.js +203 -30
- package/cli/dist/lib/agents-md.js +111 -0
- package/cli/dist/lib/bindings.js +227 -386
- package/cli/dist/lib/detect.js +7 -2
- package/cli/dist/lib/generate.js +56 -75
- package/cli/dist/lib/harness.js +0 -3
- package/cli/dist/lib/migrate-plan.js +3 -3
- package/cli/dist/lib/prompter.js +4 -4
- package/cli/dist/lib/reader.js +20 -0
- package/cli/dist/lib/upstream.js +0 -17
- package/cli/dist/lib/vendor-write.js +9 -56
- package/cli/dist/reins.js +59 -270
- package/docs/README.ko.md +31 -204
- package/harness/CHANGELOG.md +8 -3
- package/harness/VERSION +1 -1
- package/harness/models.yaml +8 -0
- package/harness/policy/common-red-lines.yaml +4 -4
- package/harness/roles/advisor.md +10 -14
- package/harness/roles/auditor.md +17 -0
- package/harness/roles/executor.md +32 -0
- package/harness/roles/implementer.md +23 -21
- package/harness/roles/pl.md +44 -21
- package/harness/roles/planner.md +17 -19
- package/harness/roles/pm.md +16 -21
- package/harness/schemas/bindings.schema.json +55 -0
- package/harness/schemas/install.schema.json +1 -2
- package/harness/schemas/intent.schema.json +1 -13
- package/harness/templates/agents-md-blocks.md +52 -17
- package/harness/templates/audit.md +25 -0
- package/harness/templates/history.md +14 -0
- package/harness/templates/intent.md +5 -0
- package/harness/templates/spec.md +4 -2
- package/package.json +1 -2
- package/skills/audit/SKILL.md +28 -0
- package/skills/implement/SKILL.md +30 -0
- package/skills/intent/SKILL.md +28 -0
- package/skills/merge/SKILL.md +26 -0
- package/skills/onboard/SKILL.md +31 -0
- package/skills/reins-setup/SKILL.md +16 -25
- package/skills/release/SKILL.md +26 -0
- package/skills/retro/SKILL.md +30 -0
- package/skills/review/SKILL.md +27 -0
- package/skills/roadmap/SKILL.md +29 -0
- package/skills/spec/SKILL.md +27 -0
- package/skills/test/SKILL.md +26 -0
- package/cli/dist/commands/check.js +0 -379
- package/cli/dist/commands/gate.js +0 -136
- package/cli/dist/commands/knowledge.js +0 -111
- package/cli/dist/commands/metrics.js +0 -138
- package/cli/dist/commands/new.js +0 -190
- package/cli/dist/commands/retro.js +0 -7
- package/cli/dist/commands/stages.js +0 -562
- package/cli/dist/commands/status.js +0 -281
- package/cli/dist/lib/enforcement.js +0 -125
- package/cli/dist/lib/memory.js +0 -96
- package/cli/dist/lib/metrics.js +0 -223
- package/cli/dist/lib/retro.js +0 -179
- package/cli/dist/lib/verdict.js +0 -15
- package/cli/dist/lib/work.js +0 -106
- package/cli/dist/scripts/enforcement.js +0 -24
- package/harness/policy/budget.yaml +0 -13
- package/harness/policy/enforcement.yaml +0 -98
- package/harness/policy/stops.yaml +0 -29
- package/harness/policy/transitions.yaml +0 -13
- package/harness/roles/code-review.md +0 -27
- package/harness/roles/deploy.md +0 -50
- package/harness/roles/docs.md +0 -19
- package/harness/roles/lookup.md +0 -22
- package/harness/roles/qa-design.md +0 -22
- package/harness/roles/qa-run.md +0 -19
- package/harness/roles/verify-tool.md +0 -21
- package/harness/schemas/bindings-local.schema.json +0 -21
- package/harness/schemas/bus-request.schema.json +0 -17
- package/harness/schemas/bus-response.schema.json +0 -14
- package/harness/schemas/enforcement.schema.json +0 -22
- package/harness/schemas/plan.schema.json +0 -10
- package/harness/schemas/ticket.schema.json +0 -15
- package/harness/templates/bus/request.yaml +0 -20
- package/harness/templates/bus/response.yaml +0 -10
- package/harness/templates/plan.md +0 -23
- package/harness/templates/ticket.md +0 -29
- package/skills/reins-implement/SKILL.md +0 -20
- package/skills/reins-intent/SKILL.md +0 -26
- package/skills/reins-loop/SKILL.md +0 -26
- package/skills/reins-loop/references/vendor-cli.md +0 -41
- package/skills/reins-release/SKILL.md +0 -18
- package/skills/reins-retro/SKILL.md +0 -20
- package/skills/reins-review/SKILL.md +0 -23
- package/skills/reins-roadmap/SKILL.md +0 -17
- package/skills/reins-spec/SKILL.md +0 -22
- package/skills/reins-test/SKILL.md +0 -18
|
@@ -1,160 +1,192 @@
|
|
|
1
|
-
import { existsSync, readFileSync,
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { parse, parseDocument
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { parse, parseDocument } from 'yaml';
|
|
4
|
+
import { subdirProposals, vendorOf, vendors } from '../lib/detect.js';
|
|
5
|
+
import { GROUP_ROLES, GROUPS, effectiveBindings, readLocalBindings, readTeam, resolveRoles, validateBindings, writeBindings, } from '../lib/bindings.js';
|
|
6
|
+
import { modeChangedNote, placeNote, renderBlocks } from '../lib/agents-md.js';
|
|
7
|
+
import { applyBlocks } from '../lib/blocks.js';
|
|
6
8
|
import { generateVendorFiles } from '../lib/generate.js';
|
|
7
9
|
import { repoRoot } from '../lib/git.js';
|
|
8
10
|
import { writeGenerated } from '../lib/vendor-write.js';
|
|
9
11
|
import { packageHarness } from '../lib/upstream.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
/** A model given alone, or `vendor:model`. */
|
|
13
|
+
export function parseBinding(v) {
|
|
14
|
+
const s = v.trim();
|
|
15
|
+
if (!s)
|
|
16
|
+
return null;
|
|
17
|
+
const i = s.indexOf(':');
|
|
18
|
+
if (i > 0)
|
|
19
|
+
return { vendor: s.slice(0, i), model: s.slice(i + 1) };
|
|
20
|
+
return { vendor: vendorOf(s), model: s };
|
|
21
|
+
}
|
|
22
|
+
/** Rewrite AGENTS.md's managed blocks for these settings (design §5); a mode change adds the light mode-changed note (ST-5). */
|
|
23
|
+
export function refreshAgents(root, doc, modeFrom) {
|
|
24
|
+
const ap = join(root, 'AGENTS.md');
|
|
25
|
+
if (!existsSync(ap))
|
|
26
|
+
return false;
|
|
27
|
+
const before = readFileSync(ap, 'utf8');
|
|
28
|
+
const pin = join(root, '.agents/harness/install.yaml');
|
|
29
|
+
const language = existsSync(pin)
|
|
30
|
+
? String(parse(readFileSync(pin, 'utf8'))?.language ?? 'ko')
|
|
31
|
+
: 'ko';
|
|
32
|
+
let text = applyBlocks(before, renderBlocks(packageHarness(), doc, language)).text;
|
|
33
|
+
if (modeFrom !== undefined) {
|
|
34
|
+
// a pending note from an earlier switch is replaced by one that names the latest change
|
|
35
|
+
text = text.replace(/<!-- reins:mode-changed (?:pending|done) -->\n(?:> \*\*Mode changed from [^\n]*\n)?\n?/, '');
|
|
36
|
+
text = placeNote(text, modeChangedNote(modeFrom, doc.mode ?? 'single'), 'mode-changed');
|
|
37
|
+
}
|
|
38
|
+
if (text !== before)
|
|
39
|
+
writeFileSync(ap, text);
|
|
40
|
+
return text !== before;
|
|
41
|
+
}
|
|
42
|
+
/** `reins config bindings` (design §9): the flag form of the models-and-roles screen. */
|
|
12
43
|
export async function configureBindings(o) {
|
|
13
44
|
const root = repoRoot(o.cwd ?? process.cwd());
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
return { refused: 'no bindings.yaml — install the graph tier first', changed: [], table: [] };
|
|
17
|
-
const roles = new Set(readdirSync(join(root, '.agents/harness/roles'))
|
|
18
|
-
.filter((f) => f.endsWith('.md'))
|
|
19
|
-
.map((f) => f.slice(0, -3)));
|
|
20
|
-
let doc = parse(readFileSync(path, 'utf8'));
|
|
21
|
-
const changed = [];
|
|
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
|
-
// 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)))
|
|
45
|
+
const team = readTeam(root);
|
|
46
|
+
if (!team.doc)
|
|
40
47
|
return {
|
|
41
|
-
refused:
|
|
42
|
-
|
|
48
|
+
refused: team.v1
|
|
49
|
+
? 'bindings.yaml is version 1 — run `reins update` to convert it'
|
|
50
|
+
: 'no bindings.yaml — run `reins install` first',
|
|
51
|
+
code: 2,
|
|
43
52
|
changed: [],
|
|
44
|
-
|
|
53
|
+
roles: [],
|
|
45
54
|
};
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
const effective = () => effectiveBindings(root);
|
|
56
|
+
if (o.show) {
|
|
57
|
+
const doc = effective();
|
|
58
|
+
return { changed: [], doc, roles: resolveRoles(doc) };
|
|
59
|
+
}
|
|
60
|
+
const base = o.local
|
|
61
|
+
? (readLocalBindings(root) ?? {})
|
|
62
|
+
: structuredClone(team.doc);
|
|
63
|
+
const next = structuredClone(base);
|
|
64
|
+
const changed = [];
|
|
65
|
+
const refuse = (why) => ({
|
|
66
|
+
refused: why,
|
|
67
|
+
code: 1,
|
|
68
|
+
changed: [],
|
|
69
|
+
roles: [],
|
|
70
|
+
});
|
|
71
|
+
const groupOf = (name) => GROUPS.includes(name) ? name : null;
|
|
72
|
+
for (const pair of o.set ?? []) {
|
|
73
|
+
const eq = pair.indexOf('=');
|
|
74
|
+
const target = pair.slice(0, eq).trim();
|
|
75
|
+
const b = eq > 0 ? parseBinding(pair.slice(eq + 1)) : null;
|
|
76
|
+
if (!target || !b)
|
|
77
|
+
return refuse(`"${pair}" is not target=model`);
|
|
78
|
+
if (target === 'default') {
|
|
79
|
+
next.default = b;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
const [g, role] = target.split('.');
|
|
83
|
+
const group = groupOf(g ?? '');
|
|
84
|
+
if (!group)
|
|
85
|
+
return refuse(`unknown group "${g}" — groups: default, ${GROUPS.join(', ')}`);
|
|
86
|
+
const roles = GROUP_ROLES[group];
|
|
87
|
+
next.groups = { ...next.groups };
|
|
88
|
+
const spec = { ...next.groups[group] };
|
|
89
|
+
if (role) {
|
|
90
|
+
if (!roles.includes(role))
|
|
91
|
+
return refuse(`unknown role "${role}" in ${group} — roles: ${roles.join(', ') || group}`);
|
|
92
|
+
spec.roles = { ...spec.roles, [role]: b };
|
|
78
93
|
}
|
|
79
|
-
else
|
|
80
|
-
|
|
81
|
-
|
|
94
|
+
else {
|
|
95
|
+
delete spec.models;
|
|
96
|
+
spec.vendor = b.vendor;
|
|
97
|
+
spec.model = b.model;
|
|
82
98
|
}
|
|
99
|
+
next.groups[group] = spec;
|
|
83
100
|
}
|
|
84
|
-
|
|
85
|
-
writeLocal(root, local);
|
|
86
|
-
toggle('local');
|
|
87
|
-
return { changed, toggled, table: teamTable(), resolved: resolveBindings(root, detect) };
|
|
101
|
+
changed.push(target);
|
|
88
102
|
}
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
for (const pair of o.models ?? []) {
|
|
104
|
+
const eq = pair.indexOf('=');
|
|
105
|
+
const group = groupOf(pair.slice(0, eq).trim());
|
|
106
|
+
if (!group || (group !== 'pl' && group !== 'advisor'))
|
|
107
|
+
return refuse(`"${pair}": several models are for pl and advisor only`);
|
|
108
|
+
const list = pair
|
|
109
|
+
.slice(eq + 1)
|
|
110
|
+
.split(',')
|
|
111
|
+
.map(parseBinding)
|
|
112
|
+
.filter((x) => x !== null);
|
|
113
|
+
if (!list.length)
|
|
114
|
+
return refuse(`"${pair}" names no model`);
|
|
115
|
+
next.groups = { ...next.groups };
|
|
116
|
+
const { vendor: _v, model: _m, ...rest } = next.groups[group] ?? {};
|
|
117
|
+
next.groups[group] = { ...rest, models: list };
|
|
118
|
+
changed.push(group);
|
|
119
|
+
}
|
|
120
|
+
for (const name of o.off ?? []) {
|
|
121
|
+
const group = groupOf(name);
|
|
122
|
+
if (!group)
|
|
123
|
+
return refuse(`unknown group "${name}" — groups: ${GROUPS.join(', ')}`);
|
|
124
|
+
next.groups = { ...next.groups };
|
|
125
|
+
if (o.local) {
|
|
126
|
+
// an empty group in the personal file hides the team's (mergeLocal replaces a group as a whole)
|
|
127
|
+
if (JSON.stringify(next.groups[group]) !== '{}') {
|
|
128
|
+
next.groups[group] = {};
|
|
129
|
+
changed.push(group);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else if (next.groups[group]) {
|
|
133
|
+
delete next.groups[group];
|
|
134
|
+
changed.push(group);
|
|
101
135
|
}
|
|
102
|
-
for (const r of Object.keys(rebuilt.roles))
|
|
103
|
-
if (JSON.stringify(rebuilt.roles[r]) !== JSON.stringify(doc.roles[r]))
|
|
104
|
-
changed.push(r);
|
|
105
|
-
doc = rebuilt;
|
|
106
136
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
pairs = ans
|
|
111
|
-
.split(',')
|
|
112
|
-
.map((s) => s.trim())
|
|
113
|
-
.filter(Boolean);
|
|
137
|
+
if (o.mode && next.mode !== o.mode) {
|
|
138
|
+
next.mode = o.mode;
|
|
139
|
+
changed.push('mode');
|
|
114
140
|
}
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
refused: `unknown role "${role}" — roles: ${[...roles].toSorted().join(', ')}`,
|
|
122
|
-
changed: [],
|
|
123
|
-
table: [],
|
|
124
|
-
};
|
|
125
|
-
const entry = { vendor: vendorOf(model), model };
|
|
126
|
-
if (typeof doc.roles[role]?.['enabled'] === 'boolean')
|
|
127
|
-
entry['enabled'] = doc.roles[role]['enabled'];
|
|
128
|
-
if (role === 'implementer')
|
|
129
|
-
entry['parallel'] = doc.roles[role]?.['parallel'] ?? 4;
|
|
130
|
-
const chk = checkBinding(model, entry.vendor, cache);
|
|
131
|
-
if (chk) {
|
|
132
|
-
if (chk.unverified)
|
|
133
|
-
entry['unverified'] = true;
|
|
134
|
-
if (chk.note)
|
|
135
|
-
entry['note'] = chk.note;
|
|
141
|
+
if (o.audit) {
|
|
142
|
+
const required = o.audit === 'on';
|
|
143
|
+
if ((next.audit?.required ?? true) !== required) {
|
|
144
|
+
next.audit = { ...next.audit, required };
|
|
145
|
+
changed.push('audit');
|
|
136
146
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
}
|
|
148
|
+
if (o.detect || o.tools?.length) {
|
|
149
|
+
const vs = (o.detectVendors ?? vendors)();
|
|
150
|
+
next.tools = { ...next.tools };
|
|
151
|
+
if (o.detect)
|
|
152
|
+
for (const v of vs)
|
|
153
|
+
next.tools[v.name] = {
|
|
154
|
+
...next.tools[v.name],
|
|
155
|
+
cli: v.cli,
|
|
156
|
+
use: next.tools[v.name]?.use ?? v.detected,
|
|
157
|
+
};
|
|
158
|
+
for (const pair of o.tools ?? []) {
|
|
159
|
+
const [name, state] = pair.split('=').map((s) => s.trim());
|
|
160
|
+
if (!name || (state !== 'on' && state !== 'off'))
|
|
161
|
+
return refuse(`"${pair}" is not tool=on|off`);
|
|
162
|
+
const cli = vs.find((v) => v.name === name)?.cli ?? next.tools[name]?.cli ?? name;
|
|
163
|
+
next.tools[name] = { ...next.tools[name], cli, use: state === 'on' };
|
|
143
164
|
}
|
|
165
|
+
changed.push('tools');
|
|
166
|
+
}
|
|
167
|
+
const problems = o.local ? [] : validateBindings({ ...next, schema: 'reins/bindings@2' });
|
|
168
|
+
if (problems.length)
|
|
169
|
+
return refuse(`the result would not be valid: ${problems.join('; ')}`);
|
|
170
|
+
const wrote = JSON.stringify(next) !== JSON.stringify(base);
|
|
171
|
+
if (!wrote) {
|
|
172
|
+
const doc = effective();
|
|
173
|
+
return { changed: [], doc, roles: resolveRoles(doc) };
|
|
144
174
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
175
|
+
writeBindings(root, next, o.local ? 'local' : 'project');
|
|
176
|
+
const doc = effective();
|
|
177
|
+
if (o.local)
|
|
178
|
+
return { changed, doc, roles: resolveRoles(doc) };
|
|
179
|
+
const teamNow = readTeam(root).doc;
|
|
180
|
+
const from = team.doc.mode ?? 'single';
|
|
181
|
+
const modeChanged = from !== (teamNow.mode ?? 'single');
|
|
182
|
+
const generated = writeGenerated(root, generateVendorFiles(root), false);
|
|
183
|
+
refreshAgents(root, teamNow, modeChanged ? from : undefined);
|
|
152
184
|
return {
|
|
153
185
|
changed,
|
|
154
|
-
|
|
155
|
-
|
|
186
|
+
doc,
|
|
187
|
+
roles: resolveRoles(doc),
|
|
156
188
|
generated,
|
|
157
|
-
|
|
189
|
+
modeChanged: modeChanged || undefined,
|
|
158
190
|
};
|
|
159
191
|
}
|
|
160
192
|
/** `reins configure gates [--add <name>…]` (spec S-7): subdirectory proposals, appended after the existing gates. */
|