@warren-dean/code-kit 0.36.1 → 0.38.0
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +16 -0
- package/README.md +87 -59
- package/bin/code-kit.mjs +97 -23
- package/hooks/guard-paths.mjs +4 -0
- package/hooks/lib/checkout.mjs +6 -1
- package/hooks/lib/checks.mjs +1 -0
- package/hooks/lib/config.mjs +9 -3
- package/hooks/lib/harness.mjs +1 -1
- package/hooks/lib/next.mjs +32 -20
- package/hooks/lib/promote.mjs +46 -11
- package/hooks/lib/queue.mjs +42 -4
- package/hooks/lib/regression.mjs +19 -4
- package/hooks/lib/rules.mjs +32 -0
- package/hooks/lib/storymap.mjs +10 -0
- package/hooks/lib/verify.mjs +29 -5
- package/hooks/lib/worktrees.mjs +10 -1
- package/hooks/mod/board.mjs +14 -2
- package/hooks/mod/codemap.mjs +4 -2
- package/hooks/mod/register.mjs +40 -5
- package/hooks/mod/streamview.mjs +95 -0
- package/hooks/mod/view.mjs +10 -0
- package/package.json +1 -1
- package/skills/decide/SKILL.md +2 -0
- package/skills/init/SKILL.md +4 -3
package/hooks/lib/regression.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { execFileSync, spawnSync } from 'node:child_process';
|
|
7
7
|
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
8
8
|
import { join } from 'node:path';
|
|
9
|
-
import { freshCheckout } from './checkout.mjs';
|
|
9
|
+
import { freshCheckout, matchInstalls } from './checkout.mjs';
|
|
10
10
|
import { runChecks } from './checks.mjs';
|
|
11
11
|
import { isDependencyFile } from './dependencies.mjs';
|
|
12
12
|
import { literalPath, matchesAny } from './glob.mjs';
|
|
@@ -250,7 +250,9 @@ export const onlyUnreachable = (output) =>
|
|
|
250
250
|
* REG-1: whether a fix's tests prove its bug. In a fresh checkout of the branch (with its own copy of
|
|
251
251
|
* the checkout's installs, after `regression.prepare`), the checks covering the tests it added
|
|
252
252
|
* or changed must pass, and fail, as the bug, once every change outside the tests goes back to `from`.
|
|
253
|
-
* Problems in words; empty when the tests prove it.
|
|
253
|
+
* Problems in words; empty when the tests prove it. Where the tests couldn't run at all (an install that
|
|
254
|
+
* failed, a tool that isn't installed, a run out of time), the list is marked `unrun`: that says nothing
|
|
255
|
+
* against the branch, so the queue keeps it in its place.
|
|
254
256
|
*/
|
|
255
257
|
export function proveFix({ root, from, base, changed, config, fix }) {
|
|
256
258
|
const what = `This branch fixes ${fix.what}${fix.story ? ` (${fix.story})` : ''}`;
|
|
@@ -292,17 +294,30 @@ export function proveFix({ root, from, base, changed, config, fix }) {
|
|
|
292
294
|
];
|
|
293
295
|
const strict = { ...config, checks: covering.map((c) => ({ ...c, ifMissing: 'fail' })) };
|
|
294
296
|
const actor = { kind: 'lead', label: 'lead' };
|
|
297
|
+
const unrun = (text) => Object.assign([text], { unrun: true });
|
|
295
298
|
const { dir, remove } = freshCheckout(root, 'HEAD', { prefix: 'code-kit-fix-' });
|
|
296
299
|
try {
|
|
297
300
|
const prepare = config.regression?.prepare;
|
|
298
301
|
if (prepare) {
|
|
299
302
|
const res = spawnSync(prepare, { cwd: dir, shell: true, encoding: 'utf8', timeout: 900000 });
|
|
300
303
|
if (res.status !== 0)
|
|
301
|
-
return
|
|
304
|
+
return unrun(
|
|
302
305
|
`regression.prepare (\`${prepare}\`) failed in a fresh checkout, so the fix's tests couldn't run:\n${`${res.stdout ?? ''}${res.stderr ?? ''}`.trim().split('\n').slice(-20).join('\n')}`,
|
|
303
|
-
|
|
306
|
+
);
|
|
307
|
+
} else {
|
|
308
|
+
// As the queue's merged tree does (MQ-1): the installs copied in match this tree, or the
|
|
309
|
+
// project's install runs here first.
|
|
310
|
+
const installs = matchInstalls(dir, root);
|
|
311
|
+
if (installs.failed)
|
|
312
|
+
return unrun(
|
|
313
|
+
`The fix's tests couldn't run: the fresh checkout's ${installs.differ.join(', ')} differ from the installs copied in, and \`${installs.command}\` ${installs.failed.missing ? "isn't installed here" : 'failed'} there${installs.failed.output ? `:\n${installs.failed.output}` : '.'}`,
|
|
314
|
+
);
|
|
304
315
|
}
|
|
305
316
|
const { failure: withFix } = runChecks(strict, tests, dir, actor);
|
|
317
|
+
if (withFix?.missing || withFix?.timedOut)
|
|
318
|
+
return unrun(
|
|
319
|
+
`${what}, but its tests couldn't run in a fresh checkout of the branch (${withFix.title.replace(/ Fix it:$/, '')}). That says nothing against the fix; if they need an install or a build first, set regression.prepare.`,
|
|
320
|
+
);
|
|
306
321
|
if (withFix)
|
|
307
322
|
return [
|
|
308
323
|
`${what}, but its tests don't pass in a fresh checkout of the branch (${withFix.title.replace(/ Fix it:$/, '')}), so code-kit can't tell whether they fail without it. If they need an install or a build first, set regression.prepare.${withFix.output ? `\n${String(withFix.output).trim().split('\n').slice(-20).join('\n')}` : ''}`,
|
package/hooks/lib/rules.mjs
CHANGED
|
@@ -929,6 +929,38 @@ export function laneOf(rel, config) {
|
|
|
929
929
|
);
|
|
930
930
|
}
|
|
931
931
|
|
|
932
|
+
/** The first line of `before` that `after` doesn't keep, in order, or null when it keeps them all. */
|
|
933
|
+
export function droppedLine(before, after) {
|
|
934
|
+
const kept = (after ?? '').split('\n');
|
|
935
|
+
let at = 0;
|
|
936
|
+
for (const line of (before ?? '').split('\n')) {
|
|
937
|
+
while (at < kept.length && kept[at] !== line) at++;
|
|
938
|
+
if (at === kept.length) return line;
|
|
939
|
+
at++;
|
|
940
|
+
}
|
|
941
|
+
return null;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* STRM-6: why a change to a shared list (an anyActor entry with `adds`) is refused, or null. Any lane
|
|
946
|
+
* adds entries to one in its own branch, where its story needs them, with no change request to core;
|
|
947
|
+
* changing or removing an entry already there is its owner's, as with any file it owns.
|
|
948
|
+
*/
|
|
949
|
+
export function sharedListProblem(actor, rel, before, after, config) {
|
|
950
|
+
if (!matchesAny(rel, config.sharedLists ?? []) || before === null || after === null) return null;
|
|
951
|
+
if (
|
|
952
|
+
actor.kind === 'lane' &&
|
|
953
|
+
matchesAny(rel, config.lanes[actor.lane]?.paths ?? []) &&
|
|
954
|
+
!matchesAny(rel, config.lanes[actor.lane]?.exclude ?? [])
|
|
955
|
+
)
|
|
956
|
+
return null;
|
|
957
|
+
if (actor.kind === 'lead' && matchesAny(rel, config.lead.paths)) return null;
|
|
958
|
+
const dropped = droppedLine(before, after);
|
|
959
|
+
if (dropped === null) return null;
|
|
960
|
+
const owner = ownerOf(rel, config) ?? 'its owner';
|
|
961
|
+
return `${rel} is a shared list: any lane adds entries to it, and only ${owner} changes or removes what's already there. This change ${dropped.trim() ? `changes or removes the line \`${dropped.trim().slice(0, 120)}\`` : 'takes out a blank line'}. Keep every existing line as it is and add yours beside them; if an existing entry must change, ask for it as a change to core.`;
|
|
962
|
+
}
|
|
963
|
+
|
|
932
964
|
/** Who reviews a change to a file any agent may write: the lane an anyActor entry names, else the lead. Null for other files. */
|
|
933
965
|
export function reviewerOf(rel, config) {
|
|
934
966
|
if (!matchesAny(rel, config.anyActor)) return null;
|
package/hooks/lib/storymap.mjs
CHANGED
|
@@ -127,6 +127,12 @@ export function laneOfFile(rel, config) {
|
|
|
127
127
|
: null;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/** STRM-10: each layer's owner in a project built as streams: its stream, or `core`; {} without streams. */
|
|
131
|
+
function ownersOf(config) {
|
|
132
|
+
if (!config.streams) return {};
|
|
133
|
+
return Object.fromEntries(config.layers.map((l) => [l.name, l.stream ?? 'core']));
|
|
134
|
+
}
|
|
135
|
+
|
|
130
136
|
/**
|
|
131
137
|
* MAP-1: a story's code: { story, layers, files: [{ path, layer, lane, imports }] }. `layers` are the
|
|
132
138
|
* config's layers in their order, then `tests` and `other` where any file falls there; each file's
|
|
@@ -160,6 +166,8 @@ export function storyMap(root, story, config, from) {
|
|
|
160
166
|
return {
|
|
161
167
|
story: { id: story.id, title: story.title, lane: story.lane, state: story.state },
|
|
162
168
|
layers,
|
|
169
|
+
// STRM-10: in a project built as streams, whose each layer is: a stream's module, or core.
|
|
170
|
+
owners: ownersOf(config),
|
|
163
171
|
files,
|
|
164
172
|
};
|
|
165
173
|
}
|
|
@@ -255,6 +263,8 @@ export function projectMap(root, config, tracked, { depth = 3, most = 60 } = {})
|
|
|
255
263
|
return {
|
|
256
264
|
story: { id: PROJECT, title: 'The whole project', lane: null, state: null },
|
|
257
265
|
layers,
|
|
266
|
+
// STRM-10: in a project built as streams, whose each layer is: a stream's module, or core.
|
|
267
|
+
owners: ownersOf(config),
|
|
258
268
|
files,
|
|
259
269
|
};
|
|
260
270
|
}
|
package/hooks/lib/verify.mjs
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
leadNeedsApproval,
|
|
30
30
|
relayCommand,
|
|
31
31
|
screenProblem,
|
|
32
|
+
sharedListProblem,
|
|
32
33
|
} from './rules.mjs';
|
|
33
34
|
|
|
34
35
|
const git = (root, ...args) =>
|
|
@@ -275,7 +276,21 @@ export function verifyBranch({
|
|
|
275
276
|
found.protected.push(
|
|
276
277
|
`${f} is ${guarded.why}, and the lead ${logged.get(f)?.approval === 'lead' ? 'changed it without' : 'changed it since it had'} the person's ${guarded.approval} approval. The lead merges here, so nobody else reviews it. Ask the person; once they approve it (they run \`! echo "<what you are approving>" > ${APPROVALS_DIR}/${guarded.approval}\`${config.approvals?.lead ? `, or you record their words with \`${relayCommand(guarded.approval)}\`` : ''}), record their approval for the file as it is with a commit of its own: \`git commit -m "Record the person's ${guarded.approval} approval for ${f}"\`. The commit hook logs it; the file doesn't need to change.`,
|
|
277
278
|
);
|
|
278
|
-
if (matchesAny(f, config.anyActor))
|
|
279
|
+
if (matchesAny(f, config.anyActor)) {
|
|
280
|
+
// STRM-6: a branch adds to a shared list; what was there stays as it was, unless the branch owns it.
|
|
281
|
+
if (lane && (lane !== 'lead' || direct.has(f))) {
|
|
282
|
+
const actor = lane === 'lead' ? { kind: 'lead' } : { kind: 'lane', lane };
|
|
283
|
+
const listed = sharedListProblem(
|
|
284
|
+
actor,
|
|
285
|
+
f,
|
|
286
|
+
showAt(root, from, f),
|
|
287
|
+
showAt(root, 'HEAD', f),
|
|
288
|
+
config,
|
|
289
|
+
);
|
|
290
|
+
if (listed) found.ownership.push(listed);
|
|
291
|
+
}
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
279
294
|
if (lane === 'lead') {
|
|
280
295
|
// The lead's branch is held to the lead's paths for what it changes itself; lane work reaches it
|
|
281
296
|
// by merging the lane's branch, which verify held to that lane.
|
|
@@ -445,10 +460,16 @@ export function verifyBranch({
|
|
|
445
460
|
|
|
446
461
|
// REG-1: a fix's tests fail without it, as the bug.
|
|
447
462
|
const fix = fixes ? fixOf(root, branch ?? currentBranchOf(root), config) : null;
|
|
448
|
-
|
|
463
|
+
// What couldn't run or finish says nothing against the branch (a fix check without its installs, a
|
|
464
|
+
// check out of time): counted, so a merge keeps the branch in its place when that's all there is.
|
|
465
|
+
let unrun = 0;
|
|
466
|
+
if (fix) {
|
|
467
|
+
const proved = proveFix({ root, from, base, changed, config, fix });
|
|
468
|
+
found.regression.push(...proved);
|
|
469
|
+
if (proved.unrun) unrun += proved.length;
|
|
470
|
+
}
|
|
449
471
|
|
|
450
472
|
let skipped = [];
|
|
451
|
-
let unfinished = false;
|
|
452
473
|
if (checks) {
|
|
453
474
|
const actor = lane
|
|
454
475
|
? { kind: 'lane', lane, label: `${lane} lane branch` }
|
|
@@ -458,8 +479,11 @@ export function verifyBranch({
|
|
|
458
479
|
const { failure } = ran;
|
|
459
480
|
if (failure) {
|
|
460
481
|
found.checks.push(`${failure.title}\n${failureOutput(failure.output)}`.trim());
|
|
461
|
-
|
|
482
|
+
if (failure.timedOut) unrun++;
|
|
462
483
|
}
|
|
463
484
|
}
|
|
464
|
-
|
|
485
|
+
// Whether every problem found is one that couldn't run or finish.
|
|
486
|
+
const total = Object.values(found).reduce((n, list) => n + list.length, 0);
|
|
487
|
+
const unfinished = unrun > 0 && total === unrun;
|
|
488
|
+
return { changed, found, skipped, unfinished, unrun, evidenceUnchecked };
|
|
465
489
|
}
|
package/hooks/lib/worktrees.mjs
CHANGED
|
@@ -87,7 +87,8 @@ function hasOwnCommits(root, branch) {
|
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* LEAN-6: each worktree but the main checkout: { path, branch, story, merged, clean, changes, report,
|
|
90
|
-
* kind, missing, locked: { reason, pid, live } | null, agentAtWork, here }. `
|
|
90
|
+
* kind, missing, locked: { reason, pid, live } | null, agentAtWork, here, streamLead }. `streamLead`: the
|
|
91
|
+
* stream whose lead works in it (on lead/<stream>, or its lead-<stream> folder), which stays. `here`: this command runs in
|
|
91
92
|
* it (`cwd`, the process's own folder unless given), so taking it away would leave the shell nowhere. `kind` is `agent` (under
|
|
92
93
|
* .claude/worktrees), `merge` (a temporary merge checkout) or `other` (one the person made). `clean` and
|
|
93
94
|
* `changes` are null where they weren't read: an unmerged worktree stays whatever it holds (cleanOf reads it).
|
|
@@ -149,11 +150,17 @@ export function worktrees(root, config, now = Date.now(), cwd = cwdNow()) {
|
|
|
149
150
|
const records = lines ? lines.filter(recordsOnly).length : 0;
|
|
150
151
|
const lane = branch?.includes('/') ? branch.split('/')[0] : null;
|
|
151
152
|
const report = branch ? `.claude/state/reports/${branch.replace(/[^\w.-]+/g, '_')}.md` : null;
|
|
153
|
+
// STRM-2: a stream's lead works from a worktree of its own, on lead/<stream>, for good.
|
|
154
|
+
const streamLead =
|
|
155
|
+
Object.keys(config?.streams ?? {}).find(
|
|
156
|
+
(name) => branch === `lead/${name}` || basename(path) === `lead-${name}`,
|
|
157
|
+
) ?? null;
|
|
152
158
|
return {
|
|
153
159
|
path,
|
|
154
160
|
branch,
|
|
155
161
|
story,
|
|
156
162
|
kind,
|
|
163
|
+
streamLead,
|
|
157
164
|
missing,
|
|
158
165
|
merged,
|
|
159
166
|
clean: changes === null ? null : changes === 0 && records === 0,
|
|
@@ -226,6 +233,8 @@ export function keptBecause(w) {
|
|
|
226
233
|
// A merge run from inside a lane's worktree mustn't take away the folder its own shell is in.
|
|
227
234
|
if (w.here)
|
|
228
235
|
return 'this command runs in it; it goes at the next merge or `code-kit worktrees prune` run from elsewhere';
|
|
236
|
+
if (w.streamLead)
|
|
237
|
+
return `it's the ${w.streamLead} stream's lead's own worktree, where that lead keeps working after its branch merges`;
|
|
229
238
|
if (w.locked && !w.locked.pid)
|
|
230
239
|
return `it's locked${w.locked.reason ? ` (${w.locked.reason})` : ''}`;
|
|
231
240
|
if (!w.branch) return 'it has no branch checked out';
|
package/hooks/mod/board.mjs
CHANGED
|
@@ -662,7 +662,8 @@ export function board(view, els, on) {
|
|
|
662
662
|
children: [
|
|
663
663
|
statusLine(
|
|
664
664
|
'build',
|
|
665
|
-
'
|
|
665
|
+
// STRM-10: a stream's lead builds its own stream.
|
|
666
|
+
view.scope ? `Build: ${view.scope}` : 'Build',
|
|
666
667
|
loopWord,
|
|
667
668
|
progress ? `${progress.tested}/${progress.total}` : null,
|
|
668
669
|
loopWord === 'moving'
|
|
@@ -1168,7 +1169,7 @@ export function board(view, els, on) {
|
|
|
1168
1169
|
children: [
|
|
1169
1170
|
statusLine(
|
|
1170
1171
|
'lanes',
|
|
1171
|
-
'Lanes',
|
|
1172
|
+
view.scope ? `Lanes: ${view.scope}` : 'Lanes',
|
|
1172
1173
|
atWork.length
|
|
1173
1174
|
? `${atWork.length} at work${needle ? ` · filter "${ui.search}"` : ''}`
|
|
1174
1175
|
: 'all resting',
|
|
@@ -1245,6 +1246,15 @@ export function board(view, els, on) {
|
|
|
1245
1246
|
),
|
|
1246
1247
|
]
|
|
1247
1248
|
: []),
|
|
1249
|
+
// STRM-10: the rest of the project, a line per other stream and one for the shared core lanes, and
|
|
1250
|
+
// what core holds of this stream's.
|
|
1251
|
+
...(view.streams ?? []).map((l) =>
|
|
1252
|
+
text(l.text, {
|
|
1253
|
+
key: `stream-line-${l.key}`,
|
|
1254
|
+
wrap: 'truncate-end',
|
|
1255
|
+
...(l.tone === 'note' ? { color: 'yellow' } : { dimColor: true }),
|
|
1256
|
+
}),
|
|
1257
|
+
),
|
|
1248
1258
|
],
|
|
1249
1259
|
});
|
|
1250
1260
|
|
|
@@ -1585,6 +1595,8 @@ export function bandOf(view, els, onAction) {
|
|
|
1585
1595
|
flexDirection: 'row',
|
|
1586
1596
|
columnGap: 1,
|
|
1587
1597
|
children: [
|
|
1598
|
+
// STRM-10: whose build the line is, in a project built as streams.
|
|
1599
|
+
...(view.scope ? [text(view.scope, { bold: true })] : []),
|
|
1588
1600
|
...(progress?.name ? [text(progress.name, { dimColor: true })] : []),
|
|
1589
1601
|
...(runs.length
|
|
1590
1602
|
? [
|
package/hooks/mod/codemap.mjs
CHANGED
|
@@ -65,6 +65,8 @@ export function layout(map, width = 100) {
|
|
|
65
65
|
// A gutter of GUTTER cells left of each column carries the imports between files of one layer.
|
|
66
66
|
const columns = layers.map((layer, i) => ({
|
|
67
67
|
layer,
|
|
68
|
+
// STRM-10: a column says whose layer it is, core or a stream's module.
|
|
69
|
+
label: map.owners?.[layer] ? `${layer} · ${map.owners[layer]}` : layer,
|
|
68
70
|
x: GUTTER + i * (colW + COL_GAP),
|
|
69
71
|
width: colW,
|
|
70
72
|
}));
|
|
@@ -118,7 +120,7 @@ export function mapRows(map, { glow = {}, selected = null, width = 100 } = {}) {
|
|
|
118
120
|
grid[y][x] = { ch, style, ...(lane ? { lane } : {}) };
|
|
119
121
|
};
|
|
120
122
|
for (const c of L.columns) {
|
|
121
|
-
const label = fit(c.layer, c.width);
|
|
123
|
+
const label = fit(c.label ?? c.layer, c.width);
|
|
122
124
|
[...label].forEach((ch, i) => put(c.x + i, 0, ch, 'dim'));
|
|
123
125
|
}
|
|
124
126
|
// Edges first, so the boxes draw over their ends: from the importer's side to the imported's.
|
|
@@ -248,7 +250,7 @@ export function mapSvg(map, { glow = {}, selected = null, tints = {}, width = 10
|
|
|
248
250
|
const parts = [];
|
|
249
251
|
for (const c of L.columns)
|
|
250
252
|
parts.push(
|
|
251
|
-
`<text x="${10 + c.x * CW}" y="${10 + RH * 0.8}" fill="#7f8c8d" font-size="11">${esc(c.layer)}</text>`,
|
|
253
|
+
`<text x="${10 + c.x * CW}" y="${10 + RH * 0.8}" fill="#7f8c8d" font-size="11">${esc(c.label ?? c.layer)}</text>`,
|
|
252
254
|
);
|
|
253
255
|
for (const f of map.files)
|
|
254
256
|
for (const target of f.imports) {
|
package/hooks/mod/register.mjs
CHANGED
|
@@ -109,6 +109,14 @@ import { goalOf, nextText } from './mission.mjs';
|
|
|
109
109
|
import { contextOf, decisionCards, decisionKey, newDecisions } from './decisions.mjs';
|
|
110
110
|
import { DEFAULT_TEAM_UI, TEAM_ID, teamFrame } from './teamview.mjs';
|
|
111
111
|
import { glowOf, mapStoryOf, touchOf } from './codemap.mjs';
|
|
112
|
+
import {
|
|
113
|
+
scopeOf,
|
|
114
|
+
scopeWord,
|
|
115
|
+
scopedCheck,
|
|
116
|
+
scopedState,
|
|
117
|
+
scopedStatus,
|
|
118
|
+
streamLines,
|
|
119
|
+
} from './streamview.mjs';
|
|
112
120
|
import { harnessSettings } from '../lib/harness.mjs';
|
|
113
121
|
import {
|
|
114
122
|
REVIEW_WAIT_MS,
|
|
@@ -377,7 +385,13 @@ export function register(on) {
|
|
|
377
385
|
const check = parseJson(ran.stdout);
|
|
378
386
|
const valid = Boolean(check?.valid);
|
|
379
387
|
const status = valid ? await json('status') : null;
|
|
380
|
-
const nextStep = valid ? await json('next') : null;
|
|
388
|
+
const nextStep = valid ? await json('next', '--session', session) : null;
|
|
389
|
+
// STRM-10: in a project built as streams, this session's views are its own streams'.
|
|
390
|
+
const streams =
|
|
391
|
+
valid && check.streams?.length
|
|
392
|
+
? await json('streams', '--session', session).catch(() => null)
|
|
393
|
+
: null;
|
|
394
|
+
const scope = scopeOf(streams);
|
|
381
395
|
const all = valid ? await json('requests') : null;
|
|
382
396
|
// OWN-1: this session's decisions, and how many wait in each other session; null from a code-kit
|
|
383
397
|
// that can't say, where every open decision shows.
|
|
@@ -443,11 +457,16 @@ export function register(on) {
|
|
|
443
457
|
const atWork = agentsAtWork(await $.agent.list().catch(() => []));
|
|
444
458
|
const before = { state: model.state, status: model.status, queue: model.queue };
|
|
445
459
|
model = {
|
|
446
|
-
state:
|
|
460
|
+
state: scopedState(
|
|
461
|
+
projectState(scopedCheck(check, scope), scopedStatus(status, scope), nextStep, atWork),
|
|
462
|
+
scope,
|
|
463
|
+
),
|
|
447
464
|
requests,
|
|
448
465
|
stops,
|
|
449
466
|
queue,
|
|
450
|
-
status,
|
|
467
|
+
status: scopedStatus(status, scope),
|
|
468
|
+
streams,
|
|
469
|
+
scope,
|
|
451
470
|
timeline,
|
|
452
471
|
adapters,
|
|
453
472
|
check,
|
|
@@ -1381,7 +1400,18 @@ export function register(on) {
|
|
|
1381
1400
|
return lease.mine;
|
|
1382
1401
|
},
|
|
1383
1402
|
// LOOP-10: the person moves the loop to this session; the other stops prompting its lead.
|
|
1384
|
-
leadHere: async () => {
|
|
1403
|
+
leadHere: async (line) => {
|
|
1404
|
+
// STRM-10: a stream chosen to lead from here becomes this session's stream first.
|
|
1405
|
+
if (line?.stream) {
|
|
1406
|
+
const ran = await $.process
|
|
1407
|
+
.run(['node', cli, 'sessions', 'lead', line.stream, '--session', session], { cwd })
|
|
1408
|
+
.catch(() => ({ exitCode: 1, stderr: '', stdout: '' }));
|
|
1409
|
+
if (ran.exitCode !== 0) {
|
|
1410
|
+
notice = `This session couldn't lead ${line.stream}: ${firstLine(ran) || 'code-kit sessions lead failed'}.`;
|
|
1411
|
+
$.ui.invalidate('ui.render');
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1385
1415
|
if (!(await act.lead({ take: true }))) {
|
|
1386
1416
|
notice = "This session couldn't take the loop: code-kit loop lead failed.";
|
|
1387
1417
|
$.ui.invalidate('ui.render');
|
|
@@ -1816,7 +1846,9 @@ export function register(on) {
|
|
|
1816
1846
|
}
|
|
1817
1847
|
return act.submit(prompt, 'restart', story);
|
|
1818
1848
|
}
|
|
1819
|
-
const ran = await $.process.run(['node', cli, 'next', '--json'], {
|
|
1849
|
+
const ran = await $.process.run(['node', cli, 'next', '--json', '--session', session], {
|
|
1850
|
+
cwd,
|
|
1851
|
+
});
|
|
1820
1852
|
// LOOP-13: a parked story stays out of the step until what it waits on moves.
|
|
1821
1853
|
await act.unpark();
|
|
1822
1854
|
// LOOP-9: never a story an agent is already at work on, building or reviewing it.
|
|
@@ -3162,6 +3194,8 @@ export function register(on) {
|
|
|
3162
3194
|
{
|
|
3163
3195
|
state,
|
|
3164
3196
|
status: model.status ?? null,
|
|
3197
|
+
scope: scopeWord(model.scope),
|
|
3198
|
+
streams: streamLines(model.streams, model.scope),
|
|
3165
3199
|
loop: loopView,
|
|
3166
3200
|
needs,
|
|
3167
3201
|
live,
|
|
@@ -3281,6 +3315,7 @@ export function register(on) {
|
|
|
3281
3315
|
{
|
|
3282
3316
|
state: stateNow(),
|
|
3283
3317
|
status: model.status ?? null,
|
|
3318
|
+
scope: scopeWord(model.scope),
|
|
3284
3319
|
loop: { ...loopNow(now), queue: model.queue ?? [] },
|
|
3285
3320
|
needs: needsOf(linesNow(now)),
|
|
3286
3321
|
leadBusy: Boolean(leadTurn),
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Streams in the mod (docs/specs/31-streams-and-platform.md, STRM-10): a stream's lead sees its own
|
|
2
|
+
// stream's build. The project's state is scoped to the streams this session leads (or works in), and
|
|
3
|
+
// the rest of the project is a line per other stream, and one for the core lanes they share.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* STRM-10: what this session's views are scoped to, from `code-kit streams --json`: the streams it leads
|
|
7
|
+
* or works in, their lanes with the shared core lanes, their stories and their requirements. Null in a
|
|
8
|
+
* project without streams, or for a session in none, which sees the whole project.
|
|
9
|
+
*/
|
|
10
|
+
export function scopeOf(streams) {
|
|
11
|
+
const mine = (streams?.streams ?? []).filter((s) => (streams.mine ?? []).includes(s.name));
|
|
12
|
+
if (!mine.length) return null;
|
|
13
|
+
return {
|
|
14
|
+
names: mine.map((s) => s.name),
|
|
15
|
+
label: mine.map((s) => s.label ?? s.name).join(', '),
|
|
16
|
+
lanes: new Set([...mine.flatMap((s) => s.lanes), ...(streams.shared ?? []).map((x) => x.lane)]),
|
|
17
|
+
stories: new Set(mine.flatMap((s) => s.stories ?? [])),
|
|
18
|
+
requirements: new Set(mine.flatMap((s) => s.requirements ?? [])),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** STRM-10: `code-kit check --json` with only the scope's lanes, so the Lanes panel draws its own. */
|
|
23
|
+
export function scopedCheck(check, scope) {
|
|
24
|
+
if (!scope || !check?.lanes) return check;
|
|
25
|
+
return {
|
|
26
|
+
...check,
|
|
27
|
+
lanes: Object.fromEntries(
|
|
28
|
+
Object.entries(check.lanes).filter(([name]) => scope.lanes.has(name)),
|
|
29
|
+
),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* STRM-10: `code-kit status --json` with only the scope's stories and requirements, so the Build bar,
|
|
35
|
+
* the milestone and the Trail count its own stream's.
|
|
36
|
+
*/
|
|
37
|
+
export function scopedStatus(status, scope) {
|
|
38
|
+
if (!scope || !status) return status;
|
|
39
|
+
return {
|
|
40
|
+
...status,
|
|
41
|
+
stories: (status.stories ?? []).filter((s) => scope.stories.has(s.id)),
|
|
42
|
+
requirements: (status.requirements ?? []).filter((r) => scope.requirements.has(r.id)),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** STRM-10: the stories ready to start, less other streams': `next` gives a stream's lead its own. */
|
|
47
|
+
export function scopedState(state, scope) {
|
|
48
|
+
if (!scope || state?.kind !== 'ok') return state;
|
|
49
|
+
return { ...state, ready: state.ready.filter((r) => scope.stories.has(r.id)) };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* STRM-10: the rest of the project, a line each: every other stream with its lead and what its lanes are
|
|
54
|
+
* on, then the core lanes the streams share with whose turn each is. And, for this session's streams,
|
|
55
|
+
* the stories core holds and what is theirs to decide for core. [{ key, text, tone }], tone 'dim' or
|
|
56
|
+
* 'note'.
|
|
57
|
+
*/
|
|
58
|
+
export function streamLines(streams, scope) {
|
|
59
|
+
if (!streams?.streams?.length) return [];
|
|
60
|
+
const lines = [];
|
|
61
|
+
for (const s of streams.streams) {
|
|
62
|
+
if (scope?.names.includes(s.name)) {
|
|
63
|
+
for (const h of s.held ?? [])
|
|
64
|
+
lines.push({ key: `held-${h.story}`, text: h.why, tone: 'note' });
|
|
65
|
+
if (s.toDecide?.length)
|
|
66
|
+
lines.push({
|
|
67
|
+
key: `decide-${s.name}`,
|
|
68
|
+
text: `for core: ${s.toDecide.join(', ')} ${s.toDecide.length === 1 ? 'is' : 'are'} the ${s.label ?? s.name} lead's to decide`,
|
|
69
|
+
tone: 'note',
|
|
70
|
+
});
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const at = (s.running ?? []).map((r) => `${r.lane} ${r.story ?? 'a story'}`);
|
|
74
|
+
lines.push({
|
|
75
|
+
key: `stream-${s.name}`,
|
|
76
|
+
text: `${s.label ?? s.name}${s.platform ? ' (platform)' : ''} · ${s.lead ? `led by ${s.lead.member}` : 'no lead'} · ${at.length ? at.join(', ') : 'no lane at work'}`,
|
|
77
|
+
tone: 'dim',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const shared = streams.shared ?? [];
|
|
81
|
+
if (shared.length)
|
|
82
|
+
lines.push({
|
|
83
|
+
key: 'shared',
|
|
84
|
+
text: `core, shared in turns: ${shared.map((x) => `${x.lane}${x.running ? ` on ${x.running}` : ''}${x.turn ? ` (${x.turn}'s turn last)` : ''}`).join(', ')}`,
|
|
85
|
+
tone: 'dim',
|
|
86
|
+
});
|
|
87
|
+
return lines;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** STRM-10: the band's word for the scope: "play" heads the build line, so a lead knows whose it is. */
|
|
91
|
+
export const scopeWord = (scope) => (scope ? scope.label : null);
|
|
92
|
+
|
|
93
|
+
/** STRM-10: the streams with no lead, each offered as a stream to lead from here. */
|
|
94
|
+
export const leaderless = (streams) =>
|
|
95
|
+
(streams?.streams ?? []).filter((s) => !s.lead).map((s) => s.name);
|
package/hooks/mod/view.mjs
CHANGED
|
@@ -301,6 +301,7 @@ export function bandLines({
|
|
|
301
301
|
working = false,
|
|
302
302
|
task = null,
|
|
303
303
|
elsewhere = [],
|
|
304
|
+
streams = null,
|
|
304
305
|
}) {
|
|
305
306
|
// SESS-3: a working session's lines are only its own: no queue, reviews or team. The build's own
|
|
306
307
|
// progress, the loop's state and the agents at work are the Build panel's and the band's one line
|
|
@@ -549,6 +550,15 @@ export function bandLines({
|
|
|
549
550
|
text: `Milestone done: ${plural(loop.doneCount, 'story', 'stories')} merged`,
|
|
550
551
|
actions: [{ id: 'dismissDone', label: 'Dismiss' }],
|
|
551
552
|
});
|
|
553
|
+
else if ((loop?.state === 'elsewhere' || loop?.state === 'unled') && streams?.streams?.length)
|
|
554
|
+
// STRM-10: in a project built as streams, a stream to lead from here, each with who leads it now.
|
|
555
|
+
for (const s of streams.streams.filter((x) => !(streams.mine ?? []).includes(x.name)))
|
|
556
|
+
lines.push({
|
|
557
|
+
kind: 'loop',
|
|
558
|
+
text: `${s.label ?? s.name}: ${s.lead ? `led by ${s.lead.member}` : 'no session leads it'}`,
|
|
559
|
+
stream: s.name,
|
|
560
|
+
actions: [{ id: 'leadHere', label: `Lead ${s.name}` }],
|
|
561
|
+
});
|
|
552
562
|
else if (loop?.state === 'elsewhere' || loop?.state === 'unled')
|
|
553
563
|
// SESS-2: another session leads the project, or none does; this one never prompts its lead.
|
|
554
564
|
lines.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warren-dean/code-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Keeps AI coding agents inside your project's rules: lanes, layer rules, protected paths and proof before finish, enforced by Claude Code hooks and in CI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Warren Langeveldt",
|
package/skills/decide/SKILL.md
CHANGED
|
@@ -64,6 +64,8 @@ In a project built as streams with a platform stream (spec 31), a stream that ne
|
|
|
64
64
|
- **Accept it** with the platform story that builds it, written in the platform's plan: `code-kit core accept C-n --story ST-n`. The asking story waits for that story to merge.
|
|
65
65
|
- **Decline it** with why, and what the stream can do instead: `code-kit core decline C-n --reason "…"`. The asking story no longer waits.
|
|
66
66
|
|
|
67
|
+
When the ask is only a new entry in a list every stream adds to (an allow-list of routes, a catalogue of lines, a registry), the list is better as a shared list than as a stream of asks: propose to the person that the config name it one (`anyActor` with `"adds": true` and the owning lane as reviewer). Until it's changed, accept or decline the ask as usual; from then on, the stream's lane adds its entries in its own branch.
|
|
68
|
+
|
|
67
69
|
## 6. Report
|
|
68
70
|
|
|
69
71
|
One line per request: what was asked, what you decided, and why. "ST-138: pillow approved for api (MED-5 needs HEIC decoding; nothing installed reads HEIC)." Then carry on with the build.
|
package/skills/init/SKILL.md
CHANGED
|
@@ -66,7 +66,8 @@ Write `.claude/code-kit.draft.json`. Follow `${CLAUDE_PLUGIN_ROOT}/README.md`
|
|
|
66
66
|
- `"streams": { "<line>": { "label", "lanes", "plan", "specs" } }`, each lane in exactly one stream: a line's lanes own its modules (`api-<line>`, `web-<line>`);
|
|
67
67
|
- each module's layer gets `"stream": "<line>"`; core's layers have none. The import check then refuses a module importing another line's module, and core importing a module;
|
|
68
68
|
- core's lanes go in a stream with `"platform": true` when the person wants a team to own core (its lead decides what goes into core, and the other streams ask it with `code-kit core ask`); otherwise they're in no stream, and the streams take them in turns;
|
|
69
|
-
- each stream's lead runs in its own session: `/code-kit:lead <stream>`; the first one leads from the main checkout, the others from a worktree each
|
|
69
|
+
- each stream's lead runs in its own session: `/code-kit:lead <stream>`; the first one leads from the main checkout, the others from a worktree each;
|
|
70
|
+
- core files every stream's stories add entries to (an allow-list of routes, a catalogue, a registry: look for the files the specs or the code say each feature registers in) go in `anyActor` as shared lists, `{ "glob", "reviewer": "<owning lane>", "adds": true }`, so a stream adds its entries without a change request to core.
|
|
70
71
|
- **A QA lane:** when lanes own screens, or the plan's journeys cross lanes, a `qa` lane with a `test-engineer` agent owning the end-to-end suites (the plan's work split names them; brownfield: the folders the existing end-to-end tests live in), even if the docs forgot it. Its agent's proving command runs the suites. Add a `checks` entry for them scoped by `files` to the suites, so verify runs them when they change. Unit tests stay with each lane.
|
|
71
72
|
- **`setup`:** `3`, the version of this setup, so `code-kit next` can tell an older project what re-running init adds.
|
|
72
73
|
- **`lead.paths`:** contracts, specs, design, root config, and anything the docs reserve for the lead.
|
|
@@ -81,8 +82,8 @@ Write `.claude/code-kit.draft.json`. Follow `${CLAUDE_PLUGIN_ROOT}/README.md`
|
|
|
81
82
|
- **`shell.restricted`:** commands that affect a shared local service, limited to the lanes that own it.
|
|
82
83
|
- **`postEdit`:** the project's existing per-file linters and formatters, with `{file}`.
|
|
83
84
|
- **`checks`:** the typecheck, test, architecture and database commands, each scoped by `files`. Only include commands that pass on the current code, or ones the person chose to keep.
|
|
84
|
-
- **`harness.autonomy`:** ask the person how hands-off they want the build. With the code-kit mod (Claude Code 2.1.287 or later), once the plan has stories, a lead loop can keep the work moving between their prompts: it prompts the lead to dispatch ready stories, review finished ones and merge them where merges are delegated. Offer the four choices in plain words: `autonomous` (it keeps going on its own; they can pause it from the band), `propose` (each step waits in the band for their Go), `off`, or `vibe` (it keeps going on its own, and every product and project decision is the lead's: the specs for later milestones, the designs, CI, the standards, packages, weakened tests, merges and pushes; they're asked only for what nobody else can give, an account with a service provider, a key from one, a payment, or an act outside the repository). Say what vibe gives up: nobody but the lead reviews a decision before it's built on, and a push to the base can deploy. Put their answer in the draft as `"harness": { "autonomy": "…" }`. If they'd rather decide later, leave it out: the loop then asks them in the band before its first step. With `autonomous`, the lead owns delivery, so also draft `"merge": true` in `approvals.delegate`: the lead merges a reviewed branch once every check passes. With `vibe`, leave `approvals.delegate` out: vibe delegates everything, whatever it says, and
|
|
85
|
-
- **`approvals.delegate`, who decides what (HELM-1, WHO-1):** the person is the product owner; the lead decides everything technical, so lanes ask the lead, never the person. With no `approvals.delegate`, that's the default: the lead approves new packages (only when the story's requirements need them and they fit the spec, the principles and the architecture; npm packages must also pass the registry limits on licence, popularity and age), every protected change except the specs (`spec`), the screens' designs (`design`), CI (`ci`) and the kit, merges into the base, and weakened tests on a lane's branch after its review. Show the person the split in two lines, what they keep and what the lead decides, and ask if they want to keep anything else. Only if they do, draft `approvals.delegate` with exactly what the lead keeps (`{ "protected": [...], "merge": true, "tests": true, "dependencies": {} }`, leaving out what they keep), or `false` to keep everything. They can change it later in
|
|
85
|
+
- **`harness.autonomy`:** ask the person how hands-off they want the build. With the code-kit mod (Claude Code 2.1.287 or later), once the plan has stories, a lead loop can keep the work moving between their prompts: it prompts the lead to dispatch ready stories, review finished ones and merge them where merges are delegated. Offer the four choices in plain words: `autonomous` (it keeps going on its own; they can pause it from the band), `propose` (each step waits in the band for their Go), `off`, or `vibe` (it keeps going on its own, and every product and project decision is the lead's: the specs for later milestones, the designs, CI, the standards, packages, weakened tests, merges and pushes; they're asked only for what nobody else can give, an account with a service provider, a key from one, a payment, or an act outside the repository). Say what vibe gives up: nobody but the lead reviews a decision before it's built on, and a push to the base can deploy. Put their answer in the draft as `"harness": { "autonomy": "…" }`. If they'd rather decide later, leave it out: the loop then asks them in the band before its first step. With `autonomous`, the lead owns delivery, so also draft `"merge": true` in `approvals.delegate`: the lead merges a reviewed branch once every check passes. With `vibe`, leave `approvals.delegate` out: vibe delegates everything, whatever it says, and `/harness`'s Approvals section shows every approval as the lead's.
|
|
86
|
+
- **`approvals.delegate`, who decides what (HELM-1, WHO-1):** the person is the product owner; the lead decides everything technical, so lanes ask the lead, never the person. With no `approvals.delegate`, that's the default: the lead approves new packages (only when the story's requirements need them and they fit the spec, the principles and the architecture; npm packages must also pass the registry limits on licence, popularity and age), every protected change except the specs (`spec`), the screens' designs (`design`), CI (`ci`) and the kit, merges into the base, and weakened tests on a lane's branch after its review. Show the person the split in two lines, what they keep and what the lead decides, and ask if they want to keep anything else. Only if they do, draft `approvals.delegate` with exactly what the lead keeps (`{ "protected": [...], "merge": true, "tests": true, "dependencies": {} }`, leaving out what they keep), or `false` to keep everything. They can change it later in `/harness`'s Approvals section.
|
|
86
87
|
- **`harness.agents.lanes.model`:** ask which model the lane agents run on. Each lane agent builds one story inside its own paths, with its requirements and acceptance criteria in its brief, and the hooks, `verify` and the lead's review catch what it gets wrong, so most stories don't need the session's model. Recommend `story`: each story runs on the model its `**Size:**` in the plan gives (Haiku for small, Sonnet for medium, Opus for large), raised to Opus for a security requirement, to Sonnet at least for a fix, and one step for each time its branch is sent back. Offer one model for every lane (`sonnet`) as the simpler choice, and say the lead, the reviewer and the security reviewer keep their own models either way. A lane's agent file with its own `model:` keeps that. Put their answer in `harness` as `"agents": { "lanes": { "model": "story" } }`, or leave it out for the session's model. A project set up before sizes existed has stories with none, which run on Sonnet until the lead sizes them.
|
|
87
88
|
- **`harness.report.on`:** ask whether agents may draft bug reports for code-kit itself when code-kit gets in their way (a refusal that shouldn't have happened, a crash). Each report holds only code-kit's own facts (its version, the rule, what it said, the command), never the project's code, paths or data, and waits in their band and the pane's Needs you: they read it and send it to code-kit's public GitHub under their own account, or discard it. Off unless they say yes; put `"report": { "on": true }` in `harness` if they do.
|
|
88
89
|
- **`docs.standards`:** `docs/standards.md` unless the project keeps its standards elsewhere (see Standards, below).
|