@alterset/alterspec-client 0.19.0 → 0.22.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 +23 -6
- package/assets/prompts/agents/spec-answerer.md +3 -1
- package/assets/prompts/spec-ask.md +2 -1
- package/assets/prompts/task-context.md +1 -1
- package/assets/skills/alterspec-spec-ask/SKILL.md +1 -1
- package/developer-guide.md +20 -4
- package/dist/cli.js +176 -40
- package/dist/cli.js.map +1 -1
- package/dist/work.d.ts +147 -12
- package/dist/work.js +45 -9
- package/dist/work.js.map +1 -1
- package/dist/work.schema.json +233 -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
|
|
@@ -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
|
|
@@ -66,4 +66,4 @@ or whose `Alterspec-Task` trailer the last commit carries; when that doesn't set
|
|
|
66
66
|
with the items whose tests pass on that commit. The hook reports them. When the work is merged into the main
|
|
67
67
|
branch, the developer types `/alterspec-task-done <task>`; never report it done yourself.
|
|
68
68
|
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.
|
|
69
|
+
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
|
@@ -21,13 +21,18 @@ You connect to it with the **alterspec client** (`@alterset/alterspec-client`, p
|
|
|
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
23
|
Nobody types a weight either: the product side's sign-off gives it, and a developer never changes it.
|
|
24
|
+
- A task may carry a **title** and a **summary**, and each item a **label**: what a person calls them, written by
|
|
25
|
+
the product side at the sign-off (or taken from the spec's own titles). The brief opens with the title and the
|
|
26
|
+
summary and shows each item's label in bold before what the item is; the dispatcher's lists show the same words
|
|
27
|
+
with the ID beside them. They are for reading. Build from the brief's spec text, never from a label.
|
|
24
28
|
- An acceptance criterion may have two outcomes: **Then**, what the system guarantees, and **Shown**, what the
|
|
25
29
|
person sees on the screen. The backend builds and tests the Then, a UI track the Shown, and each task's checklist
|
|
26
30
|
holds the criterion only for its own part; the brief shows you yours and says when the other part is another
|
|
27
31
|
task's. A criterion without Shown is all the backend's.
|
|
28
32
|
- 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
|
-
|
|
33
|
+
unclear and was not asked, what it had to read beyond the brief, and the `Q-<n>` of each assumption it built on.
|
|
34
|
+
It never says a question again: the product side reads the task's questions beside it. Two objects of the spec
|
|
35
|
+
that disagree are asked the moment Claude sees them, not kept for the feedback. It is never a grade of your work.
|
|
31
36
|
- When the spec doesn't decide something, Claude **asks** instead of stopping you or deciding itself. An answerer
|
|
32
37
|
that reads only the spec replies: *from the spec*, with the IDs it rests on; *assumed*, when the spec is silent and
|
|
33
38
|
one reading is the cautious one (work goes on, and the product side confirms or corrects it later); or *open*,
|
|
@@ -129,6 +134,14 @@ Answer `y` if npx asks to install the package. Leave out `--branch` when the tra
|
|
|
129
134
|
default. A repository that builds several tracks takes them all: `--track BE WEB`. If you sign with another key than
|
|
130
135
|
`~/.ssh/id_ed25519`, add `--key <path-to-.pub>`.
|
|
131
136
|
|
|
137
|
+
If your project must run npx with flags of its own (for instance `--min-release-age=0`, where npm is set to refuse
|
|
138
|
+
a package published in the last days and you take the client on its release day), say so once:
|
|
139
|
+
`init --npx=--min-release-age=0` (several, comma-separated). `init` keeps them in `.alterspec-client.json` as
|
|
140
|
+
`"npx": { "args": ["--min-release-age=0"] }` and writes them into everything that runs the client: the server in
|
|
141
|
+
`.mcp.json`, the progress hook, the skills' permissions and the prompts. Every later `init` reads them from there,
|
|
142
|
+
so an update never takes them away; `--npx=` removes them. The registry is not a flag: pin it in the repository's
|
|
143
|
+
`.npmrc` (see "When something is off").
|
|
144
|
+
|
|
132
145
|
`init` writes:
|
|
133
146
|
|
|
134
147
|
| File | What it is | Commit it? |
|
|
@@ -205,7 +218,9 @@ server. Then talk to it in plain words; the skills do the rest.
|
|
|
205
218
|
```
|
|
206
219
|
|
|
207
220
|
`Alterspec-Covers` names the checklist items whose tests pass with that commit, never items that aren't tested yet.
|
|
208
|
-
After each commit a hook reports them in the background, and the task's progress on the dashboard moves.
|
|
221
|
+
After each commit a hook reports them in the background, and the task's progress on the dashboard moves. An
|
|
222
|
+
object named without its section (`RULE-002` where the checklist has `RULE-002#guards`) isn't counted: the hook
|
|
223
|
+
tells Claude the form to use, and a later commit naming it that way settles it.
|
|
209
224
|
|
|
210
225
|
4. Push your branch and type `/alterspec-task-done CHG-023/BE`: the task is done at that commit on that branch, and
|
|
211
226
|
the tasks waiting for it may start from it. Open the pull request into the main branch as usual; the dispatcher
|
|
@@ -355,7 +370,8 @@ when one of yours was fixed since you last looked.
|
|
|
355
370
|
| "That is not a public key the dispatcher accepts" | you used an RSA key: make an Ed25519 key (step 1) and send it |
|
|
356
371
|
| "No SSH key to sign with" | create `~/.ssh/id_ed25519` (step 1), or point `--key` at your key and run `init` again |
|
|
357
372
|
| "ssh-agent doesn't hold the key" | `ssh-add` your key (step 1) |
|
|
358
|
-
| `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 |
|
|
373
|
+
| `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 |
|
|
374
|
+
| 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 |
|
|
359
375
|
| 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 |
|
|
360
376
|
| "No .alterspec-client.json here" | run `init` in this repository (step 4) |
|
|
361
377
|
| "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,12 @@ 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 WORD_CAPS = { title: 100, summary: 400, label: 100, name: 100 };
|
|
19
|
+
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" });
|
|
20
|
+
var WorkTitle = words(WORD_CAPS.title);
|
|
21
|
+
var WorkSummary = words(WORD_CAPS.summary);
|
|
22
|
+
var WorkLabel = words(WORD_CAPS.label);
|
|
23
|
+
var WorkName = words(WORD_CAPS.name);
|
|
18
24
|
var ChangeRef = z.string().regex(/^CHG-\d{3,}$/);
|
|
19
25
|
var Day = z.iso.date();
|
|
20
26
|
var WorkTrackSchema = z.object({
|
|
@@ -46,7 +52,20 @@ var WorkTaskSchema = z.object({
|
|
|
46
52
|
* An item the sign-off didn't weigh takes the median of the task's weighed items; a task of a change signed off
|
|
47
53
|
* without weights has no `weights`, and a reader counts each of its items as 10. For weighing progress and ETA.
|
|
48
54
|
*/
|
|
49
|
-
weights: z.record(z.string().min(1), WorkWeight).optional()
|
|
55
|
+
weights: z.record(z.string().min(1), WorkWeight).optional(),
|
|
56
|
+
/**
|
|
57
|
+
* What this track builds in this change, for a person reading a list (format 5): reasoned at the change's
|
|
58
|
+
* sign-off, in the product's words, naming no ID. Absent: the change was signed off without one.
|
|
59
|
+
*/
|
|
60
|
+
title: WorkTitle.optional(),
|
|
61
|
+
/** The same in two or three plain sentences (format 5). */
|
|
62
|
+
summary: WorkSummary.optional(),
|
|
63
|
+
/**
|
|
64
|
+
* What each item is (format 5), by item, naming only the task's own items and not necessarily all: reasoned at
|
|
65
|
+
* sign-off where the spec has no word for the item (an acceptance criterion), composed at export from the spec
|
|
66
|
+
* where it has (a screen's action, a contract's state, a part of an object, a whole object). For reading only.
|
|
67
|
+
*/
|
|
68
|
+
labels: z.record(z.string().min(1), WorkLabel).optional()
|
|
50
69
|
}).strict();
|
|
51
70
|
var WorkChangeSchema = z.object({
|
|
52
71
|
id: ChangeRef,
|
|
@@ -67,7 +86,7 @@ var WorkChangeSchema = z.object({
|
|
|
67
86
|
*/
|
|
68
87
|
weight: WorkWeight.optional()
|
|
69
88
|
}).strict();
|
|
70
|
-
var WORK_FORMAT =
|
|
89
|
+
var WORK_FORMAT = 5;
|
|
71
90
|
var WorkSchema = z.object({
|
|
72
91
|
format: z.literal(WORK_FORMAT),
|
|
73
92
|
/** The alterspec version that wrote the export. */
|
|
@@ -77,20 +96,28 @@ var WorkSchema = z.object({
|
|
|
77
96
|
baseline: z.object({ date: Day, built: z.boolean() }).strict().nullable(),
|
|
78
97
|
tracks: z.array(WorkTrackSchema),
|
|
79
98
|
/** Every change signed off after the baseline, in the change map's order. */
|
|
80
|
-
changes: z.array(WorkChangeSchema)
|
|
99
|
+
changes: z.array(WorkChangeSchema),
|
|
100
|
+
/**
|
|
101
|
+
* The title of every object a task's `objects` names, by key, as the spec holds it now (format 5); an object
|
|
102
|
+
* the spec no longer holds, and a file, has no entry. Absent when no object has one.
|
|
103
|
+
*/
|
|
104
|
+
names: z.record(z.string().min(1), WorkName).optional()
|
|
81
105
|
}).strict();
|
|
82
|
-
var
|
|
83
|
-
var
|
|
106
|
+
var WorkTaskV4Schema = WorkTaskSchema.omit({ title: true, summary: true, labels: true }).strict();
|
|
107
|
+
var WorkChangeV4Schema = WorkChangeSchema.extend({ tasks: z.array(WorkTaskV4Schema) }).strict();
|
|
108
|
+
var WorkV4Schema = WorkSchema.omit({ names: true }).extend({ format: z.literal(4), changes: z.array(WorkChangeV4Schema) }).strict();
|
|
109
|
+
var WorkChangeV3Schema = WorkChangeV4Schema.omit({ weight: true }).strict();
|
|
110
|
+
var WorkV3Schema = WorkV4Schema.extend({
|
|
84
111
|
format: z.literal(3),
|
|
85
112
|
changes: z.array(WorkChangeV3Schema)
|
|
86
113
|
}).strict();
|
|
87
|
-
var WorkTaskV2Schema =
|
|
88
|
-
var WorkV2Schema =
|
|
114
|
+
var WorkTaskV2Schema = WorkTaskV4Schema.omit({ weights: true });
|
|
115
|
+
var WorkV2Schema = WorkV4Schema.extend({
|
|
89
116
|
format: z.literal(2),
|
|
90
117
|
changes: z.array(WorkChangeV3Schema.extend({ tasks: z.array(WorkTaskV2Schema) }).strict())
|
|
91
118
|
}).strict();
|
|
92
119
|
var WorkTaskV1Schema = WorkTaskV2Schema.omit({ items: true });
|
|
93
|
-
var WorkV1Schema =
|
|
120
|
+
var WorkV1Schema = WorkV4Schema.extend({
|
|
94
121
|
format: z.literal(1),
|
|
95
122
|
changes: z.array(WorkChangeV3Schema.extend({ tasks: z.array(WorkTaskV1Schema) }).strict())
|
|
96
123
|
}).strict();
|
|
@@ -98,11 +125,13 @@ var AnyWorkSchema = z.discriminatedUnion("format", [
|
|
|
98
125
|
WorkV1Schema,
|
|
99
126
|
WorkV2Schema,
|
|
100
127
|
WorkV3Schema,
|
|
128
|
+
WorkV4Schema,
|
|
101
129
|
WorkSchema
|
|
102
130
|
]);
|
|
103
131
|
|
|
104
132
|
// src/config.ts
|
|
105
133
|
var CONFIG_FILE = ".alterspec-client.json";
|
|
134
|
+
var NpxArg = z2.string().regex(/^--?[A-Za-z0-9][A-Za-z0-9=._:/-]*$/, "must be one npx flag, like --min-release-age=0");
|
|
106
135
|
var ClientConfigSchema = z2.object({
|
|
107
136
|
/** The dispatcher's URL. */
|
|
108
137
|
dispatcher: z2.url(),
|
|
@@ -115,7 +144,12 @@ var ClientConfigSchema = z2.object({
|
|
|
115
144
|
/** The public key to sign with: a `.pub` path or the key line; default ssh-agent, then `~/.ssh/id_ed25519.pub`. */
|
|
116
145
|
key: z2.string().min(1).optional(),
|
|
117
146
|
/** The track's main branch; default the remote's `HEAD`, else `main`. */
|
|
118
|
-
branch: z2.string().min(1).optional()
|
|
147
|
+
branch: z2.string().min(1).optional(),
|
|
148
|
+
/**
|
|
149
|
+
* How this project runs the client: flags put before the package name wherever `init` writes the invocation
|
|
150
|
+
* (`.mcp.json`, the progress hook, the skills and the prompts). The registry is the project's `.npmrc`'s.
|
|
151
|
+
*/
|
|
152
|
+
npx: z2.object({ args: z2.array(NpxArg).default([]) }).strict().optional()
|
|
119
153
|
}).strict();
|
|
120
154
|
var ConfigError = class extends Error {
|
|
121
155
|
};
|
|
@@ -511,6 +545,18 @@ var ChangeSchema = z5.object({
|
|
|
511
545
|
change_weight: WorkWeight.optional(),
|
|
512
546
|
/** One line: what makes the change that size. */
|
|
513
547
|
change_weight_why: z5.string().optional(),
|
|
548
|
+
/**
|
|
549
|
+
* What each track builds in this change, for a person reading a list (`work.json` format 5, `tasks[].title` and
|
|
550
|
+
* `summary`): reasoned by the sign-off skill against the rubric (`_labels.md`), in the product's words, naming
|
|
551
|
+
* no ID. Written by `change label`, archived as it is; absent = not titled.
|
|
552
|
+
*/
|
|
553
|
+
task_words: z5.record(TrackCode, z5.object({ title: WorkTitle.optional(), summary: WorkSummary.optional() }).strict()).optional(),
|
|
554
|
+
/**
|
|
555
|
+
* What a task item is (`tasks[].labels`), by item: reasoned by the sign-off skill where the spec has no word
|
|
556
|
+
* for the item (an acceptance criterion); the export composes the others from the spec. Written by
|
|
557
|
+
* `change label`.
|
|
558
|
+
*/
|
|
559
|
+
labels: z5.record(z5.string(), WorkLabel).optional(),
|
|
514
560
|
/**
|
|
515
561
|
* In a team project: the draft IDs the change and what it creates carried until the sign-off numbered them
|
|
516
562
|
* (draft → final). Written by the CLI at sign-off.
|
|
@@ -1720,8 +1766,11 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
1720
1766
|
const lost = new Map(delta?.unrecoverable?.map((u) => [u.key, u.why]));
|
|
1721
1767
|
const items = work.items;
|
|
1722
1768
|
const weights = work.weights;
|
|
1769
|
+
const words2 = work;
|
|
1723
1770
|
const ctx = {
|
|
1724
1771
|
task: task.id,
|
|
1772
|
+
...words2.title ? { title: words2.title } : {},
|
|
1773
|
+
...words2.summary ? { summary: words2.summary } : {},
|
|
1725
1774
|
...questions ? { questions } : {},
|
|
1726
1775
|
...state.answers?.length ? { answers: state.answers } : {},
|
|
1727
1776
|
...items ? {
|
|
@@ -1733,7 +1782,8 @@ function taskContext(current, task, exportDir2, state = {}, questions, opts = {}
|
|
|
1733
1782
|
item,
|
|
1734
1783
|
what: itemWhat(x, item, entries.get(itemObject(item)), task.track),
|
|
1735
1784
|
...covered ? { covered } : {},
|
|
1736
|
-
...weight === void 0 ? {} : { weight }
|
|
1785
|
+
...weight === void 0 ? {} : { weight },
|
|
1786
|
+
...words2.labels?.[item] ? { label: words2.labels[item] } : {}
|
|
1737
1787
|
};
|
|
1738
1788
|
}),
|
|
1739
1789
|
known: state.covered !== void 0,
|
|
@@ -1983,8 +2033,11 @@ ${ticks}`;
|
|
|
1983
2033
|
};
|
|
1984
2034
|
function renderContext(c) {
|
|
1985
2035
|
const out = [
|
|
1986
|
-
`# ${c.task}: ${c.change.title}`,
|
|
2036
|
+
`# ${c.task}: ${c.title ?? c.change.title}`,
|
|
1987
2037
|
"",
|
|
2038
|
+
// The words the lists show for the task: what a person calls it, never what to build from.
|
|
2039
|
+
...c.summary ? [c.summary, ""] : [],
|
|
2040
|
+
...c.title ? [`Change: ${c.change.title}.`, ""] : [],
|
|
1988
2041
|
`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
2042
|
];
|
|
1990
2043
|
const movedSince = (c.changedSince ?? []).filter((e) => !e.entered);
|
|
@@ -2024,7 +2077,7 @@ function renderContext(c) {
|
|
|
2024
2077
|
...list2.note ? ["", `Covered items unknown: ${list2.note}`] : [],
|
|
2025
2078
|
"",
|
|
2026
2079
|
...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)})` : ""}`
|
|
2080
|
+
(i) => `- [${i.covered ? "x" : " "}] \`${i.item}\`${i.weight === void 0 ? "" : ` (w ${i.weight})`}: ${i.label ? `**${i.label}** \u2014 ` : ""}${i.what}${i.covered ? ` (covered by ${i.covered.slice(0, 12)})` : ""}`
|
|
2028
2081
|
)
|
|
2029
2082
|
);
|
|
2030
2083
|
}
|
|
@@ -2712,7 +2765,11 @@ var PROMPTS_DIR = `${CLIENT_DIR}/prompts`;
|
|
|
2712
2765
|
var MANIFEST_PATH2 = `${CLIENT_DIR}/manifest.json`;
|
|
2713
2766
|
var MCP_JSON = ".mcp.json";
|
|
2714
2767
|
var MCP_SERVER = "dispatcher";
|
|
2715
|
-
var
|
|
2768
|
+
var PACKAGE = "@alterset/alterspec-client";
|
|
2769
|
+
var INVOCATION = `npx ${PACKAGE}`;
|
|
2770
|
+
var invocation = (npxArgs = []) => ["npx", ...npxArgs, PACKAGE].join(" ");
|
|
2771
|
+
var mcpEntry = (npxArgs = []) => ({ command: "npx", args: [...npxArgs, PACKAGE, "mcp"] });
|
|
2772
|
+
var MCP_ENTRY = mcpEntry();
|
|
2716
2773
|
function walk(dir) {
|
|
2717
2774
|
return readdirSync3(dir).sort().flatMap((n) => statSync(join7(dir, n)).isDirectory() ? walk(join7(dir, n)) : [join7(dir, n)]);
|
|
2718
2775
|
}
|
|
@@ -2720,7 +2777,12 @@ var assetFiles = (sub) => walk(join7(ASSETS_DIR, sub)).map((f) => ({
|
|
|
2720
2777
|
rel: relative(join7(ASSETS_DIR, sub), f).split("\\").join("/"),
|
|
2721
2778
|
content: readFileSync6(f, "utf8")
|
|
2722
2779
|
}));
|
|
2723
|
-
function buildClientPlan(version) {
|
|
2780
|
+
function buildClientPlan(version, npxArgs = []) {
|
|
2781
|
+
const plan = clientPlan(version);
|
|
2782
|
+
if (!npxArgs.length) return plan;
|
|
2783
|
+
return plan.map((f) => ({ ...f, content: f.content.split(INVOCATION).join(invocation(npxArgs)) }));
|
|
2784
|
+
}
|
|
2785
|
+
function clientPlan(version) {
|
|
2724
2786
|
return [
|
|
2725
2787
|
...assetFiles("skills").map((f) => ({
|
|
2726
2788
|
path: `.claude/skills/${f.rel}`,
|
|
@@ -2741,7 +2803,7 @@ function buildClientPlan(version) {
|
|
|
2741
2803
|
`, policy: "framework" }
|
|
2742
2804
|
];
|
|
2743
2805
|
}
|
|
2744
|
-
function writeMcpJson(root) {
|
|
2806
|
+
function writeMcpJson(root, npxArgs = []) {
|
|
2745
2807
|
const path = join7(root, MCP_JSON);
|
|
2746
2808
|
let data = {};
|
|
2747
2809
|
const before2 = existsSync7(path) ? readFileSync6(path, "utf8") : void 0;
|
|
@@ -2751,23 +2813,25 @@ function writeMcpJson(root) {
|
|
|
2751
2813
|
} catch {
|
|
2752
2814
|
throw new ConfigError(`${path} is not valid JSON: fix it, then run init again.`);
|
|
2753
2815
|
}
|
|
2754
|
-
data.mcpServers = { ...data.mcpServers ?? {}, [MCP_SERVER]:
|
|
2816
|
+
data.mcpServers = { ...data.mcpServers ?? {}, [MCP_SERVER]: mcpEntry(npxArgs) };
|
|
2755
2817
|
const after2 = JSON.stringify(data, null, 2) + "\n";
|
|
2756
2818
|
if (after2 === before2) return "unchanged";
|
|
2757
2819
|
writeFileSync5(path, after2);
|
|
2758
2820
|
return before2 === void 0 ? "created" : "updated";
|
|
2759
2821
|
}
|
|
2760
2822
|
var CLAUDE_SETTINGS = ".claude/settings.json";
|
|
2761
|
-
var
|
|
2762
|
-
var HOOK_ENTRY = {
|
|
2823
|
+
var hookEntry = (npxArgs = []) => ({
|
|
2763
2824
|
type: "command",
|
|
2764
2825
|
if: "Bash(git commit *)",
|
|
2765
|
-
command:
|
|
2826
|
+
command: `${invocation(npxArgs)} progress --hook`,
|
|
2766
2827
|
timeout: 60,
|
|
2767
2828
|
async: true
|
|
2768
|
-
};
|
|
2769
|
-
var
|
|
2770
|
-
|
|
2829
|
+
});
|
|
2830
|
+
var HOOK_ENTRY = hookEntry();
|
|
2831
|
+
var HOOK_COMMAND = HOOK_ENTRY.command;
|
|
2832
|
+
var isOurs = (h) => typeof h.command === "string" && h.command.includes(`${PACKAGE} progress`);
|
|
2833
|
+
function writeClaudeSettings(root, npxArgs = []) {
|
|
2834
|
+
const entry = hookEntry(npxArgs);
|
|
2771
2835
|
const path = join7(root, CLAUDE_SETTINGS);
|
|
2772
2836
|
const before2 = existsSync7(path) ? readFileSync6(path, "utf8") : void 0;
|
|
2773
2837
|
let data = {};
|
|
@@ -2785,9 +2849,9 @@ function writeClaudeSettings(root) {
|
|
|
2785
2849
|
if (!isOurs(h)) return [h];
|
|
2786
2850
|
if (found) return [];
|
|
2787
2851
|
found = true;
|
|
2788
|
-
return [
|
|
2852
|
+
return [entry];
|
|
2789
2853
|
});
|
|
2790
|
-
if (!found) groups.push({ matcher: "Bash", hooks: [
|
|
2854
|
+
if (!found) groups.push({ matcher: "Bash", hooks: [entry] });
|
|
2791
2855
|
const after2 = JSON.stringify(data, null, 2) + "\n";
|
|
2792
2856
|
if (before2 !== void 0 && JSON.stringify(JSON.parse(before2)) === JSON.stringify(data)) return "unchanged";
|
|
2793
2857
|
mkdirSync3(join7(root, ".claude"), { recursive: true });
|
|
@@ -2857,14 +2921,16 @@ function initClient(root, opts, version) {
|
|
|
2857
2921
|
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
2922
|
);
|
|
2859
2923
|
}
|
|
2924
|
+
if (!parsed.data.npx?.args.length) delete parsed.data.npx;
|
|
2925
|
+
const npxArgs = parsed.data.npx?.args ?? [];
|
|
2860
2926
|
const before2 = existing && JSON.stringify(existing);
|
|
2861
2927
|
const config = !existing ? "created" : before2 === JSON.stringify(parsed.data) ? "unchanged" : "updated";
|
|
2862
2928
|
if (config !== "unchanged") writeConfig(root, parsed.data);
|
|
2863
|
-
const mcp = writeMcpJson(root);
|
|
2864
|
-
const hook = writeClaudeSettings(root);
|
|
2929
|
+
const mcp = writeMcpJson(root, npxArgs);
|
|
2930
|
+
const hook = writeClaudeSettings(root, npxArgs);
|
|
2865
2931
|
const ignore = ignoreLocalSettings(root);
|
|
2866
2932
|
const approval = writeLocalSettings(root);
|
|
2867
|
-
const files = install(root, buildClientPlan(version), {
|
|
2933
|
+
const files = install(root, buildClientPlan(version, npxArgs), {
|
|
2868
2934
|
mode: "update",
|
|
2869
2935
|
force,
|
|
2870
2936
|
version,
|
|
@@ -3240,17 +3306,48 @@ function coveredItems(repo, task) {
|
|
|
3240
3306
|
return [...first].map(([item, commit]) => ({ item, commit })).sort((a, b) => a.item < b.item ? -1 : a.item > b.item ? 1 : 0);
|
|
3241
3307
|
}
|
|
3242
3308
|
var unknownOf = (e) => e.message.split("\n").slice(1).map((l) => l.trim()).filter(Boolean);
|
|
3309
|
+
async function checklistOf(session, task) {
|
|
3310
|
+
try {
|
|
3311
|
+
const answer = await callTool(session, "task", { id: task.id });
|
|
3312
|
+
return (answer.items ?? []).map((i) => ({
|
|
3313
|
+
item: i.item,
|
|
3314
|
+
covered: !!i.covered_commit
|
|
3315
|
+
}));
|
|
3316
|
+
} catch {
|
|
3317
|
+
return [];
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
function sortRefused(refused, sent, checklist) {
|
|
3321
|
+
const sentSet = new Set(sent);
|
|
3322
|
+
const out = {
|
|
3323
|
+
unknown: [],
|
|
3324
|
+
misnamed: [],
|
|
3325
|
+
superseded: []
|
|
3326
|
+
};
|
|
3327
|
+
for (const item of refused) {
|
|
3328
|
+
const parts = item.includes("#") ? [] : checklist.filter((c) => c.item.startsWith(`${item}#`));
|
|
3329
|
+
if (!parts.length) out.unknown.push(item);
|
|
3330
|
+
else if (parts.some((p) => p.covered || sentSet.has(p.item))) out.superseded.push(item);
|
|
3331
|
+
else out.misnamed.push({ item, forms: parts.map((p) => p.item).sort() });
|
|
3332
|
+
}
|
|
3333
|
+
return out;
|
|
3334
|
+
}
|
|
3243
3335
|
async function reportProgress(session, task, covered) {
|
|
3244
3336
|
try {
|
|
3245
3337
|
const answer = await callTool(session, "report_progress", { id: task.id, covered });
|
|
3246
|
-
return { task: task.id, covered, unknown: [], answer };
|
|
3338
|
+
return { task: task.id, covered, unknown: [], misnamed: [], superseded: [], answer };
|
|
3247
3339
|
} catch (e) {
|
|
3248
3340
|
if (!(e instanceof DispatcherError) || e.code !== "UNKNOWN_ITEM") throw e;
|
|
3249
|
-
const
|
|
3250
|
-
const known = covered.filter((c) => !
|
|
3251
|
-
if (!
|
|
3341
|
+
const refused = unknownOf(e);
|
|
3342
|
+
const known = covered.filter((c) => !refused.includes(c.item));
|
|
3343
|
+
if (!refused.length || known.length === covered.length) throw e;
|
|
3252
3344
|
const answer = await callTool(session, "report_progress", { id: task.id, covered: known });
|
|
3253
|
-
|
|
3345
|
+
const sorted = sortRefused(
|
|
3346
|
+
refused,
|
|
3347
|
+
known.map((c) => c.item),
|
|
3348
|
+
await checklistOf(session, task)
|
|
3349
|
+
);
|
|
3350
|
+
return { task: task.id, covered: known, ...sorted, answer };
|
|
3254
3351
|
}
|
|
3255
3352
|
}
|
|
3256
3353
|
function progressText(r) {
|
|
@@ -3259,11 +3356,14 @@ function progressText(r) {
|
|
|
3259
3356
|
const eta = r.answer.eta;
|
|
3260
3357
|
const count = progress ? `${progress.covered} of ${progress.of} items covered (${progress.percent} %${weight ? `, ${weight.covered} of ${weight.total} weight` : ""})` : "no checklist (its export predates task items)";
|
|
3261
3358
|
const when = !eta ? "" : eta.by === "done" ? "; done" : eta.date ? `; ETA ${eta.at_least ? "at least " : ""}${eta.date}${eta.by === "developer" ? ` (yours; computed ${eta.computed?.date ?? "unknown"})` : ""}` : "; ETA unknown";
|
|
3262
|
-
|
|
3263
|
-
if (r.unknown.length) lines.unshift(unknownLine(r));
|
|
3264
|
-
return lines.join("\n") + "\n";
|
|
3359
|
+
return [...refusedLines(r), `${r.task}: ${count}${when}.`].join("\n") + "\n";
|
|
3265
3360
|
}
|
|
3361
|
+
var refusedLines = (r) => [
|
|
3362
|
+
...r.unknown.length ? [unknownLine(r)] : [],
|
|
3363
|
+
...r.misnamed.map(misnamedLine)
|
|
3364
|
+
];
|
|
3266
3365
|
var unknownLine = (r) => `${r.task} has no item ${r.unknown.join(", ")}; left out of the report: name only the task's items (context lists them).`;
|
|
3366
|
+
var misnamedLine = (m) => `${m.item} is named without its section; the checklist writes it as ${m.forms.join(m.forms.length > 2 ? ", " : " or ")}: name ${m.forms.length === 1 ? "that" : "the part you covered"} in Alterspec-Covers (left out of the report).`;
|
|
3267
3367
|
var THROTTLE_MS = 15 * 6e4;
|
|
3268
3368
|
var statePath = (repo, task) => join8(
|
|
3269
3369
|
git3(repo, ["rev-parse", "--path-format=absolute", "--git-common-dir"]),
|
|
@@ -3289,7 +3389,14 @@ async function progressHook(opts) {
|
|
|
3289
3389
|
const hash = hashOf(covered);
|
|
3290
3390
|
if (state?.reported === hash) return "unchanged";
|
|
3291
3391
|
if (state && now() - Date.parse(state.at) < THROTTLE_MS) return "throttled";
|
|
3292
|
-
await reportProgress(opts.session(), task, covered);
|
|
3392
|
+
const report = await reportProgress(opts.session(), task, covered);
|
|
3393
|
+
const named2 = new Set(headCovers(opts.repo, task));
|
|
3394
|
+
const wrong = refusedLines({
|
|
3395
|
+
task: report.task,
|
|
3396
|
+
unknown: report.unknown.filter((i) => named2.has(i)),
|
|
3397
|
+
misnamed: report.misnamed.filter((m) => named2.has(m.item))
|
|
3398
|
+
});
|
|
3399
|
+
if (wrong.length && opts.say) opts.say(hookContext(wrong.join("\n")));
|
|
3293
3400
|
mkdirSync4(join8(path, ".."), { recursive: true });
|
|
3294
3401
|
writeFileSync6(path, JSON.stringify({ reported: hash, at: new Date(now()).toISOString() }) + "\n");
|
|
3295
3402
|
return "reported";
|
|
@@ -3297,6 +3404,23 @@ async function progressHook(opts) {
|
|
|
3297
3404
|
return "failed";
|
|
3298
3405
|
}
|
|
3299
3406
|
}
|
|
3407
|
+
function headCovers(repo, task) {
|
|
3408
|
+
const trailer = (key) => `%(trailers:key=${key},valueonly,separator=%x1d)`;
|
|
3409
|
+
const [tasks = "", covers = ""] = git3(repo, [
|
|
3410
|
+
"log",
|
|
3411
|
+
"-1",
|
|
3412
|
+
`--format=${trailer(TRAILER)}%x1f${trailer(COVERS)}`,
|
|
3413
|
+
"HEAD"
|
|
3414
|
+
]).split("");
|
|
3415
|
+
if (!tasks.split("").some((t) => t.trim().toUpperCase() === task.id)) return [];
|
|
3416
|
+
return covers.replaceAll("", ",").split(/[,\s]+/).filter(Boolean);
|
|
3417
|
+
}
|
|
3418
|
+
var hookContext = (text) => JSON.stringify({
|
|
3419
|
+
hookSpecificOutput: {
|
|
3420
|
+
hookEventName: "PostToolUse",
|
|
3421
|
+
additionalContext: `alterspec-client progress: ${text}`
|
|
3422
|
+
}
|
|
3423
|
+
}) + "\n";
|
|
3300
3424
|
async function hookCwd(input, waitMs = 1e3) {
|
|
3301
3425
|
if (input.isTTY) return void 0;
|
|
3302
3426
|
const text = await new Promise((resolve2) => {
|
|
@@ -3374,13 +3498,21 @@ var program = new Command();
|
|
|
3374
3498
|
program.name("alterspec-client").description("alterspec client \u2014 takes tasks of an alterspec export from the dispatcher.").version(packageVersion());
|
|
3375
3499
|
program.command("init").description(
|
|
3376
3500
|
"set the client up in this repository: configuration, the dispatcher in .mcp.json, the progress hook, the skills"
|
|
3377
|
-
).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(
|
|
3501
|
+
).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(
|
|
3502
|
+
"--npx <flags>",
|
|
3503
|
+
"flags this project runs npx with, comma-separated (--npx=--min-release-age=0); --npx= removes them"
|
|
3504
|
+
).option("--force", "replace skills you modified").action(
|
|
3378
3505
|
run(
|
|
3379
3506
|
(opts) => {
|
|
3380
3507
|
const root = process.cwd();
|
|
3381
|
-
const { track, ...rest } = opts;
|
|
3508
|
+
const { track, npx, ...rest } = opts;
|
|
3509
|
+
const npxArgs = npx?.split(",").map((a) => a.trim()).filter(Boolean);
|
|
3382
3510
|
const tracks = track?.flatMap((t) => t.split(",")).map((t) => t.trim().toUpperCase()).filter(Boolean);
|
|
3383
|
-
const r = initClient(
|
|
3511
|
+
const r = initClient(
|
|
3512
|
+
root,
|
|
3513
|
+
{ ...rest, ...tracks ? { tracks } : {}, ...npxArgs ? { npx: { args: npxArgs } } : {} },
|
|
3514
|
+
packageVersion()
|
|
3515
|
+
);
|
|
3384
3516
|
const f = r.files;
|
|
3385
3517
|
const lines = [
|
|
3386
3518
|
`${CONFIG_FILE}: ${r.config}`,
|
|
@@ -3491,7 +3623,11 @@ program.command("progress").description("report the items the task\u2019s commit
|
|
|
3491
3623
|
if (opts.hook) {
|
|
3492
3624
|
setTimeout(() => process.exit(0), 3e4).unref();
|
|
3493
3625
|
const repo = await hookCwd(process.stdin) ?? process.cwd();
|
|
3494
|
-
await progressHook({
|
|
3626
|
+
await progressHook({
|
|
3627
|
+
repo,
|
|
3628
|
+
session: () => sessionOf(loadConfig(repo)),
|
|
3629
|
+
say: (text) => process.stdout.write(text)
|
|
3630
|
+
});
|
|
3495
3631
|
process.exit(0);
|
|
3496
3632
|
}
|
|
3497
3633
|
await run(async () => {
|