@alterset/alterspec-client 0.6.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/assets/prompts/_shared.md +9 -1
- package/assets/prompts/task-context.md +14 -6
- package/assets/prompts/task-done.md +4 -2
- package/developer-guide.md +8 -1
- package/dist/cli.js +212 -43
- package/dist/cli.js.map +1 -1
- package/dist/work.js +2 -1
- package/dist/work.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,11 @@ reference.
|
|
|
28
28
|
another's design is built in that channel's track.
|
|
29
29
|
- **Checklist**: a task's items, such as acceptance criteria (`CAP-CAT-001-AC-03`), screen actions (`SCR-PRC-01.A02`)
|
|
30
30
|
and experience states (`UX-SCR-PRC-01-WEB#error`). Progress counts the items your commits cover.
|
|
31
|
+
- **Then and Shown**: a criterion's `Then` is what the system guarantees (the backend's), its `Shown` what the screen
|
|
32
|
+
shows (a UI track's). A task's checklist holds a criterion for its own part only; one without `Shown` is all the
|
|
33
|
+
backend's.
|
|
34
|
+
- **Feedback**: when a task's checklist is covered, the agent tells the dispatcher what in the spec was unclear, what
|
|
35
|
+
it had to open beyond the brief and what it decided itself, naming IDs, so the product side can fix the spec.
|
|
31
36
|
|
|
32
37
|
## Set up a repository
|
|
33
38
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The CLI is `npx @alterset/alterspec-client`. Below it is written as `alterspec-client`; always run it as
|
|
4
4
|
`npx @alterset/alterspec-client ...` from the repository (or the task's worktree). The dispatcher's tools come from
|
|
5
5
|
the MCP server `dispatcher` that `.mcp.json` starts: `whoami`, `next_task`, `list_tasks`, `list_changes`, `task`,
|
|
6
|
-
`touch`, `set_eta`, `done`, `release`. Progress reaches the dispatcher through `alterspec-client progress`, never by
|
|
6
|
+
`touch`, `set_eta`, `feedback` (when the dispatcher lists it), `done`, `release`. Progress reaches the dispatcher through `alterspec-client progress`, never by
|
|
7
7
|
calling its tool yourself. Never call `force_release` or `mark_done`: they are an administrator's, in the
|
|
8
8
|
dispatcher's pages.
|
|
9
9
|
|
|
@@ -22,6 +22,11 @@ dispatcher's pages.
|
|
|
22
22
|
says how to build it, which is this repository's business. Cite IDs when you refer to it. The clone is read-only:
|
|
23
23
|
never edit, commit or switch branches in it; `alterspec-client` pulls it.
|
|
24
24
|
- **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.
|
|
25
|
+
- **Feedback is how the spec gets better.** Once per task, when its checklist is covered, call `feedback` with three
|
|
26
|
+
short lists, each line naming the spec IDs it is about: `unclear` (what the spec left open or said in two ways),
|
|
27
|
+
`opened` (what you had to read beyond the brief, and why), `decided` (what you decided yourself that the spec
|
|
28
|
+
should have). No code and no copied spec text; empty lists are fine, an invented complaint is not. Skip it when
|
|
29
|
+
the dispatcher has no `feedback` tool.
|
|
25
30
|
- **Progress and ETA are the dispatcher's arithmetic.** Never compute a percentage or a date yourself, and never
|
|
26
31
|
guess one: say what the dispatcher answered. The developer's own date is theirs to set, with
|
|
27
32
|
`/alterspec-task-eta`.
|
|
@@ -67,6 +72,9 @@ Alterspec-Covers: CAP-CAT-001-AC-03, CAP-CAT-002
|
|
|
67
72
|
checklist writes them (`alterspec-client context <task>` lists them). Never an item whose tests don't pass yet,
|
|
68
73
|
never one the checklist lacks, never "all". An item named once stays covered; don't name it again. A commit that
|
|
69
74
|
covers nothing has no `Alterspec-Covers` line.
|
|
75
|
+
- A criterion's `Then` is what the system guarantees, its `Shown` what the screen shows. Build and test only your
|
|
76
|
+
track's part: `Then` on the backend, `Shown` on a UI track. The brief says when the other part is another task's;
|
|
77
|
+
don't build it here, and name the criterion in `Alterspec-Covers` once your part's tests pass.
|
|
70
78
|
|
|
71
79
|
A hook reports the covered items to the dispatcher after each commit, by itself; when it asks, the developer runs
|
|
72
80
|
`alterspec-client progress`. The task is done when its work is in the track's main branch.
|
|
@@ -9,8 +9,11 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
|
|
|
9
9
|
1. Start as `_shared.md` says (`whoami`, `export-head`).
|
|
10
10
|
2. Run `alterspec-client context <task>` and read the brief. It opens with the task's checklist: its items, what
|
|
11
11
|
each is and which the dispatcher holds covered already; that is the work, and its progress. Then why the change
|
|
12
|
-
was made, what changed, the
|
|
13
|
-
|
|
12
|
+
was made, what changed, the one-time data change when the proposal declares one (what the release does once to the
|
|
13
|
+
records the product already holds; on the backend it is the `CHG-NNN#data-change` item), the delta of each of the
|
|
14
|
+
task's objects (before and after) and where each is in the export now, and "Where used": for each entity the task
|
|
15
|
+
changes, the screens, capabilities and rules of the export that show, take, return or guard it, per changed
|
|
16
|
+
attribute; for the backend the changed criteria on the checklist, the operations, and the rules and events those
|
|
14
17
|
criteria or the change's text name, whole, and the capabilities' other criteria, rules and events by their shard
|
|
15
18
|
paths only, to open when one bears on the work, and its entities by path; the decisions and glossary terms the
|
|
16
19
|
change's text names, whole, the other decisions by path. Each hunk of a diff names the section it falls in. For a
|
|
@@ -26,7 +29,12 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
|
|
|
26
29
|
the developer's. A mockup page is the agreed look and behaviour of a screen, a working example to follow, not code
|
|
27
30
|
to copy. When the spec and the code disagree, or the spec is silent, ask the developer; never fill a gap with an
|
|
28
31
|
invented business rule.
|
|
29
|
-
6. Work through the checklist.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
6. Work through the checklist. A criterion item is your track's part of it (`Then` on the backend, `Shown` on a UI
|
|
33
|
+
track); leave the part the brief gives to another task. A contract state item comes with its mockup link
|
|
34
|
+
(`…/SCR-….html?state=<state>`): open that page in that state to see what you build (sign in as one of the
|
|
35
|
+
screen's roles on the channel's `index.html` first; the session stays). For each item, make its
|
|
36
|
+
tests pass, then commit with the trailers of `_shared.md`: `Alterspec-Task: <task>` always, `Alterspec-Covers`
|
|
37
|
+
with the items whose tests pass on that commit. The hook reports them. When the work is merged into the main
|
|
38
|
+
branch, the developer types `/alterspec-task-done <task>`; never report it done yourself.
|
|
39
|
+
7. When every checklist item is covered, send your `feedback` once, as `_shared.md` says, while you still remember
|
|
40
|
+
what the work cost; then tell the developer the task is ready for `/alterspec-task-done <task>` once it is merged.
|
|
@@ -11,5 +11,7 @@ Without a task, ask for it; never guess it.
|
|
|
11
11
|
3. Run `alterspec-client merged <task>`. It prints the commit on the track's main branch that brought the task in,
|
|
12
12
|
or fails when the work isn't there yet: then say so (merge the task's branch, or push the commits carrying the
|
|
13
13
|
trailer, first) and stop. Never report a task done whose work isn't on the main branch.
|
|
14
|
-
4.
|
|
15
|
-
|
|
14
|
+
4. If this conversation built the task and sent no `feedback` for it yet, send it now, as `_shared.md` says (skip
|
|
15
|
+
when the dispatcher has no `feedback` tool, or when you didn't build it here: never invent one).
|
|
16
|
+
5. Call `done` with the task and that commit.
|
|
17
|
+
6. Say the result in one line. `NOT_IN_BRANCH`, `NOT_YOURS`, `NOT_IN_PROGRESS`: say the dispatcher's sentence.
|
package/developer-guide.md
CHANGED
|
@@ -17,6 +17,13 @@ You connect to it with the **alterspec client** (`@alterset/alterspec-client`, p
|
|
|
17
17
|
- A task's **checklist** lists what it must deliver: acceptance criteria (`CAP-CAT-001-AC-03`), screen actions
|
|
18
18
|
(`SCR-PRC-01.A02`), experience states (`UX-SCR-PRC-01-WEB#error`). Progress counts the items your commits cover;
|
|
19
19
|
nobody types percentages.
|
|
20
|
+
- An acceptance criterion may have two outcomes: **Then**, what the system guarantees, and **Shown**, what the
|
|
21
|
+
person sees on the screen. The backend builds and tests the Then, a UI track the Shown, and each task's checklist
|
|
22
|
+
holds the criterion only for its own part; the brief shows you yours and says when the other part is another
|
|
23
|
+
task's. A criterion without Shown is all the backend's.
|
|
24
|
+
- When the checklist is covered, Claude sends the dispatcher short **feedback** on the task: what in the spec was
|
|
25
|
+
unclear, what it had to read beyond the brief, what it decided itself. The product side reads it to fix the spec;
|
|
26
|
+
it is never a grade of your work.
|
|
20
27
|
- When you take a task it is yours until you report it **done** or **release** it; nobody else can.
|
|
21
28
|
- A task is **done** when its work is merged into the track's main branch on the remote.
|
|
22
29
|
|
|
@@ -162,7 +169,7 @@ server. Then talk to it in plain words; the skills do the rest.
|
|
|
162
169
|
| You say or type | What happens |
|
|
163
170
|
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
164
171
|
| "give me work" / `/alterspec-task-next` | takes the next available task on your track and shows the brief; it creates no branch or worktree, you work wherever you like |
|
|
165
|
-
| "let's work on my task" / `/alterspec-task-context` | the task's brief from the spec: why, the checklist, the objects it changes (before and after), the changed acceptance criteria, the rules, events, decisions and glossary terms they and the change name (the rest, and the entities, as paths); for a UI track also the screens, their contracts, mockups and design system |
|
|
172
|
+
| "let's work on my task" / `/alterspec-task-context` | the task's brief from the spec: why, the checklist, the one-time data change if any, the objects it changes (before and after) and where the export uses them, the changed acceptance criteria, the rules, events, decisions and glossary terms they and the change name (the rest, and the entities, as paths); for a UI track also the screens, their contracts, mockups and design system |
|
|
166
173
|
| "what am I on?" / `/alterspec-task-status` | your tasks with progress and ETA, what's available on your tracks, what is blocked and by what |
|
|
167
174
|
| "what does RULE-… say?" / `/alterspec-spec-ask` | answers about the product from the spec, citing IDs; reads only |
|
|
168
175
|
| `/alterspec-task-done CHG-023/BE` | after your branch is merged: reports the task done with the commit that brought it in; refused while the work isn't merged |
|
package/dist/cli.js
CHANGED
|
@@ -28,7 +28,8 @@ var WorkTaskSchema = z.object({
|
|
|
28
28
|
/**
|
|
29
29
|
* The task's checklist, derived from the delta: the acceptance criteria (`<CAP>-AC-NN`), screen actions
|
|
30
30
|
* (`<SCR>.Ann`) and contract states (`<UX-SCR>#<state>`) the change adds or changes, and every other object as
|
|
31
|
-
* its key
|
|
31
|
+
* its key; on `BE`, `<CHG>#data-change` when the proposal declares a one-time data change (alterspec 0.27.0).
|
|
32
|
+
* Sorted, never empty.
|
|
32
33
|
*/
|
|
33
34
|
items: z.array(z.string().min(1)).min(1),
|
|
34
35
|
/** The tasks this one waits for, resolved: the same change's `BE` task, and the track's tasks it builds on. */
|
|
@@ -552,6 +553,7 @@ var mockupPath = (code, screenId) => `${surfaceDir(code)}/mockups/${screenId}.ht
|
|
|
552
553
|
var patternsPath = (code) => `${surfaceDir(code)}/patterns.md`;
|
|
553
554
|
var designSystemPath = (code) => `${surfaceDir(code)}/design-system.md`;
|
|
554
555
|
var OPERATIONS_FILE = "_generated/operations.md";
|
|
556
|
+
var INDEX_FILE = "_generated/index.json";
|
|
555
557
|
var changesDir = (mod) => mod ? `${moduleDir(mod)}/${CHANGES_DIR}` : CHANGES_DIR;
|
|
556
558
|
var archiveDir = (mod) => `${changesDir(mod)}/archive`;
|
|
557
559
|
var CHANGE_PREFIX = String.raw`^(?:${MODULES_DIR}\/[^/]+\/)?${CHANGES_DIR}\/`;
|
|
@@ -601,6 +603,14 @@ function readExport(dir) {
|
|
|
601
603
|
const folder = shardDir(file);
|
|
602
604
|
return has(folder) ? readdirSync(join3(dir, folder)).sort().map((n) => `${folder}/${n}`) : [];
|
|
603
605
|
};
|
|
606
|
+
let indexCache = null;
|
|
607
|
+
const index = () => {
|
|
608
|
+
if (indexCache === null) {
|
|
609
|
+
const text = read(INDEX_FILE);
|
|
610
|
+
indexCache = text ? JSON.parse(text) : void 0;
|
|
611
|
+
}
|
|
612
|
+
return indexCache;
|
|
613
|
+
};
|
|
604
614
|
const proposalPath = (change) => [archiveDir(), ...modules().map((m) => `${m}/changes/archive`)].map((a) => `${a}/${change}/proposal.md`).find(has);
|
|
605
615
|
return {
|
|
606
616
|
dir,
|
|
@@ -627,7 +637,8 @@ function readExport(dir) {
|
|
|
627
637
|
itemShard(file, key) {
|
|
628
638
|
const path = itemShardPath(file, key);
|
|
629
639
|
return has(path) ? path : void 0;
|
|
630
|
-
}
|
|
640
|
+
},
|
|
641
|
+
index
|
|
631
642
|
};
|
|
632
643
|
}
|
|
633
644
|
function idsIn(text, kinds) {
|
|
@@ -642,6 +653,15 @@ function idsIn(text, kinds) {
|
|
|
642
653
|
}
|
|
643
654
|
var frontMatterOf = (text) => splitFrontMatter(text).raw ?? "";
|
|
644
655
|
|
|
656
|
+
// ../src/changes/data-change.ts
|
|
657
|
+
var DATA_CHANGE_SECTION = "One-time data change";
|
|
658
|
+
var DATA_CHANGE_ITEM = "data-change";
|
|
659
|
+
var DATA_CHANGE_RE = new RegExp(`^(CHG-\\d{3,})#${DATA_CHANGE_ITEM}$`);
|
|
660
|
+
function dataChangeText(sectionText2) {
|
|
661
|
+
const text = sectionText2?.trim();
|
|
662
|
+
return text && !/^none\b/i.test(text) ? text : void 0;
|
|
663
|
+
}
|
|
664
|
+
|
|
645
665
|
// ../src/lib/diff.ts
|
|
646
666
|
var linesOf = (text) => text === "" ? [] : text.replace(/\n$/, "").split("\n");
|
|
647
667
|
function diffLines(a, b) {
|
|
@@ -715,6 +735,44 @@ function unifiedDiff(a, b, context = 3) {
|
|
|
715
735
|
return out.join("\n");
|
|
716
736
|
}
|
|
717
737
|
|
|
738
|
+
// ../src/lib/comments.ts
|
|
739
|
+
var blankComments = (text) => text.replace(/<!--[\s\S]*?-->/g, (c) => c.replace(/[^\n]/g, " "));
|
|
740
|
+
|
|
741
|
+
// ../src/spec/criteria.ts
|
|
742
|
+
var PART = /^\s*[-*]?\s*\*\*(Given|When|Then|Shown|And|Covers):?\*\*/i;
|
|
743
|
+
function criterionParts(chunk) {
|
|
744
|
+
const system = [];
|
|
745
|
+
const shown = [];
|
|
746
|
+
let label;
|
|
747
|
+
let inShown = false;
|
|
748
|
+
let hasThen = false;
|
|
749
|
+
for (const raw of blankComments(chunk).split("\n")) {
|
|
750
|
+
const line = raw.trimEnd();
|
|
751
|
+
if (!line.trim() || /^### /.test(line)) continue;
|
|
752
|
+
const m = PART.exec(line);
|
|
753
|
+
if (m && !line.slice(m[0].length).replace(/^:/, "").trim()) continue;
|
|
754
|
+
if (m) {
|
|
755
|
+
label = m[1].toLowerCase();
|
|
756
|
+
if (label === "shown") inShown = true;
|
|
757
|
+
else if (label !== "and") inShown = false;
|
|
758
|
+
if (label === "then") hasThen = true;
|
|
759
|
+
}
|
|
760
|
+
const text = line.trim();
|
|
761
|
+
if (inShown) shown.push(text);
|
|
762
|
+
else {
|
|
763
|
+
system.push(text);
|
|
764
|
+
if (label === "given" || label === "when" || label === "and" && !hasThen) shown.push(text);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
const hasShown = shown.some((l) => PART.exec(l)?.[1]?.toLowerCase() === "shown");
|
|
768
|
+
return {
|
|
769
|
+
system: hasShown && !hasThen ? "" : system.join("\n"),
|
|
770
|
+
shown: hasShown ? shown.join("\n") : "",
|
|
771
|
+
hasThen,
|
|
772
|
+
hasShown
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
|
|
718
776
|
// src/context.ts
|
|
719
777
|
var ContextError = class extends Error {
|
|
720
778
|
};
|
|
@@ -805,22 +863,26 @@ var named = (x, id) => {
|
|
|
805
863
|
const title = titleOf(x, id);
|
|
806
864
|
return title ? `${id} ${title}` : `${id} (not in the export now)`;
|
|
807
865
|
};
|
|
808
|
-
function criterionOf(x, cap, id) {
|
|
866
|
+
function criterionOf(x, cap, id, track) {
|
|
809
867
|
const file = x.fileOf(cap);
|
|
810
868
|
const text = file && x.has(file) ? sectionText(x, x.sectionShard(file, "Acceptance criteria")) : void 0;
|
|
811
869
|
const chunk = text?.split(/^### /m).find((c) => c.split(/\s/)[0] === id);
|
|
812
870
|
if (!chunk) return void 0;
|
|
813
|
-
const
|
|
871
|
+
const parts = criterionParts(chunk.split("\n").slice(1).join("\n"));
|
|
872
|
+
const ui = track !== void 0 && track !== BACKEND;
|
|
873
|
+
const lines = (ui ? parts.shown : parts.system).split("\n").map(
|
|
814
874
|
(l) => l.replace(/^\s*[-*]\s*/, "").replace(/\*\*/g, "").trim()
|
|
815
875
|
).filter(Boolean);
|
|
816
|
-
const
|
|
817
|
-
const kept = (
|
|
818
|
-
|
|
876
|
+
const from = lines.findIndex((l) => (ui ? /^Shown\b/ : /^Then\b/).test(l));
|
|
877
|
+
const kept = (from >= 0 ? lines.slice(from) : lines).filter((l) => !/^Covers:/.test(l));
|
|
878
|
+
const note = ui ? parts.hasThen ? " (what the system guarantees is the BE task\u2019s)" : "" : parts.hasShown ? " (what the screen shows is the UI task\u2019s)" : "";
|
|
879
|
+
return kept.length ? `${kept.join(" ")}${note}` : void 0;
|
|
819
880
|
}
|
|
820
|
-
|
|
881
|
+
var BACKEND = "BE";
|
|
882
|
+
function itemWhat(x, item, entry, track) {
|
|
821
883
|
const ac = /^((CAP-[A-Z]{2,6}-\d{3})-AC-\d{2})$/.exec(item);
|
|
822
884
|
if (ac) {
|
|
823
|
-
const then = criterionOf(x, ac[2], ac[1]);
|
|
885
|
+
const then = criterionOf(x, ac[2], ac[1], track);
|
|
824
886
|
return `acceptance criterion of ${named(x, ac[2])}${then ? `: ${then}` : ""}`;
|
|
825
887
|
}
|
|
826
888
|
const action = /^(SCR-[A-Z]{2,6}-\d{2})\.(A\d{2})$/.exec(item);
|
|
@@ -832,11 +894,13 @@ function itemWhat(x, item, entry) {
|
|
|
832
894
|
const label = line2?.slice(a.length).trim();
|
|
833
895
|
return `action ${a}${label ? ` "${label.replace(/\s*→\s*/, '" \u2192 ')}` : ""}${label && !label.includes("\u2192") ? '"' : ""} on ${named(x, scr)}`;
|
|
834
896
|
}
|
|
835
|
-
const state = /^(UX-(SCR-[A-Z]{2,6}-\d{2})-[A-Z]{2,5})#(.+)$/.exec(item);
|
|
897
|
+
const state = /^(UX-(SCR-[A-Z]{2,6}-\d{2})-([A-Z]{2,5}))#(.+)$/.exec(item);
|
|
836
898
|
if (state) {
|
|
837
|
-
const [, ux, scr, id] = state;
|
|
899
|
+
const [, ux, scr, code, id] = state;
|
|
838
900
|
const rule = /^rule-(.+)$/.exec(id)?.[1];
|
|
839
|
-
|
|
901
|
+
const page = mockupPath(code, scr);
|
|
902
|
+
const open = x.has(page) ? `; open \`${page}?state=${encodeURIComponent(id)}\`` : "";
|
|
903
|
+
return `state "${id}" of ${ux} (${named(x, scr)})${rule ? `: the message of RULE-${rule.toUpperCase()}` : ""}${open}`;
|
|
840
904
|
}
|
|
841
905
|
if (item.startsWith("file:")) {
|
|
842
906
|
const path = item.slice(5);
|
|
@@ -845,6 +909,8 @@ function itemWhat(x, item, entry) {
|
|
|
845
909
|
return `${what2}: \`${path}\`${x.has(path) ? "" : " (not in the export now)"}`;
|
|
846
910
|
}
|
|
847
911
|
if (item.startsWith("term:")) return `glossary term "${item.slice(5)}"`;
|
|
912
|
+
if (DATA_CHANGE_RE.test(item))
|
|
913
|
+
return `the one-time change to the records the product already holds (the proposal's "${DATA_CHANGE_SECTION}", below)`;
|
|
848
914
|
const kind = idKind(item);
|
|
849
915
|
const what = `${kind && KIND_WORDS[kind] ? `${KIND_WORDS[kind]} ` : ""}${named(x, item)}`;
|
|
850
916
|
if (!entry) return what;
|
|
@@ -853,6 +919,60 @@ function itemWhat(x, item, entry) {
|
|
|
853
919
|
const line = firstAdded(item, entry);
|
|
854
920
|
return line ? `${what}, modified: "${line}"` : `${what}, modified (see its delta)`;
|
|
855
921
|
}
|
|
922
|
+
function dataChangeOf(text) {
|
|
923
|
+
const t = dataChangeText(text);
|
|
924
|
+
return t ? { dataChange: t } : {};
|
|
925
|
+
}
|
|
926
|
+
function changedAttributes(entry) {
|
|
927
|
+
if (!entry || !entry.exported.before || !entry.exported.after) return void 0;
|
|
928
|
+
if (entry.before === void 0 || entry.after === void 0) return void 0;
|
|
929
|
+
const names = (raw) => new Map([...raw.matchAll(/^ {2}- name: (.+?)\s*$/gm)].map((m) => [m[1], m.index]));
|
|
930
|
+
const before = splitFrontMatter(entry.before).raw ?? "";
|
|
931
|
+
const after = splitFrontMatter(entry.after).raw ?? "";
|
|
932
|
+
const attr = (raw, from) => {
|
|
933
|
+
const chunk = raw.slice(from).split(/\n(?! {4})/)[0] ?? "";
|
|
934
|
+
return chunk.replace(/^\s*- name: .*\n?/, "");
|
|
935
|
+
};
|
|
936
|
+
const b = names(before);
|
|
937
|
+
const a = names(after);
|
|
938
|
+
const out = /* @__PURE__ */ new Set();
|
|
939
|
+
for (const [n, i] of a) if (!b.has(n) || attr(before, b.get(n)) !== attr(after, i)) out.add(n);
|
|
940
|
+
for (const n of b.keys()) if (!a.has(n)) out.add(n);
|
|
941
|
+
return [...out];
|
|
942
|
+
}
|
|
943
|
+
function whereUsed(x, objects, entries, changed) {
|
|
944
|
+
const index = x.index();
|
|
945
|
+
if (!index) return [];
|
|
946
|
+
const piece = (id, title, file) => ({
|
|
947
|
+
id,
|
|
948
|
+
path: file ?? "",
|
|
949
|
+
title,
|
|
950
|
+
...changed.has(id) ? { changed: true } : {}
|
|
951
|
+
});
|
|
952
|
+
const out = [];
|
|
953
|
+
for (const entity of objects.filter((k) => idKind(k) === "entity")) {
|
|
954
|
+
const attributes = changedAttributes(entries.get(entity)) ?? [];
|
|
955
|
+
for (const attribute of attributes)
|
|
956
|
+
out.push({
|
|
957
|
+
entity,
|
|
958
|
+
attribute,
|
|
959
|
+
screens: index.screens.filter((s) => s.fields.some((f) => f.entity === entity && f.attributes.includes(attribute))).map((s) => piece(s.id, s.title, x.fileOf(s.id))),
|
|
960
|
+
capabilities: index.capabilities.filter(
|
|
961
|
+
(c) => [...c.inputs ?? [], ...c.outputs ?? []].some(
|
|
962
|
+
(d) => "entity" in d && d.entity === entity && d.attributes.includes(attribute)
|
|
963
|
+
)
|
|
964
|
+
).map((c) => piece(c.id, c.title, x.fileOf(c.id))),
|
|
965
|
+
rules: []
|
|
966
|
+
});
|
|
967
|
+
out.push({
|
|
968
|
+
entity,
|
|
969
|
+
screens: index.screens.filter((s) => s.fields.some((f) => f.entity === entity)).map((s) => piece(s.id, s.title, x.fileOf(s.id))),
|
|
970
|
+
capabilities: index.capabilities.filter((c) => c.entities.some((e) => e.entity === entity)).map((c) => piece(c.id, c.title, x.fileOf(c.id))),
|
|
971
|
+
rules: index.rules.filter((r) => r.entities.includes(entity) || (r.guards ?? []).some((g) => g.entity === entity)).map((r) => piece(r.id, r.title, x.fileOf(r.id)))
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
return out;
|
|
975
|
+
}
|
|
856
976
|
function taskContext(x, task, exportDir2, state = {}) {
|
|
857
977
|
const change = x.work.changes.find((c) => c.id === task.change);
|
|
858
978
|
if (!change) throw new ContextError(`${task.change} is not in this export's work.json: pull the export.`);
|
|
@@ -874,7 +994,11 @@ function taskContext(x, task, exportDir2, state = {}) {
|
|
|
874
994
|
checklist: {
|
|
875
995
|
items: items.map((item) => {
|
|
876
996
|
const covered = state.covered?.get(item);
|
|
877
|
-
return {
|
|
997
|
+
return {
|
|
998
|
+
item,
|
|
999
|
+
what: itemWhat(x, item, entries.get(item), task.track),
|
|
1000
|
+
...covered ? { covered } : {}
|
|
1001
|
+
};
|
|
878
1002
|
}),
|
|
879
1003
|
known: state.covered !== void 0,
|
|
880
1004
|
...state.unknown ? { note: state.unknown } : {}
|
|
@@ -893,7 +1017,8 @@ function taskContext(x, task, exportDir2, state = {}) {
|
|
|
893
1017
|
proposal: {
|
|
894
1018
|
path: proposal,
|
|
895
1019
|
why: sectionText(x, x.sectionShard(proposal, "Why")),
|
|
896
|
-
what: sectionText(x, x.sectionShard(proposal, "What changes"))
|
|
1020
|
+
what: sectionText(x, x.sectionShard(proposal, "What changes")),
|
|
1021
|
+
...dataChangeOf(sectionText(x, x.sectionShard(proposal, DATA_CHANGE_SECTION)))
|
|
897
1022
|
},
|
|
898
1023
|
...delta ? { delta: proposal.replace(/proposal\.md$/, "delta.md") } : {},
|
|
899
1024
|
objects: work.objects.map((key) => objectBrief(x, key, entries.get(key), lost.get(key)))
|
|
@@ -921,40 +1046,42 @@ function taskContext(x, task, exportDir2, state = {}) {
|
|
|
921
1046
|
}
|
|
922
1047
|
];
|
|
923
1048
|
};
|
|
1049
|
+
ctx.whereUsed = whereUsed(x, work.objects, entries, changed);
|
|
1050
|
+
const capabilities = work.objects.filter((k) => /^CAP-/.test(k) && x.fileOf(k) && x.has(x.fileOf(k)));
|
|
1051
|
+
const onList = items && new Set(items);
|
|
1052
|
+
ctx.acceptance = capabilities.flatMap((id) => {
|
|
1053
|
+
const path = x.sectionShard(x.fileOf(id), "Acceptance criteria");
|
|
1054
|
+
if (!path) return [];
|
|
1055
|
+
const chunks = (sectionText(x, path) ?? "").split(/^(?=### )/m).filter((c) => c.startsWith("### "));
|
|
1056
|
+
const existed = new Set([...(entries.get(id)?.before ?? "").matchAll(/^### (\S+)/gm)].map((m) => m[1]));
|
|
1057
|
+
const idOf2 = (c) => c.slice(4).split(/\s/)[0];
|
|
1058
|
+
const listed = onList ? chunks.filter((c) => onList.has(idOf2(c))) : chunks;
|
|
1059
|
+
written.push(...listed);
|
|
1060
|
+
const kept = onList ? listed.filter((c) => existed.has(idOf2(c))) : chunks;
|
|
1061
|
+
const added2 = listed.length - kept.length;
|
|
1062
|
+
const title = titleOf(x, id);
|
|
1063
|
+
const rest = [
|
|
1064
|
+
added2 ? `${added2 === 1 ? "One new criterion is" : `${added2} new criteria are`} whole in its delta above.` : "",
|
|
1065
|
+
chunks.length > listed.length ? `Its other criteria: \`${path}\`.` : ""
|
|
1066
|
+
].filter(Boolean).join(" ");
|
|
1067
|
+
return [
|
|
1068
|
+
{
|
|
1069
|
+
id,
|
|
1070
|
+
path,
|
|
1071
|
+
...title ? { title } : {},
|
|
1072
|
+
...kept.length ? { text: kept.join("").trim() } : {},
|
|
1073
|
+
...kept.length && rest ? { rest } : {}
|
|
1074
|
+
}
|
|
1075
|
+
];
|
|
1076
|
+
});
|
|
1077
|
+
if (!ctx.acceptance.length) delete ctx.acceptance;
|
|
924
1078
|
if (track.kind === "backend") {
|
|
925
|
-
const capabilities = work.objects.filter((k) => /^CAP-/.test(k) && x.fileOf(k) && x.has(x.fileOf(k)));
|
|
926
1079
|
const named3 = (kind) => [
|
|
927
1080
|
.../* @__PURE__ */ new Set([
|
|
928
1081
|
...work.objects.filter((k) => idsIn(k, [kind]).length === 1 && idsIn(k, [kind])[0] === k),
|
|
929
1082
|
...capabilities.flatMap((c) => idsIn(frontMatterOf(x.read(x.fileOf(c))), [kind]))
|
|
930
1083
|
])
|
|
931
1084
|
];
|
|
932
|
-
const onList = items && new Set(items);
|
|
933
|
-
ctx.acceptance = capabilities.flatMap((id) => {
|
|
934
|
-
const path = x.sectionShard(x.fileOf(id), "Acceptance criteria");
|
|
935
|
-
if (!path) return [];
|
|
936
|
-
const chunks = (sectionText(x, path) ?? "").split(/^(?=### )/m).filter((c) => c.startsWith("### "));
|
|
937
|
-
const existed = new Set([...(entries.get(id)?.before ?? "").matchAll(/^### (\S+)/gm)].map((m) => m[1]));
|
|
938
|
-
const idOf2 = (c) => c.slice(4).split(/\s/)[0];
|
|
939
|
-
const listed = onList ? chunks.filter((c) => onList.has(idOf2(c))) : chunks;
|
|
940
|
-
written.push(...listed);
|
|
941
|
-
const kept = onList ? listed.filter((c) => existed.has(idOf2(c))) : chunks;
|
|
942
|
-
const added2 = listed.length - kept.length;
|
|
943
|
-
const title = titleOf(x, id);
|
|
944
|
-
const rest = [
|
|
945
|
-
added2 ? `${added2 === 1 ? "One new criterion is" : `${added2} new criteria are`} whole in its delta above.` : "",
|
|
946
|
-
chunks.length > listed.length ? `Its other criteria: \`${path}\`.` : ""
|
|
947
|
-
].filter(Boolean).join(" ");
|
|
948
|
-
return [
|
|
949
|
-
{
|
|
950
|
-
id,
|
|
951
|
-
path,
|
|
952
|
-
...title ? { title } : {},
|
|
953
|
-
...kept.length ? { text: kept.join("").trim() } : {},
|
|
954
|
-
...kept.length && rest ? { rest } : {}
|
|
955
|
-
}
|
|
956
|
-
];
|
|
957
|
-
});
|
|
958
1085
|
const carried = (kind) => {
|
|
959
1086
|
const bearing2 = idsIn(written.join("\n"), [kind]);
|
|
960
1087
|
return [.../* @__PURE__ */ new Set([...named3(kind), ...bearing2])].flatMap((id) => piece(id, bearing2.includes(id)));
|
|
@@ -978,7 +1105,14 @@ function taskContext(x, task, exportDir2, state = {}) {
|
|
|
978
1105
|
}) : [];
|
|
979
1106
|
} else {
|
|
980
1107
|
const existing = (p) => x.has(p) ? p : void 0;
|
|
981
|
-
const
|
|
1108
|
+
const performing = [...x.sources.keys()].filter(
|
|
1109
|
+
(id) => /^SCR-/.test(id) && x.has(contractPath(id, track.code)) && idsIn(frontMatterOf(x.read(x.fileOf(id)) ?? ""), ["capability"]).some(
|
|
1110
|
+
(c) => capabilities.includes(c)
|
|
1111
|
+
)
|
|
1112
|
+
);
|
|
1113
|
+
const screens = [
|
|
1114
|
+
.../* @__PURE__ */ new Set([...work.objects.map(screenOf).filter((s) => !!s), ...performing])
|
|
1115
|
+
];
|
|
982
1116
|
ctx.screens = screens.map((id) => ({
|
|
983
1117
|
id,
|
|
984
1118
|
file: x.fileOf(id),
|
|
@@ -1037,6 +1171,15 @@ function renderContext(c) {
|
|
|
1037
1171
|
}
|
|
1038
1172
|
out.push("", `## Why (${c.proposal.path})`, "", c.proposal.why || "(none written)");
|
|
1039
1173
|
out.push("", "## What changes", "", c.proposal.what || "(none written)");
|
|
1174
|
+
if (c.proposal.dataChange)
|
|
1175
|
+
out.push(
|
|
1176
|
+
"",
|
|
1177
|
+
`## ${DATA_CHANGE_SECTION}`,
|
|
1178
|
+
"",
|
|
1179
|
+
c.track.kind === "backend" ? "What the release does once to the records the product already holds; the backend\u2019s `#data-change` item on the checklist." : "What the release does once to the records the product already holds; the backend\u2019s work, here so the screens read it.",
|
|
1180
|
+
"",
|
|
1181
|
+
c.proposal.dataChange
|
|
1182
|
+
);
|
|
1040
1183
|
out.push("", "## The task\u2019s objects", "");
|
|
1041
1184
|
if (c.delta) out.push(`The whole record of the change: ${c.delta}.`, "");
|
|
1042
1185
|
for (const o of c.objects) {
|
|
@@ -1047,6 +1190,32 @@ function renderContext(c) {
|
|
|
1047
1190
|
if (o.diff) out.push("", o.diff.startsWith("@@") ? fence(o.diff, "diff") : o.diff);
|
|
1048
1191
|
out.push("");
|
|
1049
1192
|
}
|
|
1193
|
+
if (c.whereUsed?.length) {
|
|
1194
|
+
out.push(
|
|
1195
|
+
"## Where used",
|
|
1196
|
+
"",
|
|
1197
|
+
"What the export shows, takes, returns or guards of the entities this task changes, per changed attribute and for the entity as a whole; a screen or capability not in the export isn\u2019t listed.",
|
|
1198
|
+
""
|
|
1199
|
+
);
|
|
1200
|
+
const list2 = (ps) => ps.map((p) => `${p.id}${p.changed ? " (this task changes it)" : ""}`).join(", ");
|
|
1201
|
+
for (const w of c.whereUsed) {
|
|
1202
|
+
if (w.attribute) {
|
|
1203
|
+
const parts = [
|
|
1204
|
+
w.screens.length ? `shown on ${list2(w.screens)}` : "no screen shows it",
|
|
1205
|
+
w.capabilities.length ? `taken or returned by ${list2(w.capabilities)}` : "no capability takes or returns it"
|
|
1206
|
+
];
|
|
1207
|
+
out.push(`- ${w.entity}.${w.attribute}: ${parts.join("; ")}.`);
|
|
1208
|
+
} else {
|
|
1209
|
+
const parts = [
|
|
1210
|
+
w.screens.length ? `shown on ${list2(w.screens)}` : "no screen shows it",
|
|
1211
|
+
w.capabilities.length ? `worked with by ${list2(w.capabilities)}` : "no capability works with it",
|
|
1212
|
+
w.rules.length ? `rules about it: ${list2(w.rules)}` : "no rule about it"
|
|
1213
|
+
];
|
|
1214
|
+
out.push(`- ${w.entity}: ${parts.join("; ")}.`);
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
out.push("");
|
|
1218
|
+
}
|
|
1050
1219
|
const pieces = (title, list2, intro) => {
|
|
1051
1220
|
if (!list2?.length) return;
|
|
1052
1221
|
out.push(`## ${title}`, "");
|
|
@@ -1092,7 +1261,7 @@ function renderContext(c) {
|
|
|
1092
1261
|
"The decisions the change\u2019s text names, whole; the others its objects name, by path."
|
|
1093
1262
|
);
|
|
1094
1263
|
pieces("Terms", c.terms, "The glossary terms the change\u2019s text uses.");
|
|
1095
|
-
if (c.screens) {
|
|
1264
|
+
if (c.screens?.length) {
|
|
1096
1265
|
out.push("## Screens", "");
|
|
1097
1266
|
for (const s of c.screens) {
|
|
1098
1267
|
out.push(`- **${s.id}**: \`${s.file ?? "not in the export"}\``);
|