@warren-dean/code-kit 0.38.0 → 0.38.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,7 +9,7 @@
9
9
  "name": "code-kit",
10
10
  "source": "./",
11
11
  "description": "Keeps AI coding agents inside your project's rules, from idea to merged code: spec design, lanes, layer rules, protected paths with an approval log, spec-check and design gates, proof-before-finish checks, dispatch, review, build status and CI verification, configured per project from its docs",
12
- "version": "0.38.0",
12
+ "version": "0.38.1",
13
13
  "category": "development",
14
14
  "tags": ["guardrails", "architecture", "lanes", "layers", "spec-driven", "ci", "multi-agent"],
15
15
  "license": "MIT"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-kit",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
4
4
  "description": "Keeps AI coding agents inside your project's rules, from idea to merged code: spec design, lanes, layer rules, protected paths with an approval log, spec-check and design gates, proof-before-finish checks, dispatch, review, build status and CI verification, configured per project from its docs",
5
5
  "author": {
6
6
  "name": "Warren Langeveldt"
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  What changed in each release of code-kit, newest first. Versions follow the plugin manifest and the npm package `@warren-dean/code-kit`. Each release is also on [GitHub Releases](https://github.com/warrendeanlangeveldt/code-kit/releases).
4
4
 
5
+ ## 0.38.1 (2026-11-16)
6
+
7
+ - **Shared lists found from the history.** In a project built as streams, `code-kit next` now tells the platform's lead (or the lead in the main checkout) when a core file looks like a shared list: three stories of two or more streams changed it only by adding lines. It names the stories and gives the `anyActor` entry to propose to you, so a project set up before shared lists existed finds its own without re-running init.
8
+
5
9
  ## 0.38.0 (2026-11-16)
6
10
 
7
11
  - **Any stream's lead merges the queue.** In a project built as streams only the lead in the main checkout was given the merge step, so every stream's reviewed branches waited on that one session, while it worked on its own stream's stories: branches waited three to twelve hours, and dozens stood in the queue. Now another stream's lead merges the queue's head whenever its own stream has only waiting to do. One merge still runs at a time: a lock stops two leads starting one at once.
package/README.md CHANGED
@@ -438,7 +438,7 @@ One product in one repository can have separate product lines (offerings for dif
438
438
  - **A lead per stream.** Each stream has its own lead session, plan file, specs and lanes, and they lead at once: type `/code-kit:lead <stream>` in the session that should lead it. Each lead's loop and `code-kit next` give it only its own stream's stories, and it writes only its own stream's plan and specs. The first lead works in the main checkout, the others in a worktree each, on `lead/<stream>`.
439
439
  - **Streams kept apart.** A layer with `stream` is that stream's module; one without is core. A module may import core and its own stream's modules, never another stream's, and core never imports a module: the hooks refuse both, and the refusal says to ask for it in core rather than copy it.
440
440
  - **Core has one owner.** A stream with `platform: true` owns core's lanes: the other streams ask it for changes with `code-kit core ask "<what>" --story ST-n`, and their story waits on its decision. Without a platform stream, core's lanes are in no stream, and the streams take them in turns.
441
- - **Shared lists take additions from any stream.** Some core files are lists every stream's stories add to: an allow-list of routes, a catalogue of narration lines, a registry. Asking core for each new entry costs a core story, a core lane and a merge together for one line, and holds the stream's story meanwhile. Name such a file a shared list in `anyActor`, with `"adds": true` and its owner as reviewer: `{ "glob": "services/api/tests/allowed_routes.py", "reviewer": "api", "adds": true }`. Any lane then adds its entries in its own branch. Changing or removing an entry already there is still the owner's: the edit is refused as it's made, and `verify` refuses a branch that does it, saying to ask core.
441
+ - **Shared lists take additions from any stream.** Some core files are lists every stream's stories add to: an allow-list of routes, a catalogue of strings, a registry. Asking core for each new entry costs a core story, a core lane and a merge together for one line, and holds the stream's story meanwhile. Name such a file a shared list in `anyActor`, with `"adds": true` and its owner as reviewer: `{ "glob": "src/core/routes.ts", "reviewer": "api-core", "adds": true }`. Any lane then adds its entries in its own branch. Changing or removing an entry already there is still the owner's: the edit is refused as it's made, and `verify` refuses a branch that does it, saying to ask core. You don't have to find these files yourself: when three stories from two or more streams have only added lines to a core file, `code-kit next` tells the platform's lead (or the lead in the main checkout) that it looks like a shared list, with the entry to add. Adding it is a config change, so the lead proposes it to you.
442
442
  - **Shared capability noticed.** code-kit raises a candidate for core when it sees the same code in two streams' modules (names aside), an import of another stream's module refused, a copy into a module, module code that repeats core, or a requirement another stream's spec already has. `code-kit promote` lists them; the platform's lead decides each (`/code-kit:promote`), and a promotion is a platform story. Module code that repeats core's is its own stream's lead's to decide, since switching to core's is the module's work. To keep the list to what's worth a lead's time, a clone is one candidate per pair of files, tests are left out (they repeat their setup by nature), it takes 100 tokens alike by default (`harness.promote.tokens`), and a scan of the whole project (`code-kit promote scan`) withdraws open clones it no longer finds. Set `harness.promote.coreClones` to `refuse` and verify refuses a branch whose module code repeats core's.
443
443
  - **Each lead sees its own stream.** In the mod, a stream's lead sees its stream's build: the Build panel's milestone and bar, the Lanes panel (its lanes and the shared core lanes), what's ready, and the Trail are its own, and each says the stream ("Lanes: play"). The other streams are a line each, with who leads them and what their lanes are on, and the shared core lanes a line with whose turn it was. A session that leads nothing offers each stream to lead from here, with **Lead `<stream>`**. The Code map labels each layer core or its stream's module.
444
444
  - **Project-wide still.** One merge queue, one approval log, one set of standards and checks. The queue is every stream's, so it doesn't wait on one session: the lead in the main checkout merges its head first, and any other stream's lead merges it whenever its own stream has only waiting to do. A stream's lead keeps its own worktree after its `lead/<stream>` branch merges.
@@ -30,6 +30,7 @@ import {
30
30
  heldByCore,
31
31
  lanesToGiveWay,
32
32
  platformOf,
33
+ sharedListsInWaiting,
33
34
  streamOfLane,
34
35
  streamOfStory,
35
36
  } from './streams.mjs';
@@ -435,6 +436,12 @@ export function nextStep(root, base, { stream = null, projectWide = true } = {})
435
436
  const streamed = hasStreams(config);
436
437
  const streamOf = new Map(status.stories.map((s) => [s.id, streamOfStory(config, s)]));
437
438
  const led = new Set(leadSessions(root).flatMap((l) => (l.stream ? [l.stream] : [])));
439
+ // STRM-6: a core file streams only ever add to is better as a shared list than a stream of asks.
440
+ if (streamed && (projectWide || stream === platformOf(config)?.name))
441
+ for (const f of sharedListsInWaiting(root, config, status.stories, from).slice(0, 3))
442
+ attention.push(
443
+ `${f.file} looks like a shared list: ${f.stories.length} stories of the ${f.streams.join(' and ')} streams (${f.stories.join(', ')}) only added lines to it. Propose to the person that the config name it one (anyActor: { "glob": "${f.file}", "reviewer": "${laneOf(f.file, config) ?? 'lead'}", "adds": true }), so each stream adds its entries in its own branch instead of asking core.`,
444
+ );
438
445
  const mine = (id) =>
439
446
  !streamed || (stream ? streamOf.get(id) === stream : !led.has(streamOf.get(id)));
440
447
  // STRM-6: every stream's waiting stories, for whose turn a shared core lane is.
@@ -3,7 +3,8 @@
3
3
  // per technical layer, a core and a module per stream. A layer with `stream` is that stream's module; one
4
4
  // without is core. A lane in no stream is a core lane the streams share, taken in turns; a stream with
5
5
  // `platform: true` owns core instead. A project without `streams` is one stream holding every lane.
6
- import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
6
+ import { spawnSync } from 'node:child_process';
7
+ import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
7
8
  import { dirname, join } from 'node:path';
8
9
  import { matchesAny } from './glob.mjs';
9
10
  import { layerOf } from './layers.mjs';
@@ -242,3 +243,67 @@ export function heldByCore(root, stories) {
242
243
  }
243
244
  return held;
244
245
  }
246
+
247
+ /** STRM-6: how many stories, from how many streams, only adding to a core file make it a shared list in waiting. */
248
+ export const SHARED_LIST_STORIES = 3;
249
+
250
+ /**
251
+ * STRM-6: core files that look like shared lists: on `base`'s last 1000 commits, stories of at least two
252
+ * streams (a platform story built for a change request counts as the asking stream's) changed them only
253
+ * by adding lines, SHARED_LIST_STORIES stories or more, and the config doesn't name them shared lists yet.
254
+ * [{ file, stories, streams }], most stories first.
255
+ */
256
+ export function sharedListsInWaiting(root, config, stories, base) {
257
+ if (!hasStreams(config) || !base) return [];
258
+ const asked = new Map(
259
+ coreRequests(root)
260
+ .filter((r) => r.state === 'accepted' && r.decided?.story && r.stream)
261
+ .map((r) => [r.decided.story, r.stream]),
262
+ );
263
+ const streamOf = new Map(stories.map((s) => [s.id, asked.get(s.id) ?? streamOfStory(config, s)]));
264
+ const log = spawnSync(
265
+ 'git',
266
+ ['-C', root, 'log', '-n', '1000', '--no-merges', '--numstat', '--format=%x00%s%n%b%x01', base],
267
+ { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 },
268
+ );
269
+ if (log.status !== 0) return [];
270
+ // Per story, per file: lines added and removed across the commits that name it.
271
+ const touched = new Map();
272
+ for (const commit of log.stdout.split('\0').slice(1)) {
273
+ const [message, stat = ''] = commit.split('\x01');
274
+ const ids = [...new Set(message.match(/\bST-\d+\b/g) ?? [])].filter((id) => streamOf.get(id));
275
+ if (!ids.length) continue;
276
+ for (const line of stat.split('\n')) {
277
+ const [added, removed, file] = line.split('\t');
278
+ if (!file || added === '-') continue;
279
+ for (const id of ids) {
280
+ const key = `${id}\t${file}`;
281
+ const was = touched.get(key) ?? { added: 0, removed: 0 };
282
+ touched.set(key, {
283
+ added: was.added + Number(added),
284
+ removed: was.removed + Number(removed),
285
+ });
286
+ }
287
+ }
288
+ }
289
+ const files = new Map();
290
+ for (const [key, { added, removed }] of touched) {
291
+ const [id, file] = key.split('\t');
292
+ if (removed > 0 || added === 0) continue;
293
+ const f = files.get(file) ?? { file, stories: new Set(), streams: new Set() };
294
+ f.stories.add(id);
295
+ f.streams.add(streamOf.get(id));
296
+ files.set(file, f);
297
+ }
298
+ return [...files.values()]
299
+ .filter(
300
+ (f) =>
301
+ f.stories.size >= SHARED_LIST_STORIES &&
302
+ f.streams.size >= 2 &&
303
+ ownerStreamOf(config, f.file) === CORE &&
304
+ !matchesAny(f.file, config.sharedLists ?? []) &&
305
+ existsSync(join(root, f.file)),
306
+ )
307
+ .map((f) => ({ file: f.file, stories: [...f.stories].sort(), streams: [...f.streams].sort() }))
308
+ .sort((a, b) => b.stories.length - a.stories.length || a.file.localeCompare(b.file));
309
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warren-dean/code-kit",
3
- "version": "0.38.0",
3
+ "version": "0.38.1",
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",