@skitterbyte/skitterspec 23.21.1 → 23.23.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/MIGRATION.md +126 -0
- package/assets/claude-md-section.md +23 -123
- package/assets/project-conventions.md +17 -0
- package/assets/rules/negative-checks.md +21 -48
- package/assets/rules/offered-unblocks.md +39 -74
- package/assets/rules/spec-format.md +117 -0
- package/assets/rules/spec-planning.md +128 -1013
- package/assets/rules/spec-reports.md +70 -607
- package/assets/skills/no-spec/SKILL.md +4 -4
- package/assets/skills/spec/SKILL.md +7 -7
- package/assets/skills/spec/kind-routing.md +35 -0
- package/assets/skills/spec-bug/SKILL.md +6 -6
- package/assets/skills/spec-cancel/SKILL.md +1 -1
- package/assets/skills/spec-complete/SKILL.md +1 -1
- package/assets/skills/spec-diff/SKILL.md +6 -2
- package/assets/skills/spec-diff/review-page.md +89 -0
- package/assets/skills/spec-diff/review-wait.md +133 -0
- package/assets/skills/spec-epic-next/SKILL.md +2 -1
- package/assets/skills/spec-epic-next/epics.md +44 -0
- package/assets/skills/spec-hotfix/SKILL.md +5 -5
- package/assets/skills/spec-incident/SKILL.md +1 -1
- package/assets/skills/spec-next/SKILL.md +5 -5
- package/assets/skills/spec-resume/SKILL.md +62 -8
- package/assets/skills/spec-review/SKILL.md +1 -1
- package/assets/skills/spec-start/isolation.md +90 -0
- package/bin/skitterspec.js +3 -1
- package/package.json +1 -1
- package/src/cli.js +72 -5
- package/src/conventions.js +43 -0
- package/src/env/resume.js +116 -3
- package/src/init.js +180 -30
- package/src/spec-planning-history.json +103 -0
- package/src/updateall.js +152 -0
|
@@ -31,13 +31,65 @@ each spec branch, local then remote-tracking, never fetched. That matters
|
|
|
31
31
|
because the base branch reads `backlog` for the whole life of a spec, and under
|
|
32
32
|
`land.specDocs: "branch"` an in-flight spec may exist only on its branch.
|
|
33
33
|
|
|
34
|
-
- **`ok: false
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
- **`ok: false` with an `offer`.** That is a completed spec, and the offer is
|
|
35
|
+
re-opening it. Relay the `refused` text, **then** put the offer's `label`
|
|
36
|
+
and Cancel to the operator as `.claude/rules/offered-unblocks.md`
|
|
37
|
+
describes: the label verbatim, nothing pre-selected, and no third option.
|
|
38
|
+
On the label, go to **1b**. On Cancel, stop with `⏸` and record nothing.
|
|
39
|
+
- **`ok: false` and no `offer`.** Relay the `refused` text and stop with
|
|
40
|
+
`⏸`. It covers a name or ticket that matches nothing (it never guesses the
|
|
41
|
+
nearest), a spec in `backlog` (`Next` is `/spec-start <name>`), a cancelled
|
|
42
|
+
spec, a completed hotfix or epic, and one with no branch anywhere to resume
|
|
43
|
+
from. **Never offer a re-open the engine did not declare**, however
|
|
44
|
+
obviously one seems to fit.
|
|
38
45
|
- **`ok: true`.** Carry on. `blockers`, `progress` and `identifier` are read
|
|
39
46
|
in step 3.
|
|
40
47
|
|
|
48
|
+
## 1b. Re-open a completed spec (only on the offer's pick)
|
|
49
|
+
|
|
50
|
+
Sometimes a spec was completed to get its work onto the base branch, and more
|
|
51
|
+
phases turn out to be needed. Its branch went at teardown, and its work is on
|
|
52
|
+
the base, so re-opening is a fresh branch **at the base as it is now**. This
|
|
53
|
+
step does what `/spec-start` does for that branch, and nothing more.
|
|
54
|
+
|
|
55
|
+
1. **Ask for the plan.** Run
|
|
56
|
+
`skitterspec spec-env resume <spec> --reopen --json`. A refusal here
|
|
57
|
+
(a worktree still standing, or a leftover branch holding commits the base
|
|
58
|
+
does not have) is relayed and ends `⏸`. It never resets work, and neither
|
|
59
|
+
do you.
|
|
60
|
+
2. **Provision.** Bring the review server up as step 2 says. Run the plan's
|
|
61
|
+
`commands` in order from the primary checkout. The first creates the
|
|
62
|
+
branch at the base, and the second is `spec-env up`, a planner: run the
|
|
63
|
+
commands it prints, then its `then` line with the `cd` in front, exactly
|
|
64
|
+
as `/spec-start` step 3 does. Confirm with `skitterspec spec-env resolve`
|
|
65
|
+
(no argument) as step 2 below does.
|
|
66
|
+
3. **Move it back, and say why.** Run the plan's `move` command. Add a dated
|
|
67
|
+
Changelog line, `Re-opened from complete: <reason>`. The reason comes from
|
|
68
|
+
the message, or is **asked once** when there is none.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
- Set the **Status** header: `> **Status:** In Progress — re-opened <YYYY-MM-DD>`.
|
|
73
|
+
- Append a **State log** row: `| <YYYY-MM-DD> | In Progress | in-progress | <git user.name> |`.
|
|
74
|
+
|
|
75
|
+
4. **Put the ticket back in progress.** The bucket move is the same code fact
|
|
76
|
+
`/spec-start` reports, so it takes the same steps. On a re-open, the board
|
|
77
|
+
reporting the ticket Done or Cancelled is **expected rather than a warning**:
|
|
78
|
+
the push below is what moves it back. Do not relay it.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
5. **Commit it** before anything is built: `skitterspec spec-env stage <spec>`
|
|
85
|
+
and its `owned` paths, pathspec-bounded on both the `add` and the
|
|
86
|
+
`commit`, as `docs(spec): reopen <spec>` with the `Refs:` trailer when
|
|
87
|
+
there is a ticket.
|
|
88
|
+
|
|
89
|
+
Then carry on at **step 3**. Every phase reads `✅`, so step 4's rule for new
|
|
90
|
+
work applies: the message becomes a new phase file plus an index row. With no
|
|
91
|
+
message, **ask what the new phase is** rather than inventing one.
|
|
92
|
+
|
|
41
93
|
## 2. Get into its worktree
|
|
42
94
|
|
|
43
95
|
**Only when the project has per-spec isolation** (`specs/.core/env.config.json`).
|
|
@@ -101,7 +153,7 @@ be several:
|
|
|
101
153
|
dated Changelog line quoting the report.
|
|
102
154
|
- **Work outside this spec.** For example: a different feature, or a defect in
|
|
103
155
|
code the spec never touched. Propose the right door with a one-line reason,
|
|
104
|
-
confirm first, as `.claude/
|
|
156
|
+
confirm first, as `.claude/skills/spec/kind-routing.md` does. A
|
|
105
157
|
defect goes to `/spec-bug`; new behaviour goes to `/spec`. On a no, carry
|
|
106
158
|
on with whatever part of the message was this spec's.
|
|
107
159
|
|
|
@@ -140,13 +192,15 @@ Otherwise, end with the block defined in `.claude/rules/spec-reports.md`.
|
|
|
140
192
|
stands, or bootstrap failed a step that does not stop the reading.
|
|
141
193
|
- `❌`: provisioning or the move failed part-way. Name what was left and
|
|
142
194
|
where.
|
|
143
|
-
- `⏸`: the engine refused
|
|
195
|
+
- `⏸`: the engine refused, or a re-open offer was answered Cancel. Nothing
|
|
196
|
+
was provisioned and nothing moved.
|
|
144
197
|
|
|
145
198
|
**Fields:** `Tracker` · `Spec` · `Built` · `Notes` · `Worktree` ·
|
|
146
199
|
`Follow-ups` · `Next`
|
|
147
200
|
|
|
148
|
-
`Spec` is the bucket and progress (`2 of 4 done, phase 3 in progress`)
|
|
149
|
-
`Worktree` is the path, and says
|
|
201
|
+
`Spec` is the bucket and progress (`2 of 4 done, phase 3 in progress`), and
|
|
202
|
+
says **re-opened from complete** after 1b. `Worktree` is the path, and says
|
|
203
|
+
**entered**, **provisioned** or **re-opened**. `Built` lists
|
|
150
204
|
what the message added to the spec (tasks, a cleared blocker), and is absent
|
|
151
205
|
when nothing was written. `Notes` carries any blocker still standing, quoted.
|
|
152
206
|
`Next` is `/spec-next` when the spec is ready to build, or the blocker when one
|
|
@@ -192,7 +192,7 @@ API that moved, a task the code already does. `Spec` carries the status the
|
|
|
192
192
|
review leaves it in, which is the answer to "can I start this?".
|
|
193
193
|
|
|
194
194
|
**Where step 4b rendered a page the run is waiting**, so the block omits the
|
|
195
|
-
`Review` row and ends on the banner from `.claude/
|
|
195
|
+
`Review` row and ends on the banner from `.claude/skills/spec-diff/review-wait.md` — the
|
|
196
196
|
tier stack copied from the engine's own lines, never one link chosen for the
|
|
197
197
|
reader:
|
|
198
198
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Isolation, worktrees and the live overlay
|
|
2
|
+
|
|
3
|
+
Applies only when `specs/.core/env.config.json` exists. Without it, every skill
|
|
4
|
+
works in the checkout it is standing in.
|
|
5
|
+
|
|
6
|
+
## Workspace modes (`mode` in `env.config.json`)
|
|
7
|
+
|
|
8
|
+
- **`worktree`** (the default): each spec gets its own checkout, so several can
|
|
9
|
+
be in flight and `main` stays free. `/spec-start` builds the branch there,
|
|
10
|
+
moves the session in with a plain `cd`, and asks whether to build phase 1. The
|
|
11
|
+
primary checkout stays on the base branch, so the base branch still shows an
|
|
12
|
+
in-flight spec under `backlog`. `skitterspec status` reads each worktree's own
|
|
13
|
+
copy.
|
|
14
|
+
- **`checkout`**: the branch is built in the primary checkout, one spec at a
|
|
15
|
+
time, and the build carries straight on. `/spec-connect` and `/spec-live` do
|
|
16
|
+
not apply and say so.
|
|
17
|
+
|
|
18
|
+
**Omit the spec name anywhere** and the engine uses the worktree you are
|
|
19
|
+
standing in, or else the only provisioned spec.
|
|
20
|
+
|
|
21
|
+
## Per-spec isolation
|
|
22
|
+
|
|
23
|
+
`/spec-start` gives every in-progress spec its own worktree. Docker is a
|
|
24
|
+
per-spec escalation: `> **Stack:** worktree` (the default) or
|
|
25
|
+
`worktree + docker` when the spec touches the database or stateful services.
|
|
26
|
+
`/spec-start` brings up a namespaced stack only for the latter, and starts the
|
|
27
|
+
host **dev servers** (`dev` in `env.config.json`) on the spec's ports.
|
|
28
|
+
`/spec-connect <name>` maps that spec onto your normal `localhost` ports, and
|
|
29
|
+
`/spec-connect main` hands them back. Teardown is part of `/spec-complete` and
|
|
30
|
+
`/spec-cancel`, which drop the spec's test-DB volume and offer to prune orphans
|
|
31
|
+
first.
|
|
32
|
+
|
|
33
|
+
The engine is `skitterspec spec-env
|
|
34
|
+
<up|bootstrap|nospec|main|project|down|prune|dev|connect|integrate|disposition|handoff|hotfix|live|review|stage|checks|status|resolve|resume|base>`.
|
|
35
|
+
`up` plans the fork, and **`bootstrap` runs the worktree's own steps**: seeding
|
|
36
|
+
the gitignored files, the env file, `setup` and the stack. Never reconstruct
|
|
37
|
+
those steps as shell commands.
|
|
38
|
+
|
|
39
|
+
A **hotfix** is the one spec that does not fork from `main`. `/spec-hotfix` forks
|
|
40
|
+
from a release tag, and `/spec-complete` lands it through `spec-env hotfix land`
|
|
41
|
+
(release, push on consent, carry to `main` without the version commit). Its
|
|
42
|
+
worktree stays until the deploy is out and a second `/spec-complete` runs
|
|
43
|
+
`spec-env hotfix finish`.
|
|
44
|
+
|
|
45
|
+
## The live overlay (`/spec-live`)
|
|
46
|
+
|
|
47
|
+
`/spec-connect` runs a spec's own dev stack. The live overlay instead reuses the
|
|
48
|
+
dev server you already have running. `/spec-live <spec>`, or a bare
|
|
49
|
+
`/spec-live`, rebases the branch onto the base (the fetched remote base under PR
|
|
50
|
+
landing), frees it from its worktree, and checks it out
|
|
51
|
+
**in the primary checkout**, so the running server hot-reloads it. The checked-out branch is the
|
|
52
|
+
lock, so only one spec is live at a time. `/spec-live main` hands the checkout
|
|
53
|
+
back. Fixes made while live commit straight onto the branch, and
|
|
54
|
+
`/spec-complete` knows about live specs and lands them.
|
|
55
|
+
|
|
56
|
+
- It is for **testing** a code-only spec, not for starting work, and no
|
|
57
|
+
lifecycle skill invokes it.
|
|
58
|
+
- It **refuses** stateful specs (`Stack: worktree + docker`, or a branch that
|
|
59
|
+
touches migrations). Use `/spec-connect` and a Docker stack for those.
|
|
60
|
+
- `live.afterSwitch` entries (`{ run, when }`) run in the primary checkout after
|
|
61
|
+
taking and after releasing. The engine runs them itself.
|
|
62
|
+
- The engine is `skitterspec spec-env live <take|release|abort|status>`.
|
|
63
|
+
|
|
64
|
+
## Authoring a spec off the base branch
|
|
65
|
+
|
|
66
|
+
With isolation, `/spec` grills first, then runs `spec-env up <name> --docs`,
|
|
67
|
+
moves into that worktree and writes the spec there. `--docs` skips `setup` and
|
|
68
|
+
Docker, so the tree costs one `git worktree add`. `/spec-start` later re-runs
|
|
69
|
+
`up` without the flag, and the install happens then.
|
|
70
|
+
|
|
71
|
+
Both committing verdicts on the authoring page (`Commit & Start`, `Commit`)
|
|
72
|
+
commit on the branch, then `spec-env integrate` rebases and fast-forwards, so
|
|
73
|
+
the base gains the spec as one commit. `Commit & Start` keeps the worktree and
|
|
74
|
+
carries into `/spec-start`. `Commit` tears it down. The authoring page arms
|
|
75
|
+
nothing, because a backlog spec owes no phase.
|
|
76
|
+
|
|
77
|
+
**`land.specDocs: "branch"`** (the default once a ticketing provider is
|
|
78
|
+
configured and the key is unset) keeps the spec on its feature branch, to land
|
|
79
|
+
with the work. Both verdicts commit and skip the integrate, plain `Commit` keeps
|
|
80
|
+
the branch and worktree, and the backlog is found through the tracker. Setting
|
|
81
|
+
the key, to either value, always wins.
|
|
82
|
+
|
|
83
|
+
## Staging one spec and not another
|
|
84
|
+
|
|
85
|
+
`skitterspec spec-env stage [<spec>] [--json]` splits the uncommitted tree you
|
|
86
|
+
are standing in into what belongs to this spec and what does not. **Owned** is
|
|
87
|
+
the spec's folder in any bucket plus each `spec.companionPaths` entry. Code is
|
|
88
|
+
always **foreign**, because the commits this bounds are the lifecycle ones.
|
|
89
|
+
Nothing here refuses. Commit with the pathspec on both `git add` and
|
|
90
|
+
`git commit`.
|
package/bin/skitterspec.js
CHANGED
|
@@ -28,8 +28,10 @@ const { run } = require('../src/cli.js')
|
|
|
28
28
|
// PRE-composition (seam markers still literal). Installing from it writes those
|
|
29
29
|
// markers into the user's skills. So ask a second, positive question before any
|
|
30
30
|
// install command runs.
|
|
31
|
+
// `update --all` installs nothing itself — it runs each project's own bin —
|
|
32
|
+
// so it is not asked.
|
|
31
33
|
const argv = process.argv.slice(2)
|
|
32
|
-
if (argv[0] === 'init' || argv[0] === 'update') {
|
|
34
|
+
if (argv[0] === 'init' || (argv[0] === 'update' && !argv.includes('--all'))) {
|
|
33
35
|
try {
|
|
34
36
|
require('../src/init.js').assertComposedAssets()
|
|
35
37
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skitterbyte/skitterspec",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.23.0",
|
|
4
4
|
"description": "Spec-driven development for Claude Code \u2014 a tracker-free filesystem workflow: lifecycle skills and per-spec isolation. For Linear sync, install @skitterbyte/skitterspec-linear instead.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
package/src/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ const fs = require('fs')
|
|
|
4
4
|
const path = require('path')
|
|
5
5
|
const os = require('os')
|
|
6
6
|
const { pathToFileURL } = require('url')
|
|
7
|
-
const { execFileSync } = require('child_process')
|
|
7
|
+
const { execFileSync, spawnSync } = require('child_process')
|
|
8
8
|
const { init, resync, reset, uninstall, disable, enable, checkSync, isExistingSetup, localSeedFiles } = require('./init.js')
|
|
9
9
|
const {
|
|
10
10
|
detectReleaseTooling,
|
|
@@ -197,7 +197,7 @@ const {
|
|
|
197
197
|
const { planPrune, liveSlugsForSpecs, reconcileRegistry } = require('./env/prune.js')
|
|
198
198
|
const { planIntegrate, planIntegrateCheckout, planIntegratePr, planIntegrateDocs } = require('./env/integrate.js')
|
|
199
199
|
const { specBranchDocs, preferBranches } = require('./env/specbranches.js')
|
|
200
|
-
const { findTarget, planResume, resumeLines, blockingNext } = require('./env/resume.js')
|
|
200
|
+
const { findTarget, planResume, planReopen, resumeLines, reopenLines, blockingNext } = require('./env/resume.js')
|
|
201
201
|
const { parseRemote, prFor, prPlanCommand, prAbandonCommand, preferRemoteBase } = require('./env/host.js')
|
|
202
202
|
const { collectDisposition } = require('./env/disposition.js')
|
|
203
203
|
const { planHandoff } = require('./env/handoff.js')
|
|
@@ -286,7 +286,10 @@ Usage:
|
|
|
286
286
|
skitterspec update [dir] Resync managed files to the latest, keeping your
|
|
287
287
|
edits (--force to overwrite). Leaves specs/ + live
|
|
288
288
|
.core config alone. --check reports what it would
|
|
289
|
-
change and writes nothing.
|
|
289
|
+
change and writes nothing. --all updates every
|
|
290
|
+
local install this machine's Claude Code has run
|
|
291
|
+
in, each with its own provider; team installs are
|
|
292
|
+
listed, not written.
|
|
290
293
|
skitterspec uninstall [dir] Take a local install (init --local) back off this
|
|
291
294
|
machine: managed files, hooks, the CLAUDE.local.md
|
|
292
295
|
block, the git excludes. Prints the plan; --yes
|
|
@@ -353,6 +356,8 @@ Usage:
|
|
|
353
356
|
resume [spec|#N] an in-flight spec: its blockers, and the plan
|
|
354
357
|
to rebuild its worktree from its branch
|
|
355
358
|
(prints commands; creates nothing)
|
|
359
|
+
--reopen: a completed spec, re-opened on a
|
|
360
|
+
fresh branch from the base
|
|
356
361
|
base fetch, list baseBranchPattern matches
|
|
357
362
|
newest-first, mark the base, and name
|
|
358
363
|
specs forked from an older match
|
|
@@ -486,6 +491,39 @@ function parse(argv) {
|
|
|
486
491
|
return { opts, positional }
|
|
487
492
|
}
|
|
488
493
|
|
|
494
|
+
// `update --all`: plan from Claude Code's project list, run each project's own
|
|
495
|
+
// distribution, one line per project. Exit 1 only when an update failed.
|
|
496
|
+
function updateAll() {
|
|
497
|
+
const { planUpdateAll, runUpdateAll } = require('./updateall.js')
|
|
498
|
+
const { readManifest, hasPathInstall } = require('./init.js')
|
|
499
|
+
const git = (dir, args) => {
|
|
500
|
+
try {
|
|
501
|
+
return execFileSync('git', ['-C', dir, ...args], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim()
|
|
502
|
+
} catch {
|
|
503
|
+
return null
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
const rows = planUpdateAll({
|
|
507
|
+
dirs: knownDirs(defaultRoot()),
|
|
508
|
+
exists: fs.existsSync,
|
|
509
|
+
git,
|
|
510
|
+
readManifest,
|
|
511
|
+
onPath: (bin) => hasPathInstall(process.env, bin),
|
|
512
|
+
})
|
|
513
|
+
if (!rows.length) {
|
|
514
|
+
process.stdout.write("update --all — no skitterspec installs found in Claude Code's project list\n")
|
|
515
|
+
return 0
|
|
516
|
+
}
|
|
517
|
+
process.stdout.write(`update --all — ${rows.length} project${rows.length === 1 ? '' : 's'}\n`)
|
|
518
|
+
// The run is in the project folder with no dir argument, so no path is ever
|
|
519
|
+
// quoted for a shell — cmd.exe needs the shell to start a `.cmd` shim.
|
|
520
|
+
const run = (bin, _args, cwd) =>
|
|
521
|
+
spawnSync(bin, ['update'], { cwd, encoding: 'utf8', shell: process.platform === 'win32' })
|
|
522
|
+
const { lines, failed } = runUpdateAll(rows, run)
|
|
523
|
+
for (const l of lines) process.stdout.write(`${l}\n`)
|
|
524
|
+
return failed ? 1 : 0
|
|
525
|
+
}
|
|
526
|
+
|
|
489
527
|
// After an `update`, clean up release tooling left by an older skitterspec (it
|
|
490
528
|
// now lives in @skitterbyte/skittership). Deletes only on an explicit interactive
|
|
491
529
|
// "yes" or --remove-release-tooling; a non-TTY/--yes run only prints the pointer,
|
|
@@ -4613,12 +4651,14 @@ function specEnvResolve(dir, config, specArg, flags = {}) {
|
|
|
4613
4651
|
}
|
|
4614
4652
|
|
|
4615
4653
|
/**
|
|
4616
|
-
* `skitterspec spec-env resume <name|#N> [--json]` (feat-spec-resume)
|
|
4654
|
+
* `skitterspec spec-env resume <name|#N> [--reopen] [--json]` (feat-spec-resume)
|
|
4617
4655
|
*
|
|
4618
4656
|
* Which in-flight spec the argument means, what it is blocked on, and — where
|
|
4619
4657
|
* this machine has no worktree for it — the commands that rebuild one from its
|
|
4620
4658
|
* branch. Plans and prints; creates nothing, moves nothing, asks no tracker.
|
|
4621
|
-
* A refusal exits 1.
|
|
4659
|
+
* A refusal exits 1. A completed spec's refusal carries an `offer` of
|
|
4660
|
+
* `--reopen` (feat-resume-reopen), which plans a fresh branch at the base and
|
|
4661
|
+
* the move back to in-progress.
|
|
4622
4662
|
*
|
|
4623
4663
|
* Every copy of the spec this clone can see is read — the checkout it runs
|
|
4624
4664
|
* from, each live worktree, and each spec branch (local, then remote-tracking,
|
|
@@ -4695,6 +4735,28 @@ function specEnvResume(dir, config, arg, flags = {}) {
|
|
|
4695
4735
|
}
|
|
4696
4736
|
}
|
|
4697
4737
|
const worktreePath = ownTree(target.folder)
|
|
4738
|
+
if (flags.reopen) {
|
|
4739
|
+
// Merged means an ancestor of the base: `merge-base --is-ancestor` exits 0
|
|
4740
|
+
// for yes and 1 for no, and the reader returns null for any non-zero exit,
|
|
4741
|
+
// so a git error reads as NOT merged, the side that resets nothing.
|
|
4742
|
+
const merged = (ref) => (base ? git(['merge-base', '--is-ancestor', ref, base]) !== null : null)
|
|
4743
|
+
const localBranch = git(['show-ref', '--verify', '--quiet', `refs/heads/${branch}`]) !== null
|
|
4744
|
+
const remoteBranch = git(['show-ref', '--verify', '--quiet', `refs/remotes/${remote}/${branch}`]) !== null
|
|
4745
|
+
const rr = planReopen(target, {
|
|
4746
|
+
branch,
|
|
4747
|
+
base,
|
|
4748
|
+
remote,
|
|
4749
|
+
worktreePath,
|
|
4750
|
+
worktreeExists: fs.existsSync(worktreePath),
|
|
4751
|
+
localBranch,
|
|
4752
|
+
localMerged: localBranch ? merged(`refs/heads/${branch}`) : null,
|
|
4753
|
+
remoteBranch,
|
|
4754
|
+
remoteMerged: remoteBranch ? merged(`refs/remotes/${remote}/${branch}`) : null,
|
|
4755
|
+
})
|
|
4756
|
+
if (!rr.ok) process.exitCode = 1
|
|
4757
|
+
process.stdout.write(flags.json ? JSON.stringify(rr, null, 2) + '\n' : reopenLines(rr).join('\n') + '\n')
|
|
4758
|
+
return
|
|
4759
|
+
}
|
|
4698
4760
|
const r = planResume(target, {
|
|
4699
4761
|
branch,
|
|
4700
4762
|
worktreePath,
|
|
@@ -8188,6 +8250,7 @@ async function specEnv(rest) {
|
|
|
8188
8250
|
else if (args[i] === '--assert-primary-clean') flags.assertPrimaryClean = true
|
|
8189
8251
|
else if (args[i] === '--use-fallback') flags.useFallback = true
|
|
8190
8252
|
else if (args[i] === '--unpin') flags.unpin = true
|
|
8253
|
+
else if (args[i] === '--reopen') flags.reopen = true
|
|
8191
8254
|
else positional.push(args[i])
|
|
8192
8255
|
}
|
|
8193
8256
|
dir = path.resolve(dir)
|
|
@@ -8550,6 +8613,10 @@ async function run(argv) {
|
|
|
8550
8613
|
// `update` is a resync — refresh managed files, keep customized ones
|
|
8551
8614
|
// (--force to overwrite). Leaves specs/ and live .core config alone.
|
|
8552
8615
|
// `--check` reports what it WOULD change and writes nothing.
|
|
8616
|
+
if (opts.all) {
|
|
8617
|
+
process.exitCode = updateAll()
|
|
8618
|
+
break
|
|
8619
|
+
}
|
|
8553
8620
|
if (opts.check) {
|
|
8554
8621
|
checkSync(dir, { claudeMd: opts.claudeMd })
|
|
8555
8622
|
break
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Moving a project's conventions out of the old `spec-planning.md`
|
|
4
|
+
// (feat-rules-budget). Before that spec, the typecheck and test commands lived
|
|
5
|
+
// in a "Project conventions (fill this in)" section inside the managed rule.
|
|
6
|
+
// Filling it in made the whole 66k file "customized", so `update` kept it and
|
|
7
|
+
// the host went on loading all of it every session.
|
|
8
|
+
//
|
|
9
|
+
// `split` cuts that section out. `KNOWN` holds the hash of every shipped
|
|
10
|
+
// version with the section cut out, so a file whose ONLY edits were in that
|
|
11
|
+
// section hashes to a known value, and its edits can be carried over to
|
|
12
|
+
// `project-conventions.md` safely. Any other edit is cannot-tell, and the file
|
|
13
|
+
// is kept (`.claude/rules/negative-checks.md` rule 4).
|
|
14
|
+
|
|
15
|
+
const crypto = require('crypto')
|
|
16
|
+
|
|
17
|
+
const HEADING = /^## Project conventions \(fill this in\)[^\n]*\n/m
|
|
18
|
+
|
|
19
|
+
// `{ rest, body }`: `rest` is the file without the section, `body` the
|
|
20
|
+
// section's text below its heading. `null` when the section is not there.
|
|
21
|
+
function split(text) {
|
|
22
|
+
const t = text.replace(/\r\n/g, '\n')
|
|
23
|
+
const m = HEADING.exec(t)
|
|
24
|
+
if (!m) return null
|
|
25
|
+
const from = m.index
|
|
26
|
+
const after = from + m[0].length
|
|
27
|
+
const next = t.slice(after).search(/^## /m)
|
|
28
|
+
const end = next === -1 ? t.length : after + next
|
|
29
|
+
return { rest: t.slice(0, from) + t.slice(end), body: t.slice(after, end).trim() }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function strippedHash(text) {
|
|
33
|
+
const parts = split(text)
|
|
34
|
+
return parts && crypto.createHash('sha1').update(parts.rest).digest('hex')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let known = null
|
|
38
|
+
function KNOWN() {
|
|
39
|
+
if (!known) known = new Set(require('./spec-planning-history.json').stripped)
|
|
40
|
+
return known
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = { split, strippedHash, KNOWN }
|
package/src/env/resume.js
CHANGED
|
@@ -177,8 +177,18 @@ function planResume(target, env) {
|
|
|
177
177
|
const how =
|
|
178
178
|
target.bucket === 'backlog'
|
|
179
179
|
? ' — it was never started; /spec-start puts it in flight'
|
|
180
|
-
:
|
|
181
|
-
|
|
180
|
+
: reopenable(target)
|
|
181
|
+
? ' — re-opening it forks a fresh branch from the base branch as it is now'
|
|
182
|
+
: ' — there is nothing left to resume'
|
|
183
|
+
const r = { ok: false, ...base, refused: `${target.folder} is in ${target.bucket}${how}` }
|
|
184
|
+
if (reopenable(target)) {
|
|
185
|
+
r.offer = {
|
|
186
|
+
kind: 'satisfy',
|
|
187
|
+
label: `Re-open ${target.folder}`,
|
|
188
|
+
command: `skitterspec spec-env resume ${target.folder} --reopen`,
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return r
|
|
182
192
|
}
|
|
183
193
|
if (env.worktreeExists) return { ok: true, ...base, commands: [], then: [] }
|
|
184
194
|
|
|
@@ -204,6 +214,95 @@ function planResume(target, env) {
|
|
|
204
214
|
return { ok: true, ...base, commands, then: [`skitterspec spec-env bootstrap ${target.folder}`] }
|
|
205
215
|
}
|
|
206
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Whether a finished spec may be re-opened (feat-resume-reopen): only from
|
|
219
|
+
* `complete`, and never a hotfix (it lands by tag and cherry-pick, so a
|
|
220
|
+
* re-opened one has no landing path) or an epic (it holds no phases). A
|
|
221
|
+
* cancelled spec's code never landed, so "from the current state" would be a
|
|
222
|
+
* rebuild from the text alone — that is a new spec.
|
|
223
|
+
*
|
|
224
|
+
* The kind is read off the `Type:` header, falling back to the folder prefix
|
|
225
|
+
* for a spec written without one.
|
|
226
|
+
*/
|
|
227
|
+
function reopenable(target) {
|
|
228
|
+
if (!target || target.bucket !== 'complete') return false
|
|
229
|
+
const type = (headerValue(target.overview, 'Type') || '').toLowerCase()
|
|
230
|
+
if (type === 'hotfix' || type === 'epic') return false
|
|
231
|
+
return !/^(hotfix|epic)-/.test(target.folder)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The plan for `spec-env resume <spec> --reopen`, or a refusal with no offer.
|
|
236
|
+
*
|
|
237
|
+
* The spec's branch was deleted when it completed, and its work is on the base
|
|
238
|
+
* branch, so re-opening is a fresh branch AT the base. The branch is created
|
|
239
|
+
* here (`git branch -f`) rather than left to `up`, so `up` takes its attach
|
|
240
|
+
* path: left alone, `up` would carry on from a leftover remote branch instead,
|
|
241
|
+
* which is an older state than the base it landed on.
|
|
242
|
+
*
|
|
243
|
+
* WHAT WOULD FOOL THIS: a leftover branch with commits the base does not hold
|
|
244
|
+
* — a teardown that was declined, or a squash merge, whose commits are never
|
|
245
|
+
* ancestors of the base. `-f` over that branch would destroy them, so an
|
|
246
|
+
* unmerged leftover, local or remote, refuses and names it. An answer the
|
|
247
|
+
* caller could not get (`null`) is read the same way: a branch nobody could
|
|
248
|
+
* prove safe is not reset (`.claude/rules/negative-checks.md` rule 4).
|
|
249
|
+
*
|
|
250
|
+
* @param {object} target the copy `findTarget` chose
|
|
251
|
+
* @param {object} env `{ branch, base, worktreePath, worktreeExists,
|
|
252
|
+
* localBranch, localMerged, remoteBranch, remoteMerged, remote }`
|
|
253
|
+
*/
|
|
254
|
+
function planReopen(target, env) {
|
|
255
|
+
const spec = target.folder
|
|
256
|
+
const refuse = (refused) => ({ ok: false, spec, bucket: target.bucket, branch: env.branch, refused })
|
|
257
|
+
if (!reopenable(target)) {
|
|
258
|
+
if (target.bucket !== 'complete') return refuse(`${spec} is in ${target.bucket} — only a completed spec can be re-opened`)
|
|
259
|
+
const epic = /^epic-/.test(spec) || (headerValue(target.overview, 'Type') || '').toLowerCase() === 'epic'
|
|
260
|
+
return refuse(
|
|
261
|
+
epic
|
|
262
|
+
? `${spec} is a completed epic, which holds no phases`
|
|
263
|
+
: `${spec} is a completed hotfix, which lands by tag and has no branch to re-open`,
|
|
264
|
+
)
|
|
265
|
+
}
|
|
266
|
+
if (!env.base) return refuse(`the base branch cannot be resolved, so there is nothing to fork ${spec} from`)
|
|
267
|
+
if (env.worktreeExists) {
|
|
268
|
+
return refuse(`a worktree for ${spec} still exists at ${env.worktreePath} — tear it down (spec-env down ${spec}) or work there`)
|
|
269
|
+
}
|
|
270
|
+
if (env.localBranch && env.localMerged !== true) {
|
|
271
|
+
return refuse(`${env.branch} still exists with commits not on ${env.base} — land or delete it before re-opening`)
|
|
272
|
+
}
|
|
273
|
+
if (env.remoteBranch && env.remoteMerged !== true) {
|
|
274
|
+
return refuse(
|
|
275
|
+
`${env.remote}/${env.branch} still exists with commits not on ${env.base} — ` +
|
|
276
|
+
`delete it (git push ${env.remote} --delete ${env.branch}) before re-opening`,
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
ok: true,
|
|
281
|
+
spec,
|
|
282
|
+
bucket: target.bucket,
|
|
283
|
+
branch: env.branch,
|
|
284
|
+
base: env.base,
|
|
285
|
+
worktree: { path: env.worktreePath, present: false },
|
|
286
|
+
commands: [`git branch -f ${env.branch} ${env.base}`, `skitterspec spec-env up ${spec}`],
|
|
287
|
+
move: [`git -C ${shellPath(env.worktreePath)} mv specs/complete/${spec} specs/in-progress/${spec}`],
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** The text report for `--reopen`. */
|
|
292
|
+
function reopenLines(r) {
|
|
293
|
+
if (!r.ok) return [`spec-env resume --reopen: refused — ${r.refused}`]
|
|
294
|
+
return [
|
|
295
|
+
`spec-env resume --reopen: ${r.spec} (complete → in-progress, on ${r.branch} from ${r.base})`,
|
|
296
|
+
` worktree: ${r.worktree.path}`,
|
|
297
|
+
'',
|
|
298
|
+
' to provision, run (then run what `up` prints):',
|
|
299
|
+
...r.commands.map((c) => ` ${c}`),
|
|
300
|
+
'',
|
|
301
|
+
' then, move the spec:',
|
|
302
|
+
...r.move.map((c) => ` ${c}`),
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
|
|
207
306
|
function blockerLine(b) {
|
|
208
307
|
const where = b.where === 'spec' ? 'spec' : `phase ${b.where}`
|
|
209
308
|
return `${where} — ${b.text}${b.until ? ` (until ${b.until})` : ''}`
|
|
@@ -221,6 +320,7 @@ function resumeLines(r) {
|
|
|
221
320
|
for (const b of r.blockers) lines.push(` blocked: ${blockerLine(b)}${r.blocking && b.where === r.blocking.where ? ' ← holds the next build' : ''}`)
|
|
222
321
|
if (!r.ok) {
|
|
223
322
|
lines.push(` refused: ${r.refused}`)
|
|
323
|
+
if (r.offer) lines.push(` offer: ${r.offer.label} — ${r.offer.command}`)
|
|
224
324
|
return lines
|
|
225
325
|
}
|
|
226
326
|
lines.push(` worktree: ${r.worktree.path}${r.worktree.present ? '' : ' (missing — provision below)'}`)
|
|
@@ -231,4 +331,17 @@ function resumeLines(r) {
|
|
|
231
331
|
return lines
|
|
232
332
|
}
|
|
233
333
|
|
|
234
|
-
module.exports = {
|
|
334
|
+
module.exports = {
|
|
335
|
+
blockers,
|
|
336
|
+
blockingNext,
|
|
337
|
+
parseBlockedOn,
|
|
338
|
+
findTarget,
|
|
339
|
+
planResume,
|
|
340
|
+
planReopen,
|
|
341
|
+
reopenable,
|
|
342
|
+
resumeLines,
|
|
343
|
+
reopenLines,
|
|
344
|
+
blockerLine,
|
|
345
|
+
frontmatterField,
|
|
346
|
+
sameRef,
|
|
347
|
+
}
|