@alterset/alterspec-client 0.31.0 → 0.32.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 +14 -2
- package/assets/prompts/spec-ask.md +14 -8
- package/assets/prompts/task-context.md +5 -1
- package/developer-guide.md +18 -2
- package/dist/cli.js +212 -29
- package/dist/cli.js.map +1 -1
- package/dist/work.d.ts +88 -5
- package/dist/work.js +8 -6
- package/dist/work.js.map +1 -1
- package/package.json +1 -1
|
@@ -87,13 +87,25 @@ dispatcher's pages.
|
|
|
87
87
|
item uncovered, work the others, and never name it in `Alterspec-Covers`. Both carry your reading of the spec
|
|
88
88
|
(`assumption`; `no_reading` with the reason only when there truly is none), and an open one says what it waits
|
|
89
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`)
|
|
91
|
-
|
|
90
|
+
open question on the same matter is joined (`joins`), your own follow-up extends it (`extends`). Before anything
|
|
91
|
+
is posted, the questions already held on the same objects are read, answered ones included even when the export
|
|
92
|
+
doesn't hold their answer yet: `ask` comes back `RELATED_FIRST` with that list until the call joins one, extends
|
|
93
|
+
one or says `new: true`, and the `related` an `ask` returns after posting are shown in one line each. The brief (`alterspec-client context`)
|
|
92
94
|
opens with the change's questions on every track and the product side's answers, and `alterspec-client questions
|
|
93
95
|
<task>` prints a task's: an answer to an open one unblocks its item; a corrected assumption is rework, done before
|
|
94
96
|
anything else. An answer that changes the spec comes back one export later as a change of its own; when the brief
|
|
95
97
|
says this track built it already ("Built already"), that task checks the code against the spec's new text and
|
|
96
98
|
rebuilds nothing.
|
|
99
|
+
- **A ruling stands before its export.** The brief's "Ruled, not in the export yet" lists the product side's
|
|
100
|
+
answers on this task's objects that the export doesn't say yet: build on them as on the spec, over the export's
|
|
101
|
+
silence or older wording, and name no question number in code or tests (write the behaviour; the spec catches up
|
|
102
|
+
when the ruling is groomed). When the brief opens with "A ruling changed since you last read this brief", the
|
|
103
|
+
product side replaced an answer you saw: what you built on the earlier one follows the new one, tests included,
|
|
104
|
+
before anything else.
|
|
105
|
+
- **Failing tests after another track shipped are your work.** When the brief says "<TRACK> has shipped this
|
|
106
|
+
change" and that tests of what it removes or changes are expected to fail, those tests are part of this task:
|
|
107
|
+
update them with the work. It is not a question of task order; never ask about it. When the brief says the
|
|
108
|
+
shipped task alters nothing your track does, a failing test is a fault like any other.
|
|
97
109
|
- **A contradiction is asked when it is found, not reported at the end.** Two objects that disagree (a rule and a
|
|
98
110
|
criterion, an entity's lifecycle and a capability, two rules) are one question naming both IDs, asked with
|
|
99
111
|
`/alterspec-spec-ask` the moment you see it; never keep it for `unclear`, where it waits for days among other
|
|
@@ -30,11 +30,14 @@ that follows is that change's task too.
|
|
|
30
30
|
|
|
31
31
|
1. Start as `_shared.md` says (`whoami`, then `export-head`, so the clone is current; keep its `send`). When the
|
|
32
32
|
dispatcher can't be reached or refuses the key, say so in one line and go on from the clone as it is.
|
|
33
|
-
2. Asked before? With a task, `alterspec-client questions <task>` (the brief's questions, on a task you hold)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
answered
|
|
37
|
-
|
|
33
|
+
2. Asked before? With a task, `alterspec-client questions <task>` (the brief's questions, on a task you hold),
|
|
34
|
+
and in every case, once the question's IDs are known (the question's own, else the "about" of the lookup at step
|
|
35
|
+
3, run first then), `alterspec-client questions --about <ID...>`: every task's questions on those objects,
|
|
36
|
+
answered ones included. An answer marked "not in the export yet" is the product side's word the export doesn't
|
|
37
|
+
hold yet. When one of them is this question and the product side answered it, say that answer with its `Q-<n>`
|
|
38
|
+
and stop: nothing is asked or recorded twice, and that answer stands over the export's silence. The same
|
|
39
|
+
question asked from another task is joined at step 7, never asked again. A failure here stops nothing. A
|
|
40
|
+
failing test after another track shipped the change is never a question (`_shared.md`).
|
|
38
41
|
**One question per matter.** When one of them is still open, cites the same object (the same rule, entity,
|
|
39
42
|
integration or moment) and this question is the next case of it (a follow-up to your own question, an edge the
|
|
40
43
|
first one didn't name), this is not a new question: it is a new numbered part of that one. Go on through steps
|
|
@@ -72,9 +75,12 @@ that follows is that change's task too.
|
|
|
72
75
|
Anything else is `assumed`: record the assumption and work on.
|
|
73
76
|
- `joins` (`Q-<n>`) instead of a new question when step 2 found another asker's open question on the same matter;
|
|
74
77
|
`extends: Q-<n>` for your own follow-up.
|
|
75
|
-
-
|
|
76
|
-
in one line each
|
|
77
|
-
|
|
78
|
+
- The client looks once more before it posts: when the dispatcher holds questions on the same objects, `ask`
|
|
79
|
+
comes back `RELATED_FIRST` with them in one line each and nothing is posted. Read the ones that may be this
|
|
80
|
+
matter (`alterspec-client questions <id>`). If one answers it, use that answer and post nothing; else call
|
|
81
|
+
`ask` again with `joins: "Q-<n>"` (another asker's question on the same matter), `extends: "Q-<n>"` (your own),
|
|
82
|
+
or `new: true` (none is this matter). Never send `new: true` without having read the list.
|
|
83
|
+
- When the dispatcher's answer carries `related`, show them to the developer in one line each.
|
|
78
84
|
Keep the `Q-<n>` it returns. Without the tool, or when the call fails, go on and say the question was not
|
|
79
85
|
recorded.
|
|
80
86
|
8. Say the result, by outcome:
|
|
@@ -20,7 +20,11 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
|
|
|
20
20
|
code: read each checklist item against the code first; where the code says what the spec now says, add the test
|
|
21
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
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.
|
|
23
|
+
the brief marks as not built here: the code may hold them already. When it opens with "A ruling changed since you
|
|
24
|
+
last read this brief", rework what stood on the earlier answer first. "Ruled, not in the export yet" lists the
|
|
25
|
+
product side's answers on this task's objects the export doesn't hold yet: build on them as on the spec, naming
|
|
26
|
+
no question number in code or tests. When it says another track "has shipped this change" and tests are expected
|
|
27
|
+
to fail, those tests are this task's to update; never ask about the order of tasks. Then the task's checklist: its items, what
|
|
24
28
|
each is and which the dispatcher holds covered already; that is the work, and its progress. Then why the change
|
|
25
29
|
was made, what changed, the one-time data change when the proposal declares one (what the release does once to the
|
|
26
30
|
records the product already holds; on the backend it is the `CHG-NNN#data-change` item), the delta of each of the
|
package/developer-guide.md
CHANGED
|
@@ -254,8 +254,24 @@ yet: fetch it and base your branch on it, not on main (`git fetch origin task/ch
|
|
|
254
254
|
When another track has finished the same change, the brief says so near its top: "**BE has shipped this change**"
|
|
255
255
|
with its commit and branch (from the dispatcher's `task`, which names the change's other tasks). The server already
|
|
256
256
|
behaves as the change says, so your tests of what the change removes or narrows fail until your task is done:
|
|
257
|
-
updating them is part of your task, not a broken dependency
|
|
258
|
-
|
|
257
|
+
updating them is part of your task, not a broken dependency and not a question of task order, so the agent asks
|
|
258
|
+
nothing about it. When the export says which tracks the shipped task alters (`alters`, `work.json` format 9) and
|
|
259
|
+
yours is not among them, the brief says it alters nothing your track does, and a failing test is an ordinary fault.
|
|
260
|
+
A track still at work is named as "building this change now". The dispatcher offers a shipped change's other tasks
|
|
261
|
+
first.
|
|
262
|
+
|
|
263
|
+
**Rulings the export doesn't hold yet.** When the product side has answered a question about one of your task's
|
|
264
|
+
objects and the answer isn't in the export yet, the brief lists it under "Ruled, not in the export yet": whole when
|
|
265
|
+
it changes an item of your task, else one line with the command that prints it. The agent builds on it as on the
|
|
266
|
+
spec and puts no question number in code or tests; the export says the same once the ruling is groomed. When the
|
|
267
|
+
product side reverses a ruling your brief showed, the next brief opens with "A ruling changed since you last read
|
|
268
|
+
this brief", and `whoami` counts such changes across your tasks.
|
|
269
|
+
|
|
270
|
+
**Asked before?** Before a question is posted, the client asks the dispatcher which questions it already holds on
|
|
271
|
+
the same objects, answered or open. If there are any, `ask` comes back `RELATED_FIRST` with them listed and nothing
|
|
272
|
+
is posted until the agent settles it: it uses an answer that already covers the question, joins another task's
|
|
273
|
+
question on the same matter (`joins`), extends its own (`extends`), or sends the question as new (`new: true`, a
|
|
274
|
+
flag of the client's that the dispatcher never sees). When that look fails, the question is posted as it came.
|
|
259
275
|
|
|
260
276
|
When the change keeps a **compatibility** (its proposal's "Compatibility" section: what the server keeps accepting
|
|
261
277
|
from the apps as they are today), the brief says that instead of "tests will fail": on the backend, which tracks
|
package/dist/cli.js
CHANGED
|
@@ -93,9 +93,8 @@ var WorkChangeSchema = z.object({
|
|
|
93
93
|
initiative: InitiativeRef.optional()
|
|
94
94
|
}).strict();
|
|
95
95
|
var WorkInitiativeSchema = z.object({ id: InitiativeRef, title: z.string().min(1) }).strict();
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
format: z.literal(WORK_FORMAT),
|
|
96
|
+
var WorkV8Schema = z.object({
|
|
97
|
+
format: z.literal(8),
|
|
99
98
|
/** The alterspec version that wrote the export. */
|
|
100
99
|
alterspec: z.string(),
|
|
101
100
|
exported: Day,
|
|
@@ -151,7 +150,7 @@ var WorkReleaseSchema = z.object({
|
|
|
151
150
|
held: z.array(ChangeRef),
|
|
152
151
|
touches: z.record(ChangeRef, z.array(z.string().min(1)))
|
|
153
152
|
}).strict();
|
|
154
|
-
var WorkV9Schema =
|
|
153
|
+
var WorkV9Schema = WorkV8Schema.extend({
|
|
155
154
|
format: z.literal(9),
|
|
156
155
|
changes: z.array(WorkChangeV9Schema),
|
|
157
156
|
/** The path of every object any task names, every decision any task cites, and every initiative. */
|
|
@@ -159,7 +158,7 @@ var WorkV9Schema = WorkSchema.extend({
|
|
|
159
158
|
release: WorkReleaseSchema.optional()
|
|
160
159
|
}).strict();
|
|
161
160
|
var WorkChangeV7Schema = WorkChangeSchema.omit({ initiative: true }).strict();
|
|
162
|
-
var WorkV7Schema =
|
|
161
|
+
var WorkV7Schema = WorkV8Schema.omit({ initiatives: true }).extend({ format: z.literal(7), changes: z.array(WorkChangeV7Schema) }).strict();
|
|
163
162
|
var WorkTaskV6Schema = WorkTaskSchema.omit({ weight: true }).strict();
|
|
164
163
|
var WorkChangeV6Schema = WorkChangeV7Schema.extend({
|
|
165
164
|
tasks: z.array(WorkTaskV6Schema),
|
|
@@ -203,7 +202,7 @@ var AnyWorkSchema = z.discriminatedUnion("format", [
|
|
|
203
202
|
WorkV5Schema,
|
|
204
203
|
WorkV6Schema,
|
|
205
204
|
WorkV7Schema,
|
|
206
|
-
|
|
205
|
+
WorkV8Schema,
|
|
207
206
|
WorkV9Schema
|
|
208
207
|
]);
|
|
209
208
|
|
|
@@ -707,6 +706,11 @@ var ChangeSchema = z5.object({
|
|
|
707
706
|
* `change new --initiative` and `change initiative`, on an archived proposal too.
|
|
708
707
|
*/
|
|
709
708
|
initiative: InitiativeId.optional(),
|
|
709
|
+
/**
|
|
710
|
+
* Set when the change alters behaviour another track already built (`alters` in `work.json`): its server task
|
|
711
|
+
* reaches the main branch only after the change's client tasks are done. A hold, never a cycle in `after`.
|
|
712
|
+
*/
|
|
713
|
+
coupled: z5.literal(true).optional(),
|
|
710
714
|
/** The first 16 hex of the sha256 of the change's `delta.json`, written with it at sign-off, never rewritten. */
|
|
711
715
|
delta: z5.string().regex(/^[0-9a-f]{16}$/).optional(),
|
|
712
716
|
/**
|
|
@@ -1340,6 +1344,65 @@ import { z as z7 } from "zod";
|
|
|
1340
1344
|
|
|
1341
1345
|
// src/mcp.ts
|
|
1342
1346
|
import { createInterface } from "readline";
|
|
1347
|
+
|
|
1348
|
+
// src/related.ts
|
|
1349
|
+
var RELATED_FIRST = "RELATED_FIRST";
|
|
1350
|
+
var SHOWN = 10;
|
|
1351
|
+
var str = (v) => typeof v === "string" && v ? v : void 0;
|
|
1352
|
+
function settled(args) {
|
|
1353
|
+
return Boolean(str(args.joins) || str(args.extends) || args.new === true);
|
|
1354
|
+
}
|
|
1355
|
+
function aboutOf(args) {
|
|
1356
|
+
const cites = Array.isArray(args.cites) ? args.cites : [];
|
|
1357
|
+
const refs = [...cites, args.item].flatMap((r) => {
|
|
1358
|
+
const s = str(r);
|
|
1359
|
+
return s && !s.includes("/") ? [s.trim()] : [];
|
|
1360
|
+
});
|
|
1361
|
+
return [...new Set(refs)];
|
|
1362
|
+
}
|
|
1363
|
+
function forwardedArgs(args) {
|
|
1364
|
+
if (!("new" in args)) return args;
|
|
1365
|
+
const rest = { ...args };
|
|
1366
|
+
delete rest.new;
|
|
1367
|
+
return rest;
|
|
1368
|
+
}
|
|
1369
|
+
function stateOf(q) {
|
|
1370
|
+
const answers = Array.isArray(q.answers) ? q.answers : [];
|
|
1371
|
+
const answered = q.status === "answered" || answers.length > 0;
|
|
1372
|
+
if (str(q.merged_into)) return `joined into ${String(q.merged_into)}`;
|
|
1373
|
+
if (answered)
|
|
1374
|
+
return q.reconciled === true ? "answered, the spec says so now" : "answered, not in the export yet";
|
|
1375
|
+
if (q.outcome === "assumed") return "open, working on an assumption";
|
|
1376
|
+
return "open";
|
|
1377
|
+
}
|
|
1378
|
+
var one = (text, max = 160) => {
|
|
1379
|
+
const t = text.replace(/\s+/g, " ").trim();
|
|
1380
|
+
return t.length > max ? `${t.slice(0, max - 1)}\u2026` : t;
|
|
1381
|
+
};
|
|
1382
|
+
function relatedLines(questions) {
|
|
1383
|
+
if (!Array.isArray(questions)) return [];
|
|
1384
|
+
return questions.flatMap((v) => {
|
|
1385
|
+
const q = v;
|
|
1386
|
+
const id = str(q?.id);
|
|
1387
|
+
if (!q || !id) return [];
|
|
1388
|
+
const task = str(q.task);
|
|
1389
|
+
const text = str(q.question) ?? "";
|
|
1390
|
+
return [`- ${id} (${task ? `${task}; ` : ""}${stateOf(q)}): ${one(text)}`];
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
function relatedRefusal(questions, about = []) {
|
|
1394
|
+
const lines = relatedLines(questions);
|
|
1395
|
+
if (!lines.length) return void 0;
|
|
1396
|
+
const more = lines.length - SHOWN;
|
|
1397
|
+
return [
|
|
1398
|
+
`Not posted: the dispatcher holds ${lines.length === 1 ? "a question" : `${lines.length} questions`} on the same objects. Read ${lines.length === 1 ? "it" : "them"} first (\`alterspec-client questions <id>\` prints one whole); an answer not in the export yet stands over the export's silence.`,
|
|
1399
|
+
...lines.slice(0, SHOWN),
|
|
1400
|
+
...more > 0 ? [`- and ${more} more: \`alterspec-client questions --about ${about.join(" ") || "<ID...>"}\``] : [],
|
|
1401
|
+
'If one of them answers your question, use that answer and post nothing. Otherwise call `ask` again with `joins: "Q-<n>"` (another asker\u2019s question on the same matter: your task waits on its answer), `extends: "Q-<n>"` (your own earlier question: this is its next part), or `new: true` (none of them is this matter).'
|
|
1402
|
+
].join("\n");
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
// src/mcp.ts
|
|
1343
1406
|
var isRequest = (m) => m.method !== void 0 && m.id !== void 0;
|
|
1344
1407
|
async function callTool(session, name, args = {}) {
|
|
1345
1408
|
const res = await session.fetch("/mcp", {
|
|
@@ -1432,6 +1495,16 @@ function runProxy(opts) {
|
|
|
1432
1495
|
return error(id, e.advice);
|
|
1433
1496
|
}
|
|
1434
1497
|
}
|
|
1498
|
+
async function earlier(args) {
|
|
1499
|
+
const about = aboutOf(args);
|
|
1500
|
+
if (!about.length) return void 0;
|
|
1501
|
+
try {
|
|
1502
|
+
const answer = await callTool(session, "questions", { about });
|
|
1503
|
+
return relatedRefusal(answer.questions, about);
|
|
1504
|
+
} catch {
|
|
1505
|
+
return void 0;
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1435
1508
|
async function forward(m) {
|
|
1436
1509
|
try {
|
|
1437
1510
|
const gated = m.method === "tools/list" || m.method === "tools/call";
|
|
@@ -1448,6 +1521,20 @@ function runProxy(opts) {
|
|
|
1448
1521
|
isError: true
|
|
1449
1522
|
});
|
|
1450
1523
|
}
|
|
1524
|
+
if (r === "developer" && tool === "ask") {
|
|
1525
|
+
const args = m.params?.arguments ?? {};
|
|
1526
|
+
const held = settled(args) ? void 0 : await earlier(args);
|
|
1527
|
+
if (held) {
|
|
1528
|
+
log(`ask held: ${RELATED_FIRST}`);
|
|
1529
|
+
if (!isRequest(m)) return;
|
|
1530
|
+
return result(m.id, {
|
|
1531
|
+
content: [{ type: "text", text: held }],
|
|
1532
|
+
structuredContent: { error: { code: RELATED_FIRST, message: held } },
|
|
1533
|
+
isError: true
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
if ("new" in args) m = { ...m, params: { ...m.params, arguments: forwardedArgs(args) } };
|
|
1537
|
+
}
|
|
1451
1538
|
}
|
|
1452
1539
|
const headers = {
|
|
1453
1540
|
"content-type": "application/json",
|
|
@@ -1593,24 +1680,24 @@ function sortQuestions(questions) {
|
|
|
1593
1680
|
const rank = (q) => isCorrected(q) ? 0 : q.status === "open" ? 1 : 2;
|
|
1594
1681
|
return [...questions].sort((a, b) => rank(a) - rank(b));
|
|
1595
1682
|
}
|
|
1596
|
-
var
|
|
1597
|
-
function
|
|
1683
|
+
var one2 = (text) => text.replace(/\s+/g, " ").trim();
|
|
1684
|
+
function stateOf2(q) {
|
|
1598
1685
|
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";
|
|
1686
|
+
return isCorrected(q) ? "ASSUMPTION CORRECTED" : last ? q.outcome === "assumed" ? "assumption confirmed" : q.reconciled ? "answered by the product side" : "answered by the product side, not in the export yet" : 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
1687
|
}
|
|
1601
1688
|
function questionLines(q) {
|
|
1602
1689
|
const about = [q.task, q.item].filter(Boolean).join(" ");
|
|
1603
1690
|
const last = holding(q);
|
|
1604
|
-
const lines = [`- ${q.id} (${
|
|
1605
|
-
if (q.outcome === "assumed" && q.assumption) lines.push(` - Assumed: ${
|
|
1606
|
-
if (q.outcome === "open" && q.assumption) lines.push(` - Reading: ${
|
|
1691
|
+
const lines = [`- ${q.id} (${stateOf2(q)}${about ? `; ${about}` : ""}): ${one2(q.question)}`];
|
|
1692
|
+
if (q.outcome === "assumed" && q.assumption) lines.push(` - Assumed: ${one2(q.assumption)}`);
|
|
1693
|
+
if (q.outcome === "open" && q.assumption) lines.push(` - Reading: ${one2(q.assumption)}`);
|
|
1607
1694
|
if (isCorrected(q) && q.rework)
|
|
1608
1695
|
lines.push(` - Rework: ${q.rework}, covered with \`Alterspec-Covers: ${q.rework}\`.`);
|
|
1609
1696
|
if (q.outcome === "spec" && q.answer)
|
|
1610
|
-
lines.push(` - From the spec: ${
|
|
1697
|
+
lines.push(` - From the spec: ${one2(q.answer)}${q.cites.length ? ` (${q.cites.join(", ")})` : ""}`);
|
|
1611
1698
|
if (last)
|
|
1612
1699
|
lines.push(
|
|
1613
|
-
` - Product side (${last.developer}, ${last.at.slice(0, 10)}): ${
|
|
1700
|
+
` - Product side (${last.developer}, ${last.at.slice(0, 10)}): ${one2(last.text)}${q.reconciled ? " The spec says so now." : `${last.change ? ` It comes into the spec with ${last.change}.` : ""} Not in the export yet: this answer stands over the export\u2019s silence.`}`
|
|
1614
1701
|
);
|
|
1615
1702
|
return lines;
|
|
1616
1703
|
}
|
|
@@ -1620,7 +1707,7 @@ function questionsText(questions) {
|
|
|
1620
1707
|
}
|
|
1621
1708
|
function questionLine(q) {
|
|
1622
1709
|
const about = [q.task, q.item].filter(Boolean).join(" ");
|
|
1623
|
-
return `- ${q.id} (${about ? `${about}; ` : ""}${
|
|
1710
|
+
return `- ${q.id} (${about ? `${about}; ` : ""}${stateOf2(q)}): \`alterspec-client questions ${q.id}\``;
|
|
1624
1711
|
}
|
|
1625
1712
|
function questionsSection(questions, full) {
|
|
1626
1713
|
if (!questions.length) return [];
|
|
@@ -1668,6 +1755,72 @@ function answersSection(answers) {
|
|
|
1668
1755
|
return [`## Built already (${built} of ${answers.length})`, "", how, "", ...answers.map(answerLine), ""];
|
|
1669
1756
|
}
|
|
1670
1757
|
|
|
1758
|
+
// src/ruled.ts
|
|
1759
|
+
var str2 = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
1760
|
+
function rulingOf(v) {
|
|
1761
|
+
if (typeof v === "string")
|
|
1762
|
+
return /^Q-\d+$/.test(v) ? { id: v, path: `alterspec-client questions ${v}` } : void 0;
|
|
1763
|
+
const r = v;
|
|
1764
|
+
if (!r || typeof r !== "object") return void 0;
|
|
1765
|
+
const id = str2(r.id) ?? str2(r.question_id) ?? (/^Q-\d+$/.test(String(r.question)) ? str2(r.question) : void 0);
|
|
1766
|
+
if (!id) return void 0;
|
|
1767
|
+
const answers = Array.isArray(r.answers) ? r.answers : [];
|
|
1768
|
+
const answer = r.answer;
|
|
1769
|
+
const text = r.full === false ? void 0 : str2(answer) ?? str2(answer?.text) ?? str2(r.text) ?? str2(answers.at(-1)?.text);
|
|
1770
|
+
const question = str2(r.title) ?? (str2(r.question) === id ? void 0 : str2(r.question));
|
|
1771
|
+
const about = [str2(r.task), str2(r.item) ?? str2(r.object)].filter(Boolean).join(" ") || void 0;
|
|
1772
|
+
const state = str2(r.state);
|
|
1773
|
+
return {
|
|
1774
|
+
id,
|
|
1775
|
+
...question ? { question } : {},
|
|
1776
|
+
...text ? { text } : {},
|
|
1777
|
+
...about ? { about } : {},
|
|
1778
|
+
...state ? { state } : {},
|
|
1779
|
+
path: str2(r.path) ?? `alterspec-client questions ${id}`
|
|
1780
|
+
};
|
|
1781
|
+
}
|
|
1782
|
+
function parseRuled(value) {
|
|
1783
|
+
if (!Array.isArray(value)) return void 0;
|
|
1784
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
1785
|
+
return value.flatMap((v) => {
|
|
1786
|
+
const r = rulingOf(v);
|
|
1787
|
+
if (!r || seen2.has(r.id)) return [];
|
|
1788
|
+
seen2.add(r.id);
|
|
1789
|
+
return [r];
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
var one3 = (text) => text.replace(/\s+/g, " ").trim();
|
|
1793
|
+
function rulingLines(r) {
|
|
1794
|
+
const head = `- ${r.id}${r.about || r.state ? ` (${[r.about, r.state].filter(Boolean).join("; ")})` : ""}`;
|
|
1795
|
+
if (!r.text) return [`${head}: ${r.question ? `${one3(r.question)} ` : ""}\`${r.path}\``];
|
|
1796
|
+
return [`${head}${r.question ? `: ${one3(r.question)}` : ""}`, ` - Ruled: ${one3(r.text)}`];
|
|
1797
|
+
}
|
|
1798
|
+
function ruledChangedLines(changed) {
|
|
1799
|
+
if (!changed?.length) return [];
|
|
1800
|
+
return [
|
|
1801
|
+
`**A ruling changed since you last read this brief** (${changed.map((r) => r.id).join(", ")}): the product side replaced an answer this task saw. What you built on the earlier answer follows this one; the tests that checked the earlier answer change with it.`,
|
|
1802
|
+
"",
|
|
1803
|
+
...changed.flatMap(rulingLines),
|
|
1804
|
+
""
|
|
1805
|
+
];
|
|
1806
|
+
}
|
|
1807
|
+
function ruledSection(ruled, shownWhole = /* @__PURE__ */ new Set()) {
|
|
1808
|
+
const list2 = (ruled ?? []).filter((r) => !shownWhole.has(r.id));
|
|
1809
|
+
if (!list2.length) return [];
|
|
1810
|
+
const whole = list2.filter((r) => r.text).length;
|
|
1811
|
+
return [
|
|
1812
|
+
"## Ruled, not in the export yet",
|
|
1813
|
+
"",
|
|
1814
|
+
[
|
|
1815
|
+
"The product side has answered these about this task\u2019s objects; the export will say so once the ruling is groomed and signed off. Build on them as you would on the spec, over the export\u2019s silence or older wording. Name no question number in code or tests: write the behaviour, as the spec will.",
|
|
1816
|
+
whole === list2.length ? "" : whole ? `Whole: the ${whole === 1 ? "ruling" : `${whole} rulings`} that change an item of this task; the others are one line each, read with the command they name when their object is in front of you.` : "None changes an item of this task: each is one line, read with the command it names when its object is in front of you."
|
|
1817
|
+
].filter(Boolean).join(" "),
|
|
1818
|
+
"",
|
|
1819
|
+
...list2.flatMap(rulingLines),
|
|
1820
|
+
""
|
|
1821
|
+
];
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1671
1824
|
// src/context.ts
|
|
1672
1825
|
var ContextError = class extends Error {
|
|
1673
1826
|
};
|
|
@@ -1695,15 +1848,15 @@ function parseChangedSince(value) {
|
|
|
1695
1848
|
}
|
|
1696
1849
|
function parseSiblings(value) {
|
|
1697
1850
|
if (!Array.isArray(value)) return void 0;
|
|
1698
|
-
const
|
|
1851
|
+
const str3 = (v) => typeof v === "string" && v ? v : void 0;
|
|
1699
1852
|
return value.flatMap((v) => {
|
|
1700
|
-
const id =
|
|
1701
|
-
const track =
|
|
1702
|
-
const status =
|
|
1853
|
+
const id = str3(v?.id);
|
|
1854
|
+
const track = str3(v?.track) ?? id?.split("/")[1];
|
|
1855
|
+
const status = str3(v?.status);
|
|
1703
1856
|
if (!id || !track || !status) return [];
|
|
1704
|
-
const commit =
|
|
1705
|
-
const branch =
|
|
1706
|
-
const inMain =
|
|
1857
|
+
const commit = str3(v.commit);
|
|
1858
|
+
const branch = str3(v.branch);
|
|
1859
|
+
const inMain = str3(v.in_main_at);
|
|
1707
1860
|
return [
|
|
1708
1861
|
{
|
|
1709
1862
|
id,
|
|
@@ -2118,7 +2271,14 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
2118
2271
|
track,
|
|
2119
2272
|
after: work.after,
|
|
2120
2273
|
...state.startFrom?.length ? { startFrom: state.startFrom } : {},
|
|
2121
|
-
...state.siblings?.length ? {
|
|
2274
|
+
...state.siblings?.length ? {
|
|
2275
|
+
siblings: state.siblings.map((s) => {
|
|
2276
|
+
const alters = (change.tasks ?? []).find((t) => t.track === s.track)?.alters;
|
|
2277
|
+
return alters ? { ...s, alters } : s;
|
|
2278
|
+
})
|
|
2279
|
+
} : {},
|
|
2280
|
+
...state.ruled?.length ? { ruled: state.ruled } : {},
|
|
2281
|
+
...state.ruledChanged?.length ? { ruledChanged: state.ruledChanged } : {},
|
|
2122
2282
|
...compatibilityOf(x, change, work, proposal),
|
|
2123
2283
|
proposal: {
|
|
2124
2284
|
path: proposal,
|
|
@@ -2425,14 +2585,20 @@ function checklistSection(c) {
|
|
|
2425
2585
|
}
|
|
2426
2586
|
return out;
|
|
2427
2587
|
}
|
|
2588
|
+
function wholeQuestions(c) {
|
|
2589
|
+
const full = c.questionsFull ? new Set(c.questionsFull) : void 0;
|
|
2590
|
+
return new Set((c.questions ?? []).filter((q) => !full || full.has(q.id)).map((q) => q.id));
|
|
2591
|
+
}
|
|
2428
2592
|
function renderChecklist(c) {
|
|
2429
2593
|
const out = [
|
|
2430
2594
|
`# ${c.task}: ${c.title ?? c.change.title}`,
|
|
2431
2595
|
"",
|
|
2432
2596
|
...c.summary ? [c.summary, ""] : [],
|
|
2433
2597
|
...c.weight === void 0 ? [] : [`Task weight ${c.weight} of 100.`, ""],
|
|
2598
|
+
...ruledChangedLines(c.ruledChanged),
|
|
2434
2599
|
...shippedLines(c),
|
|
2435
2600
|
...c.questions?.length ? questionsSection(c.questions, c.questionsFull ? new Set(c.questionsFull) : void 0) : [],
|
|
2601
|
+
...ruledSection(c.ruled, wholeQuestions(c)),
|
|
2436
2602
|
...c.answers?.length ? answersSection(c.answers) : [],
|
|
2437
2603
|
...checklistSection(c),
|
|
2438
2604
|
"",
|
|
@@ -2446,8 +2612,9 @@ function shippedLines(c) {
|
|
|
2446
2612
|
for (const s of c.siblings ?? []) {
|
|
2447
2613
|
if (s.status === "done") {
|
|
2448
2614
|
const where = [s.commit?.slice(0, 12), s.in_main_at ? "in main" : s.branch ?? "main"].filter(Boolean).join(", ");
|
|
2615
|
+
const additive = s.alters !== void 0 && !s.alters.includes(c.track.code);
|
|
2449
2616
|
out.push(
|
|
2450
|
-
`**${s.track} has shipped this change** (${where})` + (kept ? ": the server keeps the old behaviour this change\u2019s Compatibility names until the other tracks\u2019 tasks are done (below)." : ": tests that check the behaviour it removes or changes are expected to fail until this task is done; updating them is part of this task."),
|
|
2617
|
+
`**${s.track} has shipped this change** (${where})` + (kept ? ": the server keeps the old behaviour this change\u2019s Compatibility names until the other tracks\u2019 tasks are done (below)." : additive ? `: it alters nothing ${c.track.code} already does, so no test of yours should fail because of it.` : ": tests that check the behaviour it removes or changes are expected to fail until this task is done; updating them is part of this task. This is not a question of task order: don\u2019t ask about it, fix the tests with the work."),
|
|
2451
2618
|
""
|
|
2452
2619
|
);
|
|
2453
2620
|
} else if (s.status === "in_progress") out.push(`${s.track} is building this change now.`, "");
|
|
@@ -2493,9 +2660,10 @@ function renderContext(c) {
|
|
|
2493
2660
|
"",
|
|
2494
2661
|
`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}\`).`
|
|
2495
2662
|
);
|
|
2496
|
-
out.push("", ...shippedLines(c));
|
|
2663
|
+
out.push("", ...ruledChangedLines(c.ruledChanged), ...shippedLines(c));
|
|
2497
2664
|
if (c.questions?.length)
|
|
2498
2665
|
out.push(...questionsSection(c.questions, c.questionsFull ? new Set(c.questionsFull) : void 0));
|
|
2666
|
+
out.push(...ruledSection(c.ruled, wholeQuestions(c)));
|
|
2499
2667
|
if (c.answers?.length) out.push(...answersSection(c.answers));
|
|
2500
2668
|
out.push(...checklistSection(c));
|
|
2501
2669
|
out.push("", `## Why (${c.proposal.path})`, "", c.proposal.why || "(none written)");
|
|
@@ -2797,7 +2965,7 @@ async function listBugs(session, filter = {}) {
|
|
|
2797
2965
|
if (!parsed.success) throw new BugsError("The dispatcher\u2019s bugs are not in a form this client reads.");
|
|
2798
2966
|
return parsed.data;
|
|
2799
2967
|
}
|
|
2800
|
-
var
|
|
2968
|
+
var one4 = (text) => text.replace(/\s+/g, " ").trim();
|
|
2801
2969
|
function bugTaskWords(t) {
|
|
2802
2970
|
const who = t.developer ? ` (${t.developer})` : "";
|
|
2803
2971
|
const where = t.status === "blocked" && t.after.length ? `, after ${t.after.join(", ")}` : t.status === "done" ? t.in_main ? ", in main" : t.branch ? `, on \`${t.branch}\`` : "" : "";
|
|
@@ -2805,9 +2973,9 @@ function bugTaskWords(t) {
|
|
|
2805
2973
|
}
|
|
2806
2974
|
function bugLines(b) {
|
|
2807
2975
|
const state = b.status === "dismissed" ? `dismissed by ${b.dismissed?.by ?? "an admin"}${b.dismissed?.duplicate_of ? `, duplicate of ${b.dismissed.duplicate_of}` : ""}` : b.status;
|
|
2808
|
-
const lines = [`- ${b.id} (${state}; ${b.developer}, ${b.at.slice(0, 10)}): ${
|
|
2976
|
+
const lines = [`- ${b.id} (${state}; ${b.developer}, ${b.at.slice(0, 10)}): ${one4(b.title)}`];
|
|
2809
2977
|
if (b.cites.length) lines.push(` - Cites: ${b.cites.join(", ")}`);
|
|
2810
|
-
if (b.dismissed) lines.push(` - Reason: ${
|
|
2978
|
+
if (b.dismissed) lines.push(` - Reason: ${one4(b.dismissed.reason)}`);
|
|
2811
2979
|
else if (b.tasks.length) lines.push(` - Tasks: ${b.tasks.map(bugTaskWords).join("; ")}`);
|
|
2812
2980
|
return lines;
|
|
2813
2981
|
}
|
|
@@ -3952,6 +4120,17 @@ function whoamiText(me) {
|
|
|
3952
4120
|
if (role === "developer") {
|
|
3953
4121
|
const tracks = Array.isArray(me.tracks) ? me.tracks : [];
|
|
3954
4122
|
if (tracks.length) lines.push(`Tracks: ${tracks.join(", ")}`);
|
|
4123
|
+
const count = (v) => typeof v === "number" ? v : Array.isArray(v) ? v.length : 0;
|
|
4124
|
+
const changed = count(me.ruled_changed);
|
|
4125
|
+
const shipped = count(me.shipped_for_you);
|
|
4126
|
+
if (changed)
|
|
4127
|
+
lines.push(
|
|
4128
|
+
`Rulings changed on your tasks: ${changed} (\`alterspec-client context <task>\` says which and what follows).`
|
|
4129
|
+
);
|
|
4130
|
+
if (shipped)
|
|
4131
|
+
lines.push(
|
|
4132
|
+
`Changes another track has shipped, with a task of yours still open: ${shipped} (the brief says what that means for your tests).`
|
|
4133
|
+
);
|
|
3955
4134
|
}
|
|
3956
4135
|
if (latest?.commit)
|
|
3957
4136
|
lines.push(`Latest ingested export: ${latest.commit}${latest.ordinal ? ` (#${latest.ordinal})` : ""}`);
|
|
@@ -3979,6 +4158,8 @@ async function coveredState(loaded, task) {
|
|
|
3979
4158
|
const siblings = parseSiblings(answer.siblings);
|
|
3980
4159
|
const questionsFull = parseQuestionsFull(answer.questions_full);
|
|
3981
4160
|
const changedSince = parseChangedSince(answer.changed_since);
|
|
4161
|
+
const ruled = parseRuled(answer.ruled);
|
|
4162
|
+
const ruledChanged = parseRuled(answer.ruled_changed);
|
|
3982
4163
|
return {
|
|
3983
4164
|
covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : [])),
|
|
3984
4165
|
// The dispatcher's list is the checklist: its first item list stands (its spec, section 9), so the brief and
|
|
@@ -3994,7 +4175,9 @@ async function coveredState(loaded, task) {
|
|
|
3994
4175
|
...from.length ? { startFrom: from } : {},
|
|
3995
4176
|
...siblings?.length ? { siblings } : {},
|
|
3996
4177
|
...questionsFull ? { questionsFull } : {},
|
|
3997
|
-
...changedSince ? { changedSince } : {}
|
|
4178
|
+
...changedSince ? { changedSince } : {},
|
|
4179
|
+
...ruled?.length ? { ruled } : {},
|
|
4180
|
+
...ruledChanged?.length ? { ruledChanged } : {}
|
|
3998
4181
|
};
|
|
3999
4182
|
} catch (e) {
|
|
4000
4183
|
return { unknown: e.message.split("\n")[0] };
|