@alterset/alterspec-client 0.15.0 → 0.16.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 +7 -1
- package/agent-instructions.md +2 -0
- package/assets/prompts/_shared.md +10 -3
- package/assets/prompts/bug.md +69 -0
- package/assets/prompts/task-context.md +7 -1
- package/assets/prompts/task-done.md +1 -1
- package/assets/prompts/task-next.md +2 -1
- package/assets/prompts/task-status.md +3 -1
- package/assets/skills/alterspec-bug/SKILL.md +10 -0
- package/developer-guide.md +28 -0
- package/dist/cli.js +315 -97
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -319,9 +319,8 @@ function keyOf(loaded) {
|
|
|
319
319
|
}
|
|
320
320
|
var sessionOf = (loaded) => new Session(loaded.config.dispatcher, keyOf(loaded));
|
|
321
321
|
|
|
322
|
-
//
|
|
323
|
-
import {
|
|
324
|
-
import { join as join3 } from "path";
|
|
322
|
+
// src/bugs.ts
|
|
323
|
+
import { z as z8 } from "zod";
|
|
325
324
|
|
|
326
325
|
// ../src/schemas/delta.ts
|
|
327
326
|
import { z as z6 } from "zod";
|
|
@@ -533,6 +532,26 @@ function exportChange(e) {
|
|
|
533
532
|
return "not in the export";
|
|
534
533
|
}
|
|
535
534
|
|
|
535
|
+
// ../src/changes/data-change.ts
|
|
536
|
+
var DATA_CHANGE_SECTION = "One-time data change";
|
|
537
|
+
var DATA_CHANGE_ITEM = "data-change";
|
|
538
|
+
var DATA_CHANGE_RE = new RegExp(`^(CHG-\\d{3,})#${DATA_CHANGE_ITEM}$`);
|
|
539
|
+
function dataChangeText(sectionText2) {
|
|
540
|
+
const text = sectionText2?.trim();
|
|
541
|
+
return text && !/^none\b/i.test(text) ? text : void 0;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// ../src/export/paths.ts
|
|
545
|
+
var EXPORT_JSON = "export.json";
|
|
546
|
+
var WORK_JSON = "work.json";
|
|
547
|
+
var SHARDS_DIR = "_shards";
|
|
548
|
+
var slug = (text) => text.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[đłøæœßþ]/g, (c) => ({ \u0111: "d", \u0142: "l", \u00F8: "o", \u00E6: "ae", \u0153: "oe", \u00DF: "ss", \u00FE: "th" })[c] ?? c).replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/, "") || "section";
|
|
549
|
+
var shardDir = (path) => `${SHARDS_DIR}/${path.replace(/\.md$/, "")}`;
|
|
550
|
+
var itemShardName = (key) => `${key.startsWith("term:") ? slug(key.slice(5)) : key}.md`;
|
|
551
|
+
var itemShardPath = (path, key) => `${shardDir(path)}/${itemShardName(key)}`;
|
|
552
|
+
var FRONT_MATTER_SHARD = "00-front-matter.yaml";
|
|
553
|
+
var isSectionShard = (name, heading) => new RegExp(`^\\d{2}-${slug(heading)}\\.md$`).test(name);
|
|
554
|
+
|
|
536
555
|
// ../src/lib/frontmatter-split.ts
|
|
537
556
|
var FRONT_MATTER = /^---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
538
557
|
function splitFrontMatter(source) {
|
|
@@ -545,6 +564,79 @@ function splitFrontMatter(source) {
|
|
|
545
564
|
};
|
|
546
565
|
}
|
|
547
566
|
|
|
567
|
+
// ../src/changes/parts.ts
|
|
568
|
+
var FRONT_MATTER_PART = "front-matter";
|
|
569
|
+
var itemObject = (item) => item.startsWith("file:") ? item : item.replace(/-AC-\d{2}$/, "").replace(/[.#][^.#]*$/, "");
|
|
570
|
+
var forWork = (text) => text.replace(/^[^\S\n]*<!--[\s\S]*?-->[^\S\n]*\n/gm, "").replace(/<!--[\s\S]*?-->/g, "").replace(/^version:[^\S\n]*\d+[^\S\n]*\n/m, "").replace(/^(?:reviewed|dry|page):[^\n]*\n/gm, "");
|
|
571
|
+
function objectParts(text, kind) {
|
|
572
|
+
const out = /* @__PURE__ */ new Map();
|
|
573
|
+
const put = (label, heading, body2) => {
|
|
574
|
+
const base = label === "front-matter" ? FRONT_MATTER_PART : slug(heading);
|
|
575
|
+
let key = base;
|
|
576
|
+
for (let n = 2; out.has(key); n++) key = `${base}-${n}`;
|
|
577
|
+
out.set(key, { label, heading, text: body2 });
|
|
578
|
+
};
|
|
579
|
+
const t = forWork(text);
|
|
580
|
+
if (kind === "doc") {
|
|
581
|
+
const { raw, body: body2 } = splitFrontMatter(t);
|
|
582
|
+
if (raw) put("front-matter", FRONT_MATTER_PART, raw);
|
|
583
|
+
for (const s of headed(body2, "## ").sections) put("section", s.heading, s.text);
|
|
584
|
+
return out;
|
|
585
|
+
}
|
|
586
|
+
const yaml = /^```ya?ml\n([\s\S]*?)\n```[^\S\n]*$/m.exec(t);
|
|
587
|
+
if (yaml) put("front-matter", FRONT_MATTER_PART, yaml[1]);
|
|
588
|
+
const body = yaml ? t.slice(yaml.index + yaml[0].length) : t.replace(/^## [^\n]*\n?/, "");
|
|
589
|
+
const { sections } = headed(body, "### ");
|
|
590
|
+
if (sections.length) for (const s of sections) put("section", s.heading, s.text);
|
|
591
|
+
else for (const b of bullets(body)) put("line", b.heading, b.text);
|
|
592
|
+
return out;
|
|
593
|
+
}
|
|
594
|
+
function headed(text, marker) {
|
|
595
|
+
const sections = [];
|
|
596
|
+
let intro = "";
|
|
597
|
+
let fence2 = false;
|
|
598
|
+
for (const l of text.split("\n")) {
|
|
599
|
+
if (/^(?:```|~~~)/.test(l)) fence2 = !fence2;
|
|
600
|
+
if (!fence2 && l.startsWith(marker) && /\S/.test(l.slice(marker.length))) {
|
|
601
|
+
sections.push({ heading: l.slice(marker.length).trim(), text: "" });
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
if (sections.length) sections[sections.length - 1].text += `${l}
|
|
605
|
+
`;
|
|
606
|
+
else intro += `${l}
|
|
607
|
+
`;
|
|
608
|
+
}
|
|
609
|
+
return { intro, sections };
|
|
610
|
+
}
|
|
611
|
+
var BULLET = /^(?:[-*+]|\d+[.)])\s+(.*)$/;
|
|
612
|
+
function bullets(text) {
|
|
613
|
+
const out = [];
|
|
614
|
+
let current;
|
|
615
|
+
let fence2 = false;
|
|
616
|
+
for (const l of text.split("\n")) {
|
|
617
|
+
if (/^(?:```|~~~)/.test(l)) {
|
|
618
|
+
fence2 = !fence2;
|
|
619
|
+
current = void 0;
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
if (fence2) continue;
|
|
623
|
+
const m = BULLET.exec(l);
|
|
624
|
+
if (m) {
|
|
625
|
+
current = { heading: lead(m[1]), text: `${l}
|
|
626
|
+
` };
|
|
627
|
+
out.push(current);
|
|
628
|
+
} else if (current && /^\s+\S/.test(l)) current.text += `${l}
|
|
629
|
+
`;
|
|
630
|
+
else current = void 0;
|
|
631
|
+
}
|
|
632
|
+
return out;
|
|
633
|
+
}
|
|
634
|
+
var lead = (s) => s.replace(/\*\*|__|`/g, "").split(/:\s|:$|\s[—–-]\s|\.\s|\.$/)[0].trim().split(/\s+/).slice(0, 8).join(" ");
|
|
635
|
+
|
|
636
|
+
// ../src/export/read.ts
|
|
637
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "fs";
|
|
638
|
+
import { join as join3 } from "path";
|
|
639
|
+
|
|
548
640
|
// ../src/spec/layout.ts
|
|
549
641
|
var ROOT_DOCS = {
|
|
550
642
|
application: "application.md",
|
|
@@ -590,17 +682,6 @@ var ARCHIVED_PROPOSAL = new RegExp(
|
|
|
590
682
|
String.raw`^(?:${MODULES_DIR}\/(?<mod>[^/]+)\/)?${CHANGES_DIR}\/archive\/(?<change>[^/]+)\/proposal\.md$`
|
|
591
683
|
);
|
|
592
684
|
|
|
593
|
-
// ../src/export/paths.ts
|
|
594
|
-
var EXPORT_JSON = "export.json";
|
|
595
|
-
var WORK_JSON = "work.json";
|
|
596
|
-
var SHARDS_DIR = "_shards";
|
|
597
|
-
var slug = (text) => text.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[đłøæœßþ]/g, (c) => ({ \u0111: "d", \u0142: "l", \u00F8: "o", \u00E6: "ae", \u0153: "oe", \u00DF: "ss", \u00FE: "th" })[c] ?? c).replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/, "") || "section";
|
|
598
|
-
var shardDir = (path) => `${SHARDS_DIR}/${path.replace(/\.md$/, "")}`;
|
|
599
|
-
var itemShardName = (key) => `${key.startsWith("term:") ? slug(key.slice(5)) : key}.md`;
|
|
600
|
-
var itemShardPath = (path, key) => `${shardDir(path)}/${itemShardName(key)}`;
|
|
601
|
-
var FRONT_MATTER_SHARD = "00-front-matter.yaml";
|
|
602
|
-
var isSectionShard = (name, heading) => new RegExp(`^\\d{2}-${slug(heading)}\\.md$`).test(name);
|
|
603
|
-
|
|
604
685
|
// ../src/export/read.ts
|
|
605
686
|
var ExportReadError = class extends Error {
|
|
606
687
|
};
|
|
@@ -676,84 +757,6 @@ function idsIn(text, kinds) {
|
|
|
676
757
|
}
|
|
677
758
|
var frontMatterOf = (text) => splitFrontMatter(text).raw ?? "";
|
|
678
759
|
|
|
679
|
-
// ../src/changes/data-change.ts
|
|
680
|
-
var DATA_CHANGE_SECTION = "One-time data change";
|
|
681
|
-
var DATA_CHANGE_ITEM = "data-change";
|
|
682
|
-
var DATA_CHANGE_RE = new RegExp(`^(CHG-\\d{3,})#${DATA_CHANGE_ITEM}$`);
|
|
683
|
-
function dataChangeText(sectionText2) {
|
|
684
|
-
const text = sectionText2?.trim();
|
|
685
|
-
return text && !/^none\b/i.test(text) ? text : void 0;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
// ../src/changes/parts.ts
|
|
689
|
-
var FRONT_MATTER_PART = "front-matter";
|
|
690
|
-
var itemObject = (item) => item.startsWith("file:") ? item : item.replace(/-AC-\d{2}$/, "").replace(/[.#][^.#]*$/, "");
|
|
691
|
-
var forWork = (text) => text.replace(/^[^\S\n]*<!--[\s\S]*?-->[^\S\n]*\n/gm, "").replace(/<!--[\s\S]*?-->/g, "").replace(/^version:[^\S\n]*\d+[^\S\n]*\n/m, "").replace(/^(?:reviewed|dry|page):[^\n]*\n/gm, "");
|
|
692
|
-
function objectParts(text, kind) {
|
|
693
|
-
const out = /* @__PURE__ */ new Map();
|
|
694
|
-
const put = (label, heading, body2) => {
|
|
695
|
-
const base = label === "front-matter" ? FRONT_MATTER_PART : slug(heading);
|
|
696
|
-
let key = base;
|
|
697
|
-
for (let n = 2; out.has(key); n++) key = `${base}-${n}`;
|
|
698
|
-
out.set(key, { label, heading, text: body2 });
|
|
699
|
-
};
|
|
700
|
-
const t = forWork(text);
|
|
701
|
-
if (kind === "doc") {
|
|
702
|
-
const { raw, body: body2 } = splitFrontMatter(t);
|
|
703
|
-
if (raw) put("front-matter", FRONT_MATTER_PART, raw);
|
|
704
|
-
for (const s of headed(body2, "## ").sections) put("section", s.heading, s.text);
|
|
705
|
-
return out;
|
|
706
|
-
}
|
|
707
|
-
const yaml = /^```ya?ml\n([\s\S]*?)\n```[^\S\n]*$/m.exec(t);
|
|
708
|
-
if (yaml) put("front-matter", FRONT_MATTER_PART, yaml[1]);
|
|
709
|
-
const body = yaml ? t.slice(yaml.index + yaml[0].length) : t.replace(/^## [^\n]*\n?/, "");
|
|
710
|
-
const { sections } = headed(body, "### ");
|
|
711
|
-
if (sections.length) for (const s of sections) put("section", s.heading, s.text);
|
|
712
|
-
else for (const b of bullets(body)) put("line", b.heading, b.text);
|
|
713
|
-
return out;
|
|
714
|
-
}
|
|
715
|
-
function headed(text, marker) {
|
|
716
|
-
const sections = [];
|
|
717
|
-
let intro = "";
|
|
718
|
-
let fence2 = false;
|
|
719
|
-
for (const l of text.split("\n")) {
|
|
720
|
-
if (/^(?:```|~~~)/.test(l)) fence2 = !fence2;
|
|
721
|
-
if (!fence2 && l.startsWith(marker) && /\S/.test(l.slice(marker.length))) {
|
|
722
|
-
sections.push({ heading: l.slice(marker.length).trim(), text: "" });
|
|
723
|
-
continue;
|
|
724
|
-
}
|
|
725
|
-
if (sections.length) sections[sections.length - 1].text += `${l}
|
|
726
|
-
`;
|
|
727
|
-
else intro += `${l}
|
|
728
|
-
`;
|
|
729
|
-
}
|
|
730
|
-
return { intro, sections };
|
|
731
|
-
}
|
|
732
|
-
var BULLET = /^(?:[-*+]|\d+[.)])\s+(.*)$/;
|
|
733
|
-
function bullets(text) {
|
|
734
|
-
const out = [];
|
|
735
|
-
let current;
|
|
736
|
-
let fence2 = false;
|
|
737
|
-
for (const l of text.split("\n")) {
|
|
738
|
-
if (/^(?:```|~~~)/.test(l)) {
|
|
739
|
-
fence2 = !fence2;
|
|
740
|
-
current = void 0;
|
|
741
|
-
continue;
|
|
742
|
-
}
|
|
743
|
-
if (fence2) continue;
|
|
744
|
-
const m = BULLET.exec(l);
|
|
745
|
-
if (m) {
|
|
746
|
-
current = { heading: lead(m[1]), text: `${l}
|
|
747
|
-
` };
|
|
748
|
-
out.push(current);
|
|
749
|
-
} else if (current && /^\s+\S/.test(l)) current.text += `${l}
|
|
750
|
-
`;
|
|
751
|
-
else current = void 0;
|
|
752
|
-
}
|
|
753
|
-
return out;
|
|
754
|
-
}
|
|
755
|
-
var lead = (s) => s.replace(/\*\*|__|`/g, "").split(/:\s|:$|\s[—–-]\s|\.\s|\.$/)[0].trim().split(/\s+/).slice(0, 8).join(" ");
|
|
756
|
-
|
|
757
760
|
// ../src/lib/diff.ts
|
|
758
761
|
var linesOf = (text) => text === "" ? [] : text.replace(/\n$/, "").split("\n");
|
|
759
762
|
function diffLines(a, b) {
|
|
@@ -1832,6 +1835,188 @@ function contextStats(markdown) {
|
|
|
1832
1835
|
].join("\n") + "\n";
|
|
1833
1836
|
}
|
|
1834
1837
|
|
|
1838
|
+
// src/bugs.ts
|
|
1839
|
+
var BugTaskSchema = z8.object({
|
|
1840
|
+
id: z8.string(),
|
|
1841
|
+
track: z8.string(),
|
|
1842
|
+
status: z8.string(),
|
|
1843
|
+
developer: z8.string().nullish(),
|
|
1844
|
+
items: z8.array(z8.string()).default([]),
|
|
1845
|
+
/** The built tasks it waits for. */
|
|
1846
|
+
after: z8.array(z8.string()).default([]),
|
|
1847
|
+
branch: z8.string().nullish(),
|
|
1848
|
+
in_main: z8.boolean().nullish()
|
|
1849
|
+
});
|
|
1850
|
+
var BugSchema = z8.object({
|
|
1851
|
+
id: z8.string(),
|
|
1852
|
+
title: z8.string(),
|
|
1853
|
+
description: z8.string(),
|
|
1854
|
+
/** The reporter. */
|
|
1855
|
+
developer: z8.string(),
|
|
1856
|
+
at: z8.string(),
|
|
1857
|
+
export: z8.string().nullish(),
|
|
1858
|
+
cites: z8.array(z8.string()).default([]),
|
|
1859
|
+
/** The changes of the tasks it waits for. */
|
|
1860
|
+
origin: z8.array(z8.string()).default([]),
|
|
1861
|
+
status: z8.enum(["open", "done", "dismissed"]).default("open"),
|
|
1862
|
+
dismissed: z8.object({ by: z8.string(), at: z8.string(), reason: z8.string(), duplicate_of: z8.string().nullish() }).nullish(),
|
|
1863
|
+
tasks: z8.array(BugTaskSchema).default([])
|
|
1864
|
+
});
|
|
1865
|
+
var BugsError = class extends Error {
|
|
1866
|
+
};
|
|
1867
|
+
async function listBugs(session, filter = {}) {
|
|
1868
|
+
const answer = await callTool(session, "bugs", {
|
|
1869
|
+
...filter.about ? { about: filter.about } : { mine: true },
|
|
1870
|
+
...filter.status ? { status: filter.status } : {},
|
|
1871
|
+
...filter.track ? { track: filter.track } : {}
|
|
1872
|
+
});
|
|
1873
|
+
const parsed = z8.array(BugSchema).safeParse(answer.bugs ?? []);
|
|
1874
|
+
if (!parsed.success) throw new BugsError("The dispatcher\u2019s bugs are not in a form this client reads.");
|
|
1875
|
+
return parsed.data;
|
|
1876
|
+
}
|
|
1877
|
+
var one2 = (text) => text.replace(/\s+/g, " ").trim();
|
|
1878
|
+
function bugTaskWords(t) {
|
|
1879
|
+
const who = t.developer ? ` (${t.developer})` : "";
|
|
1880
|
+
const where = t.status === "blocked" && t.after.length ? `, after ${t.after.join(", ")}` : t.status === "done" ? t.in_main ? ", in main" : t.branch ? `, on \`${t.branch}\`` : "" : "";
|
|
1881
|
+
return `${t.id} ${t.status}${who}${where}`;
|
|
1882
|
+
}
|
|
1883
|
+
function bugLines(b) {
|
|
1884
|
+
const state = b.status === "dismissed" ? `dismissed by ${b.dismissed?.by ?? "an admin"}${b.dismissed?.duplicate_of ? `, duplicate of ${b.dismissed.duplicate_of}` : ""}` : b.status;
|
|
1885
|
+
const lines = [`- ${b.id} (${state}; ${b.developer}, ${b.at.slice(0, 10)}): ${one2(b.title)}`];
|
|
1886
|
+
if (b.cites.length) lines.push(` - Cites: ${b.cites.join(", ")}`);
|
|
1887
|
+
if (b.dismissed) lines.push(` - Reason: ${one2(b.dismissed.reason)}`);
|
|
1888
|
+
else if (b.tasks.length) lines.push(` - Tasks: ${b.tasks.map(bugTaskWords).join("; ")}`);
|
|
1889
|
+
return lines;
|
|
1890
|
+
}
|
|
1891
|
+
function bugsText(bugs) {
|
|
1892
|
+
if (!bugs.length) return "No bugs.\n";
|
|
1893
|
+
return bugs.flatMap(bugLines).join("\n") + "\n";
|
|
1894
|
+
}
|
|
1895
|
+
function parseBug(raw) {
|
|
1896
|
+
const parsed = BugSchema.safeParse(raw);
|
|
1897
|
+
return parsed.success ? parsed.data : void 0;
|
|
1898
|
+
}
|
|
1899
|
+
async function bugTaskState(session, task) {
|
|
1900
|
+
let answer;
|
|
1901
|
+
try {
|
|
1902
|
+
answer = await callTool(session, "task", { id: task.id });
|
|
1903
|
+
} catch (e) {
|
|
1904
|
+
throw new BugsError(
|
|
1905
|
+
`${task.id} is a bug's task, and only the dispatcher holds a bug: ${e.message.split("\n")[0]}`
|
|
1906
|
+
);
|
|
1907
|
+
}
|
|
1908
|
+
const bug = parseBug(answer.bug);
|
|
1909
|
+
if (!bug) throw new BugsError(`The dispatcher sent no bug for ${task.id} this client reads.`);
|
|
1910
|
+
const items = answer.items ?? [];
|
|
1911
|
+
const from = startFrom(task.track, answer.after);
|
|
1912
|
+
return {
|
|
1913
|
+
bug,
|
|
1914
|
+
objects: z8.array(z8.string()).catch([]).parse(answer.objects),
|
|
1915
|
+
after: (answer.after ?? []).flatMap((a) => a.id ? [a.id] : []),
|
|
1916
|
+
covered: new Map(items.flatMap((i) => i.covered_commit ? [[i.item, i.covered_commit]] : [])),
|
|
1917
|
+
...from.length ? { startFrom: from } : {}
|
|
1918
|
+
};
|
|
1919
|
+
}
|
|
1920
|
+
var objectOfItem = (item, objects) => [...objects].filter(
|
|
1921
|
+
(o) => item === o || item.startsWith(`${o}-`) || item.startsWith(`${o}.`) || item.startsWith(`${o}#`)
|
|
1922
|
+
).sort((a, b) => b.length - a.length)[0] ?? item.replace(/(-AC-\d+|\.A\d+|#.+)$/, "");
|
|
1923
|
+
function bugContext(x, task, exportDir2, state, questions) {
|
|
1924
|
+
const track = x.work.tracks.find((t) => t.code === task.track) ?? {
|
|
1925
|
+
code: task.track,
|
|
1926
|
+
kind: "ui",
|
|
1927
|
+
channels: []
|
|
1928
|
+
};
|
|
1929
|
+
const keys = [
|
|
1930
|
+
...new Set(state.objects.length ? state.objects : state.bug.cites.map((c) => objectOfItem(c, [])))
|
|
1931
|
+
];
|
|
1932
|
+
const objects = keys.map((key) => {
|
|
1933
|
+
const file = x.fileOf(key);
|
|
1934
|
+
const held = file !== void 0 && x.has(file);
|
|
1935
|
+
const o = { key, ...held ? { file } : {} };
|
|
1936
|
+
if (held && x.shards(file).length) o.shards = x.shards(file)[0].replace(/\/[^/]+$/, "");
|
|
1937
|
+
const by = x.sources.get(key)?.changed_by;
|
|
1938
|
+
if (by?.length) o.changed_by = by;
|
|
1939
|
+
return o;
|
|
1940
|
+
});
|
|
1941
|
+
return {
|
|
1942
|
+
task: task.id,
|
|
1943
|
+
bug: state.bug,
|
|
1944
|
+
track: { code: track.code, kind: track.kind, channels: track.channels },
|
|
1945
|
+
export: exportDir2,
|
|
1946
|
+
...questions?.length ? { questions } : {},
|
|
1947
|
+
after: state.after,
|
|
1948
|
+
...state.startFrom?.length ? { startFrom: state.startFrom } : {},
|
|
1949
|
+
checklist: {
|
|
1950
|
+
items: state.bug.cites.map((item) => {
|
|
1951
|
+
const covered = state.covered?.get(item);
|
|
1952
|
+
return { item, what: itemWhat(x, item, void 0, task.track), ...covered ? { covered } : {} };
|
|
1953
|
+
})
|
|
1954
|
+
},
|
|
1955
|
+
objects,
|
|
1956
|
+
origin: state.bug.origin.map((id) => {
|
|
1957
|
+
const change = x.work.changes.find((c) => c.id === id);
|
|
1958
|
+
const proposal = x.proposalPath(id);
|
|
1959
|
+
return { id, ...change ? { title: change.title } : {}, ...proposal ? { proposal } : {} };
|
|
1960
|
+
})
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
function renderBugContext(c) {
|
|
1964
|
+
const b = c.bug;
|
|
1965
|
+
const out = [
|
|
1966
|
+
`# ${c.task}: ${b.title}`,
|
|
1967
|
+
"",
|
|
1968
|
+
`Track ${c.track.code} (${c.track.kind}${c.track.channels.length ? `: ${c.track.channels.join(", ")}` : ""}). Bug ${b.id}, raised by ${b.developer} on ${b.at.slice(0, 10)}${b.export ? `, groomed against export ${b.export.slice(0, 12)}` : ""}${b.origin.length ? `, in what ${b.origin.join(", ")} built` : ""}. Paths are relative to the export, ${c.export}.`
|
|
1969
|
+
];
|
|
1970
|
+
if (c.after.length) out.push("", `Waits for: ${c.after.join(", ")}.`);
|
|
1971
|
+
if (c.startFrom?.length)
|
|
1972
|
+
out.push(
|
|
1973
|
+
"",
|
|
1974
|
+
`Start from ${c.startFrom.map((s) => `\`${s.branch}\` (${s.id}${s.commit ? ` done at ${s.commit.slice(0, 12)}` : ""})`).join(", then ")}, not from the main branch: the work the bug is in is pushed there and not merged yet (fetch it and base your branch on \`origin/${c.startFrom[c.startFrom.length - 1].branch}\`).`
|
|
1975
|
+
);
|
|
1976
|
+
out.push("");
|
|
1977
|
+
if (c.questions?.length) out.push(...questionsSection(c.questions));
|
|
1978
|
+
out.push(
|
|
1979
|
+
"## The bug",
|
|
1980
|
+
"",
|
|
1981
|
+
"The reporter\u2019s words, naming IDs; what the spec says is in the export, under the objects below. The product deviates from the cited items: make it do what they say, and nothing else. The tasks that built them stay as they are; this task is the fix.",
|
|
1982
|
+
"",
|
|
1983
|
+
b.description.trim(),
|
|
1984
|
+
"",
|
|
1985
|
+
`Cites: ${b.cites.join(", ")}.`
|
|
1986
|
+
);
|
|
1987
|
+
const done = c.checklist.items.filter((i) => i.covered).length;
|
|
1988
|
+
out.push(
|
|
1989
|
+
"",
|
|
1990
|
+
`## Checklist (${done} of ${c.checklist.items.length} covered)`,
|
|
1991
|
+
"",
|
|
1992
|
+
"The cited items. Name an item in `Alterspec-Covers` on the commit with which its tests pass again.",
|
|
1993
|
+
"",
|
|
1994
|
+
...c.checklist.items.map(
|
|
1995
|
+
(i) => `- [${i.covered ? "x" : " "}] \`${i.item}\`: ${i.what}${i.covered ? ` (covered by ${i.covered.slice(0, 12)})` : ""}`
|
|
1996
|
+
)
|
|
1997
|
+
);
|
|
1998
|
+
out.push("", "## The objects", "", "What the spec says now; a bug is fixed against the current text.", "");
|
|
1999
|
+
for (const o of c.objects) {
|
|
2000
|
+
const where = o.file ? `\`${o.file}\`${o.shards ? `, shards in \`${o.shards}/\`` : ""}` : "not in the export now";
|
|
2001
|
+
out.push(
|
|
2002
|
+
`- ${o.key}: ${where}${o.changed_by?.length ? `; last changed by ${o.changed_by.join(", ")}` : ""}.`
|
|
2003
|
+
);
|
|
2004
|
+
}
|
|
2005
|
+
if (c.origin.length) {
|
|
2006
|
+
out.push(
|
|
2007
|
+
"",
|
|
2008
|
+
"## The changes it originates in",
|
|
2009
|
+
"",
|
|
2010
|
+
"What was built and found wanting; their proposals say why.",
|
|
2011
|
+
""
|
|
2012
|
+
);
|
|
2013
|
+
for (const ch of c.origin)
|
|
2014
|
+
out.push(`- ${ch.id}${ch.title ? ` ${ch.title}` : ""}${ch.proposal ? `: ${ch.proposal}` : ""}`);
|
|
2015
|
+
}
|
|
2016
|
+
out.push("");
|
|
2017
|
+
return out.join("\n");
|
|
2018
|
+
}
|
|
2019
|
+
|
|
1835
2020
|
// src/git.ts
|
|
1836
2021
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
1837
2022
|
import { existsSync as existsSync4 } from "fs";
|
|
@@ -1842,16 +2027,23 @@ var TRAILER = "Alterspec-Task";
|
|
|
1842
2027
|
var TaskError = class extends Error {
|
|
1843
2028
|
};
|
|
1844
2029
|
function parseTask(text) {
|
|
1845
|
-
const m = /^(CHG-\d{3})\/([A-Z]{2,5})$/.exec(text.trim().toUpperCase());
|
|
2030
|
+
const m = /^(CHG-\d{3}|BUG-[1-9]\d*)\/([A-Z]{2,5})$/.exec(text.trim().toUpperCase());
|
|
1846
2031
|
if (!m)
|
|
1847
|
-
throw new TaskError(
|
|
1848
|
-
|
|
2032
|
+
throw new TaskError(
|
|
2033
|
+
`"${text}" is not a task: write it as CHG-012/BE (the change, a slash, the track), or BUG-3/BE for a bug's.`
|
|
2034
|
+
);
|
|
2035
|
+
return {
|
|
2036
|
+
id: `${m[1]}/${m[2]}`,
|
|
2037
|
+
change: m[1],
|
|
2038
|
+
track: m[2],
|
|
2039
|
+
kind: m[1].startsWith("BUG-") ? "bug" : "change"
|
|
2040
|
+
};
|
|
1849
2041
|
}
|
|
1850
2042
|
var branchOf = (t) => `task/${t.change.toLowerCase()}-${t.track.toLowerCase()}`;
|
|
1851
2043
|
var folderOf = (t) => `${t.change.toLowerCase()}-${t.track.toLowerCase()}`;
|
|
1852
2044
|
var COVERS = "Alterspec-Covers";
|
|
1853
2045
|
function taskOfBranch(branch) {
|
|
1854
|
-
const m = /^task\/(chg-\d{3})-([a-z]{2,5})$/.exec(branch?.trim() ?? "");
|
|
2046
|
+
const m = /^task\/(chg-\d{3}|bug-[1-9]\d*)-([a-z]{2,5})$/.exec(branch?.trim() ?? "");
|
|
1855
2047
|
return m ? parseTask(`${m[1]}/${m[2]}`) : void 0;
|
|
1856
2048
|
}
|
|
1857
2049
|
|
|
@@ -2783,13 +2975,27 @@ program.command("export-head").description("pull the export clone and print its
|
|
|
2783
2975
|
process.stdout.write(JSON.stringify(head, null, 2) + "\n");
|
|
2784
2976
|
})
|
|
2785
2977
|
);
|
|
2786
|
-
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").option("--stats", "print its size by section instead").action(
|
|
2978
|
+
program.command("context").description("print a task\u2019s brief, assembled from the export").argument("<task>", "the task, e.g. CHG-012/BE or BUG-3/BE").option("--json", "print it as JSON").option("--stats", "print its size by section instead").action(
|
|
2787
2979
|
run(async (id, opts) => {
|
|
2788
2980
|
const loaded = loadConfig();
|
|
2789
2981
|
approveWorktree(loaded);
|
|
2790
2982
|
const dir = exportDir(loaded);
|
|
2791
2983
|
const x = readExport(dir);
|
|
2792
2984
|
const task = parseTask(id);
|
|
2985
|
+
if (task.kind === "bug") {
|
|
2986
|
+
const session = sessionOf(loaded);
|
|
2987
|
+
const ctx2 = bugContext(
|
|
2988
|
+
x,
|
|
2989
|
+
task,
|
|
2990
|
+
dir,
|
|
2991
|
+
await bugTaskState(session, task),
|
|
2992
|
+
await changeQuestions(session, [task.id])
|
|
2993
|
+
);
|
|
2994
|
+
process.stdout.write(
|
|
2995
|
+
opts.stats ? contextStats(renderBugContext(ctx2)) : opts.json ? JSON.stringify(ctx2, null, 2) + "\n" : renderBugContext(ctx2)
|
|
2996
|
+
);
|
|
2997
|
+
return;
|
|
2998
|
+
}
|
|
2793
2999
|
const tasks = [
|
|
2794
3000
|
task.id,
|
|
2795
3001
|
...(x.work.changes.find((c) => c.id === task.change)?.tasks ?? []).map((t) => `${task.change}/${t.track}`).filter((t) => t !== task.id)
|
|
@@ -2873,6 +3079,18 @@ program.command("questions").description("print the questions the dispatcher kee
|
|
|
2873
3079
|
process.stdout.write(opts.json ? JSON.stringify(questions, null, 2) + "\n" : questionsText(questions));
|
|
2874
3080
|
})
|
|
2875
3081
|
);
|
|
3082
|
+
program.command("bugs").description("print the bugs the dispatcher keeps: the ones naming some IDs, or without --about your own").option("--about <id...>", "everyone\u2019s bugs whose cites, title or description name these IDs").option("--status <status>", "only the open, done or dismissed ones").option("--track <code>", "only those with a task on this track").option("--json", "print them as JSON").action(
|
|
3083
|
+
run(async (opts) => {
|
|
3084
|
+
if (opts.status && !["open", "done", "dismissed"].includes(opts.status))
|
|
3085
|
+
throw new Error(`--status takes open, done or dismissed, not "${opts.status}".`);
|
|
3086
|
+
const bugs = await listBugs(sessionOf(loadConfig()), {
|
|
3087
|
+
...opts.about ? { about: opts.about } : {},
|
|
3088
|
+
...opts.status ? { status: opts.status } : {},
|
|
3089
|
+
...opts.track ? { track: opts.track.toUpperCase() } : {}
|
|
3090
|
+
});
|
|
3091
|
+
process.stdout.write(opts.json ? JSON.stringify(bugs, null, 2) + "\n" : bugsText(bugs));
|
|
3092
|
+
})
|
|
3093
|
+
);
|
|
2876
3094
|
program.command("merged").description(
|
|
2877
3095
|
"print the commit and branch to report done with: the pushed task branch\u2019s head, or the commit on origin/<main> that brought the task in"
|
|
2878
3096
|
).argument("<task>", "the task, e.g. CHG-012/BE").option("--json", "print { commit, branch } as JSON").action(
|