@warren-dean/code-kit 0.34.0 → 0.35.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.
@@ -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.34.0",
12
+ "version": "0.35.0",
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.34.0",
3
+ "version": "0.35.0",
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,17 @@
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.35.0 (2026-11-13)
6
+
7
+ - **Reading the approval log beside a helper function.** A command that defined a short name for code-kit's command line (`ck() { node …/code-kit.mjs "$@"; }`) and also read `.claude/approval-log.jsonl` with `tail` or `grep` was refused as a possible write to the log, though the read never called the function. A function now stops the read only when the read calls it. One that shadows a reader, writes the log, or defines an alias or exports a variable in its body is still refused.
8
+ - **Lane agents change files with Edit and Write.** In its own worktree, a lane agent's shell command is refused when Claude Code can't prove it stays inside that worktree, and writes through a heredoc (`cat > file <<EOF`, `python3 - <<EOF`) were the usual case, each costing the lane a step. The lane instructions now say to change files with the Edit and Write tools and keep the shell for running things. Projects are asked once to bring their instructions up to date.
9
+ - **A pause from another tool pauses the loop.** `code-kit loop pause` recorded a pause that other tools read, but a session already running the loop only read it when it started, so it carried on prompting. It now reads the recorded pause as it reads the project, and stops taking new steps within seconds; the band says the loop is paused, and Resume stays yours.
10
+ - **`unset`, then a commit.** Unsetting a variable (`unset NAME`, `unset -v A B`) before a commit in the same command was refused as a command that may write files. It writes nothing, like setting one, so it passes now; with a redirect it still counts.
11
+ - **Reading the approval log beside a heredoc.** `python3 - <<'EOF' … EOF` and then `grep -c … .claude/approval-log.jsonl` in the same command was refused as a possible write to the log, though `python3 -c '…'` before the same read passed: any heredoc in the line made code-kit judge the whole line as one command. A heredoc whose body doesn't name the log is now judged like any other command that doesn't, so the read passes; one whose body names it is still judged whole.
12
+ - **git's read-only plumbing before a commit.** `git check-ignore -q <path> && git commit …` was refused as a write the commit's checks can't see. `check-ignore`, `check-attr`, `ls-tree`, `rev-list`, `merge-base`, `describe`, `name-rev`, `show-ref`, `for-each-ref` and `cherry` only read, and now pass like `git status` and `git log`; redirected into the checkout, they still count.
13
+ - **Python's bare asserts count.** The weakened-test check counted `assert(…)` calls and `self.assertEqual(…)`, but not Python's and pytest's bare `assert x == y` statements. A test file whose assertions went from calls to statements, or that gained bare asserts, could be read as having fewer and refused as weakened. Each bare `assert` statement now counts as one assertion.
14
+ - **`set -o pipefail`, then a commit.** Setting the shell's options (`set -euo pipefail`, `set +x`) before a commit in the same command was refused as a command that may write files. It writes nothing, so it passes now; with a redirect it still counts.
15
+
5
16
  ## 0.34.0 (2026-11-08)
6
17
 
7
18
  - **The loop no longer cuts into a conversation.** It prompted the lead as soon as each turn ended, so when you were talking with the lead about something else, the next step landed a minute after its answer to you. The reading of the lead's reply is now given what you said and tells a conversation from asking it to carry on; after a conversation, the loop waits until you've been quiet for `harness.loop.quietMinutes` (10 by default), and the band says so, with **Carry on**.
@@ -102,7 +102,7 @@ const ALWAYS = [
102
102
  ],
103
103
  [
104
104
  /approval-log\.jsonl/,
105
- "The approval audit log is appended only by the commit hook; nobody edits it. A shell command may name it only to read it: git diff, log, show or blame, or cat, head, tail, grep, wc, jq, cut, sort, uniq, awk or sed -n printing lines, piped only into each other, with no redirect but 2>&1 or into /dev/null, no command's output in its arguments ($(…) or backticks) and no variable set before a command; other commands may come before or after it with ; or &&, if none defines a function or alias, exports a variable or sets one a command reads, such as PATH. Run the read in that form, or read the file with the Read tool, which can't write. To put it back as the last commit has it (after a `git revert --no-commit` or `git cherry-pick --no-commit` took entries out), run `git restore --staged --worktree .claude/approval-log.jsonl` in the same form, and commit in a command after it.",
105
+ "The approval audit log is appended only by the commit hook; nobody edits it. A shell command may name it only to read it: git diff, log, show or blame, or cat, head, tail, grep, wc, jq, cut, sort, uniq, awk or sed -n printing lines, piped only into each other, with no redirect but 2>&1 or into /dev/null, no command's output in its arguments ($(…) or backticks) and no variable set before a command; other commands may come before or after it with ; or &&, if none defines an alias or a function the read calls, exports a variable or sets one a command reads, such as PATH. Run the read in that form, or read the file with the Read tool, which can't write. To put it back as the last commit has it (after a `git revert --no-commit` or `git cherry-pick --no-commit` took entries out), run `git restore --staged --worktree .claude/approval-log.jsonl` in the same form, and commit in a command after it.",
106
106
  unreadNames(cmd, /approval-log\.jsonl/).join('\n'),
107
107
  ],
