@alterset/alterspec-client 0.19.1 → 0.23.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 +1 -0
- package/assets/prompts/_shared.md +24 -7
- package/assets/prompts/agents/spec-answerer.md +3 -1
- package/assets/prompts/spec-ask.md +2 -1
- package/assets/prompts/task-context.md +4 -2
- package/assets/skills/alterspec-spec-ask/SKILL.md +1 -1
- package/developer-guide.md +21 -4
- package/dist/cli.js +141 -42
- package/dist/cli.js.map +1 -1
- package/dist/work.d.ts +274 -13
- package/dist/work.js +65 -13
- package/dist/work.js.map +1 -1
- package/dist/work.schema.json +466 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,6 +59,7 @@ npx @alterset/alterspec-client init --dispatcher https://<dispatcher> --export .
|
|
|
59
59
|
| `--track <code...>` | The tracks this repository builds (`BE`, `BO`, …). Several are allowed: `--track BE BO`. |
|
|
60
60
|
| `--key <key>` | The public key to sign with, as a `.pub` path or the key line. Default: the first `ssh-ed25519` key in ssh-agent, then `~/.ssh/id_ed25519.pub`. |
|
|
61
61
|
| `--branch <name>` | The track's main branch. Default: the remote's `HEAD`, else `main`. |
|
|
62
|
+
| `--npx <flags>` | Flags this project runs npx with, comma-separated (`--npx=--min-release-age=0`). Kept as `npx.args` in the configuration and written into `.mcp.json`, the hook, the skills and the prompts; `--npx=` removes them. |
|
|
62
63
|
| `--force` | Replace skills you modified. |
|
|
63
64
|
|
|
64
65
|
`init` writes:
|
|
@@ -33,12 +33,22 @@ dispatcher's pages.
|
|
|
33
33
|
spec as it is now. What later changes did is listed at the brief's end as their tasks' work: never build it in
|
|
34
34
|
this task, and never ask a question of this task about a sentence a later change wrote.
|
|
35
35
|
- **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.
|
|
36
|
-
- **Feedback is how the spec gets better.** Once per task, when its checklist
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
- **Feedback is how the spec gets better, and it never restates a question.** Once per task, when its checklist
|
|
37
|
+
is covered, call `feedback` with three short lists. What you asked is on the task already, with its answer: the
|
|
38
|
+
product side reads the questions beside the feedback, so a question said again is a line someone must close by
|
|
39
|
+
hand.
|
|
40
|
+
- `unclear`: what in the spec cost you work and was **not** a question, each line naming the spec IDs it is
|
|
41
|
+
about (a sentence that took three readings, a term used for two things, a fact that sat far from where it was
|
|
42
|
+
needed). Never a question that was asked: no `Q-<n>` on these lines and no question said again. A task whose
|
|
43
|
+
every difficulty was asked sends an empty `unclear`.
|
|
44
|
+
- `decided`: one line per assumption you built on, and the line is its `Q-<n>` and nothing more: no object ID
|
|
45
|
+
and no retelling, so the line closes with its question. A decision without a `Q-<n>` was taken silently: ask
|
|
46
|
+
it now, before the feedback, and send the number you get.
|
|
47
|
+
- `opened`: what you had to read beyond the brief, and why, naming the IDs. It is read by whoever builds the
|
|
48
|
+
brief, as a count of how often each ID was opened, not by the product side: name the object, not a complaint.
|
|
49
|
+
|
|
50
|
+
No code and no copied spec text; empty lists are fine, an invented complaint is not. Skip it when the dispatcher
|
|
51
|
+
has no `feedback` tool.
|
|
42
52
|
- **A question is asked, never guessed.** When the spec is silent, ambiguous or says two things about what you are
|
|
43
53
|
building, use `/alterspec-spec-ask` with the question; don't stop the developer for it and don't decide it. Its
|
|
44
54
|
answer is one of three. *From the spec*, with the IDs it rests on: work on. *Assumed* (`Q-<n>`): the spec doesn't
|
|
@@ -50,6 +60,13 @@ dispatcher's pages.
|
|
|
50
60
|
anything else. An answer that changes the spec comes back one export later as a change of its own; when the brief
|
|
51
61
|
says this track built it already ("Built already"), that task checks the code against the spec's new text and
|
|
52
62
|
rebuilds nothing.
|
|
63
|
+
- **A contradiction is asked when it is found, not reported at the end.** Two objects that disagree (a rule and a
|
|
64
|
+
criterion, an entity's lifecycle and a capability, two rules) are one question naming both IDs, asked with
|
|
65
|
+
`/alterspec-spec-ask` the moment you see it; never keep it for `unclear`, where it waits for days among other
|
|
66
|
+
lines. A generated view (`_generated/visibility.md`, `_generated/rule-matrix.md`) that disagrees with the text
|
|
67
|
+
of the object it was generated from is the same case: first read the view's own "How to read" lines, and when
|
|
68
|
+
it still disagrees, ask one question naming the view and the object. One question per matter, as always: a
|
|
69
|
+
second disagreement about the same object is a part of the first question.
|
|
53
70
|
- **A decision about the product is recorded when it is made, not when the task ends.** Whenever you are about to
|
|
54
71
|
build behaviour the brief doesn't state, you are deciding for the product: which refusal wins when two apply, a
|
|
55
72
|
default, an order, a limit, what happens to records that already exist, the wording of a message, what an input
|
|
@@ -105,7 +122,7 @@ Alterspec-Covers: CAP-CAT-001-AC-03, CAP-CAT-002
|
|
|
105
122
|
- `Alterspec-Task` always, the task exactly as the dispatcher wrote it.
|
|
106
123
|
- `Alterspec-Covers` only on the commit with which an item's tests pass, naming those items exactly as the task's
|
|
107
124
|
checklist writes them (`alterspec-client context <task>` lists them). Never an item whose tests don't pass yet,
|
|
108
|
-
never one the checklist lacks, never "all". An item named once stays covered; don't name it again. A commit that
|
|
125
|
+
never one the checklist lacks, never one marked `w 0` (nothing your track builds), never "all". An item named once stays covered; don't name it again. A commit that
|
|
109
126
|
covers nothing has no `Alterspec-Covers` line.
|
|
110
127
|
- A criterion's `Then` is what the system guarantees, its `Shown` what the screen shows. Build and test only your
|
|
111
128
|
track's part: `Then` on the backend, `Shown` on a UI track. The brief says when the other part is another task's;
|
|
@@ -56,7 +56,9 @@ Exactly one of three outcomes. Which one is decided by what you can cite, never
|
|
|
56
56
|
- **`spec`**: the export says it. Every part of the answer stands on something you opened; name each as the ID it
|
|
57
57
|
is in (`RULE-PRC-001`, `CAP-PRC-001-AC-02`, `SCR-PRC-01.A02`, `DEC-004`) with the shard or file path. If one part
|
|
58
58
|
of the answer has nothing to cite, the outcome is not `spec`. Two places that say different things are not an
|
|
59
|
-
answer: that is `open`, citing both.
|
|
59
|
+
answer: that is `open`, citing both. A generated view (`_generated/visibility.md`, `_generated/rule-matrix.md`)
|
|
60
|
+
against the text of the object it was generated from is such a pair, once the view's own "How to read" lines
|
|
61
|
+
don't explain the difference: cite the view's path and the object.
|
|
60
62
|
- **`assumed`**: the export doesn't say, and one reading is clearly the cautious one: it follows from what the
|
|
61
63
|
export does say (a rule about the same entity, the same case decided for a neighbouring capability, a glossary
|
|
62
64
|
term), refuses rather than allows, and loses or exposes nothing if it turns out wrong. State the assumption as
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Read `.alterspec-client/prompts/_shared.md` first and follow it.
|
|
4
4
|
|
|
5
5
|
Arguments: the question. It is the developer's, or your own when the spec leaves your work on a task undecided
|
|
6
|
-
(silent, ambiguous, or saying two things
|
|
6
|
+
(silent, ambiguous, or saying two things: two objects that disagree, or a generated view that disagrees with the
|
|
7
|
+
text of the object it was generated from, are asked here when you find them, as one question naming both), or when you are about to decide something about the product's behaviour
|
|
7
8
|
that the brief doesn't state: then ask here instead of stopping the developer or deciding silently. For a decision
|
|
8
9
|
you are about to take, say in the question which way you would go and why; the answerer weighs it against the
|
|
9
10
|
export, and when the export is silent it is what gets recorded as the assumption. A question is about one
|
|
@@ -58,7 +58,9 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
|
|
|
58
58
|
product's behaviour that the brief didn't state. Each one has a `Q-<n>` from `/alterspec-spec-ask`, or you ask it
|
|
59
59
|
now, before the commit, as `_shared.md` says; the commit's body names the `Q-<n>` it stands on.
|
|
60
60
|
7. Work through the checklist, the heavy items first (their weight `w`, when the brief shows one, is how much
|
|
61
|
-
behaviour each is; it is the sign-off's, never yours to set or send).
|
|
61
|
+
behaviour each is; it is the sign-off's, never yours to set or send). An item marked `w 0, nothing to build on this track` is
|
|
62
|
+
another track's behaviour that your track only reads: read it, build nothing for it and never name it in
|
|
63
|
+
`Alterspec-Covers`; when your track does have work for it, ask with `/alterspec-spec-ask`. A criterion item is your track's part of
|
|
62
64
|
it (`Then` on the backend, `Shown` on a UI track); leave the part the brief gives to another task. A contract state item comes with its mockup link
|
|
63
65
|
(`…/SCR-….html?state=<state>`): open that page in that state to see what you build (sign in as one of the
|
|
64
66
|
screen's roles on the channel's `index.html` first; the session stays). For each item, make its
|
|
@@ -66,4 +68,4 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
|
|
|
66
68
|
with the items whose tests pass on that commit. The hook reports them. When the work is merged into the main
|
|
67
69
|
branch, the developer types `/alterspec-task-done <task>`; never report it done yourself.
|
|
68
70
|
8. When every checklist item is covered, send your `feedback` once, as `_shared.md` says, while you still remember
|
|
69
|
-
what the work cost; then tell the developer the task is ready for `/alterspec-task-done <task>` once it is merged.
|
|
71
|
+
what the work cost (nothing you asked is said again: `decided` is the bare `Q-<n>` of each assumption); then tell the developer the task is ready for `/alterspec-task-done <task>` once it is merged.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: alterspec-spec-ask
|
|
3
|
-
description: "Use when the developer asks about the product the export specifies (\"who may approve a price?\", \"what does RULE-PRC-001 say?\"), or when the spec leaves your own work on a task undecided, or before you decide yourself how the product behaves where the brief doesn't say. Answers from the export citing IDs; what the export doesn't say becomes a recorded assumption or an open question for the product side."
|
|
3
|
+
description: "Use when the developer asks about the product the export specifies (\"who may approve a price?\", \"what does RULE-PRC-001 say?\"), or when the spec leaves your own work on a task undecided, or when two spec objects disagree or a generated view disagrees with the object it was generated from (ask it when you find it, never keep it for the feedback), or before you decide yourself how the product behaves where the brief doesn't say. Answers from the export citing IDs; what the export doesn't say becomes a recorded assumption or an open question for the product side."
|
|
4
4
|
argument-hint: "<question>"
|
|
5
5
|
allowed-tools: Read Glob Grep Agent Bash(npx @alterset/alterspec-client *) mcp__dispatcher__whoami mcp__dispatcher__ask
|
|
6
6
|
---
|
package/developer-guide.md
CHANGED
|
@@ -16,18 +16,26 @@ You connect to it with the **alterspec client** (`@alterset/alterspec-client`, p
|
|
|
16
16
|
change is done.
|
|
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
|
-
nobody types percentages. Each item may carry a **weight** (`w 20`),
|
|
19
|
+
nobody types percentages. Each item may carry a **weight** (`w 20`), 0 to 100: how much specified behaviour it
|
|
20
20
|
is, reasoned when the change was signed off from the spec alone, never from your code (a wording change is a
|
|
21
21
|
few, an acceptance criterion about 10, a new capability 40 to 60). The dispatcher's progress and ETA count
|
|
22
22
|
weight, not items, so a task of twelve small parts is not twelve days; an item without a weight counts 10.
|
|
23
|
+
The weight is your track's: an item marked `w 0, nothing to build on this track` is behaviour another track
|
|
24
|
+
builds (a criterion only the other channel shows, a mockup file). You read it, build nothing for it and never
|
|
25
|
+
name it in `Alterspec-Covers`; it counts in no progress, and a task whose items all weigh 0 is never handed out.
|
|
23
26
|
Nobody types a weight either: the product side's sign-off gives it, and a developer never changes it.
|
|
27
|
+
- A task may carry a **title** and a **summary**, and each item a **label**: what a person calls them, written by
|
|
28
|
+
the product side at the sign-off (or taken from the spec's own titles). The brief opens with the title and the
|
|
29
|
+
summary and shows each item's label in bold before what the item is; the dispatcher's lists show the same words
|
|
30
|
+
with the ID beside them. They are for reading. Build from the brief's spec text, never from a label.
|
|
24
31
|
- An acceptance criterion may have two outcomes: **Then**, what the system guarantees, and **Shown**, what the
|
|
25
32
|
person sees on the screen. The backend builds and tests the Then, a UI track the Shown, and each task's checklist
|
|
26
33
|
holds the criterion only for its own part; the brief shows you yours and says when the other part is another
|
|
27
34
|
task's. A criterion without Shown is all the backend's.
|
|
28
35
|
- When the checklist is covered, Claude sends the dispatcher short **feedback** on the task: what in the spec was
|
|
29
|
-
unclear, what it had to read beyond the brief,
|
|
30
|
-
|
|
36
|
+
unclear and was not asked, what it had to read beyond the brief, and the `Q-<n>` of each assumption it built on.
|
|
37
|
+
It never says a question again: the product side reads the task's questions beside it. Two objects of the spec
|
|
38
|
+
that disagree are asked the moment Claude sees them, not kept for the feedback. It is never a grade of your work.
|
|
31
39
|
- When the spec doesn't decide something, Claude **asks** instead of stopping you or deciding itself. An answerer
|
|
32
40
|
that reads only the spec replies: *from the spec*, with the IDs it rests on; *assumed*, when the spec is silent and
|
|
33
41
|
one reading is the cautious one (work goes on, and the product side confirms or corrects it later); or *open*,
|
|
@@ -129,6 +137,14 @@ Answer `y` if npx asks to install the package. Leave out `--branch` when the tra
|
|
|
129
137
|
default. A repository that builds several tracks takes them all: `--track BE WEB`. If you sign with another key than
|
|
130
138
|
`~/.ssh/id_ed25519`, add `--key <path-to-.pub>`.
|
|
131
139
|
|
|
140
|
+
If your project must run npx with flags of its own (for instance `--min-release-age=0`, where npm is set to refuse
|
|
141
|
+
a package published in the last days and you take the client on its release day), say so once:
|
|
142
|
+
`init --npx=--min-release-age=0` (several, comma-separated). `init` keeps them in `.alterspec-client.json` as
|
|
143
|
+
`"npx": { "args": ["--min-release-age=0"] }` and writes them into everything that runs the client: the server in
|
|
144
|
+
`.mcp.json`, the progress hook, the skills' permissions and the prompts. Every later `init` reads them from there,
|
|
145
|
+
so an update never takes them away; `--npx=` removes them. The registry is not a flag: pin it in the repository's
|
|
146
|
+
`.npmrc` (see "When something is off").
|
|
147
|
+
|
|
132
148
|
`init` writes:
|
|
133
149
|
|
|
134
150
|
| File | What it is | Commit it? |
|
|
@@ -357,7 +373,8 @@ when one of yours was fixed since you last looked.
|
|
|
357
373
|
| "That is not a public key the dispatcher accepts" | you used an RSA key: make an Ed25519 key (step 1) and send it |
|
|
358
374
|
| "No SSH key to sign with" | create `~/.ssh/id_ed25519` (step 1), or point `--key` at your key and run `init` again |
|
|
359
375
|
| "ssh-agent doesn't hold the key" | `ssh-add` your key (step 1) |
|
|
360
|
-
| `E401` or `E404` running `npx @alterset/...` | npm is set to a private registry that doesn't have the client. The client is on the public registry: add `registry=https://registry.npmjs.org/` to the repository's `.npmrc`, or fix your registry login |
|
|
376
|
+
| `E401` or `E404` running `npx @alterset/...` | npm is set to a private registry that doesn't have the client. The client is on the public registry: add `@alterset:registry=https://registry.npmjs.org/` (only this package's scope) or `registry=https://registry.npmjs.org/` to the repository's `.npmrc`, or fix your registry login |
|
|
377
|
+
| npm refuses the client as published too recently | your npm keeps packages back for some days after their release: run `init --npx=--min-release-age=0` once, and every command, the hook and the dispatcher server run with the flag |
|
|
361
378
|
| Claude has no `dispatcher` tools | run `init` again (it approves the server), make sure git doesn't track `.claude/settings.local.json`, and start a new session. In a terminal `claude` session, `/mcp` shows and approves the server too |
|
|
362
379
|
| "No .alterspec-client.json here" | run `init` in this repository (step 4) |
|
|
363
380
|
| "The export is N commits behind the dispatcher" | your export clone couldn't be pulled: `git -C ../<product>-export pull`, and check its remote if it keeps happening |
|
package/dist/cli.js
CHANGED
|
@@ -15,6 +15,13 @@ import { z as z2 } from "zod";
|
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
var TrackCode = z.string().regex(/^[A-Z]{2,5}$/, { message: "must be BE or a channel code" });
|
|
17
17
|
var WorkWeight = z.number().int().min(1).max(100);
|
|
18
|
+
var ItemWeight = z.number().int().min(0).max(100);
|
|
19
|
+
var WORD_CAPS = { title: 100, summary: 400, label: 100, name: 100 };
|
|
20
|
+
var words = (max) => z.string().max(max, { message: `at most ${max} characters` }).regex(/^\S(?:[^\n\r]*\S)?$/, { message: "one line of text, without spaces around it" });
|
|
21
|
+
var WorkTitle = words(WORD_CAPS.title);
|
|
22
|
+
var WorkSummary = words(WORD_CAPS.summary);
|
|
23
|
+
var WorkLabel = words(WORD_CAPS.label);
|
|
24
|
+
var WorkName = words(WORD_CAPS.name);
|
|
18
25
|
var ChangeRef = z.string().regex(/^CHG-\d{3,}$/);
|
|
19
26
|
var Day = z.iso.date();
|
|
20
27
|
var WorkTrackSchema = z.object({
|
|
@@ -41,12 +48,27 @@ var WorkTaskSchema = z.object({
|
|
|
41
48
|
*/
|
|
42
49
|
after: z.array(z.object({ change: ChangeRef, track: TrackCode }).strict()),
|
|
43
50
|
/**
|
|
44
|
-
* The weight of each item (format 3
|
|
45
|
-
* change's sign-off against alterspec's rubric
|
|
46
|
-
*
|
|
47
|
-
*
|
|
51
|
+
* The weight of each item on this track (format 3; per track and 0–100 from format 6): how much of the
|
|
52
|
+
* behaviour the item specifies this track builds, reasoned at the change's sign-off against alterspec's rubric
|
|
53
|
+
* (a typical acceptance criterion about 10), never anyone's code. 0: nothing to build on this track; the item
|
|
54
|
+
* is read, not built, and counts in no progress. A task whose weights are all 0 has no work and is not handed
|
|
55
|
+
* out. An item the sign-off didn't weigh takes the median of the task's weighed items above 0; a task of a
|
|
56
|
+
* change signed off without weights has no `weights`, and a reader counts each of its items as 10.
|
|
48
57
|
*/
|
|
49
|
-
weights: z.record(z.string().min(1),
|
|
58
|
+
weights: z.record(z.string().min(1), ItemWeight).optional(),
|
|
59
|
+
/**
|
|
60
|
+
* What this track builds in this change, for a person reading a list (format 5): reasoned at the change's
|
|
61
|
+
* sign-off, in the product's words, naming no ID. Absent: the change was signed off without one.
|
|
62
|
+
*/
|
|
63
|
+
title: WorkTitle.optional(),
|
|
64
|
+
/** The same in two or three plain sentences (format 5). */
|
|
65
|
+
summary: WorkSummary.optional(),
|
|
66
|
+
/**
|
|
67
|
+
* What each item is (format 5), by item, naming only the task's own items and not necessarily all: reasoned at
|
|
68
|
+
* sign-off where the spec has no word for the item (an acceptance criterion), composed at export from the spec
|
|
69
|
+
* where it has (a screen's action, a contract's state, a part of an object, a whole object). For reading only.
|
|
70
|
+
*/
|
|
71
|
+
labels: z.record(z.string().min(1), WorkLabel).optional()
|
|
50
72
|
}).strict();
|
|
51
73
|
var WorkChangeSchema = z.object({
|
|
52
74
|
id: ChangeRef,
|
|
@@ -67,7 +89,7 @@ var WorkChangeSchema = z.object({
|
|
|
67
89
|
*/
|
|
68
90
|
weight: WorkWeight.optional()
|
|
69
91
|
}).strict();
|
|
70
|
-
var WORK_FORMAT =
|
|
92
|
+
var WORK_FORMAT = 6;
|
|
71
93
|
var WorkSchema = z.object({
|
|
72
94
|
format: z.literal(WORK_FORMAT),
|
|
73
95
|
/** The alterspec version that wrote the export. */
|
|
@@ -77,20 +99,36 @@ var WorkSchema = z.object({
|
|
|
77
99
|
baseline: z.object({ date: Day, built: z.boolean() }).strict().nullable(),
|
|
78
100
|
tracks: z.array(WorkTrackSchema),
|
|
79
101
|
/** Every change signed off after the baseline, in the change map's order. */
|
|
80
|
-
changes: z.array(WorkChangeSchema)
|
|
102
|
+
changes: z.array(WorkChangeSchema),
|
|
103
|
+
/**
|
|
104
|
+
* The title of every object a task's `objects` names, by key, as the spec holds it now (format 5); an object
|
|
105
|
+
* the spec no longer holds, and a file, has no entry. Absent when no object has one.
|
|
106
|
+
*/
|
|
107
|
+
names: z.record(z.string().min(1), WorkName).optional()
|
|
108
|
+
}).strict();
|
|
109
|
+
var WorkTaskV5Schema = WorkTaskSchema.extend({
|
|
110
|
+
weights: z.record(z.string().min(1), WorkWeight).optional()
|
|
81
111
|
}).strict();
|
|
82
|
-
var
|
|
83
|
-
var
|
|
112
|
+
var WorkChangeV5Schema = WorkChangeSchema.extend({ tasks: z.array(WorkTaskV5Schema) }).strict();
|
|
113
|
+
var WorkV5Schema = WorkSchema.extend({
|
|
114
|
+
format: z.literal(5),
|
|
115
|
+
changes: z.array(WorkChangeV5Schema)
|
|
116
|
+
}).strict();
|
|
117
|
+
var WorkTaskV4Schema = WorkTaskV5Schema.omit({ title: true, summary: true, labels: true }).strict();
|
|
118
|
+
var WorkChangeV4Schema = WorkChangeV5Schema.extend({ tasks: z.array(WorkTaskV4Schema) }).strict();
|
|
119
|
+
var WorkV4Schema = WorkV5Schema.omit({ names: true }).extend({ format: z.literal(4), changes: z.array(WorkChangeV4Schema) }).strict();
|
|
120
|
+
var WorkChangeV3Schema = WorkChangeV4Schema.omit({ weight: true }).strict();
|
|
121
|
+
var WorkV3Schema = WorkV4Schema.extend({
|
|
84
122
|
format: z.literal(3),
|
|
85
123
|
changes: z.array(WorkChangeV3Schema)
|
|
86
124
|
}).strict();
|
|
87
|
-
var WorkTaskV2Schema =
|
|
88
|
-
var WorkV2Schema =
|
|
125
|
+
var WorkTaskV2Schema = WorkTaskV4Schema.omit({ weights: true });
|
|
126
|
+
var WorkV2Schema = WorkV4Schema.extend({
|
|
89
127
|
format: z.literal(2),
|
|
90
128
|
changes: z.array(WorkChangeV3Schema.extend({ tasks: z.array(WorkTaskV2Schema) }).strict())
|
|
91
129
|
}).strict();
|
|
92
130
|
var WorkTaskV1Schema = WorkTaskV2Schema.omit({ items: true });
|
|
93
|
-
var WorkV1Schema =
|
|
131
|
+
var WorkV1Schema = WorkV4Schema.extend({
|
|
94
132
|
format: z.literal(1),
|
|
95
133
|
changes: z.array(WorkChangeV3Schema.extend({ tasks: z.array(WorkTaskV1Schema) }).strict())
|
|
96
134
|
}).strict();
|
|
@@ -98,11 +136,14 @@ var AnyWorkSchema = z.discriminatedUnion("format", [
|
|
|
98
136
|
WorkV1Schema,
|
|
99
137
|
WorkV2Schema,
|
|
100
138
|
WorkV3Schema,
|
|
139
|
+
WorkV4Schema,
|
|
140
|
+
WorkV5Schema,
|
|
101
141
|
WorkSchema
|
|
102
142
|
]);
|
|
103
143
|
|
|
104
144
|
// src/config.ts
|
|
105
145
|
var CONFIG_FILE = ".alterspec-client.json";
|
|
146
|
+
var NpxArg = z2.string().regex(/^--?[A-Za-z0-9][A-Za-z0-9=._:/-]*$/, "must be one npx flag, like --min-release-age=0");
|
|
106
147
|
var ClientConfigSchema = z2.object({
|
|
107
148
|
/** The dispatcher's URL. */
|
|
108
149
|
dispatcher: z2.url(),
|
|
@@ -115,7 +156,12 @@ var ClientConfigSchema = z2.object({
|
|
|
115
156
|
/** The public key to sign with: a `.pub` path or the key line; default ssh-agent, then `~/.ssh/id_ed25519.pub`. */
|
|
116
157
|
key: z2.string().min(1).optional(),
|
|
117
158
|
/** The track's main branch; default the remote's `HEAD`, else `main`. */
|
|
118
|
-
branch: z2.string().min(1).optional()
|
|
159
|
+
branch: z2.string().min(1).optional(),
|
|
160
|
+
/**
|
|
161
|
+
* How this project runs the client: flags put before the package name wherever `init` writes the invocation
|
|
162
|
+
* (`.mcp.json`, the progress hook, the skills and the prompts). The registry is the project's `.npmrc`'s.
|
|
163
|
+
*/
|
|
164
|
+
npx: z2.object({ args: z2.array(NpxArg).default([]) }).strict().optional()
|
|
119
165
|
}).strict();
|
|
120
166
|
var ConfigError = class extends Error {
|
|
121
167
|
};
|
|
@@ -496,12 +542,19 @@ var ChangeSchema = z5.object({
|
|
|
496
542
|
*/
|
|
497
543
|
tracks: z5.record(TrackCode, z5.array(z5.string())).optional(),
|
|
498
544
|
/**
|
|
499
|
-
* The weight of each task item (`work.json`),
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
545
|
+
* The weight of each task item (`work.json`), 0–100, on every track that has no weight of its own for it
|
|
546
|
+
* (`track_weights`): how much specified behaviour the item adds or changes, reasoned by the sign-off skill
|
|
547
|
+
* against the rubric (`_weights.md`), never anyone's code. Written by `change weigh`, frozen at sign-off next
|
|
548
|
+
* to `tracks` (`{}` = signed off without weighing); absent = signed off before weights existed. The dispatcher
|
|
549
|
+
* weighs progress and ETA by it.
|
|
503
550
|
*/
|
|
504
|
-
weights: z5.record(z5.string(),
|
|
551
|
+
weights: z5.record(z5.string(), ItemWeight).optional(),
|
|
552
|
+
/**
|
|
553
|
+
* The weight of an item on one track where it differs from `weights`, by track then item, 0–100: the part of
|
|
554
|
+
* the behaviour that track builds; 0 when it builds nothing of it (a criterion only another channel shows).
|
|
555
|
+
* Written by `change weigh` (an entry with `track`), frozen at sign-off as it is.
|
|
556
|
+
*/
|
|
557
|
+
track_weights: z5.record(TrackCode, z5.record(z5.string(), ItemWeight)).optional(),
|
|
505
558
|
/**
|
|
506
559
|
* The size of the whole change, 1–100 (`work.json` format 4, `changes[].weight`): reasoned by the sign-off skill
|
|
507
560
|
* against the change rubric (`_weights.md` "The change's weight"), never a sum of the item weights and never
|
|
@@ -511,6 +564,18 @@ var ChangeSchema = z5.object({
|
|
|
511
564
|
change_weight: WorkWeight.optional(),
|
|
512
565
|
/** One line: what makes the change that size. */
|
|
513
566
|
change_weight_why: z5.string().optional(),
|
|
567
|
+
/**
|
|
568
|
+
* What each track builds in this change, for a person reading a list (`work.json` format 5, `tasks[].title` and
|
|
569
|
+
* `summary`): reasoned by the sign-off skill against the rubric (`_labels.md`), in the product's words, naming
|
|
570
|
+
* no ID. Written by `change label`, archived as it is; absent = not titled.
|
|
571
|
+
*/
|
|
572
|
+
task_words: z5.record(TrackCode, z5.object({ title: WorkTitle.optional(), summary: WorkSummary.optional() }).strict()).optional(),
|
|
573
|
+
/**
|
|
574
|
+
* What a task item is (`tasks[].labels`), by item: reasoned by the sign-off skill where the spec has no word
|
|
575
|
+
* for the item (an acceptance criterion); the export composes the others from the spec. Written by
|
|
576
|
+
* `change label`.
|
|
577
|
+
*/
|
|
578
|
+
labels: z5.record(z5.string(), WorkLabel).optional(),
|
|
514
579
|
/**
|
|
515
580
|
* In a team project: the draft IDs the change and what it creates carried until the sign-off numbered them
|
|
516
581
|
* (draft → final). Written by the CLI at sign-off.
|
|
@@ -1720,8 +1785,11 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
1720
1785
|
const lost = new Map(delta?.unrecoverable?.map((u) => [u.key, u.why]));
|
|
1721
1786
|
const items = work.items;
|
|
1722
1787
|
const weights = work.weights;
|
|
1788
|
+
const words2 = work;
|
|
1723
1789
|
const ctx = {
|
|
1724
1790
|
task: task.id,
|
|
1791
|
+
...words2.title ? { title: words2.title } : {},
|
|
1792
|
+
...words2.summary ? { summary: words2.summary } : {},
|
|
1725
1793
|
...questions ? { questions } : {},
|
|
1726
1794
|
...state.answers?.length ? { answers: state.answers } : {},
|
|
1727
1795
|
...items ? {
|
|
@@ -1733,7 +1801,8 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
1733
1801
|
item,
|
|
1734
1802
|
what: itemWhat(x, item, entries.get(itemObject(item)), task.track),
|
|
1735
1803
|
...covered ? { covered } : {},
|
|
1736
|
-
...weight === void 0 ? {} : { weight }
|
|
1804
|
+
...weight === void 0 ? {} : { weight },
|
|
1805
|
+
...words2.labels?.[item] ? { label: words2.labels[item] } : {}
|
|
1737
1806
|
};
|
|
1738
1807
|
}),
|
|
1739
1808
|
known: state.covered !== void 0,
|
|
@@ -1983,8 +2052,11 @@ ${ticks}`;
|
|
|
1983
2052
|
};
|
|
1984
2053
|
function renderContext(c) {
|
|
1985
2054
|
const out = [
|
|
1986
|
-
`# ${c.task}: ${c.change.title}`,
|
|
2055
|
+
`# ${c.task}: ${c.title ?? c.change.title}`,
|
|
1987
2056
|
"",
|
|
2057
|
+
// The words the lists show for the task: what a person calls it, never what to build from.
|
|
2058
|
+
...c.summary ? [c.summary, ""] : [],
|
|
2059
|
+
...c.title ? [`Change: ${c.change.title}.`, ""] : [],
|
|
1988
2060
|
`Track ${c.track.code} (${c.track.kind}${c.track.channels.length ? `: ${c.track.channels.join(", ")}` : ""}). Change ${c.change.id}, signed off ${c.change.signed_off}, level ${c.change.level}. Paths are relative to the export, ${c.export}.`
|
|
1989
2061
|
];
|
|
1990
2062
|
const movedSince = (c.changedSince ?? []).filter((e) => !e.entered);
|
|
@@ -2009,22 +2081,28 @@ function renderContext(c) {
|
|
|
2009
2081
|
out.push("This export has no checklist (work.json format 1): the task\u2019s progress is its status only.");
|
|
2010
2082
|
else {
|
|
2011
2083
|
const list2 = c.checklist;
|
|
2012
|
-
const
|
|
2084
|
+
const toBuild = list2.items.filter((i) => i.weight !== 0);
|
|
2085
|
+
const readOnly = list2.items.length - toBuild.length;
|
|
2086
|
+
const done = toBuild.filter((i) => i.covered).length;
|
|
2013
2087
|
const weighed = list2.items.some((i) => i.weight !== void 0);
|
|
2014
2088
|
const sum = (items) => items.reduce((a, i) => a + (i.weight ?? 0), 0);
|
|
2015
2089
|
const weight = weighed ? list2.known ? `, ${sum(list2.items.filter((i) => i.covered))} of ${sum(list2.items)} weight` : `, ${sum(list2.items)} weight` : "";
|
|
2016
2090
|
out.push(
|
|
2017
|
-
`## Checklist (${list2.known ? `${done} of ${
|
|
2091
|
+
`## Checklist (${list2.known ? `${done} of ${toBuild.length} covered` : `${toBuild.length} item${toBuild.length === 1 ? "" : "s"}`}${weight}${readOnly ? `; ${readOnly} to read only` : ""})`,
|
|
2018
2092
|
"",
|
|
2019
2093
|
"Name an item in `Alterspec-Covers` on the commit with which its tests pass.",
|
|
2020
2094
|
...weighed ? [
|
|
2021
|
-
"The weight (w) is how much specified behaviour an item is
|
|
2095
|
+
"The weight (w) is how much specified behaviour an item is on this track, reasoned at the sign-off from the spec alone;",
|
|
2022
2096
|
"progress and the ETA count weight, not items. Start with the heavy ones."
|
|
2023
2097
|
] : [],
|
|
2098
|
+
...readOnly ? [
|
|
2099
|
+
"An item of weight 0 is nothing this track builds (another channel shows it, or it is a mockup file): read it,",
|
|
2100
|
+
"build nothing for it and never name it in `Alterspec-Covers`. If your track does have work for it, say so with `/alterspec-spec-ask`."
|
|
2101
|
+
] : [],
|
|
2024
2102
|
...list2.note ? ["", `Covered items unknown: ${list2.note}`] : [],
|
|
2025
2103
|
"",
|
|
2026
2104
|
...list2.items.map(
|
|
2027
|
-
(i) => `- [${i.covered ? "x" : " "}] \`${i.item}\`${i.weight === void 0 ? "" : ` (w ${i.weight})`}: ${i.what}${i.covered ? ` (covered by ${i.covered.slice(0, 12)})` : ""}`
|
|
2105
|
+
(i) => `- [${i.weight === 0 ? "-" : i.covered ? "x" : " "}] \`${i.item}\`${i.weight === void 0 ? "" : i.weight === 0 ? " (w 0, nothing to build on this track)" : ` (w ${i.weight})`}: ${i.label ? `**${i.label}** \u2014 ` : ""}${i.what}${i.covered ? ` (covered by ${i.covered.slice(0, 12)})` : ""}`
|
|
2028
2106
|
)
|
|
2029
2107
|
);
|
|
2030
2108
|
}
|
|
@@ -2712,7 +2790,11 @@ var PROMPTS_DIR = `${CLIENT_DIR}/prompts`;
|
|
|
2712
2790
|
var MANIFEST_PATH2 = `${CLIENT_DIR}/manifest.json`;
|
|
2713
2791
|
var MCP_JSON = ".mcp.json";
|
|
2714
2792
|
var MCP_SERVER = "dispatcher";
|
|
2715
|
-
var
|
|
2793
|
+
var PACKAGE = "@alterset/alterspec-client";
|
|
2794
|
+
var INVOCATION = `npx ${PACKAGE}`;
|
|
2795
|
+
var invocation = (npxArgs = []) => ["npx", ...npxArgs, PACKAGE].join(" ");
|
|
2796
|
+
var mcpEntry = (npxArgs = []) => ({ command: "npx", args: [...npxArgs, PACKAGE, "mcp"] });
|
|
2797
|
+
var MCP_ENTRY = mcpEntry();
|
|
2716
2798
|
function walk(dir) {
|
|
2717
2799
|
return readdirSync3(dir).sort().flatMap((n) => statSync(join7(dir, n)).isDirectory() ? walk(join7(dir, n)) : [join7(dir, n)]);
|
|
2718
2800
|
}
|
|
@@ -2720,7 +2802,12 @@ var assetFiles = (sub) => walk(join7(ASSETS_DIR, sub)).map((f) => ({
|
|
|
2720
2802
|
rel: relative(join7(ASSETS_DIR, sub), f).split("\\").join("/"),
|
|
2721
2803
|
content: readFileSync6(f, "utf8")
|
|
2722
2804
|
}));
|
|
2723
|
-
function buildClientPlan(version) {
|
|
2805
|
+
function buildClientPlan(version, npxArgs = []) {
|
|
2806
|
+
const plan = clientPlan(version);
|
|
2807
|
+
if (!npxArgs.length) return plan;
|
|
2808
|
+
return plan.map((f) => ({ ...f, content: f.content.split(INVOCATION).join(invocation(npxArgs)) }));
|
|
2809
|
+
}
|
|
2810
|
+
function clientPlan(version) {
|
|
2724
2811
|
return [
|
|
2725
2812
|
...assetFiles("skills").map((f) => ({
|
|
2726
2813
|
path: `.claude/skills/${f.rel}`,
|
|
@@ -2741,7 +2828,7 @@ function buildClientPlan(version) {
|
|
|
2741
2828
|
`, policy: "framework" }
|
|
2742
2829
|
];
|
|
2743
2830
|
}
|
|
2744
|
-
function writeMcpJson(root) {
|
|
2831
|
+
function writeMcpJson(root, npxArgs = []) {
|
|
2745
2832
|
const path = join7(root, MCP_JSON);
|
|
2746
2833
|
let data = {};
|
|
2747
2834
|
const before2 = existsSync7(path) ? readFileSync6(path, "utf8") : void 0;
|
|
@@ -2751,23 +2838,25 @@ function writeMcpJson(root) {
|
|
|
2751
2838
|
} catch {
|
|
2752
2839
|
throw new ConfigError(`${path} is not valid JSON: fix it, then run init again.`);
|
|
2753
2840
|
}
|
|
2754
|
-
data.mcpServers = { ...data.mcpServers ?? {}, [MCP_SERVER]:
|
|
2841
|
+
data.mcpServers = { ...data.mcpServers ?? {}, [MCP_SERVER]: mcpEntry(npxArgs) };
|
|
2755
2842
|
const after2 = JSON.stringify(data, null, 2) + "\n";
|
|
2756
2843
|
if (after2 === before2) return "unchanged";
|
|
2757
2844
|
writeFileSync5(path, after2);
|
|
2758
2845
|
return before2 === void 0 ? "created" : "updated";
|
|
2759
2846
|
}
|
|
2760
2847
|
var CLAUDE_SETTINGS = ".claude/settings.json";
|
|
2761
|
-
var
|
|
2762
|
-
var HOOK_ENTRY = {
|
|
2848
|
+
var hookEntry = (npxArgs = []) => ({
|
|
2763
2849
|
type: "command",
|
|
2764
2850
|
if: "Bash(git commit *)",
|
|
2765
|
-
command:
|
|
2851
|
+
command: `${invocation(npxArgs)} progress --hook`,
|
|
2766
2852
|
timeout: 60,
|
|
2767
2853
|
async: true
|
|
2768
|
-
};
|
|
2769
|
-
var
|
|
2770
|
-
|
|
2854
|
+
});
|
|
2855
|
+
var HOOK_ENTRY = hookEntry();
|
|
2856
|
+
var HOOK_COMMAND = HOOK_ENTRY.command;
|
|
2857
|
+
var isOurs = (h) => typeof h.command === "string" && h.command.includes(`${PACKAGE} progress`);
|
|
2858
|
+
function writeClaudeSettings(root, npxArgs = []) {
|
|
2859
|
+
const entry = hookEntry(npxArgs);
|
|
2771
2860
|
const path = join7(root, CLAUDE_SETTINGS);
|
|
2772
2861
|
const before2 = existsSync7(path) ? readFileSync6(path, "utf8") : void 0;
|
|
2773
2862
|
let data = {};
|
|
@@ -2785,9 +2874,9 @@ function writeClaudeSettings(root) {
|
|
|
2785
2874
|
if (!isOurs(h)) return [h];
|
|
2786
2875
|
if (found) return [];
|
|
2787
2876
|
found = true;
|
|
2788
|
-
return [
|
|
2877
|
+
return [entry];
|
|
2789
2878
|
});
|
|
2790
|
-
if (!found) groups.push({ matcher: "Bash", hooks: [
|
|
2879
|
+
if (!found) groups.push({ matcher: "Bash", hooks: [entry] });
|
|
2791
2880
|
const after2 = JSON.stringify(data, null, 2) + "\n";
|
|
2792
2881
|
if (before2 !== void 0 && JSON.stringify(JSON.parse(before2)) === JSON.stringify(data)) return "unchanged";
|
|
2793
2882
|
mkdirSync3(join7(root, ".claude"), { recursive: true });
|
|
@@ -2857,14 +2946,16 @@ function initClient(root, opts, version) {
|
|
|
2857
2946
|
existing ? `The configuration would not be valid: ${parsed.error.issues.map((i) => `${i.path.join(".")} ${i.message}`).join("; ")}.` : `init needs --dispatcher <url> and --export <path to your clone of the export>${missing.length ? ` (missing or wrong: ${missing.join(", ")})` : ""}.`
|
|
2858
2947
|
);
|
|
2859
2948
|
}
|
|
2949
|
+
if (!parsed.data.npx?.args.length) delete parsed.data.npx;
|
|
2950
|
+
const npxArgs = parsed.data.npx?.args ?? [];
|
|
2860
2951
|
const before2 = existing && JSON.stringify(existing);
|
|
2861
2952
|
const config = !existing ? "created" : before2 === JSON.stringify(parsed.data) ? "unchanged" : "updated";
|
|
2862
2953
|
if (config !== "unchanged") writeConfig(root, parsed.data);
|
|
2863
|
-
const mcp = writeMcpJson(root);
|
|
2864
|
-
const hook = writeClaudeSettings(root);
|
|
2954
|
+
const mcp = writeMcpJson(root, npxArgs);
|
|
2955
|
+
const hook = writeClaudeSettings(root, npxArgs);
|
|
2865
2956
|
const ignore = ignoreLocalSettings(root);
|
|
2866
2957
|
const approval = writeLocalSettings(root);
|
|
2867
|
-
const files = install(root, buildClientPlan(version), {
|
|
2958
|
+
const files = install(root, buildClientPlan(version, npxArgs), {
|
|
2868
2959
|
mode: "update",
|
|
2869
2960
|
force,
|
|
2870
2961
|
version,
|
|
@@ -3432,13 +3523,21 @@ var program = new Command();
|
|
|
3432
3523
|
program.name("alterspec-client").description("alterspec client \u2014 takes tasks of an alterspec export from the dispatcher.").version(packageVersion());
|
|
3433
3524
|
program.command("init").description(
|
|
3434
3525
|
"set the client up in this repository: configuration, the dispatcher in .mcp.json, the progress hook, the skills"
|
|
3435
|
-
).option("--dispatcher <url>", "the dispatcher\u2019s URL").option("--export <path>", "your clone of the export repository").option("--track <code...>", "the tracks this repository builds (BE, WEB, \u2026)").option("--key <key>", "the public key to sign with: a .pub path or the key line").option("--branch <name>", "the track\u2019s main branch (default the remote\u2019s HEAD)").option(
|
|
3526
|
+
).option("--dispatcher <url>", "the dispatcher\u2019s URL").option("--export <path>", "your clone of the export repository").option("--track <code...>", "the tracks this repository builds (BE, WEB, \u2026)").option("--key <key>", "the public key to sign with: a .pub path or the key line").option("--branch <name>", "the track\u2019s main branch (default the remote\u2019s HEAD)").option(
|
|
3527
|
+
"--npx <flags>",
|
|
3528
|
+
"flags this project runs npx with, comma-separated (--npx=--min-release-age=0); --npx= removes them"
|
|
3529
|
+
).option("--force", "replace skills you modified").action(
|
|
3436
3530
|
run(
|
|
3437
3531
|
(opts) => {
|
|
3438
3532
|
const root = process.cwd();
|
|
3439
|
-
const { track, ...rest } = opts;
|
|
3533
|
+
const { track, npx, ...rest } = opts;
|
|
3534
|
+
const npxArgs = npx?.split(",").map((a) => a.trim()).filter(Boolean);
|
|
3440
3535
|
const tracks = track?.flatMap((t) => t.split(",")).map((t) => t.trim().toUpperCase()).filter(Boolean);
|
|
3441
|
-
const r = initClient(
|
|
3536
|
+
const r = initClient(
|
|
3537
|
+
root,
|
|
3538
|
+
{ ...rest, ...tracks ? { tracks } : {}, ...npxArgs ? { npx: { args: npxArgs } } : {} },
|
|
3539
|
+
packageVersion()
|
|
3540
|
+
);
|
|
3442
3541
|
const f = r.files;
|
|
3443
3542
|
const lines = [
|
|
3444
3543
|
`${CONFIG_FILE}: ${r.config}`,
|