@alterset/alterspec-client 0.11.1 → 0.12.1

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.
@@ -34,8 +34,11 @@ dispatcher's pages.
34
34
  say and one reading is the cautious one; work on with it, name `Q-<n>` in the body of every commit that stands on
35
35
  it, and expect that the product side may correct it. *Open* (`Q-<n>`): nobody may assume it; leave that checklist
36
36
  item uncovered, work the others, and never name it in `Alterspec-Covers`. The brief (`alterspec-client context`)
37
- opens with the task's questions and the product side's answers, and `alterspec-client questions <task>` prints
38
- them: an answer to an open one unblocks its item; a corrected assumption is rework, done before anything else.
37
+ opens with the change's questions on every track and the product side's answers, and `alterspec-client questions
38
+ <task>` prints a task's: an answer to an open one unblocks its item; a corrected assumption is rework, done before
39
+ anything else. An answer that changes the spec comes back one export later as a change of its own; when the brief
40
+ says this track built it already ("Built already"), that task checks the code against the spec's new text and
41
+ rebuilds nothing.
39
42
  - **A decision about the product is recorded when it is made, not when the task ends.** Whenever you are about to
40
43
  build behaviour the brief doesn't state, you are deciding for the product: which refusal wins when two apply, a
41
44
  default, an order, a limit, what happens to records that already exist, the wording of a message, what an input
@@ -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? On a task, the brief's questions; else, when the question names IDs and the dispatcher keeps
16
- questions, `alterspec-client questions --about <ID...>`. When one of them is this question and the product side
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>` on
20
- a task. It prints what the question is about, the shards to read first, the ones that must be opened before the
21
- export may be called silent, the neighbours and the views. When it says the question names nothing the export
22
- holds, put the question in the export's terms (the IDs of the task's brief, the glossary's words) and run it
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, on a task, the task and the checklist item. Don't answer it
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, on a task, `task` and `item`. The words are
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 and work
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,8 +7,12 @@ 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 task has questions it opens with them: say
11
- in one line each one the product side answered since, and take up a corrected assumption first. Then the task's checklist: its items, what
10
+ 2. Run `alterspec-client context <task>` and read the brief. When the change has questions it opens with them, on
11
+ every track (each names the task it was asked on): say in one line each one the product side answered since, and
12
+ take up a corrected assumption first. When the dispatcher says this change carries answers this track built
13
+ already ("Built already"), the task is a check, not a build: read each checklist item against the code, add the
14
+ tests that are missing, cover each item as its tests pass, and rebuild nothing; build only what stands on a
15
+ question not built here. Then the task's checklist: its items, what
12
16
  each is and which the dispatcher holds covered already; that is the work, and its progress. Then why the change
13
17
  was made, what changed, the one-time data change when the proposal declares one (what the release does once to the
14
18
  records the product already holds; on the backend it is the `CHG-NNN#data-change` item), the delta of each of the
@@ -229,6 +229,11 @@ either the spec already says, or the choice is recorded at once as an assumption
229
229
  hour. Nothing about the product is decided silently and found out at the end of the task. How the code is built is
230
230
  yours and is never asked.
231
231
 
232
+ A question is recorded with the task it concerns, and the checklist item when it concerns one, whether or not the
233
+ 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
234
+ its next holder's brief, not among the questions about no task. Name the task, or Claude takes the one the work is
235
+ about.
236
+
232
237
  How an answer is found: the client first looks whether the question was asked before, then computes where the spec
233
238
  would answer it (`lookup`: what the question names, by ID, by the glossary's words and their synonyms, by title; the
234
239
  sections to read first; the rules, decisions and "out of scope" lines about it) and gives that reading list to the
@@ -237,9 +242,13 @@ that it did. So "the spec doesn't say" means the places that would say it were r
237
242
  nothing.
238
243
 
239
244
  `npx @alterset/alterspec-client questions` prints your questions with their answers, `questions CHG-023/BE` a
