@alterset/alterspec-client 0.25.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31,7 +31,27 @@ dispatcher's pages.
31
31
  - **A task is built to what its change saw.** The brief (`alterspec-client context <task>`) gives every object as
32
32
  the task's change saw it at its sign-off, however many changes touched it since; the export's own files are the
33
33
  spec as it is now. What later changes did is listed at the brief's end as their tasks' work: never build it in
34
- this task, and never ask a question of this task about a sentence a later change wrote.
34
+ this task, and never ask a question of this task about a sentence a later change wrote. Where a later change
35
+ removed or reworded a line of your task's own hunks, the brief says so under "Checked", from the deltas: you
36
+ compare nothing.
37
+ - **A claim about the code is checked, never trusted.** Three things in a brief say what the code already does: an
38
+ item marked `w 0, nothing to build on this track`, a task summary that opens with "Nothing to build" (a weight
39
+ reasoned "as built"), and the "Built already" section. None of them was read from the code: the first two are the
40
+ sign-off's judgement, the third is computed from dates (the asking task was done after the answer). On one
41
+ product they were wrong, in both directions, on fifteen tasks of sixty-four. So before you skip or cover such an
42
+ item, read the code against the item's text and write or run its test. When the code has the behaviour, the
43
+ test stays and the item is covered like any other (a `w 0` item is never named in `Alterspec-Covers`, it
44
+ carries no weight, but its test still proves it). When the code lacks it and the item is your track's, build it,
45
+ say in the commit's body that the brief called it built, and put one line in `unclear`. A `w 0` item whose text
46
+ names only another channel is that track's behaviour: read it and build nothing. When you can't tell which it
47
+ is, ask with `/alterspec-spec-ask`.
48
+ - **News is read at the boundaries, never in the middle of an item.** Answers to your questions, the later changes
49
+ under "Changed since", `followed_by` and `overlaps` are read when a skill starts (`context`, `task`), before each
50
+ commit (`alterspec-client context <task> --checklist`: this task's questions with their answers and its
51
+ checklist, nothing else) and in `/alterspec-task-done`. Between those
52
+ points you build: don't re-read the brief or the export to see whether something moved, and don't call `whoami`
53
+ for it. What `followed_by` and `overlaps` name is said once, at the start, and left. A corrected assumption found
54
+ at a boundary is rework before the next item.
35
55
  - **The CLI does the deterministic work**: which commit to send, the task's brief and checklist, the items its commits cover, the commit that brought it in. Never work these out yourself.
36
56
  - **Feedback is how the spec gets better, and it never restates a question.** Once per task, when its checklist
37
57
  is covered, call `feedback` with three short lists. What you asked is on the task already, with its answer: the
@@ -39,13 +59,23 @@ dispatcher's pages.
39
59
  hand.
40
60
  - `unclear`: what in the spec cost you work and was **not** a question, each line naming the spec IDs it is
41
61
  about (a sentence that took three readings, a term used for two things, a fact that sat far from where it was
42
- needed). Never a question that was asked: no `Q-<n>` on these lines and no question said again. A task whose
43
- every difficulty was asked sends an empty `unclear`.
62
+ needed, a brief that called built what the code didn't hold). Never a question that was asked:
63
+ no `Q-<n>` on these lines and no question said again. A task whose every difficulty was asked sends an empty
64
+ `unclear`.
44
65
  - `decided`: one line per assumption you built on, and the line is its `Q-<n>` and nothing more: no object ID
45
- and no retelling, so the line closes with its question. A decision without a `Q-<n>` was taken silently: ask
46
- it now, before the feedback, and send the number you get.
66
+ and no retelling, so the line closes with its question. Never prose: a decision without a `Q-<n>` was taken
67
+ silently; ask it now, before the feedback, and send the number you get.
47
68
  - `opened`: what you had to read beyond the brief, and why, naming the IDs. It is read by whoever builds the
48
69
  brief, as a count of how often each ID was opened, not by the product side: name the object, not a complaint.
70
+ Never a finding (what you found goes to `unclear`), never a file the brief itself gave you.
71
+
72
+ Three lines as they should read:
73
+
74
+ ```
75
+ unclear: RULE-NTF-007, CAP-NTF-001-AC-04, CAP-NTF-001-AC-17: the 60th day falls on a different side in each.
76
+ opened: _generated/rule-matrix.md, the row of RULE-058: which capabilities trigger it; the brief gave the rule, not its reach.
77
+ decided: Q-198
78
+ ```
49
79
 
50
80
  No code and no copied spec text; empty lists are fine, an invented complaint is not. Skip it when the dispatcher
51
81
  has no `feedback` tool.
@@ -16,9 +16,11 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
16
16
  When the change has questions it opens with them, on
17
17
  every track (each names the task it was asked on): say in one line each one the product side answered since, and
18
18
  take up a corrected assumption first. When the dispatcher says this change carries answers this track built
