@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.
- package/README.md +50 -203
- package/cli/dist/commands/config-models.js +175 -126
- package/cli/dist/commands/config.js +96 -15
- package/cli/dist/commands/configure.js +165 -138
- 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 +102 -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/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 +7 -3
- package/harness/VERSION +1 -1
- 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 +29 -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,161 +1,188 @@
|
|
|
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 { placeNote, reconcileNote, 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 reconcile note. */
|
|
23
|
+
export function refreshAgents(root, doc, modeChanged) {
|
|
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 (modeChanged) {
|
|
34
|
+
// a previous text the PM has not reconciled yet is older and stays; the current one is still in AGENTS.md
|
|
35
|
+
const prev = join(root, '.agents/AGENTS.previous.md');
|
|
36
|
+
if (!(existsSync(prev) && before.includes('<!-- reins:reconcile pending -->')))
|
|
37
|
+
writeFileSync(prev, before);
|
|
38
|
+
text = placeNote(text, reconcileNote(`The user switched the mode to ${doc.mode ?? 'single'}.`), 'reconcile');
|
|
39
|
+
}
|
|
40
|
+
if (text !== before)
|
|
41
|
+
writeFileSync(ap, text);
|
|
42
|
+
return text !== before;
|
|
43
|
+
}
|
|
44
|
+
/** `reins config bindings` (design §9): the flag form of the models-and-roles screen. */
|
|
12
45
|
export async function configureBindings(o) {
|
|
13
46
|
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)))
|
|
47
|
+
const team = readTeam(root);
|
|
48
|
+
if (!team.doc)
|
|
40
49
|
return {
|
|
41
|
-
refused:
|
|
42
|
-
|
|
50
|
+
refused: team.v1
|
|
51
|
+
? 'bindings.yaml is version 1 — run `reins update` to convert it'
|
|
52
|
+
: 'no bindings.yaml — run `reins install` first',
|
|
53
|
+
code: 2,
|
|
43
54
|
changed: [],
|
|
44
|
-
|
|
55
|
+
roles: [],
|
|
45
56
|
};
|
|
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
|
-
|
|
57
|
+
const effective = () => effectiveBindings(root);
|
|
58
|
+
if (o.show) {
|
|
59
|
+
const doc = effective();
|
|
60
|
+
return { changed: [], doc, roles: resolveRoles(doc) };
|
|
61
|
+
}
|
|
62
|
+
const base = o.local
|
|
63
|
+
? (readLocalBindings(root) ?? {})
|
|
64
|
+
: structuredClone(team.doc);
|
|
65
|
+
const next = structuredClone(base);
|
|
66
|
+
const changed = [];
|
|
67
|
+
const refuse = (why) => ({
|
|
68
|
+
refused: why,
|
|
69
|
+
code: 1,
|
|
70
|
+
changed: [],
|
|
71
|
+
roles: [],
|
|
72
|
+
});
|
|
73
|
+
const groupOf = (name) => GROUPS.includes(name) ? name : null;
|
|
74
|
+
for (const pair of o.set ?? []) {
|
|
75
|
+
const eq = pair.indexOf('=');
|
|
76
|
+
const target = pair.slice(0, eq).trim();
|
|
77
|
+
const b = eq > 0 ? parseBinding(pair.slice(eq + 1)) : null;
|
|
78
|
+
if (!target || !b)
|
|
79
|
+
return refuse(`"${pair}" is not target=model`);
|
|
80
|
+
if (target === 'default') {
|
|
81
|
+
next.default = b;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const [g, role] = target.split('.');
|
|
85
|
+
const group = groupOf(g ?? '');
|
|
86
|
+
if (!group)
|
|
87
|
+
return refuse(`unknown group "${g}" — groups: default, ${GROUPS.join(', ')}`);
|
|
88
|
+
const roles = GROUP_ROLES[group];
|
|
89
|
+
next.groups = { ...next.groups };
|
|
90
|
+
const spec = { ...next.groups[group] };
|
|
91
|
+
if (role) {
|
|
92
|
+
if (!roles.includes(role))
|
|
93
|
+
return refuse(`unknown role "${role}" in ${group} — roles: ${roles.join(', ') || group}`);
|
|
94
|
+
spec.roles = { ...spec.roles, [role]: b };
|
|
78
95
|
}
|
|
79
|
-
else
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
else {
|
|
97
|
+
delete spec.models;
|
|
98
|
+
spec.vendor = b.vendor;
|
|
99
|
+
spec.model = b.model;
|
|
82
100
|
}
|
|
101
|
+
next.groups[group] = spec;
|
|
83
102
|
}
|
|
84
|
-
|
|
85
|
-
writeLocal(root, local);
|
|
86
|
-
toggle('local');
|
|
87
|
-
return { changed, toggled, table: teamTable(), resolved: resolveBindings(root, detect) };
|
|
103
|
+
changed.push(target);
|
|
88
104
|
}
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
for (const pair of o.models ?? []) {
|
|
106
|
+
const eq = pair.indexOf('=');
|
|
107
|
+
const group = groupOf(pair.slice(0, eq).trim());
|
|
108
|
+
if (!group || (group !== 'pl' && group !== 'advisor'))
|
|
109
|
+
return refuse(`"${pair}": several models are for pl and advisor only`);
|
|
110
|
+
const list = pair
|
|
111
|
+
.slice(eq + 1)
|
|
112
|
+
.split(',')
|
|
113
|
+
.map(parseBinding)
|
|
114
|
+
.filter((x) => x !== null);
|
|
115
|
+
if (!list.length)
|
|
116
|
+
return refuse(`"${pair}" names no model`);
|
|
117
|
+
next.groups = { ...next.groups };
|
|
118
|
+
const { vendor: _v, model: _m, ...rest } = next.groups[group] ?? {};
|
|
119
|
+
next.groups[group] = { ...rest, models: list };
|
|
120
|
+
changed.push(group);
|
|
121
|
+
}
|
|
122
|
+
for (const name of o.off ?? []) {
|
|
123
|
+
const group = groupOf(name);
|
|
124
|
+
if (!group)
|
|
125
|
+
return refuse(`unknown group "${name}" — groups: ${GROUPS.join(', ')}`);
|
|
126
|
+
next.groups = { ...next.groups };
|
|
127
|
+
if (o.local) {
|
|
128
|
+
// an empty group in the personal file hides the team's (mergeLocal replaces a group as a whole)
|
|
129
|
+
if (JSON.stringify(next.groups[group]) !== '{}') {
|
|
130
|
+
next.groups[group] = {};
|
|
131
|
+
changed.push(group);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (next.groups[group]) {
|
|
135
|
+
delete next.groups[group];
|
|
136
|
+
changed.push(group);
|
|
101
137
|
}
|
|
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
138
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
pairs = ans
|
|
111
|
-
.split(',')
|
|
112
|
-
.map((s) => s.trim())
|
|
113
|
-
.filter(Boolean);
|
|
139
|
+
if (o.mode && next.mode !== o.mode) {
|
|
140
|
+
next.mode = o.mode;
|
|
141
|
+
changed.push('mode');
|
|
114
142
|
}
|
|
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;
|
|
143
|
+
if (o.audit) {
|
|
144
|
+
const required = o.audit === 'on';
|
|
145
|
+
if ((next.audit?.required ?? true) !== required) {
|
|
146
|
+
next.audit = { ...next.audit, required };
|
|
147
|
+
changed.push('audit');
|
|
136
148
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
}
|
|
150
|
+
if (o.detect || o.tools?.length) {
|
|
151
|
+
const vs = (o.detectVendors ?? vendors)();
|
|
152
|
+
next.tools = { ...next.tools };
|
|
153
|
+
if (o.detect)
|
|
154
|
+
for (const v of vs)
|
|
155
|
+
next.tools[v.name] = {
|
|
156
|
+
...next.tools[v.name],
|
|
157
|
+
cli: v.cli,
|
|
158
|
+
use: next.tools[v.name]?.use ?? v.detected,
|
|
159
|
+
};
|
|
160
|
+
for (const pair of o.tools ?? []) {
|
|
161
|
+
const [name, state] = pair.split('=').map((s) => s.trim());
|
|
162
|
+
if (!name || (state !== 'on' && state !== 'off'))
|
|
163
|
+
return refuse(`"${pair}" is not tool=on|off`);
|
|
164
|
+
const cli = vs.find((v) => v.name === name)?.cli ?? next.tools[name]?.cli ?? name;
|
|
165
|
+
next.tools[name] = { ...next.tools[name], cli, use: state === 'on' };
|
|
143
166
|
}
|
|
167
|
+
changed.push('tools');
|
|
168
|
+
}
|
|
169
|
+
const problems = o.local ? [] : validateBindings({ ...next, schema: 'reins/bindings@2' });
|
|
170
|
+
if (problems.length)
|
|
171
|
+
return refuse(`the result would not be valid: ${problems.join('; ')}`);
|
|
172
|
+
const wrote = JSON.stringify(next) !== JSON.stringify(base);
|
|
173
|
+
if (!wrote) {
|
|
174
|
+
const doc = effective();
|
|
175
|
+
return { changed: [], doc, roles: resolveRoles(doc) };
|
|
144
176
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const generated =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
toggled,
|
|
155
|
-
table: teamTable(),
|
|
156
|
-
generated,
|
|
157
|
-
resolved: resolveBindings(root, detect),
|
|
158
|
-
};
|
|
177
|
+
writeBindings(root, next, o.local ? 'local' : 'global');
|
|
178
|
+
const doc = effective();
|
|
179
|
+
if (o.local)
|
|
180
|
+
return { changed, doc, roles: resolveRoles(doc) };
|
|
181
|
+
const teamNow = readTeam(root).doc;
|
|
182
|
+
const modeChanged = (team.doc.mode ?? 'single') !== (teamNow.mode ?? 'single');
|
|
183
|
+
const generated = writeGenerated(root, generateVendorFiles(root), false);
|
|
184
|
+
refreshAgents(root, teamNow, modeChanged);
|
|
185
|
+
return { changed, doc, roles: resolveRoles(doc), generated, reconcile: modeChanged || undefined };
|
|
159
186
|
}
|
|
160
187
|
/** `reins configure gates [--add <name>…]` (spec S-7): subdirectory proposals, appended after the existing gates. */
|
|
161
188
|
export function configureGates(o = {}) {
|