240
- task's. `/alterspec-task-done` names the questions still open and doesn't refuse: whether to wait is yours to
241
- decide. If the answer changes the product, the product side signs it off as a change, and it reaches you as a task
242
- of its own in a later export.
245
+ task's; the brief shows the whole change's, so what the backend assumed is in front of the web task too.
246
+ `/alterspec-task-done` names the questions still open and doesn't refuse: whether to wait is yours to
247
+ decide. If the answer changes the product, the product side grooms it into the spec (several answers as one
248
+ change) and signs it off, and it reaches you as a task of its own in a later export. The dispatcher knows which
249
+ of that change's questions your track built already (your task finished after the answer), and the brief opens
250
+ with it under "Built already": such a task checks that the code says what the spec now says, adds the missing tests
251
+ and covers the items; it builds only what wasn't built here. Nothing is marked done for you, and nothing is rebuilt.
243
252
 
244
253
  While the dispatcher has no questions yet (an older one), the answer is still given, and Claude says it was not
245
254
  recorded: then an open question is yours to carry, as before.
package/dist/cli.js CHANGED
@@ -956,6 +956,20 @@ var QuestionSchema = z7.object({
956
956
  reconciled: z7.boolean().optional(),
957
957
  answers: z7.array(AnswerSchema).default([])
958
958
  });
959
+ var TaskAnswerSchema = z7.object({
960
+ question: z7.string(),
961
+ built: z7.boolean(),
962
+ /** The asking change's task on this track, when it has one. */
963
+ task: z7.string().nullish(),
964
+ done_at: z7.string().nullish(),
965
+ answer_at: z7.string().nullish(),
966
+ /** Why not built: no_task | not_done | answered_after_done | no_task_asked. */
967
+ why: z7.string().nullish()
968
+ });
969
+ function parseAnswers(raw) {
970
+ const parsed = z7.array(TaskAnswerSchema).safeParse(raw);
971
+ return parsed.success && parsed.data.length ? parsed.data : void 0;
972
+ }
959
973
  var QuestionsError = class extends Error {
960
974
  };
961
975
  var PART2 = /^(.+?)(?:-AC-\d+|\.A\d+|#[\w-]+)$/;
@@ -990,6 +1004,12 @@ async function taskQuestions(session, task) {
990
1004
  return void 0;
991
1005
  }
992
1006
  }
1007
+ async function changeQuestions(session, tasks) {
1008
+ const lists = await Promise.all(tasks.map((t) => taskQuestions(session, t)));
1009
+ if (lists.some((l) => l === void 0)) return void 0;
1010
+ const seen = /* @__PURE__ */ new Set();
1011
+ return lists.flat().filter((q) => q && !seen.has(q.id) && seen.add(q.id));
1012
+ }
993
1013
  var holding = (q) => q.answers.at(-1);
994
1014
  var isCorrected = (q) => q.corrected ?? holding(q)?.verdict === "corrected";
