@alterset/alterspec-client 0.30.0 → 0.31.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/assets/prompts/_shared.md +5 -1
- package/assets/prompts/spec-ask.md +18 -4
- package/assets/prompts/task-done.md +8 -0
- package/developer-guide.md +21 -5
- package/dist/cli.js +156 -30
- package/dist/cli.js.map +1 -1
- package/dist/work.d.ts +274 -2
- package/dist/work.js +54 -2
- package/dist/work.js.map +1 -1
- package/dist/work.schema.json +432 -0
- package/package.json +1 -1
|
@@ -84,7 +84,11 @@ dispatcher's pages.
|
|
|
84
84
|
answer is one of three. *From the spec*, with the IDs it rests on: work on. *Assumed* (`Q-<n>`): the spec doesn't
|
|
85
85
|
say and one reading is the cautious one; work on with it, name `Q-<n>` in the body of every commit that stands on
|
|
86
86
|
it, and expect that the product side may correct it. *Open* (`Q-<n>`): nobody may assume it; leave that checklist
|
|
87
|
-
item uncovered, work the others, and never name it in `Alterspec-Covers`.
|
|
87
|
+
item uncovered, work the others, and never name it in `Alterspec-Covers`. Both carry your reading of the spec
|
|
88
|
+
(`assumption`; `no_reading` with the reason only when there truly is none), and an open one says what it waits
|
|
89
|
+
for: a contradiction between two objects, or a business decision; anything else is assumed. Another developer's
|
|
90
|
+
open question on the same matter is joined (`joins`), your own follow-up extends it (`extends`), and the
|
|
91
|
+
questions the dispatcher returns as `related` are shown before anything is posted. The brief (`alterspec-client context`)
|
|
88
92
|
opens with the change's questions on every track and the product side's answers, and `alterspec-client questions
|
|
89
93
|
<task>` prints a task's: an answer to an open one unblocks its item; a corrected assumption is rework, done before
|
|
90
94
|
anything else. An answer that changes the spec comes back one export later as a change of its own; when the brief
|
|
@@ -40,7 +40,9 @@ that follows is that change's task too.
|
|
|
40
40
|
first one didn't name), this is not a new question: it is a new numbered part of that one. Go on through steps
|
|
41
41
|
3 to 6 for the new part alone and, at step 7, record it as one question that restates the open one with its
|
|
42
42
|
parts numbered, naming the earlier `Q-<n>` first in its text ("Extends Q-124: (1) … (2) …") and passing
|
|
43
|
-
`extends: Q-<n>` when the dispatcher's `ask` takes it; the product side then answers the matter once.
|
|
43
|
+
`extends: Q-<n>` when the dispatcher's `ask` takes it; the product side then answers the matter once. When the
|
|
44
|
+
open one is another developer's question on the same matter, don't restate it: pass `joins: Q-<n>` at step 7,
|
|
45
|
+
and your task waits on that question's answer like theirs (`extends` is for your own follow-up only). And a
|
|
44
46
|
limit: once three of your questions about one cited object are open on the task, ask nothing more about that
|
|
45
47
|
object. Write the cases still undecided into one consolidated question the same way, build everything else on the
|
|
46
48
|
assumptions already recorded, and leave the items those cases hold uncovered. Fifty questions on one task about
|
|
@@ -60,9 +62,21 @@ that follows is that change's task too.
|
|
|
60
62
|
7. An answer from the spec is not sent to the dispatcher: nothing was decided, so there is nothing for the product
|
|
61
63
|
side to read. Record it with `ask` only when the outcome is `assumed` or `open`, and when the dispatcher lists
|
|
62
64
|
that tool: `question`, `outcome`, `cites` (what the question concerns, what the assumption extends),
|
|
63
|
-
`assumption
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
`assumption`, `export` (the commit from step 1) and, with a task, `task` and `item`. The words are the answerer's
|
|
66
|
+
and yours, naming IDs: no code and no copied spec text.
|
|
67
|
+
- `assumption` is always sent with `assumed`, and with `open` too: your best reading of what the product does,
|
|
68
|
+
which the product side confirms or corrects. Only when you truly have no reading of an `open` question, send
|
|
69
|
+
`no_reading` with the reason in its place.
|
|
70
|
+
- `open` also takes `waits_for`, and only two reasons make a question wait: `"contradiction"` (two objects of the
|
|
71
|
+
export say different things; cite both) or `"business"` (a product decision no reading of the spec can make).
|
|
72
|
+
Anything else is `assumed`: record the assumption and work on.
|
|
73
|
+
- `joins` (`Q-<n>`) instead of a new question when step 2 found another asker's open question on the same matter;
|
|
74
|
+
`extends: Q-<n>` for your own follow-up.
|
|
75
|
+
- When the dispatcher answers with `related` (questions it holds on the same objects), show them to the developer
|
|
76
|
+
in one line each before anything is posted, and post only once it is settled: join one, extend your own, or
|
|
77
|
+
send the question as new.
|
|
78
|
+
Keep the `Q-<n>` it returns. Without the tool, or when the call fails, go on and say the question was not
|
|
79
|
+
recorded.
|
|
66
80
|
8. Say the result, by outcome:
|
|
67
81
|
- `spec`: the answer in the export's business terms with the IDs it rests on. Work on.
|
|
68
82
|
- `assumed`: "Assumed, not decided (Q-<n>):" and the assumption, what it extends and what changes if the product
|
|
@@ -21,7 +21,15 @@ Without a task, ask for it; never guess it.
|
|
|
21
21
|
5. Run `alterspec-client questions <task> --open`, when the dispatcher keeps questions (a failure here doesn't
|
|
22
22
|
stop what follows). Say each open one in a line: work standing on an assumption may still be corrected, and an
|
|
23
23
|
item that waited for an answer is not built. The developer typed the command, so go on.
|
|
24
|
+
When the dispatcher's `task` lists `rework` (a `REWORK-<n>` item beside the checklist: a corrected assumption's
|
|
25
|
+
work), say each one that isn't covered. One whose fix is committed and whose tests pass is covered by naming
|
|
26
|
+
`REWORK-<n>` in an `Alterspec-Covers` trailer and running `alterspec-client progress <task>` again; it carries
|
|
27
|
+
no weight. Never cover one whose fix isn't in the code.
|
|
24
28
|
6. Call `done` with the task, that `commit` and, when `merged` printed one, that `branch` (`{ id, commit, branch }`;
|
|
25
29
|
leave `branch` out when there is none).
|
|
26
30
|
7. Say the result in one line: done, at which commit, on which branch, and that the tasks waiting for it may start
|
|
27
31
|
from that branch. `NOT_IN_BRANCH`, `NOT_YOURS`, `NOT_IN_PROGRESS`: say the dispatcher's sentence.
|
|
32
|
+
`QUESTIONS_OPEN` (an item still waits for an answer), `REWORK_OPEN` (a `REWORK-<n>` item isn't covered),
|
|
33
|
+
`COUPLED_HOLD` (the change ships with its other tracks, which aren't done) and `HELD` (the change is held out of
|
|
34
|
+
the release; done on a feature branch is allowed, on the main branch it is not): say the dispatcher's sentence
|
|
35
|
+
as it is and what it waits for; never retry `done` to get past it.
|
package/developer-guide.md
CHANGED
|
@@ -283,6 +283,9 @@ sentence a later change wrote is asked on that change's task.
|
|
|
283
283
|
nothing.
|
|
284
284
|
- An object that was signed off only after your task's change (the brief says so) is shown as the export holds it
|
|
285
285
|
now: the export never had its earlier text.
|
|
286
|
+
- When the dispatcher sends the list of what changed since your task's export (client 0.31.0), "Changed since"
|
|
287
|
+
names only the objects your task cites, plus the objects that entered the export after it; when none of yours
|
|
288
|
+
changed it says so in one line. An older dispatcher sends no list, and the section stays as above.
|
|
286
289
|
|
|
287
290
|
### One task of your choosing
|
|
288
291
|
|
|
@@ -312,7 +315,10 @@ You don't carry questions to the product owner by hand. When the spec leaves som
|
|
|
312
315
|
A product person confirms or corrects it on the dispatcher's **Questions** page. A correction shows at the top of
|
|
313
316
|
the task's brief, and Claude reworks what stood on the assumption before anything else.
|
|
314
317
|
- **Open** (`Q-13`). Nothing may be assumed. That checklist item stays uncovered and Claude works the others; when
|
|
315
|
-
the answer is there, the brief shows it and the item goes on.
|
|
318
|
+
the answer is there, the brief shows it and the item goes on. Only two things make a question wait: two parts of
|
|
319
|
+
the spec that say different things (both are named), or a business decision no reading of the spec can make.
|
|
320
|
+
Anything else is assumed. An open question still carries Claude's reading of the spec, which the product side
|
|
321
|
+
confirms or corrects; only when there is truly none does it say why.
|
|
316
322
|
|
|
317
323
|
Claude asks not only when it is stuck. Every time it is about to decide how the product behaves where the brief
|
|
318
324
|
doesn't say (which refusal wins, a default, what happens to existing records, a message's wording), it asks first:
|
|
@@ -331,7 +337,10 @@ question extends that question instead of adding a new one, so the product side
|
|
|
331
337
|
three open questions about one object on a task, Claude asks nothing more about it: it writes the cases still
|
|
332
338
|
undecided into one question and builds everything else on the assumptions already recorded. A wish about how the
|
|
333
339
|
product should behave or look, with nothing in the spec read two ways and no item waiting on it, is not a question:
|
|
334
|
-
bring it to the product side as a proposal.
|
|
340
|
+
bring it to the product side as a proposal. When another developer already asked the same open question, Claude
|
|
341
|
+
joins it instead of asking again, and your task waits on its answer like theirs. When the dispatcher answers that it
|
|
342
|
+
holds related questions on the same objects, Claude shows them to you one line each before anything is posted, and
|
|
343
|
+
posts once you settle it: join one, extend your own, or send it as new.
|
|
335
344
|
|
|
336
345
|
How an answer is found: the client first looks whether the question was asked before, then computes where the spec
|
|
337
346
|
would answer it (`lookup`: what the question names, by ID, by the glossary's words and their synonyms, by title; the
|
|
@@ -341,9 +350,16 @@ that it did. So "the spec doesn't say" means the places that would say it were r
|
|
|
341
350
|
nothing.
|
|
342
351
|
|
|
343
352
|
`npx @alterset/alterspec-client questions` prints your questions with their answers, `questions CHG-023/BE` a
|
|
344
|
-
task's; the brief shows the whole change's, so what the backend assumed
|
|
345
|
-
|
|
346
|
-
|
|
353
|
+
task's, `questions Q-12 Q-13` those questions whole; the brief shows the whole change's, so what the backend assumed
|
|
354
|
+
is in front of the web task too. When the dispatcher says which of them bear on your task (asked on your track, or
|
|
355
|
+
answered with a change to one of your items), only those are whole in the brief and the others are one line each,
|
|
356
|
+
naming the command that prints them. A corrected assumption opens a `REWORK-<n>` item beside the checklist: fix what
|
|
357
|
+
stood on it, and cover it with `Alterspec-Covers: REWORK-<n>` once its tests pass; it carries no weight.
|
|
358
|
+
`/alterspec-task-done` names the questions still open and the rework not covered. The dispatcher may refuse
|
|
359
|
+
`done` while an item waits for an answer (`QUESTIONS_OPEN`), a rework item isn't covered (`REWORK_OPEN`), the
|
|
360
|
+
change ships with its other tracks that aren't done (`COUPLED_HOLD`), or the change is held out of the release on
|
|
361
|
+
the main branch (`HELD`); Claude says the dispatcher's sentence and what it waits for, and never retries to get
|
|
362
|
+
past it. An older dispatcher refuses none of these. If the answer changes the product, the product side grooms it into the spec (several answers as one
|
|
347
363
|
change) and signs it off, and it reaches you as a task of its own in a later export. The dispatcher knows which
|
|
348
364
|
of that change's questions your track built already (your task finished after the answer), and the brief opens
|
|
349
365
|
with it under "Built already": such a task checks that the code says what the spec now says, adds the missing tests
|
package/dist/cli.js
CHANGED
|
@@ -112,6 +112,52 @@ var WorkSchema = z.object({
|
|
|
112
112
|
/** The initiatives the changes name, by ID (format 8). Absent when no change names one. */
|
|
113
113
|
initiatives: z.array(WorkInitiativeSchema).optional()
|
|
114
114
|
}).strict();
|
|
115
|
+
var Version = z.string().regex(/^[0-9a-f]{12}$/);
|
|
116
|
+
var TaskRef = z.object({ change: ChangeRef, track: TrackCode }).strict();
|
|
117
|
+
var WorkBriefPartSchema = z.object({
|
|
118
|
+
kind: z.enum(["capability", "used_by", "decision", "object"]),
|
|
119
|
+
key: z.string().min(1),
|
|
120
|
+
/** A file path inside the export, never an anchor; `paragraphs` names a decision's paragraphs. */
|
|
121
|
+
path: z.string().min(1),
|
|
122
|
+
bytes: z.number().int().min(0),
|
|
123
|
+
touched: z.boolean().optional(),
|
|
124
|
+
paragraphs: z.array(z.string().min(1)).optional()
|
|
125
|
+
}).strict();
|
|
126
|
+
var WorkTaskV9Schema = WorkTaskSchema.extend({
|
|
127
|
+
/** The version of every object, item and cited decision paragraph (`DEC-573#p3`) of the task, as of this export. */
|
|
128
|
+
versions: z.record(z.string().min(1), Version).optional(),
|
|
129
|
+
/** The tracks whose existing behaviour this task changes; sorted, never its own track. */
|
|
130
|
+
alters: z.array(TrackCode).optional(),
|
|
131
|
+
brief: z.object({ bytes: z.number().int().min(0), parts: z.array(WorkBriefPartSchema) }).strict().optional(),
|
|
132
|
+
/** The signed-off tasks whose cited objects a later edit changed, which this task exists for. A label only. */
|
|
133
|
+
amends: z.array(TaskRef).optional()
|
|
134
|
+
}).strict().refine((t) => !t.alters?.includes(t.track), {
|
|
135
|
+
message: "alters never names the task's own track",
|
|
136
|
+
path: ["alters"]
|
|
137
|
+
});
|
|
138
|
+
var WorkChangeV9Schema = WorkChangeSchema.extend({
|
|
139
|
+
tasks: z.array(WorkTaskV9Schema).optional(),
|
|
140
|
+
released: z.literal(false).optional(),
|
|
141
|
+
coupled: z.literal(true).optional()
|
|
142
|
+
}).strict().refine((c) => c.released === false ? c.tasks === void 0 : c.tasks !== void 0, {
|
|
143
|
+
message: "a held change (released: false) has no tasks; a released one has tasks",
|
|
144
|
+
path: ["tasks"]
|
|
145
|
+
});
|
|
146
|
+
var WorkReleaseSchema = z.object({
|
|
147
|
+
id: z.string().regex(/^R-\d{4}-\d{2}-\d{2}-\d+$/),
|
|
148
|
+
date: Day,
|
|
149
|
+
note: z.string().max(400).refine((t) => !/[\r\n]/.test(t), { message: "one line" }),
|
|
150
|
+
changes: z.array(ChangeRef),
|
|
151
|
+
held: z.array(ChangeRef),
|
|
152
|
+
touches: z.record(ChangeRef, z.array(z.string().min(1)))
|
|
153
|
+
}).strict();
|
|
154
|
+
var WorkV9Schema = WorkSchema.extend({
|
|
155
|
+
format: z.literal(9),
|
|
156
|
+
changes: z.array(WorkChangeV9Schema),
|
|
157
|
+
/** The path of every object any task names, every decision any task cites, and every initiative. */
|
|
158
|
+
paths: z.record(z.string().min(1), z.string().min(1)).optional(),
|
|
159
|
+
release: WorkReleaseSchema.optional()
|
|
160
|
+
}).strict();
|
|
115
161
|
var WorkChangeV7Schema = WorkChangeSchema.omit({ initiative: true }).strict();
|
|
116
162
|
var WorkV7Schema = WorkSchema.omit({ initiatives: true }).extend({ format: z.literal(7), changes: z.array(WorkChangeV7Schema) }).strict();
|
|
117
163
|
var WorkTaskV6Schema = WorkTaskSchema.omit({ weight: true }).strict();
|
|
@@ -157,7 +203,8 @@ var AnyWorkSchema = z.discriminatedUnion("format", [
|
|
|
157
203
|
WorkV5Schema,
|
|
158
204
|
WorkV6Schema,
|
|
159
205
|
WorkV7Schema,
|
|
160
|
-
WorkSchema
|
|
206
|
+
WorkSchema,
|
|
207
|
+
WorkV9Schema
|
|
161
208
|
]);
|
|
162
209
|
|
|
163
210
|
// src/config.ts
|
|
@@ -554,7 +601,7 @@ var Status = z4.enum(["draft", "ready", "signed_off"], {
|
|
|
554
601
|
var Scope = z4.enum(["own", "team", "org", "all"]);
|
|
555
602
|
var Op = z4.enum(["C", "R", "U", "D", "A"]);
|
|
556
603
|
var Title = z4.string().trim().min(1, { message: "must not be empty" });
|
|
557
|
-
var
|
|
604
|
+
var Version2 = z4.number().int().min(1);
|
|
558
605
|
var StateName = z4.string().regex(/^[a-z][a-z0-9_]*$/, {
|
|
559
606
|
message: "must be a lowercase state name (letters, digits, underscore)"
|
|
560
607
|
});
|
|
@@ -1468,7 +1515,7 @@ var QuestionSchema = z7.object({
|
|
|
1468
1515
|
developer: z7.string(),
|
|
1469
1516
|
at: z7.string(),
|
|
1470
1517
|
question: z7.string(),
|
|
1471
|
-
outcome: z7.enum(["spec", "assumed", "open"]),
|
|
1518
|
+
outcome: z7.enum(["spec", "assumed", "open", "proposal"]),
|
|
1472
1519
|
status: z7.enum(["open", "answered"]),
|
|
1473
1520
|
cites: z7.array(z7.string()).default([]),
|
|
1474
1521
|
answer: z7.string().nullish(),
|
|
@@ -1476,7 +1523,15 @@ var QuestionSchema = z7.object({
|
|
|
1476
1523
|
corrected: z7.boolean().optional(),
|
|
1477
1524
|
/** The product side's mark: the spec now says what the answer says. */
|
|
1478
1525
|
reconciled: z7.boolean().optional(),
|
|
1479
|
-
answers: z7.array(AnswerSchema).default([])
|
|
1526
|
+
answers: z7.array(AnswerSchema).default([]),
|
|
1527
|
+
/** What an open question waits for (wave contract 2.4). */
|
|
1528
|
+
waits_for: z7.enum(["contradiction", "business"]).nullish(),
|
|
1529
|
+
/** Why an open question carries no reading of the spec. */
|
|
1530
|
+
no_reading: z7.string().nullish(),
|
|
1531
|
+
/** The question this one was joined into. */
|
|
1532
|
+
merged_into: z7.string().nullish(),
|
|
1533
|
+
/** The `REWORK-<n>` item a corrected assumption opened on the asking task. */
|
|
1534
|
+
rework: z7.string().nullish()
|
|
1480
1535
|
});
|
|
1481
1536
|
var TaskAnswerSchema = z7.object({
|
|
1482
1537
|
question: z7.string(),
|
|
@@ -1511,7 +1566,7 @@ function missingCites(x, refs) {
|
|
|
1511
1566
|
}
|
|
1512
1567
|
async function listQuestions(session, filter = {}) {
|
|
1513
1568
|
const answer = await callTool(session, "questions", {
|
|
1514
|
-
...filter.task ? { task: filter.task } : filter.about ? { about: filter.about } : { mine: true },
|
|
1569
|
+
...filter.ids?.length ? { ids: filter.ids } : filter.task ? { task: filter.task } : filter.about ? { about: filter.about } : { mine: true },
|
|
1515
1570
|
...filter.open ? { status: "open" } : {}
|
|
1516
1571
|
});
|
|
1517
1572
|
const parsed = z7.array(QuestionSchema).safeParse(answer.questions ?? []);
|
|
@@ -1539,12 +1594,18 @@ function sortQuestions(questions) {
|
|
|
1539
1594
|
return [...questions].sort((a, b) => rank(a) - rank(b));
|
|
1540
1595
|
}
|
|
1541
1596
|
var one = (text) => text.replace(/\s+/g, " ").trim();
|
|
1597
|
+
function stateOf(q) {
|
|
1598
|
+
const last = holding(q);
|
|
1599
|
+
return isCorrected(q) ? "ASSUMPTION CORRECTED" : last ? q.outcome === "assumed" ? "assumption confirmed" : "answered by the product side" : q.outcome === "spec" ? "answered from the spec" : q.outcome === "assumed" ? "open, working on an assumption" : q.outcome === "proposal" ? "a proposal for the product side" : q.merged_into ? `joined into ${q.merged_into}` : q.waits_for === "contradiction" ? "open, waiting for the product side on a contradiction" : "open, waiting for the product side";
|
|
1600
|
+
}
|
|
1542
1601
|
function questionLines(q) {
|
|
1543
1602
|
const about = [q.task, q.item].filter(Boolean).join(" ");
|
|
1544
1603
|
const last = holding(q);
|
|
1545
|
-
const
|
|
1546
|
-
const lines = [`- ${q.id} (${state}${about ? `; ${about}` : ""}): ${one(q.question)}`];
|
|
1604
|
+
const lines = [`- ${q.id} (${stateOf(q)}${about ? `; ${about}` : ""}): ${one(q.question)}`];
|
|
1547
1605
|
if (q.outcome === "assumed" && q.assumption) lines.push(` - Assumed: ${one(q.assumption)}`);
|
|
1606
|
+
if (q.outcome === "open" && q.assumption) lines.push(` - Reading: ${one(q.assumption)}`);
|
|
1607
|
+
if (isCorrected(q) && q.rework)
|
|
1608
|
+
lines.push(` - Rework: ${q.rework}, covered with \`Alterspec-Covers: ${q.rework}\`.`);
|
|
1548
1609
|
if (q.outcome === "spec" && q.answer)
|
|
1549
1610
|
lines.push(` - From the spec: ${one(q.answer)}${q.cites.length ? ` (${q.cites.join(", ")})` : ""}`);
|
|
1550
1611
|
if (last)
|
|
@@ -1557,17 +1618,27 @@ function questionsText(questions) {
|
|
|
1557
1618
|
if (!questions.length) return "No questions.\n";
|
|
1558
1619
|
return sortQuestions(questions).flatMap(questionLines).join("\n") + "\n";
|
|
1559
1620
|
}
|
|
1560
|
-
function
|
|
1621
|
+
function questionLine(q) {
|
|
1622
|
+
const about = [q.task, q.item].filter(Boolean).join(" ");
|
|
1623
|
+
return `- ${q.id} (${about ? `${about}; ` : ""}${stateOf(q)}): \`alterspec-client questions ${q.id}\``;
|
|
1624
|
+
}
|
|
1625
|
+
function questionsSection(questions, full) {
|
|
1561
1626
|
if (!questions.length) return [];
|
|
1562
1627
|
const sorted = sortQuestions(questions);
|
|
1628
|
+
const whole = (q) => !full || full.has(q.id);
|
|
1629
|
+
const lined = sorted.filter((q) => !whole(q)).length;
|
|
1563
1630
|
const corrected = sorted.filter(isCorrected).length;
|
|
1564
1631
|
const open = sorted.filter((q) => q.status === "open").length;
|
|
1565
1632
|
return [
|
|
1566
1633
|
`## Questions (${open} open${corrected ? `, ${corrected} corrected` : ""})`,
|
|
1567
1634
|
"",
|
|
1568
1635
|
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.",
|
|
1636
|
+
...lined ? [
|
|
1637
|
+
"",
|
|
1638
|
+
`Whole: the questions asked on this track or answered with a change to an item of this task. The other ${lined} are one line each; read one with \`alterspec-client questions <id>\` when its object is in front of you.`
|
|
1639
|
+
] : [],
|
|
1569
1640
|
"",
|
|
1570
|
-
...sorted.flatMap(questionLines),
|
|
1641
|
+
...sorted.flatMap((q) => whole(q) ? questionLines(q) : [questionLine(q)]),
|
|
1571
1642
|
""
|
|
1572
1643
|
];
|
|
1573
1644
|
}
|
|
@@ -1600,6 +1671,28 @@ function answersSection(answers) {
|
|
|
1600
1671
|
// src/context.ts
|
|
1601
1672
|
var ContextError = class extends Error {
|
|
1602
1673
|
};
|
|
1674
|
+
function parseQuestionsFull(value) {
|
|
1675
|
+
if (!Array.isArray(value)) return void 0;
|
|
1676
|
+
return new Set(
|
|
1677
|
+
value.flatMap((v) => {
|
|
1678
|
+
const id = typeof v === "string" ? v : v?.id;
|
|
1679
|
+
return typeof id === "string" && id ? [id] : [];
|
|
1680
|
+
})
|
|
1681
|
+
);
|
|
1682
|
+
}
|
|
1683
|
+
function parseChangedSince(value) {
|
|
1684
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1685
|
+
const lists = ["added", "changed", "removed"].map((k) => value[k]);
|
|
1686
|
+
if (!lists.some(Array.isArray)) return void 0;
|
|
1687
|
+
return new Set(
|
|
1688
|
+
lists.flatMap(
|
|
1689
|
+
(l) => Array.isArray(l) ? l.flatMap((v) => {
|
|
1690
|
+
const key = typeof v === "string" ? v : v?.key ?? v?.id;
|
|
1691
|
+
return typeof key === "string" && key ? [key] : [];
|
|
1692
|
+
}) : []
|
|
1693
|
+
)
|
|
1694
|
+
);
|
|
1695
|
+
}
|
|
1603
1696
|
function parseSiblings(value) {
|
|
1604
1697
|
if (!Array.isArray(value)) return void 0;
|
|
1605
1698
|
const str = (v) => typeof v === "string" && v ? v : void 0;
|
|
@@ -1937,9 +2030,9 @@ function compatibilityOf(x, change, work, proposal) {
|
|
|
1937
2030
|
const text = compatibilityText(sectionText(x, x.sectionShard(proposal, COMPATIBILITY_SECTION)));
|
|
1938
2031
|
const crosses = (owner, ownerChange, a) => a.change !== ownerChange && a.track !== owner.track;
|
|
1939
2032
|
const endedBy = x.work.changes.flatMap(
|
|
1940
|
-
(other) => other.tasks.filter((t) => t.after.some((a) => a.change === change.id && crosses(t, other.id, a))).map((t) => `${other.id}/${t.track}`)
|
|
2033
|
+
(other) => (other.tasks ?? []).filter((t) => t.after.some((a) => a.change === change.id && crosses(t, other.id, a))).map((t) => `${other.id}/${t.track}`)
|
|
1941
2034
|
);
|
|
1942
|
-
const kept = text ? { text, tracks: change.tasks.filter((t) => t.track !== "BE").map((t) => t.track), endedBy } : void 0;
|
|
2035
|
+
const kept = text ? { text, tracks: (change.tasks ?? []).filter((t) => t.track !== "BE").map((t) => t.track), endedBy } : void 0;
|
|
1943
2036
|
const byChange = /* @__PURE__ */ new Map();
|
|
1944
2037
|
for (const a of work.after)
|
|
1945
2038
|
if (crosses(work, change.id, a)) byChange.set(a.change, [...byChange.get(a.change) ?? [], a.track]);
|
|
@@ -1964,10 +2057,10 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
1964
2057
|
};
|
|
1965
2058
|
const change = x.work.changes.find((c) => c.id === task.change);
|
|
1966
2059
|
if (!change) throw new ContextError(`${task.change} is not in this export's work.json: pull the export.`);
|
|
1967
|
-
const work = change.tasks.find((t) => t.track === task.track);
|
|
2060
|
+
const work = (change.tasks ?? []).find((t) => t.track === task.track);
|
|
1968
2061
|
if (!work)
|
|
1969
2062
|
throw new ContextError(
|
|
1970
|
-
`${task.change} has no task on ${task.track}: its tracks are ${change.tasks.map((t) => t.track).join(", ") || "none"}.`
|
|
2063
|
+
`${task.change} has no task on ${task.track}: its tracks are ${(change.tasks ?? []).map((t) => t.track).join(", ") || "none"}.`
|
|
1971
2064
|
);
|
|
1972
2065
|
const track = x.work.tracks.find((t) => t.code === task.track);
|
|
1973
2066
|
const proposal = x.proposalPath(task.change);
|
|
@@ -1994,6 +2087,7 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
1994
2087
|
...words2.summary ? { summary: words2.summary } : {},
|
|
1995
2088
|
...words2.weight === void 0 ? {} : { weight: words2.weight },
|
|
1996
2089
|
...questions ? { questions } : {},
|
|
2090
|
+
...questions && state.questionsFull ? { questionsFull: [...state.questionsFull].sort() } : {},
|
|
1997
2091
|
...state.answers?.length ? { answers: state.answers } : {},
|
|
1998
2092
|
...items ? {
|
|
1999
2093
|
checklist: {
|
|
@@ -2072,8 +2166,8 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
2072
2166
|
const idOf2 = (c) => c.slice(4).split(/\s/)[0];
|
|
2073
2167
|
const listed = onList ? chunks.filter((c) => onList.has(idOf2(c))) : chunks;
|
|
2074
2168
|
written2.push(...listed);
|
|
2075
|
-
const
|
|
2076
|
-
const added2 = listed.length -
|
|
2169
|
+
const kept2 = onList ? listed.filter((c) => existed.has(idOf2(c))) : chunks;
|
|
2170
|
+
const added2 = listed.length - kept2.length;
|
|
2077
2171
|
const title = titleOf(x, id);
|
|
2078
2172
|
const rest = [
|
|
2079
2173
|
added2 ? `${added2 === 1 ? "One new criterion is" : `${added2} new criteria are`} whole in its delta above.` : "",
|
|
@@ -2084,8 +2178,8 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
2084
2178
|
id,
|
|
2085
2179
|
path: at(path),
|
|
2086
2180
|
...title ? { title } : {},
|
|
2087
|
-
...
|
|
2088
|
-
...
|
|
2181
|
+
...kept2.length ? { text: kept2.join("").trim() } : {},
|
|
2182
|
+
...kept2.length && rest ? { rest } : {}
|
|
2089
2183
|
}
|
|
2090
2184
|
];
|
|
2091
2185
|
});
|
|
@@ -2219,9 +2313,9 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
2219
2313
|
);
|
|
2220
2314
|
lost2 = s.later.flatMap((l) => {
|
|
2221
2315
|
if (l.entry.binary) return [];
|
|
2222
|
-
const
|
|
2316
|
+
const kept2 = linesOf2(key, l.entry.exported.after ? l.entry.after : void 0);
|
|
2223
2317
|
const gone = [...linesOf2(key, l.entry.exported.before ? l.entry.before : void 0)].filter(
|
|
2224
|
-
(line) => wrote.includes(line) && !
|
|
2318
|
+
(line) => wrote.includes(line) && !kept2.has(line)
|
|
2225
2319
|
);
|
|
2226
2320
|
return gone.length ? [{ change: l.change, lines: gone }] : [];
|
|
2227
2321
|
});
|
|
@@ -2241,17 +2335,24 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
2241
2335
|
}
|
|
2242
2336
|
];
|
|
2243
2337
|
});
|
|
2244
|
-
|
|
2245
|
-
|
|
2338
|
+
const cited = state.changedSince;
|
|
2339
|
+
const kept = cited ? moved.filter((e) => e.entered || cited.has(e.key)) : moved;
|
|
2340
|
+
if (cited) {
|
|
2341
|
+
const elsewhere = moved.length - kept.length;
|
|
2342
|
+
if (elsewhere) ctx.sinceElsewhere = elsewhere;
|
|
2343
|
+
if (!kept.some((e) => !e.entered)) ctx.changedSinceNone = true;
|
|
2344
|
+
}
|
|
2345
|
+
if (kept.length) {
|
|
2346
|
+
ctx.changedSince = kept.sort(
|
|
2246
2347
|
(a, b) => Number(!!b.own) - Number(!!a.own) || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)
|
|
2247
2348
|
);
|
|
2248
|
-
const touched = new Set(
|
|
2349
|
+
const touched = new Set(kept.flatMap((e) => e.changes.map((ch) => ch.id)));
|
|
2249
2350
|
ctx.later = x.work.changes.filter((c) => touched.has(c.id)).map((c) => {
|
|
2250
2351
|
const delta2 = x.proposalPath(c.id)?.replace(/proposal\.md$/, "delta.md");
|
|
2251
2352
|
return {
|
|
2252
2353
|
id: c.id,
|
|
2253
2354
|
title: c.title,
|
|
2254
|
-
...c.tasks.some((t) => t.track === task.track) ? { task: `${c.id}/${task.track}` } : {},
|
|
2355
|
+
...(c.tasks ?? []).some((t) => t.track === task.track) ? { task: `${c.id}/${task.track}` } : {},
|
|
2255
2356
|
...delta2 ? { delta: delta2 } : {}
|
|
2256
2357
|
};
|
|
2257
2358
|
});
|
|
@@ -2331,7 +2432,7 @@ function renderChecklist(c) {
|
|
|
2331
2432
|
...c.summary ? [c.summary, ""] : [],
|
|
2332
2433
|
...c.weight === void 0 ? [] : [`Task weight ${c.weight} of 100.`, ""],
|
|
2333
2434
|
...shippedLines(c),
|
|
2334
|
-
...c.questions?.length ? questionsSection(c.questions) : [],
|
|
2435
|
+
...c.questions?.length ? questionsSection(c.questions, c.questionsFull ? new Set(c.questionsFull) : void 0) : [],
|
|
2335
2436
|
...c.answers?.length ? answersSection(c.answers) : [],
|
|
2336
2437
|
...checklistSection(c),
|
|
2337
2438
|
"",
|
|
@@ -2393,7 +2494,8 @@ function renderContext(c) {
|
|
|
2393
2494
|
`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}\`).`
|
|
2394
2495
|
);
|
|
2395
2496
|
out.push("", ...shippedLines(c));
|
|
2396
|
-
if (c.questions?.length)
|
|
2497
|
+
if (c.questions?.length)
|
|
2498
|
+
out.push(...questionsSection(c.questions, c.questionsFull ? new Set(c.questionsFull) : void 0));
|
|
2397
2499
|
if (c.answers?.length) out.push(...answersSection(c.answers));
|
|
2398
2500
|
out.push(...checklistSection(c));
|
|
2399
2501
|
out.push("", `## Why (${c.proposal.path})`, "", c.proposal.why || "(none written)");
|
|
@@ -2561,8 +2663,20 @@ function renderContext(c) {
|
|
|
2561
2663
|
""
|
|
2562
2664
|
);
|
|
2563
2665
|
}
|
|
2666
|
+
if (c.changedSinceNone && !movedSince.length)
|
|
2667
|
+
out.push(
|
|
2668
|
+
"## Changed since (other tasks\u2019 work)",
|
|
2669
|
+
"",
|
|
2670
|
+
`No part of this task changed (the dispatcher\u2019s list).${c.sinceElsewhere ? ` ${c.sinceElsewhere === 1 ? "One other object" : `${c.sinceElsewhere} other objects`} the brief names ${c.sinceElsewhere === 1 ? "was" : "were"}, in other tasks\u2019 work.` : ""}`,
|
|
2671
|
+
""
|
|
2672
|
+
);
|
|
2564
2673
|
if (c.changedSince?.length) {
|
|
2565
|
-
out.push("## Changed since (other tasks\u2019 work)", "");
|
|
2674
|
+
if (!(c.changedSinceNone && !movedSince.length)) out.push("## Changed since (other tasks\u2019 work)", "");
|
|
2675
|
+
if (c.sinceElsewhere && movedSince.length)
|
|
2676
|
+
out.push(
|
|
2677
|
+
`Only the objects this task cites (the dispatcher\u2019s list); ${c.sinceElsewhere === 1 ? "one other object" : `${c.sinceElsewhere} other objects`} the brief names ${c.sinceElsewhere === 1 ? "was" : "were"} changed in other tasks\u2019 work.`,
|
|
2678
|
+
""
|
|
2679
|
+
);
|
|
2566
2680
|
const names = (e) => `${e.key}${e.title ? ` ${e.title}` : ""}${e.own ? " (this task changes it)" : ""}`;
|
|
2567
2681
|
if (movedSince.length) {
|
|
2568
2682
|
out.push(
|
|
@@ -3436,7 +3550,7 @@ function lookup(x, opts) {
|
|
|
3436
3550
|
}
|
|
3437
3551
|
if (opts.item) add(opts.item);
|
|
3438
3552
|
if (!about.size && opts.task) {
|
|
3439
|
-
const task = x.work.changes.find((c) => c.id === opts.task.change)?.tasks
|
|
3553
|
+
const task = x.work.changes.find((c) => c.id === opts.task.change)?.tasks?.find((t) => t.track === opts.task.track);
|
|
3440
3554
|
for (const key of task?.objects ?? []) if (x.sources.has(key) && !key.startsWith("file:")) add(key);
|
|
3441
3555
|
}
|
|
3442
3556
|
const links = (id) => {
|
|
@@ -3863,6 +3977,8 @@ async function coveredState(loaded, task) {
|
|
|
3863
3977
|
const answers = parseAnswers(answer.answers);
|
|
3864
3978
|
const from = startFrom(task.track, answer.after);
|
|
3865
3979
|
const siblings = parseSiblings(answer.siblings);
|
|
3980
|
+
const questionsFull = parseQuestionsFull(answer.questions_full);
|
|
3981
|
+
const changedSince = parseChangedSince(answer.changed_since);
|
|
3866
3982
|
return {
|
|
3867
3983
|
covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : [])),
|
|
3868
3984
|
// The dispatcher's list is the checklist: its first item list stands (its spec, section 9), so the brief and
|
|
@@ -3876,7 +3992,9 @@ async function coveredState(loaded, task) {
|
|
|
3876
3992
|
} : {},
|
|
3877
3993
|
...answers ? { answers } : {},
|
|
3878
3994
|
...from.length ? { startFrom: from } : {},
|
|
3879
|
-
...siblings?.length ? { siblings } : {}
|
|
3995
|
+
...siblings?.length ? { siblings } : {},
|
|
3996
|
+
...questionsFull ? { questionsFull } : {},
|
|
3997
|
+
...changedSince ? { changedSince } : {}
|
|
3880
3998
|
};
|
|
3881
3999
|
} catch (e) {
|
|
3882
4000
|
return { unknown: e.message.split("\n")[0] };
|
|
@@ -4114,9 +4232,17 @@ program.command("cites").description("check that every reference is an ID or a p
|
|
|
4114
4232
|
`);
|
|
4115
4233
|
})
|
|
4116
4234
|
);
|
|
4117
|
-
program.command("questions").description(
|
|
4118
|
-
|
|
4235
|
+
program.command("questions").description(
|
|
4236
|
+
"print the questions the dispatcher keeps: some by number, a task\u2019s, or without either your own"
|
|
4237
|
+
).argument("[ref...]", "a task, e.g. CHG-012/BE, or questions by number, e.g. Q-12 Q-14").option("--open", "only the ones still open").option("--about <id...>", "everyone\u2019s questions that name these IDs").option("--json", "print them as JSON").action(
|
|
4238
|
+
run(async (refs, opts) => {
|
|
4239
|
+
const ids = refs.filter((r) => /^Q-\d+$/i.test(r)).map((r) => r.toUpperCase());
|
|
4240
|
+
const rest = refs.filter((r) => !/^Q-\d+$/i.test(r));
|
|
4241
|
+
if (rest.length > 1 || rest.length && ids.length)
|
|
4242
|
+
throw new Error("Name one task, or questions by number (Q-<n>), not both.");
|
|
4243
|
+
const id = rest[0];
|
|
4119
4244
|
const questions = await listQuestions(sessionOf(loadConfig()), {
|
|
4245
|
+
...ids.length ? { ids } : {},
|
|
4120
4246
|
...id ? { task: parseTask(id).id } : {},
|
|
4121
4247
|
...opts.about ? { about: opts.about } : {},
|
|
4122
4248
|
...opts.open ? { open: true } : {}
|