@warren-dean/code-kit 0.22.0 → 0.23.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 +24 -0
- package/README.md +5 -4
- package/bin/code-kit.mjs +105 -77
- package/hooks/guard-bash.mjs +62 -17
- package/hooks/lib/adapters/hub/client.mjs +177 -25
- package/hooks/lib/checks.mjs +3 -1
- package/hooks/lib/config.mjs +13 -2
- package/hooks/lib/instructions.mjs +2 -1
- package/hooks/lib/next.mjs +26 -27
- package/hooks/lib/registry.mjs +70 -3
- package/hooks/lib/report.mjs +76 -7
- package/hooks/lib/rules.mjs +12 -4
- package/hooks/lib/verify.mjs +27 -8
- package/hooks/lib/worktrees.mjs +286 -0
- package/hooks/mod/decisions.mjs +27 -1
- package/hooks/mod/register.mjs +62 -11
- package/hooks/mod/register.test.ts +117 -2
- package/hooks/mod/view.mjs +10 -0
- package/hooks/session.mjs +20 -3
- package/package.json +1 -1
- package/skills/team-init/SKILL.md +1 -1
|
@@ -82,6 +82,8 @@ function project() {
|
|
|
82
82
|
answer: 'Merge',
|
|
83
83
|
open: new Set<string>(),
|
|
84
84
|
opened: [] as string[],
|
|
85
|
+
reportFails: false, // report send: GitHub refuses it
|
|
86
|
+
toasts: [] as string[],
|
|
85
87
|
closed: [] as string[],
|
|
86
88
|
prompts: [] as string[],
|
|
87
89
|
acts: [] as string[][],
|
|
@@ -216,6 +218,18 @@ function stub(on: any, w: World) {
|
|
|
216
218
|
return ran(0, 'Recorded.');
|
|
217
219
|
}
|
|
218
220
|
if (sub === 'ask') return ran(0, JSON.stringify(w.questions));
|
|
221
|
+
if (sub === 'worktrees' && argv[3] === 'discard') {
|
|
222
|
+
w.acts.push([...argv.slice(2)]);
|
|
223
|
+
w.next = {
|
|
224
|
+
...w.next,
|
|
225
|
+
worktrees: (w.next.worktrees ?? []).filter((x: any) => x.branch !== argv[4]),
|
|
226
|
+
};
|
|
227
|
+
return ran(0, `Removed ${argv[4]}'s worktree.`);
|
|
228
|
+
}
|
|
229
|
+
if (sub === 'report' && argv[3] === 'send' && w.reportFails) {
|
|
230
|
+
w.acts.push([...argv.slice(2)]);
|
|
231
|
+
return ran(1, '', "GitHub didn't take it (HTTP 502).");
|
|
232
|
+
}
|
|
219
233
|
if (sub === 'report' && ['send', 'discard'].includes(argv[3])) {
|
|
220
234
|
w.acts.push([...argv.slice(2)]);
|
|
221
235
|
w.reports = w.reports.map((r) =>
|
|
@@ -492,6 +506,10 @@ function stub(on: any, w: World) {
|
|
|
492
506
|
return { value: undefined };
|
|
493
507
|
});
|
|
494
508
|
on('ui.panes', () => ({ value: [...w.open].map((id) => ({ id, title: id, isShown: true })) }));
|
|
509
|
+
on('ui.toast', ($: any, e: any) => {
|
|
510
|
+
w.toasts.push(e.text);
|
|
511
|
+
return { value: undefined };
|
|
512
|
+
});
|
|
495
513
|
on('ui.open', ($: any, e: any) => {
|
|
496
514
|
w.opened.push(e.id);
|
|
497
515
|
w.open.add(e.id);
|
|
@@ -1902,8 +1920,83 @@ test('REPORT-3 a bug report an agent drafted waits for the person, who reads it
|
|
|
1902
1920
|
await ui.find({ type: 'Text', text: '**What happened:** the card never showed' }),
|
|
1903
1921
|
).toBeDefined();
|
|
1904
1922
|
await press($, 'decide-sendReport', PANE);
|
|
1905
|
-
expect(w.acts
|
|
1906
|
-
|
|
1923
|
+
expect(w.acts.filter((a: string[]) => a[0] === 'report' && a[1] === 'send')).toEqual([
|
|
1924
|
+
['report', 'send', 'R-1'],
|
|
1925
|
+
]);
|
|
1926
|
+
// Sent, it leaves the tab, and the result is a toast, not a pane to close.
|
|
1927
|
+
expect(w.toasts).toEqual([
|
|
1928
|
+
"Sending R-1 to code-kit's GitHub…",
|
|
1929
|
+
'Filed https://github.com/o/code-kit/issues/9',
|
|
1930
|
+
]);
|
|
1931
|
+
expect(await ui.find({ type: 'Text', text: '**What happened:** the card never showed' })).toBe(
|
|
1932
|
+
undefined,
|
|
1933
|
+
);
|
|
1934
|
+
expect(w.opened).not.toContain(RESULT);
|
|
1935
|
+
await ui.unmount();
|
|
1936
|
+
});
|
|
1937
|
+
|
|
1938
|
+
test('REPORT-3 a report GitHub refused stays to send again, and says why', async ($, on) => {
|
|
1939
|
+
const w = project();
|
|
1940
|
+
w.reportFails = true;
|
|
1941
|
+
w.reports = [
|
|
1942
|
+
{
|
|
1943
|
+
id: 'R-1',
|
|
1944
|
+
at: '2026-10-13T00:00:00Z',
|
|
1945
|
+
by: 'lead',
|
|
1946
|
+
title: 'Decisions tab misses a held call',
|
|
1947
|
+
fingerprint: 'ck-1',
|
|
1948
|
+
body: '**What happened:** the card never showed',
|
|
1949
|
+
state: 'draft',
|
|
1950
|
+
sent: null,
|
|
1951
|
+
},
|
|
1952
|
+
];
|
|
1953
|
+
await start($, on, w);
|
|
1954
|
+
const band = await bandUi($);
|
|
1955
|
+
await press($, 'band-openDecision');
|
|
1956
|
+
await band.unmount();
|
|
1957
|
+
const ui = await pane($, PANE);
|
|
1958
|
+
await press($, 'decide-sendReport', PANE);
|
|
1959
|
+
expect(w.opened).toContain(RESULT);
|
|
1960
|
+
const result = await pane($, RESULT);
|
|
1961
|
+
expect(await result.find({ type: 'Text', text: /GitHub didn't take it/ })).toBeDefined();
|
|
1962
|
+
await result.unmount();
|
|
1963
|
+
expect(
|
|
1964
|
+
await ui.find({ type: 'Text', text: '**What happened:** the card never showed' }),
|
|
1965
|
+
).toBeDefined();
|
|
1966
|
+
await ui.unmount();
|
|
1967
|
+
});
|
|
1968
|
+
|
|
1969
|
+
test('LEAN-8 a merged worktree still holding changes waits for the person, who keeps it or discards it', async ($, on) => {
|
|
1970
|
+
const w = project();
|
|
1971
|
+
w.next = {
|
|
1972
|
+
...w.next,
|
|
1973
|
+
worktrees: [
|
|
1974
|
+
{ branch: 'web/st-2', story: 'ST-2', changes: 2, files: [' M st2.txt', '?? notes.txt'] },
|
|
1975
|
+
{ branch: 'api/st-3', story: 'ST-3', changes: 1, files: [' M a.ts'] },
|
|
1976
|
+
],
|
|
1977
|
+
};
|
|
1978
|
+
await start($, on, w);
|
|
1979
|
+
const band = await bandUi($);
|
|
1980
|
+
expect(
|
|
1981
|
+
await band.find({
|
|
1982
|
+
type: 'Text',
|
|
1983
|
+
text: '2 merged worktrees still hold changes: web/st-2',
|
|
1984
|
+
}),
|
|
1985
|
+
).toBeDefined();
|
|
1986
|
+
await press($, 'band-openDecision');
|
|
1987
|
+
await band.unmount();
|
|
1988
|
+
const ui = await pane($, PANE);
|
|
1989
|
+
expect(await ui.find({ type: 'Text', text: /\?\? notes\.txt/ })).toBeDefined();
|
|
1990
|
+
await press($, 'decide-discardWorktree', PANE);
|
|
1991
|
+
expect(w.acts).toContainEqual(['worktrees', 'discard', 'web/st-2']);
|
|
1992
|
+
expect(w.opened).not.toContain(RESULT);
|
|
1993
|
+
await press($, 'decide-keepWorktree', PANE);
|
|
1994
|
+
expect(w.acts.filter((a: string[]) => a[0] === 'worktrees')).toEqual([
|
|
1995
|
+
['worktrees', 'discard', 'web/st-2'],
|
|
1996
|
+
]);
|
|
1997
|
+
expect((await ui.findAll({ type: 'Text' })).some((t: any) => /api\/st-3/.test(t.text))).toBe(
|
|
1998
|
+
false,
|
|
1999
|
+
);
|
|
1907
2000
|
await ui.unmount();
|
|
1908
2001
|
});
|
|
1909
2002
|
|
|
@@ -2423,6 +2516,28 @@ test('LEAN-5 a lane agent past its context limit is told to wrap up, and its sto
|
|
|
2423
2516
|
);
|
|
2424
2517
|
});
|
|
2425
2518
|
|
|
2519
|
+
test('#59 an agent that hands back at its limit a story already merged and done is not carried on', async ($, on) => {
|
|
2520
|
+
const w = project();
|
|
2521
|
+
w.next = { step: 'wait', args: '', then: [] };
|
|
2522
|
+
w.stories = w.stories.map((s: any) => (s.id === 'ST-4' ? { ...s, state: 'done' } : s));
|
|
2523
|
+
w.agents = [
|
|
2524
|
+
{ id: 'a1', type: 'web-engineer', description: 'ST-4 booking form', status: 'running' },
|
|
2525
|
+
];
|
|
2526
|
+
const clock = await start($, on, w);
|
|
2527
|
+
await clock.advance(2000);
|
|
2528
|
+
await request($, 'a1', 300);
|
|
2529
|
+
await $.turn.complete({
|
|
2530
|
+
turnId: 't-a1',
|
|
2531
|
+
agentId: 'a1',
|
|
2532
|
+
answer: 'ST-4: committed, report written.',
|
|
2533
|
+
durationMs: 1,
|
|
2534
|
+
isAborted: false,
|
|
2535
|
+
} as any);
|
|
2536
|
+
await leadTurn($, 't-2');
|
|
2537
|
+
await settle(clock);
|
|
2538
|
+
expect(w.prompts.some((p: string) => /handed ST-4 back/.test(p))).toBe(false);
|
|
2539
|
+
});
|
|
2540
|
+
|
|
2426
2541
|
test("LEAN-4 past compact.at the lead's context is compacted between turns, without asking", async ($, on) => {
|
|
2427
2542
|
const w = project();
|
|
2428
2543
|
const compacted: string[] = [];
|
package/hooks/mod/view.mjs
CHANGED
|
@@ -729,6 +729,7 @@ export function bandLines({
|
|
|
729
729
|
questions = [],
|
|
730
730
|
brief = [],
|
|
731
731
|
reports = [],
|
|
732
|
+
worktrees = [],
|
|
732
733
|
working = false,
|
|
733
734
|
task = null,
|
|
734
735
|
elsewhere = [],
|
|
@@ -913,6 +914,15 @@ export function bandLines({
|
|
|
913
914
|
{ id: 'discardReport', label: 'Discard' },
|
|
914
915
|
],
|
|
915
916
|
});
|
|
917
|
+
// LEAN-8: a merged worktree that still holds uncommitted changes: the person keeps it, or discards them.
|
|
918
|
+
if (worktrees.length && !working)
|
|
919
|
+
lines.push({
|
|
920
|
+
kind: 'worktree',
|
|
921
|
+
text: `${worktrees.length > 1 ? `${worktrees.length} merged worktrees still hold changes: ` : 'A merged worktree still holds changes: '}${worktrees[0].branch}`,
|
|
922
|
+
worktree: worktrees[0],
|
|
923
|
+
worktrees,
|
|
924
|
+
actions: [{ id: 'openDecision', label: 'Look…' }],
|
|
925
|
+
});
|
|
916
926
|
// LOOP-7: the milestone is done; LOOP-6: the loop's own state, with Pause or Resume.
|
|
917
927
|
if (loop?.state === 'done')
|
|
918
928
|
lines.push({
|
package/hooks/session.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// SessionStart and SessionEnd (docs/specs/23-the-team.md): a session starting is recorded as a member
|
|
3
|
-
// of the team, the lead session when no other live session leads (SESS-2)
|
|
4
|
-
//
|
|
3
|
+
// of the team, the lead session when no other live session leads (SESS-2), and the worktrees done with
|
|
4
|
+
// are pruned (docs/specs/20-lean-lead.md, LEAN-8); as it ends, it leads nothing more, and the lanes its
|
|
5
|
+
// agents had claimed are free again (SCHED-1). Its task stays, stale (SESS-4).
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
5
7
|
import { readFileSync } from 'node:fs';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
6
9
|
import { loadConfig } from './lib/config.mjs';
|
|
7
10
|
import { releaseSession } from './lib/laneclaims.mjs';
|
|
8
11
|
import { endSession, startSession } from './lib/sessions.mjs';
|
|
@@ -17,7 +20,21 @@ try {
|
|
|
17
20
|
const project = projectDir();
|
|
18
21
|
const { config } = loadConfig(project);
|
|
19
22
|
const session = input.session_id ?? null;
|
|
20
|
-
if (config && session && process.argv[2] === 'start')
|
|
23
|
+
if (config && session && process.argv[2] === 'start') {
|
|
24
|
+
startSession(project, session);
|
|
25
|
+
// LEAN-8: the worktrees left done with since the last session go, in the background: a project with
|
|
26
|
+
// many of them never holds up a session's start.
|
|
27
|
+
spawn(
|
|
28
|
+
process.execPath,
|
|
29
|
+
[
|
|
30
|
+
fileURLToPath(new URL('../bin/code-kit.mjs', import.meta.url)),
|
|
31
|
+
'worktrees',
|
|
32
|
+
'prune',
|
|
33
|
+
'--quiet',
|
|
34
|
+
],
|
|
35
|
+
{ cwd: project, detached: true, stdio: 'ignore' },
|
|
36
|
+
).unref();
|
|
37
|
+
}
|
|
21
38
|
if (config && session && process.argv[2] === 'end') {
|
|
22
39
|
endSession(project, session);
|
|
23
40
|
releaseSession(project, session);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warren-dean/code-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.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",
|
|
@@ -48,7 +48,7 @@ Each is optional; ask, and do only what they want:
|
|
|
48
48
|
|
|
49
49
|
- **CODEOWNERS** (TEAM-11): `team codeowners --write` writes `.github/CODEOWNERS` from the config, so GitHub asks the tech lead and lane owners to review. Then they require code owners' review in a ruleset on the protected branch.
|
|
50
50
|
- **A Project board** (TEAM-12): with a GitHub Project's owner and number, add `"board": { "owner": "<user or organisation>", "number": <n> }` to `team` in the config; the mod then mirrors the plan onto it.
|
|
51
|
-
- **A hosted team provider, only when the config already names one:** hosted providers are in preview, so never offer or suggest one. When `team.provider` is `{ "<name>": "<https address>" }` (set by hand), connect this machine: run `team provider status`; if it isn't signed in, run `team provider signin` in the background, give the person the code and the GitHub address it prints, and wait (they enter the code in their browser; never ask for a password or token); then `team provider connect`, which checks the provider can see the repository
|
|
51
|
+
- **A hosted team provider, only when the config already names one:** hosted providers are in preview, so never offer or suggest one. When `team.provider` is `{ "<name>": "<https address>" }` (set by hand), connect this machine: run `team provider status`; if it isn't signed in, run `team provider signin` in the background, give the person the code and the GitHub address it prints, and wait (they enter the code in their browser; never ask for a password or token); then `team provider connect`, which checks the provider can see the repository, adds its MCP server to `.mcp.json` and links this session (no restart). Commit `.mcp.json` with the config, on the base branch: the hub reads the team from there, and a session only links where the checked-out config names the hub. Then run `team provider status` and give the person its last line; for each ✗, say what it asks for.
|
|
52
52
|
|
|
53
53
|
## 5. Finish
|
|
54
54
|
|