108
108
  ];
@@ -841,7 +841,12 @@ const BEFORE_COMMIT = new RegExp(
841
841
  // Setting shell variables (`f=docs/x.md`, `export MSG="…"`) writes no file, unless a value runs a
842
842
  // command. What a later `git add "$f"` stages can't be read, so it counts as every changed file.
843
843
  const ASSIGNS_ONLY = /^(?:export\s+)?[A-Za-z_]\w*=\S*(?:\s+[A-Za-z_]\w*=\S*)*$/;
844
- const assignsOnly = (c) => ASSIGNS_ONLY.test(c.code) && !/`|\$\(|<\(/.test(c.text);
844
+ // Nor does setting the shell's own options (`set -euo pipefail`, `set +x`), or unsetting variables.
845
+ const SHELL_OPTIONS = /^set(?:\s+[-+][a-zA-Z]+(?:\s+[a-z]+)?)+\s*$/;
846
+ const UNSETS = /^unset(?:\s+-[vn])?(?:\s+[A-Za-z_]\w*)+\s*$/;
847
+ const assignsOnly = (c) =>
848
+ (ASSIGNS_ONLY.test(c.code) || SHELL_OPTIONS.test(c.code) || UNSETS.test(c.code)) &&
849
+ !/`|\$\(|<\(|[<>]/.test(c.text);
845
850
  // A tool's command that writes only the tool's own records (an adapter's `shell.records`), which any
846
851
  // actor may write and no check covers, with no redirect of its own.
847
852
  const recordsOnly = (c) =>
@@ -15,7 +15,7 @@ import {
15
15
  import { registerFile } from './costs.mjs';
16
16
 
17
17
  /** The version of code-kit's instructions: raised whenever the templates' rules change. */
18
- export const INSTRUCTIONS_VERSION = 13;
18
+ export const INSTRUCTIONS_VERSION = 14;
19
19
 
20
20
  const TEMPLATES = fileURLToPath(new URL('../../templates/', import.meta.url));
21
21
  const BEGIN = (v) => `<!-- code-kit:begin v${v} -->`;
@@ -35,8 +35,9 @@ const SKIPS = [
35
35
  /@(?:Disabled|Ignore)\b/,
36
36
  ];
37
37
  // `expect(` and its retrying and soft forms (`expect.poll(`, `expect.soft(`), each one assertion.
38
+ // Python's and pytest's bare `assert x == y` statements count too, one per statement.
38
39
  const ASSERTION =
39
- /\bexpect(?:\.(?:poll|soft))?\s*\(|\bassert\w*\s*[.(]|\bt\.(?:Error|Errorf|Fatal|Fatalf|Fail)\b|\bshould\.\w/g;
40
+ /\bexpect(?:\.(?:poll|soft))?\s*\(|\bassert\w*\s*[.(]|(?<=^|\n)[ \t]*assert[ \t]+(?=[^\s(.=])|\bt\.(?:Error|Errorf|Fatal|Fatalf|Fail)\b|\bshould\.\w/g;
40
41
 
41
42
  const skipLines = (text) =>
42
43
  String(text ?? '')
@@ -3,23 +3,28 @@
3
3
  // (`git commit`, `code-kit merge`) look only at the simple commands it runs, each from its own start.
4
4
  // Rules about text the command carries (a commit trailer, a path in a redirect) still read it whole.
5
5
 
6
- /** The command with each heredoc's body taken out: the lines after `<<WORD` up to the line `WORD`. */
7
- export function withoutHeredocs(cmd) {
8
- const out = [];
6
+ /** The command's lines and its heredocs' bodies apart: a body is the lines after `<<WORD` up to the line `WORD`. */
7
+ function heredocsApart(cmd) {
8
+ const kept = [];
9
+ const bodies = [];
9
10
  let until = null;
10
11
  for (const line of String(cmd).split('\n')) {
11
12
  if (until) {
12
13
  if (line.trim() === until) until = null;
14
+ else bodies.push(line);
13
15
  continue;
14
16
  }
15
- out.push(line);
17
+ kept.push(line);
16
18
  // `<<WORD`, `<<-WORD`, `<<'WORD'` or `<<"WORD"`; not a `<<<` here-string, whose text is on the line.
17
19
  const m = line.match(/(?<!<)<<-?\s*(['"]?)([\w.-]+)\1(?!<)/);
18
20
  if (m && !line.includes('<<<')) until = m[2];
19
21
  }
20
- return out.join('\n');
22
+ return { kept: kept.join('\n'), bodies: bodies.join('\n') };
21
23
  }
22
24
 
25
+ /** The command with each heredoc's body taken out: the lines after `<<WORD` up to the line `WORD`. */
26
+ export const withoutHeredocs = (cmd) => heredocsApart(cmd).kept;
27
+
23
28
  /** `text` with every quoted character replaced by `_`, the quotes kept: same length, nothing inside to match. */
24
29
  export function maskQuotes(text) {
25
30
  let out = '';
@@ -113,7 +118,7 @@ const READERS = [
113
118
  /^(?:cd|pwd|cat|head|tail|wc|grep|egrep|fgrep|cut|jq|nl|tr|ls|stat|diff|cmp|echo|printf|true)(?:\s|$)/,
114
119
  // less with no log file of what it shows.
115
120
  /^(?!.*\s(?:-[a-zA-Z]*[oO]|--log-file\b|--LOG-FILE\b))less(?:\s|$)/,
116
- /^(?!.*\s(?:--output\b|-O|--open-files-in-pager\b))git(?:\s+(?:-C\s+\S+|--no-pager|-P))*\s+(?:diff|log|show|blame|grep|status|cat-file|ls-files|shortlog|rev-parse)(?:\s|$)/,
121
+ /^(?!.*\s(?:--output\b|-O|--open-files-in-pager\b))git(?:\s+(?:-C\s+\S+|--no-pager|-P))*\s+(?:diff|log|show|blame|grep|status|cat-file|ls-files|ls-tree|shortlog|rev-parse|rev-list|merge-base|check-ignore|check-attr|describe|name-rev|show-ref|for-each-ref|cherry)(?:\s|$)/,
117
122
  // git branch only listing branches or naming the current one: no name to create, move or delete.
118
123
  /^git(?:\s+(?:-C\s+\S+|--no-pager|-P))*\s+branch(?:\s+(?:--show-current|--list|-l|-a|--all|-r|--remotes|-vv?|--verbose|--no-color|--color|--merged|--no-merged))*\s*$/,
119
124
  // rg with no preprocessor; sort with no output file or compressor.
@@ -281,6 +286,16 @@ const REDEFINES =
281
286
  /(?:^|[;&|\n(]\s*)(?:[\w.-]+\s*\(\s*\)|function\s|alias\s|unalias\s|source\s|\.\s|hash\s|enable\s|builtin\s|set\s|setopt\s|shopt\s|unset\s|export\s|typeset\s|declare\s|local\s|readonly\s)/;
282
287
  const SHELL_READS =
283
288
  /^(?:PATH|path|FPATH|fpath|CDPATH|cdpath|IFS|ENV|BASH_ENV|ZDOTDIR|HOME|LD_\w*|DYLD_\w*|GIT_\w*|XDG_\w*)$/;
289
+ // A function defined in the line: `name() {` or `function name`. One that no reading part calls can't
290
+ // change what that part runs; what its body runs is judged as the line's other commands are.
291
+ const DEFINES_FUNCTION =
292
+ /(?:^|[;&|\n(]\s*)(?:function\s+([\w.-]+)(?:\s*\(\s*\))?|([\w.-]+)\s*\(\s*\))/g;
293
+ function definedFunctions(code) {
294
+ const names = [...code.matchAll(DEFINES_FUNCTION)].map(([, a, b]) => a ?? b);
295
+ // What else the line redefines, a function's body counted, since a call runs it.
296
+ const rest = code.replace(DEFINES_FUNCTION, ';').replace(/[{}]/g, ';');
297
+ return { names, rest };
298
+ }
284
299
  // Any other variable set in the line (`CK=…/code-kit.mjs`) stays in the shell: no command it runs sees
285
300
  // it, unless it was exported already, and what names it is judged on its own.
286
301
  const setsWhatRuns = (code) =>
@@ -290,15 +305,23 @@ const setsWhatRuns = (code) =>
290
305
 
291
306
  /**
292
307
  * The parts of `cmd` that name `pattern`, each a pipeline (`a | b`) of its own, that don't only read
293
- * (readsOnly): what a rule for a file only reads may hold. A line with a heredoc, or one that could
294
- * change what its commands run (REDEFINES), is one part, judged whole.
308
+ * (readsOnly): what a rule for a file only reads may hold. A line with a heredoc whose body names
309
+ * `pattern`, or one that could change what its commands run (REDEFINES), is one part, judged whole; a
310
+ * heredoc that doesn't name it is judged like any other command that doesn't, and so is a function
311
+ * defined, unless a part that names `pattern` calls it.
295
312
  */
296
313
  export function unreadNames(cmd, pattern) {
297
314
  const read = withoutHarmlessRedirects(cmd);
298
315
  const code = codeOf(read);
299
316
  if (!pattern.test(cmd)) return [];
300
- if (/<</.test(cmd) || REDEFINES.test(code) || setsWhatRuns(code))
317
+ const functions = definedFunctions(code);
318
+ if (
319
+ pattern.test(heredocsApart(cmd).bodies) ||
320
+ REDEFINES.test(functions.rest) ||
321
+ setsWhatRuns(code)
322
+ )
301
323
  return readsOnly(cmd) ? [] : [cmd];
324
+ const calls = (p) => commandsOf(p).some(({ text: t }) => functions.names.includes(wordsOf(t)[0]));
302
325
  const text = withoutHeredocs(read);
303
326
  const parts = [];
304
327
  let start = 0;
@@ -319,7 +342,9 @@ export function unreadNames(cmd, pattern) {
319
342
  new RegExp(String.raw`^${GIT}(?:commit|merge|revert|cherry-pick|rebase|am|pull)(?![\w-])`),
320
343
  );
321
344
  return parts.filter(
322
- (p) => pattern.test(p) && !readsOnly(p) && !(restores && restoresFromHead(p, pattern)),
345
+ (p) =>
346
+ pattern.test(p) &&
347
+ (calls(p) || (!readsOnly(p) && !(restores && restoresFromHead(p, pattern)))),
323
348
  );
324
349
  }
325
350
 
@@ -421,13 +421,19 @@ export function register(on) {
421
421
  boardSynced = at;
422
422
  $.process.run(['node', cli, 'team', 'board'], { cwd, timeoutMs: 120000 }).catch(() => {});
423
423
  }
424
+ const recorded = await json('loop', '--session', session).catch(() => null);
424
425
  // LOOP-10: while another session runs the loop, whether it still does (its lease lapses as it ends).
425
426
  if (!lease.mine) {
426
- const recorded = await json('loop', '--session', session).catch(() => null);
427
427
  const lead = recorded?.lead ?? null;
428
428
  lease.other = lead && lead.session !== session ? lead : null;
429
429
  role = recorded?.role ?? role;
430
430
  }
431
+ // LOOP-6: a pause another tool recorded in the project (`code-kit loop pause`) pauses this loop too.
432
+ if (recorded?.paused && !loop.paused) {
433
+ loop.paused = true;
434
+ loop.proposal = null;
435
+ $.ui.invalidate('ui.render');
436
+ }
431
437
  // SESS-4: a working session's own task, for its band.
432
438
  const task =
433
439
  valid && role === 'working'
@@ -686,6 +692,8 @@ export function register(on) {
686
692
  // TEAM-7: a live provider (the hub's helper) rewrites the team's state as events arrive.
687
693
  await stamp('.claude/state/team.json'),
688
694
  await stamp('.claude/state/merge-queue.json'),
695
+ // LOOP-6: a pause recorded by another tool.
696
+ await stamp('.claude/state/loop.json'),
689
697
  await listing('.claude/approvals'),
690
698
  await listing('.claude/state/stop-blocks'),
691
699
  [...agentsAtWork(await $.agent.list().catch(() => []))].sort().join(','),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warren-dean/code-kit",
3
- "version": "0.34.0",
3
+ "version": "0.35.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",
@@ -23,6 +23,7 @@ Always:
23
23
  - {{if standards}}Build to the project's standards for your layers, from `{{docs.standards}}` (read a standard's why and evidence there when you need it). A required one that review checks sends your branch back if it's broken; advice is yours to weigh:{{standards}}{{end}}
24
24
  - Read every file you change in full. Of what it imports and what calls it, read what your change needs: the definitions it uses and the call sites it changes. A context tool's fresh card for a file stands for reading it whole; read the source where the card is missing, stale or not enough.
25
25
  - Search before you build; reuse existing services, providers, components and schemas.
26
+ - Change files with the Edit and Write tools, not the shell: no `cat > file <<EOF`, `python3 - <<EOF`, `sed -i` or `>>`. In your own worktree, Claude Code refuses a shell command it can't prove stays inside it, and each refusal is a step lost. Keep shell commands to running things, one plain command at a time, from your worktree's root.
26
27
  - Write only in your owned paths. For anything else, write a short change request for the lead and stop.
27
28
  - You answer to the lead, never the person. A question the spec doesn't settle (a product choice, UX the spec is silent on, an account): write it for the lead, with the choices and what each does, and carry on with what doesn't depend on it, or stop. The lead decides, or asks the person.
28
29
  - A new dependency needs the lead's approval. Before asking, check the project doesn't already have something that does the job. If the install is refused, put in a change request for the lead: the package, the story and requirement that need it, what you checked, and anything lighter that would do; then stop. The lead approves it, or tells you what to use instead.