@alterset/alterspec-client 0.12.0 → 0.13.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/README.md +8 -7
- package/assets/prompts/_shared.md +4 -2
- package/assets/prompts/spec-ask.md +22 -13
- package/assets/prompts/task-context.md +4 -1
- package/assets/prompts/task-done.md +10 -5
- package/assets/prompts/task-next.md +9 -4
- package/assets/skills/alterspec-task-done/SKILL.md +1 -1
- package/developer-guide.md +19 -6
- package/dist/cli.js +64 -15
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,9 +126,11 @@ You talk to Claude Code; the skills call the dispatcher and the CLI for you.
|
|
|
126
126
|
`Alterspec-Covers` line. After each commit the hook reports the covered items to the dispatcher. It works in the
|
|
127
127
|
background and never blocks you. It skips the report when nothing changed or the last report is under 15 minutes
|
|
128
128
|
old.
|
|
129
|
-
4. **
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
4. **Push, then report done.** Once the task's branch is pushed, type `/alterspec-task-done CHG-012/BE`. It sends
|
|
130
|
+
the last progress and reports the task done with the branch's head commit and the branch (or, once merged, with
|
|
131
|
+
the commit on the main branch that brought it in). It refuses while nothing is pushed. The tasks waiting for yours
|
|
132
|
+
start from your branch; the dispatcher learns of the merge from the repository's pushes. When the brief says
|
|
133
|
+
"Start from `task/…`", base your branch on that one (`worktree <task> --from <branch>`), not on main.
|
|
132
134
|
|
|
133
135
|
Other skills:
|
|
134
136
|
|
|
@@ -153,12 +155,12 @@ worktree, the configuration is read from the main checkout.
|
|
|
153
155
|
| `key` | Print the public key and fingerprint you sign with. |
|
|
154
156
|
| `open dispatcher` | Sign in and open the dispatcher's pages in the browser. The link works once, for a minute. |
|
|
155
157
|
| `context <task> [--json] [--stats]` | Print the task's brief from the export, starting with its questions and its checklist. |
|
|
156
|
-
| `worktree <task> [--here]`
|
|
158
|
+
| `worktree <task> [--here] [--from <branch>]` | Create the branch `task/<chg>-<track>` from `origin/<main>`, or from the predecessor's pushed branch with `--from`, in its own worktree, with the checkout's git-ignored top-level symlinks linked in and its committed relative ones made to resolve. `--here` uses this checkout instead. |
|
|
157
159
|
| `progress [task] [--json]` | Report the items your commits cover. Default: the task of the current branch. |
|
|
158
160
|
| `lookup [ref...] [--question <text>] [--task <task>] [--item <item>]` | Where in the export a question is answered: what to read first, what to open before calling the export silent, the neighbours. `--unread <path...>` says what of that was not opened. |
|
|
159
161
|
| `cites <ref...>` | Check that every ID or path is in the export; what an answer "from the spec" must pass. |
|
|
160
162
|
| `questions [task] [--about <ID...>] [--open] [--json]` | Print a task's questions with the product side's answers, the ones naming some IDs, or without either your own. |
|
|
161
|
-
| `merged <task
|
|
163
|
+
| `merged <task> [--json]` | Print the commit and branch to report `done` with: the pushed task branch's head, or the commit on `origin/<main>` that brought the task in. |
|
|
162
164
|
| `export-head [--latest <sha>]` | Pull the export clone and print the commit to send to the dispatcher. |
|
|
163
165
|
| `mcp` | The MCP server Claude Code starts from `.mcp.json`. It forwards to the dispatcher. |
|
|
164
166
|
|
|
@@ -181,8 +183,7 @@ Each runs as `npx @alterset/alterspec-client <command>`.
|
|
|
181
183
|
goes on. Check the clone's remote if it keeps happening.
|
|
182
184
|
- **An item reported as unknown**: an `Alterspec-Covers` line named something the checklist lacks. A pushed commit
|
|
183
185
|
can't be corrected; name the right item on a later commit.
|
|
184
|
-
- **`task-done` says the work isn't
|
|
185
|
-
carry its `Alterspec-Task` trailer, then run it again.
|
|
186
|
+
- **`task-done` says the work isn't pushed**: push the task's branch `task/<chg>-<track>`, then run it again.
|
|
186
187
|
|
|
187
188
|
## For the dispatcher: the `work.json` format
|
|
188
189
|
|
|
@@ -82,7 +82,8 @@ dispatcher's pages.
|
|
|
82
82
|
|
|
83
83
|
Work where the developer works: the client makes no branch or worktree for a task, and you make none unless the
|
|
84
84
|
developer asks (then `alterspec-client worktree <task>` makes the branch `task/<chg>-<track>` in a worktree of its own,
|
|
85
|
-
`--here` in this checkout
|
|
85
|
+
`--here` in this checkout, `--from <branch>` when the brief or `next_task` says the task starts from a done
|
|
86
|
+
predecessor's pushed branch). Every commit of the task ends with a trailer block, after a blank line:
|
|
86
87
|
|
|
87
88
|
```
|
|
88
89
|
Alterspec-Task: CHG-012/BE
|
|
@@ -99,4 +100,5 @@ Alterspec-Covers: CAP-CAT-001-AC-03, CAP-CAT-002
|
|
|
99
100
|
don't build it here, and name the criterion in `Alterspec-Covers` once your part's tests pass.
|
|
100
101
|
|
|
101
102
|
A hook reports the covered items to the dispatcher after each commit, by itself; when it asks, the developer runs
|
|
102
|
-
`alterspec-client progress`. The task is done when its work is
|
|
103
|
+
`alterspec-client progress`. The task is done when its work is pushed and the developer reports it (the commit and
|
|
104
|
+
its branch); the merge into the track's main branch comes after, and the dispatcher learns of it by itself.
|
|
@@ -10,19 +10,28 @@ export, and when the export is silent it is what gets recorded as the assumption
|
|
|
10
10
|
|
|
11
11
|
You edit nothing in the export. The answer comes from the export, never from this repository's code.
|
|
12
12
|
|
|
13
|
+
**The task the question concerns.** A question is recorded with its task whenever it has one, taken or not: the
|
|
14
|
+
task the developer names, else the one the work is about (the change and track you are building: the brief's, the
|
|
15
|
+
branch's `task/<chg>-<track>`, the last commit's `Alterspec-Task`, or the task in the export's `work.json` for the
|
|
16
|
+
change you are reading). It need not be assigned to anyone: a developer reading ahead of a blocked task asks about
|
|
17
|
+
that task. When it concerns one of the task's checklist items (`alterspec-client context <task>` lists them), name
|
|
18
|
+
the item too. Without one, a question about the product as a whole is asked without a task. Never make a task up:
|
|
19
|
+
`_shared.md` says how one is written.
|
|
20
|
+
|
|
13
21
|
1. Start as `_shared.md` says (`whoami`, then `export-head`, so the clone is current; keep its `send`). When the
|
|
14
22
|
dispatcher can't be reached or refuses the key, say so in one line and go on from the clone as it is.
|
|
15
|
-
2. Asked before?
|
|
16
|
-
|
|
23
|
+
2. Asked before? With a task, `alterspec-client questions <task>` (the brief's questions, on a task you hold);
|
|
24
|
+
else, when the question names IDs and the dispatcher keeps questions, `alterspec-client questions --about
|
|
25
|
+
<ID...>`. When one of them is this question and the product side
|
|
17
26
|
answered it, say that answer with its `Q-<n>` and stop: nothing is asked or recorded twice, and a product
|
|
18
27
|
person's answer the export doesn't hold yet stands over the export's silence. A failure here stops nothing.
|
|
19
|
-
3. Run `alterspec-client lookup --question "<the question, in full>"`, with `--task <task>` and `--item <item>`
|
|
20
|
-
|
|
21
|
-
export may be called silent, the neighbours and the views. When it says the
|
|
22
|
-
holds, put the question in the export's terms (the IDs of the task's brief,
|
|
23
|
-
once more.
|
|
28
|
+
3. Run `alterspec-client lookup --question "<the question, in full>"`, with `--task <task>` and `--item <item>`
|
|
29
|
+
whenever the question concerns one. It prints what the question is about, the shards to read first, the ones
|
|
30
|
+
that must be opened before the export may be called silent, the neighbours and the views. When it says the
|
|
31
|
+
question names nothing the export holds, put the question in the export's terms (the IDs of the task's brief,
|
|
32
|
+
the glossary's words) and run it once more.
|
|
24
33
|
4. Hand the `alterspec-spec-answerer` subagent the question in full, the export's path (`.alterspec-client.json`
|
|
25
|
-
names it), the lookup's output as it is and,
|
|
34
|
+
names it), the lookup's output as it is and, with a task, the task and the checklist item. Don't answer it
|
|
26
35
|
yourself and don't tell the answerer what you expect: it reads the export only, and you have read the code.
|
|
27
36
|
5. When it returns `assumed` or `open`, run the same `lookup` with `--unread <everything on its Looked list>`.
|
|
28
37
|
What that prints was not opened: send the answerer back once with those paths, and take what it returns then.
|
|
@@ -31,12 +40,12 @@ You edit nothing in the export. The answer comes from the export, never from thi
|
|
|
31
40
|
7. An answer from the spec is not sent to the dispatcher: nothing was decided, so there is nothing for the product
|
|
32
41
|
side to read. Record it with `ask` only when the outcome is `assumed` or `open`, and when the dispatcher lists
|
|
33
42
|
that tool: `question`, `outcome`, `cites` (what the question concerns, what the assumption extends),
|
|
34
|
-
`assumption` (for `assumed`), `export` (the commit from step 1) and,
|
|
35
|
-
the answerer's and yours, naming IDs: no code and no copied spec text. Keep the `Q-<n>` it returns. Without the
|
|
43
|
+
`assumption` (for `assumed`), `export` (the commit from step 1) and, with a task, `task` and `item`. The words
|
|
44
|
+
are the answerer's and yours, naming IDs: no code and no copied spec text. Keep the `Q-<n>` it returns. Without the
|
|
36
45
|
tool, or when the call fails, go on and say the question was not recorded.
|
|
37
46
|
8. Say the result, by outcome:
|
|
38
47
|
- `spec`: the answer in the export's business terms with the IDs it rests on. Work on.
|
|
39
48
|
- `assumed`: "Assumed, not decided (Q-<n>):" and the assumption, what it extends and what changes if the product
|
|
40
|
-
side corrects it. On a task, work on with it, as `_shared.md` says.
|
|
41
|
-
- `open`: what is undecided and that it waits for the product side (Q-<n>). On a task, leave that item
|
|
42
|
-
the others. Never fill it in.
|
|
49
|
+
side corrects it. On a task you hold, work on with it, as `_shared.md` says.
|
|
50
|
+
- `open`: what is undecided and that it waits for the product side (Q-<n>). On a task you hold, leave that item
|
|
51
|
+
and work the others. Never fill it in.
|
|
@@ -7,7 +7,10 @@ there are several, the one whose branch this checkout is on (`git branch --show-
|
|
|
7
7
|
or whose `Alterspec-Task` trailer the last commit carries; when that doesn't settle it, ask which.
|
|
8
8
|
|
|
9
9
|
1. Start as `_shared.md` says (`whoami`, `export-head`).
|
|
10
|
-
2. Run `alterspec-client context <task>` and read the brief. When
|
|
10
|
+
2. Run `alterspec-client context <task>` and read the brief. When it says "Start from `task/…`", a done predecessor
|
|
11
|
+
of this track is pushed there and not in the main branch yet: the task's branch is based on that branch, not on
|
|
12
|
+
main (`alterspec-client worktree <task> --from <branch>` when a branch or worktree is made); say so in one line.
|
|
13
|
+
When the change has questions it opens with them, on
|
|
11
14
|
every track (each names the task it was asked on): say in one line each one the product side answered since, and
|
|
12
15
|
take up a corrected assumption first. When the dispatcher says this change carries answers this track built
|
|
13
16
|
already ("Built already"), the task is a check, not a build: read each checklist item against the code, add the
|
|
@@ -8,9 +8,12 @@ Without a task, ask for it; never guess it.
|
|
|
8
8
|
1. Start as `_shared.md` says (`whoami`, `export-head`).
|
|
9
9
|
2. Run `alterspec-client progress <task>`, so the dispatcher has the last covered items. Say its lines as they are
|
|
10
10
|
(an item the task lacks is one of them); a failure here doesn't stop what follows.
|
|
11
|
-
3. Run `alterspec-client merged <task
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
3. Run `alterspec-client merged <task> --json`. It prints `{ "commit", "branch" }`: the head of the pushed task
|
|
12
|
+
branch `task/<chg>-<track>` with that branch, or, when the task was merged into the main branch already, the
|
|
13
|
+
commit that brought it in and no `branch`. It fails when the branch isn't pushed and nothing is merged: then say
|
|
14
|
+
so (push the branch `task/<chg>-<track>` first) and stop. Never report a task done whose work isn't pushed. The
|
|
15
|
+
merge into the main branch is not waited for: the dispatcher learns of it from the repository's pushes, and the
|
|
16
|
+
tasks after this one start from the branch.
|
|
14
17
|
4. If this conversation built the task: a choice about the product's behaviour you made for it that has no `Q-<n>`
|
|
15
18
|
yet is asked now with `/alterspec-spec-ask`, so the product side has it before the task is reported.
|
|
16
19
|
Then, if no `feedback` was sent for it yet, send it now, as `_shared.md` says (skip
|
|
@@ -18,5 +21,7 @@ Without a task, ask for it; never guess it.
|
|
|
18
21
|
5. Run `alterspec-client questions <task> --open`, when the dispatcher keeps questions (a failure here doesn't
|
|
19
22
|
stop what follows). Say each open one in a line: work standing on an assumption may still be corrected, and an
|
|
20
23
|
item that waited for an answer is not built. The developer typed the command, so go on.
|
|
21
|
-
6. Call `done` with the task and that commit
|
|
22
|
-
|
|
24
|
+
6. Call `done` with the task, that `commit` and, when `merged` printed one, that `branch` (`{ id, commit, branch }`;
|
|
25
|
+
leave `branch` out when there is none).
|
|
26
|
+
7. Say the result in one line: done, at which commit, on which branch, and that the tasks waiting for it may start
|
|
27
|
+
from that branch. `NOT_IN_BRANCH`, `NOT_YOURS`, `NOT_IN_PROGRESS`: say the dispatcher's sentence.
|
|
@@ -10,11 +10,16 @@ the developer wants in progress at once (default 1).
|
|
|
10
10
|
the dispatcher offers every track the developer may take.
|
|
11
11
|
3. Call `next_task` with `export` = `send` from `export-head`, `tracks` and `parallel`.
|
|
12
12
|
4. Say each `reasons` entry in one line (none available, blocked by what, at the limit, more after pulling).
|
|
13
|
-
5.
|
|
13
|
+
5. Each assigned task's `after` lists the done tasks it waited for, each with its `commit` and `branch`. When an
|
|
14
|
+
entry of the same track names a `branch` (not null), that predecessor's work is pushed there and not in the main
|
|
15
|
+
branch yet: say in one line which branch to start from, e.g. "CHG-013/BE starts from `task/chg-012-be`, where
|
|
16
|
+
CHG-012/BE was done; not from main", and, whenever a branch or worktree is made for the task, pass it:
|
|
17
|
+
`alterspec-client worktree <task> --from <branch>`. A null `branch` means the main branch, as usual.
|
|
18
|
+
6. The tasks it assigned:
|
|
14
19
|
- **One**: continue with `.alterspec-client/prompts/task-context.md` for that task, here, on whatever branch the
|
|
15
|
-
developer is on.
|
|
16
|
-
- **Several**: list each task with its title
|
|
17
|
-
on it. Work on none of them in this session.
|
|
20
|
+
developer is on (when it starts from a predecessor's branch, say so before any commit is made).
|
|
21
|
+
- **Several**: list each task with its title and, when it has one, the branch it starts from, and say: type
|
|
22
|
+
`/alterspec-task-context <task>` where you want to work on it. Work on none of them in this session.
|
|
18
23
|
- **None**: say so, with the reasons. Stop.
|
|
19
24
|
|
|
20
25
|
Taking a task assigns it, nothing more: never create a branch or a worktree, switch branches or stash anything. Where
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: alterspec-task-done
|
|
3
|
-
description: "Report a task done once its work is
|
|
3
|
+
description: "Report a task done once its work is pushed: the commit and the branch it is on. Only when the developer types it with the task."
|
|
4
4
|
argument-hint: "<CHG-NNN/TRACK>"
|
|
5
5
|
disable-model-invocation: true
|
|
6
6
|
allowed-tools: Read Bash(npx @alterset/alterspec-client *) Bash(git *) mcp__dispatcher__*
|
package/developer-guide.md
CHANGED
|
@@ -30,7 +30,9 @@ You connect to it with the **alterspec client** (`@alterset/alterspec-client`, p
|
|
|
30
30
|
when nobody may assume it (that checklist item waits, the others go on). An answer from the spec stays with you;
|
|
31
31
|
the dispatcher keeps the assumptions and the open questions, a product person answers them, and the answer is in the task's brief the next time Claude reads it.
|
|
32
32
|
- When you take a task it is yours until you report it **done** or **release** it; nobody else can.
|
|
33
|
-
- A task is **done** when its work is
|
|
33
|
+
- A task is **done** when its work is pushed and you report it: the commit and the branch it is on. The merge into
|
|
34
|
+
the track's main branch comes after; the dispatcher learns of it from the repository's pushes, and the tasks
|
|
35
|
+
waiting for yours start from your branch in the meantime.
|
|
34
36
|
|
|
35
37
|
## Before you start
|
|
36
38
|
|
|
@@ -177,7 +179,7 @@ server. Then talk to it in plain words; the skills do the rest.
|
|
|
177
179
|
| "let's work on my task" / `/alterspec-task-context` | the task's brief from the spec: why, the checklist, the one-time data change if any, the objects it changes (before and after) and where the export uses them, the changed acceptance criteria, the rules, events, decisions and glossary terms they and the change name (the rest, and the entities, as paths); for a UI track also the screens, their contracts, mockups and design system |
|
|
178
180
|
| "what am I on?" / `/alterspec-task-status` | your tasks with progress and ETA, what's available on your tracks, what is blocked and by what |
|
|
179
181
|
| "what does RULE-… say?" / `/alterspec-spec-ask` | answers about the product from the spec, citing IDs; what the spec doesn't say is recorded as an assumption or an open question for the product side; Claude uses it by itself when a task's spec is undecided |
|
|
180
|
-
| `/alterspec-task-done CHG-023/BE` | after your branch is
|
|
182
|
+
| `/alterspec-task-done CHG-023/BE` | after your branch is pushed: reports the task done with its head commit and the branch (or, once merged, the commit on the main branch); refused while nothing is pushed |
|
|
181
183
|
| `/alterspec-task-release CHG-023/BE <reason>` | gives the task back so someone else can take it; your code and branches stay as they are |
|
|
182
184
|
| `/alterspec-task-eta CHG-023/BE <YYYY-MM-DD> <reason>` | sets your own date when the computed ETA is wrong; `clear` instead of the date removes it |
|
|
183
185
|
|
|
@@ -200,15 +202,21 @@ server. Then talk to it in plain words; the skills do the rest.
|
|
|
200
202
|
`Alterspec-Covers` names the checklist items whose tests pass with that commit, never items that aren't tested yet.
|
|
201
203
|
After each commit a hook reports them in the background, and the task's progress on the dashboard moves.
|
|
202
204
|
|
|
203
|
-
4. Push your branch
|
|
204
|
-
|
|
205
|
+
4. Push your branch and type `/alterspec-task-done CHG-023/BE`: the task is done at that commit on that branch, and
|
|
206
|
+
the tasks waiting for it may start from it. Open the pull request into the main branch as usual; the dispatcher
|
|
207
|
+
notices the merge by itself.
|
|
208
|
+
|
|
209
|
+
When the brief says "Start from `task/chg-012-be`", a task yours waited for was done on that branch and isn't merged
|
|
210
|
+
yet: base your branch on it, not on main (`npx @alterset/alterspec-client worktree CHG-023/BE --from task/chg-012-be`
|
|
211
|
+
when the client makes the branch). The teams merge a change's branches together once every track is done.
|
|
205
212
|
|
|
206
213
|
### Several tasks at once
|
|
207
214
|
|
|
208
215
|
Ask for more than one: `/alterspec-task-next BE 2`. Claude lists them and works on none; type
|
|
209
216
|
`/alterspec-task-context <task>` wherever you work on each, e.g. a session per worktree. If you want the client to
|
|
210
217
|
make a worktree for a task, run `npx @alterset/alterspec-client worktree CHG-023/BE`: it creates the branch
|
|
211
|
-
`task/chg-023-be` from `origin/<branch>`
|
|
218
|
+
`task/chg-023-be` from `origin/<branch>` (or from the predecessor's branch with `--from`) in `../<code-repo>-tasks/`
|
|
219
|
+
(the `--worktrees` folder of `init`). The
|
|
212
220
|
dispatcher never gives you two tasks on the same track that change the same objects, so they don't conflict.
|
|
213
221
|
|
|
214
222
|
### Questions about the spec
|
|
@@ -229,6 +237,11 @@ either the spec already says, or the choice is recorded at once as an assumption
|
|
|
229
237
|
hour. Nothing about the product is decided silently and found out at the end of the task. How the code is built is
|
|
230
238
|
yours and is never asked.
|
|
231
239
|
|
|
240
|
+
A question is recorded with the task it concerns, and the checklist item when it concerns one, whether or not the
|
|
241
|
+
task is yours yet: ask about `CHG-028/BE` while it waits behind another task and it lands on that task's page and in
|
|
242
|
+
its next holder's brief, not among the questions about no task. Name the task, or Claude takes the one the work is
|
|
243
|
+
about.
|
|
244
|
+
|
|
232
245
|
How an answer is found: the client first looks whether the question was asked before, then computes where the spec
|
|
233
246
|
would answer it (`lookup`: what the question names, by ID, by the glossary's words and their synonyms, by title; the
|
|
234
247
|
sections to read first; the rules, decisions and "out of scope" lines about it) and gives that reading list to the
|
|
@@ -276,6 +289,6 @@ recorded: then an open question is yours to carry, as before.
|
|
|
276
289
|
| "No .alterspec-client.json here" | run `init` in this repository (step 4) |
|
|
277
290
|
| "The export is N commits behind the dispatcher" | your export clone couldn't be pulled: `git -C ../<product>-export pull`, and check its remote if it keeps happening |
|
|
278
291
|
| an item reported as unknown | a commit's `Alterspec-Covers` named something the checklist lacks. A pushed commit can't be corrected; name the right item on a later commit |
|
|
279
|
-
| `task-done` refused: not
|
|
292
|
+
| `task-done` refused: not pushed | push the task's branch `task/<chg>-<track>` first, then run it again |
|
|
280
293
|
| a worktree link "points nowhere", or `worktree` refuses | a symlink in your repository doesn't resolve from the task worktree; the message says which and what to do. Update the client to 0.4.4 or later first |
|
|
281
294
|
| anything else | send your admin the message exactly as it appears |
|
package/dist/cli.js
CHANGED
|
@@ -1078,6 +1078,16 @@ function answersSection(answers) {
|
|
|
1078
1078
|
// src/context.ts
|
|
1079
1079
|
var ContextError = class extends Error {
|
|
1080
1080
|
};
|
|
1081
|
+
function startFrom(track, after) {
|
|
1082
|
+
if (!Array.isArray(after)) return [];
|
|
1083
|
+
const out = [];
|
|
1084
|
+
for (const a of after) {
|
|
1085
|
+
if (typeof a?.id !== "string" || typeof a.branch !== "string" || !a.branch) continue;
|
|
1086
|
+
if (a.id.split("/")[1] !== track) continue;
|
|
1087
|
+
out.push({ id: a.id, branch: a.branch, ...typeof a.commit === "string" ? { commit: a.commit } : {} });
|
|
1088
|
+
}
|
|
1089
|
+
return out;
|
|
1090
|
+
}
|
|
1081
1091
|
var shardText = (x, path) => path ? x.read(path)?.replace(/^<!-- source: [^\n]*-->\n\n/, "").trim() : void 0;
|
|
1082
1092
|
var sectionText = (x, path) => shardText(x, path)?.replace(/^## [^\n]*\n*/, "");
|
|
1083
1093
|
var screenOf = (key) => /^UX-(SCR-[A-Z]{2,6}-\d{2})-[A-Z]{2,5}$/.exec(key)?.[1] ?? /^file:experience\/[a-z]{2,5}\/mockups\/(SCR-[A-Z]{2,6}-\d{2})\.html$/.exec(key)?.[1] ?? (/^SCR-[A-Z]{2,6}-\d{2}$/.test(key) ? key : void 0);
|
|
@@ -1318,6 +1328,7 @@ function taskContext(x, task, exportDir2, state = {}, questions) {
|
|
|
1318
1328
|
},
|
|
1319
1329
|
track,
|
|
1320
1330
|
after: work.after,
|
|
1331
|
+
...state.startFrom?.length ? { startFrom: state.startFrom } : {},
|
|
1321
1332
|
proposal: {
|
|
1322
1333
|
path: proposal,
|
|
1323
1334
|
why: sectionText(x, x.sectionShard(proposal, "Why")),
|
|
@@ -1456,6 +1467,11 @@ function renderContext(c) {
|
|
|
1456
1467
|
`Track ${c.track.code} (${c.track.kind}${c.track.channels.length ? `: ${c.track.channels.join(", ")}` : ""}). Change ${c.change.id}, signed off ${c.change.signed_off}, level ${c.change.level}. Paths are relative to the export, ${c.export}.`
|
|
1457
1468
|
];
|
|
1458
1469
|
if (c.after.length) out.push("", `Waits for: ${c.after.map((a) => `${a.change}/${a.track}`).join(", ")}.`);
|
|
1470
|
+
if (c.startFrom?.length)
|
|
1471
|
+
out.push(
|
|
1472
|
+
"",
|
|
1473
|
+
`Start from ${c.startFrom.map((s) => `\`${s.branch}\` (${s.id}${s.commit ? ` done at ${s.commit.slice(0, 12)}` : ""})`).join(", then ")}, not from the main branch: the predecessor's work is pushed there and not merged yet (\`alterspec-client worktree ${c.task} --from ${c.startFrom[c.startFrom.length - 1].branch}\`).`
|
|
1474
|
+
);
|
|
1459
1475
|
out.push("");
|
|
1460
1476
|
if (c.questions?.length) out.push(...questionsSection(c.questions));
|
|
1461
1477
|
if (c.answers?.length) out.push(...answersSection(c.answers));
|
|
@@ -1675,29 +1691,33 @@ function mainBranch(repo, configured) {
|
|
|
1675
1691
|
var branchExists = (repo, branch) => tryGit(repo, ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`]) !== void 0;
|
|
1676
1692
|
function taskWorktree(repo, task, opts) {
|
|
1677
1693
|
const branch = branchOf(task);
|
|
1678
|
-
|
|
1679
|
-
|
|
1694
|
+
const from = opts.from?.replace(/^origin\//, "") || opts.main;
|
|
1695
|
+
if (tryGit(repo, ["fetch", "--quiet", "origin", from]) === void 0 && from !== opts.main)
|
|
1696
|
+
throw new GitError(`origin has no branch ${from}: was the predecessor's branch pushed?`);
|
|
1697
|
+
const base = `origin/${from}`;
|
|
1698
|
+
if (!tryGit(repo, ["rev-parse", "--verify", "--quiet", base]))
|
|
1699
|
+
throw new GitError(`There is no ${base} here: is "${from}" a branch of origin?`);
|
|
1680
1700
|
if (opts.here) {
|
|
1681
1701
|
const top2 = git2(repo, ["rev-parse", "--show-toplevel"]);
|
|
1682
1702
|
if (tryGit(repo, ["symbolic-ref", "--short", "HEAD"]) === branch)
|
|
1683
|
-
return { path: top2, branch, created: false };
|
|
1703
|
+
return { path: top2, branch, created: false, base };
|
|
1684
1704
|
if (git2(repo, ["status", "--porcelain", "--untracked-files=no"]))
|
|
1685
1705
|
throw new GitError(
|
|
1686
1706
|
`This checkout has uncommitted work: commit or stash it before switching to ${branch}.`
|
|
1687
1707
|
);
|
|
1688
1708
|
if (branchExists(repo, branch)) {
|
|
1689
1709
|
git2(repo, ["switch", "--quiet", branch]);
|
|
1690
|
-
return { path: top2, branch, created: false };
|
|
1710
|
+
return { path: top2, branch, created: false, base };
|
|
1691
1711
|
}
|
|
1692
1712
|
git2(repo, ["switch", "--quiet", "--no-track", "-c", branch, base]);
|
|
1693
|
-
return { path: top2, branch, created: true };
|
|
1713
|
+
return { path: top2, branch, created: true, base };
|
|
1694
1714
|
}
|
|
1695
1715
|
const path = resolve2(opts.worktreesDir, folderOf(task));
|
|
1696
1716
|
const listed = git2(repo, ["worktree", "list", "--porcelain"]).split("\n").filter((l) => l.startsWith("worktree ")).map((l) => real(l.slice("worktree ".length)));
|
|
1697
1717
|
const top = git2(repo, ["rev-parse", "--show-toplevel"]);
|
|
1698
1718
|
if (listed.includes(real(path))) {
|
|
1699
1719
|
const bridges = bridgeTrackedLinks(top, path);
|
|
1700
|
-
return { path, branch, created: false, bridges, dangling: danglingLinks(path) };
|
|
1720
|
+
return { path, branch, created: false, base, bridges, dangling: danglingLinks(path) };
|
|
1701
1721
|
}
|
|
1702
1722
|
if (branchExists(repo, branch)) git2(repo, ["worktree", "add", "--quiet", path, branch]);
|
|
1703
1723
|
else git2(repo, ["worktree", "add", "--quiet", "--no-track", "-b", branch, path, base]);
|
|
@@ -1705,6 +1725,7 @@ function taskWorktree(repo, task, opts) {
|
|
|
1705
1725
|
path,
|
|
1706
1726
|
branch,
|
|
1707
1727
|
created: true,
|
|
1728
|
+
base,
|
|
1708
1729
|
links: mirrorIgnoredLinks(top, path),
|
|
1709
1730
|
bridges: bridgeTrackedLinks(top, path),
|
|
1710
1731
|
dangling: danglingLinks(path)
|
|
@@ -1769,10 +1790,19 @@ var present = (path) => {
|
|
|
1769
1790
|
var real = (path) => existsSync4(path) ? realpathSync(path) : resolve2(path);
|
|
1770
1791
|
var escape = (s) => s.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
1771
1792
|
function mergedCommit(repo, task, main) {
|
|
1793
|
+
const branch = branchOf(task);
|
|
1772
1794
|
tryGit(repo, ["fetch", "--quiet", "origin", main]);
|
|
1795
|
+
tryGit(repo, ["fetch", "--quiet", "origin", branch]);
|
|
1773
1796
|
const target = `origin/${main}`;
|
|
1774
1797
|
if (!tryGit(repo, ["rev-parse", "--verify", "--quiet", target]))
|
|
1775
1798
|
throw new GitError(`There is no ${target} here: is "${main}" the track's main branch?`);
|
|
1799
|
+
const pushed = tryGit(repo, ["rev-parse", "--verify", "--quiet", `origin/${branch}^{commit}`]);
|
|
1800
|
+
if (pushed && !isAncestor(repo, pushed, target)) return { commit: pushed, branch };
|
|
1801
|
+
const merged = mergedInto(repo, task, target);
|
|
1802
|
+
if (merged) return { commit: merged };
|
|
1803
|
+
return pushed ? { commit: pushed, branch } : void 0;
|
|
1804
|
+
}
|
|
1805
|
+
function mergedInto(repo, task, target) {
|
|
1776
1806
|
const trailer = new RegExp(`^${TRAILER}:\\s*${escape(task.id)}\\s*$`, "mi");
|
|
1777
1807
|
const branch = new RegExp(`(^|[\\s'"/:])${escape(branchOf(task))}($|[\\s'".,)])`, "m");
|
|
1778
1808
|
const log = git2(repo, ["log", "--first-parent", "--format=%H%x1f%P%x1f%B%x1e", target]);
|
|
@@ -2502,9 +2532,11 @@ async function coveredState(loaded, task) {
|
|
|
2502
2532
|
const answer = await callTool(sessionOf(loaded), "task", { id: task.id });
|
|
2503
2533
|
const items = answer.items ?? [];
|
|
2504
2534
|
const answers = parseAnswers(answer.answers);
|
|
2535
|
+
const from = startFrom(task.track, answer.after);
|
|
2505
2536
|
return {
|
|
2506
2537
|
covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : [])),
|
|
2507
|
-
...answers ? { answers } : {}
|
|
2538
|
+
...answers ? { answers } : {},
|
|
2539
|
+
...from.length ? { startFrom: from } : {}
|
|
2508
2540
|
};
|
|
2509
2541
|
} catch (e) {
|
|
2510
2542
|
return { unknown: e.message.split("\n")[0] };
|
|
@@ -2636,14 +2668,25 @@ program.command("progress").description("report the items the task\u2019s commit
|
|
|
2636
2668
|
process.stdout.write(opts.json ? JSON.stringify(report, null, 2) + "\n" : progressText(report));
|
|
2637
2669
|
})();
|
|
2638
2670
|
});
|
|
2639
|
-
program.command("worktree").description(
|
|
2671
|
+
program.command("worktree").description(
|
|
2672
|
+
"create the task\u2019s branch task/<chg>-<track> from origin/<main>, or from the predecessor\u2019s branch, in a worktree of its own"
|
|
2673
|
+
).argument("<task>", "the task, e.g. CHG-012/BE").option("--here", "make the branch in this checkout instead of a worktree").option(
|
|
2674
|
+
"--from <branch>",
|
|
2675
|
+
"the branch to start from: the one next_task named on a done predecessor of the same track (fetched as origin/<branch>)"
|
|
2676
|
+
).action(
|
|
2640
2677
|
run((id, opts) => {
|
|
2641
2678
|
const loaded = loadConfig();
|
|
2642
2679
|
const wt = taskWorktree(process.cwd(), parseTask(id), {
|
|
2643
2680
|
main: mainBranch(process.cwd(), loaded.config.branch),
|
|
2644
2681
|
worktreesDir: worktreesDir(loaded),
|
|
2645
|
-
here: opts.here
|
|
2682
|
+
here: opts.here,
|
|
2683
|
+
from: opts.from
|
|
2646
2684
|
});
|
|
2685
|
+
process.stderr.write(
|
|
2686
|
+
wt.created ? `Created ${wt.branch} from ${wt.base}.
|
|
2687
|
+
` : `${wt.branch} exists already; it was not rebased on ${wt.base}.
|
|
2688
|
+
`
|
|
2689
|
+
);
|
|
2647
2690
|
if (wt.dangling?.length)
|
|
2648
2691
|
process.stderr.write(
|
|
2649
2692
|
`In ${wt.path}, ${wt.dangling.join(", ")} ${wt.dangling.length === 1 ? "points" : "point"} nowhere. A symlink git tracks is checked out as it is, so a relative target made for the checkout doesn't resolve from the worktree: keep such links out of git (ignored, not committed) and the client links them into each worktree, or fix them there.
|
|
@@ -2699,17 +2742,23 @@ program.command("questions").description("print the questions the dispatcher kee
|
|
|
2699
2742
|
process.stdout.write(opts.json ? JSON.stringify(questions, null, 2) + "\n" : questionsText(questions));
|
|
2700
2743
|
})
|
|
2701
2744
|
);
|
|
2702
|
-
program.command("merged").description(
|
|
2703
|
-
|
|
2745
|
+
program.command("merged").description(
|
|
2746
|
+
"print the commit and branch to report done with: the pushed task branch\u2019s head, or the commit on origin/<main> that brought the task in"
|
|
2747
|
+
).argument("<task>", "the task, e.g. CHG-012/BE").option("--json", "print { commit, branch } as JSON").action(
|
|
2748
|
+
run((id, opts) => {
|
|
2704
2749
|
const loaded = loadConfig();
|
|
2705
2750
|
const main = mainBranch(process.cwd(), loaded.config.branch);
|
|
2706
2751
|
const task = parseTask(id);
|
|
2707
|
-
const
|
|
2708
|
-
if (!
|
|
2752
|
+
const found = mergedCommit(process.cwd(), task, main);
|
|
2753
|
+
if (!found)
|
|
2709
2754
|
throw new Error(
|
|
2710
|
-
`${task.id} is not
|
|
2755
|
+
`${task.id} is not pushed yet: push its branch ${branchOf(task)} (or merge it into ${main} with the trailer "Alterspec-Task: ${task.id}" on a commit), then run this again.`
|
|
2711
2756
|
);
|
|
2712
|
-
process.stdout.write(
|
|
2757
|
+
process.stdout.write(
|
|
2758
|
+
opts.json ? JSON.stringify(found) + "\n" : found.branch ? `${found.commit} on ${found.branch} (pushed, not in ${main} yet)
|
|
2759
|
+
` : `${found.commit} on ${main} (merged)
|
|
2760
|
+
`
|
|
2761
|
+
);
|
|
2713
2762
|
})
|
|
2714
2763
|
);
|
|
2715
2764
|
await program.parseAsync();
|