19
- already ("Built already"), the task is a check, not a build: read each checklist item against the code, add the
20
- tests that are missing, cover each item as its tests pass, and rebuild nothing; build only what stands on a
21
- question not built here. Then the task's checklist: its items, what
19
+ already ("Built already"), the mark comes from dates (the asking task was done after the answer), not from the
20
+ code: read each checklist item against the code first; where the code says what the spec now says, add the test
21
+ that is missing and cover the item as it passes; where it doesn't, build it, whatever the mark said, and say so
22
+ in the commit's body (`_shared.md`, "A claim about the code is checked"). The same reading settles the answers
23
+ the brief marks as not built here: the code may hold them already. Then the task's checklist: its items, what
22
24
  each is and which the dispatcher holds covered already; that is the work, and its progress. Then why the change
23
25
  was made, what changed, the one-time data change when the proposal declares one (what the release does once to the
24
26
  records the product already holds; on the backend it is the `CHG-NNN#data-change` item), the delta of each of the
@@ -35,10 +37,10 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
35
37
  with its task on this track, and what each touched. Every text and path the brief gives for such an object is
36
38
  the object as this change saw it (an absolute path under `.alterspec-client/pins/` is that pinned copy; the
37
39
  export's own file carries the later changes too). Build to the brief. What a later change added is built in
38
- that change's task, never here; say the later tasks in one line and leave them. One exception: before you build
39
- one of this task's own objects that is listed there, compare the file the brief gives with the export's, and
40
- don't build a line a later change removed or reversed: build that item as the later change says and say so in
41
- the commit's body. What is marked **new** moved since you last read the brief; its diff is shown once.
40
+ that change's task, never here; say the later tasks in one line and leave them. One exception, and the brief does the
41
+ checking: under "Checked" it says, for each object this task changes, whether a later change removed or
42
+ reworded a line of this task's hunks. When it names lines, build those as the later change says and say so in
43
+ the commit's body; otherwise build to the brief and compare nothing. What is marked **new** moved since you last read the brief; its diff is shown once.
42
44
  **A bug's task** (`BUG-<n>/<track>`) has a shorter brief: it opens with the bug's words (what was expected, what
43
45
  happened, how to see it) and the items it cites, which are its checklist; then the objects those items belong to,
44
46
  where each is in the export now, and the changes the bug originates in. There is no delta: the product deviates
@@ -48,27 +50,46 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
48
50
  3. Call `touch` with the task, then `task` with it. `followed_by` lists the later tasks on this track whose objects
49
51
  overlap this one's; say them in one line, e.g. "CHG-015/BE, after yours, changes some of the same objects; it will
50
52
  be its own task." Build what this change says, not what later ones do.
51
- 4. Work from the brief. Open a file the brief names only when you need it, at the path the brief gives (an
53
+ 4. **The question pass, before any code.** Walk the checklist and, for each item, name what you would have to
54
+ decide that the brief doesn't state: the edge of each input (empty, the last one, a record gone meanwhile),
55
+ which refusal wins when two apply, a default, an order, a limit, what happens to records that already exist, the
56
+ wording of a text. Group them by matter (the same rule, entity or moment) and ask each matter once with
57
+ `/alterspec-spec-ask`, its cases as numbered parts, with `--task` and `--item`. Then plan the work with the
58
+ answers: an `open` matter's items go last, an `assumed` one is built on its assumption. A question that surfaces
59
+ while building is still asked before the commit that stands on it (step 7), but there should be few: the pass is
60
+ where the product side gets your questions in one batch, while they are cheap to answer, and where you stop
61
+ being interrupted by their answers.
62
+ 5. Work from the brief. Open a file the brief names only when you need it, at the path the brief gives (an
52
63
  absolute one is the pinned copy of an object changed since), and its shards (one per section
53
64
  or item, under `_shards/`) rather than the whole file when one section is enough. Never read the export
54
65
  wholesale. An object "not in the export now" was removed or isn't signed off: build nothing for it, and say so.
55
- 5. Build it here, in this repository's own technology and conventions. The spec says what the product does; how is
66
+ Between the start and a commit, read nothing to see whether something moved: news is read at the boundaries
67
+ (`_shared.md`); `alterspec-client context <task> --checklist` is the brief to re-read during the work (this
68
+ task's questions and checklist, nothing else). Under "Reach" each rule comes with its row of the rule matrix
69
+ (who triggers, reads, lists and covers it, where its message shows): `_generated/rule-matrix.md` need not be
70
+ opened for it.
71
+ 6. Build it here, in this repository's own technology and conventions. The spec says what the product does; how is
56
72
  the developer's. A mockup page is the agreed look and behaviour of a screen, a working example to follow, not code
57
73
  to copy. When the spec is silent, ambiguous or says two things, ask with `/alterspec-spec-ask` as
58
74
  `_shared.md` says and go on with what its answer allows; when the spec and the code disagree, tell the developer.
59
75
  Never fill a gap with an invented business rule.
60
- 6. Before each commit of the task, look at what you built for it and name to yourself every choice about the
61
- product's behaviour that the brief didn't state. Each one has a `Q-<n>` from `/alterspec-spec-ask`, or you ask it
62
- now, before the commit, as `_shared.md` says; the commit's body names the `Q-<n>` it stands on.
63
- 7. Work through the checklist, the heavy items first (their weight `w`, when the brief shows one, is how much
76
+ 7. Before each commit of the task, look at what you built for it and name to yourself every choice about the
77
+ product's behaviour that the brief didn't state. Each one has a `Q-<n>` from `/alterspec-spec-ask` (most from the
78
+ pass of step 4), or you ask it now, before the commit, as `_shared.md` says; the commit's body names the `Q-<n>`
79
+ it stands on.
80
+ 8. Work through the checklist, the heavy items first (their weight `w`, when the brief shows one, is how much
64
81
  behaviour each is; it is the sign-off's, never yours to set or send). An item marked `w 0, nothing to build on this track` is
65
- another track's behaviour that your track only reads: read it, build nothing for it and never name it in
66
- `Alterspec-Covers`; when your track does have work for it, ask with `/alterspec-spec-ask`. A criterion item is your track's part of
82
+ one of two things, and the brief doesn't say which: another track's behaviour that your track only reads (its
83
+ text names only another channel: read it, build nothing), or behaviour the sign-off holds this track to have
84
+ already (as built). Read the code against the item either way, as `_shared.md` says: when it has the behaviour,
85
+ its test stays; when it lacks it and the item is yours, build it and say in the commit's body that the weight
86
+ called it built. Never name a `w 0` item in `Alterspec-Covers`; when you can't tell whose the item is, ask with
87
+ `/alterspec-spec-ask`. A criterion item is your track's part of
67
88
  it (`Then` on the backend, `Shown` on a UI track); leave the part the brief gives to another task. A contract state item comes with its mockup link
68
89
  (`…/SCR-….html?state=<state>`): open that page in that state to see what you build (sign in as one of the
69
90
  screen's roles on the channel's `index.html` first; the session stays). For each item, make its
70
91
  tests pass, then commit with the trailers of `_shared.md`: `Alterspec-Task: <task>` always, `Alterspec-Covers`
71
92
  with the items whose tests pass on that commit. The hook reports them. When the work is merged into the main
72
93
  branch, the developer types `/alterspec-task-done <task>`; never report it done yourself.
73
- 8. When every checklist item is covered, send your `feedback` once, as `_shared.md` says, while you still remember
94
+ 9. When every checklist item is covered, send your `feedback` once, as `_shared.md` says, while you still remember
74
95
  what the work cost (nothing you asked is said again: `decided` is the bare `Q-<n>` of each assumption); then tell the developer the task is ready for `/alterspec-task-done <task>` once it is merged.
@@ -26,7 +26,8 @@ CHG-052/BE", "take CHG-052/BE").
26
26
  (`git fetch origin <branch>` first). A null `branch` means the main branch, as usual.
27
27
  6. The tasks it assigned:
28
28
  - **One**: continue with `.alterspec-client/prompts/task-context.md` for that task, here, on whatever branch the
29
- developer is on (when it starts from a predecessor's branch, say so before any commit is made).
29
+ developer is on (when it starts from a predecessor's branch, say so before any commit is made), starting with
30
+ its question pass before any code.
30
31
  - **Several**: list each task with its title and, when it has one, the branch it starts from, and say: type
31
32
  `/alterspec-task-context <task>` where you want to work on it. Work on none of them in this session.
32
33
  - **None**: say so, with the reasons. Stop.
@@ -218,9 +218,17 @@ server. Then talk to it in plain words; the skills do the rest.
218
218
 
219
219
  1. "Give me work." Claude takes a task and shows the brief and its checklist. Work on it in the branch (or worktree) you
220
220
  choose, made the way you make them: the client creates no branch, no worktree and no commit in your repository.
221
+ Before any code, Claude walks the checklist and asks the product side every question it can see, one per
222
+ matter, in one batch through `/alterspec-spec-ask`; the answers usually arrive while it plans, and the rest of
223
+ the task runs without waiting for anyone.
221
224
  2. Build it with Claude in your own technology. The spec says what, never how; a mockup shows the agreed look and
222
225
  behaviour, it is not code to copy. When the spec is silent or says two things, Claude asks through `/alterspec-spec-ask` and
223
- goes on with what the answer allows; when the spec and the code disagree, Claude asks you.
226
+ goes on with what the answer allows; when the spec and the code disagree, Claude asks you. A brief's "Built
227
+ already", a summary's "Nothing to build" or an item's `w 0` is a claim about your code, made from the spec side
228
+ or from dates: Claude reads the code against the item before it skips or covers it, and builds what the code
229
+ turns out to lack. Between the start and a commit Claude reads nothing to see whether the spec moved: answers
230
+ and later changes are looked at when a skill starts, before a commit and at `/alterspec-task-done`
231
+ (`alterspec-client context <task> --checklist` prints the task's questions and checklist alone).
224
232
  3. Claude ends every commit of the task with a trailer:
225
233
 
226
234
  ```
@@ -255,9 +263,10 @@ sentence a later change wrote is asked on that change's task.
255
263
  ignores itself in git and is rewritten every time the brief is made; delete it whenever you like.
256
264
  - When the brief is read again and something moved in between, it marks it **new** and shows once what the new
257
265
  changes did.
258
- - One exception to "not your work": before building one of your task's own objects that later changes touched,
259
- Claude compares the two texts and doesn't build a line a later change removed or reversed; it builds that item
260
- as the later change says and says so in the commit.
266
+ - One exception to "not your work", and the brief does the checking: under "Checked" it says, for each object
267
+ your task changes, whether a later change removed or reworded a line of your task's own hunks. Claude builds
268
+ such a line as the later change says and says so in the commit; otherwise it builds to the brief and compares
269
+ nothing.
261
270
  - An object that was signed off only after your task's change (the brief says so) is shown as the export holds it
262
271
  now: the export never had its earlier text.
263
272
 
@@ -368,7 +377,15 @@ when one of yours was fixed since you last looked.
368
377
  widen or narrow the task yourself.
369
378
  - **Only you move your task on.** Going away for a while? Release it. An admin can force a release only when you are
370
379
  gone, and that is logged.
380
+ - **The checklist is the dispatcher's list.** When the dispatcher answers, the brief's items, weights and labels are
381
+ the ones it holds, so `Alterspec-Covers` names what it accepts; the brief computes them from the export only when
382
+ it can't be asked. A bug's task lists the cites of its own track.
383
+ - **A rule's reach is in the brief.** Under Reach, a rule comes with its row of the rule matrix (who triggers,
384
+ reads, lists and covers it, where its message shows); the matrix itself need not be opened.
371
385
  - **Keep the client current.** Run `init` again now and then (or when your admin says so); it updates the skills.
386
+ - **One task at a time, in order, on `task/<chg>-<track>`.** Taking several at once or out of order is allowed, but
387
+ the dispatcher then warns of shared objects, and the warnings are usually right. The branch name the client
388
+ recognises by itself spares you the trailer when a commit forgets it.
372
389
  - **Tell Claude about the spec outside the skills too.** The skills explain the export only while they run. Copy the
373
390
  block in [`agent-instructions.md`](agent-instructions.md) (in this package) into your `CLAUDE.md` or wherever you
374
391
  keep your agent's instructions, with your export clone's path.
package/dist/cli.js CHANGED
@@ -821,6 +821,7 @@ var patternsPath = (code) => `${surfaceDir(code)}/patterns.md`;
821
821
  var designSystemPath = (code) => `${surfaceDir(code)}/design-system.md`;
822
822
  var OPERATIONS_FILE = "_generated/operations.md";
823
823
  var INDEX_FILE = "_generated/index.json";
824
+ var RULE_MATRIX_FILE = "_generated/rule-matrix.md";
824
825
  var CONTRACT = new RegExp(
825
826
  `^modules/[^/]+/screens/(?<screen>${SCREEN_ID})/experience/(?<code>[a-z]{2,5})\\.md$`
826
827
  );
@@ -1765,6 +1766,31 @@ function lifecycleOf(x, id) {
1765
1766
  const transitions = (e.transitions ?? []).map((t) => `${t.from}->${t.to}${t.by === "time" ? ` by time${t.at ? ` at ${t.at}` : ""}` : ""}`).join(", ");
1766
1767
  return `states ${states}${transitions ? `; transitions ${transitions}` : "; no transitions"}`;
1767
1768
  }
1769
+ var linesOf2 = (key, text) => new Set(
1770
+ forDiff(key, text).split("\n").map((l) => l.trim()).filter((l) => l && l !== "---")
1771
+ );
1772
+ var MATRIX_ROW = /^- \*\*(Triggered by|Reads the guarded entity|Listed by, without triggering a guard|Covered by|Message shown on)/;
1773
+ var matrices = /* @__PURE__ */ new WeakMap();
1774
+ function matrixOf(x) {
1775
+ const known = matrices.get(x);
1776
+ if (known) return known;
1777
+ const m = { legend: [], rows: /* @__PURE__ */ new Map() };
1778
+ const text = x.read(RULE_MATRIX_FILE);
1779
+ if (text) {
1780
+ const [head, ...blocks] = text.split(/^(?=## )/m);
1781
+ const legend = head.split("How to read a rule:")[1] ?? "";
1782
+ const bullets2 = legend.split(/^(?=- )/m).map((b) => b.trimEnd());
1783
+ for (const b of bullets2) if (MATRIX_ROW.test(b)) m.legend.push(...b.split("\n"));
1784
+ for (const block of blocks) {
1785
+ const id = block.slice(3).split(/\s/)[0];
1786
+ if (!id) continue;
1787
+ const rows = block.split("\n").filter((l) => MATRIX_ROW.test(l)).map((l) => l.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1"));
1788
+ if (rows.length) m.rows.set(id, rows);
1789
+ }
1790
+ }
1791
+ matrices.set(x, m);
1792
+ return m;
1793
+ }
1768
1794
  function reachOf(x, id, kind, changed) {
1769
1795
  const index = x.index();
1770
1796
  if (!index) return void 0;
@@ -1787,13 +1813,15 @@ function reachOf(x, id, kind, changed) {
1787
1813
  ).map((chunk) => chunk.slice(4).split(/\s/)[0]);
1788
1814
  });
1789
1815
  const screens2 = [...new Set(caps2.flatMap((c) => c.screens ?? []))].filter((sid) => x.sources.has(sid));
1816
+ const matrix = matrixOf(x).rows.get(id) ?? [];
1790
1817
  return {
1791
1818
  id,
1792
1819
  kind,
1793
1820
  ...title ? { title } : {},
1794
1821
  capabilities: caps2.map((c) => piece(c.id, c.title)),
1795
1822
  criteria,
1796
- screens: screens2.map(screenPiece)
1823
+ screens: screens2.map(screenPiece),
1824
+ ...matrix.length ? { matrix } : {}
1797
1825
  };
1798
1826
  }
1799
1827
  const caps = index.capabilities.filter((c) => (c.roles ?? []).some((r) => r.role === id));
@@ -1828,9 +1856,16 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
1828
1856
  const delta = x.delta(task.change);
1829
1857
  const entries = new Map(delta?.objects.map((e) => [e.key, e]));
1830
1858
  const lost = new Map(delta?.unrecoverable?.map((u) => [u.key, u.why]));
1831
- const items = work.items;
1832
- const weights = work.weights;
1859
+ const exported = work;
1860
+ const items = state.items?.length ? state.items.map((i) => i.item) : exported.items;
1861
+ const weights = state.items?.length ? Object.fromEntries(
1862
+ state.items.flatMap((i) => {
1863
+ const w = i.weight ?? exported.weights?.[i.item];
1864
+ return w === void 0 ? [] : [[i.item, w]];
1865
+ })
1866
+ ) : exported.weights;
1833
1867
  const words2 = work;
1868
+ const labelOf = (item) => state.items?.find((i) => i.item === item)?.label ?? words2.labels?.[item];
1834
1869
  const initiativeId = change.initiative;
1835
1870
  const initiative = initiativeId ? x.initiative(initiativeId) : void 0;
1836
1871
  const ctx = {
@@ -1851,7 +1886,7 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
1851
1886
  what: itemWhat(x, item, entries.get(itemObject(item)), task.track),
1852
1887
  ...covered ? { covered } : {},
1853
1888
  ...weight === void 0 ? {} : { weight },
1854
- ...words2.labels?.[item] ? { label: words2.labels[item] } : {}
1889
+ ...labelOf(item) ? { label: labelOf(item) } : {}
1855
1890
  };
1856
1891
  }),
1857
1892
  known: state.covered !== void 0,
@@ -2019,6 +2054,10 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2019
2054
  ...roles.map((id) => reachOf(current, id, "role", changed))
2020
2055
  ].filter((r) => !!r);
2021
2056
  if (!ctx.reach.length) delete ctx.reach;
2057
+ if (ctx.reach?.some((r) => r.matrix?.length)) {
2058
+ const legend = matrixOf(current).legend;
2059
+ if (legend.length) ctx.matrixLegend = legend;
2060
+ }
2022
2061
  const glossary = x.fileOf("term:");
2023
2062
  const writtenText = written.join("\n");
2024
2063
  ctx.terms = (glossary && x.has(glossary) ? x.shards(glossary) : []).filter((path) => !/\/\d{2}-[^/]*$/.test(path)).flatMap((path) => {
@@ -2047,6 +2086,24 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2047
2086
  }
2048
2087
  const title = key.includes(":") ? void 0 : titleOf(current, key);
2049
2088
  const pinned = pinnedPath(x, key);
2089
+ const mine = entries.get(key);
2090
+ let checked = false;
2091
+ let lost2;
2092
+ if (changed.has(key) && mine && !mine.binary && !s.absent) {
2093
+ checked = true;
2094
+ const wroteBefore = linesOf2(key, mine.exported.before ? mine.before : void 0);
2095
+ const wrote = [...linesOf2(key, mine.exported.after ? mine.after : void 0)].filter(
2096
+ (l) => !wroteBefore.has(l)
2097
+ );
2098
+ lost2 = s.later.flatMap((l) => {
2099
+ if (l.entry.binary) return [];
2100
+ const kept = linesOf2(key, l.entry.exported.after ? l.entry.after : void 0);
2101
+ const gone = [...linesOf2(key, l.entry.exported.before ? l.entry.before : void 0)].filter(
2102
+ (line) => wrote.includes(line) && !kept.has(line)
2103
+ );
2104
+ return gone.length ? [{ change: l.change, lines: gone }] : [];
2105
+ });
2106
+ }
2050
2107
  return [
2051
2108
  {
2052
2109
  key,
@@ -2056,7 +2113,9 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
2056
2113
  ...pinned ? { pinned: at(pinned) } : {},
2057
2114
  ...diff ? { diff } : {},
2058
2115
  ...now === void 0 ? { gone: true } : {},
2059
- ...s.absent ? { entered: true } : {}
2116
+ ...s.absent ? { entered: true } : {},
2117
+ ...checked ? { checked: true } : {},
2118
+ ...lost2?.length ? { lost: lost2 } : {}
2060
2119
  }
2061
2120
  ];
2062
2121
  });
@@ -2088,6 +2147,7 @@ function pinFiles(current, c) {
2088
2147
  var textAfter = (e) => e.exported.after ? e.after : void 0;
2089
2148
  var DIFF_LINES = 40;
2090
2149
  var NEW_DIFFS = 12;
2150
+ var LOST_LINES = 8;
2091
2151
  function clippedDiff(diff) {
2092
2152
  const lines = diff.split("\n");
2093
2153
  return lines.length <= DIFF_LINES ? diff : `${lines.slice(0, DIFF_LINES).join("\n")}
@@ -2109,34 +2169,8 @@ function initiativeSection(i) {
2109
2169
  ...prose ? [prose, ""] : []
2110
2170
  ];
2111
2171
  }
2112
- function renderContext(c) {
2113
- const out = [
2114
- `# ${c.task}: ${c.title ?? c.change.title}`,
2115
- "",
2116
- // The words the lists show for the task: what a person calls it, never what to build from.
2117
- ...c.summary ? [c.summary, ""] : [],
2118
- ...c.title ? [`Change: ${c.change.title}.`, ""] : [],
2119
- ...c.initiative ? initiativeSection(c.initiative) : [],
2120
- `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}. ` + (c.weight === void 0 ? "" : `Task weight ${c.weight} of 100. `) + `Paths are relative to the export, ${c.export}.`
2121
- ];
2122
- const movedSince = (c.changedSince ?? []).filter((e) => !e.entered);
2123
- if (movedSince.length) {
2124
- const n = movedSince.length;
2125
- const fresh = movedSince.filter((e) => e.changes.some((ch) => ch.fresh)).length;
2126
- out.push(
2127
- "",
2128
- `This brief is the spec as ${c.change.id} saw it at its sign-off. ${n === 1 ? "One object it names was" : `${n} objects it names were`} changed since by later changes${fresh ? ` (${fresh} new since you last read this brief)` : ""}: those are the later changes\u2019 tasks, listed under "Changed since" at the end, never this task\u2019s work.` + (c.pins ? ` An absolute path under ${c.pins} is such an object as ${c.change.id} saw it.` : "")
2129
- );
2130
- }
2131
- if (c.after.length) out.push("", `Waits for: ${c.after.map((a) => `${a.change}/${a.track}`).join(", ")}.`);
2132
- if (c.startFrom?.length)
2133
- out.push(
2134
- "",
2135
- `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 (fetch it and base your branch on \`origin/${c.startFrom[c.startFrom.length - 1].branch}\`).`
2136
- );
2137
- out.push("");
2138
- if (c.questions?.length) out.push(...questionsSection(c.questions));
2139
- if (c.answers?.length) out.push(...answersSection(c.answers));
2172
+ function checklistSection(c) {
2173
+ const out = [];
2140
2174
  if (!c.checklist)
2141
2175
  out.push("This export has no checklist (work.json format 1): the task\u2019s progress is its status only.");
2142
2176
  else {
@@ -2166,6 +2200,51 @@ function renderContext(c) {
2166
2200
  )
2167
2201
  );
2168
2202
  }
2203
+ return out;
2204
+ }
2205
+ function renderChecklist(c) {
2206
+ const out = [
2207
+ `# ${c.task}: ${c.title ?? c.change.title}`,
2208
+ "",
2209
+ ...c.summary ? [c.summary, ""] : [],
2210
+ ...c.weight === void 0 ? [] : [`Task weight ${c.weight} of 100.`, ""],
2211
+ ...c.questions?.length ? questionsSection(c.questions) : [],
2212
+ ...c.answers?.length ? answersSection(c.answers) : [],
2213
+ ...checklistSection(c),
2214
+ "",
2215
+ `This task\u2019s questions and checklist only; the full brief is \`alterspec-client context ${c.task}\`.`
2216
+ ];
2217
+ return out.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd() + "\n";
2218
+ }
2219
+ function renderContext(c) {
2220
+ const out = [
2221
+ `# ${c.task}: ${c.title ?? c.change.title}`,
2222
+ "",
2223
+ // The words the lists show for the task: what a person calls it, never what to build from.
2224
+ ...c.summary ? [c.summary, ""] : [],
2225
+ ...c.title ? [`Change: ${c.change.title}.`, ""] : [],
2226
+ ...c.initiative ? initiativeSection(c.initiative) : [],
2227
+ `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}. ` + (c.weight === void 0 ? "" : `Task weight ${c.weight} of 100. `) + `Paths are relative to the export, ${c.export}.`
2228
+ ];
2229
+ const movedSince = (c.changedSince ?? []).filter((e) => !e.entered);
2230
+ if (movedSince.length) {
2231
+ const n = movedSince.length;
2232
+ const fresh = movedSince.filter((e) => e.changes.some((ch) => ch.fresh)).length;
2233
+ out.push(
2234
+ "",
2235
+ `This brief is the spec as ${c.change.id} saw it at its sign-off. ${n === 1 ? "One object it names was" : `${n} objects it names were`} changed since by later changes${fresh ? ` (${fresh} new since you last read this brief)` : ""}: those are the later changes\u2019 tasks, listed under "Changed since" at the end, never this task\u2019s work.` + (c.pins ? ` An absolute path under ${c.pins} is such an object as ${c.change.id} saw it.` : "")
2236
+ );
2237
+ }
2238
+ if (c.after.length) out.push("", `Waits for: ${c.after.map((a) => `${a.change}/${a.track}`).join(", ")}.`);
2239
+ if (c.startFrom?.length)
2240
+ out.push(
2241
+ "",
2242
+ `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 (fetch it and base your branch on \`origin/${c.startFrom[c.startFrom.length - 1].branch}\`).`
2243
+ );
2244
+ out.push("");
2245
+ if (c.questions?.length) out.push(...questionsSection(c.questions));
2246
+ if (c.answers?.length) out.push(...answersSection(c.answers));
2247
+ out.push(...checklistSection(c));
2169
2248
  out.push("", `## Why (${c.proposal.path})`, "", c.proposal.why || "(none written)");
2170
2249
  out.push("", "## What changes", "", c.proposal.what || "(none written)");
2171
2250
  if (c.proposal.dataChange)
@@ -2230,6 +2309,13 @@ function renderContext(c) {
2230
2309
  "Where the export enforces, holds or shows the rules and roles this task touches or names; a capability or screen not in the export isn\u2019t listed.",
2231
2310
  ""
2232
2311
  );
2312
+ if (c.matrixLegend?.length)
2313
+ out.push(
2314
+ `Under a rule, its row of the rule matrix (\`${RULE_MATRIX_FILE}\`), so the matrix need not be opened. How to read it:`,
2315
+ "",
2316
+ ...c.matrixLegend,
2317
+ ""
2318
+ );
2233
2319
  const list2 = (ps) => ps.map((p) => `${p.id}${p.scope ? ` (${p.scope})` : ""}${p.changed ? " (this task changes it)" : ""}`).join(", ");
2234
2320
  for (const r of c.reach) {
2235
2321
  const name = `${r.id}${r.title ? ` ${r.title}` : ""}`;
@@ -2240,6 +2326,7 @@ function renderContext(c) {
2240
2326
  r.screens.length ? `on ${list2(r.screens)}` : "on no screen"
2241
2327
  ];
2242
2328
  out.push(`- ${name}: ${parts.join("; ")}.`);
2329
+ for (const line of r.matrix ?? []) out.push(` ${line}`);
2243
2330
  } else {
2244
2331
  const parts = [
2245
2332
  r.capabilities.length ? `may perform ${list2(r.capabilities)}` : "may perform no capability",
@@ -2328,7 +2415,7 @@ function renderContext(c) {
2328
2415
  const names = (e) => `${e.key}${e.title ? ` ${e.title}` : ""}${e.own ? " (this task changes it)" : ""}`;
2329
2416
  if (movedSince.length) {
2330
2417
  out.push(
2331
- `Later changes touched what this brief names. Build this task to the text above: what a later change added is built in its own task. Before you build one of this task\u2019s objects listed here, compare the file the brief gives for it with the export\u2019s: a line a later change removed or reversed is not built twice (build that item as the later change says and say so in the commit).`,
2418
+ `Later changes touched what this brief names. Build this task to the text above: what a later change added is built in its own task.` + (movedSince.some((e) => e.own) ? ' For the objects this task changes, whether a later change removed or reworded a line of this task\u2019s hunks is checked here, under "Checked": compare nothing yourself.' : ""),
2332
2419
  "",
2333
2420
  ...(c.later ?? []).map(
2334
2421
  (l) => `- ${l.id}${l.title ? ` "${l.title}"` : ""}: ${l.task ? `its task ${l.task}` : "no task on this track"}${l.delta ? `; \`${l.delta}\`` : ""}`
@@ -2341,6 +2428,27 @@ function renderContext(c) {
2341
2428
  ),
2342
2429
  ""
2343
2430
  );
2431
+ const own = movedSince.filter((e) => e.own);
2432
+ if (own.length)
2433
+ out.push(
2434
+ "Checked: this task\u2019s own lines against the later changes\u2019 deltas.",
2435
+ "",
2436
+ ...own.map((e) => {
2437
+ if (!e.checked)
2438
+ return `- ${names(e)}: not checked (a binary file, or the export did not hold it then): compare the pinned file with the export\u2019s.`;
2439
+ if (!e.lost?.length)
2440
+ return `- ${names(e)}: no line of this task\u2019s hunks was removed or reworded by ${e.changes.map((ch) => ch.id).join(", ")}. Build it as the brief says.`;
2441
+ return [
2442
+ `- ${names(e)}: build these lines as the later change says, not as the brief has them, and say so in the commit\u2019s body:`,
2443
+ ...e.lost.flatMap((l) => [
2444
+ ` - ${l.change} removed or reworded ${l.lines.length === 1 ? "one line" : `${l.lines.length} lines`}:`,
2445
+ ...l.lines.slice(0, LOST_LINES).map((line) => ` - \`${line.replace(/`/g, "'")}\``),
2446
+ ...l.lines.length > LOST_LINES ? [` - and ${l.lines.length - LOST_LINES} more (see its delta)`] : []
2447
+ ])
2448
+ ].join("\n");
2449
+ }),
2450
+ ""
2451
+ );
2344
2452
  const fresh = movedSince.filter((e) => e.diff);
2345
2453
  if (fresh.length) {
2346
2454
  out.push(
@@ -2463,6 +2571,8 @@ async function bugTaskState(session, task) {
2463
2571
  bug,
2464
2572
  objects: z8.array(z8.string()).catch([]).parse(answer.objects),
2465
2573
  after: (answer.after ?? []).flatMap((a) => a.id ? [a.id] : []),
2574
+ // The task's items are the bug's cites on this track, not every track's.
2575
+ ...items.length ? { items: items.map((i) => ({ item: i.item })) } : {},
2466
2576
  covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : [])),
2467
2577
  ...from.length ? { startFrom: from } : {}
2468
2578
  };
@@ -2476,9 +2586,8 @@ function bugContext(x, task, exportDir2, state, questions) {
2476
2586
  kind: "ui",
2477
2587
  channels: []
2478
2588
  };
2479
- const keys = [
2480
- ...new Set(state.objects.length ? state.objects : state.bug.cites.map((c) => objectOfItem(c, [])))
2481
- ];
2589
+ const cites = state.items?.length ? state.items.map((i) => i.item) : state.bug.cites;
2590
+ const keys = [...new Set(state.objects.length ? state.objects : cites.map((c) => objectOfItem(c, [])))];
2482
2591
  const objects = keys.map((key) => {
2483
2592
  const file = x.fileOf(key);
2484
2593
  const held = file !== void 0 && x.has(file);
@@ -2497,7 +2606,7 @@ function bugContext(x, task, exportDir2, state, questions) {
2497
2606
  after: state.after,
2498
2607
  ...state.startFrom?.length ? { startFrom: state.startFrom } : {},
2499
2608
  checklist: {
2500
- items: state.bug.cites.map((item) => {
2609
+ items: cites.map((item) => {
2501
2610
  const covered = state.covered?.get(item);
2502
2611
  return { item, what: itemWhat(x, item, void 0, task.track), ...covered ? { covered } : {} };
2503
2612
  })
@@ -2539,7 +2648,7 @@ function renderBugContext(c) {
2539
2648
  "",
2540
2649
  `## Checklist (${done} of ${c.checklist.items.length} covered)`,
2541
2650
  "",
2542
- "The cited items. Name an item in `Alterspec-Covers` on the commit with which its tests pass again.",
2651
+ "The cited items on this track. Name an item in `Alterspec-Covers` on the commit with which its tests pass again.",
2543
2652
  "",
2544
2653
  ...c.checklist.items.map(
2545
2654
  (i) => `- [${i.covered ? "x" : " "}] \`${i.item}\`: ${i.what}${i.covered ? ` (covered by ${i.covered.slice(0, 12)})` : ""}`
@@ -3550,6 +3659,15 @@ async function coveredState(loaded, task) {
3550
3659
  const from = startFrom(task.track, answer.after);
3551
3660
  return {
3552
3661
  covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : [])),
3662
+ // The dispatcher's list is the checklist: its first item list stands (its spec, section 9), so the brief and
3663
+ // the `Alterspec-Covers` it accepts name the same items.
3664
+ ...items.length ? {
3665
+ items: items.map((i) => ({
3666
+ item: i.item,
3667
+ ...typeof i.weight === "number" ? { weight: i.weight } : {},
3668
+ ...typeof i.label === "string" && i.label ? { label: i.label } : {}
3669
+ }))
3670
+ } : {},
3553
3671
  ...answers ? { answers } : {},
3554
3672
  ...from.length ? { startFrom: from } : {}
3555
3673
  };
@@ -3658,7 +3776,10 @@ program.command("export-head").description("pull the export clone and print its
3658
3776
  process.stdout.write(JSON.stringify(head, null, 2) + "\n");
3659
3777
  })
3660
3778
  );
3661
- program.command("context").description("print a task\u2019s brief, assembled from the export").argument("<task>", "the task, e.g. CHG-012/BE or BUG-3/BE").option("--json", "print it as JSON").option("--stats", "print its size by section instead").action(
3779
+ program.command("context").description("print a task\u2019s brief, assembled from the export").argument("<task>", "the task, e.g. CHG-012/BE or BUG-3/BE").option("--json", "print it as JSON").option("--stats", "print its size by section instead").option(
3780
+ "--checklist",
3781
+ "print only the task\u2019s questions and checklist, for re-reading during the work (a bug\u2019s brief whole)"
3782
+ ).action(
3662
3783
  run(async (id, opts) => {
3663
3784
  const loaded = loadConfig();
3664
3785
  approveWorktree(loaded);
@@ -3692,12 +3813,12 @@ program.command("context").description("print a task\u2019s brief, assembled fro
3692
3813
  await changeQuestions(sessionOf(loaded), tasks),
3693
3814
  { pins, shown: readShown(process.cwd(), task) }
3694
3815
  );
3695
- if (!opts.stats) {
3816
+ if (!opts.stats && !opts.checklist) {
3696
3817
  writePins(pins, pinFiles(x, ctx));
3697
3818
  writeShown(process.cwd(), task, shownOf(ctx));
3698
3819
  }
3699
3820
  process.stdout.write(
3700
- opts.stats ? contextStats(renderContext(ctx)) : opts.json ? JSON.stringify(ctx, null, 2) + "\n" : renderContext(ctx)
3821
+ opts.stats ? contextStats(renderContext(ctx)) : opts.json ? JSON.stringify(ctx, null, 2) + "\n" : opts.checklist ? renderChecklist(ctx) : renderContext(ctx)
3701
3822
  );
3702
3823
  })
3703
3824
  );