@warren-dean/code-kit 0.37.0 → 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.
@@ -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)) continue;
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
- if (fix) found.regression.push(...proveFix({ root, from, base, changed, config, fix }));
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
- unfinished = Boolean(failure.timedOut);
482
+ if (failure.timedOut) unrun++;
462
483
  }
463
484
  }
464
- return { changed, found, skipped, unfinished, evidenceUnchecked };
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
  }
@@ -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 }. `here`: this command runs in
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warren-dean/code-kit",
3
- "version": "0.37.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",
@@ -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.
@@ -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.