995
1015
  function sortQuestions(questions) {
@@ -1023,12 +1043,37 @@ function questionsSection(questions) {
1023
1043
  return [
1024
1044
  `## Questions (${open} open${corrected ? `, ${corrected} corrected` : ""})`,
1025
1045
  "",
1026
- corrected ? "A corrected assumption is rework: what was built on it follows the product side\u2019s answer before the task is done." : "What was asked about this task. An open one on an assumption may still be corrected; an item waiting for an answer stays uncovered.",
1046
+ corrected ? "A corrected assumption is rework: what was built on it follows the product side\u2019s answer before the task is done." : "What was asked about this change, on any of its tracks (each names the task it was asked on). An open one on an assumption may still be corrected; an item waiting for an answer stays uncovered.",
1027
1047
  "",
1028
1048
  ...sorted.flatMap(questionLines),
1029
1049
  ""
1030
1050
  ];
1031
1051
  }
1052
+ var day = (at) => at ? at.slice(0, 10) : void 0;
1053
+ function notBuilt(a) {
1054
+ const t = a.task ? `${a.task}` : "the asking task";
1055
+ switch (a.why) {
1056
+ case "no_task":
1057
+ return "the change it was asked on had no task on this track";
1058
+ case "not_done":
1059
+ return `${t} isn\u2019t done`;
1060
+ case "answered_after_done":
1061
+ return `the product side\u2019s answer (${day(a.answer_at) ?? "later"}) came after ${t} was done${a.done_at ? ` (${day(a.done_at)})` : ""}`;
1062
+ case "no_task_asked":
1063
+ return "it was asked outside a task";
1064
+ default:
1065
+ return a.why ?? "not built on this track";
1066
+ }
1067
+ }
1068
+ function answerLine(a) {
1069
+ return a.built ? `- ${a.question}: built in ${a.task ?? "the asking task"}, done ${day(a.done_at) ?? "earlier"}, after the product side\u2019s answer of ${day(a.answer_at) ?? "before it"}.` : `- ${a.question}: not built here: ${notBuilt(a)}.`;
1070
+ }
1071
+ function answersSection(answers) {
1072
+ if (!answers.length) return [];
1073
+ const built = answers.filter((a) => a.built).length;
1074
+ const how = built === answers.length ? "This change carries answers this track built already: the task checks that the code says what the spec now says. Read each checklist item against the code, add the tests that are missing, cover each item as its tests pass, and rebuild nothing." : built ? "This change carries answers this track built in part: build what stands on a question not built here; for the rest, read each checklist item against the code, add the tests that are missing and cover each item as its tests pass." : "This change carries answers to questions another track or task asked; none was built on this track, so build it as any task.";
1075
+ return [`## Built already (${built} of ${answers.length})`, "", how, "", ...answers.map(answerLine), ""];
1076
+ }
1032
1077
 
1033
1078
  // src/context.ts
1034
1079
  var ContextError = class extends Error {
@@ -1248,6 +1293,7 @@ function taskContext(x, task, exportDir2, state = {}, questions) {
1248
1293
  const ctx = {
1249
1294
  task: task.id,
1250
1295
  ...questions ? { questions } : {},
1296
+ ...state.answers?.length ? { answers: state.answers } : {},
1251
1297
  ...items ? {
1252
1298
  checklist: {
1253
1299
  items: items.map((item) => {
@@ -1412,6 +1458,7 @@ function renderContext(c) {
1412
1458
  if (c.after.length) out.push("", `Waits for: ${c.after.map((a) => `${a.change}/${a.track}`).join(", ")}.`);
1413
1459
  out.push("");
1414
1460
  if (c.questions?.length) out.push(...questionsSection(c.questions));
1461
+ if (c.answers?.length) out.push(...answersSection(c.answers));
1415
1462
  if (!c.checklist)
1416
1463
  out.push("This export has no checklist (work.json format 1): the task\u2019s progress is its status only.");
1417
1464
  else {
@@ -2454,8 +2501,10 @@ async function coveredState(loaded, task) {
2454
2501
  try {
2455
2502
  const answer = await callTool(sessionOf(loaded), "task", { id: task.id });
2456
2503
  const items = answer.items ?? [];
2504
+ const answers = parseAnswers(answer.answers);
2457
2505
  return {
2458
- covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : []))
2506
+ covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : [])),
2507
+ ...answers ? { answers } : {}
2459
2508
  };
2460
2509
  } catch (e) {
2461
2510
  return { unknown: e.message.split("\n")[0] };
@@ -2550,12 +2599,16 @@ program.command("context").description("print a task\u2019s brief, assembled fro
2550
2599
  const dir = exportDir(loaded);
2551
2600
  const x = readExport(dir);
2552
2601
  const task = parseTask(id);
2602
+ const tasks = [
2603
+ task.id,
2604
+ ...(x.work.changes.find((c) => c.id === task.change)?.tasks ?? []).map((t) => `${task.change}/${t.track}`).filter((t) => t !== task.id)
2605
+ ];
2553
2606
  const ctx = taskContext(
2554
2607
  x,
2555
2608
  task,
2556
2609
  dir,
2557
2610
  await coveredState(loaded, task),
2558
- await taskQuestions(sessionOf(loaded), task.id)
2611
+ await changeQuestions(sessionOf(loaded), tasks)
2559
2612
  );
2560
2613
  process.stdout.write(
2561
2614
  opts.stats ? contextStats(renderContext(ctx)) : opts.json ? JSON.stringify(ctx, null, 2) + "\n" : renderContext(ctx)