@warren-dean/code-kit 0.26.2 → 0.27.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 +15 -0
- package/README.md +5 -3
- package/bin/code-kit.mjs +269 -52
- package/hooks/act.mjs +14 -5
- package/hooks/guard-bash.mjs +76 -17
- package/hooks/lib/checkout.mjs +105 -0
- package/hooks/lib/checks.mjs +34 -8
- package/hooks/lib/config.mjs +5 -2
- package/hooks/lib/dependencies.mjs +4 -0
- package/hooks/lib/designs.mjs +137 -0
- package/hooks/lib/events.mjs +9 -4
- package/hooks/lib/hook.mjs +41 -1
- package/hooks/lib/next.mjs +26 -5
- package/hooks/lib/plan.mjs +26 -13
- package/hooks/lib/queue.mjs +86 -1
- package/hooks/lib/regression.mjs +54 -44
- package/hooks/lib/rules.mjs +63 -20
- package/hooks/lib/team.mjs +27 -1
- package/hooks/lib/verify.mjs +37 -4
- package/hooks/lib/worktrees.mjs +18 -1
- package/hooks/mod/board.mjs +10 -1
- package/hooks/mod/loop.mjs +44 -1
- package/hooks/mod/register.mjs +96 -8
- package/hooks/mod/view.mjs +8 -0
- package/hooks/stop-check.mjs +6 -1
- package/package.json +1 -1
- package/skills/design/SKILL.md +36 -7
- package/skills/dispatch/SKILL.md +1 -0
- package/skills/review/SKILL.md +2 -1
- package/skills/spec-design/SKILL.md +1 -1
- package/skills/status/SKILL.md +1 -1
- package/templates/agent.md +2 -1
|
@@ -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.27.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.27.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,21 @@
|
|
|
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.27.0 (2026-10-30)
|
|
6
|
+
|
|
7
|
+
Fixes for what projects reported: the loop respects Claude's usage limit, merges land as they were verified, claims end with their stories, and approved designs reach lanes as files.
|
|
8
|
+
|
|
9
|
+
- **Usage limits.** When Claude's usage limit stops the lead, the loop now waits until the limit resets instead of prompting into it, and the band says so, with **Try now**. With no reset time, it retries after 5 minutes, doubling up to an hour. A lane agent stopped by the limit isn't taken as finished: it keeps its lane, its story stays in progress, and its finish isn't checked.
|
|
10
|
+
- **The loop** no longer repeats steps it has already asked while nothing in the project has changed. It doesn't send a step it worked out while the lead's turn began, so a branch you just dropped from the queue isn't put up to merge. It carries on a lane agent at its context limit only when the agent says it isn't finished.
|
|
11
|
+
- **The merge queue** verifies each branch as it will land, merged with the base in a fresh checkout that has its own installs. A merge already running isn't started again or asked for. `queue add <branch> --with <other>` makes branches that only work together wait for each other and merge as one. `merge <branch>` marks its queue entry as merged.
|
|
12
|
+
- **Claims.** When a story merges, its claim is released on GitHub as well as on the hub, and claims stuck on merged stories are cleared.
|
|
13
|
+
- **Approvals.** When merges are delegated, the lead still needs your approval to change what's yours. Every commit is judged, including `git -C`, and a commit chained after a command that writes files is refused. A refusal says when the approval ran out or which commit used it up. A commit stopped by the secrets scan doesn't use one up, and a request is no longer closed by a commit made just before it.
|
|
14
|
+
- **Test checks.** `expect.poll` and `expect.soft` count as assertions. A branch deleting or reworking tests it added itself isn't weakening tests. A fix made entirely in tests (a flaky test, a broken helper) passes the fix check. A fix's proof that a typecheck failure hid is found.
|
|
15
|
+
- **verify** no longer counts files the branch holds exactly as the base does. A check's long output doesn't fail it, because its exit code decides. Installs inside a container (`docker run`, podman) aren't the project's dependencies. `.mcp.json` belongs to the lead.
|
|
16
|
+
- **Plans and commands.** A story marked `**Status:** dropped` is never dispatched or waited on. A story whose lane is building it again isn't offered for review. `ask --help` and `ask list` behave as commands. `git merge-base`, `merge-tree` and `commit-tree` aren't read as merges or commits.
|
|
17
|
+
- **Designs handed over (spec 24).** An approved design is now files in `design/` (each state's code and a PNG, with their hashes), so a lane builds from exactly what you approved. Committing the register is refused while a file is missing or changed, or a state the spec lists has no design. `code-kit designs <story>` lists a story's designs, and review compares each built screen with its design. `next` asks once to export designs that are still only in a design tool (`/code-kit:design --hand-over`).
|
|
18
|
+
- After updating, `next` asks to refresh each project's lane-agent instructions.
|
|
19
|
+
|
|
5
20
|
## 0.26.2 (2026-10-26)
|
|
6
21
|
|
|
7
22
|
The lanes pane tells the truth about what's being built, and is easier to read.
|
package/README.md
CHANGED
|
@@ -214,7 +214,7 @@ spec-design works an idea into a specification with you before any code exists.
|
|
|
214
214
|
|
|
215
215
|
It writes `docs/brief.md` (with the decision log and open questions), `docs/specs/NN-<area>.md`, `docs/architecture.md`, `docs/standards.md`, `docs/principles.md` and `docs/plan.md`. Those are exactly what `/code-kit:init docs/` turns into lanes, layers and standards, and what lanes spec-check against. Run it again to resume where it left off, to change a decision, or to spec a new feature in an existing codebase.
|
|
216
216
|
|
|
217
|
-
Requirements are headings (`### BOOK-4 Cancel a booking`). Stories are `### ST-12` headings in the plan with `**Lane:**`, `**Requirements:**`, `**Depends on:**` and `**Status:**` lines (`templates/plan.md`). The lane `lead` marks the lead's own stories, such as contracts and spikes, which the lead builds itself instead of dispatching; the lane `design` marks a design story, which the lead designs with you (`/code-kit:design`) before any screen that depends on it is built; `**Requirements:** none` marks a story that delivers no requirement. Those two formats are what the build loop below runs on.
|
|
217
|
+
Requirements are headings (`### BOOK-4 Cancel a booking`). Stories are `### ST-12` headings in the plan with `**Lane:**`, `**Requirements:**`, `**Depends on:**` and `**Status:**` lines (`templates/plan.md`). The lane `lead` marks the lead's own stories, such as contracts and spikes, which the lead builds itself instead of dispatching; the lane `design` marks a design story, which the lead designs with you (`/code-kit:design`) before any screen that depends on it is built; `**Requirements:** none` marks a story that delivers no requirement. `**Status:** dropped` takes a story out of the plan without deleting it (folded into another, or no longer wanted): it's never dispatched, never waited on, and covers no requirement. Those two formats are what the build loop below runs on.
|
|
218
218
|
|
|
219
219
|
## Set up a project
|
|
220
220
|
|
|
@@ -463,6 +463,7 @@ code-kit worktrees discard <branch> # the person's, from the band: remove a mer
|
|
|
463
463
|
code-kit instructions [--write] [--json] | instructions show lead|lane [<lane>] # code-kit's part of CLAUDE.md and the lane agents: where each stands, brought up to date, or printed
|
|
464
464
|
code-kit standards [--json] [--for <path>...] # the project's standards with any its organisation's provider supplies, and what's wrong with them; --for keeps the ones for those files' layers
|
|
465
465
|
code-kit trace <path>... [--json] # what a file is for: requirements, lane, layer rules
|
|
466
|
+
code-kit designs [<story>] [--json] # the approved designs: a story's screens' files, every state, or each entry and what's wrong with it
|
|
466
467
|
code-kit merge <branch> --delegated|--person [--into branch] # merge a branch that passes verify: the lead where approvals.delegate.merge is on, or the person
|
|
467
468
|
code-kit publish --delegated|--person # put what's merged into the base onto the remote's, as branches.publish says
|
|
468
469
|
code-kit replay <story> [--json|--brief] # a story's state rebuilt from its event log: its phase, last commit, tests, what's left open
|
|
@@ -489,6 +490,7 @@ code-kit settings [--json] # the harness setti
|
|
|
489
490
|
code-kit settings set <key> <value> --reason "…" # change one, as the person (approvals.<name> lead|person among them): written to the config and logged as a kit approval
|
|
490
491
|
code-kit queue [--json] # the merge queue: branches whose review passed, in order
|
|
491
492
|
code-kit queue add|drop <branch> # the lead queues a branch at the commit its review passed, or takes it out
|
|
493
|
+
code-kit queue add <branch> --with <branch>[,<branch>] # a branch that only lands together with others: merged as a group once all are queued
|
|
492
494
|
code-kit queue rules # the lead puts the approved rules onto a base that has none yet (a project set up before 0.8.0)
|
|
493
495
|
code-kit queue merge --delegated|--person # merge the head at the commit its review passed, verified against the base as it is now; a conflict or failed verify sends it back to its lane, and a branch that moved since its review leaves the queue to be reviewed again
|
|
494
496
|
code-kit loop [--json] # whether the person paused the lead loop; other tools' background work pauses with it
|
|
@@ -530,7 +532,7 @@ code-kit approve <name>... --reason "…" [--lane name] [--delegated [--story ST
|
|
|
530
532
|
| `docs.principles`, `docs.plan` | no | The engineering principles and the implementation plan |
|
|
531
533
|
| `docs.decisions` | no | Where agreed intents are recorded as numbered decision records (`code-kit intend record`); default `docs/decisions` |
|
|
532
534
|
| `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 |
|
|
533
|
-
| `lead.paths` | yes | What the main session writes. `.claude/**`
|
|
535
|
+
| `lead.paths` | yes | What the main session writes. `.claude/**` and `.mcp.json` are always added. |
|
|
534
536
|
| `lead.outside` | no | Paths outside the repository the lead may write, e.g. `../shared-lib/**`. Claude's memory and scratchpad are always included. |
|
|
535
537
|
| `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. |
|
|
536
538
|
| `lanes.<name>` | yes (may be `{}`) | `{ agent, paths, exclude?, owners? }`: the agent name maps a subagent to its lane; `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. |
|
|
@@ -542,7 +544,7 @@ code-kit approve <name>... --reason "…" [--lane name] [--delegated [--story ST
|
|
|
542
544
|
| `shell.restricted[]` | no | `{ pattern, lanes, why }`: only the lead and these lanes |
|
|
543
545
|
| `postEdit[]` | no | `{ files, exclude?, run }`: after each edit of a matching file. `{file}` is the file. Exit 127 (tool not installed) is skipped. |
|
|
544
546
|
| `tests[]` | no | Globs naming the test files, for the weakened-test and fix rules. Default: the usual conventions (`*.test.*`, `*.spec.*`, `__tests__/`, `test/`, `tests/`, `e2e/`, `*_test.go`, `test_*.py`). |
|
|
545
|
-
| `regression.prepare` | no | A command run in a fresh checkout before a fix's tests run there without the fix, such as `npm ci`.
|
|
547
|
+
| `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. |
|
|
546
548
|
| `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. |
|
|
547
549
|
| `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). |
|
|
548
550
|
| `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). |
|
package/bin/code-kit.mjs
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
// each story and requirement in the plan: built, in review, ready, blocked, tested
|
|
15
15
|
// adapters other tools detected in the project, what each adds to the rules, and its setup
|
|
16
16
|
// trace <path> [--json] what a file is for: the requirements it delivers, its lane, its layer rules
|
|
17
|
+
// designs [<story>] [--json] the approved designs from the register: a story's screens' design files,
|
|
18
|
+
// every state, for the lane's brief; or every entry and what's wrong with it
|
|
17
19
|
// next [--base ref] [--json]
|
|
18
20
|
// the step to take now (spec-design, init, dispatch, review…), from the project's state
|
|
19
21
|
// approve <name>... --reason "…" [--lane name]
|
|
@@ -100,6 +102,13 @@ import {
|
|
|
100
102
|
} from '../hooks/lib/questions.mjs';
|
|
101
103
|
import { traceFile } from '../hooks/lib/trace.mjs';
|
|
102
104
|
import { buildStatus, readStories, specCheckRows } from '../hooks/lib/plan.mjs';
|
|
105
|
+
import {
|
|
106
|
+
designsFor,
|
|
107
|
+
entryProblems,
|
|
108
|
+
handedOver,
|
|
109
|
+
readRegister,
|
|
110
|
+
toolOf,
|
|
111
|
+
} from '../hooks/lib/designs.mjs';
|
|
103
112
|
import { recordSentBack } from '../hooks/lib/reviews.mjs';
|
|
104
113
|
import {
|
|
105
114
|
SECURITY_AGENT,
|
|
@@ -117,7 +126,18 @@ import {
|
|
|
117
126
|
leadSection,
|
|
118
127
|
writeInstructions,
|
|
119
128
|
} from '../hooks/lib/instructions.mjs';
|
|
120
|
-
import {
|
|
129
|
+
import {
|
|
130
|
+
dequeue,
|
|
131
|
+
enqueue,
|
|
132
|
+
lastMerged,
|
|
133
|
+
markMerging,
|
|
134
|
+
mergingNow,
|
|
135
|
+
nextToMerge,
|
|
136
|
+
setPartners,
|
|
137
|
+
readQueue,
|
|
138
|
+
settle,
|
|
139
|
+
waiting,
|
|
140
|
+
} from '../hooks/lib/queue.mjs';
|
|
121
141
|
import { publishBase } from '../hooks/lib/publish.mjs';
|
|
122
142
|
import {
|
|
123
143
|
briefOf,
|
|
@@ -133,6 +153,7 @@ import {
|
|
|
133
153
|
storyOfBranch,
|
|
134
154
|
syncBoard,
|
|
135
155
|
readCache,
|
|
156
|
+
mergedClaims,
|
|
136
157
|
teamOf,
|
|
137
158
|
teamProvider,
|
|
138
159
|
whoami,
|
|
@@ -164,6 +185,7 @@ import {
|
|
|
164
185
|
import { heldTo, laneOfBranch, verifyBranch } from '../hooks/lib/verify.mjs';
|
|
165
186
|
import { skippedLine } from '../hooks/lib/checks.mjs';
|
|
166
187
|
import { TESTS_APPROVAL } from '../hooks/lib/regression.mjs';
|
|
188
|
+
import { freshCheckout } from '../hooks/lib/checkout.mjs';
|
|
167
189
|
import { laneClaim, laneClaims, releaseLane, shortSession } from '../hooks/lib/laneclaims.mjs';
|
|
168
190
|
import { slicesOf } from '../hooks/lib/schedule.mjs';
|
|
169
191
|
import {
|
|
@@ -178,6 +200,8 @@ import {
|
|
|
178
200
|
} from '../hooks/lib/sessions.mjs';
|
|
179
201
|
import { globsOverlap } from '../hooks/lib/teamfacts.mjs';
|
|
180
202
|
import {
|
|
203
|
+
BUSY_MS,
|
|
204
|
+
agentBusy,
|
|
181
205
|
cleanOf,
|
|
182
206
|
discardWorktree,
|
|
183
207
|
keptBecause,
|
|
@@ -240,6 +264,7 @@ for (let o = option('--owner'); o !== undefined; o = option('--owner')) ownersGi
|
|
|
240
264
|
const storyGiven = option('--story');
|
|
241
265
|
const whyGiven = option('--why');
|
|
242
266
|
const whatGiven = option('--what');
|
|
267
|
+
const withGiven = option('--with');
|
|
243
268
|
const expectedGiven = option('--expected');
|
|
244
269
|
const commandGiven = option('--command');
|
|
245
270
|
const refusalGiven = option('--refusal');
|
|
@@ -677,7 +702,10 @@ function merge(branch) {
|
|
|
677
702
|
const { config } = load();
|
|
678
703
|
const byPerson = mergeMode();
|
|
679
704
|
try {
|
|
680
|
-
|
|
705
|
+
const { message } = mergeOne(branch, config, byPerson);
|
|
706
|
+
// A branch merged outside the queue leaves it too, as one the queue merged would.
|
|
707
|
+
settle(resolve('.'), branch, 'merged');
|
|
708
|
+
out(`${message}${publishAfter(config, byPerson)}`);
|
|
681
709
|
} catch (e) {
|
|
682
710
|
if (e instanceof MergeStop) die(e.message);
|
|
683
711
|
throw e;
|
|
@@ -690,7 +718,7 @@ function merge(branch) {
|
|
|
690
718
|
* commit, and refuses if the branch has moved on from it. Returns { into, message }; throws a
|
|
691
719
|
* MergeStop when nothing was merged.
|
|
692
720
|
*/
|
|
693
|
-
function mergeOne(branch, config, byPerson, commit = null) {
|
|
721
|
+
function mergeOne(branch, config, byPerson, commit = null, partners = []) {
|
|
694
722
|
const refuse = (message) => {
|
|
695
723
|
throw new MergeStop('refused', message);
|
|
696
724
|
};
|
|
@@ -725,9 +753,13 @@ function mergeOne(branch, config, byPerson, commit = null) {
|
|
|
725
753
|
const temporary = [];
|
|
726
754
|
// A stop is thrown at once, so every way out of here removes the temporary worktrees first.
|
|
727
755
|
const cleanup = () => {
|
|
728
|
-
for (const
|
|
756
|
+
for (const t of temporary.splice(0)) {
|
|
757
|
+
if (t.remove) {
|
|
758
|
+
t.remove();
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
729
761
|
try {
|
|
730
|
-
g(root, 'worktree', 'remove', '--force',
|
|
762
|
+
g(root, 'worktree', 'remove', '--force', t);
|
|
731
763
|
} catch {
|
|
732
764
|
// already gone
|
|
733
765
|
}
|
|
@@ -745,17 +777,55 @@ function mergeOne(branch, config, byPerson, commit = null) {
|
|
|
745
777
|
return dir;
|
|
746
778
|
};
|
|
747
779
|
try {
|
|
748
|
-
|
|
749
|
-
// temporary worktree, where checks that need an install fail rather than being skipped.
|
|
750
|
-
const verifyIn = checkedOut(branch) ?? worktree(branch, true);
|
|
751
|
-
clean(verifyIn, branch);
|
|
752
|
-
const tip = g(verifyIn, 'rev-parse', 'HEAD').trim();
|
|
780
|
+
const tip = g(root, 'rev-parse', `refs/heads/${branch}`).trim();
|
|
753
781
|
if (commit && tip !== commit)
|
|
754
782
|
fail(
|
|
755
783
|
`Nothing was merged: ${branch} has moved on since its review passed (${commit.slice(0, 7)} → ${tip.slice(0, 7)}). Review it again, then queue it.`,
|
|
756
784
|
'moved',
|
|
757
785
|
);
|
|
758
|
-
|
|
786
|
+
// MQ-1: verified as it will land: the branch merged with the base as it is now, in a fresh checkout
|
|
787
|
+
// with its own copy of the installs (the branch's worktree's, else the main checkout's), so neither
|
|
788
|
+
// a stale branch head nor a checkout without dependencies decides it.
|
|
789
|
+
let fresh;
|
|
790
|
+
try {
|
|
791
|
+
fresh = freshCheckout(root, into, {
|
|
792
|
+
merge: tip,
|
|
793
|
+
installsFrom: checkedOut(branch) ?? root,
|
|
794
|
+
prefix: 'code-kit-merge-',
|
|
795
|
+
});
|
|
796
|
+
} catch (e) {
|
|
797
|
+
if (!e.conflict) throw e;
|
|
798
|
+
fail(
|
|
799
|
+
`Nothing was merged: ${branch} doesn't merge cleanly into ${into}. Merge ${into} into ${branch} and resolve it there, then merge again.\n${e.message}`,
|
|
800
|
+
'conflict',
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
temporary.push(fresh);
|
|
804
|
+
const verifyIn = fresh.dir;
|
|
805
|
+
// MQ-7: a group lands as one: its partners merged into the same tree, which the checks run on.
|
|
806
|
+
const members = partners.map((p) => ({
|
|
807
|
+
...p,
|
|
808
|
+
tip: g(root, 'rev-parse', `refs/heads/${p.branch}`).trim(),
|
|
809
|
+
}));
|
|
810
|
+
for (const m of members) {
|
|
811
|
+
const merged = spawnSync(
|
|
812
|
+
'git',
|
|
813
|
+
['-C', verifyIn, '-c', 'user.name=code-kit', '-c', 'user.email=code-kit@localhost'].concat([
|
|
814
|
+
'merge',
|
|
815
|
+
'--no-ff',
|
|
816
|
+
'--no-edit',
|
|
817
|
+
'--quiet',
|
|
818
|
+
m.tip,
|
|
819
|
+
]),
|
|
820
|
+
{ encoding: 'utf8' },
|
|
821
|
+
);
|
|
822
|
+
if (merged.status !== 0)
|
|
823
|
+
fail(
|
|
824
|
+
`Nothing was merged: ${m.branch} doesn't merge cleanly with ${branch} on ${into}. Merge one into the other and resolve it there, then merge again.\n${`${merged.stdout}${merged.stderr}`.trim()}`,
|
|
825
|
+
'conflict',
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
const lane = members.length ? null : laneOfBranch(branch, config);
|
|
759
829
|
const { changed, found, skipped, unfinished } = verifyBranch({
|
|
760
830
|
root: verifyIn,
|
|
761
831
|
base: into,
|
|
@@ -764,9 +834,29 @@ function mergeOne(branch, config, byPerson, commit = null) {
|
|
|
764
834
|
checks: true,
|
|
765
835
|
branch,
|
|
766
836
|
});
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
837
|
+
// Each member is still held to its own lane's paths, on its own tree.
|
|
838
|
+
for (const b of members.length ? [{ branch, tip }, ...members] : []) {
|
|
839
|
+
const own = freshCheckout(root, into, { merge: b.tip, prefix: 'code-kit-merge-' });
|
|
840
|
+
temporary.push(own);
|
|
841
|
+
const held = verifyBranch({
|
|
842
|
+
root: own.dir,
|
|
843
|
+
base: into,
|
|
844
|
+
config,
|
|
845
|
+
lane: laneOfBranch(b.branch, config),
|
|
846
|
+
checks: false,
|
|
847
|
+
fixes: false,
|
|
848
|
+
branch: b.branch,
|
|
849
|
+
});
|
|
850
|
+
for (const key of Object.keys(found))
|
|
851
|
+
found[key].push(...held.found[key].map((p) => `${b.branch}: ${p}`));
|
|
852
|
+
}
|
|
853
|
+
const problems = [
|
|
854
|
+
...new Set(
|
|
855
|
+
Object.entries(VERIFY_GROUPS).flatMap(([key, title]) =>
|
|
856
|
+
found[key].map((p) => `${title}: ${p.split('\n').join('\n ')}`),
|
|
857
|
+
),
|
|
858
|
+
),
|
|
859
|
+
];
|
|
770
860
|
// #62: a check that only ran out of time says nothing against the branch: it's tried again.
|
|
771
861
|
if (problems.length === 1 && unfinished)
|
|
772
862
|
fail(
|
|
@@ -781,32 +871,50 @@ function mergeOne(branch, config, byPerson, commit = null) {
|
|
|
781
871
|
);
|
|
782
872
|
const mergeIn = checkedOut(into) ?? worktree(into, false);
|
|
783
873
|
clean(mergeIn, into);
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
'-m',
|
|
790
|
-
`Merge ${branch} into ${into}`,
|
|
791
|
-
'-m',
|
|
792
|
-
`Verified with code-kit verify (${changed.length} file(s)${lane ? `, held to ${heldTo(lane)}` : ''}) at ${tip.slice(0, 7)}${commit ? ', the commit the review passed,' : ''} and merged ${byPerson ? 'by the person, from the code-kit pane' : 'by the lead within the delegated rules'}.${skipped.length ? ` ${notRun(skipped)}` : ''}`,
|
|
793
|
-
tip,
|
|
794
|
-
);
|
|
795
|
-
} catch (e) {
|
|
874
|
+
const before = g(mergeIn, 'rev-parse', 'HEAD').trim();
|
|
875
|
+
const together = members.length
|
|
876
|
+
? ` together with ${members.map((m) => m.branch).join(', ')} (MQ-7)`
|
|
877
|
+
: '';
|
|
878
|
+
for (const b of [{ branch, tip, commit }, ...members]) {
|
|
796
879
|
try {
|
|
797
|
-
g(
|
|
798
|
-
|
|
799
|
-
|
|
880
|
+
g(
|
|
881
|
+
mergeIn,
|
|
882
|
+
'merge',
|
|
883
|
+
'--no-ff',
|
|
884
|
+
'-m',
|
|
885
|
+
`Merge ${b.branch} into ${into}`,
|
|
886
|
+
'-m',
|
|
887
|
+
`Verified with code-kit verify (${changed.length} file(s)${lane ? `, held to ${heldTo(lane)}` : ''}) at ${b.tip.slice(0, 7)}${b.commit ? ', the commit the review passed,' : ''}${together && b.branch === branch ? together : ''} and merged ${byPerson ? 'by the person, from the code-kit pane' : 'by the lead within the delegated rules'}.${skipped.length ? ` ${notRun(skipped)}` : ''}`,
|
|
888
|
+
b.tip,
|
|
889
|
+
);
|
|
890
|
+
} catch (e) {
|
|
891
|
+
try {
|
|
892
|
+
g(mergeIn, 'merge', '--abort');
|
|
893
|
+
} catch {
|
|
894
|
+
// nothing to abort
|
|
895
|
+
}
|
|
896
|
+
// A group's earlier members stay merged only if the whole group lands: undo them.
|
|
897
|
+
if (b.branch !== branch) g(mergeIn, 'reset', '--hard', before);
|
|
898
|
+
fail(
|
|
899
|
+
`Nothing was merged: ${b.branch} doesn't merge cleanly into ${into}. Merge ${into} into ${b.branch} and resolve it there, then merge again.\n${String(e.stderr ?? e.message).trim()}`,
|
|
900
|
+
'conflict',
|
|
901
|
+
);
|
|
800
902
|
}
|
|
801
|
-
fail(
|
|
802
|
-
`Nothing was merged: ${branch} doesn't merge cleanly into ${into}. Merge ${into} into ${branch} and resolve it there, then merge again.\n${String(e.stderr ?? e.message).trim()}`,
|
|
803
|
-
'conflict',
|
|
804
|
-
);
|
|
805
903
|
}
|
|
806
|
-
// TEAM-1: a merged story's claim ends, whoever merged it.
|
|
904
|
+
// TEAM-1: a merged story's claim ends, whoever merged it, and so does any an earlier merge left.
|
|
807
905
|
const team = teamOf(config);
|
|
808
|
-
const
|
|
809
|
-
|
|
906
|
+
const stories = [branch, ...members.map((m) => m.branch)].map(storyOfBranch).filter(Boolean);
|
|
907
|
+
let unreleased = '';
|
|
908
|
+
if (team) {
|
|
909
|
+
const provider = teamProvider(resolve('.'), team);
|
|
910
|
+
for (const story of stories) {
|
|
911
|
+
const left = provider.release(story, { merged: true });
|
|
912
|
+
if (!left?.ok)
|
|
913
|
+
unreleased += ` Its claim on ${story} wasn't released (${left?.why ?? "the team provider didn't answer"}): run code-kit team release ${story}.`;
|
|
914
|
+
}
|
|
915
|
+
for (const s of mergedClaims(root, provider.state()?.claims ?? [], into))
|
|
916
|
+
if (!stories.includes(s)) provider.release(s, { merged: true });
|
|
917
|
+
}
|
|
810
918
|
// LEAN-8: the merged branch's worktree, and any other that's done with, go now.
|
|
811
919
|
const pruned = pruneWorktrees(root, config).removed;
|
|
812
920
|
const removed = pruned.length
|
|
@@ -814,7 +922,7 @@ function mergeOne(branch, config, byPerson, commit = null) {
|
|
|
814
922
|
: '';
|
|
815
923
|
return {
|
|
816
924
|
into,
|
|
817
|
-
message: `Merged ${branch} into ${into}: verify passed on ${changed.length} file(s)${lane ? `, held to ${heldTo(lane)}` : ''}, at ${tip.slice(0, 7)}.${skipped.length ? ` ${notRun(skipped)}` : ''}${removed}`,
|
|
925
|
+
message: `Merged ${branch}${together} into ${into}: verify passed on ${changed.length} file(s)${lane ? `, held to ${heldTo(lane)}` : ''}, at ${tip.slice(0, 7)}.${skipped.length ? ` ${notRun(skipped)}` : ''}${removed}${unreleased}`,
|
|
818
926
|
};
|
|
819
927
|
} finally {
|
|
820
928
|
cleanup();
|
|
@@ -850,23 +958,69 @@ function queue() {
|
|
|
850
958
|
}
|
|
851
959
|
// The commit the review passed: the queue merges exactly it, and a branch that moves is reviewed again.
|
|
852
960
|
const added = enqueue(root, branch, commit);
|
|
853
|
-
|
|
961
|
+
// MQ-7: branches that only land together.
|
|
962
|
+
const partnersGiven = (withGiven ?? '')
|
|
963
|
+
.split(/[\s,]+/)
|
|
964
|
+
.filter(Boolean)
|
|
965
|
+
.filter((b) => b !== branch);
|
|
966
|
+
if (partnersGiven.length) setPartners(root, branch, partnersGiven);
|
|
967
|
+
const joined = partnersGiven.length
|
|
968
|
+
? ` It merges together with ${partnersGiven.join(', ')}, once ${partnersGiven.length === 1 ? "it's" : "they're"} queued too.`
|
|
969
|
+
: '';
|
|
970
|
+
if (!added)
|
|
971
|
+
return out(`${branch} is already in the merge queue, at ${commit.slice(0, 7)}.${joined}`);
|
|
854
972
|
if (added === 'updated')
|
|
855
|
-
return out(
|
|
973
|
+
return out(
|
|
974
|
+
`${branch} keeps its place in the merge queue, now at ${commit.slice(0, 7)}.${joined}`,
|
|
975
|
+
);
|
|
856
976
|
const place = waiting(readQueue(root)).length;
|
|
857
977
|
return out(
|
|
858
|
-
`Queued ${branch} at ${commit.slice(0, 7)} to merge${place > 1 ? `, ${place - 1} ahead of it` : ', next'}
|
|
978
|
+
`Queued ${branch} at ${commit.slice(0, 7)} to merge${place > 1 ? `, ${place - 1} ahead of it` : ', next'}.${joined}`,
|
|
859
979
|
);
|
|
860
980
|
}
|
|
861
981
|
if (sub === 'rules') return rulesOntoBase(root, config);
|
|
862
982
|
if (sub === 'merge') {
|
|
863
983
|
const byPerson = mergeMode();
|
|
864
984
|
const entries = readQueue(root);
|
|
865
|
-
|
|
866
|
-
|
|
985
|
+
if (!waiting(entries).length) return out('The merge queue is empty.');
|
|
986
|
+
// MQ-7: the first branch that can merge: one queued with partners waits until they're queued too.
|
|
987
|
+
const { head, partners, held } = nextToMerge(entries);
|
|
988
|
+
if (!head)
|
|
989
|
+
return out(
|
|
990
|
+
`Nothing can merge yet: ${held.map((h) => `${h.branch} merges together with ${h.missing.join(', ')}, which ${h.missing.length === 1 ? "isn't" : "aren't"} queued yet`).join('; ')}.`,
|
|
991
|
+
);
|
|
992
|
+
const group = [head, ...partners];
|
|
993
|
+
// One merge at a time: a second run while the first verifies would merge the same head twice.
|
|
994
|
+
if (mergingNow(head))
|
|
995
|
+
die(
|
|
996
|
+
`${head.branch} is being merged now (queue merge, process ${head.pid}); nothing more was started. It says when it's done.`,
|
|
997
|
+
);
|
|
998
|
+
markMerging(root, head.branch, process.pid);
|
|
999
|
+
// However this run ends without settling the head, it goes back to waiting in its place.
|
|
1000
|
+
process.on('exit', () => {
|
|
1001
|
+
if (readQueue(root).some((e) => e.branch === head.branch && e.state === 'merging'))
|
|
1002
|
+
markMerging(root, head.branch, null);
|
|
1003
|
+
});
|
|
867
1004
|
try {
|
|
868
|
-
|
|
869
|
-
|
|
1005
|
+
for (const p of partners) {
|
|
1006
|
+
const at = execFileSync('git', ['rev-parse', '--verify', `${p.branch}^{commit}`], {
|
|
1007
|
+
encoding: 'utf8',
|
|
1008
|
+
}).trim();
|
|
1009
|
+
if (p.commit && at !== p.commit) {
|
|
1010
|
+
settle(root, p.branch, 'moved', 'changed after its review');
|
|
1011
|
+
die(
|
|
1012
|
+
`Nothing was merged: ${p.branch}, which ${head.branch} merges together with, has moved on since its review passed (${p.commit.slice(0, 7)} → ${at.slice(0, 7)}). It leaves the queue until it's reviewed again; ${head.branch} waits for it.`,
|
|
1013
|
+
);
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
const { message } = mergeOne(
|
|
1017
|
+
head.branch,
|
|
1018
|
+
config,
|
|
1019
|
+
byPerson,
|
|
1020
|
+
head.commit ?? null,
|
|
1021
|
+
partners.map((p) => ({ branch: p.branch, commit: p.commit ?? null })),
|
|
1022
|
+
);
|
|
1023
|
+
for (const m of group) settle(root, m.branch, 'merged');
|
|
870
1024
|
const published = publishAfter(config, byPerson);
|
|
871
1025
|
const left = waiting(readQueue(root));
|
|
872
1026
|
return out(
|
|
@@ -889,19 +1043,23 @@ function queue() {
|
|
|
889
1043
|
e.kind === 'conflict'
|
|
890
1044
|
? `conflicts with ${into}${after ? ` after ${after}` : ''}`
|
|
891
1045
|
: `fails verify against ${into}${after ? ` after ${after}` : ''}${e.first ? `: ${e.first}` : ''}`;
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1046
|
+
// A group goes back together: it only lands as one.
|
|
1047
|
+
for (const m of group) {
|
|
1048
|
+
const sha = execFileSync('git', ['rev-parse', '--verify', `${m.branch}^{commit}`], {
|
|
1049
|
+
encoding: 'utf8',
|
|
1050
|
+
}).trim();
|
|
1051
|
+
recordSentBack(root, m.branch, sha, why);
|
|
1052
|
+
settle(root, m.branch, 'sent back', why);
|
|
1053
|
+
}
|
|
1054
|
+
const names = group.map((m) => m.branch).join(', ');
|
|
897
1055
|
die(
|
|
898
|
-
`${e.message}\n${
|
|
1056
|
+
`${e.message}\n${names} ${group.length === 1 ? 'is sent back to its lane' : 'are sent back to their lanes'} (${why}) and ${group.length === 1 ? 'leaves' : 'leave'} the queue; ${group.length === 1 ? 'its fix rejoins' : 'their fixes rejoin'} after the next review.`,
|
|
899
1057
|
);
|
|
900
1058
|
}
|
|
901
1059
|
}
|
|
902
1060
|
if (sub !== undefined)
|
|
903
1061
|
die(
|
|
904
|
-
'code-kit queue [--json] | queue add <branch> | queue drop <branch> | queue rules | queue merge --delegated|--person',
|
|
1062
|
+
'code-kit queue [--json] | queue add <branch> [--with <branch>,…] | queue drop <branch> | queue rules | queue merge --delegated|--person',
|
|
905
1063
|
);
|
|
906
1064
|
const entries = readQueue(root);
|
|
907
1065
|
if (flag('--json')) return out(JSON.stringify(entries, null, 2));
|
|
@@ -2351,8 +2509,17 @@ function intendCommand() {
|
|
|
2351
2509
|
* hooks refuse from agents; otherwise the lead recording what the person said in chat); `ask withdraw`
|
|
2352
2510
|
* takes one back once it no longer needs the person.
|
|
2353
2511
|
*/
|
|
2512
|
+
const ASK_USAGE = `code-kit ask "<question>" [--story ST-n] [--blocks] [--why …] [--option "Label: what it does"]...
|
|
2513
|
+
asks the person what the lead can't settle; it waits in their Decisions tab
|
|
2514
|
+
code-kit ask [list] [--json] the questions waiting, and those answered lately
|
|
2515
|
+
code-kit ask answer <id> "<answer>"
|
|
2516
|
+
code-kit ask withdraw <id> --reason "…"`;
|
|
2517
|
+
|
|
2354
2518
|
function askCommand() {
|
|
2355
2519
|
const root = resolve('.');
|
|
2520
|
+
if (['--help', '-h', 'help'].includes(rest[0])) return out(ASK_USAGE);
|
|
2521
|
+
// `ask list` lists, as `ask` does.
|
|
2522
|
+
if (rest[0] === 'list' && rest.length === 1) rest.length = 0;
|
|
2356
2523
|
const [sub, id, ...words] = rest;
|
|
2357
2524
|
if (sub === 'answer') {
|
|
2358
2525
|
const r = answerQuestion(root, id, {
|
|
@@ -2390,6 +2557,13 @@ function askCommand() {
|
|
|
2390
2557
|
return;
|
|
2391
2558
|
}
|
|
2392
2559
|
const question = rest.join(' ').trim();
|
|
2560
|
+
// A question reaches the person, so a flag or a stray word never becomes one.
|
|
2561
|
+
if (rest[0].startsWith('-'))
|
|
2562
|
+
die(`${rest[0]} isn't an option of ask; nothing was asked.\n${ASK_USAGE}`);
|
|
2563
|
+
if (!/\s/.test(question) && !question.endsWith('?'))
|
|
2564
|
+
die(
|
|
2565
|
+
`"${question}" isn't a question for the person; nothing was asked. Ask it as a sentence they can answer.\n${ASK_USAGE}`,
|
|
2566
|
+
);
|
|
2393
2567
|
if (flag('--blocks') && !storyGiven) die('--blocks holds a story: name it with --story ST-n.');
|
|
2394
2568
|
const r = askQuestion(root, {
|
|
2395
2569
|
by: 'lead',
|
|
@@ -2571,6 +2745,10 @@ function worktreesCommand() {
|
|
|
2571
2745
|
if (rest[0] === 'release') {
|
|
2572
2746
|
const w = list.find((x) => x.branch === rest[1] || x.path === rest[1]);
|
|
2573
2747
|
if (!w) die(`No worktree has ${rest[1] ?? '<branch>'} checked out.`);
|
|
2748
|
+
if (agentBusy(root, w))
|
|
2749
|
+
die(
|
|
2750
|
+
`The ${w.branch.split('/')[0]} lane's agent is still at work on ${w.branch} (its last act was under ${BUSY_MS / 60_000} minutes ago, with no hand-back); nothing was removed. Wait for it to hand back, or stop it with TaskStop, then release it.`,
|
|
2751
|
+
);
|
|
2574
2752
|
return out(`Released ${releaseWorktree(w)}. The branch and its commits stay.`);
|
|
2575
2753
|
}
|
|
2576
2754
|
if (rest[0] === 'discard') {
|
|
@@ -2684,8 +2862,47 @@ function standardsCommand() {
|
|
|
2684
2862
|
process.exit(1);
|
|
2685
2863
|
}
|
|
2686
2864
|
|
|
2865
|
+
/**
|
|
2866
|
+
* HAND-3, HAND-5: the approved designs, from the design register. `designs <story>` gives the designs a
|
|
2867
|
+
* story's screens are built from (its own entries and its design stories'), each state's files and
|
|
2868
|
+
* viewport, for the lane's brief; `designs` lists every entry and what's wrong with it.
|
|
2869
|
+
*/
|
|
2870
|
+
function designsCommand() {
|
|
2871
|
+
const { config } = load();
|
|
2872
|
+
const root = resolve('.');
|
|
2873
|
+
if (!config.designGate) die('The project has no design gate (designGate in the config).');
|
|
2874
|
+
const { entries, error } = readRegister(root, config);
|
|
2875
|
+
if (error) die(error);
|
|
2876
|
+
const story = rest[0];
|
|
2877
|
+
const stories = config.docs?.plan ? readStories(root, config.docs.plan) : [];
|
|
2878
|
+
const shown = (story ? designsFor(entries, story, stories) : entries).map((e) => ({
|
|
2879
|
+
...e,
|
|
2880
|
+
handedOver: handedOver(e),
|
|
2881
|
+
problems: entryProblems(root, e, config.docs?.specs),
|
|
2882
|
+
}));
|
|
2883
|
+
if (flag('--json')) return out(JSON.stringify(shown, null, 2));
|
|
2884
|
+
if (!shown.length)
|
|
2885
|
+
return out(
|
|
2886
|
+
story ? `No approved design is for ${story}'s screens.` : 'No approved designs yet.',
|
|
2887
|
+
);
|
|
2888
|
+
for (const e of shown) {
|
|
2889
|
+
out(
|
|
2890
|
+
`${e.file}: ${e.screen ?? '(no screen name)'}, approved ${e.approved ?? '?'} in ${e.story}`,
|
|
2891
|
+
);
|
|
2892
|
+
if (!e.handedOver)
|
|
2893
|
+
out(` only in ${toolOf(e)}: hand it over with /code-kit:design --hand-over`);
|
|
2894
|
+
for (const st of e.states ?? [])
|
|
2895
|
+
out(
|
|
2896
|
+
` ${st.name} (${st.viewport ?? 'no viewport'}): ${[st.image, st.code].filter(Boolean).join(', ')}${st.why ? ` (no code: ${st.why})` : ''}`,
|
|
2897
|
+
);
|
|
2898
|
+
if (e.tokens) out(` tokens: ${e.tokens}`);
|
|
2899
|
+
for (const p of e.handedOver ? e.problems : []) out(` ✗ ${p}`);
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2687
2903
|
const commands = {
|
|
2688
2904
|
check,
|
|
2905
|
+
designs: designsCommand,
|
|
2689
2906
|
standards: standardsCommand,
|
|
2690
2907
|
worktrees: worktreesCommand,
|
|
2691
2908
|
instructions: instructionsCommand,
|
|
@@ -2735,7 +2952,7 @@ function usage() {
|
|
|
2735
2952
|
' | security [--base ref] [--branch name] [--json]\n' +
|
|
2736
2953
|
' | next [--base ref] [--json] | adapters | trace <path>... [--json]\n' +
|
|
2737
2954
|
' | instructions [--write] [--json] | instructions show lead|lane [<lane>]\n' +
|
|
2738
|
-
' | standards [--json] [--for <path>...]\n' +
|
|
2955
|
+
' | standards [--json] [--for <path>...] | designs [<story>] [--json]\n' +
|
|
2739
2956
|
' | worktrees [--json] | worktrees release|discard <branch> | worktrees prune [--quiet]\n' +
|
|
2740
2957
|
' | approve <name>... --reason "…" [--lane name] [--config file]\n' +
|
|
2741
2958
|
' | merge <branch> --delegated|--person [--into branch] | publish --delegated|--person\n' +
|