@bluenyang/reins 0.1.3 → 0.1.4-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 +2 -1
- package/cli/dist/commands/check.js +15 -1
- package/cli/dist/commands/configure.js +34 -2
- package/cli/dist/commands/install.js +74 -7
- package/cli/dist/commands/migrate.js +49 -4
- package/cli/dist/commands/stages.js +22 -0
- package/cli/dist/commands/status.js +16 -2
- package/cli/dist/commands/update.js +4 -1
- package/cli/dist/lib/detect.js +114 -1
- package/cli/dist/lib/fsx.js +1 -1
- package/cli/dist/lib/memory.js +96 -0
- package/cli/dist/lib/migrate-plan.js +162 -35
- package/cli/dist/lib/release.js +124 -0
- package/cli/dist/lib/schema.js +2 -0
- package/cli/dist/lib/secrets.js +1 -0
- package/cli/dist/reins.js +42 -5
- package/docs/README.ko.md +2 -1
- package/harness/policy/common-red-lines.yaml +1 -1
- package/harness/roles/deploy.md +15 -8
- package/harness/schemas/install.schema.json +29 -0
- package/package.json +1 -1
- package/skills/reins-release/SKILL.md +2 -2
- package/skills/reins-setup/SKILL.md +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { listFiles } from './fsx.js';
|
|
4
|
+
import { isSecretPath } from './secrets.js';
|
|
5
|
+
const slug = (rel) => rel
|
|
6
|
+
.replace(/\.[^./]+$/, '')
|
|
7
|
+
.toLowerCase()
|
|
8
|
+
.replaceAll(/[^a-z0-9]+/g, '-')
|
|
9
|
+
.replaceAll(/^-+|-+$/g, '') || 'note';
|
|
10
|
+
/**
|
|
11
|
+
* `.claude/memory/*` is someone's own memory, not a decision (design §7): it is never moved or
|
|
12
|
+
* deleted. Each file becomes a knowledge draft the user may accept with `reins knowledge accept`.
|
|
13
|
+
* Pure: reads, never writes. A draft that already exists is left alone.
|
|
14
|
+
*/
|
|
15
|
+
export function planMemoryProposals(root, today) {
|
|
16
|
+
const out = { writes: [], notes: [] };
|
|
17
|
+
const dir = join(root, '.claude/memory');
|
|
18
|
+
if (!existsSync(dir))
|
|
19
|
+
return out;
|
|
20
|
+
// a draft is identified by its `source:`, so names stay stable across runs
|
|
21
|
+
const pdir = join(root, '.loctx/knowledge-proposals');
|
|
22
|
+
const taken = new Set();
|
|
23
|
+
const drafted = new Set();
|
|
24
|
+
const srcOf = (file) => {
|
|
25
|
+
let text;
|
|
26
|
+
try {
|
|
27
|
+
text = readFileSync(file, 'utf8');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null; // a directory or an unreadable entry names no source; its name stays taken
|
|
31
|
+
}
|
|
32
|
+
const m = /^source:\s*(.+)$/m.exec(text);
|
|
33
|
+
return m ? m[1].trim().replace(/^"(.*)"$/, '$1') : null;
|
|
34
|
+
};
|
|
35
|
+
// an accepted entry keeps the source: its draft had, so accepting does not cause a re-draft
|
|
36
|
+
const kdir = join(root, '.agents/knowledge');
|
|
37
|
+
if (existsSync(kdir))
|
|
38
|
+
for (const n of readdirSync(kdir)) {
|
|
39
|
+
if (!n.endsWith('.md'))
|
|
40
|
+
continue;
|
|
41
|
+
const src = srcOf(join(kdir, n));
|
|
42
|
+
if (src)
|
|
43
|
+
drafted.add(src);
|
|
44
|
+
}
|
|
45
|
+
if (existsSync(pdir))
|
|
46
|
+
for (const n of readdirSync(pdir)) {
|
|
47
|
+
if (!/^memory-.*\.md$/.test(n))
|
|
48
|
+
continue;
|
|
49
|
+
taken.add(n.slice(0, -3));
|
|
50
|
+
const src = srcOf(join(pdir, n));
|
|
51
|
+
if (src)
|
|
52
|
+
drafted.add(src);
|
|
53
|
+
}
|
|
54
|
+
for (const f of listFiles(dir)) {
|
|
55
|
+
const source = `.claude/memory/${f}`;
|
|
56
|
+
if (isSecretPath(source))
|
|
57
|
+
continue;
|
|
58
|
+
if (drafted.has(source))
|
|
59
|
+
continue;
|
|
60
|
+
const base = `memory-${slug(f)}`;
|
|
61
|
+
let name = base;
|
|
62
|
+
for (let i = 2; taken.has(name); i++)
|
|
63
|
+
name = `${base}-${i}`;
|
|
64
|
+
taken.add(name);
|
|
65
|
+
const path = `.loctx/knowledge-proposals/${name}.md`;
|
|
66
|
+
let text;
|
|
67
|
+
try {
|
|
68
|
+
text = readFileSync(join(dir, f), 'utf8');
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
out.writes.push({
|
|
74
|
+
path,
|
|
75
|
+
why: 'memory draft',
|
|
76
|
+
content: [
|
|
77
|
+
'---',
|
|
78
|
+
`id: ${today}_${name}`,
|
|
79
|
+
'kind: decision',
|
|
80
|
+
'status: active',
|
|
81
|
+
'supersedes: null',
|
|
82
|
+
'topics: []',
|
|
83
|
+
'decisions: []',
|
|
84
|
+
'symptoms: []',
|
|
85
|
+
'applies_to: all',
|
|
86
|
+
`source: ${JSON.stringify(source)}`,
|
|
87
|
+
'---',
|
|
88
|
+
'## 결정',
|
|
89
|
+
text.replace(/\s*$/, ''),
|
|
90
|
+
'',
|
|
91
|
+
].join('\n'),
|
|
92
|
+
});
|
|
93
|
+
out.notes.push(`memory draft ${path} from ${source} (original kept) — promote with \`reins knowledge accept ${name}\``);
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs';
|
|
2
2
|
import { basename, extname, join } from 'node:path';
|
|
3
3
|
import { listFiles } from './fsx.js';
|
|
4
|
+
import { isSecretPath } from './secrets.js';
|
|
4
5
|
import { splitFrontmatter } from './skills.js';
|
|
5
6
|
const TOOL_EXT = new Set([
|
|
6
7
|
'.cjs',
|
|
@@ -23,14 +24,131 @@ const isToolFile = (f) => TOOL_EXT.has(extname(f).toLowerCase()) || /dockerfile|
|
|
|
23
24
|
function dirFiles(root, rel) {
|
|
24
25
|
return listFiles(join(root, rel)).map((f) => `${rel}/${f}`);
|
|
25
26
|
}
|
|
27
|
+
const natural = (a, b) => a.localeCompare(b, 'en', { numeric: true });
|
|
28
|
+
const slugOf = (fileName) => basename(fileName, '.md')
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replaceAll(/[^a-z0-9]+/g, '-')
|
|
31
|
+
.replaceAll(/^-+|-+$/g, '') || 'work';
|
|
26
32
|
/** A work file is open unless its frontmatter says done. */
|
|
27
|
-
function
|
|
28
|
-
const { data } = splitFrontmatter(readFileSync(
|
|
29
|
-
|
|
33
|
+
function workItem(root, path, dir) {
|
|
34
|
+
const { data } = splitFrontmatter(readFileSync(join(root, path), 'utf8'));
|
|
35
|
+
const fm = data ?? {};
|
|
36
|
+
const name = basename(path, '.md');
|
|
37
|
+
const version = String(fm['version'] ?? (name.includes('_') ? name.split('_')[0] : ''));
|
|
38
|
+
const sub = path.slice(dir.length + 1);
|
|
39
|
+
return {
|
|
40
|
+
path,
|
|
41
|
+
group: `${sub.includes('/') ? sub.slice(0, sub.lastIndexOf('/')) : ''}|${version}`,
|
|
42
|
+
id: fm['id'] == null ? '' : String(fm['id']),
|
|
43
|
+
deps: Array.isArray(fm['depends']) ? fm['depends'].map(String) : [],
|
|
44
|
+
open: !data || String(fm['status'] ?? 'todo') !== 'done',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Tickets an earlier run wrote (by `migrated_from`), and the highest `000-<n>` in use. */
|
|
48
|
+
function existingTickets(root) {
|
|
49
|
+
const list = [];
|
|
50
|
+
let max = 0;
|
|
51
|
+
const dir = '.loctx/ticket';
|
|
52
|
+
for (const f of existsSync(join(root, dir)) ? readdirSync(join(root, dir)) : []) {
|
|
53
|
+
const m = /^000-(\d+)_/.exec(f);
|
|
54
|
+
if (!m)
|
|
55
|
+
continue;
|
|
56
|
+
max = Math.max(max, Number(m[1]));
|
|
57
|
+
const { data } = splitFrontmatter(readFileSync(join(root, dir, f), 'utf8'));
|
|
58
|
+
if (!data?.['migrated_from'])
|
|
59
|
+
continue;
|
|
60
|
+
const from = String(data['migrated_from']);
|
|
61
|
+
const slash = from.lastIndexOf('/');
|
|
62
|
+
const name = basename(from, '.md');
|
|
63
|
+
list.push({
|
|
64
|
+
path: `${dir}/${f}`,
|
|
65
|
+
id: `000-${m[1]}`,
|
|
66
|
+
from,
|
|
67
|
+
origId: data['migrated_id'] == null ? '' : String(data['migrated_id']),
|
|
68
|
+
// tickets from before migrated_group: folder plus the filename's version prefix
|
|
69
|
+
group: data['migrated_group'] == null
|
|
70
|
+
? `${slash < 0 ? '' : from.slice(0, slash)}|${name.includes('_') ? name.split('_')[0] : ''}`
|
|
71
|
+
: String(data['migrated_group']),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return { list, byFrom: new Map(list.map((t) => [t.from, t])), max };
|
|
75
|
+
}
|
|
76
|
+
/** Open work items become `000-1…000-N` in path order; `depends` is remapped only where exactly one item in the same folder and version carries the id, counting tickets from earlier runs. */
|
|
77
|
+
function planTickets(root, ai, files, moves) {
|
|
78
|
+
for (const f of files.filter((x) => !x.endsWith('.md')))
|
|
79
|
+
moves.push({
|
|
80
|
+
from: f,
|
|
81
|
+
to: `.loctx/history/work/${f.slice(`${ai}/work/`.length)}`,
|
|
82
|
+
action: 'move',
|
|
83
|
+
why: 'closed work item',
|
|
84
|
+
});
|
|
85
|
+
const items = files
|
|
86
|
+
.filter((f) => f.endsWith('.md'))
|
|
87
|
+
.toSorted(natural)
|
|
88
|
+
.map((f) => workItem(root, f, `${ai}/work`));
|
|
89
|
+
const prior = existingTickets(root);
|
|
90
|
+
let next = prior.max;
|
|
91
|
+
const numberOf = new Map();
|
|
92
|
+
const pending = [];
|
|
93
|
+
for (const it of items) {
|
|
94
|
+
const sub = it.path.slice(`${ai}/work/`.length);
|
|
95
|
+
if (!it.open) {
|
|
96
|
+
moves.push({
|
|
97
|
+
from: it.path,
|
|
98
|
+
to: `.loctx/history/work/${sub}`,
|
|
99
|
+
action: 'move',
|
|
100
|
+
why: 'closed work item',
|
|
101
|
+
});
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const was = prior.byFrom.get(sub);
|
|
105
|
+
const m = was
|
|
106
|
+
? { from: it.path, to: was.path, action: 'ticket', existing: true, why: 'already migrated' }
|
|
107
|
+
: {
|
|
108
|
+
from: it.path,
|
|
109
|
+
to: '',
|
|
110
|
+
action: 'ticket',
|
|
111
|
+
why: 'open work item → ticket',
|
|
112
|
+
group: it.group,
|
|
113
|
+
};
|
|
114
|
+
if (was)
|
|
115
|
+
numberOf.set(it.path, was.id);
|
|
116
|
+
else {
|
|
117
|
+
next += 1;
|
|
118
|
+
m.n = next;
|
|
119
|
+
m.to = `.loctx/ticket/000-${next}_${slugOf(it.path)}.md`;
|
|
120
|
+
numberOf.set(it.path, `000-${next}`);
|
|
121
|
+
}
|
|
122
|
+
moves.push(m);
|
|
123
|
+
pending.push({ move: m, item: it });
|
|
124
|
+
}
|
|
125
|
+
const here = new Set(items.map((i) => i.path.slice(`${ai}/work/`.length)));
|
|
126
|
+
for (const { move, item } of pending) {
|
|
127
|
+
if (move.existing)
|
|
128
|
+
continue;
|
|
129
|
+
const idMap = {};
|
|
130
|
+
const dropped = [];
|
|
131
|
+
for (const d of item.deps) {
|
|
132
|
+
const same = items.filter((p) => p.group === item.group && p.id === d);
|
|
133
|
+
const old = prior.list.filter((t) => t.group === item.group && t.origId === d && !here.has(t.from));
|
|
134
|
+
if (same.length + old.length !== 1)
|
|
135
|
+
dropped.push(d);
|
|
136
|
+
else if (old[0])
|
|
137
|
+
idMap[d] = old[0].id;
|
|
138
|
+
else if (same[0]?.open) {
|
|
139
|
+
const target = numberOf.get(same[0].path);
|
|
140
|
+
if (target)
|
|
141
|
+
idMap[d] = target;
|
|
142
|
+
} // finished — nothing to wait for
|
|
143
|
+
}
|
|
144
|
+
move.idMap = idMap;
|
|
145
|
+
move.dropped = dropped;
|
|
146
|
+
}
|
|
30
147
|
}
|
|
31
|
-
export function planMigration(root) {
|
|
148
|
+
export function planMigration(root, opts = {}) {
|
|
32
149
|
const moves = [];
|
|
33
150
|
const report = [];
|
|
151
|
+
const legacyDir = opts.legacy === 'committed' ? '.agents/legacy/' : '.loctx/_legacy/';
|
|
34
152
|
const ai = '.ai';
|
|
35
153
|
if (!existsSync(join(root, ai)))
|
|
36
154
|
return { moves, report };
|
|
@@ -51,21 +169,7 @@ export function planMigration(root) {
|
|
|
51
169
|
});
|
|
52
170
|
continue;
|
|
53
171
|
case 'work':
|
|
54
|
-
|
|
55
|
-
if (f.endsWith('.md') && isOpen(join(root, f)))
|
|
56
|
-
moves.push({
|
|
57
|
-
from: f,
|
|
58
|
-
to: `.loctx/ticket/${sub(f)}`,
|
|
59
|
-
action: 'ticket',
|
|
60
|
-
why: 'open work item → ticket',
|
|
61
|
-
});
|
|
62
|
-
else
|
|
63
|
-
moves.push({
|
|
64
|
-
from: f,
|
|
65
|
-
to: `.loctx/history/work/${sub(f)}`,
|
|
66
|
-
action: 'move',
|
|
67
|
-
why: 'closed work item',
|
|
68
|
-
});
|
|
172
|
+
planTickets(root, ai, files, moves);
|
|
69
173
|
continue;
|
|
70
174
|
case 'release':
|
|
71
175
|
case 'pr':
|
|
@@ -101,7 +205,7 @@ export function planMigration(root) {
|
|
|
101
205
|
action: 'legacy',
|
|
102
206
|
why: 'verification assets — review before committing',
|
|
103
207
|
});
|
|
104
|
-
report.push(`${rel}/ (${files.length} files)
|
|
208
|
+
report.push(`${rel}/ (${files.length} files) moved to ${legacyDir} — promote what should be committed to test/`);
|
|
105
209
|
continue;
|
|
106
210
|
case 'plan':
|
|
107
211
|
for (const f of files)
|
|
@@ -176,14 +280,7 @@ export function planMigration(root) {
|
|
|
176
280
|
}
|
|
177
281
|
seen.add(m.to);
|
|
178
282
|
}
|
|
179
|
-
// .claude/memory
|
|
180
|
-
for (const f of dirFiles(root, '.claude/memory'))
|
|
181
|
-
moves.push({
|
|
182
|
-
from: f,
|
|
183
|
-
to: `.agents/knowledge/${f.slice('.claude/memory/'.length)}`,
|
|
184
|
-
action: 'move',
|
|
185
|
-
why: 'shared memory → knowledge',
|
|
186
|
-
});
|
|
283
|
+
// old procedures → legacy (.claude/memory is left in place; install drafts knowledge proposals)
|
|
187
284
|
for (const d of [
|
|
188
285
|
'.claude/commands',
|
|
189
286
|
...(existsSync(join(root, '.claude/skills'))
|
|
@@ -201,30 +298,60 @@ export function planMigration(root) {
|
|
|
201
298
|
why: 'replaced by reins skills',
|
|
202
299
|
});
|
|
203
300
|
if (fs.length)
|
|
204
|
-
report.push(`${d}/ moved to
|
|
301
|
+
report.push(`${d}/ moved to ${legacyDir} — keep any project-specific procedure as a skill in .agents/skills/`);
|
|
302
|
+
}
|
|
303
|
+
if (opts.legacy === 'committed') {
|
|
304
|
+
// committed legacy goes to .agents/legacy/ — except what looks like a secret, which stays local
|
|
305
|
+
const kept = [];
|
|
306
|
+
let moved = 0;
|
|
307
|
+
for (const m of moves) {
|
|
308
|
+
if (m.action !== 'legacy')
|
|
309
|
+
continue;
|
|
310
|
+
if (isSecretPath(m.from)) {
|
|
311
|
+
kept.push(m.from);
|
|
312
|
+
m.why += ' (secret pattern — kept local)';
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
m.to = m.to.replace('.loctx/_legacy/', '.agents/legacy/');
|
|
316
|
+
moved += 1;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
for (const k of kept)
|
|
320
|
+
report.push(`${k} matches a secret pattern — kept in .loctx/_legacy/, not .agents/legacy/`);
|
|
321
|
+
if (moved)
|
|
322
|
+
report.push(`.agents/legacy/ (${moved} files) — review before committing: a script or config there can still hold a secret the patterns do not catch`);
|
|
205
323
|
}
|
|
206
324
|
return { moves, report };
|
|
207
325
|
}
|
|
208
|
-
/**
|
|
209
|
-
|
|
326
|
+
/**
|
|
327
|
+
* work → ticket frontmatter (design §7): `release: <ver>-rc.N` becomes planned; the rest carries over.
|
|
328
|
+
* `n` and `idMap` come from planMigration: the number this item gets, and the new ids its `depends` can use.
|
|
329
|
+
*/
|
|
330
|
+
export function convertWorkToTicket(text, fileName, n, idMap = {}, dropped = [], group = '') {
|
|
210
331
|
const { data, body } = splitFrontmatter(text);
|
|
211
332
|
const fm = data ?? {};
|
|
212
333
|
const rel = String(fm['release'] ?? '');
|
|
334
|
+
const origId = fm['id'] == null ? '' : String(fm['id']);
|
|
335
|
+
const depends = (Array.isArray(fm['depends']) ? fm['depends'].map(String) : [])
|
|
336
|
+
.map((d) => idMap[d])
|
|
337
|
+
.filter((d) => d !== undefined);
|
|
213
338
|
const ticket = {
|
|
214
339
|
// intent 000 = not yet tied to an intent; the PL links it when the work is planned again
|
|
215
|
-
id: `000-${
|
|
340
|
+
id: `000-${n}`,
|
|
216
341
|
intent: '000',
|
|
217
|
-
plan_step: Number(
|
|
342
|
+
plan_step: Number.parseInt(origId, 10) || 1,
|
|
218
343
|
title: String(fm['title'] ?? basename(fileName, '.md')),
|
|
219
344
|
status: ['todo', 'doing', 'blocked', 'done'].includes(String(fm['status']))
|
|
220
345
|
? String(fm['status'])
|
|
221
346
|
: 'todo',
|
|
222
|
-
depends
|
|
347
|
+
depends,
|
|
223
348
|
release: /rc\.(\d+)/.exec(rel) && Number(/rc\.(\d+)/.exec(rel)?.[1]) > 1 ? 'stabilization' : 'planned',
|
|
224
349
|
role: 'implementer',
|
|
225
|
-
asks:
|
|
350
|
+
asks: dropped.map((d) => `depends on ${d} (${fileName}) could not be matched to one migrated ticket — set it by hand`),
|
|
226
351
|
...(fm['branch'] ? { branch: fm['branch'] } : {}),
|
|
227
352
|
migrated_from: fileName,
|
|
353
|
+
...(origId ? { migrated_id: origId } : {}),
|
|
354
|
+
...(group ? { migrated_group: group } : {}),
|
|
228
355
|
};
|
|
229
356
|
const yaml = Object.entries(ticket)
|
|
230
357
|
.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { parse } from 'yaml';
|
|
4
|
+
/** Reads `release:` from install.yaml; null when the file or the key is missing or malformed. */
|
|
5
|
+
export function readRelease(root) {
|
|
6
|
+
const p = join(root, '.agents/harness/install.yaml');
|
|
7
|
+
if (!existsSync(p))
|
|
8
|
+
return null;
|
|
9
|
+
let doc;
|
|
10
|
+
try {
|
|
11
|
+
doc = parse(readFileSync(p, 'utf8'));
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const list = doc?.release?.workflows;
|
|
17
|
+
if (!Array.isArray(list))
|
|
18
|
+
return null;
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const w of list) {
|
|
21
|
+
if (!w || typeof w['file'] !== 'string')
|
|
22
|
+
continue;
|
|
23
|
+
const inputs = {};
|
|
24
|
+
for (const [k, v] of Object.entries(w['inputs'] ?? {}))
|
|
25
|
+
inputs[k] = String(v);
|
|
26
|
+
const explicit = Array.isArray(w['stages']);
|
|
27
|
+
const stages = Array.isArray(w['stages'])
|
|
28
|
+
? w['stages'].filter((s) => s === 'rc' || s === 'stable')
|
|
29
|
+
: [];
|
|
30
|
+
out.push({
|
|
31
|
+
file: w['file'],
|
|
32
|
+
inputs,
|
|
33
|
+
stages: explicit ? stages : ['rc', 'stable'],
|
|
34
|
+
approval: w['approval'] === 'npm-staged' ? 'npm-staged' : 'none',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/** POSIX single-quote `s` unless it only has safe characters. */
|
|
40
|
+
export function shq(s) {
|
|
41
|
+
return /^[A-Za-z0-9_.,:/@%+=-]+$/.test(s) ? s : `'${s.split("'").join("'\\''")}'`;
|
|
42
|
+
}
|
|
43
|
+
/** The `gh workflow run` lines for one stage; `{version}` in an input value becomes `version`. */
|
|
44
|
+
export function dispatchLines(workflows, stage, version) {
|
|
45
|
+
return workflows
|
|
46
|
+
.filter((w) => w.stages.includes(stage))
|
|
47
|
+
.map((w) => {
|
|
48
|
+
const args = Object.entries(w.inputs).flatMap(([k, v]) => [
|
|
49
|
+
'-f',
|
|
50
|
+
shq(`${k}=${v.split('{version}').join(version)}`),
|
|
51
|
+
]);
|
|
52
|
+
return ['gh workflow run', shq(w.file), ...args].join(' ');
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Proposes `release:` settings (design §4) from `.github/workflows/*.yml|yaml` that have an
|
|
57
|
+
* `on: workflow_dispatch` trigger (string, list or map form). Pure: reads, never writes; files
|
|
58
|
+
* that do not parse are ignored. Returns [] when install.yaml already has a `release:` key.
|
|
59
|
+
*/
|
|
60
|
+
const RELEASE_NAME = /release|publish|deploy|ship/i;
|
|
61
|
+
export function draftRelease(root) {
|
|
62
|
+
const pin = join(root, '.agents/harness/install.yaml');
|
|
63
|
+
if (existsSync(pin))
|
|
64
|
+
try {
|
|
65
|
+
const doc = parse(readFileSync(pin, 'utf8'));
|
|
66
|
+
if (doc && typeof doc === 'object' && 'release' in doc)
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// an unreadable pin has no release key to respect
|
|
71
|
+
}
|
|
72
|
+
const dir = join(root, '.github/workflows');
|
|
73
|
+
if (!existsSync(dir))
|
|
74
|
+
return [];
|
|
75
|
+
const out = [];
|
|
76
|
+
for (const f of readdirSync(dir).sort()) {
|
|
77
|
+
if (!/\.ya?ml$/.test(f))
|
|
78
|
+
continue;
|
|
79
|
+
let doc;
|
|
80
|
+
try {
|
|
81
|
+
doc = parse(readFileSync(join(dir, f), 'utf8'));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (!doc || typeof doc !== 'object')
|
|
87
|
+
continue;
|
|
88
|
+
const d = doc;
|
|
89
|
+
const on = 'on' in d ? d['on'] : d['true']; // YAML 1.1 readers turn `on` into true
|
|
90
|
+
let dispatch;
|
|
91
|
+
if (on === 'workflow_dispatch')
|
|
92
|
+
dispatch = {};
|
|
93
|
+
else if (Array.isArray(on))
|
|
94
|
+
dispatch = on.includes('workflow_dispatch') ? {} : undefined;
|
|
95
|
+
else if (on && typeof on === 'object' && 'workflow_dispatch' in on)
|
|
96
|
+
dispatch = on['workflow_dispatch'] ?? {};
|
|
97
|
+
if (dispatch === undefined)
|
|
98
|
+
continue;
|
|
99
|
+
const declared = dispatch?.inputs;
|
|
100
|
+
const inputs = {};
|
|
101
|
+
if (declared && typeof declared === 'object')
|
|
102
|
+
for (const [name, spec] of Object.entries(declared)) {
|
|
103
|
+
const type = spec?.type;
|
|
104
|
+
inputs[name] =
|
|
105
|
+
name === 'version'
|
|
106
|
+
? '{version}'
|
|
107
|
+
: name === 'tag'
|
|
108
|
+
? 'v{version}'
|
|
109
|
+
: type === 'boolean'
|
|
110
|
+
? 'false'
|
|
111
|
+
: '<fill in>';
|
|
112
|
+
}
|
|
113
|
+
out.push({ file: f, inputs, approval: 'none' });
|
|
114
|
+
}
|
|
115
|
+
// CI and scanners are often dispatchable too: when some workflow looks like a release, propose only those
|
|
116
|
+
const releasing = out.filter((d) => RELEASE_NAME.test(d.file));
|
|
117
|
+
return releasing.length ? releasing : out;
|
|
118
|
+
}
|
|
119
|
+
/** The notes install and migrate print for a draft (and their dry runs). */
|
|
120
|
+
export function releaseDraftNotes(drafts) {
|
|
121
|
+
return drafts.map((d) => `release settings draft (not written; add under release.workflows in install.yaml if right): {file: ${d.file}, inputs: {${Object.entries(d.inputs)
|
|
122
|
+
.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)
|
|
123
|
+
.join(', ')}}, approval: ${d.approval}}`);
|
|
124
|
+
}
|
package/cli/dist/lib/schema.js
CHANGED
|
@@ -83,6 +83,8 @@ export function schemaFor(rel) {
|
|
|
83
83
|
if (/(^|\/)(knowledge|knowledge-seeds\/[^/]+)\/[^/]+\.md$/.test(rel) ||
|
|
84
84
|
rel.endsWith('templates/knowledge.md'))
|
|
85
85
|
return { schema: 'knowledge', whole: false };
|
|
86
|
+
if (rel.endsWith('.agents/harness/install.yaml'))
|
|
87
|
+
return { schema: 'install', whole: true };
|
|
86
88
|
if (name.endsWith('.request.yaml') || rel.endsWith('templates/bus/request.yaml'))
|
|
87
89
|
return { schema: 'bus-request', whole: true };
|
|
88
90
|
if (name.endsWith('.response.yaml') || rel.endsWith('templates/bus/response.yaml'))
|
package/cli/dist/lib/secrets.js
CHANGED
package/cli/dist/reins.js
CHANGED
|
@@ -8,7 +8,7 @@ import { acceptKnowledge, dismissKnowledge, proposeKnowledge } from './commands/
|
|
|
8
8
|
import { formatRetro, runRetro } from './commands/retro.js';
|
|
9
9
|
import { runStatus } from './commands/status.js';
|
|
10
10
|
import { runUpdate } from './commands/update.js';
|
|
11
|
-
import { configureBindings } from './commands/configure.js';
|
|
11
|
+
import { configureBindings, configureGates } from './commands/configure.js';
|
|
12
12
|
import { respondRefusal, runGates, writeResponse } from './commands/gate.js';
|
|
13
13
|
import { newIntent, newRequest, newTicket } from './commands/new.js';
|
|
14
14
|
import { collectMetrics, formatMetrics, logCheck, logGates, recordUsage, } from './commands/metrics.js';
|
|
@@ -74,15 +74,26 @@ program
|
|
|
74
74
|
.description('move an existing harness or .ai/ workspace onto the reins layout')
|
|
75
75
|
.argument('<tier>', 'harness | loop | graph')
|
|
76
76
|
.option('--mode <mode>', 'manual | auto', 'manual')
|
|
77
|
+
.option('--legacy <where>', 'local (.loctx/_legacy/) | committed (.agents/legacy/)', 'local')
|
|
77
78
|
.option('--dry-run', 'show the moves without touching anything')
|
|
78
79
|
.option('--json')
|
|
79
80
|
.action(async (tier, o) => {
|
|
81
|
+
if (!['local', 'committed'].includes(o.legacy)) {
|
|
82
|
+
process.stderr.write(`reins migrate: --legacy must be local or committed (got "${o.legacy}")\n`);
|
|
83
|
+
process.exit(2);
|
|
84
|
+
}
|
|
80
85
|
if (!['harness', 'loop', 'graph'].includes(tier)) {
|
|
81
86
|
process.stderr.write(`reins migrate: tier must be harness, loop or graph (got "${tier}")\n`);
|
|
82
87
|
process.exit(2);
|
|
83
88
|
}
|
|
84
89
|
const asker = o.mode === 'auto' || o.dryRun ? defaultsAsker : await stdinAsker();
|
|
85
|
-
const r = await runMigrate({
|
|
90
|
+
const r = await runMigrate({
|
|
91
|
+
tier: tier,
|
|
92
|
+
mode: o.mode,
|
|
93
|
+
dryRun: o.dryRun,
|
|
94
|
+
legacy: o.legacy,
|
|
95
|
+
asker,
|
|
96
|
+
});
|
|
86
97
|
asker.close();
|
|
87
98
|
if (o.json) {
|
|
88
99
|
process.stdout.write(`${JSON.stringify(r, null, 2)}\n`);
|
|
@@ -122,13 +133,17 @@ program
|
|
|
122
133
|
process.exit(2);
|
|
123
134
|
}
|
|
124
135
|
const a = r.install?.applied;
|
|
125
|
-
process.stdout.write(`reins update — harness v${r.from} → v${r.to}${o.dryRun ? ' (dry run)' : ''}\n`);
|
|
136
|
+
process.stdout.write(`reins update — cli ${r.cliFrom === 'none' ? 'none' : `v${r.cliFrom}`} → v${r.cliTo}, harness v${r.from} → v${r.to}${o.dryRun ? ' (dry run)' : ''}\n`);
|
|
126
137
|
for (const c of r.changes)
|
|
127
138
|
process.stdout.write(` · ${c}\n`);
|
|
128
|
-
if (a)
|
|
129
|
-
process.stdout.write(
|
|
139
|
+
if (a && a.created.length + a.changed.length + a.removed.length === 0)
|
|
140
|
+
process.stdout.write('already up to date\n');
|
|
141
|
+
else if (a) {
|
|
142
|
+
process.stdout.write(`${o.dryRun ? 'would write' : 'wrote'}: ${a.created.length} new, ${a.changed.length} changed${a.removed.length ? `, ${a.removed.length} removed` : ''}\n`);
|
|
130
143
|
for (const p of [...a.created, ...a.changed])
|
|
131
144
|
process.stdout.write(` ~ ${p}\n`);
|
|
145
|
+
for (const p of a.removed)
|
|
146
|
+
process.stdout.write(` - ${p} (no longer installed by this tier)\n`);
|
|
132
147
|
}
|
|
133
148
|
for (const n of r.overrides)
|
|
134
149
|
process.stdout.write(`• block "${n}" is overridden by the project — compare it with the new upstream block\n`);
|
|
@@ -175,6 +190,28 @@ configure
|
|
|
175
190
|
process.stdout.write(`• left alone ${x.path}: ${x.why}\n`);
|
|
176
191
|
}
|
|
177
192
|
});
|
|
193
|
+
configure
|
|
194
|
+
.command('gates')
|
|
195
|
+
.description('subdirectory gate proposals not in gates.yaml; --add <name>… appends them')
|
|
196
|
+
.option('--add <names...>', 'proposal names to append after the existing gates')
|
|
197
|
+
.option('--json')
|
|
198
|
+
.action((o) => {
|
|
199
|
+
const r = configureGates({ add: o.add });
|
|
200
|
+
if (o.json) {
|
|
201
|
+
process.stdout.write(`${JSON.stringify(r, null, 2)}\n`);
|
|
202
|
+
process.exit(r.code ?? 0);
|
|
203
|
+
}
|
|
204
|
+
if (r.refused) {
|
|
205
|
+
process.stderr.write(`reins configure gates: ${r.refused}\n`);
|
|
206
|
+
process.exit(r.code ?? 2);
|
|
207
|
+
}
|
|
208
|
+
for (const n of r.added)
|
|
209
|
+
process.stdout.write(`added: ${n}\n`);
|
|
210
|
+
if (!r.available.length)
|
|
211
|
+
process.stdout.write('no more proposals\n');
|
|
212
|
+
for (const g of r.available)
|
|
213
|
+
process.stdout.write(` ${g.name} ${g.cmd} (${g.from})\n`);
|
|
214
|
+
});
|
|
178
215
|
program
|
|
179
216
|
.command('gate')
|
|
180
217
|
.description('run gates.yaml gates as declared; raw output goes to .loctx/reports/ as T3 evidence')
|
package/docs/README.ko.md
CHANGED
|
@@ -122,7 +122,8 @@ reins 자체를 개발하려면 `git clone https://github.com/bluenyang/reins.gi
|
|
|
122
122
|
| `metrics` | 구현됨 | `.loctx/reports/metrics.jsonl` 요약: 역할·벤더·ticket·intent별 토큰, ticket당 knowledge 정지 수. `metrics record`로 역할 실행의 토큰을 남깁니다 |
|
|
123
123
|
| `recall` | 미구현 | 증상으로 과거 결정을 찾습니다 |
|
|
124
124
|
| `doctor` | 미구현 | — |
|
|
125
|
-
| `configure
|
|
125
|
+
| `configure gates` | 구현됨 | 하위 디렉터리 게이트 제안을 보여 줍니다. `--add <name>...`은 gates.yaml 끝에 덧붙입니다 |
|
|
126
|
+
| `configure budget\|language` | 미구현 | — |
|
|
126
127
|
|
|
127
128
|
`install`, `migrate`, `update`, `gate`, `status`, `check`, `metrics`는 `--json`을 받습니다. `check`와 `gate`는 실행할 때마다 `.loctx/reports/metrics.jsonl`에 한 줄을 남깁니다. `check`의 stage는
|
|
128
129
|
T1(`ticket-start`), T2(`pre-commit`), T3(`verdict`), T4(`pre-push`), T5(`rc-close`)에 대응합니다.
|
|
@@ -9,7 +9,7 @@ rules:
|
|
|
9
9
|
text: Editing one's own permission file or any generated vendor file.
|
|
10
10
|
- id: C4
|
|
11
11
|
text: Reading secret files.
|
|
12
|
-
patterns: ['.env', '.env.*', 'secrets/**', '*.key', '*.pem', '*.p12', '*.pfx', '*.properties', 'id_rsa', 'id_rsa.*', 'id_ed25519', 'id_ed25519.*']
|
|
12
|
+
patterns: ['.env', '.env.*', '*.env', 'secrets/**', '*.key', '*.pem', '*.p12', '*.pfx', '*.properties', 'id_rsa', 'id_rsa.*', 'id_ed25519', 'id_ed25519.*']
|
|
13
13
|
allowed: ['.env.example', '*.example', '*.example.*', '*.sample']
|
|
14
14
|
- id: C5
|
|
15
15
|
text: Bypassing hooks (--no-verify) or massaging gate output (pipes that hide the exit code).
|
package/harness/roles/deploy.md
CHANGED
|
@@ -4,7 +4,7 @@ default_binding: "claude-haiku-5-5"
|
|
|
4
4
|
summary: "Pushes, opens PRs, cuts rc releases and publishes notes — inside the pre-release loop only."
|
|
5
5
|
may:
|
|
6
6
|
- "push the feature branch; open and rebase-merge the PR when checks are green"
|
|
7
|
-
- "
|
|
7
|
+
- "dispatch the release workflows the repository configures (install.yaml release:); publish release notes"
|
|
8
8
|
- "escalate to claude-sonnet-5-5 then claude-opus-5-5 on failure"
|
|
9
9
|
must_not:
|
|
10
10
|
- "cut a stable release (user's explicit instruction, every time)"
|
|
@@ -20,19 +20,26 @@ Stage skills: `reins-release`.
|
|
|
20
20
|
|
|
21
21
|
## Merge procedure (design §4 PR flow)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
The merge target is the repository's default branch (`gh repo view --json defaultBranchRef -q .defaultBranchRef.name`), never a name assumed in advance.
|
|
24
|
+
|
|
25
|
+
1. Push the feature branch (`type/topic`); never push to the default branch (T4 holds it, A4).
|
|
24
26
|
2. Open the PR with `gh pr create`; the body comes from the docs role.
|
|
25
27
|
3. Wait: `gh pr checks --watch`.
|
|
26
28
|
4. Only when every required check is green: `gh pr merge --rebase --delete-branch`.
|
|
27
29
|
5. If any check is red, do not merge. Return it to the PL (D2: a red check twice).
|
|
30
|
+
6. Without `release:` in `.agents/harness/install.yaml` the work ends here: report "no release settings".
|
|
28
31
|
|
|
29
32
|
## rc procedure (design §4)
|
|
30
33
|
|
|
31
34
|
1. Run `reins check --stage rc-close --release <V>`. Anything but CONTINUE (open `release: planned` or `release: stabilization` tickets, F2) means no dispatch.
|
|
32
|
-
2.
|
|
33
|
-
3.
|
|
34
|
-
4. Identify the
|
|
35
|
-
5.
|
|
36
|
-
6.
|
|
37
|
-
|
|
35
|
+
2. T5 prints the next rc (`next rc: <V>-rc.<N>`; rc.1 when `.loctx/release/<V>.md` is missing) and one `dispatch: gh workflow run <file> -f k=v …` line per workflow configured for the rc stage (also in `--json`). Or "no release settings": stop after the merge.
|
|
36
|
+
3. Before dispatching record the current UTC time and the expected head commit (the default-branch commit being released). Run each `dispatch:` line exactly as printed. If the run is refused for permissions, do not look for another way: hand the printed line to the user and wait.
|
|
37
|
+
4. Identify the run (every approval mode): `gh run list --workflow <file> --event workflow_dispatch --json databaseId,displayTitle,headSha,createdAt`, keeping runs whose `headSha` equals the expected commit and `createdAt` >= the recorded UTC time. Exactly one match: `gh run watch <id> --exit-status`. Zero or several: stop and ask the user, never guess. On failure: no ledger line; report to the PL.
|
|
38
|
+
5. On success append `- rc.<N> <commit> <date>` to `.loctx/release/<V>.md` (local ledger, not committed). Fixes after an rc are `release: stabilization` tickets; the next rc follows the next T5 pass.
|
|
39
|
+
6. Stable only on the user's explicit instruction (A2): the same workflows whose `stages` include stable, with `{version}` = `<V>`. Then set the intent's `status: released` in its intent.md and commit it.
|
|
40
|
+
|
|
41
|
+
### `approval: npm-staged` (added steps, only for workflows with this value)
|
|
38
42
|
|
|
43
|
+
- Step 4: the one matching run must also have a `displayTitle` that carries the dispatched version.
|
|
44
|
+
- Step 5: read the stage id from that run's log line "staged with id …" and add it to the ledger line: `- rc.<N> <commit> <stage-id> <date>`. Then ask the user to approve the staged version on npm.
|
|
45
|
+
- Step 6: the workflow requires a `v<V>-rc.*` tag exactly at the default branch HEAD; after the stable version is approved on npm, set the intent `status: released`.
|