@alterset/alterspec-client 0.12.1 → 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 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. **Merge, then report done.** Once the task's work is on the track's main branch on the remote, type
130
- `/alterspec-task-done CHG-012/BE`. It sends the last progress, finds the commit that brought the task in, and
131
- reports it done. It refuses while the work is not merged.
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]` | Create the branch `task/<chg>-<track>` from `origin/<main>` 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. |
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>` | Print the commit on `origin/<main>` that brought the task in. |
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 merged**: merge the task's branch into the main branch, or push the commits that
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). Every commit of the task ends with a trailer block, after a blank line:
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 in the track's main branch.
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.
@@ -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 the change has questions it opens with them, on
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>`. It prints the commit on the track's main branch that brought the task in,
12
- or fails when the work isn't there yet: then say so (merge the task's branch, or push the commits carrying the
13
- trailer, first) and stop. Never report a task done whose work isn't on the main branch.
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
- 7. Say the result in one line. `NOT_IN_BRANCH`, `NOT_YOURS`, `NOT_IN_PROGRESS`: say the dispatcher's sentence.
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. The tasks it assigned:
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, and say: type `/alterspec-task-context <task>` where you want to work
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 in the track's main branch. Only when the developer types it with the task."
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__*
@@ -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 merged into the track's main branch on the remote.
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 merged: reports the task done with the commit that brought it in; refused while the work isn't merged |
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, open a pull request into the main branch as usual, get it reviewed and merged.
204
- 5. Type `/alterspec-task-done CHG-023/BE`.
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>` in `../<code-repo>-tasks/` (the `--worktrees` folder of `init`). The
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
@@ -281,6 +289,6 @@ recorded: then an open question is yours to carry, as before.
281
289
  | "No .alterspec-client.json here" | run `init` in this repository (step 4) |
282
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 |
283
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 |
284
- | `task-done` refused: not merged | merge the pull request into the main branch first, then run it again |
292
+ | `task-done` refused: not pushed | push the task's branch `task/<chg>-<track>` first, then run it again |
285
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 |
286
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
- tryGit(repo, ["fetch", "--quiet", "origin", opts.main]);
1679
- const base = `origin/${opts.main}`;
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("create the task\u2019s branch task/<chg>-<track> from origin/<main>, in a worktree of its own").argument("<task>", "the task, e.g. CHG-012/BE").option("--here", "make the branch in this checkout instead of a worktree").action(
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("print the commit on origin/<main> that brought the task in").argument("<task>", "the task, e.g. CHG-012/BE").action(
2703
- run((id) => {
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 sha = mergedCommit(process.cwd(), task, main);
2708
- if (!sha)
2752
+ const found = mergedCommit(process.cwd(), task, main);
2753
+ if (!found)
2709
2754
  throw new Error(
2710
- `${task.id} is not on origin/${main} yet: merge its branch, or commit with the trailer "Alterspec-Task: ${task.id}", and push.`
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(sha + "\n");
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();