@alterset/alterspec-client 0.6.0 → 0.8.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 +9 -4
- package/assets/prompts/task-done.md +4 -2
- package/developer-guide.md +7 -0
- package/dist/cli.js +96 -40
- package/dist/cli.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.
|
|
@@ -26,7 +26,12 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
|
|
|
26
26
|
the developer's. A mockup page is the agreed look and behaviour of a screen, a working example to follow, not code
|
|
27
27
|
to copy. When the spec and the code disagree, or the spec is silent, ask the developer; never fill a gap with an
|
|
28
28
|
invented business rule.
|
|
29
|
-
6. Work through the checklist.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
6. Work through the checklist. A criterion item is your track's part of it (`Then` on the backend, `Shown` on a UI
|
|
30
|
+
track); leave the part the brief gives to another task. A contract state item comes with its mockup link
|
|
31
|
+
(`…/SCR-….html?state=<state>`): open that page in that state to see what you build (sign in as one of the
|
|
32
|
+
screen's roles on the channel's `index.html` first; the session stays). For each item, make its
|
|
33
|
+
tests pass, then commit with the trailers of `_shared.md`: `Alterspec-Task: <task>` always, `Alterspec-Covers`
|
|
34
|
+
with the items whose tests pass on that commit. The hook reports them. When the work is merged into the main
|
|
35
|
+
branch, the developer types `/alterspec-task-done <task>`; never report it done yourself.
|
|
36
|
+
7. When every checklist item is covered, send your `feedback` once, as `_shared.md` says, while you still remember
|
|
37
|
+
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
|
|
package/dist/cli.js
CHANGED
|
@@ -715,6 +715,44 @@ function unifiedDiff(a, b, context = 3) {
|
|
|
715
715
|
return out.join("\n");
|
|
716
716
|
}
|
|
717
717
|
|
|
718
|
+
// ../src/lib/comments.ts
|
|
719
|
+
var blankComments = (text) => text.replace(/<!--[\s\S]*?-->/g, (c) => c.replace(/[^\n]/g, " "));
|
|
720
|
+
|
|
721
|
+
// ../src/spec/criteria.ts
|
|
722
|
+
var PART = /^\s*[-*]?\s*\*\*(Given|When|Then|Shown|And|Covers):?\*\*/i;
|
|
723
|
+
function criterionParts(chunk) {
|
|
724
|
+
const system = [];
|
|
725
|
+
const shown = [];
|
|
726
|
+
let label;
|
|
727
|
+
let inShown = false;
|
|
728
|
+
let hasThen = false;
|
|
729
|
+
for (const raw of blankComments(chunk).split("\n")) {
|
|
730
|
+
const line = raw.trimEnd();
|
|
731
|
+
if (!line.trim() || /^### /.test(line)) continue;
|
|
732
|
+
const m = PART.exec(line);
|
|
733
|
+
if (m && !line.slice(m[0].length).replace(/^:/, "").trim()) continue;
|
|
734
|
+
if (m) {
|
|
735
|
+
label = m[1].toLowerCase();
|
|
736
|
+
if (label === "shown") inShown = true;
|
|
737
|
+
else if (label !== "and") inShown = false;
|
|
738
|
+
if (label === "then") hasThen = true;
|
|
739
|
+
}
|
|
740
|
+
const text = line.trim();
|
|
741
|
+
if (inShown) shown.push(text);
|
|
742
|
+
else {
|
|
743
|
+
system.push(text);
|
|
744
|
+
if (label === "given" || label === "when" || label === "and" && !hasThen) shown.push(text);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
const hasShown = shown.some((l) => PART.exec(l)?.[1]?.toLowerCase() === "shown");
|
|
748
|
+
return {
|
|
749
|
+
system: hasShown && !hasThen ? "" : system.join("\n"),
|
|
750
|
+
shown: hasShown ? shown.join("\n") : "",
|
|
751
|
+
hasThen,
|
|
752
|
+
hasShown
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
|
|
718
756
|
// src/context.ts
|
|
719
757
|
var ContextError = class extends Error {
|
|
720
758
|
};
|
|
@@ -805,22 +843,26 @@ var named = (x, id) => {
|
|
|
805
843
|
const title = titleOf(x, id);
|
|
806
844
|
return title ? `${id} ${title}` : `${id} (not in the export now)`;
|
|
807
845
|
};
|
|
808
|
-
function criterionOf(x, cap, id) {
|
|
846
|
+
function criterionOf(x, cap, id, track) {
|
|
809
847
|
const file = x.fileOf(cap);
|
|
810
848
|
const text = file && x.has(file) ? sectionText(x, x.sectionShard(file, "Acceptance criteria")) : void 0;
|
|
811
849
|
const chunk = text?.split(/^### /m).find((c) => c.split(/\s/)[0] === id);
|
|
812
850
|
if (!chunk) return void 0;
|
|
813
|
-
const
|
|
851
|
+
const parts = criterionParts(chunk.split("\n").slice(1).join("\n"));
|
|
852
|
+
const ui = track !== void 0 && track !== BACKEND;
|
|
853
|
+
const lines = (ui ? parts.shown : parts.system).split("\n").map(
|
|
814
854
|
(l) => l.replace(/^\s*[-*]\s*/, "").replace(/\*\*/g, "").trim()
|
|
815
855
|
).filter(Boolean);
|
|
816
|
-
const
|
|
817
|
-
const kept = (
|
|
818
|
-
|
|
856
|
+
const from = lines.findIndex((l) => (ui ? /^Shown\b/ : /^Then\b/).test(l));
|
|
857
|
+
const kept = (from >= 0 ? lines.slice(from) : lines).filter((l) => !/^Covers:/.test(l));
|
|
858
|
+
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)" : "";
|
|
859
|
+
return kept.length ? `${kept.join(" ")}${note}` : void 0;
|
|
819
860
|
}
|
|
820
|
-
|
|
861
|
+
var BACKEND = "BE";
|
|
862
|
+
function itemWhat(x, item, entry, track) {
|
|
821
863
|
const ac = /^((CAP-[A-Z]{2,6}-\d{3})-AC-\d{2})$/.exec(item);
|
|
822
864
|
if (ac) {
|
|
823
|
-
const then = criterionOf(x, ac[2], ac[1]);
|
|
865
|
+
const then = criterionOf(x, ac[2], ac[1], track);
|
|
824
866
|
return `acceptance criterion of ${named(x, ac[2])}${then ? `: ${then}` : ""}`;
|
|
825
867
|
}
|
|
826
868
|
const action = /^(SCR-[A-Z]{2,6}-\d{2})\.(A\d{2})$/.exec(item);
|
|
@@ -832,11 +874,13 @@ function itemWhat(x, item, entry) {
|
|
|
832
874
|
const label = line2?.slice(a.length).trim();
|
|
833
875
|
return `action ${a}${label ? ` "${label.replace(/\s*→\s*/, '" \u2192 ')}` : ""}${label && !label.includes("\u2192") ? '"' : ""} on ${named(x, scr)}`;
|
|
834
876
|
}
|
|
835
|
-
const state = /^(UX-(SCR-[A-Z]{2,6}-\d{2})-[A-Z]{2,5})#(.+)$/.exec(item);
|
|
877
|
+
const state = /^(UX-(SCR-[A-Z]{2,6}-\d{2})-([A-Z]{2,5}))#(.+)$/.exec(item);
|
|
836
878
|
if (state) {
|
|
837
|
-
const [, ux, scr, id] = state;
|
|
879
|
+
const [, ux, scr, code, id] = state;
|
|
838
880
|
const rule = /^rule-(.+)$/.exec(id)?.[1];
|
|
839
|
-
|
|
881
|
+
const page = mockupPath(code, scr);
|
|
882
|
+
const open = x.has(page) ? `; open \`${page}?state=${encodeURIComponent(id)}\`` : "";
|
|
883
|
+
return `state "${id}" of ${ux} (${named(x, scr)})${rule ? `: the message of RULE-${rule.toUpperCase()}` : ""}${open}`;
|
|
840
884
|
}
|
|
841
885
|
if (item.startsWith("file:")) {
|
|
842
886
|
const path = item.slice(5);
|
|
@@ -874,7 +918,11 @@ function taskContext(x, task, exportDir2, state = {}) {
|
|
|
874
918
|
checklist: {
|
|
875
919
|
items: items.map((item) => {
|
|
876
920
|
const covered = state.covered?.get(item);
|
|
877
|
-
return {
|
|
921
|
+
return {
|
|
922
|
+
item,
|
|
923
|
+
what: itemWhat(x, item, entries.get(item), task.track),
|
|
924
|
+
...covered ? { covered } : {}
|
|
925
|
+
};
|
|
878
926
|
}),
|
|
879
927
|
known: state.covered !== void 0,
|
|
880
928
|
...state.unknown ? { note: state.unknown } : {}
|
|
@@ -921,40 +969,41 @@ function taskContext(x, task, exportDir2, state = {}) {
|
|
|
921
969
|
}
|
|
922
970
|
];
|
|
923
971
|
};
|
|
972
|
+
const capabilities = work.objects.filter((k) => /^CAP-/.test(k) && x.fileOf(k) && x.has(x.fileOf(k)));
|
|
973
|
+
const onList = items && new Set(items);
|
|
974
|
+
ctx.acceptance = capabilities.flatMap((id) => {
|
|
975
|
+
const path = x.sectionShard(x.fileOf(id), "Acceptance criteria");
|
|
976
|
+
if (!path) return [];
|
|
977
|
+
const chunks = (sectionText(x, path) ?? "").split(/^(?=### )/m).filter((c) => c.startsWith("### "));
|
|
978
|
+
const existed = new Set([...(entries.get(id)?.before ?? "").matchAll(/^### (\S+)/gm)].map((m) => m[1]));
|
|
979
|
+
const idOf2 = (c) => c.slice(4).split(/\s/)[0];
|
|
980
|
+
const listed = onList ? chunks.filter((c) => onList.has(idOf2(c))) : chunks;
|
|
981
|
+
written.push(...listed);
|
|
982
|
+
const kept = onList ? listed.filter((c) => existed.has(idOf2(c))) : chunks;
|
|
983
|
+
const added2 = listed.length - kept.length;
|
|
984
|
+
const title = titleOf(x, id);
|
|
985
|
+
const rest = [
|
|
986
|
+
added2 ? `${added2 === 1 ? "One new criterion is" : `${added2} new criteria are`} whole in its delta above.` : "",
|
|
987
|
+
chunks.length > listed.length ? `Its other criteria: \`${path}\`.` : ""
|
|
988
|
+
].filter(Boolean).join(" ");
|
|
989
|
+
return [
|
|
990
|
+
{
|
|
991
|
+
id,
|
|
992
|
+
path,
|
|
993
|
+
...title ? { title } : {},
|
|
994
|
+
...kept.length ? { text: kept.join("").trim() } : {},
|
|
995
|
+
...kept.length && rest ? { rest } : {}
|
|
996
|
+
}
|
|
997
|
+
];
|
|
998
|
+
});
|
|
999
|
+
if (!ctx.acceptance.length) delete ctx.acceptance;
|
|
924
1000
|
if (track.kind === "backend") {
|
|
925
|
-
const capabilities = work.objects.filter((k) => /^CAP-/.test(k) && x.fileOf(k) && x.has(x.fileOf(k)));
|
|
926
1001
|
const named3 = (kind) => [
|
|
927
1002
|
.../* @__PURE__ */ new Set([
|
|
928
1003
|
...work.objects.filter((k) => idsIn(k, [kind]).length === 1 && idsIn(k, [kind])[0] === k),
|
|
929
1004
|
...capabilities.flatMap((c) => idsIn(frontMatterOf(x.read(x.fileOf(c))), [kind]))
|
|
930
1005
|
])
|
|
931
1006
|
];
|
|
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
1007
|
const carried = (kind) => {
|
|
959
1008
|
const bearing2 = idsIn(written.join("\n"), [kind]);
|
|
960
1009
|
return [.../* @__PURE__ */ new Set([...named3(kind), ...bearing2])].flatMap((id) => piece(id, bearing2.includes(id)));
|
|
@@ -978,7 +1027,14 @@ function taskContext(x, task, exportDir2, state = {}) {
|
|
|
978
1027
|
}) : [];
|
|
979
1028
|
} else {
|
|
980
1029
|
const existing = (p) => x.has(p) ? p : void 0;
|
|
981
|
-
const
|
|
1030
|
+
const performing = [...x.sources.keys()].filter(
|
|
1031
|
+
(id) => /^SCR-/.test(id) && x.has(contractPath(id, track.code)) && idsIn(frontMatterOf(x.read(x.fileOf(id)) ?? ""), ["capability"]).some(
|
|
1032
|
+
(c) => capabilities.includes(c)
|
|
1033
|
+
)
|
|
1034
|
+
);
|
|
1035
|
+
const screens = [
|
|
1036
|
+
.../* @__PURE__ */ new Set([...work.objects.map(screenOf).filter((s) => !!s), ...performing])
|
|
1037
|
+
];
|
|
982
1038
|
ctx.screens = screens.map((id) => ({
|
|
983
1039
|
id,
|
|
984
1040
|
file: x.fileOf(id),
|
|
@@ -1092,7 +1148,7 @@ function renderContext(c) {
|
|
|
1092
1148
|
"The decisions the change\u2019s text names, whole; the others its objects name, by path."
|
|
1093
1149
|
);
|
|
1094
1150
|
pieces("Terms", c.terms, "The glossary terms the change\u2019s text uses.");
|
|
1095
|
-
if (c.screens) {
|
|
1151
|
+
if (c.screens?.length) {
|
|
1096
1152
|
out.push("## Screens", "");
|
|
1097
1153
|
for (const s of c.screens) {
|
|
1098
1154
|
out.push(`- **${s.id}**: \`${s.file ?? "not in the export"}\``);
|