@warren-dean/code-kit 0.33.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +26 -0
- package/README.md +36 -34
- package/bin/code-kit.mjs +2 -0
- package/hooks/guard-bash.mjs +58 -7
- package/hooks/lib/checkout.mjs +38 -3
- package/hooks/lib/harness.mjs +15 -0
- package/hooks/lib/instructions.mjs +4 -2
- package/hooks/lib/next.mjs +6 -0
- package/hooks/lib/plan.mjs +8 -2
- package/hooks/lib/regression.mjs +2 -1
- package/hooks/lib/shell.mjs +47 -13
- package/hooks/mod/board.mjs +2 -0
- package/hooks/mod/loop.mjs +66 -3
- package/hooks/mod/register.mjs +211 -5
- package/hooks/mod/view.mjs +17 -1
- package/package.json +1 -1
- package/templates/agent.md +1 -0
|
@@ -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.
|
|
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.
|
|
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,32 @@
|
|
|
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
|
+
|
|
16
|
+
## 0.34.0 (2026-11-08)
|
|
17
|
+
|
|
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**.
|
|
19
|
+
- **Each step is checked against the project before the lead gets it.** The loop kept prompting steps the lead had already explained: a merge whose verify was still running, instructions already brought up to date on the base, a story already under way. A story the lead said waits was held, but a merge or an instructions step wasn't, and anything you said to the lead let every step come back. Before each prompt, the loop now reads the project itself (the step's branches against the base, the merge queue, the agents at work, the latest commits and the lead's last replies) and a small model judges whether the step is still due. One that isn't waits in the band as a note with **Ask now**, and is checked again once the project moves. A step the lead said waits, or didn't take, is held the same way. `harness.loop.check` switches the check off. In auto mode a mod can't start an agent itself, so this is a side call, not a subagent.
|
|
20
|
+
|
|
21
|
+
- **code-kit's own records, then a commit.** `node "$CK" ask withdraw Q-3 --reason "…"`, `defer release`, `sent-back` or `queue add`, followed by a commit in the same command, was refused as a write the commit's checks can't see. These write only code-kit's state folder, which the project ignores, so they now pass when run by this code-kit's own CLI, by its path or through a variable the line sets to it. Any other code-kit command (one that writes instructions, merges or publishes), a script elsewhere with the same name, and a redirect into the checkout still count.
|
|
22
|
+
- **`git switch -qc <branch>`, then a commit.** A branch made with its flags combined was refused, though `git switch -q -c <branch>` passed. Both pass now.
|
|
23
|
+
- **A branch queued again after a batch failed no longer goes back to its lane.** When a batch fails verify in the merge queue, every branch in it is sent back, including those with nothing wrong. The lead queued those again at the same commits, yet `status` still read them as sent back, and `next` proposed dispatching lanes with nothing to fix whenever it wasn't the lead's turn to merge. A branch queued since its send-back, at that commit, now reads as passed and waits to merge. A branch that's sent back while it's in the queue stays sent back.
|
|
24
|
+
- **A branch merged after a send-back no longer asks for a dispatch.** A branch sent back, queued again and merged at the same commit still read as sent back until the plan said `done`, so the loop asked the lead to dispatch a story that was already on the base. A branch whose commits the base holds has nothing left to fix, and now reads as merged.
|
|
25
|
+
- **The loop says how to hold a story it keeps asking about.** A story the lead left because it waits on something outside the build (a run on a set day, say) was asked about again every half hour, as soon as other lanes committed. When a story comes up again with nothing it waits on having moved, the loop's prompt now adds that `code-kit defer` holds it, with a reason and an optional date, so the loop stops asking.
|
|
26
|
+
- **A lane's report, then its commit.** `cat >> .claude/state/reports/<branch>.md <<'EOF' … EOF`, followed by `git add … && git commit` in the same command, was refused as a write the commit's checks can't see, and lanes hit this often as they finished a story. The state folder is ignored, so no commit can take what goes there. A read or a heredoc redirected only into it now passes, as long as the project's `.gitignore` covers the folder.
|
|
27
|
+
- **Instructions from a newer code-kit are left alone.** When a teammate had updated code-kit and committed its instructions, a session on an older plugin read them as out of date. Its loop kept asking it to run `instructions --write`, which would have put the older rules back. From this release, `instructions` reads them as ahead, `--write` leaves them, and `next` says to update the plugin and restart instead. The instructions' version is now raised whenever they change, so this works between releases; existing projects will be asked once to bring theirs up to date. A session still on an older release keeps the old behaviour until it updates.
|
|
28
|
+
- **Reading the approval log beside a variable of your own.** `CK=…/code-kit.mjs; node "$CK" status; tail -3 .claude/approval-log.jsonl` was refused, because any variable set in the line made the whole line count as a possible write. A variable now counts only if a command could read it: `PATH`, `HOME`, `GIT_*` and the like, or one already exported.
|
|
29
|
+
- **The merge queue no longer fails every branch when the OS empties its kept installs.** The queue's kept checkout lives in the temporary folder, and macOS removes old files there while leaving the folders and links. The installs looked present, so checks failed with missing modules and each queued branch was sent back to its lane. Each merge now counts the kept installs' files. If any have gone, it copies them again and runs the project's install over the copy.
|
|
30
|
+
|
|
5
31
|
## 0.33.0 (2026-11-06)
|
|
6
32
|
|
|
7
33
|
- **A running budget.** Projects were being designed on each provider's production defaults, with nothing adding up what they'd cost a month. spec-design now asks how much a month each environment may cost, in your currency, and the load to plan for; init writes it to `cost` in the config, with the project's infrastructure files. spec-design costs each architecture it proposes against it and, when your preferred one doesn't fit, offers options that do, each with what it gives up. The costs go in `docs/costs.md`, a row per paid thing with where its price came from, and `code-kit cost` adds them up against the budget. A branch that changes the infrastructure has to change the register (verify), lanes may write it, and a commit that takes an environment past its budget waits for your `cost` approval, which the lead can't give, under vibe either. `next` asks a project with infrastructure and no budget for one. It works for any provider: code-kit holds no prices, and the lead cites where each came from. Reading real spend from an account comes later.
|
package/README.md
CHANGED
|
@@ -336,8 +336,10 @@ The loop keeps the build moving between your prompts, under `harness.autonomy`.
|
|
|
336
336
|
|
|
337
337
|
- **Each step.** Once the lead has finished a turn, with the lead idle and nothing typed in the prompt, the loop asks `code-kit next` and prompts the lead to dispatch the ready stories, review a finished one, or build its own. It never prompts the same step twice while nothing has changed, and never a story an agent is still on: one its lane agent is building, or a reviewer is reviewing, waits until that agent finishes ("waiting: ST-10 is still with its agent").
|
|
338
338
|
- **It reads the lead's reply first.** Before prompting again, the loop reads the lead's last reply with a side call over the lead's own conversation. A reply that waits on you (a question, a design to look at, an approval), or a turn you stopped, holds the loop until you answer or speak to the lead: the band says what the lead waits on, and the Decide pane answers it. A step the lead didn't take shows in the band as a note, with its reason and **Ask again**.
|
|
339
|
-
- **Stories waiting on other work.** When the lead says a story isn't due yet because it waits on work still going (a paired story a lane is building, a rebuild, a check running), the loop parks that story and leaves it out of every step, so a step naming it with others prompts only the others. It wakes when its own branch or state moves, or when a story it waits on (one the lead named, or an unfinished one building on it) changes state; that story's commits along the way don't wake it, nor do other lanes'. A story the lead's turn left exactly where it stood is parked too, whatever the reply said. After 30 minutes with nothing moving, the lead is asked once more.
|
|
339
|
+
- **Stories waiting on other work.** When the lead says a story isn't due yet because it waits on work still going (a paired story a lane is building, a rebuild, a check running), the loop parks that story and leaves it out of every step, so a step naming it with others prompts only the others. It wakes when its own branch or state moves, or when a story it waits on (one the lead named, or an unfinished one building on it) changes state; that story's commits along the way don't wake it, nor do other lanes'. A story the lead's turn left exactly where it stood is parked too, whatever the reply said. After 30 minutes with nothing moving, the lead is asked once more, and told that `code-kit defer` holds a story that waits on a date or on something outside the build.
|
|
340
340
|
- **Holding on purpose.** A story the lead means to leave alone for a while (it waits on something outside the build, or on a date) is held with `code-kit defer <story> --reason "…" [--until <date>]`: `next`, the loop and the merge queue don't dispatch, review or merge it until then, or until `code-kit defer release <story>`, and it isn't asked about again in the meantime. `code-kit queue pause --reason "…"` holds the whole merge queue the same way, until `code-kit queue resume`. `next` lists each hold with its reason, and the band shows them as notes.
|
|
341
|
+
- **It doesn't cut into a conversation.** When you talk with the lead about something other than the build (a question, a discussion, another task), the loop waits until you've been quiet for `harness.loop.quietMinutes` (10) before it prompts again; the band says so, with **Carry on**. Asking the lead to carry on with the build holds nothing.
|
|
342
|
+
- **Each step is checked first.** code-kit's records can lag the work, so before it prompts the lead the loop reads the project itself (the step's branches against the base, the merge queue, the agents at work, the latest commits and the lead's last replies) and a small model judges whether the step is still due. One that isn't (merged already, under way, or one the lead said why it won't take, with nothing changed since) is held as a note with **Ask now**, and checked again once the project moves. A step the lead said waits, or didn't take, is held the same way, so speaking to the lead doesn't bring it back. `harness.loop.check` switches the check off.
|
|
341
343
|
- **A step that doesn't move.** One the lead was prompted with three times in a row that is still next shows as a note, not a decision: "Merge lead/st-1: still next after 3 prompts to the lead", with **Ask again** if you want it.
|
|
342
344
|
- **A lean lead.** A lane writes its full report, with its commands and their output, to `.claude/state/reports/<branch>.md`, and hands the lead a few lines naming it; the stop hook won't let a lane on a story branch finish without it, or with a hand-back of more than ten lines, and the lead reads the file when it reviews. Lanes don't message the lead while they work. When a milestone finishes, the lead's context is compacted before the next one (`harness.compact.milestone`: you're asked by default, or it's done at once): the summary keeps what's in flight and what waits on you, and drops the finished stories' detail.
|
|
343
345
|
- **Token use.** A long-lived agent rereads its whole context on every request, which is most of what a build costs. So each lane agent builds one story; one past `agents.lanes.contextLimit` is told to wrap up, and the lead carries its story on with a fresh agent that reads its report (`code-kit worktrees release` frees the branch). The lead's context is compacted between turns once it's past `compact.at`. The loop reads the lead's replies with Sonnet, and the reviewers run on Sonnet by default.
|
|
@@ -545,38 +547,38 @@ code-kit approve <name>... --reason "…" [--lane name] [--delegated [--story ST
|
|
|
545
547
|
|
|
546
548
|
`.claude/code-kit.json`. Globs use `*` (one segment), `**` (any depth), `**/` (zero or more folders), `?` and `{a,b}`. Patterns under `shell` are regular expressions.
|
|
547
549
|
|
|
548
|
-
| Field | Required | What it is
|
|
549
|
-
| ------------------------------ | ----------------- |
|
|
550
|
-
| `version` | yes | `1`
|
|
551
|
-
| `docs.specs` | no | Folder of specs. With it, a lane needs a spec-check report before writing code on a branch
|
|
552
|
-
| `docs.principles`, `docs.plan` | no | The engineering principles and the implementation plan
|
|
553
|
-
| `docs.costs` | no | The cost register (spec 29), default `docs/costs.md`: one table, `\| Item \| Provider \| Environment \| Size \| Monthly \| Basis \|`, a row per paid thing with its monthly estimate as a number and where the price came from, dated. Any agent may write it once `cost` is set
|
|
554
|
-
| `docs.decisions` | no | Where agreed intents are recorded as numbered decision records (`code-kit intend record`); default `docs/decisions`
|
|
555
|
-
| `docs.standards` | no | The project's standards (spec 22), default `docs/standards.md`: each a `### <id> <title>` heading with `level` (required or recommended), `applied` (enforced, checked or advice), `layers`, `why`, `source` and, when enforced, `enforced by` naming the layer rule, protected path, check or shell rule that refuses a breach. The id's prefix is its category: `PRI-` principles, `PAT-` patterns, `ARC-` architecture, `CON-` conventions, `POL-` policies. Each lane agent is given the ones for its layers; a refusal from an enforcing rule names the standard; reviews check the checked ones. Protect the file with the `standards` approval: removing a standard, or weakening a required one, always needs the person's, whatever is delegated
|
|
556
|
-
| `lead.paths` | yes | What the main session writes. `.claude/**` and `.mcp.json` are always added.
|
|
557
|
-
| `lead.outside` | no | Paths outside the repository the lead may write, e.g. `../shared-lib/**`. Claude's memory is always included, and the session's own folder in Claude Code's temporary folder (`/tmp/claude-<uid>/<project>/<session id>/`: its scratchpad and tool output), which the lanes may write too; another session's isn't.
|
|
558
|
-
| `anyActor` | no | Paths every writer may change (e.g. the lockfile), read-only agents included. `.claude/state/**` is always included. An entry may be `{ "glob", "reviewer" }` to name the lane (or `"lead"`) that reviews changes to it; otherwise the lead reviews them, and `who` and `trace` say so.
|
|
559
|
-
| `lanes.<name>` | yes (may be `{}`) | `{ agent, paths, exclude?, owners?, label? }`: the agent name maps a subagent to its lane; `label` names what the lane delivers ("Screens", "API contract"; one line, at most 60 characters), for a team provider's report, and is otherwise taken from the lane's name; `owners` (GitHub handles) are the people whose sessions work it, in a team (needs `team`). A worktree with a `.lane` file holding the lane name makes the main session that lane.
|
|
560
|
-
| `protected[]` | no | `{ glob, approval, why }`: logged on every commit. Anyone but the lead needs an approval: the lead's where `approvals.delegate.protected` names it, otherwise a person's (see [Approvals](#approvals)). `.claude/**` is always protected as `kit`.
|
|
561
|
-
| `designGate` | no | `{ register, screens: [{ glob, not? }], howTo }`: screen files wait until the register (`{ "screens": [{ "file": … }] }`) holds their exported designs; an entry naming only a design tool's artboard doesn't open the gate. Init sets it for every lane that owns screens; `/code-kit:design` adds approved designs
|
|
562
|
-
| `layers[]` | no | `{ name, paths, mayImport, denyPackages?, label? }`: the first layer whose paths match a file owns it. A layer may always import itself. `label` names what the layer delivers ("Data", "Service"; one line, at most 60 characters), for a team provider's report, and is otherwise taken from the layer's name.
|
|
563
|
-
| `importAliases` | no | `{ "@app/domain": "packages/domain/src" }`: resolves non-relative imports to repository paths
|
|
564
|
-
| `shell.block[]` | no | `{ pattern, why, person?, command? }`: never run. `person: true` marks a person's act, which the lead may do for them with `approvals.lead` on. `command: true` matches the pattern from the start of each command the line runs (after a package runner such as `npx` or `pnpm exec`, and inside `sh -c` or `eval`), with quoted text masked unless the pattern has quotes, so a grep, a heredoc or a message that mentions it isn't refused. Without it the pattern reads the whole line, except a read's quoted arguments: `grep "<command>" docs` doesn't run it
|
|
565
|
-
| `shell.restricted[]` | no | `{ pattern, lanes, why }`: only the lead and these lanes. A read's quoted arguments don't count, as for `shell.block`
|
|
566
|
-
| `postEdit[]` | no | `{ files, exclude?, run }`: after each edit of a matching file. `{file}` is the file. Exit 127 (tool not installed) is skipped.
|
|
567
|
-
| `tests[]` | no | Globs naming the test files, in place of the conventions, for every rule that asks what a test is: weakened tests, a fix's tests, the tests that name a requirement, the code map and the security review. Default: a file named as a test (`*.test.*`, `*.spec.*`, `*.smoke.*`, `test_*.py`, `*_test.go`, `*_test.py`) or in a test folder (`test/`, `tests/`, `__tests__/`, `e2e/`, `smoke/`). Proving a fix keeps the files named as tests and takes the rest back, test-folder helpers included; with `tests` set, the files it names are the ones kept.
|
|
568
|
-
| `regression.prepare` | no | A command run in a fresh checkout before a fix's tests run there without the fix, such as `npm ci`. The checkout's `node_modules` and virtualenvs are copied in first (a copy-on-write clone where the disk has one), so it can't change the checkout's own. The merge queue runs it too, in the merged tree's checkout, when its manifests or lockfiles differ from the installs copied in; without it, the queue runs the install the lockfile calls for.
|
|
569
|
-
| `checks[]` | no | `{ name, files, exclude?, run[], each?, owners?, ifMissing?, timeoutSeconds? }`: before finishing, when matching files changed. `each` runs the commands in every changed folder matching that glob. `owners` limits who may change the files (the lead always may). `ifMissing: "fail"` makes a missing tool an error (the default is to skip the check, which `verify` and a merge list as not run). `timeoutSeconds` (240 unless set) is how long each command may run; one that runs out of time leaves its branch at the head of the merge queue rather than sending it back.
|
|
570
|
-
| `adapters` | no | `{ "<adapter>": false }` switches off an adapter that would otherwise be detected; `true` says the project wants that tool, so until it's set up here `next` gives its setup before any code. See [Adapters](#adapters).
|
|
571
|
-
| `approvals.lead` | no | `true` lets the lead act on what the person says in chat, for when `!` isn't available (on a phone, say): it records their approvals with `code-kit approve`, and runs `shell.block` commands marked `person`. Default `false`. See [Approvals](#approvals).
|
|
572
|
-
| `approvals.delegate` | no | `false`, or `{ protected?: [approval names], merge?: true, push?: true, tests?: true, dependencies?: { licences?, minWeeklyDownloads?, maxMonthsSinceRelease?, allowInstallScripts?: true \| false \| [kinds] } }`: what the lead decides, inside the guardrails you keep: the protected approvals it grants, and packages it approves for a story, with `code-kit approve --delegated`; with `merge`, merges into a protected branch with `code-kit merge --delegated`; with `push`, pushes the protected branch, never by force (yours unless you set it, since a push can deploy; read from the config committed on that branch); with `tests`, weakened tests on a lane's branch. Left out, the lead decides everything technical: every protected approval but `spec`, `design`, `ci` and `kit`, packages, merges and weakened tests (WHO-1); `false` keeps everything for you. Lanes ask the lead for these, never you. npm packages are also checked against the npm registry, and a Python lane's against PyPI; the defaults are MIT, Apache-2.0, BSD and ISC, 10,000 weekly downloads, a release within 18 months, and no install scripts. See [Approvals](#approvals).
|
|
573
|
-
| `setup` | no | The version of init's setup the project has (3 now). Without it, or lower, `next` names what the project is missing (the design gate, design stories before screens, a QA lane, a security reviewer) and starts no new story until re-running init adds it
|
|
574
|
-
| `cost` | no | The running budget (spec 29): `{ currency, monthly, load?, paths? }`. `currency` is a three-letter code (USD, AUD, EUR); `monthly` maps each environment (`prod`, `dev`, …, not `all`) to what it may cost a month; `load` says in words what the budget plans for; `paths` are the infrastructure files, whatever defines them, and a branch that changes one changes the register too. A commit that takes an environment past its budget needs the person's `cost` approval, whatever is delegated
|
|
575
|
-
| `team` | no | Preview. For several people in one repository: `{ techLead, staleDays?, intents?, board?, provider?, report? }`. `techLead` is the GitHub handle of the person who owns the plan, specs and contracts; `staleDays` is how many working days without a push make a claim stale (default 3); `intents` is the discussion category intents go in (default `Intents`; create it once in the repository's Settings › Discussions); `board` is `{ owner, number }`, a GitHub Project the plan is mirrored onto; `provider` is `"github"` (default), `{ command, fallback? }` for another team provider, or, in preview, a hosted provider's adapter as `{ "<name>": "<https address>" }`, which keeps the intents (Discussions only when `intents` is set) and has GitHub as its fallback; with `fallback: "github"`, claims go through GitHub whenever that provider can't be reached; `report` (default true) is whether the project reports its facts (stories' stages, send-backs, the requirement trail, the specs' titles and outcome lines, approvals, token use, the rules, the design register and the sessions at work; never code) to a provider that isn't GitHub. A provider may also supply an organisation's standards (`standards`, answering `{ standards, waivers, version }`, each standard in `docs.standards`' fields, each waiver `{ standard, paths?, expires?, reason?, approvedBy? }`): they apply as if in the project's file, which may extend or tighten one but weaken a required one only under a waiver. See docs/specs/16-teams.md, docs/specs/21-hub-adapter-and-reports.md and docs/specs/22-standards.md.
|
|
576
|
-
| `branches.protected` | no | Default `["main", "master"]`
|
|
577
|
-
| `branches.publish` | no | How a merge reaches the remote's base: `push` (the base is pushed, fast-forward only) or `pull-request` (for a base the remote only lets change through pull requests: code-kit opens one from `code-kit/publish-<base>` after each merge, and merges it where `approvals.delegate.push` is on, otherwise it waits for you). Left out, code-kit leaves pushing the base to you
|
|
578
|
-
| `execution.unrepeatable` | no | Patterns (regular expressions) for commands that can't safely run twice, such as a seed or a deploy. With migrations, the commands `shell.block` and `shell.restricted` name, and `git push`, an interrupted one is never run again on its own after a crash: the lead finds out what happened first (spec 26)
|
|
579
|
-
| `harness` | no | What the mod's harness does in the session: `autonomy` (`autonomous`, `propose`, `off` or `vibe`; default `autonomous`; `vibe` is autonomous with every decision the lead's, see [Vibe](#vibe)), `hold.minutes` (how long a call waiting on your approval is held, 0 to 10; default 2), `stall.nudgeMinutes` and `stall.restartMinutes` (default 5 and 10), `stall.maxRestarts` (default 2), `agents.reviewer.on` (default `false`) and `agents.reviewer.model` (code-kit's reviewer and the security reviewer; default `sonnet`), `agents.lanes.model` (the model each lane agent starts on, unless the lead's call or the lane's agent file names one: a model, or `story` for each story's `**Size:**` in the plan, raised for security requirements, fixes and send-backs; default the session's), `slices.open` (how many of the plan's slices are in focus: a free lane builds an open slice's stories first; default 1), `background.pauseAtPercent` (default 80), `compact.at` (compact the lead's context between turns once it's past this share of its window; default 40, 0 for never), `compact.milestone` (when a milestone finishes, compact the lead's context: `ask`, `auto` or `off`; default `ask`), `agents.lanes.contextLimit` (the context a lane agent may reach before it hands its story to a fresh agent; default 250,000 tokens), `notify.on` (a system notification when something new needs you; default `true`), `motion` (whether the pane's characters, clocks and the lead's rail move while work flows: `while-active` or `off`; default `while-active`) and `report.on` (agents draft bug reports for code-kit, which you send or discard; default `false`). Change them with `/harness` or `code-kit settings set`. |
|
|
550
|
+
| Field | Required | What it is |
|
|
551
|
+
| ------------------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
552
|
+
| `version` | yes | `1` |
|
|
553
|
+
| `docs.specs` | no | Folder of specs. With it, a lane needs a spec-check report before writing code on a branch |
|
|
554
|
+
| `docs.principles`, `docs.plan` | no | The engineering principles and the implementation plan |
|
|
555
|
+
| `docs.costs` | no | The cost register (spec 29), default `docs/costs.md`: one table, `\| Item \| Provider \| Environment \| Size \| Monthly \| Basis \|`, a row per paid thing with its monthly estimate as a number and where the price came from, dated. Any agent may write it once `cost` is set |
|
|
556
|
+
| `docs.decisions` | no | Where agreed intents are recorded as numbered decision records (`code-kit intend record`); default `docs/decisions` |
|
|
557
|
+
| `docs.standards` | no | The project's standards (spec 22), default `docs/standards.md`: each a `### <id> <title>` heading with `level` (required or recommended), `applied` (enforced, checked or advice), `layers`, `why`, `source` and, when enforced, `enforced by` naming the layer rule, protected path, check or shell rule that refuses a breach. The id's prefix is its category: `PRI-` principles, `PAT-` patterns, `ARC-` architecture, `CON-` conventions, `POL-` policies. Each lane agent is given the ones for its layers; a refusal from an enforcing rule names the standard; reviews check the checked ones. Protect the file with the `standards` approval: removing a standard, or weakening a required one, always needs the person's, whatever is delegated |
|
|
558
|
+
| `lead.paths` | yes | What the main session writes. `.claude/**` and `.mcp.json` are always added. |
|
|
559
|
+
| `lead.outside` | no | Paths outside the repository the lead may write, e.g. `../shared-lib/**`. Claude's memory is always included, and the session's own folder in Claude Code's temporary folder (`/tmp/claude-<uid>/<project>/<session id>/`: its scratchpad and tool output), which the lanes may write too; another session's isn't. |
|
|
560
|
+
| `anyActor` | no | Paths every writer may change (e.g. the lockfile), read-only agents included. `.claude/state/**` is always included. An entry may be `{ "glob", "reviewer" }` to name the lane (or `"lead"`) that reviews changes to it; otherwise the lead reviews them, and `who` and `trace` say so. |
|
|
561
|
+
| `lanes.<name>` | yes (may be `{}`) | `{ agent, paths, exclude?, owners?, label? }`: the agent name maps a subagent to its lane; `label` names what the lane delivers ("Screens", "API contract"; one line, at most 60 characters), for a team provider's report, and is otherwise taken from the lane's name; `owners` (GitHub handles) are the people whose sessions work it, in a team (needs `team`). A worktree with a `.lane` file holding the lane name makes the main session that lane. |
|
|
562
|
+
| `protected[]` | no | `{ glob, approval, why }`: logged on every commit. Anyone but the lead needs an approval: the lead's where `approvals.delegate.protected` names it, otherwise a person's (see [Approvals](#approvals)). `.claude/**` is always protected as `kit`. |
|
|
563
|
+
| `designGate` | no | `{ register, screens: [{ glob, not? }], howTo }`: screen files wait until the register (`{ "screens": [{ "file": … }] }`) holds their exported designs; an entry naming only a design tool's artboard doesn't open the gate. Init sets it for every lane that owns screens; `/code-kit:design` adds approved designs |
|
|
564
|
+
| `layers[]` | no | `{ name, paths, mayImport, denyPackages?, label? }`: the first layer whose paths match a file owns it. A layer may always import itself. `label` names what the layer delivers ("Data", "Service"; one line, at most 60 characters), for a team provider's report, and is otherwise taken from the layer's name. |
|
|
565
|
+
| `importAliases` | no | `{ "@app/domain": "packages/domain/src" }`: resolves non-relative imports to repository paths |
|
|
566
|
+
| `shell.block[]` | no | `{ pattern, why, person?, command? }`: never run. `person: true` marks a person's act, which the lead may do for them with `approvals.lead` on. `command: true` matches the pattern from the start of each command the line runs (after a package runner such as `npx` or `pnpm exec`, and inside `sh -c` or `eval`), with quoted text masked unless the pattern has quotes, so a grep, a heredoc or a message that mentions it isn't refused. Without it the pattern reads the whole line, except a read's quoted arguments: `grep "<command>" docs` doesn't run it |
|
|
567
|
+
| `shell.restricted[]` | no | `{ pattern, lanes, why }`: only the lead and these lanes. A read's quoted arguments don't count, as for `shell.block` |
|
|
568
|
+
| `postEdit[]` | no | `{ files, exclude?, run }`: after each edit of a matching file. `{file}` is the file. Exit 127 (tool not installed) is skipped. |
|
|
569
|
+
| `tests[]` | no | Globs naming the test files, in place of the conventions, for every rule that asks what a test is: weakened tests, a fix's tests, the tests that name a requirement, the code map and the security review. Default: a file named as a test (`*.test.*`, `*.spec.*`, `*.smoke.*`, `test_*.py`, `*_test.go`, `*_test.py`) or in a test folder (`test/`, `tests/`, `__tests__/`, `e2e/`, `smoke/`). Proving a fix keeps the files named as tests and takes the rest back, test-folder helpers included; with `tests` set, the files it names are the ones kept. |
|
|
570
|
+
| `regression.prepare` | no | A command run in a fresh checkout before a fix's tests run there without the fix, such as `npm ci`. The checkout's `node_modules` and virtualenvs are copied in first (a copy-on-write clone where the disk has one), so it can't change the checkout's own. The merge queue runs it too, in the merged tree's checkout, when its manifests or lockfiles differ from the installs copied in; without it, the queue runs the install the lockfile calls for. |
|
|
571
|
+
| `checks[]` | no | `{ name, files, exclude?, run[], each?, owners?, ifMissing?, timeoutSeconds? }`: before finishing, when matching files changed. `each` runs the commands in every changed folder matching that glob. `owners` limits who may change the files (the lead always may). `ifMissing: "fail"` makes a missing tool an error (the default is to skip the check, which `verify` and a merge list as not run). `timeoutSeconds` (240 unless set) is how long each command may run; one that runs out of time leaves its branch at the head of the merge queue rather than sending it back. |
|
|
572
|
+
| `adapters` | no | `{ "<adapter>": false }` switches off an adapter that would otherwise be detected; `true` says the project wants that tool, so until it's set up here `next` gives its setup before any code. See [Adapters](#adapters). |
|
|
573
|
+
| `approvals.lead` | no | `true` lets the lead act on what the person says in chat, for when `!` isn't available (on a phone, say): it records their approvals with `code-kit approve`, and runs `shell.block` commands marked `person`. Default `false`. See [Approvals](#approvals). |
|
|
574
|
+
| `approvals.delegate` | no | `false`, or `{ protected?: [approval names], merge?: true, push?: true, tests?: true, dependencies?: { licences?, minWeeklyDownloads?, maxMonthsSinceRelease?, allowInstallScripts?: true \| false \| [kinds] } }`: what the lead decides, inside the guardrails you keep: the protected approvals it grants, and packages it approves for a story, with `code-kit approve --delegated`; with `merge`, merges into a protected branch with `code-kit merge --delegated`; with `push`, pushes the protected branch, never by force (yours unless you set it, since a push can deploy; read from the config committed on that branch); with `tests`, weakened tests on a lane's branch. Left out, the lead decides everything technical: every protected approval but `spec`, `design`, `ci` and `kit`, packages, merges and weakened tests (WHO-1); `false` keeps everything for you. Lanes ask the lead for these, never you. npm packages are also checked against the npm registry, and a Python lane's against PyPI; the defaults are MIT, Apache-2.0, BSD and ISC, 10,000 weekly downloads, a release within 18 months, and no install scripts. See [Approvals](#approvals). |
|
|
575
|
+
| `setup` | no | The version of init's setup the project has (3 now). Without it, or lower, `next` names what the project is missing (the design gate, design stories before screens, a QA lane, a security reviewer) and starts no new story until re-running init adds it |
|
|
576
|
+
| `cost` | no | The running budget (spec 29): `{ currency, monthly, load?, paths? }`. `currency` is a three-letter code (USD, AUD, EUR); `monthly` maps each environment (`prod`, `dev`, …, not `all`) to what it may cost a month; `load` says in words what the budget plans for; `paths` are the infrastructure files, whatever defines them, and a branch that changes one changes the register too. A commit that takes an environment past its budget needs the person's `cost` approval, whatever is delegated |
|
|
577
|
+
| `team` | no | Preview. For several people in one repository: `{ techLead, staleDays?, intents?, board?, provider?, report? }`. `techLead` is the GitHub handle of the person who owns the plan, specs and contracts; `staleDays` is how many working days without a push make a claim stale (default 3); `intents` is the discussion category intents go in (default `Intents`; create it once in the repository's Settings › Discussions); `board` is `{ owner, number }`, a GitHub Project the plan is mirrored onto; `provider` is `"github"` (default), `{ command, fallback? }` for another team provider, or, in preview, a hosted provider's adapter as `{ "<name>": "<https address>" }`, which keeps the intents (Discussions only when `intents` is set) and has GitHub as its fallback; with `fallback: "github"`, claims go through GitHub whenever that provider can't be reached; `report` (default true) is whether the project reports its facts (stories' stages, send-backs, the requirement trail, the specs' titles and outcome lines, approvals, token use, the rules, the design register and the sessions at work; never code) to a provider that isn't GitHub. A provider may also supply an organisation's standards (`standards`, answering `{ standards, waivers, version }`, each standard in `docs.standards`' fields, each waiver `{ standard, paths?, expires?, reason?, approvedBy? }`): they apply as if in the project's file, which may extend or tighten one but weaken a required one only under a waiver. See docs/specs/16-teams.md, docs/specs/21-hub-adapter-and-reports.md and docs/specs/22-standards.md. |
|
|
578
|
+
| `branches.protected` | no | Default `["main", "master"]` |
|
|
579
|
+
| `branches.publish` | no | How a merge reaches the remote's base: `push` (the base is pushed, fast-forward only) or `pull-request` (for a base the remote only lets change through pull requests: code-kit opens one from `code-kit/publish-<base>` after each merge, and merges it where `approvals.delegate.push` is on, otherwise it waits for you). Left out, code-kit leaves pushing the base to you |
|
|
580
|
+
| `execution.unrepeatable` | no | Patterns (regular expressions) for commands that can't safely run twice, such as a seed or a deploy. With migrations, the commands `shell.block` and `shell.restricted` name, and `git push`, an interrupted one is never run again on its own after a crash: the lead finds out what happened first (spec 26) |
|
|
581
|
+
| `harness` | no | What the mod's harness does in the session: `autonomy` (`autonomous`, `propose`, `off` or `vibe`; default `autonomous`; `vibe` is autonomous with every decision the lead's, see [Vibe](#vibe)), `loop.quietMinutes` (while you talk with the lead about something else, how long the loop waits after you last spoke, 0 to 120; default 10), `loop.check` (check each step against the project before the lead is prompted with it; default `true`), `hold.minutes` (how long a call waiting on your approval is held, 0 to 10; default 2), `stall.nudgeMinutes` and `stall.restartMinutes` (default 5 and 10), `stall.maxRestarts` (default 2), `agents.reviewer.on` (default `false`) and `agents.reviewer.model` (code-kit's reviewer and the security reviewer; default `sonnet`), `agents.lanes.model` (the model each lane agent starts on, unless the lead's call or the lane's agent file names one: a model, or `story` for each story's `**Size:**` in the plan, raised for security requirements, fixes and send-backs; default the session's), `slices.open` (how many of the plan's slices are in focus: a free lane builds an open slice's stories first; default 1), `background.pauseAtPercent` (default 80), `compact.at` (compact the lead's context between turns once it's past this share of its window; default 40, 0 for never), `compact.milestone` (when a milestone finishes, compact the lead's context: `ask`, `auto` or `off`; default `ask`), `agents.lanes.contextLimit` (the context a lane agent may reach before it hands its story to a fresh agent; default 250,000 tokens), `notify.on` (a system notification when something new needs you; default `true`), `motion` (whether the pane's characters, clocks and the lead's rail move while work flows: `while-active` or `off`; default `while-active`) and `report.on` (agents draft bug reports for code-kit, which you send or discard; default `false`). Change them with `/harness` or `code-kit settings set`. |
|
|
580
582
|
|
|
581
583
|
Add `.claude/approvals/`, `.claude/state/` and `.claude/code-kit.draft.json` to `.gitignore`, and `.claude/approval-log.jsonl merge=union` to `.gitattributes`, so merging branches that both logged changes keeps every entry. Commit `.claude/code-kit.baseline.json` if the project has one.
|
|
582
584
|
|
|
@@ -638,7 +640,7 @@ code-kit approve pillow --lane api --delegated --story ST-138 --reason "MED-5 ne
|
|
|
638
640
|
- **Who:** only the lead. With `"approvals": { "delegate": false }`, `--delegated` is refused, and every approval is yours.
|
|
639
641
|
- **Weakened tests:** with `"tests": true` (the default), the lead approves a weakened test on a lane's branch for the story it reviewed, with `--lane` and `--story`; on its own branches it's yours.
|
|
640
642
|
- **Merges:** with `"merge": true`, the lead merges a reviewed branch into a protected branch with `code-kit merge <branch> --delegated`.
|
|
641
|
-
- It runs `code-kit verify` on the branch first, checks included, and merges only if it passes. The checks run on the branch merged with the base, in code-kit's own checkout of the project, kept between merges with its installs (`node_modules`, virtualenvs), copied in from the base's checkout the first time. Keeping it means a merge doesn't copy millions of files in and delete them again each time, which keeps macOS's file-change tracking and Spotlight busy; it lives in the temporary folder under `code-kit-checkouts.noindex`, which Spotlight skips. Where the merged tree's manifests or lockfiles differ from them, the install runs in that checkout first: `regression.prepare` if set, else the one its lockfile calls for (pnpm, npm, yarn, bun, uv). An install that fails there keeps the branch in its place in the queue; where code-kit knows no install, the merge says the installs it used may not match. A branch the base already holds is merged already: it leaves the queue as merged, never verified again.
|
|
643
|
+
- It runs `code-kit verify` on the branch first, checks included, and merges only if it passes. The checks run on the branch merged with the base, in code-kit's own checkout of the project, kept between merges with its installs (`node_modules`, virtualenvs), copied in from the base's checkout the first time. Keeping it means a merge doesn't copy millions of files in and delete them again each time, which keeps macOS's file-change tracking and Spotlight busy; it lives in the temporary folder under `code-kit-checkouts.noindex`, which Spotlight skips. The OS empties old files out of that folder, so each merge counts the kept installs' files. If any have gone, it copies them again and runs the install over the copy. Where the merged tree's manifests or lockfiles differ from them, the install runs in that checkout first: `regression.prepare` if set, else the one its lockfile calls for (pnpm, npm, yarn, bun, uv). An install that fails there keeps the branch in its place in the queue; where code-kit knows no install, the merge says the installs it used may not match. A branch the base already holds is merged already: it leaves the queue as merged, never verified again.
|
|
642
644
|
- Only uncommitted changes to files the merge changes stop it, in the base's checkout; it checks before the verify and again after. Other changes there, such as a log another tool appends to each turn, are carried as they are.
|
|
643
645
|
- Run from inside the lane's worktree, the merge keeps that worktree (the shell is in it); it goes at the next merge.
|
|
644
646
|
- The merge commit says it was verified and delegated.
|
package/bin/code-kit.mjs
CHANGED
|
@@ -3176,6 +3176,8 @@ function instructionsCommand() {
|
|
|
3176
3176
|
const said = {
|
|
3177
3177
|
current: 'up to date',
|
|
3178
3178
|
stale: 'from an older code-kit or config; --write brings it up to date',
|
|
3179
|
+
ahead:
|
|
3180
|
+
'from a newer code-kit than this one; --write leaves it. Run /plugin marketplace update code-kit and restart Claude Code',
|
|
3179
3181
|
missing: 'none yet; --write adds it',
|
|
3180
3182
|
legacy: 'written before code-kit marked its part; merge it once, by hand (below)',
|
|
3181
3183
|
};
|
package/hooks/guard-bash.mjs
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { appendFileSync, existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
9
9
|
import { spawnSync } from 'node:child_process';
|
|
10
10
|
import { basename, dirname, join, resolve, sep } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
11
12
|
import {
|
|
12
13
|
addedPackages,
|
|
13
14
|
dependencyApproval,
|
|
@@ -101,7 +102,7 @@ const ALWAYS = [
|
|
|
101
102
|
],
|
|
102
103
|
[
|
|
103
104
|
/approval-log\.jsonl/,
|
|
104
|
-
"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
|
|
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.",
|
|
105
106
|
unreadNames(cmd, /approval-log\.jsonl/).join('\n'),
|
|
106
107
|
],
|
|
107
108
|
];
|
|
@@ -835,12 +836,17 @@ ${approvalHowTo(TESTS_APPROVAL, actor, root, 'weakening tests in one commit', pe
|
|
|
835
836
|
// with no output file), or that write only outside the checkout (writesOutside). Errors sent into the
|
|
836
837
|
// output or /dev/null write no file.
|
|
837
838
|
const BEFORE_COMMIT = new RegExp(
|
|
838
|
-
String.raw`^(?:cd\s|${GIT}(?:add|rm|mv|restore\s+--staged|reset\s+--soft)(?![\w-])|${GIT}(?:switch\s+(?:-q\s+|--quiet\s+)*(?:-c|--create)|checkout\s+(?:-q\s+|--quiet\s+)*-b)\s+[^\s-]\S*\s*$)`,
|
|
839
|
+
String.raw`^(?:cd\s|${GIT}(?:add|rm|mv|restore\s+--staged|reset\s+--soft)(?![\w-])|${GIT}(?:switch\s+(?:-q\s+|--quiet\s+)*(?:-q?c|--create)|checkout\s+(?:-q\s+|--quiet\s+)*-q?b)\s+[^\s-]\S*\s*$)`,
|
|
839
840
|
);
|
|
840
841
|
// Setting shell variables (`f=docs/x.md`, `export MSG="…"`) writes no file, unless a value runs a
|
|
841
842
|
// command. What a later `git add "$f"` stages can't be read, so it counts as every changed file.
|
|
842
843
|
const ASSIGNS_ONLY = /^(?:export\s+)?[A-Za-z_]\w*=\S*(?:\s+[A-Za-z_]\w*=\S*)*$/;
|
|
843
|
-
|
|
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);
|
|
844
850
|
// A tool's command that writes only the tool's own records (an adapter's `shell.records`), which any
|
|
845
851
|
// actor may write and no check covers, with no redirect of its own.
|
|
846
852
|
const recordsOnly = (c) =>
|
|
@@ -851,7 +857,7 @@ const recordsOnly = (c) =>
|
|
|
851
857
|
const KEEPS_FILES = new RegExp(String.raw`^(?:mkdir\s|${GIT}worktree\s+(?:remove|prune)(?![\w-]))`);
|
|
852
858
|
// A branch made at a start point that is the commit the checkout is at already: no file changes.
|
|
853
859
|
const BRANCHES_AT =
|
|
854
|
-
/^git\s+(?:switch\s+(?:-q\s+|--quiet\s+)*(?:-c|--create)|checkout\s+(?:-q\s+|--quiet\s+)*-b)\s+[^\s-]\S*\s+([^\s-$`]\S*)\s*$/;
|
|
860
|
+
/^git\s+(?:switch\s+(?:-q\s+|--quiet\s+)*(?:-q?c|--create)|checkout\s+(?:-q\s+|--quiet\s+)*-q?b)\s+[^\s-]\S*\s+([^\s-$`]\S*)\s*$/;
|
|
855
861
|
const commitOf = (ref) =>
|
|
856
862
|
spawnSync('git', ['-C', root, 'rev-parse', '--verify', '--quiet', `${ref}^{commit}`], {
|
|
857
863
|
encoding: 'utf8',
|
|
@@ -887,20 +893,64 @@ function realOf(p) {
|
|
|
887
893
|
}
|
|
888
894
|
return join(realpathSync(at), ...tail);
|
|
889
895
|
}
|
|
896
|
+
const STATE_DIR = '.claude/state';
|
|
890
897
|
const within = (p, dir) => p === dir || p.startsWith(dir.endsWith(sep) ? dir : dir + sep);
|
|
891
898
|
function outsideCheckout(p) {
|
|
892
899
|
if (!p.startsWith('/') || /[$`*?{}[\]~]/.test(p)) return false;
|
|
893
900
|
const real = realOf(p);
|
|
894
901
|
return ![project, root].some((r) => within(real, realOf(r)));
|
|
895
902
|
}
|
|
896
|
-
//
|
|
897
|
-
//
|
|
903
|
+
// A path in code-kit's own state folder (a lane's report), which the project's .gitignore keeps out of
|
|
904
|
+
// any commit. A relative path is read from where the command runs, so one that moves elsewhere on the
|
|
905
|
+
// way, or commits in another repository, doesn't pass.
|
|
906
|
+
function inOwnState(p) {
|
|
907
|
+
if (/[$`*?{}[\]~]/.test(p)) return false;
|
|
908
|
+
if (!p.startsWith('/')) {
|
|
909
|
+
const moves = commandsOf(cmd).filter((c) => /^(?:cd|pushd|popd)\b/.test(c.text));
|
|
910
|
+
if (/\bgit\s+-C\b/.test(cmd) || moves.length > (/^\s*cd\s/.test(cmd) ? 1 : 0)) return false;
|
|
911
|
+
}
|
|
912
|
+
const real = realOf(resolve(input.cwd || project, gitDir ?? '.', p));
|
|
913
|
+
if (within(real, join(realOf(project), STATE_DIR)) && realOf(project) !== realOf(root))
|
|
914
|
+
return true;
|
|
915
|
+
if (!within(real, join(realOf(root), STATE_DIR))) return false;
|
|
916
|
+
return spawnSync('git', ['-C', root, 'check-ignore', '-q', real]).status === 0;
|
|
917
|
+
}
|
|
918
|
+
// What writes only where no commit can take it (a message drafted in a scratchpad for `git commit -F`,
|
|
919
|
+
// a lane's report): a read whose output goes only to such paths, or sed's substitutions in place on
|
|
920
|
+
// files outside the checkout.
|
|
898
921
|
function writesOutside(c) {
|
|
899
922
|
const out = outputRedirects(c.whole);
|
|
900
|
-
if (!out?.targets.every(outsideCheckout)) return false;
|
|
923
|
+
if (!out?.targets.every((t) => outsideCheckout(t) || inOwnState(t))) return false;
|
|
901
924
|
if (out.targets.length && readsOnly(out.rest)) return true;
|
|
902
925
|
return sedInPlaceFiles(out.rest.trim())?.every(outsideCheckout) ?? false;
|
|
903
926
|
}
|
|
927
|
+
// code-kit's own commands that write only its state folder (a question, a hold, a send-back, the merge
|
|
928
|
+
// queue's entries), or only read: run by this code-kit's own CLI, by its path or through a variable the
|
|
929
|
+
// line sets to it, with no redirect of their own, where the project ignores the state folder.
|
|
930
|
+
const KIT_CLI = realOf(join(dirname(fileURLToPath(import.meta.url)), '..', 'bin', 'code-kit.mjs'));
|
|
931
|
+
const KIT_RECORDS =
|
|
932
|
+
/^(?:ask|defer|sent-back|reconcile|requests\s+drop|queue(?:\s+(?:add|drop|pause|resume))?|next|status|who|trace)(?:\s|$)/;
|
|
933
|
+
function kitRecordsOnly(c) {
|
|
934
|
+
if (/[<>]/.test(c.code) || /(?:^|\s)--write(?:\s|$)/.test(c.code)) return false;
|
|
935
|
+
const run = c.text.match(/^node\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s+(.*)$/s);
|
|
936
|
+
if (!run || !KIT_RECORDS.test(run[4])) return false;
|
|
937
|
+
let path = run[1] ?? run[2] ?? run[3];
|
|
938
|
+
const variable = path.match(/^\$\{?([A-Za-z_]\w*)\}?$/)?.[1];
|
|
939
|
+
if (variable) {
|
|
940
|
+
const set = [
|
|
941
|
+
...cmd.matchAll(
|
|
942
|
+
new RegExp(
|
|
943
|
+
String.raw`(?:^|[;&|\n]\s*)(?:export\s+)?${variable}=(?:"([^"$\`]+)"|'([^']+)'|([^\s"'$\`;&|]+))`,
|
|
944
|
+
'g',
|
|
945
|
+
),
|
|
946
|
+
),
|
|
947
|
+
];
|
|
948
|
+
if (set.length !== 1) return false;
|
|
949
|
+
path = set[0][1] ?? set[0][2] ?? set[0][3];
|
|
950
|
+
}
|
|
951
|
+
if (/[$\`]/.test(path) || realOf(resolve(input.cwd || project, path)) !== KIT_CLI) return false;
|
|
952
|
+
return spawnSync('git', ['-C', root, 'check-ignore', '-q', join(root, STATE_DIR)]).status === 0;
|
|
953
|
+
}
|
|
904
954
|
function writesBeforeCommit() {
|
|
905
955
|
const pieces = commandsOf(withoutHarmlessRedirects(cmd));
|
|
906
956
|
const at = pieces.findIndex((c) => new RegExp(String.raw`^${GIT}commit(?![\w-])`).test(c.text));
|
|
@@ -912,6 +962,7 @@ function writesBeforeCommit() {
|
|
|
912
962
|
!readsOnly(c.whole) &&
|
|
913
963
|
!assignsOnly(c) &&
|
|
914
964
|
!recordsOnly(c) &&
|
|
965
|
+
!kitRecordsOnly(c) &&
|
|
915
966
|
!keepsFiles(c) &&
|
|
916
967
|
!writesOutside(c),
|
|
917
968
|
);
|