@alterset/alterspec-client 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/prompts/_shared.md +25 -6
- package/assets/prompts/task-context.md +9 -6
- package/assets/prompts/task-done.md +5 -3
- package/assets/prompts/task-eta.md +14 -0
- package/assets/prompts/task-status.md +10 -3
- package/assets/skills/alterspec-task-eta/SKILL.md +11 -0
- package/assets/skills/alterspec-task-status/SKILL.md +1 -1
- package/dist/cli.js +535 -218
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3,12 +3,140 @@
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
|
|
6
|
-
// src/
|
|
6
|
+
// src/config.ts
|
|
7
7
|
import { execFileSync } from "child_process";
|
|
8
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
9
|
+
import { homedir } from "os";
|
|
10
|
+
import { basename, dirname, isAbsolute, join, resolve } from "path";
|
|
11
|
+
import { z as z2 } from "zod";
|
|
12
|
+
|
|
13
|
+
// ../src/schemas/work.ts
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
var TrackCode = z.string().regex(/^[A-Z]{2,5}$/, { message: "must be BE or a channel code" });
|
|
16
|
+
var ChangeRef = z.string().regex(/^CHG-\d{3,}$/);
|
|
17
|
+
var Day = z.iso.date();
|
|
18
|
+
var WorkTrackSchema = z.object({
|
|
19
|
+
code: TrackCode,
|
|
20
|
+
kind: z.enum(["backend", "ui"]),
|
|
21
|
+
/** The channel codes the track builds: the API channels for `BE`, the channels sharing the experience for a UI track. */
|
|
22
|
+
channels: z.array(z.string())
|
|
23
|
+
}).strict();
|
|
24
|
+
var WorkTaskSchema = z.object({
|
|
25
|
+
track: TrackCode,
|
|
26
|
+
/** The keys of the objects in the change's delta that put it on the track. */
|
|
27
|
+
objects: z.array(z.string()),
|
|
28
|
+
/**
|
|
29
|
+
* The task's checklist, derived from the delta: the acceptance criteria (`<CAP>-AC-NN`), screen actions
|
|
30
|
+
* (`<SCR>.Ann`) and contract states (`<UX-SCR>#<state>`) the change adds or changes, and every other object as
|
|
31
|
+
* its key. Sorted, never empty.
|
|
32
|
+
*/
|
|
33
|
+
items: z.array(z.string().min(1)).min(1),
|
|
34
|
+
/** The tasks this one waits for, resolved: the same change's `BE` task, and the track's tasks it builds on. */
|
|
35
|
+
after: z.array(z.object({ change: ChangeRef, track: TrackCode }).strict())
|
|
36
|
+
}).strict();
|
|
37
|
+
var WorkChangeSchema = z.object({
|
|
38
|
+
id: ChangeRef,
|
|
39
|
+
title: z.string(),
|
|
40
|
+
signed_off: Day,
|
|
41
|
+
/** The hash of the change's `delta.json`; a signed-off change never changes. */
|
|
42
|
+
delta: z.string().regex(/^[0-9a-f]{16}$/),
|
|
43
|
+
depends_on: z.array(ChangeRef),
|
|
44
|
+
/** The change map's level. */
|
|
45
|
+
level: z.number().int().min(1),
|
|
46
|
+
/** One per track the change is on; empty = no work. */
|
|
47
|
+
tasks: z.array(WorkTaskSchema)
|
|
48
|
+
}).strict();
|
|
49
|
+
var WORK_FORMAT = 2;
|
|
50
|
+
var WorkSchema = z.object({
|
|
51
|
+
format: z.literal(WORK_FORMAT),
|
|
52
|
+
/** The alterspec version that wrote the export. */
|
|
53
|
+
alterspec: z.string(),
|
|
54
|
+
exported: Day,
|
|
55
|
+
/** Everything signed off before the changes began; `built`: the product as it runs (a reverse-spec), no work. */
|
|
56
|
+
baseline: z.object({ date: Day, built: z.boolean() }).strict().nullable(),
|
|
57
|
+
tracks: z.array(WorkTrackSchema),
|
|
58
|
+
/** Every change signed off after the baseline, in the change map's order. */
|
|
59
|
+
changes: z.array(WorkChangeSchema)
|
|
60
|
+
}).strict();
|
|
61
|
+
var WorkTaskV1Schema = WorkTaskSchema.omit({ items: true });
|
|
62
|
+
var WorkV1Schema = WorkSchema.extend({
|
|
63
|
+
format: z.literal(1),
|
|
64
|
+
changes: z.array(WorkChangeSchema.extend({ tasks: z.array(WorkTaskV1Schema) }).strict())
|
|
65
|
+
}).strict();
|
|
66
|
+
var AnyWorkSchema = z.discriminatedUnion("format", [WorkV1Schema, WorkSchema]);
|
|
67
|
+
|
|
68
|
+
// src/config.ts
|
|
69
|
+
var CONFIG_FILE = ".alterspec-client.json";
|
|
70
|
+
var ClientConfigSchema = z2.object({
|
|
71
|
+
/** The dispatcher's URL. */
|
|
72
|
+
dispatcher: z2.url(),
|
|
73
|
+
/** The developer's clone of the export repository, relative to this file's folder or absolute. */
|
|
74
|
+
export: z2.string().min(1),
|
|
75
|
+
/** The tracks this repository builds: the default of `next_task`. */
|
|
76
|
+
tracks: z2.array(TrackCode).default([]),
|
|
77
|
+
/** Where `worktree` puts a task's worktree; default `../<repo>-tasks`. */
|
|
78
|
+
worktrees: z2.string().min(1).optional(),
|
|
79
|
+
/** The public key to sign with: a `.pub` path or the key line; default ssh-agent, then `~/.ssh/id_ed25519.pub`. */
|
|
80
|
+
key: z2.string().min(1).optional(),
|
|
81
|
+
/** The track's main branch; default the remote's `HEAD`, else `main`. */
|
|
82
|
+
branch: z2.string().min(1).optional()
|
|
83
|
+
}).strict();
|
|
84
|
+
var ConfigError = class extends Error {
|
|
85
|
+
};
|
|
86
|
+
var git = (cwd, ...args) => {
|
|
87
|
+
try {
|
|
88
|
+
return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
89
|
+
} catch {
|
|
90
|
+
return void 0;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
function candidates(cwd) {
|
|
94
|
+
const top = git(cwd, "rev-parse", "--show-toplevel");
|
|
95
|
+
const common = git(cwd, "rev-parse", "--path-format=absolute", "--git-common-dir");
|
|
96
|
+
const main = common && basename(common) === ".git" ? dirname(common) : void 0;
|
|
97
|
+
return [...new Set([top, main, resolve(cwd)].filter((d) => !!d))];
|
|
98
|
+
}
|
|
99
|
+
function readConfigAt(root) {
|
|
100
|
+
const path = join(root, CONFIG_FILE);
|
|
101
|
+
if (!existsSync(path)) return void 0;
|
|
102
|
+
let raw;
|
|
103
|
+
try {
|
|
104
|
+
raw = JSON.parse(readFileSync(path, "utf8"));
|
|
105
|
+
} catch {
|
|
106
|
+
throw new ConfigError(`${path} is not valid JSON.`);
|
|
107
|
+
}
|
|
108
|
+
const parsed = ClientConfigSchema.safeParse(raw);
|
|
109
|
+
if (!parsed.success)
|
|
110
|
+
throw new ConfigError(
|
|
111
|
+
`${path} is not valid: ${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}.`
|
|
112
|
+
);
|
|
113
|
+
return parsed.data;
|
|
114
|
+
}
|
|
115
|
+
function loadConfig(cwd = process.cwd()) {
|
|
116
|
+
for (const root of candidates(cwd)) {
|
|
117
|
+
const config = readConfigAt(root);
|
|
118
|
+
if (config) return { root, config };
|
|
119
|
+
}
|
|
120
|
+
throw new ConfigError(
|
|
121
|
+
`No ${CONFIG_FILE} here: run \`npx @alterset/alterspec-client init --dispatcher <url> --export <path>\` first.`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function configPath(root, path) {
|
|
125
|
+
if (path === "~" || path.startsWith("~/")) return join(homedir(), path.slice(1));
|
|
126
|
+
return isAbsolute(path) ? path : resolve(root, path);
|
|
127
|
+
}
|
|
128
|
+
var exportDir = ({ root, config }) => configPath(root, config.export);
|
|
129
|
+
var worktreesDir = ({ root, config }) => configPath(root, config.worktrees ?? `../${basename(root)}-tasks`);
|
|
130
|
+
function writeConfig(root, config) {
|
|
131
|
+
writeFileSync(join(root, CONFIG_FILE), JSON.stringify(config, null, 2) + "\n");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/ssh.ts
|
|
135
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
8
136
|
import { createHash } from "crypto";
|
|
9
|
-
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
10
|
-
import { homedir, tmpdir } from "os";
|
|
11
|
-
import { join } from "path";
|
|
137
|
+
import { existsSync as existsSync2, mkdtempSync, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
138
|
+
import { homedir as homedir2, tmpdir } from "os";
|
|
139
|
+
import { join as join2 } from "path";
|
|
12
140
|
var NAMESPACE = "alterspec-dispatcher";
|
|
13
141
|
var KEY_TYPES = ["ssh-ed25519", "sk-ssh-ed25519@openssh.com"];
|
|
14
142
|
var KeyError = class extends Error {
|
|
@@ -25,23 +153,23 @@ function parseKeyLine(line, source, file) {
|
|
|
25
153
|
}
|
|
26
154
|
function agentKeys() {
|
|
27
155
|
try {
|
|
28
|
-
return
|
|
156
|
+
return execFileSync2("ssh-add", ["-L"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).split("\n").filter((l) => l.trim());
|
|
29
157
|
} catch {
|
|
30
158
|
return [];
|
|
31
159
|
}
|
|
32
160
|
}
|
|
33
161
|
var isKeyLine = (s) => KEY_TYPES.some((t) => s.trim().startsWith(`${t} `));
|
|
34
162
|
function resolveKey(opts = {}) {
|
|
35
|
-
const { configured, agent = agentKeys, home =
|
|
163
|
+
const { configured, agent = agentKeys, home = homedir2() } = opts;
|
|
36
164
|
if (configured) {
|
|
37
165
|
if (isKeyLine(configured)) return parseKeyLine(configured, "the configuration");
|
|
38
|
-
if (!
|
|
39
|
-
return parseKeyLine(
|
|
166
|
+
if (!existsSync2(configured)) throw new KeyError(`The configured key ${configured} doesn't exist.`);
|
|
167
|
+
return parseKeyLine(readFileSync2(configured, "utf8"), configured, configured);
|
|
40
168
|
}
|
|
41
169
|
const fromAgent = agent().find((l) => l.startsWith("ssh-ed25519 "));
|
|
42
170
|
if (fromAgent) return parseKeyLine(fromAgent, "ssh-agent");
|
|
43
|
-
const file =
|
|
44
|
-
if (
|
|
171
|
+
const file = join2(home, ".ssh", "id_ed25519.pub");
|
|
172
|
+
if (existsSync2(file)) return parseKeyLine(readFileSync2(file, "utf8"), file, file);
|
|
45
173
|
throw new KeyError(
|
|
46
174
|
"No SSH key to sign with: add an ssh-ed25519 key to ssh-agent, create ~/.ssh/id_ed25519, or name one as `key` in .alterspec-client.json."
|
|
47
175
|
);
|
|
@@ -49,22 +177,22 @@ function resolveKey(opts = {}) {
|
|
|
49
177
|
var blobOf = (line) => line.trim().split(/\s+/)[1];
|
|
50
178
|
function sign(key, data, agent = agentKeys) {
|
|
51
179
|
const inAgent = agent().some((l) => blobOf(l) === blobOf(key.line));
|
|
52
|
-
const temp = !key.file || inAgent ? mkdtempSync(
|
|
180
|
+
const temp = !key.file || inAgent ? mkdtempSync(join2(tmpdir(), "alterspec-client-")) : void 0;
|
|
53
181
|
try {
|
|
54
182
|
let keyFile;
|
|
55
183
|
if (inAgent || !key.file) {
|
|
56
184
|
if (!inAgent)
|
|
57
185
|
throw new KeyError(`ssh-agent doesn't hold the key ${key.fingerprint}: add it with ssh-add.`);
|
|
58
|
-
keyFile =
|
|
59
|
-
|
|
186
|
+
keyFile = join2(temp, "key.pub");
|
|
187
|
+
writeFileSync2(keyFile, key.line + "\n");
|
|
60
188
|
} else {
|
|
61
189
|
keyFile = key.file.replace(/\.pub$/, "");
|
|
62
|
-
if (keyFile === key.file || !
|
|
190
|
+
if (keyFile === key.file || !existsSync2(keyFile))
|
|
63
191
|
throw new KeyError(
|
|
64
192
|
`No private key beside ${key.file} and ssh-agent doesn't hold it: add it with ssh-add.`
|
|
65
193
|
);
|
|
66
194
|
}
|
|
67
|
-
return
|
|
195
|
+
return execFileSync2("ssh-keygen", ["-q", "-Y", "sign", "-n", NAMESPACE, "-f", keyFile], {
|
|
68
196
|
input: data,
|
|
69
197
|
encoding: "utf8",
|
|
70
198
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -179,22 +307,28 @@ var Session = class {
|
|
|
179
307
|
}
|
|
180
308
|
}
|
|
181
309
|
};
|
|
310
|
+
function keyOf(loaded) {
|
|
311
|
+
const key = loaded?.config.key;
|
|
312
|
+
const configured = key && !/^(ssh-ed25519|sk-ssh-ed25519@openssh\.com) /.test(key) ? configPath(loaded.root, key) : key;
|
|
313
|
+
return resolveKey({ configured });
|
|
314
|
+
}
|
|
315
|
+
var sessionOf = (loaded) => new Session(loaded.config.dispatcher, keyOf(loaded));
|
|
182
316
|
|
|
183
317
|
// ../src/export/read.ts
|
|
184
|
-
import { existsSync as
|
|
185
|
-
import { join as
|
|
318
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "fs";
|
|
319
|
+
import { join as join3 } from "path";
|
|
186
320
|
|
|
187
321
|
// ../src/schemas/delta.ts
|
|
188
|
-
import { z as
|
|
322
|
+
import { z as z6 } from "zod";
|
|
189
323
|
|
|
190
324
|
// ../src/schemas/change.ts
|
|
191
|
-
import { z as
|
|
325
|
+
import { z as z5 } from "zod";
|
|
192
326
|
|
|
193
327
|
// ../src/schemas/common.ts
|
|
194
|
-
import { z as
|
|
328
|
+
import { z as z4 } from "zod";
|
|
195
329
|
|
|
196
330
|
// ../src/schemas/ids.ts
|
|
197
|
-
import { z } from "zod";
|
|
331
|
+
import { z as z3 } from "zod";
|
|
198
332
|
var CODE = "[A-Z]{2,6}";
|
|
199
333
|
var NAME = "[A-Z0-9]+(?:-[A-Z0-9]+)*";
|
|
200
334
|
var CHANNEL_CODE = "[A-Z]{2,5}";
|
|
@@ -220,7 +354,7 @@ var ID_PATTERNS = {
|
|
|
220
354
|
var ID_REGEX = Object.fromEntries(
|
|
221
355
|
Object.entries(ID_PATTERNS).map(([k, p]) => [k, new RegExp(p)])
|
|
222
356
|
);
|
|
223
|
-
var idOf = (kind, label) =>
|
|
357
|
+
var idOf = (kind, label) => z3.string().regex(ID_REGEX[kind], { message: `must be a ${label} ID matching ${ID_PATTERNS[kind]}` });
|
|
224
358
|
var AppId = idOf("app", "application");
|
|
225
359
|
var ModuleId = idOf("module", "module");
|
|
226
360
|
var CapabilityId = idOf("capability", "capability");
|
|
@@ -238,15 +372,18 @@ var DecisionId = idOf("decision", "decision");
|
|
|
238
372
|
var ChangeId = idOf("change", "change");
|
|
239
373
|
var AcceptanceId = idOf("acceptance", "acceptance criterion");
|
|
240
374
|
var ScreenActionId = idOf("screenAction", "screen action");
|
|
241
|
-
var ChannelCode =
|
|
242
|
-
var AnyId =
|
|
375
|
+
var ChannelCode = z3.string().regex(new RegExp(`^${CHANNEL_CODE}$`), { message: "must be 2\u20135 uppercase letters, e.g. WEB or MOB" });
|
|
376
|
+
var AnyId = z3.string().refine(
|
|
243
377
|
(v) => Object.keys(ID_REGEX).some((k) => k !== "screenAction" && ID_REGEX[k].test(v)),
|
|
244
378
|
{ message: "must be a valid alterspec ID" }
|
|
245
379
|
);
|
|
246
380
|
var codeInId = (id) => /^(?:CAP|SCR|RULE)-([A-Z]{2,6})-/.exec(id)?.[1];
|
|
381
|
+
function idKind(id) {
|
|
382
|
+
return Object.keys(ID_REGEX).find((k) => ID_REGEX[k].test(id));
|
|
383
|
+
}
|
|
247
384
|
|
|
248
385
|
// ../src/schemas/common.ts
|
|
249
|
-
var Status =
|
|
386
|
+
var Status = z4.enum(["draft", "ready", "signed_off"], {
|
|
250
387
|
error: (iss) => {
|
|
251
388
|
const was = {
|
|
252
389
|
refined: "refined is no longer a status; a complete object is ready",
|
|
@@ -257,120 +394,65 @@ var Status = z2.enum(["draft", "ready", "signed_off"], {
|
|
|
257
394
|
return said ? `${said}; \`alterspec status migrate\` moves a spec to the current statuses` : void 0;
|
|
258
395
|
}
|
|
259
396
|
});
|
|
260
|
-
var Scope =
|
|
261
|
-
var Op =
|
|
262
|
-
var Title =
|
|
263
|
-
var Version =
|
|
264
|
-
var StateName =
|
|
397
|
+
var Scope = z4.enum(["own", "team", "org", "all"]);
|
|
398
|
+
var Op = z4.enum(["C", "R", "U", "D", "A"]);
|
|
399
|
+
var Title = z4.string().trim().min(1, { message: "must not be empty" });
|
|
400
|
+
var Version = z4.number().int().min(1);
|
|
401
|
+
var StateName = z4.string().regex(/^[a-z][a-z0-9_]*$/, {
|
|
265
402
|
message: "must be a lowercase state name (letters, digits, underscore)"
|
|
266
403
|
});
|
|
267
|
-
var TransitionRef =
|
|
404
|
+
var TransitionRef = z4.string().regex(/^[a-z][a-z0-9_]*->[a-z][a-z0-9_]*$/, {
|
|
268
405
|
message: "must be written as from->to, e.g. draft->active"
|
|
269
406
|
});
|
|
270
|
-
var list = (item) =>
|
|
271
|
-
var AcceptSchema =
|
|
407
|
+
var list = (item) => z4.array(item).default([]);
|
|
408
|
+
var AcceptSchema = z4.object({
|
|
272
409
|
/** The lint rule's name. */
|
|
273
|
-
rule:
|
|
410
|
+
rule: z4.string().trim().min(1),
|
|
274
411
|
/** Part of the finding's message; absent, every finding of the rule on this object is accepted. */
|
|
275
|
-
match:
|
|
412
|
+
match: z4.string().trim().min(1).optional(),
|
|
276
413
|
/** The decided `DEC-NNN` (kind decision) that records why, naming this object in `affects`. */
|
|
277
414
|
decision: DecisionId,
|
|
278
|
-
reason:
|
|
279
|
-
}).strict();
|
|
280
|
-
|
|
281
|
-
// ../src/schemas/work.ts
|
|
282
|
-
import { z as z3 } from "zod";
|
|
283
|
-
var TrackCode = z3.string().regex(/^[A-Z]{2,5}$/, { message: "must be BE or a channel code" });
|
|
284
|
-
var ChangeRef = z3.string().regex(/^CHG-\d{3,}$/);
|
|
285
|
-
var Day = z3.iso.date();
|
|
286
|
-
var WorkTrackSchema = z3.object({
|
|
287
|
-
code: TrackCode,
|
|
288
|
-
kind: z3.enum(["backend", "ui"]),
|
|
289
|
-
/** The channel codes the track builds: the API channels for `BE`, the channels sharing the experience for a UI track. */
|
|
290
|
-
channels: z3.array(z3.string())
|
|
291
|
-
}).strict();
|
|
292
|
-
var WorkTaskSchema = z3.object({
|
|
293
|
-
track: TrackCode,
|
|
294
|
-
/** The keys of the objects in the change's delta that put it on the track. */
|
|
295
|
-
objects: z3.array(z3.string()),
|
|
296
|
-
/**
|
|
297
|
-
* The task's checklist, derived from the delta: the acceptance criteria (`<CAP>-AC-NN`), screen actions
|
|
298
|
-
* (`<SCR>.Ann`) and contract states (`<UX-SCR>#<state>`) the change adds or changes, and every other object as
|
|
299
|
-
* its key. Sorted, never empty.
|
|
300
|
-
*/
|
|
301
|
-
items: z3.array(z3.string().min(1)).min(1),
|
|
302
|
-
/** The tasks this one waits for, resolved: the same change's `BE` task, and the track's tasks it builds on. */
|
|
303
|
-
after: z3.array(z3.object({ change: ChangeRef, track: TrackCode }).strict())
|
|
415
|
+
reason: z4.string().trim().min(1)
|
|
304
416
|
}).strict();
|
|
305
|
-
var WorkChangeSchema = z3.object({
|
|
306
|
-
id: ChangeRef,
|
|
307
|
-
title: z3.string(),
|
|
308
|
-
signed_off: Day,
|
|
309
|
-
/** The hash of the change's `delta.json`; a signed-off change never changes. */
|
|
310
|
-
delta: z3.string().regex(/^[0-9a-f]{16}$/),
|
|
311
|
-
depends_on: z3.array(ChangeRef),
|
|
312
|
-
/** The change map's level. */
|
|
313
|
-
level: z3.number().int().min(1),
|
|
314
|
-
/** One per track the change is on; empty = no work. */
|
|
315
|
-
tasks: z3.array(WorkTaskSchema)
|
|
316
|
-
}).strict();
|
|
317
|
-
var WORK_FORMAT = 2;
|
|
318
|
-
var WorkSchema = z3.object({
|
|
319
|
-
format: z3.literal(WORK_FORMAT),
|
|
320
|
-
/** The alterspec version that wrote the export. */
|
|
321
|
-
alterspec: z3.string(),
|
|
322
|
-
exported: Day,
|
|
323
|
-
/** Everything signed off before the changes began; `built`: the product as it runs (a reverse-spec), no work. */
|
|
324
|
-
baseline: z3.object({ date: Day, built: z3.boolean() }).strict().nullable(),
|
|
325
|
-
tracks: z3.array(WorkTrackSchema),
|
|
326
|
-
/** Every change signed off after the baseline, in the change map's order. */
|
|
327
|
-
changes: z3.array(WorkChangeSchema)
|
|
328
|
-
}).strict();
|
|
329
|
-
var WorkTaskV1Schema = WorkTaskSchema.omit({ items: true });
|
|
330
|
-
var WorkV1Schema = WorkSchema.extend({
|
|
331
|
-
format: z3.literal(1),
|
|
332
|
-
changes: z3.array(WorkChangeSchema.extend({ tasks: z3.array(WorkTaskV1Schema) }).strict())
|
|
333
|
-
}).strict();
|
|
334
|
-
var AnyWorkSchema = z3.discriminatedUnion("format", [WorkV1Schema, WorkSchema]);
|
|
335
417
|
|
|
336
418
|
// ../src/schemas/change.ts
|
|
337
|
-
var ChangeStatus =
|
|
419
|
+
var ChangeStatus = z5.enum(["draft", "in_review", "signed_off", "rejected"], {
|
|
338
420
|
error: (iss) => iss.input === "applied" || iss.input === "approved" ? `${iss.input} is no longer a status: a change is merged into the spec when it is signed off; \`alterspec status migrate\` moves a spec to the current statuses` : void 0
|
|
339
421
|
});
|
|
340
|
-
var ObjectKey =
|
|
422
|
+
var ObjectKey = z5.string().refine(
|
|
341
423
|
(v) => /^term:\S.*$/.test(v) || /^file:[\w./-]+\.md$/.test(v) || /^file:experience\/(?:[a-z]{2,5}\/)?mockups\/[\w./-]+$/.test(v) || v === "file:experience/data.js" || Object.keys(ID_REGEX).some(
|
|
342
424
|
(k) => k !== "screenAction" && k !== "acceptance" && ID_REGEX[k].test(v)
|
|
343
425
|
),
|
|
344
426
|
{ message: "must be a spec ID, term:<Term> or file:<path>" }
|
|
345
427
|
);
|
|
346
|
-
var ChangeSchema =
|
|
428
|
+
var ChangeSchema = z5.object({
|
|
347
429
|
id: ChangeId,
|
|
348
430
|
title: Title,
|
|
349
431
|
status: ChangeStatus,
|
|
350
|
-
created:
|
|
432
|
+
created: z5.iso.date(),
|
|
351
433
|
/** The day the change was signed off and merged. Written by the CLI. */
|
|
352
|
-
signed_off:
|
|
434
|
+
signed_off: z5.iso.date().optional(),
|
|
353
435
|
/** Objects this change removes. */
|
|
354
436
|
removes: list(ObjectKey),
|
|
355
437
|
/**
|
|
356
438
|
* Fingerprint of each touched object when the change started touching it (null = new object).
|
|
357
439
|
* Written by the CLI; used to detect conflicts.
|
|
358
440
|
*/
|
|
359
|
-
base:
|
|
441
|
+
base: z5.record(z5.string(), z5.string().nullable()).default({}),
|
|
360
442
|
/**
|
|
361
443
|
* The earlier signed-off changes this one builds on: developers take it after them. Written by the CLI at sign-off
|
|
362
444
|
* once a baseline exists, never rewritten; `[]` builds on the baseline alone. Absent: signed off before the
|
|
363
445
|
* baseline, part of it.
|
|
364
446
|
*/
|
|
365
|
-
depends_on:
|
|
447
|
+
depends_on: z5.array(ChangeId).optional(),
|
|
366
448
|
/**
|
|
367
449
|
* The tracks the change puts work on (`BE`, or the code of a channel with an experience of its own), each with the
|
|
368
450
|
* keys of its delta that put it there; `{}` = no work. Written by the CLI at sign-off next to `depends_on`, never
|
|
369
451
|
* rewritten, so a channel added later gives an old change no task.
|
|
370
452
|
*/
|
|
371
|
-
tracks:
|
|
453
|
+
tracks: z5.record(TrackCode, z5.array(z5.string())).optional(),
|
|
372
454
|
/** The first 16 hex of the sha256 of the change's `delta.json`, written with it at sign-off, never rewritten. */
|
|
373
|
-
delta:
|
|
455
|
+
delta: z5.string().regex(/^[0-9a-f]{16}$/).optional()
|
|
374
456
|
}).strict().superRefine((c, ctx) => {
|
|
375
457
|
for (const key of Object.keys(c.base)) {
|
|
376
458
|
if (!ObjectKey.safeParse(key).success) {
|
|
@@ -380,37 +462,37 @@ var ChangeSchema = z4.object({
|
|
|
380
462
|
});
|
|
381
463
|
|
|
382
464
|
// ../src/schemas/delta.ts
|
|
383
|
-
var Fingerprint =
|
|
384
|
-
var Side = (t) =>
|
|
385
|
-
var Binary =
|
|
386
|
-
var DeltaChange =
|
|
387
|
-
var DeltaEntrySchema =
|
|
465
|
+
var Fingerprint = z6.string().regex(/^[0-9a-f]{16}$/);
|
|
466
|
+
var Side = (t) => z6.object({ before: t.optional(), after: t.optional() }).strict();
|
|
467
|
+
var Binary = z6.object({ sha256: z6.string().regex(/^[0-9a-f]{64}$/), size: z6.number().int() }).strict();
|
|
468
|
+
var DeltaChange = z6.enum(["added", "modified", "removed", "moved"]);
|
|
469
|
+
var DeltaEntrySchema = z6.object({
|
|
388
470
|
key: ObjectKey,
|
|
389
|
-
kind:
|
|
471
|
+
kind: z6.enum(["doc", "item", "prose"]),
|
|
390
472
|
change: DeltaChange,
|
|
391
|
-
file: Side(
|
|
473
|
+
file: Side(z6.string()),
|
|
392
474
|
/** The object's status before and after, when it has one. */
|
|
393
|
-
status: Side(
|
|
475
|
+
status: Side(z6.string()).optional(),
|
|
394
476
|
/** Whether the export held the object before and after the sign-off (`buildBundle`). */
|
|
395
|
-
exported:
|
|
477
|
+
exported: z6.object({ before: z6.boolean(), after: z6.boolean() }).strict(),
|
|
396
478
|
fingerprint: Side(Fingerprint),
|
|
397
479
|
/** The text without generated blocks; absent for a binary file and for a side the object has no content on. */
|
|
398
|
-
before:
|
|
399
|
-
after:
|
|
480
|
+
before: z6.string().optional(),
|
|
481
|
+
after: z6.string().optional(),
|
|
400
482
|
/** A binary file (an image): its hash and size instead of its text. */
|
|
401
483
|
binary: Side(Binary).optional()
|
|
402
484
|
}).strict();
|
|
403
|
-
var DeltaSchema =
|
|
485
|
+
var DeltaSchema = z6.object({
|
|
404
486
|
change: ChangeId,
|
|
405
|
-
title:
|
|
406
|
-
signed_off:
|
|
487
|
+
title: z6.string(),
|
|
488
|
+
signed_off: z6.iso.date().optional(),
|
|
407
489
|
/** `git`: rebuilt afterwards from the repository's history by `alterspec migrate changes`. */
|
|
408
|
-
recovered:
|
|
490
|
+
recovered: z6.literal("git").optional(),
|
|
409
491
|
/** In the export: which objects it shows in export terms only (see the export README). */
|
|
410
|
-
view:
|
|
411
|
-
objects:
|
|
492
|
+
view: z6.literal("export").optional(),
|
|
493
|
+
objects: z6.array(DeltaEntrySchema),
|
|
412
494
|
/** Objects a rebuilt delta could not recover, with why. */
|
|
413
|
-
unrecoverable:
|
|
495
|
+
unrecoverable: z6.array(z6.object({ key: z6.string(), why: z6.string() }).strict()).optional()
|
|
414
496
|
}).strict();
|
|
415
497
|
|
|
416
498
|
// ../src/changes/delta-record.ts
|
|
@@ -498,26 +580,26 @@ var isSectionShard = (name, heading) => new RegExp(`^\\d{2}-${slug(heading)}\\.m
|
|
|
498
580
|
var ExportReadError = class extends Error {
|
|
499
581
|
};
|
|
500
582
|
function readJson(dir, name) {
|
|
501
|
-
const path =
|
|
502
|
-
if (!
|
|
583
|
+
const path = join3(dir, name);
|
|
584
|
+
if (!existsSync3(path)) throw new ExportReadError(`${dir} is not an alterspec export: it has no ${name}.`);
|
|
503
585
|
try {
|
|
504
|
-
return JSON.parse(
|
|
586
|
+
return JSON.parse(readFileSync3(path, "utf8"));
|
|
505
587
|
} catch {
|
|
506
|
-
throw new ExportReadError(`${
|
|
588
|
+
throw new ExportReadError(`${join3(dir, name)} is not valid JSON.`);
|
|
507
589
|
}
|
|
508
590
|
}
|
|
509
591
|
function readExport(dir) {
|
|
510
592
|
const exp = readJson(dir, EXPORT_JSON);
|
|
511
593
|
const parsed = AnyWorkSchema.safeParse(readJson(dir, WORK_JSON));
|
|
512
594
|
if (!parsed.success)
|
|
513
|
-
throw new ExportReadError(`${
|
|
595
|
+
throw new ExportReadError(`${join3(dir, WORK_JSON)} is not a work.json this client reads.`);
|
|
514
596
|
const sources = new Map((exp.sources ?? []).map((s) => [s.id, s]));
|
|
515
|
-
const has = (path) =>
|
|
516
|
-
const read = (path) => has(path) ?
|
|
517
|
-
const modules = () =>
|
|
597
|
+
const has = (path) => existsSync3(join3(dir, path));
|
|
598
|
+
const read = (path) => has(path) ? readFileSync3(join3(dir, path), "utf8") : void 0;
|
|
599
|
+
const modules = () => existsSync3(join3(dir, "modules")) ? readdirSync(join3(dir, "modules")).map((m) => moduleDir(m)) : [];
|
|
518
600
|
const shards = (file) => {
|
|
519
601
|
const folder = shardDir(file);
|
|
520
|
-
return has(folder) ? readdirSync(
|
|
602
|
+
return has(folder) ? readdirSync(join3(dir, folder)).sort().map((n) => `${folder}/${n}`) : [];
|
|
521
603
|
};
|
|
522
604
|
const proposalPath = (change) => [archiveDir(), ...modules().map((m) => `${m}/changes/archive`)].map((a) => `${a}/${change}/proposal.md`).find(has);
|
|
523
605
|
return {
|
|
@@ -560,77 +642,6 @@ function idsIn(text, kinds) {
|
|
|
560
642
|
}
|
|
561
643
|
var frontMatterOf = (text) => splitFrontMatter(text).raw ?? "";
|
|
562
644
|
|
|
563
|
-
// src/config.ts
|
|
564
|
-
import { execFileSync as execFileSync2 } from "child_process";
|
|
565
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
566
|
-
import { homedir as homedir2 } from "os";
|
|
567
|
-
import { basename, dirname, isAbsolute, join as join3, resolve } from "path";
|
|
568
|
-
import { z as z6 } from "zod";
|
|
569
|
-
var CONFIG_FILE = ".alterspec-client.json";
|
|
570
|
-
var ClientConfigSchema = z6.object({
|
|
571
|
-
/** The dispatcher's URL. */
|
|
572
|
-
dispatcher: z6.url(),
|
|
573
|
-
/** The developer's clone of the export repository, relative to this file's folder or absolute. */
|
|
574
|
-
export: z6.string().min(1),
|
|
575
|
-
/** The tracks this repository builds: the default of `next_task`. */
|
|
576
|
-
tracks: z6.array(TrackCode).default([]),
|
|
577
|
-
/** Where `worktree` puts a task's worktree; default `../<repo>-tasks`. */
|
|
578
|
-
worktrees: z6.string().min(1).optional(),
|
|
579
|
-
/** The public key to sign with: a `.pub` path or the key line; default ssh-agent, then `~/.ssh/id_ed25519.pub`. */
|
|
580
|
-
key: z6.string().min(1).optional(),
|
|
581
|
-
/** The track's main branch; default the remote's `HEAD`, else `main`. */
|
|
582
|
-
branch: z6.string().min(1).optional()
|
|
583
|
-
}).strict();
|
|
584
|
-
var ConfigError = class extends Error {
|
|
585
|
-
};
|
|
586
|
-
var git = (cwd, ...args) => {
|
|
587
|
-
try {
|
|
588
|
-
return execFileSync2("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
589
|
-
} catch {
|
|
590
|
-
return void 0;
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
function candidates(cwd) {
|
|
594
|
-
const top = git(cwd, "rev-parse", "--show-toplevel");
|
|
595
|
-
const common = git(cwd, "rev-parse", "--path-format=absolute", "--git-common-dir");
|
|
596
|
-
const main = common && basename(common) === ".git" ? dirname(common) : void 0;
|
|
597
|
-
return [...new Set([top, main, resolve(cwd)].filter((d) => !!d))];
|
|
598
|
-
}
|
|
599
|
-
function readConfigAt(root) {
|
|
600
|
-
const path = join3(root, CONFIG_FILE);
|
|
601
|
-
if (!existsSync3(path)) return void 0;
|
|
602
|
-
let raw;
|
|
603
|
-
try {
|
|
604
|
-
raw = JSON.parse(readFileSync3(path, "utf8"));
|
|
605
|
-
} catch {
|
|
606
|
-
throw new ConfigError(`${path} is not valid JSON.`);
|
|
607
|
-
}
|
|
608
|
-
const parsed = ClientConfigSchema.safeParse(raw);
|
|
609
|
-
if (!parsed.success)
|
|
610
|
-
throw new ConfigError(
|
|
611
|
-
`${path} is not valid: ${parsed.error.issues.map((i) => `${i.path.join(".") || "(root)"} ${i.message}`).join("; ")}.`
|
|
612
|
-
);
|
|
613
|
-
return parsed.data;
|
|
614
|
-
}
|
|
615
|
-
function loadConfig(cwd = process.cwd()) {
|
|
616
|
-
for (const root of candidates(cwd)) {
|
|
617
|
-
const config = readConfigAt(root);
|
|
618
|
-
if (config) return { root, config };
|
|
619
|
-
}
|
|
620
|
-
throw new ConfigError(
|
|
621
|
-
`No ${CONFIG_FILE} here: run \`npx @alterset/alterspec-client init --dispatcher <url> --export <path>\` first.`
|
|
622
|
-
);
|
|
623
|
-
}
|
|
624
|
-
function configPath(root, path) {
|
|
625
|
-
if (path === "~" || path.startsWith("~/")) return join3(homedir2(), path.slice(1));
|
|
626
|
-
return isAbsolute(path) ? path : resolve(root, path);
|
|
627
|
-
}
|
|
628
|
-
var exportDir = ({ root, config }) => configPath(root, config.export);
|
|
629
|
-
var worktreesDir = ({ root, config }) => configPath(root, config.worktrees ?? `../${basename(root)}-tasks`);
|
|
630
|
-
function writeConfig(root, config) {
|
|
631
|
-
writeFileSync2(join3(root, CONFIG_FILE), JSON.stringify(config, null, 2) + "\n");
|
|
632
|
-
}
|
|
633
|
-
|
|
634
645
|
// ../src/lib/diff.ts
|
|
635
646
|
var linesOf = (text) => text === "" ? [] : text.replace(/\n$/, "").split("\n");
|
|
636
647
|
function diffLines(a, b) {
|
|
@@ -727,7 +738,77 @@ function objectBrief(x, key, entry, why) {
|
|
|
727
738
|
}
|
|
728
739
|
return brief;
|
|
729
740
|
}
|
|
730
|
-
|
|
741
|
+
var KIND_WORDS = {
|
|
742
|
+
app: "the application",
|
|
743
|
+
module: "module",
|
|
744
|
+
capability: "capability",
|
|
745
|
+
screen: "screen",
|
|
746
|
+
experience: "experience screen",
|
|
747
|
+
role: "role",
|
|
748
|
+
integration: "integration",
|
|
749
|
+
nfr: "non-functional requirement",
|
|
750
|
+
persona: "persona",
|
|
751
|
+
entity: "entity",
|
|
752
|
+
rule: "rule",
|
|
753
|
+
flow: "flow",
|
|
754
|
+
event: "event",
|
|
755
|
+
decision: "decision"
|
|
756
|
+
};
|
|
757
|
+
function titleOf(x, id) {
|
|
758
|
+
const file = x.fileOf(id);
|
|
759
|
+
if (!file || !x.has(file)) return void 0;
|
|
760
|
+
const shard = x.itemShard(file, id);
|
|
761
|
+
if (shard) return /^## \S+ (.+)$/m.exec(shardText(x, shard) ?? "")?.[1]?.trim();
|
|
762
|
+
return /^# (.+)$/m.exec(splitFrontMatter(x.read(file)).body)?.[1]?.trim();
|
|
763
|
+
}
|
|
764
|
+
var named = (x, id) => {
|
|
765
|
+
const title = titleOf(x, id);
|
|
766
|
+
return title ? `${id} ${title}` : `${id} (not in the export now)`;
|
|
767
|
+
};
|
|
768
|
+
function criterionOf(x, cap, id) {
|
|
769
|
+
const file = x.fileOf(cap);
|
|
770
|
+
const text = file && x.has(file) ? sectionText(x, x.sectionShard(file, "Acceptance criteria")) : void 0;
|
|
771
|
+
const chunk = text?.split(/^### /m).find((c) => c.split(/\s/)[0] === id);
|
|
772
|
+
if (!chunk) return void 0;
|
|
773
|
+
const lines = chunk.split("\n").slice(1).map(
|
|
774
|
+
(l) => l.replace(/^\s*[-*]\s*/, "").replace(/\*\*/g, "").trim()
|
|
775
|
+
).filter(Boolean);
|
|
776
|
+
const then = lines.findIndex((l) => /^Then\b/.test(l));
|
|
777
|
+
const kept = (then >= 0 ? lines.slice(then) : lines).filter((l) => !/^Covers:/.test(l));
|
|
778
|
+
return kept.join(" ") || void 0;
|
|
779
|
+
}
|
|
780
|
+
function itemWhat(x, item) {
|
|
781
|
+
const ac = /^((CAP-[A-Z]{2,6}-\d{3})-AC-\d{2})$/.exec(item);
|
|
782
|
+
if (ac) {
|
|
783
|
+
const then = criterionOf(x, ac[2], ac[1]);
|
|
784
|
+
return `acceptance criterion of ${named(x, ac[2])}${then ? `: ${then}` : ""}`;
|
|
785
|
+
}
|
|
786
|
+
const action = /^(SCR-[A-Z]{2,6}-\d{2})\.(A\d{2})$/.exec(item);
|
|
787
|
+
if (action) {
|
|
788
|
+
const [, scr, a] = action;
|
|
789
|
+
const file = x.fileOf(scr);
|
|
790
|
+
const actions = file && x.has(file) ? sectionText(x, x.sectionShard(file, "Actions")) : void 0;
|
|
791
|
+
const line = actions?.split("\n").map((l) => l.replace(/^\s*[-*]\s*/, "").trim()).find((l) => l.startsWith(`${a} `));
|
|
792
|
+
const label = line?.slice(a.length).trim();
|
|
793
|
+
return `action ${a}${label ? ` "${label.replace(/\s*→\s*/, '" \u2192 ')}` : ""}${label && !label.includes("\u2192") ? '"' : ""} on ${named(x, scr)}`;
|
|
794
|
+
}
|
|
795
|
+
const state = /^(UX-(SCR-[A-Z]{2,6}-\d{2})-[A-Z]{2,5})#(.+)$/.exec(item);
|
|
796
|
+
if (state) {
|
|
797
|
+
const [, ux, scr, id] = state;
|
|
798
|
+
const rule = /^rule-(.+)$/.exec(id)?.[1];
|
|
799
|
+
return `state "${id}" of ${ux} (${named(x, scr)})${rule ? `: the message of RULE-${rule.toUpperCase()}` : ""}`;
|
|
800
|
+
}
|
|
801
|
+
if (item.startsWith("file:")) {
|
|
802
|
+
const path = item.slice(5);
|
|
803
|
+
const page = /\/mockups\/(SCR-[A-Z]{2,6}-\d{2})\.html$/.exec(path)?.[1];
|
|
804
|
+
const what = page ? `the mockup page of ${page}` : /\/design-system\.md$/.test(path) ? "the channel\u2019s design system" : /\/patterns\.md$/.test(path) ? "the channel\u2019s patterns" : "a file of the channel\u2019s experience";
|
|
805
|
+
return `${what}: \`${path}\`${x.has(path) ? "" : " (not in the export now)"}`;
|
|
806
|
+
}
|
|
807
|
+
if (item.startsWith("term:")) return `glossary term "${item.slice(5)}"`;
|
|
808
|
+
const kind = idKind(item);
|
|
809
|
+
return `${kind && KIND_WORDS[kind] ? `${KIND_WORDS[kind]} ` : ""}${named(x, item)}`;
|
|
810
|
+
}
|
|
811
|
+
function taskContext(x, task, exportDir2, state = {}) {
|
|
731
812
|
const change = x.work.changes.find((c) => c.id === task.change);
|
|
732
813
|
if (!change) throw new ContextError(`${task.change} is not in this export's work.json: pull the export.`);
|
|
733
814
|
const work = change.tasks.find((t) => t.track === task.track);
|
|
@@ -741,8 +822,19 @@ function taskContext(x, task, exportDir2) {
|
|
|
741
822
|
const delta = x.delta(task.change);
|
|
742
823
|
const entries = new Map(delta?.objects.map((e) => [e.key, e]));
|
|
743
824
|
const lost = new Map(delta?.unrecoverable?.map((u) => [u.key, u.why]));
|
|
825
|
+
const items = work.items;
|
|
744
826
|
const ctx = {
|
|
745
827
|
task: task.id,
|
|
828
|
+
...items ? {
|
|
829
|
+
checklist: {
|
|
830
|
+
items: items.map((item) => {
|
|
831
|
+
const covered = state.covered?.get(item);
|
|
832
|
+
return { item, what: itemWhat(x, item), ...covered ? { covered } : {} };
|
|
833
|
+
}),
|
|
834
|
+
known: state.covered !== void 0,
|
|
835
|
+
...state.unknown ? { note: state.unknown } : {}
|
|
836
|
+
}
|
|
837
|
+
} : {},
|
|
746
838
|
export: exportDir2,
|
|
747
839
|
change: {
|
|
748
840
|
id: change.id,
|
|
@@ -763,13 +855,13 @@ function taskContext(x, task, exportDir2) {
|
|
|
763
855
|
};
|
|
764
856
|
if (track.kind === "backend") {
|
|
765
857
|
const capabilities = work.objects.filter((k) => /^CAP-/.test(k) && x.fileOf(k) && x.has(x.fileOf(k)));
|
|
766
|
-
const
|
|
858
|
+
const named2 = (kind) => [
|
|
767
859
|
.../* @__PURE__ */ new Set([
|
|
768
860
|
...work.objects.filter((k) => idsIn(k, [kind]).length === 1 && idsIn(k, [kind])[0] === k),
|
|
769
861
|
...capabilities.flatMap((c) => idsIn(frontMatterOf(x.read(x.fileOf(c))), [kind]))
|
|
770
862
|
])
|
|
771
863
|
];
|
|
772
|
-
const
|
|
864
|
+
const items2 = (ids) => ids.flatMap((id) => {
|
|
773
865
|
const file = x.fileOf(id);
|
|
774
866
|
const path = file && x.itemShard(file, id);
|
|
775
867
|
return path ? [{ id, path, text: shardText(x, path) }] : [];
|
|
@@ -778,8 +870,8 @@ function taskContext(x, task, exportDir2) {
|
|
|
778
870
|
const path = x.sectionShard(x.fileOf(id), "Acceptance criteria");
|
|
779
871
|
return path ? [{ id, path, text: sectionText(x, path) }] : [];
|
|
780
872
|
});
|
|
781
|
-
ctx.rules =
|
|
782
|
-
ctx.events =
|
|
873
|
+
ctx.rules = items2(named2("rule"));
|
|
874
|
+
ctx.events = items2(named2("event"));
|
|
783
875
|
ctx.operations = x.has(OPERATIONS_FILE) ? capabilities.flatMap((id) => {
|
|
784
876
|
const path = x.shards(OPERATIONS_FILE).find((p) => new RegExp(`/\\d{2}-${slug(id)}(-|\\.md$)`).test(p));
|
|
785
877
|
return path ? [{ id, path, text: shardText(x, path) }] : [];
|
|
@@ -813,6 +905,23 @@ function renderContext(c) {
|
|
|
813
905
|
`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}.`
|
|
814
906
|
];
|
|
815
907
|
if (c.after.length) out.push("", `Waits for: ${c.after.map((a) => `${a.change}/${a.track}`).join(", ")}.`);
|
|
908
|
+
out.push("");
|
|
909
|
+
if (!c.checklist)
|
|
910
|
+
out.push("This export has no checklist (work.json format 1): the task\u2019s progress is its status only.");
|
|
911
|
+
else {
|
|
912
|
+
const list2 = c.checklist;
|
|
913
|
+
const done = list2.items.filter((i) => i.covered).length;
|
|
914
|
+
out.push(
|
|
915
|
+
`## Checklist (${list2.known ? `${done} of ${list2.items.length} covered` : `${list2.items.length} item${list2.items.length === 1 ? "" : "s"}`})`,
|
|
916
|
+
"",
|
|
917
|
+
"Name an item in `Alterspec-Covers` on the commit with which its tests pass.",
|
|
918
|
+
...list2.note ? ["", `Covered items unknown: ${list2.note}`] : [],
|
|
919
|
+
"",
|
|
920
|
+
...list2.items.map(
|
|
921
|
+
(i) => `- [${i.covered ? "x" : " "}] \`${i.item}\`: ${i.what}${i.covered ? ` (covered by ${i.covered.slice(0, 12)})` : ""}`
|
|
922
|
+
)
|
|
923
|
+
);
|
|
924
|
+
}
|
|
816
925
|
out.push("", `## Why (${c.proposal.path})`, "", c.proposal.why || "(none written)");
|
|
817
926
|
out.push("", "## What changes", "", c.proposal.what || "(none written)");
|
|
818
927
|
out.push("", "## The task\u2019s objects", "");
|
|
@@ -870,6 +979,11 @@ function parseTask(text) {
|
|
|
870
979
|
}
|
|
871
980
|
var branchOf = (t) => `task/${t.change.toLowerCase()}-${t.track.toLowerCase()}`;
|
|
872
981
|
var folderOf = (t) => `${t.change.toLowerCase()}-${t.track.toLowerCase()}`;
|
|
982
|
+
var COVERS = "Alterspec-Covers";
|
|
983
|
+
function taskOfBranch(branch) {
|
|
984
|
+
const m = /^task\/(chg-\d{3})-([a-z]{2,5})$/.exec(branch?.trim() ?? "");
|
|
985
|
+
return m ? parseTask(`${m[1]}/${m[2]}`) : void 0;
|
|
986
|
+
}
|
|
873
987
|
|
|
874
988
|
// src/git.ts
|
|
875
989
|
var GitError = class extends Error {
|
|
@@ -976,7 +1090,7 @@ function mergedCommit(repo, task, main) {
|
|
|
976
1090
|
}
|
|
977
1091
|
|
|
978
1092
|
// src/install.ts
|
|
979
|
-
import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync3, statSync, writeFileSync as writeFileSync4 } from "fs";
|
|
1093
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync5, readdirSync as readdirSync3, statSync, writeFileSync as writeFileSync4 } from "fs";
|
|
980
1094
|
import { join as join6, relative } from "path";
|
|
981
1095
|
import { fileURLToPath } from "url";
|
|
982
1096
|
|
|
@@ -1120,6 +1234,43 @@ function writeMcpJson(root) {
|
|
|
1120
1234
|
writeFileSync4(path, after);
|
|
1121
1235
|
return before === void 0 ? "created" : "updated";
|
|
1122
1236
|
}
|
|
1237
|
+
var CLAUDE_SETTINGS = ".claude/settings.json";
|
|
1238
|
+
var HOOK_COMMAND = "npx @alterset/alterspec-client progress --hook";
|
|
1239
|
+
var HOOK_ENTRY = {
|
|
1240
|
+
type: "command",
|
|
1241
|
+
if: "Bash(git commit *)",
|
|
1242
|
+
command: HOOK_COMMAND,
|
|
1243
|
+
timeout: 60,
|
|
1244
|
+
async: true
|
|
1245
|
+
};
|
|
1246
|
+
var isOurs = (h) => typeof h.command === "string" && h.command.includes("@alterset/alterspec-client progress");
|
|
1247
|
+
function writeClaudeSettings(root) {
|
|
1248
|
+
const path = join6(root, CLAUDE_SETTINGS);
|
|
1249
|
+
const before = existsSync6(path) ? readFileSync5(path, "utf8") : void 0;
|
|
1250
|
+
let data = {};
|
|
1251
|
+
if (before !== void 0)
|
|
1252
|
+
try {
|
|
1253
|
+
data = JSON.parse(before);
|
|
1254
|
+
} catch {
|
|
1255
|
+
throw new ConfigError(`${path} is not valid JSON: fix it, then run init again.`);
|
|
1256
|
+
}
|
|
1257
|
+
const hooks = data.hooks ??= {};
|
|
1258
|
+
const groups = hooks.PostToolUse ??= [];
|
|
1259
|
+
let found = false;
|
|
1260
|
+
for (const group of groups)
|
|
1261
|
+
group.hooks = group.hooks?.flatMap((h) => {
|
|
1262
|
+
if (!isOurs(h)) return [h];
|
|
1263
|
+
if (found) return [];
|
|
1264
|
+
found = true;
|
|
1265
|
+
return [HOOK_ENTRY];
|
|
1266
|
+
});
|
|
1267
|
+
if (!found) groups.push({ matcher: "Bash", hooks: [HOOK_ENTRY] });
|
|
1268
|
+
const after = JSON.stringify(data, null, 2) + "\n";
|
|
1269
|
+
if (before !== void 0 && JSON.stringify(JSON.parse(before)) === JSON.stringify(data)) return "unchanged";
|
|
1270
|
+
mkdirSync2(join6(root, ".claude"), { recursive: true });
|
|
1271
|
+
writeFileSync4(path, after);
|
|
1272
|
+
return before === void 0 ? "created" : "updated";
|
|
1273
|
+
}
|
|
1123
1274
|
function initClient(root, opts, version) {
|
|
1124
1275
|
const { force, ...given } = opts;
|
|
1125
1276
|
const existing = readConfigAt(root);
|
|
@@ -1135,6 +1286,7 @@ function initClient(root, opts, version) {
|
|
|
1135
1286
|
const config = !existing ? "created" : before === JSON.stringify(parsed.data) ? "unchanged" : "updated";
|
|
1136
1287
|
if (config !== "unchanged") writeConfig(root, parsed.data);
|
|
1137
1288
|
const mcp = writeMcpJson(root);
|
|
1289
|
+
const hook = writeClaudeSettings(root);
|
|
1138
1290
|
const files = install(root, buildClientPlan(version), {
|
|
1139
1291
|
mode: "update",
|
|
1140
1292
|
force,
|
|
@@ -1142,12 +1294,37 @@ function initClient(root, opts, version) {
|
|
|
1142
1294
|
manifestPath: MANIFEST_PATH2,
|
|
1143
1295
|
emptiedFolder: /\.claude\/skills\/alterspec-[^/]+$/
|
|
1144
1296
|
});
|
|
1145
|
-
return { config, mcp, files };
|
|
1297
|
+
return { config, mcp, hook, files };
|
|
1146
1298
|
}
|
|
1147
1299
|
|
|
1148
1300
|
// src/mcp.ts
|
|
1149
1301
|
import { createInterface } from "readline";
|
|
1150
1302
|
var isRequest = (m) => m.method !== void 0 && m.id !== void 0;
|
|
1303
|
+
async function callTool(session, name, args = {}) {
|
|
1304
|
+
const res = await session.fetch("/mcp", {
|
|
1305
|
+
method: "POST",
|
|
1306
|
+
headers: { "content-type": "application/json", accept: "application/json, text/event-stream" },
|
|
1307
|
+
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: args } })
|
|
1308
|
+
});
|
|
1309
|
+
const text = await res.text();
|
|
1310
|
+
if (!res.ok)
|
|
1311
|
+
throw new DispatcherError(`HTTP_${res.status}`, `The dispatcher answered ${res.status}.`, res.status);
|
|
1312
|
+
const answer = messagesOf(res.headers.get("content-type") ?? "", text)[0];
|
|
1313
|
+
if (!answer?.result)
|
|
1314
|
+
throw new DispatcherError(
|
|
1315
|
+
"MCP_ERROR",
|
|
1316
|
+
answer?.error?.message ?? `The dispatcher gave no answer to ${name}.`
|
|
1317
|
+
);
|
|
1318
|
+
const out = answer.result.structuredContent ?? {};
|
|
1319
|
+
if (answer.result.isError) {
|
|
1320
|
+
const err = out.error;
|
|
1321
|
+
throw new DispatcherError(
|
|
1322
|
+
err?.code ?? "TOOL_ERROR",
|
|
1323
|
+
err?.message ?? answer.result.content?.map((c) => c.text ?? "").join("\n") ?? `${name} failed.`
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
return out;
|
|
1327
|
+
}
|
|
1151
1328
|
function messagesOf(contentType, text) {
|
|
1152
1329
|
if (!text.trim()) return [];
|
|
1153
1330
|
if (!contentType.includes("text/event-stream")) return [JSON.parse(text)];
|
|
@@ -1271,10 +1448,120 @@ async function openDispatcher(session, open = openInBrowser) {
|
|
|
1271
1448
|
return url;
|
|
1272
1449
|
}
|
|
1273
1450
|
|
|
1451
|
+
// src/progress.ts
|
|
1452
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
1453
|
+
import { createHash as createHash3 } from "crypto";
|
|
1454
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
1455
|
+
import { join as join7 } from "path";
|
|
1456
|
+
var git3 = (cwd, args) => execFileSync4("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
1457
|
+
function currentTask(repo) {
|
|
1458
|
+
try {
|
|
1459
|
+
return taskOfBranch(git3(repo, ["symbolic-ref", "--short", "HEAD"]));
|
|
1460
|
+
} catch {
|
|
1461
|
+
return void 0;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
function coveredItems(repo, task) {
|
|
1465
|
+
const trailer = (key) => `%(trailers:key=${key},valueonly,separator=%x1d)`;
|
|
1466
|
+
const log = git3(repo, [
|
|
1467
|
+
"log",
|
|
1468
|
+
"--reverse",
|
|
1469
|
+
"--topo-order",
|
|
1470
|
+
`--format=%H%x1f${trailer(TRAILER)}%x1f${trailer(COVERS)}%x1e`,
|
|
1471
|
+
"HEAD"
|
|
1472
|
+
]);
|
|
1473
|
+
const first = /* @__PURE__ */ new Map();
|
|
1474
|
+
for (const record of log.split("")) {
|
|
1475
|
+
const [sha, tasks = "", covers = ""] = record.trim().split("");
|
|
1476
|
+
if (!sha) continue;
|
|
1477
|
+
if (!tasks.split("").some((t) => t.trim().toUpperCase() === task.id)) continue;
|
|
1478
|
+
for (const item of covers.replaceAll("", ",").split(/[,\s]+/).filter(Boolean))
|
|
1479
|
+
if (!first.has(item)) first.set(item, sha);
|
|
1480
|
+
}
|
|
1481
|
+
return [...first].map(([item, commit]) => ({ item, commit })).sort((a, b) => a.item < b.item ? -1 : a.item > b.item ? 1 : 0);
|
|
1482
|
+
}
|
|
1483
|
+
var unknownOf = (e) => e.message.split("\n").slice(1).map((l) => l.trim()).filter(Boolean);
|
|
1484
|
+
async function reportProgress(session, task, covered) {
|
|
1485
|
+
try {
|
|
1486
|
+
const answer = await callTool(session, "report_progress", { id: task.id, covered });
|
|
1487
|
+
return { task: task.id, covered, unknown: [], answer };
|
|
1488
|
+
} catch (e) {
|
|
1489
|
+
if (!(e instanceof DispatcherError) || e.code !== "UNKNOWN_ITEM") throw e;
|
|
1490
|
+
const unknown = unknownOf(e);
|
|
1491
|
+
const known = covered.filter((c) => !unknown.includes(c.item));
|
|
1492
|
+
if (!unknown.length || known.length === covered.length) throw e;
|
|
1493
|
+
const answer = await callTool(session, "report_progress", { id: task.id, covered: known });
|
|
1494
|
+
return { task: task.id, covered: known, unknown, answer };
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
function progressText(r) {
|
|
1498
|
+
const progress = r.answer.progress;
|
|
1499
|
+
const eta = r.answer.eta;
|
|
1500
|
+
const count = progress ? `${progress.covered} of ${progress.of} items covered (${progress.percent} %)` : "no checklist (its export predates task items)";
|
|
1501
|
+
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";
|
|
1502
|
+
const lines = [`${r.task}: ${count}${when}.`];
|
|
1503
|
+
if (r.unknown.length) lines.unshift(unknownLine(r));
|
|
1504
|
+
return lines.join("\n") + "\n";
|
|
1505
|
+
}
|
|
1506
|
+
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).`;
|
|
1507
|
+
var THROTTLE_MS = 15 * 6e4;
|
|
1508
|
+
var statePath = (repo, task) => join7(
|
|
1509
|
+
git3(repo, ["rev-parse", "--path-format=absolute", "--git-common-dir"]),
|
|
1510
|
+
"alterspec-client",
|
|
1511
|
+
`progress-${folderOf(task)}.json`
|
|
1512
|
+
);
|
|
1513
|
+
var hashOf = (covered) => createHash3("sha256").update(JSON.stringify(covered)).digest("hex").slice(0, 16);
|
|
1514
|
+
function readState(path) {
|
|
1515
|
+
try {
|
|
1516
|
+
return existsSync7(path) ? JSON.parse(readFileSync6(path, "utf8")) : void 0;
|
|
1517
|
+
} catch {
|
|
1518
|
+
return void 0;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
async function progressHook(opts) {
|
|
1522
|
+
const now = opts.now ?? Date.now;
|
|
1523
|
+
try {
|
|
1524
|
+
const task = currentTask(opts.repo);
|
|
1525
|
+
if (!task) return "off-task";
|
|
1526
|
+
const covered = coveredItems(opts.repo, task);
|
|
1527
|
+
const path = statePath(opts.repo, task);
|
|
1528
|
+
const state = readState(path);
|
|
1529
|
+
const hash = hashOf(covered);
|
|
1530
|
+
if (state?.reported === hash) return "unchanged";
|
|
1531
|
+
if (state && now() - Date.parse(state.at) < THROTTLE_MS) return "throttled";
|
|
1532
|
+
await reportProgress(opts.session(), task, covered);
|
|
1533
|
+
mkdirSync3(join7(path, ".."), { recursive: true });
|
|
1534
|
+
writeFileSync5(path, JSON.stringify({ reported: hash, at: new Date(now()).toISOString() }) + "\n");
|
|
1535
|
+
return "reported";
|
|
1536
|
+
} catch {
|
|
1537
|
+
return "failed";
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
async function hookCwd(input, waitMs = 1e3) {
|
|
1541
|
+
if (input.isTTY) return void 0;
|
|
1542
|
+
const text = await new Promise((resolve3) => {
|
|
1543
|
+
let data = "";
|
|
1544
|
+
const done = () => resolve3(data);
|
|
1545
|
+
const timer = setTimeout(done, waitMs);
|
|
1546
|
+
input.on("data", (c) => data += c.toString());
|
|
1547
|
+
input.on("end", () => {
|
|
1548
|
+
clearTimeout(timer);
|
|
1549
|
+
done();
|
|
1550
|
+
});
|
|
1551
|
+
input.on("error", done);
|
|
1552
|
+
});
|
|
1553
|
+
try {
|
|
1554
|
+
const cwd = JSON.parse(text).cwd;
|
|
1555
|
+
return typeof cwd === "string" && cwd ? cwd : void 0;
|
|
1556
|
+
} catch {
|
|
1557
|
+
return void 0;
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1274
1561
|
// src/version.ts
|
|
1275
|
-
import { readFileSync as
|
|
1562
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
1276
1563
|
function packageVersion() {
|
|
1277
|
-
const pkg = JSON.parse(
|
|
1564
|
+
const pkg = JSON.parse(readFileSync7(new URL("../package.json", import.meta.url), "utf8"));
|
|
1278
1565
|
return pkg.version;
|
|
1279
1566
|
}
|
|
1280
1567
|
|
|
@@ -1286,10 +1573,16 @@ var tryConfig = () => {
|
|
|
1286
1573
|
return void 0;
|
|
1287
1574
|
}
|
|
1288
1575
|
};
|
|
1289
|
-
function
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1576
|
+
async function coveredState(loaded, task) {
|
|
1577
|
+
try {
|
|
1578
|
+
const answer = await callTool(sessionOf(loaded), "task", { id: task.id });
|
|
1579
|
+
const items = answer.items ?? [];
|
|
1580
|
+
return {
|
|
1581
|
+
covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : []))
|
|
1582
|
+
};
|
|
1583
|
+
} catch (e) {
|
|
1584
|
+
return { unknown: e.message.split("\n")[0] };
|
|
1585
|
+
}
|
|
1293
1586
|
}
|
|
1294
1587
|
var run = (fn) => async (...args) => {
|
|
1295
1588
|
try {
|
|
@@ -1302,7 +1595,9 @@ var run = (fn) => async (...args) => {
|
|
|
1302
1595
|
};
|
|
1303
1596
|
var program = new Command();
|
|
1304
1597
|
program.name("alterspec-client").description("alterspec client \u2014 takes tasks of an alterspec export from the dispatcher.").version(packageVersion());
|
|
1305
|
-
program.command("init").description(
|
|
1598
|
+
program.command("init").description(
|
|
1599
|
+
"set the client up in this repository: configuration, the dispatcher in .mcp.json, the progress hook, the skills"
|
|
1600
|
+
).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("--worktrees <path>", "where task worktrees go (default ../<repo>-tasks)").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("--force", "replace skills you modified").action(
|
|
1306
1601
|
run(
|
|
1307
1602
|
(opts) => {
|
|
1308
1603
|
const root = process.cwd();
|
|
@@ -1313,10 +1608,11 @@ program.command("init").description("set the client up in this repository: confi
|
|
|
1313
1608
|
const lines = [
|
|
1314
1609
|
`${CONFIG_FILE}: ${r.config}`,
|
|
1315
1610
|
`${MCP_JSON} (server "dispatcher"): ${r.mcp}`,
|
|
1611
|
+
`${CLAUDE_SETTINGS} (progress hook after git commit): ${r.hook}`,
|
|
1316
1612
|
`Skills and ${PROMPTS_DIR}/: ${f.created.length} created, ${f.updated.length} updated, ${f.unchanged.length} unchanged${f.removed.length ? `, ${f.removed.length} removed` : ""}.`,
|
|
1317
1613
|
...f.conflicts.map((p) => `Kept your modified ${p}; --force replaces it.`),
|
|
1318
1614
|
"",
|
|
1319
|
-
"Commit .mcp.json, .claude/skills/alterspec-* and .alterspec-client/, so task worktrees have them too."
|
|
1615
|
+
"Commit .mcp.json, .claude/settings.json, .claude/skills/alterspec-* and .alterspec-client/, so task worktrees have them too."
|
|
1320
1616
|
];
|
|
1321
1617
|
try {
|
|
1322
1618
|
const key = keyOf({ root, config: readConfigAt(root) });
|
|
@@ -1341,7 +1637,7 @@ program.command("open").description("sign in and open the dispatcher\u2019s page
|
|
|
1341
1637
|
if (!OPENABLE.includes(what))
|
|
1342
1638
|
throw new Error(`Nothing to open called "${what}": ${OPENABLE.join(", ")}.`);
|
|
1343
1639
|
const loaded = loadConfig();
|
|
1344
|
-
const url = await openDispatcher(
|
|
1640
|
+
const url = await openDispatcher(sessionOf(loaded));
|
|
1345
1641
|
process.stdout.write(
|
|
1346
1642
|
`Opened ${new URL(url).origin} in the browser (the link works once, for a minute).
|
|
1347
1643
|
`
|
|
@@ -1353,7 +1649,7 @@ program.command("mcp").description(
|
|
|
1353
1649
|
).action(
|
|
1354
1650
|
run(async () => {
|
|
1355
1651
|
const loaded = loadConfig();
|
|
1356
|
-
const session =
|
|
1652
|
+
const session = sessionOf(loaded);
|
|
1357
1653
|
await runProxy({ session, input: process.stdin, output: process.stdout, version: packageVersion() });
|
|
1358
1654
|
})
|
|
1359
1655
|
);
|
|
@@ -1364,12 +1660,33 @@ program.command("export-head").description("pull the export clone and print its
|
|
|
1364
1660
|
})
|
|
1365
1661
|
);
|
|
1366
1662
|
program.command("context").description("print a task\u2019s brief, assembled from the export").argument("<task>", "the task, e.g. CHG-012/BE").option("--json", "print it as JSON").action(
|
|
1367
|
-
run((id, opts) => {
|
|
1368
|
-
const
|
|
1369
|
-
const
|
|
1663
|
+
run(async (id, opts) => {
|
|
1664
|
+
const loaded = loadConfig();
|
|
1665
|
+
const dir = exportDir(loaded);
|
|
1666
|
+
const x = readExport(dir);
|
|
1667
|
+
const task = parseTask(id);
|
|
1668
|
+
const ctx = taskContext(x, task, dir, await coveredState(loaded, task));
|
|
1370
1669
|
process.stdout.write(opts.json ? JSON.stringify(ctx, null, 2) + "\n" : renderContext(ctx));
|
|
1371
1670
|
})
|
|
1372
1671
|
);
|
|
1672
|
+
program.command("progress").description("report the items the task\u2019s commits cover to the dispatcher").argument("[task]", "the task, e.g. CHG-012/BE; default the one of the current branch task/<chg>-<track>").option("--hook", "as the Claude Code hook after a commit: silent, throttled, never failing").option("--json", "print the dispatcher\u2019s answer as JSON").action(async (id, opts) => {
|
|
1673
|
+
if (opts.hook) {
|
|
1674
|
+
setTimeout(() => process.exit(0), 3e4).unref();
|
|
1675
|
+
const repo = await hookCwd(process.stdin) ?? process.cwd();
|
|
1676
|
+
await progressHook({ repo, session: () => sessionOf(loadConfig(repo)) });
|
|
1677
|
+
process.exit(0);
|
|
1678
|
+
}
|
|
1679
|
+
await run(async () => {
|
|
1680
|
+
const repo = process.cwd();
|
|
1681
|
+
const task = id ? parseTask(id) : currentTask(repo);
|
|
1682
|
+
if (!task)
|
|
1683
|
+
throw new Error(
|
|
1684
|
+
"This branch is no task branch (task/<chg>-<track>): name the task, e.g. `progress CHG-012/BE`."
|
|
1685
|
+
);
|
|
1686
|
+
const report = await reportProgress(sessionOf(loadConfig()), task, coveredItems(repo, task));
|
|
1687
|
+
process.stdout.write(opts.json ? JSON.stringify(report, null, 2) + "\n" : progressText(report));
|
|
1688
|
+
})();
|
|
1689
|
+
});
|
|
1373
1690
|
program.command("worktree").description("create the task\u2019s branch task/<chg>-<track> from origin/<main>, in a worktree of its own").argument("<task>", "the task, e.g. CHG-012/BE").option("--here", "make the branch in this checkout instead of a worktree").action(
|
|
1374
1691
|
run((id, opts) => {
|
|
1375
1692
|
const loaded = loadConfig();
|