@dendelion/paper-camp 0.36.0 → 0.37.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/dist/chunks/phase-progress.C97wkNMK.js +3103 -0
- package/dist/chunks/phase-progress.C97wkNMK.js.map +1 -0
- package/dist/cli/index.js +2328 -2222
- package/dist/cli/index.js.map +1 -1
- package/dist/core/index.js +108 -106
- package/dist/core/parked-questions.d.ts +3 -2
- package/dist/core/parked-questions.d.ts.map +1 -1
- package/dist/core/roadmap.d.ts +22 -8
- package/dist/core/roadmap.d.ts.map +1 -1
- package/dist/toolbar/toolbar.js.map +1 -1
- package/dist/types/index.d.ts +21 -17
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/phase-progress.r-Xs-Sr0.js +0 -3064
- package/dist/chunks/phase-progress.r-Xs-Sr0.js.map +0 -1
|
@@ -0,0 +1,3103 @@
|
|
|
1
|
+
import { readFile as v, mkdir as P, writeFile as E, readdir as z, stat as jt, rename as Mt, access as Lt } from "node:fs/promises";
|
|
2
|
+
import { dirname as M, join as p, basename as Ft } from "node:path";
|
|
3
|
+
import { parse as V, stringify as Ht } from "yaml";
|
|
4
|
+
import { spawn as b } from "node:child_process";
|
|
5
|
+
import { AGENT_IDS as L, NIGHT_CHECK_IDS as Gt, NOTIFICATION_SETTING_KINDS as Bt, PLAN_KINDS as Yt } from "../types/index.js";
|
|
6
|
+
import { createHash as qt } from "node:crypto";
|
|
7
|
+
import { existsSync as ae, readFileSync as He } from "node:fs";
|
|
8
|
+
import { fileURLToPath as Ut } from "node:url";
|
|
9
|
+
import { z as Kt, A as Wt, e as Jt, n as zt, a as Vt, u as Xt } from "./daemon-state.BeDnhzBY.js";
|
|
10
|
+
import { z as d } from "zod";
|
|
11
|
+
const Zt = /^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/;
|
|
12
|
+
function Qt(e) {
|
|
13
|
+
return e.length >= 2 && (e.startsWith('"') && e.endsWith('"') || e.startsWith("'") && e.endsWith("'")) ? e.slice(1, -1) : e;
|
|
14
|
+
}
|
|
15
|
+
function Re(e) {
|
|
16
|
+
return e === "" || /[\s#"]/.test(e) ? `"${e.replace(/"/g, '\\"')}"` : e;
|
|
17
|
+
}
|
|
18
|
+
function Ge(e) {
|
|
19
|
+
const t = e.trim();
|
|
20
|
+
if (!t || t.startsWith("#")) return null;
|
|
21
|
+
const n = t.match(Zt);
|
|
22
|
+
return n ? { key: n[1], value: Qt(n[2]) } : null;
|
|
23
|
+
}
|
|
24
|
+
function gi(e) {
|
|
25
|
+
const t = [];
|
|
26
|
+
for (const n of e.split(`
|
|
27
|
+
`)) {
|
|
28
|
+
const s = Ge(n);
|
|
29
|
+
s && t.push(s);
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
|
+
function yi(e, t) {
|
|
34
|
+
const n = new Map(t.map((i) => [i.key, i.value])), s = e.length > 0 ? e.split(`
|
|
35
|
+
`) : [], r = [];
|
|
36
|
+
for (const i of s) {
|
|
37
|
+
const a = Ge(i);
|
|
38
|
+
if (!a) {
|
|
39
|
+
r.push(i);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
n.has(a.key) && (r.push(`${a.key}=${Re(n.get(a.key) ?? "")}`), n.delete(a.key));
|
|
43
|
+
}
|
|
44
|
+
for (const [i, a] of n)
|
|
45
|
+
r.push(`${i}=${Re(a)}`);
|
|
46
|
+
for (; r.length > 0 && r[r.length - 1] === ""; ) r.pop();
|
|
47
|
+
return r.length > 0 ? `${r.join(`
|
|
48
|
+
`)}
|
|
49
|
+
` : "";
|
|
50
|
+
}
|
|
51
|
+
function wi(e) {
|
|
52
|
+
return e.archived === !0 || e.status === "done";
|
|
53
|
+
}
|
|
54
|
+
function ee(e) {
|
|
55
|
+
const t = e.phases.length > 0 && e.phases.every((s) => s.done), n = (e.fixes ?? []).every((s) => s.done);
|
|
56
|
+
return t && n;
|
|
57
|
+
}
|
|
58
|
+
function X(e, t, n, s = !1) {
|
|
59
|
+
return e.kind === "note" || e.status === "dropped" ? e.status : e.archived ? "done" : t ? t.state === "merged" ? ee(e) ? "done" : "planned" : t.state === "closed" ? "dropped" : ee(e) ? "review" : "in-progress" : n ? e.status === "review" || e.status === "done" ? e.status : s && e.phases.length > 0 ? ee(e) ? "review" : "in-progress" : e.phases.length > 0 ? "planned" : "idea" : e.status ?? (e.phases.length > 0 ? "planned" : "idea");
|
|
60
|
+
}
|
|
61
|
+
function en(e, t, n) {
|
|
62
|
+
return e.kind === "note" || e.kind === "board" || e.status === "dropped" || e.archived || t ? !1 : !n;
|
|
63
|
+
}
|
|
64
|
+
function tn(e, t) {
|
|
65
|
+
if (e.kind === "note" || e.archived || (t == null ? void 0 : t.state) !== "merged") return !1;
|
|
66
|
+
const n = X(e, t, !0);
|
|
67
|
+
return n === "review" || n === "done";
|
|
68
|
+
}
|
|
69
|
+
function Be(e) {
|
|
70
|
+
return e.length === 0 ? "idea" : e.every((t) => t === "done" || t === "dropped") ? "review" : e.some((t) => t !== "idea" && t !== "planned") ? "in-progress" : "planned";
|
|
71
|
+
}
|
|
72
|
+
function nn(e = [], t = [], n = [], s = []) {
|
|
73
|
+
const r = [
|
|
74
|
+
...e.map((a) => ({ kind: "log", date: a.date, text: a.text })),
|
|
75
|
+
...t.map((a) => ({ kind: "clarification", date: a.date, text: a.text })),
|
|
76
|
+
...s.map((a) => ({ kind: "review", date: a.date, text: a.text }))
|
|
77
|
+
].sort((a, o) => a.date.localeCompare(o.date)), i = n.map((a) => ({
|
|
78
|
+
kind: a.kind ?? "note",
|
|
79
|
+
text: a.anchor.kind === "phase" ? `[phase ${a.anchor.index}] ${a.prose}` : a.prose,
|
|
80
|
+
state: a.state
|
|
81
|
+
}));
|
|
82
|
+
return [...r, ...i];
|
|
83
|
+
}
|
|
84
|
+
function oe(e, t) {
|
|
85
|
+
return e.filter((n) => n.kind === t).map((n) => ({ date: n.date ?? "", text: n.text }));
|
|
86
|
+
}
|
|
87
|
+
function Ye(e = []) {
|
|
88
|
+
return oe(e, "log");
|
|
89
|
+
}
|
|
90
|
+
function sn(e = []) {
|
|
91
|
+
return oe(e, "clarification");
|
|
92
|
+
}
|
|
93
|
+
function rn(e = []) {
|
|
94
|
+
return oe(e, "review");
|
|
95
|
+
}
|
|
96
|
+
function an(e = []) {
|
|
97
|
+
return e.filter(
|
|
98
|
+
(t) => t.kind === "note" || t.kind === "decision" || t.kind === "question"
|
|
99
|
+
).map((t) => ({
|
|
100
|
+
anchor: { kind: "body" },
|
|
101
|
+
prose: t.text,
|
|
102
|
+
state: t.state ?? "open",
|
|
103
|
+
kind: t.kind
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
function bi(e, t, n) {
|
|
107
|
+
return [...(e ?? []).filter((s) => !t.includes(s.kind)), ...n];
|
|
108
|
+
}
|
|
109
|
+
function vi(e, t, n, s) {
|
|
110
|
+
return e.map((r, i) => {
|
|
111
|
+
if (i !== t) return r;
|
|
112
|
+
const a = s ? `${r.text}
|
|
113
|
+
|
|
114
|
+
${s}` : r.text;
|
|
115
|
+
if (n === "decision") return { ...r, kind: n, state: "open", text: a };
|
|
116
|
+
const { state: o, ...c } = r;
|
|
117
|
+
return { ...c, kind: n, text: a };
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function Ei(e = []) {
|
|
121
|
+
const t = e.reduce((n, s, r) => s.kind === "log" ? r : n, -1);
|
|
122
|
+
return e.slice(t + 1).filter((n) => n.kind === "chat");
|
|
123
|
+
}
|
|
124
|
+
function qe(e, t, n = !1, s = !1) {
|
|
125
|
+
return {
|
|
126
|
+
title: e.title,
|
|
127
|
+
// Non-note entities can't carry the note-only 'open' (schema-enforced).
|
|
128
|
+
status: X(e, t, n, s),
|
|
129
|
+
statusFallback: en(e, t, n),
|
|
130
|
+
kind: e.type,
|
|
131
|
+
entityKind: e.kind === "note" ? void 0 : e.kind,
|
|
132
|
+
id: e.id,
|
|
133
|
+
idea: e.idea,
|
|
134
|
+
agent: e.agent,
|
|
135
|
+
created: e.created,
|
|
136
|
+
updated: e.updated,
|
|
137
|
+
audited: e.audited,
|
|
138
|
+
auditedHash: e.auditedHash,
|
|
139
|
+
released: e.released,
|
|
140
|
+
tags: e.tags,
|
|
141
|
+
subject: e.subject,
|
|
142
|
+
order: e.order,
|
|
143
|
+
issueSource: e.issueSource,
|
|
144
|
+
body: e.body,
|
|
145
|
+
phases: e.phases,
|
|
146
|
+
fixes: e.fixes,
|
|
147
|
+
log: Ye(e.thread),
|
|
148
|
+
clarifications: sn(e.thread),
|
|
149
|
+
notes: an(e.thread),
|
|
150
|
+
review: rn(e.thread),
|
|
151
|
+
thread: e.thread,
|
|
152
|
+
archived: e.archived,
|
|
153
|
+
pr: t
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function on(e) {
|
|
157
|
+
return {
|
|
158
|
+
id: e.id,
|
|
159
|
+
title: e.title,
|
|
160
|
+
body: e.body,
|
|
161
|
+
kind: "note",
|
|
162
|
+
status: e.status,
|
|
163
|
+
subject: e.subject,
|
|
164
|
+
order: e.order,
|
|
165
|
+
created: e.created,
|
|
166
|
+
log: Ye(e.thread)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
const cn = /^[0-9a-f]{4,40}$/i, dn = /^Merge pull request #\d+ from \S+\/([a-z]+-\d+)-/i;
|
|
170
|
+
function S(e, t) {
|
|
171
|
+
return new Promise((n) => {
|
|
172
|
+
var i;
|
|
173
|
+
const s = b("git", t, { cwd: e, stdio: ["ignore", "pipe", "ignore"] });
|
|
174
|
+
let r = "";
|
|
175
|
+
(i = s.stdout) == null || i.on("data", (a) => {
|
|
176
|
+
r += a.toString();
|
|
177
|
+
}), s.on("close", () => n(r)), s.on("error", () => n(""));
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
async function Ue(e) {
|
|
181
|
+
var n;
|
|
182
|
+
return ((n = (await S(e, ["symbolic-ref", "refs/remotes/origin/HEAD"])).trim().match(/refs\/remotes\/origin\/(.+)/)) == null ? void 0 : n[1]) ?? "main";
|
|
183
|
+
}
|
|
184
|
+
function ne(e) {
|
|
185
|
+
const t = e.match(/^Refs:\s*([A-Za-z]+-\d+)\s*$/m);
|
|
186
|
+
if (t) return t[1].toUpperCase();
|
|
187
|
+
const n = e.split(`
|
|
188
|
+
`, 1)[0], s = n.match(/\(([A-Za-z]+-\d+)\)/);
|
|
189
|
+
if (s) return s[1].toUpperCase();
|
|
190
|
+
const r = n.match(dn);
|
|
191
|
+
return r ? r[1].toUpperCase() : null;
|
|
192
|
+
}
|
|
193
|
+
function un(e) {
|
|
194
|
+
return e.length > 0 && e.every((t) => t.startsWith("papercamp/"));
|
|
195
|
+
}
|
|
196
|
+
async function Ke(e) {
|
|
197
|
+
const t = await Ue(e), n = await S(e, ["log", "--format=%x02%B%x00", "--name-only", t]), s = /* @__PURE__ */ new Set();
|
|
198
|
+
for (const r of n.split("")) {
|
|
199
|
+
if (!r) continue;
|
|
200
|
+
const [i, a = ""] = r.split("\0"), o = a.split(`
|
|
201
|
+
`).map((u) => u.trim()).filter(Boolean);
|
|
202
|
+
if (un(o)) continue;
|
|
203
|
+
const c = ne(i.trim());
|
|
204
|
+
c && s.add(c);
|
|
205
|
+
}
|
|
206
|
+
return s;
|
|
207
|
+
}
|
|
208
|
+
const We = "", j = "", ln = `${We}%H${j}%s${j}%cI${j}%D${j}%(trailers:key=Refs,valueonly)`, fn = /^([a-z]+(?:\([^)]*\))?):\s*(.+)$/i;
|
|
209
|
+
function pn(e) {
|
|
210
|
+
const t = e.match(fn);
|
|
211
|
+
return t ? { prefix: t[1], subject: t[2] } : { prefix: "", subject: e };
|
|
212
|
+
}
|
|
213
|
+
function hn(e, t) {
|
|
214
|
+
const n = [];
|
|
215
|
+
let s = !1;
|
|
216
|
+
for (const r of e.split(",")) {
|
|
217
|
+
const i = r.trim().replace(/^HEAD -> /, "");
|
|
218
|
+
i && (i.startsWith("tag: ") ? n.push(i.slice(5)) : t && i === t && (s = !0));
|
|
219
|
+
}
|
|
220
|
+
return { tags: n, isUpstreamHead: s };
|
|
221
|
+
}
|
|
222
|
+
function mn(e) {
|
|
223
|
+
const t = e.trim();
|
|
224
|
+
return /^[A-Za-z]+-\d+$/.test(t) ? t.toUpperCase() : null;
|
|
225
|
+
}
|
|
226
|
+
function gn(e, t, n) {
|
|
227
|
+
return e.split(We).map((s) => s.trim()).filter(Boolean).map((s) => {
|
|
228
|
+
const [r, i = "", a = "", o = "", c = ""] = s.split(j), { prefix: u, subject: l } = pn(i), { tags: f, isUpstreamHead: h } = hn(o, t);
|
|
229
|
+
return {
|
|
230
|
+
hash: r,
|
|
231
|
+
subject: l,
|
|
232
|
+
prefix: u,
|
|
233
|
+
date: a,
|
|
234
|
+
tags: f,
|
|
235
|
+
isUpstreamHead: h,
|
|
236
|
+
pushed: t !== null && !n.has(r),
|
|
237
|
+
ideaId: mn(c)
|
|
238
|
+
};
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
async function yn(e) {
|
|
242
|
+
return (await S(e, ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"])).trim() || null;
|
|
243
|
+
}
|
|
244
|
+
async function ki(e, t, n = 30) {
|
|
245
|
+
const s = await yn(e), r = await S(e, [
|
|
246
|
+
"log",
|
|
247
|
+
"--first-parent",
|
|
248
|
+
`--max-count=${n + 1}`,
|
|
249
|
+
`--skip=${t}`,
|
|
250
|
+
`--format=${ln}`
|
|
251
|
+
]), i = /* @__PURE__ */ new Set();
|
|
252
|
+
if (s) {
|
|
253
|
+
const c = await S(e, ["rev-list", `${s}..HEAD`]);
|
|
254
|
+
for (const u of c.split(`
|
|
255
|
+
`)) {
|
|
256
|
+
const l = u.trim();
|
|
257
|
+
l && i.add(l);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const a = gn(r, s, i), o = a.length > n;
|
|
261
|
+
return { commits: a.slice(0, n), upstream: s, hasMore: o };
|
|
262
|
+
}
|
|
263
|
+
const k = /* @__PURE__ */ new Map(), wn = 5 * 60 * 1e3, ce = (e) => p(e, "papercamp", "pr-map.json");
|
|
264
|
+
async function bn(e, t, n) {
|
|
265
|
+
const s = ce(e);
|
|
266
|
+
try {
|
|
267
|
+
const r = { fetchedAt: n, prs: Object.fromEntries(t) };
|
|
268
|
+
await P(M(s), { recursive: !0 }), await E(s, `${JSON.stringify(r, null, 2)}
|
|
269
|
+
`, "utf-8");
|
|
270
|
+
} catch (r) {
|
|
271
|
+
console.error(`papercamp: could not persist PR map for ${e}:`, r);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function Je(e) {
|
|
275
|
+
try {
|
|
276
|
+
const t = await v(ce(e), "utf-8"), n = JSON.parse(t);
|
|
277
|
+
return { prs: new Map(Object.entries(n.prs)), fetchedAt: n.fetchedAt };
|
|
278
|
+
} catch {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const vn = {
|
|
283
|
+
APPROVED: "approved",
|
|
284
|
+
CHANGES_REQUESTED: "changes-requested",
|
|
285
|
+
REVIEW_REQUIRED: "review-required"
|
|
286
|
+
};
|
|
287
|
+
function En(e) {
|
|
288
|
+
const t = e.state === "MERGED" ? "merged" : e.state === "CLOSED" ? "closed" : e.isDraft ? "draft" : "open", n = vn[e.reviewDecision];
|
|
289
|
+
return {
|
|
290
|
+
number: e.number,
|
|
291
|
+
url: e.url,
|
|
292
|
+
state: t,
|
|
293
|
+
...n && { reviewDecision: n },
|
|
294
|
+
...e.headRefOid && { headSha: e.headRefOid },
|
|
295
|
+
...e.headRefName && { headBranch: e.headRefName }
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const Ae = { merged: 4, open: 3, draft: 2, closed: 1 };
|
|
299
|
+
function ze(e, t) {
|
|
300
|
+
const n = e == null ? void 0 : e.match(/\*\*Plan:\*\*\s*`?([A-Za-z]+-\d+)`?/);
|
|
301
|
+
if (n) return n[1].toUpperCase();
|
|
302
|
+
const s = t == null ? void 0 : t.match(/^[a-z]+\/([a-z]+-\d+)-/);
|
|
303
|
+
return s ? s[1].toUpperCase() : null;
|
|
304
|
+
}
|
|
305
|
+
const kn = `
|
|
306
|
+
query($owner: String!, $repo: String!, $number: Int!) {
|
|
307
|
+
repository(owner: $owner, name: $repo) {
|
|
308
|
+
pullRequest(number: $number) {
|
|
309
|
+
reviewThreads(first: 100) { nodes { isResolved } }
|
|
310
|
+
commits(last: 1) { nodes { commit { committedDate } } }
|
|
311
|
+
comments(last: 1) { nodes { createdAt } }
|
|
312
|
+
reviews(last: 20) { nodes { createdAt body } }
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}`;
|
|
316
|
+
function Sn(e, t) {
|
|
317
|
+
return `Paper Scout · ${e} · ${t.slice(0, 7)}`;
|
|
318
|
+
}
|
|
319
|
+
function F(e) {
|
|
320
|
+
const t = e.match(/github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/);
|
|
321
|
+
if (!t) return null;
|
|
322
|
+
const [, n, s, r] = t;
|
|
323
|
+
return { owner: n, repo: s, number: r };
|
|
324
|
+
}
|
|
325
|
+
const $n = 15e3;
|
|
326
|
+
function Ve(e, t) {
|
|
327
|
+
return new Promise((n) => {
|
|
328
|
+
var c, u;
|
|
329
|
+
const s = b("gh", t, { cwd: e, stdio: ["ignore", "pipe", "pipe"] });
|
|
330
|
+
let r = !1;
|
|
331
|
+
const i = (l) => {
|
|
332
|
+
r || (r = !0, clearTimeout(a), l());
|
|
333
|
+
}, a = setTimeout(() => {
|
|
334
|
+
s.kill(), i(() => n(void 0));
|
|
335
|
+
}, $n);
|
|
336
|
+
let o = "";
|
|
337
|
+
(c = s.stdout) == null || c.on("data", (l) => {
|
|
338
|
+
o += l.toString();
|
|
339
|
+
}), (u = s.stderr) == null || u.on("data", () => {
|
|
340
|
+
}), s.on("close", (l) => {
|
|
341
|
+
i(() => {
|
|
342
|
+
if (l !== 0) {
|
|
343
|
+
n(void 0);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
try {
|
|
347
|
+
n(JSON.parse(o));
|
|
348
|
+
} catch {
|
|
349
|
+
n(void 0);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
}), s.on("error", () => i(() => n(void 0)));
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function Xe(e, t, n, s, r) {
|
|
356
|
+
return Qe(e, [
|
|
357
|
+
"-f",
|
|
358
|
+
`query=${t}`,
|
|
359
|
+
"-f",
|
|
360
|
+
`owner=${n}`,
|
|
361
|
+
"-f",
|
|
362
|
+
`repo=${s}`,
|
|
363
|
+
"-F",
|
|
364
|
+
`number=${r}`
|
|
365
|
+
]);
|
|
366
|
+
}
|
|
367
|
+
function Ze(e, t, n) {
|
|
368
|
+
const s = ["-f", `query=${t}`];
|
|
369
|
+
for (const [r, i] of Object.entries(n))
|
|
370
|
+
s.push("-f", `${r}=${i}`);
|
|
371
|
+
return Qe(e, s);
|
|
372
|
+
}
|
|
373
|
+
function Qe(e, t) {
|
|
374
|
+
return Ve(e, ["api", "graphql", ...t]);
|
|
375
|
+
}
|
|
376
|
+
async function In(e, t) {
|
|
377
|
+
var l, f, h, g, w;
|
|
378
|
+
const n = F(t);
|
|
379
|
+
if (!n) return;
|
|
380
|
+
const s = await Xe(e, kn, n.owner, n.repo, n.number), r = (f = (l = s == null ? void 0 : s.data) == null ? void 0 : l.repository) == null ? void 0 : f.pullRequest;
|
|
381
|
+
if (!r) return;
|
|
382
|
+
const i = r.reviewThreads.nodes.filter((y) => !y.isResolved).length, a = (h = r.commits.nodes[0]) == null ? void 0 : h.commit.committedDate, o = [(g = r.comments.nodes[0]) == null ? void 0 : g.createdAt, (w = r.reviews.nodes.at(-1)) == null ? void 0 : w.createdAt].filter((y) => !!y).sort().at(-1), c = !!(a && o && o > a), u = r.reviews.nodes.map((y) => y.body);
|
|
383
|
+
return { unresolvedThreadCount: i, hasNewCommentsSincePush: c, reviewBodies: u };
|
|
384
|
+
}
|
|
385
|
+
const Rn = `
|
|
386
|
+
query($owner: String!, $repo: String!, $number: Int!) {
|
|
387
|
+
repository(owner: $owner, name: $repo) {
|
|
388
|
+
pullRequest(number: $number) {
|
|
389
|
+
reviewThreads(first: 100) {
|
|
390
|
+
nodes {
|
|
391
|
+
id
|
|
392
|
+
isResolved
|
|
393
|
+
comments(first: 1) { nodes { path line body author { login } } }
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}`;
|
|
399
|
+
async function Si(e, t) {
|
|
400
|
+
var i, a, o;
|
|
401
|
+
const n = F(t);
|
|
402
|
+
if (!n) return [];
|
|
403
|
+
const s = await Xe(e, Rn, n.owner, n.repo, n.number);
|
|
404
|
+
return (((o = (a = (i = s == null ? void 0 : s.data) == null ? void 0 : i.repository) == null ? void 0 : a.pullRequest) == null ? void 0 : o.reviewThreads.nodes) ?? []).filter((c) => !c.isResolved).map((c) => ({ id: c.id, comment: c.comments.nodes[0] })).filter((c) => !!c.comment).map(({ id: c, comment: u }) => {
|
|
405
|
+
var l;
|
|
406
|
+
return {
|
|
407
|
+
id: c,
|
|
408
|
+
...u.path ? { path: u.path } : {},
|
|
409
|
+
...u.line != null ? { line: u.line } : {},
|
|
410
|
+
...(l = u.author) != null && l.login ? { author: u.author.login } : {},
|
|
411
|
+
body: u.body
|
|
412
|
+
};
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
const An = `
|
|
416
|
+
mutation($threadId: ID!) {
|
|
417
|
+
resolveReviewThread(input: { threadId: $threadId }) {
|
|
418
|
+
thread { id isResolved }
|
|
419
|
+
}
|
|
420
|
+
}`, Pn = `
|
|
421
|
+
mutation($threadId: ID!, $body: String!) {
|
|
422
|
+
addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $threadId, body: $body }) {
|
|
423
|
+
comment { id }
|
|
424
|
+
}
|
|
425
|
+
}`;
|
|
426
|
+
async function $i(e, t) {
|
|
427
|
+
var s, r, i;
|
|
428
|
+
const n = await Ze(e, An, { threadId: t });
|
|
429
|
+
return !!((i = (r = (s = n == null ? void 0 : n.data) == null ? void 0 : s.resolveReviewThread) == null ? void 0 : r.thread) != null && i.isResolved);
|
|
430
|
+
}
|
|
431
|
+
async function Ii(e, t, n) {
|
|
432
|
+
var r, i, a;
|
|
433
|
+
const s = await Ze(e, Pn, { threadId: t, body: n });
|
|
434
|
+
return !!((a = (i = (r = s == null ? void 0 : s.data) == null ? void 0 : r.addPullRequestReviewThreadReply) == null ? void 0 : i.comment) != null && a.id);
|
|
435
|
+
}
|
|
436
|
+
function et(e, t, n) {
|
|
437
|
+
return new Promise((s) => {
|
|
438
|
+
var a, o, c;
|
|
439
|
+
const r = b("gh", ["api", t, "-X", "POST", "--input", "-"], {
|
|
440
|
+
cwd: e,
|
|
441
|
+
stdio: ["pipe", "ignore", "pipe"]
|
|
442
|
+
});
|
|
443
|
+
let i = "";
|
|
444
|
+
(a = r.stderr) == null || a.on("data", (u) => {
|
|
445
|
+
i += u;
|
|
446
|
+
}), r.on(
|
|
447
|
+
"close",
|
|
448
|
+
(u) => s(u === 0 ? { delivered: !0 } : { delivered: !1, body: i.trim() })
|
|
449
|
+
), r.on("error", (u) => s({ delivered: !1, body: u.message })), (o = r.stdin) == null || o.on("error", () => {
|
|
450
|
+
}), (c = r.stdin) == null || c.end(JSON.stringify(n));
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
async function Ri(e, t, n) {
|
|
454
|
+
const s = F(t);
|
|
455
|
+
return s ? et(
|
|
456
|
+
e,
|
|
457
|
+
`repos/${s.owner}/${s.repo}/pulls/${s.number}/reviews`,
|
|
458
|
+
n
|
|
459
|
+
) : { delivered: !1 };
|
|
460
|
+
}
|
|
461
|
+
async function Ai(e, t, n) {
|
|
462
|
+
const s = F(t);
|
|
463
|
+
return s ? et(e, `repos/${s.owner}/${s.repo}/dispatches`, {
|
|
464
|
+
event_type: "paper-camp-review",
|
|
465
|
+
client_payload: { review: { number: Number(s.number), ...n } }
|
|
466
|
+
}) : { delivered: !1 };
|
|
467
|
+
}
|
|
468
|
+
async function Cn(e, t) {
|
|
469
|
+
const n = [...t.entries()].filter(
|
|
470
|
+
([, r]) => r.state === "open" || r.state === "draft"
|
|
471
|
+
), s = await Promise.all(n.map(([, r]) => In(e, r.url)));
|
|
472
|
+
n.forEach(([r, i], a) => {
|
|
473
|
+
const o = s[a];
|
|
474
|
+
if (!o) return;
|
|
475
|
+
const { reviewBodies: c, ...u } = o, l = !!i.headSha && c.some((f) => f.includes(Sn(r, i.headSha)));
|
|
476
|
+
t.set(r, { ...i, ...u, ...l && { scoutReviewObserved: l } });
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
async function _n(e) {
|
|
480
|
+
const t = await Ve(e, [
|
|
481
|
+
"pr",
|
|
482
|
+
"list",
|
|
483
|
+
"--state",
|
|
484
|
+
"all",
|
|
485
|
+
"--limit",
|
|
486
|
+
"2000",
|
|
487
|
+
"--json",
|
|
488
|
+
"number,url,state,isDraft,headRefName,headRefOid,body,reviewDecision"
|
|
489
|
+
]);
|
|
490
|
+
if (!t) return;
|
|
491
|
+
const n = /* @__PURE__ */ new Map();
|
|
492
|
+
for (const s of t) {
|
|
493
|
+
const r = ze(s.body, s.headRefName);
|
|
494
|
+
if (!r) continue;
|
|
495
|
+
const i = En(s), a = n.get(r);
|
|
496
|
+
(!a || Ae[i.state] > Ae[a.state]) && n.set(r, i);
|
|
497
|
+
}
|
|
498
|
+
return await Cn(e, n), n;
|
|
499
|
+
}
|
|
500
|
+
async function tt(e, t = wn) {
|
|
501
|
+
let n = k.get(e);
|
|
502
|
+
if (!n) {
|
|
503
|
+
const r = await Je(e);
|
|
504
|
+
r && (k.set(e, r), n = r);
|
|
505
|
+
}
|
|
506
|
+
if (n && Date.now() - n.fetchedAt < t) return n.prs;
|
|
507
|
+
if (!Number.isFinite(t)) return n == null ? void 0 : n.prs;
|
|
508
|
+
const s = await _n(e);
|
|
509
|
+
if (s !== void 0) {
|
|
510
|
+
const r = Date.now();
|
|
511
|
+
return k.set(e, { prs: s, fetchedAt: r }), await bn(e, s, r), s;
|
|
512
|
+
}
|
|
513
|
+
return n == null ? void 0 : n.prs;
|
|
514
|
+
}
|
|
515
|
+
function Pi(e) {
|
|
516
|
+
var t;
|
|
517
|
+
return (t = k.get(e)) == null ? void 0 : t.prs;
|
|
518
|
+
}
|
|
519
|
+
function Ci(e, t) {
|
|
520
|
+
const n = (r) => `${r.number}:${r.headSha ?? "unknown"}`, s = [];
|
|
521
|
+
for (const [r, i] of t) {
|
|
522
|
+
if (i.reviewDecision !== "changes-requested") continue;
|
|
523
|
+
const a = e == null ? void 0 : e.get(r);
|
|
524
|
+
((a == null ? void 0 : a.reviewDecision) === "changes-requested" ? n(a) : void 0) !== n(i) && s.push({ entityId: r, pr: i });
|
|
525
|
+
}
|
|
526
|
+
return s;
|
|
527
|
+
}
|
|
528
|
+
async function _i(e) {
|
|
529
|
+
let t = k.get(e);
|
|
530
|
+
if (!t) {
|
|
531
|
+
const n = await Je(e);
|
|
532
|
+
n && (k.set(e, n), t = n);
|
|
533
|
+
}
|
|
534
|
+
return (t == null ? void 0 : t.fetchedAt) ?? null;
|
|
535
|
+
}
|
|
536
|
+
async function Ti(e) {
|
|
537
|
+
if (e === void 0) {
|
|
538
|
+
k.clear();
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
const t = k.get(e);
|
|
542
|
+
t && k.set(e, { ...t, fetchedAt: 0 });
|
|
543
|
+
const n = ce(e);
|
|
544
|
+
try {
|
|
545
|
+
const s = await v(n, "utf-8"), r = JSON.parse(s);
|
|
546
|
+
r.fetchedAt = 0, await E(n, `${JSON.stringify(r, null, 2)}
|
|
547
|
+
`, "utf-8");
|
|
548
|
+
} catch {
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
const nt = /^#{2,3}\s+/, Y = /^[-*]\s+\[([ xX])\]\s+(.*)$/, Tn = /^\[(review|manual|issue)\]\s+(.*)$/, Nn = /^run:\s*(.+)$/, Pe = /^-\s+(\d{4}-\d{2}-\d{2}):\s*(.*)$/, xn = /^\[(?:phase:(\d+)|body)\]\s+(?:\[(decision|question)\]\s+)?(.*)$/, Ce = /^-\s+\[([ xX])\]\s+(?:(\d{4}-\d{2}-\d{2})\s+)?\[(log|clarification|review|note|decision|question|chat)\]\s+(\[agent\]\s+)?(?:\[\[([A-Za-z]+-\d+)\]\]\s+)?(.*)$/, On = ["note", "decision", "question"];
|
|
552
|
+
function de(e, t, n, s) {
|
|
553
|
+
const r = [];
|
|
554
|
+
let i = t;
|
|
555
|
+
for (; i < n; ) {
|
|
556
|
+
const a = e[i];
|
|
557
|
+
if (a.trim() === "" || !/^\s/.test(a)) break;
|
|
558
|
+
const o = a.trimStart();
|
|
559
|
+
if (s.test(o) || nt.test(o)) break;
|
|
560
|
+
r.push(o), i++;
|
|
561
|
+
}
|
|
562
|
+
return { text: r.join(" "), next: i };
|
|
563
|
+
}
|
|
564
|
+
function ue(e, t) {
|
|
565
|
+
return t ? `${e.trim()} ${t}` : e.trim();
|
|
566
|
+
}
|
|
567
|
+
function st(e, t, n) {
|
|
568
|
+
const s = [];
|
|
569
|
+
let r = t;
|
|
570
|
+
for (; r < n; ) {
|
|
571
|
+
const i = e[r].match(Y);
|
|
572
|
+
if (i) {
|
|
573
|
+
const a = i[1].toLowerCase() === "x", o = i[2].trim(), c = o.match(Tn), u = c ? c[2].trim() : o, l = c ? c[1] : void 0, f = [];
|
|
574
|
+
let h;
|
|
575
|
+
for (r++; r < n; ) {
|
|
576
|
+
const g = e[r];
|
|
577
|
+
if (g.trim() === "" || Y.test(g) || nt.test(g)) break;
|
|
578
|
+
if (/^\s/.test(g)) {
|
|
579
|
+
const w = g.trimStart(), y = w.match(Nn), m = y ? Kt(y[1]) : void 0;
|
|
580
|
+
m ? h = m : f.push(w), r++;
|
|
581
|
+
} else
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
584
|
+
s.push({
|
|
585
|
+
done: a,
|
|
586
|
+
text: u,
|
|
587
|
+
description: f.length > 0 ? f.join(`
|
|
588
|
+
`) : void 0,
|
|
589
|
+
source: l,
|
|
590
|
+
run: h
|
|
591
|
+
});
|
|
592
|
+
} else
|
|
593
|
+
r++;
|
|
594
|
+
}
|
|
595
|
+
return s;
|
|
596
|
+
}
|
|
597
|
+
function le(e, t, n) {
|
|
598
|
+
const s = [];
|
|
599
|
+
let r = t;
|
|
600
|
+
for (; r < n; ) {
|
|
601
|
+
const i = e[r].match(Pe);
|
|
602
|
+
if (!i) {
|
|
603
|
+
r++;
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
const a = de(e, r + 1, n, Pe);
|
|
607
|
+
s.push({ date: i[1], text: ue(i[2], a.text) }), r = a.next;
|
|
608
|
+
}
|
|
609
|
+
return s;
|
|
610
|
+
}
|
|
611
|
+
function rt(e, t) {
|
|
612
|
+
const n = [e];
|
|
613
|
+
for (const s of t) {
|
|
614
|
+
const r = s.source ? `[${s.source}] ${s.text}` : s.text;
|
|
615
|
+
if (n.push(`- [${s.done ? "x" : " "}] ${r}`), s.description)
|
|
616
|
+
for (const i of s.description.split(`
|
|
617
|
+
`)) n.push(` ${i}`);
|
|
618
|
+
s.run && n.push(` run: ${Wt(s.run)}`);
|
|
619
|
+
}
|
|
620
|
+
return n;
|
|
621
|
+
}
|
|
622
|
+
function fe(e, t) {
|
|
623
|
+
return [e, ...t.map((n) => `- ${n.date}: ${n.text}`)];
|
|
624
|
+
}
|
|
625
|
+
function Dn(e) {
|
|
626
|
+
return e.kind === "phase" ? `[phase:${e.index}]` : "[body]";
|
|
627
|
+
}
|
|
628
|
+
function jn(e, t, n) {
|
|
629
|
+
const s = [];
|
|
630
|
+
let r = t;
|
|
631
|
+
for (; r < n; ) {
|
|
632
|
+
const i = e[r].match(Y), a = i ? i[2].trim().match(xn) : null;
|
|
633
|
+
if (!i || !a) {
|
|
634
|
+
r++;
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
const o = a[1] ? { kind: "phase", index: Number(a[1]) } : { kind: "body" }, c = a[2], u = de(e, r + 1, n, Y);
|
|
638
|
+
s.push({
|
|
639
|
+
anchor: o,
|
|
640
|
+
prose: ue(a[3], u.text),
|
|
641
|
+
state: i[1].toLowerCase() === "x" ? "resolved" : "open",
|
|
642
|
+
...c ? { kind: c } : {}
|
|
643
|
+
}), r = u.next;
|
|
644
|
+
}
|
|
645
|
+
return s;
|
|
646
|
+
}
|
|
647
|
+
function Mn(e) {
|
|
648
|
+
const t = ["### Notes"];
|
|
649
|
+
for (const n of e) {
|
|
650
|
+
const s = n.kind && n.kind !== "note" ? `[${n.kind}] ` : "";
|
|
651
|
+
t.push(
|
|
652
|
+
`- [${n.state === "resolved" ? "x" : " "}] ${Dn(n.anchor)} ${s}${n.prose}`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
return t;
|
|
656
|
+
}
|
|
657
|
+
const Z = {
|
|
658
|
+
headingRe: /^#{2,3}\s+Phases\s*$/i,
|
|
659
|
+
parseEntries: st,
|
|
660
|
+
formatLines: (e) => rt("### Phases", e)
|
|
661
|
+
}, it = {
|
|
662
|
+
headingRe: /^#{2,3}\s+Fixes\s*$/i,
|
|
663
|
+
parseEntries: st,
|
|
664
|
+
formatLines: (e) => rt("### Fixes", e)
|
|
665
|
+
}, H = {
|
|
666
|
+
headingRe: /^#{2,3}\s+Log\s*$/i,
|
|
667
|
+
parseEntries: le,
|
|
668
|
+
formatLines: (e) => fe("### Log", e)
|
|
669
|
+
}, pe = {
|
|
670
|
+
headingRe: /^#{2,3}\s+Clarifications\s*$/i,
|
|
671
|
+
parseEntries: le,
|
|
672
|
+
formatLines: (e) => fe("### Clarifications", e)
|
|
673
|
+
}, he = {
|
|
674
|
+
headingRe: /^#{2,3}\s+Notes\s*$/i,
|
|
675
|
+
parseEntries: jn,
|
|
676
|
+
formatLines: Mn
|
|
677
|
+
}, Ln = {
|
|
678
|
+
headingRe: /^#{2,3}\s+Review\s*$/i,
|
|
679
|
+
parseEntries: le,
|
|
680
|
+
formatLines: (e) => fe("### Review", e)
|
|
681
|
+
};
|
|
682
|
+
function Fn(e, t, n) {
|
|
683
|
+
const s = [];
|
|
684
|
+
let r = t;
|
|
685
|
+
for (; r < n; ) {
|
|
686
|
+
const i = e[r].match(Ce);
|
|
687
|
+
if (!i) {
|
|
688
|
+
r++;
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
const a = i[3], o = de(e, r + 1, n, Ce), c = { kind: a, text: ue(i[6], o.text) };
|
|
692
|
+
i[2] && (c.date = i[2]), i[4] && (c.from = "agent"), i[5] && (c.entityId = i[5]), On.includes(a) && (c.state = i[1].toLowerCase() === "x" ? "resolved" : "open"), s.push(c), r = o.next;
|
|
693
|
+
}
|
|
694
|
+
return s;
|
|
695
|
+
}
|
|
696
|
+
function Hn(e) {
|
|
697
|
+
const t = ["### Thread"];
|
|
698
|
+
for (const n of e) {
|
|
699
|
+
const s = n.state ? n.state === "resolved" : !0, r = n.date ? `${n.date} ` : "", i = n.from === "agent" ? "[agent] " : "", a = n.entityId ? `[[${n.entityId}]] ` : "";
|
|
700
|
+
t.push(`- [${s ? "x" : " "}] ${r}[${n.kind}] ${i}${a}${n.text}`);
|
|
701
|
+
}
|
|
702
|
+
return t;
|
|
703
|
+
}
|
|
704
|
+
const at = {
|
|
705
|
+
headingRe: /^#{2,3}\s+Thread\s*$/i,
|
|
706
|
+
parseEntries: Fn,
|
|
707
|
+
formatLines: Hn
|
|
708
|
+
}, $ = d.preprocess(
|
|
709
|
+
(e) => typeof e == "string" ? { agent: e } : e,
|
|
710
|
+
d.object({
|
|
711
|
+
agent: d.enum(L),
|
|
712
|
+
model: d.string().optional(),
|
|
713
|
+
effort: d.string().optional()
|
|
714
|
+
})
|
|
715
|
+
), I = d.string().regex(/^\d{4}-\d{2}-\d{2}$/, "expected YYYY-MM-DD"), Gn = d.object({
|
|
716
|
+
status: d.enum(["idea", "planned", "in-progress", "review", "done", "dropped"]),
|
|
717
|
+
kind: d.enum(["feat", "fix", "chore", "docs", "refactor"]).optional(),
|
|
718
|
+
id: d.string().optional(),
|
|
719
|
+
idea: d.string().optional(),
|
|
720
|
+
agent: d.enum(L).optional(),
|
|
721
|
+
created: I,
|
|
722
|
+
updated: I.optional(),
|
|
723
|
+
tags: d.string().optional()
|
|
724
|
+
}), Bn = d.object({
|
|
725
|
+
id: d.string().describe("Permanent plan ID, e.g. FEAT-24"),
|
|
726
|
+
title: d.string().describe('Human-readable plan name, e.g. "Plan storage architecture"'),
|
|
727
|
+
kind: d.enum(["feat", "fix", "chore", "docs", "refactor"]).describe("Plan kind matching Conventional Commits types"),
|
|
728
|
+
status: d.enum(["idea", "planned", "in-progress", "review", "done", "dropped"]).describe("Current lifecycle status"),
|
|
729
|
+
idea: d.string().optional().describe("IDEA-N backlink if this plan grew out of an idea"),
|
|
730
|
+
agent: d.enum(L).optional().describe("Per-plan agent override"),
|
|
731
|
+
created: I.describe("Creation date (YYYY-MM-DD)"),
|
|
732
|
+
updated: I.optional().describe("Last significant update date (YYYY-MM-DD)"),
|
|
733
|
+
audited: I.optional().describe("Date of last successful convergence audit (YYYY-MM-DD)"),
|
|
734
|
+
"audited-hash": d.string().optional().describe("Content hash of the plan at last audit, used to detect edits regardless of mtime"),
|
|
735
|
+
tags: d.array(d.string()).optional().describe("Tagging categories")
|
|
736
|
+
}).passthrough(), Yn = d.object({
|
|
737
|
+
id: d.string().describe("Permanent idea ID, e.g. IDEA-20"),
|
|
738
|
+
title: d.string().describe("Short idea headline (3-6 words)"),
|
|
739
|
+
kind: d.enum(["idea", "note"]).optional().describe('"note" for ideas that never need a plan; omitted means a plan-bearing idea'),
|
|
740
|
+
status: d.enum(["open", "done", "dropped"]).optional().describe("Manual lifecycle, valid only on notes — plan-bearing ideas carry no status")
|
|
741
|
+
}).passthrough().refine((e) => e.status === void 0 || e.kind === "note", {
|
|
742
|
+
message: "status is only valid on ideas with kind: note",
|
|
743
|
+
path: ["status"]
|
|
744
|
+
}), ot = d.object({
|
|
745
|
+
id: d.string().describe("Permanent lifetime entity ID, e.g. IDEA-45 — never changes"),
|
|
746
|
+
title: d.string().describe("Human-readable entity name"),
|
|
747
|
+
type: d.enum(["feat", "fix", "chore", "docs", "refactor"]).optional().describe(
|
|
748
|
+
"Work classification (Conventional Commits values) driving commit types and branch prefixes; usually set once a plan is drafted"
|
|
749
|
+
),
|
|
750
|
+
kind: d.enum(["note", "fix", "board", "ticket"]).optional().describe(
|
|
751
|
+
'"note" marks an entity that never grows phases; "fix" is a follow-up entity linked to a done/archived parent via `idea`; "board" decomposes into "ticket" children instead of phases; "ticket" is a full entity linked back to its board via `idea`; omitted for normal ideas'
|
|
752
|
+
),
|
|
753
|
+
status: d.enum(["idea", "planned", "in-progress", "review", "done", "dropped", "open"]).optional().describe(
|
|
754
|
+
"Stored override, no longer the source of truth: most lifecycle states derive from phases/branch/PR. Only dropped, a planless idea/note being closed, or the offline fallback need this set."
|
|
755
|
+
),
|
|
756
|
+
agent: d.enum(L).optional().describe("Per-entity agent override"),
|
|
757
|
+
created: I.describe("Creation date (YYYY-MM-DD)"),
|
|
758
|
+
updated: I.optional().describe("Last significant update date (YYYY-MM-DD)"),
|
|
759
|
+
audited: I.optional().describe("Date of last successful convergence audit (YYYY-MM-DD)"),
|
|
760
|
+
"audited-hash": d.string().optional().describe(
|
|
761
|
+
"Content hash of the entity at last audit, used to detect edits regardless of mtime"
|
|
762
|
+
),
|
|
763
|
+
released: d.string().optional().describe(
|
|
764
|
+
"Version tag (e.g. v0.13.1) that first shipped this idea, stamped from the release train"
|
|
765
|
+
),
|
|
766
|
+
tags: d.array(d.string()).optional().describe("Tagging categories"),
|
|
767
|
+
idea: d.string().optional().describe("IDEA-N backlink to the parent this fix addresses; required when kind: fix"),
|
|
768
|
+
subject: d.string().optional().describe('Subject group name; absent renders as the virtual "No subject" group'),
|
|
769
|
+
order: d.number().int().optional().describe("Run order; absent means unordered, sorting after ordered entries"),
|
|
770
|
+
issueSource: d.string().optional().describe(
|
|
771
|
+
"sourceKind:sourceKey of the Issue (IDEA-192) this entity was promoted from, if any"
|
|
772
|
+
)
|
|
773
|
+
}).passthrough(), qn = new Set(
|
|
774
|
+
Object.keys(ot.shape)
|
|
775
|
+
), ct = ot.refine(
|
|
776
|
+
(e) => e.kind !== "note" || e.status === void 0 || ["open", "done", "dropped"].includes(e.status),
|
|
777
|
+
{
|
|
778
|
+
message: "a note entity must use status open, done, or dropped",
|
|
779
|
+
path: ["status"]
|
|
780
|
+
}
|
|
781
|
+
).refine((e) => e.kind === "note" || e.status !== "open", {
|
|
782
|
+
message: "status open is only valid on entities with kind: note",
|
|
783
|
+
path: ["status"]
|
|
784
|
+
}).refine((e) => e.kind !== "fix" || e.idea !== void 0, {
|
|
785
|
+
message: "a kind: fix entity requires an idea: link to its parent",
|
|
786
|
+
path: ["idea"]
|
|
787
|
+
}).refine((e) => e.kind !== "ticket" || e.idea !== void 0, {
|
|
788
|
+
message: "a kind: ticket entity requires an idea: link to its board",
|
|
789
|
+
path: ["idea"]
|
|
790
|
+
}), Un = d.object({
|
|
791
|
+
name: d.string(),
|
|
792
|
+
cmd: d.string(),
|
|
793
|
+
port: d.number().int().positive().optional(),
|
|
794
|
+
healthcheck: d.string().optional()
|
|
795
|
+
}), Kn = d.object({
|
|
796
|
+
name: d.string(),
|
|
797
|
+
cmd: d.string(),
|
|
798
|
+
fixCmd: d.string().optional()
|
|
799
|
+
}), Wn = d.object({
|
|
800
|
+
repo: d.string(),
|
|
801
|
+
branch: d.string().optional(),
|
|
802
|
+
releasePlease: d.boolean().optional()
|
|
803
|
+
}), Jn = d.object({
|
|
804
|
+
services: d.array(Un).optional(),
|
|
805
|
+
checks: d.array(Kn).optional(),
|
|
806
|
+
ci: Wn.optional()
|
|
807
|
+
}), zn = d.object({
|
|
808
|
+
from: d.string(),
|
|
809
|
+
to: d.string()
|
|
810
|
+
}), Vn = d.object({
|
|
811
|
+
name: d.string(),
|
|
812
|
+
prompt: d.string()
|
|
813
|
+
}), Xn = d.object({
|
|
814
|
+
ceiling: d.number().optional(),
|
|
815
|
+
floor: d.number().optional(),
|
|
816
|
+
window: zn.optional(),
|
|
817
|
+
roots: d.array(d.string()).optional(),
|
|
818
|
+
maxChunks: d.number().int().positive().optional(),
|
|
819
|
+
threshold: d.number().min(0).max(100).optional(),
|
|
820
|
+
checks: d.record(d.enum(Gt), d.boolean()).optional(),
|
|
821
|
+
customChecks: d.array(Vn).optional(),
|
|
822
|
+
maxTurns: d.number().int().positive().optional(),
|
|
823
|
+
maxCostUsd: d.number().positive().optional()
|
|
824
|
+
}), Zn = d.object({
|
|
825
|
+
kinds: d.record(d.enum(Bt), d.boolean()).optional()
|
|
826
|
+
}), Qn = d.object({
|
|
827
|
+
endpoint: d.string(),
|
|
828
|
+
keys: d.object({ p256dh: d.string(), auth: d.string() })
|
|
829
|
+
}), Ni = d.discriminatedUnion("transport", [
|
|
830
|
+
d.object({
|
|
831
|
+
transport: d.literal("webpush"),
|
|
832
|
+
name: d.string(),
|
|
833
|
+
subscription: Qn
|
|
834
|
+
}),
|
|
835
|
+
d.object({ transport: d.literal("expo"), name: d.string(), token: d.string() })
|
|
836
|
+
]), xi = d.discriminatedUnion("transport", [
|
|
837
|
+
d.object({ transport: d.literal("webpush"), endpoint: d.string() }),
|
|
838
|
+
d.object({ transport: d.literal("expo"), token: d.string() })
|
|
839
|
+
]), es = d.object({
|
|
840
|
+
version: d.number().int().describe("Corpus format version (see CORPUS_FORMAT_VERSION), not the package version"),
|
|
841
|
+
projectName: d.string(),
|
|
842
|
+
initializedAt: d.string(),
|
|
843
|
+
nextId: d.object({
|
|
844
|
+
// idea: unified-entity counter minting lifetime IDEA-N ids. ticket: board/ticket
|
|
845
|
+
// counter (IDEA-201) minting TICKET-N ids. The rest are legacy per-kind counters.
|
|
846
|
+
idea: d.number().optional(),
|
|
847
|
+
ticket: d.number().optional(),
|
|
848
|
+
feat: d.number().optional(),
|
|
849
|
+
fix: d.number().optional(),
|
|
850
|
+
chore: d.number().optional(),
|
|
851
|
+
docs: d.number().optional(),
|
|
852
|
+
refactor: d.number().optional()
|
|
853
|
+
}).optional(),
|
|
854
|
+
defaultAgent: d.enum(L).optional(),
|
|
855
|
+
defaultAgents: d.object({
|
|
856
|
+
phase: $,
|
|
857
|
+
planDraft: $,
|
|
858
|
+
ideaExtend: $,
|
|
859
|
+
commitSuggest: $,
|
|
860
|
+
feedback: $,
|
|
861
|
+
codeReview: $,
|
|
862
|
+
deskDiscovery: $,
|
|
863
|
+
nightShift: $
|
|
864
|
+
}).optional(),
|
|
865
|
+
desk: Jn.optional(),
|
|
866
|
+
night: Xn.optional(),
|
|
867
|
+
notifications: Zn.optional()
|
|
868
|
+
}), ts = d.object({
|
|
869
|
+
id: d.string(),
|
|
870
|
+
kind: d.enum([
|
|
871
|
+
"completed",
|
|
872
|
+
"reply",
|
|
873
|
+
"check-failed",
|
|
874
|
+
"pr-review-changes-requested",
|
|
875
|
+
"night-review-findings",
|
|
876
|
+
"service-stopped"
|
|
877
|
+
]),
|
|
878
|
+
entityId: d.string(),
|
|
879
|
+
entityTitle: d.string(),
|
|
880
|
+
text: d.string(),
|
|
881
|
+
date: d.string(),
|
|
882
|
+
read: d.boolean(),
|
|
883
|
+
outcome: d.enum(["done", "error"]).optional(),
|
|
884
|
+
push: d.boolean().optional().default(!0)
|
|
885
|
+
}), _e = /^##\s+(.+?)\s*$/, ns = /^\*\*([A-Za-z][A-Za-z-]*):\*\*\s*(.*)$/, ss = /^#{2,3}\s+/;
|
|
886
|
+
function q(e, t) {
|
|
887
|
+
const n = e.split(`
|
|
888
|
+
`), s = n.findIndex((o) => t.headingRe.test(o));
|
|
889
|
+
if (s === -1) return { body: e, entries: [] };
|
|
890
|
+
let r = n.length;
|
|
891
|
+
for (let o = s + 1; o < n.length; o++)
|
|
892
|
+
if (ss.test(n[o])) {
|
|
893
|
+
r = o;
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
896
|
+
const i = t.parseEntries(n, s + 1, r);
|
|
897
|
+
return { body: [...n.slice(0, s), ...n.slice(r)].join(`
|
|
898
|
+
`).trim(), entries: i };
|
|
899
|
+
}
|
|
900
|
+
const Te = {
|
|
901
|
+
phases: Z,
|
|
902
|
+
log: H,
|
|
903
|
+
clarifications: pe,
|
|
904
|
+
notes: he,
|
|
905
|
+
review: Ln
|
|
906
|
+
};
|
|
907
|
+
function me(e) {
|
|
908
|
+
const t = {
|
|
909
|
+
phases: [],
|
|
910
|
+
log: [],
|
|
911
|
+
clarifications: [],
|
|
912
|
+
notes: [],
|
|
913
|
+
review: []
|
|
914
|
+
};
|
|
915
|
+
let n = e;
|
|
916
|
+
for (const s of Object.keys(Te)) {
|
|
917
|
+
const r = q(n, Te[s]);
|
|
918
|
+
n = r.body, t[s] = r.entries;
|
|
919
|
+
}
|
|
920
|
+
return { body: n, ...t };
|
|
921
|
+
}
|
|
922
|
+
function rs(e) {
|
|
923
|
+
const t = e.split(`
|
|
924
|
+
`), n = [];
|
|
925
|
+
for (let r = 0; r < t.length; r++)
|
|
926
|
+
_e.test(t[r]) && n.push(r);
|
|
927
|
+
const s = [];
|
|
928
|
+
for (let r = 0; r < n.length; r++) {
|
|
929
|
+
const i = n[r], a = r + 1 < n.length ? n[r + 1] : t.length, o = t[i].match(_e)[1], c = t.slice(i + 1, a);
|
|
930
|
+
let u = 0;
|
|
931
|
+
for (; u < c.length && c[u].trim() === ""; ) u++;
|
|
932
|
+
const l = {};
|
|
933
|
+
for (; u < c.length; ) {
|
|
934
|
+
const G = c[u].match(ns);
|
|
935
|
+
if (!G) break;
|
|
936
|
+
l[G[1].toLowerCase()] = G[2].trim(), u++;
|
|
937
|
+
}
|
|
938
|
+
for (; u < c.length && c[u].trim() === ""; ) u++;
|
|
939
|
+
const f = c.slice(u).join(`
|
|
940
|
+
`).trim(), { body: h, phases: g, log: w, clarifications: y, notes: m, review: D } = me(f);
|
|
941
|
+
s.push({ title: o, fields: l, body: h, phases: g, log: w, clarifications: y, notes: m, review: D });
|
|
942
|
+
}
|
|
943
|
+
return s;
|
|
944
|
+
}
|
|
945
|
+
function Oi(e) {
|
|
946
|
+
const t = [], n = [];
|
|
947
|
+
for (const s of rs(e)) {
|
|
948
|
+
const r = Gn.safeParse(s.fields);
|
|
949
|
+
if (!r.success) {
|
|
950
|
+
n.push({
|
|
951
|
+
title: s.title,
|
|
952
|
+
message: r.error.issues.map((a) => a.message).join("; ")
|
|
953
|
+
});
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
const i = r.data;
|
|
957
|
+
t.push({
|
|
958
|
+
title: s.title,
|
|
959
|
+
status: i.status,
|
|
960
|
+
kind: i.kind,
|
|
961
|
+
id: i.id,
|
|
962
|
+
idea: i.idea,
|
|
963
|
+
agent: i.agent,
|
|
964
|
+
created: i.created,
|
|
965
|
+
updated: i.updated,
|
|
966
|
+
tags: i.tags ? i.tags.split(",").map((a) => a.trim()).filter(Boolean) : [],
|
|
967
|
+
body: s.body,
|
|
968
|
+
phases: s.phases,
|
|
969
|
+
log: s.log,
|
|
970
|
+
clarifications: s.clarifications,
|
|
971
|
+
notes: s.notes,
|
|
972
|
+
review: s.review
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
return { entries: t, warnings: n };
|
|
976
|
+
}
|
|
977
|
+
const is = /^---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n)?/;
|
|
978
|
+
function ge(e, t) {
|
|
979
|
+
const n = [], s = e.match(is);
|
|
980
|
+
if (!s)
|
|
981
|
+
return { data: null, body: e.trim(), warnings: n };
|
|
982
|
+
const r = s[1], i = e.slice(s[0].length).trim();
|
|
983
|
+
let a;
|
|
984
|
+
try {
|
|
985
|
+
a = V(r);
|
|
986
|
+
} catch (c) {
|
|
987
|
+
return n.push({
|
|
988
|
+
title: "(frontmatter)",
|
|
989
|
+
message: `Invalid YAML frontmatter: ${c.message}`
|
|
990
|
+
}), { data: null, body: i, warnings: n };
|
|
991
|
+
}
|
|
992
|
+
if (typeof a != "object" || a === null || Array.isArray(a))
|
|
993
|
+
return n.push({
|
|
994
|
+
title: "(frontmatter)",
|
|
995
|
+
message: "YAML frontmatter did not produce an object"
|
|
996
|
+
}), { data: null, body: i, warnings: n };
|
|
997
|
+
const o = t.safeParse(a);
|
|
998
|
+
if (!o.success) {
|
|
999
|
+
const c = a.id;
|
|
1000
|
+
return n.push({
|
|
1001
|
+
title: c ?? "(frontmatter)",
|
|
1002
|
+
message: o.error.issues.map((u) => u.message).join("; ")
|
|
1003
|
+
}), { data: null, body: i, warnings: n };
|
|
1004
|
+
}
|
|
1005
|
+
return { data: o.data, body: i, warnings: n };
|
|
1006
|
+
}
|
|
1007
|
+
function as(e, t) {
|
|
1008
|
+
const n = Object.fromEntries(
|
|
1009
|
+
Object.entries(e).filter(([s]) => !t.has(s))
|
|
1010
|
+
);
|
|
1011
|
+
return Object.keys(n).length > 0 ? n : void 0;
|
|
1012
|
+
}
|
|
1013
|
+
function dt(e) {
|
|
1014
|
+
const t = [], {
|
|
1015
|
+
data: n,
|
|
1016
|
+
body: s,
|
|
1017
|
+
warnings: r
|
|
1018
|
+
} = ge(e, ct);
|
|
1019
|
+
if (t.push(...r), !n)
|
|
1020
|
+
return { entries: [], warnings: t };
|
|
1021
|
+
const {
|
|
1022
|
+
body: i,
|
|
1023
|
+
phases: a,
|
|
1024
|
+
log: o,
|
|
1025
|
+
clarifications: c,
|
|
1026
|
+
notes: u,
|
|
1027
|
+
review: l
|
|
1028
|
+
} = me(s), { body: f, entries: h } = q(i, it), { body: g, entries: w } = q(f, at), y = [...w, ...nn(o, c, u, l)];
|
|
1029
|
+
n.kind === "note" && a.length > 0 && t.push({
|
|
1030
|
+
title: n.title,
|
|
1031
|
+
message: "note entities must not carry a Phases section — kept, but fix the file"
|
|
1032
|
+
});
|
|
1033
|
+
const m = as(n, qn);
|
|
1034
|
+
return { entries: [{
|
|
1035
|
+
id: n.id,
|
|
1036
|
+
title: n.title,
|
|
1037
|
+
type: n.type,
|
|
1038
|
+
kind: n.kind,
|
|
1039
|
+
status: n.status,
|
|
1040
|
+
idea: n.idea,
|
|
1041
|
+
agent: n.agent,
|
|
1042
|
+
created: n.created,
|
|
1043
|
+
updated: n.updated,
|
|
1044
|
+
audited: n.audited,
|
|
1045
|
+
auditedHash: n["audited-hash"],
|
|
1046
|
+
released: n.released,
|
|
1047
|
+
tags: n.tags ?? [],
|
|
1048
|
+
subject: n.subject,
|
|
1049
|
+
order: n.order,
|
|
1050
|
+
issueSource: n.issueSource,
|
|
1051
|
+
body: g,
|
|
1052
|
+
phases: a,
|
|
1053
|
+
...h.length > 0 && { fixes: h },
|
|
1054
|
+
...y.length > 0 && { thread: y },
|
|
1055
|
+
...m && { unknownFrontmatter: m }
|
|
1056
|
+
}], warnings: t };
|
|
1057
|
+
}
|
|
1058
|
+
function Di(e) {
|
|
1059
|
+
const t = [], {
|
|
1060
|
+
data: n,
|
|
1061
|
+
body: s,
|
|
1062
|
+
warnings: r
|
|
1063
|
+
} = ge(e, Bn);
|
|
1064
|
+
if (t.push(...r), !n)
|
|
1065
|
+
return { entries: [], warnings: t };
|
|
1066
|
+
const { body: i, phases: a, log: o, clarifications: c, notes: u, review: l } = me(s);
|
|
1067
|
+
return { entries: [{
|
|
1068
|
+
title: n.title,
|
|
1069
|
+
status: n.status,
|
|
1070
|
+
kind: n.kind,
|
|
1071
|
+
id: n.id,
|
|
1072
|
+
idea: n.idea,
|
|
1073
|
+
agent: n.agent,
|
|
1074
|
+
created: n.created,
|
|
1075
|
+
updated: n.updated,
|
|
1076
|
+
audited: n.audited,
|
|
1077
|
+
auditedHash: n["audited-hash"],
|
|
1078
|
+
tags: n.tags ?? [],
|
|
1079
|
+
body: i,
|
|
1080
|
+
phases: a,
|
|
1081
|
+
log: o,
|
|
1082
|
+
clarifications: c,
|
|
1083
|
+
notes: u,
|
|
1084
|
+
review: l
|
|
1085
|
+
}], warnings: t };
|
|
1086
|
+
}
|
|
1087
|
+
function ji(e) {
|
|
1088
|
+
const {
|
|
1089
|
+
data: t,
|
|
1090
|
+
body: n,
|
|
1091
|
+
warnings: s
|
|
1092
|
+
} = ge(e, Yn);
|
|
1093
|
+
if (!t)
|
|
1094
|
+
return { entries: [], warnings: s };
|
|
1095
|
+
const { body: r, entries: i } = q(n, H);
|
|
1096
|
+
return { entries: [{
|
|
1097
|
+
id: t.id,
|
|
1098
|
+
title: t.title,
|
|
1099
|
+
body: r || "",
|
|
1100
|
+
...t.kind && { kind: t.kind },
|
|
1101
|
+
...t.status && { status: t.status },
|
|
1102
|
+
...i.length > 0 && { log: i }
|
|
1103
|
+
}], warnings: s };
|
|
1104
|
+
}
|
|
1105
|
+
const os = /^(IDEA-\d+):\s*/, cs = /\n---+\n/;
|
|
1106
|
+
function Mi(e) {
|
|
1107
|
+
return e.split(cs).filter(Boolean).map((n) => {
|
|
1108
|
+
var c;
|
|
1109
|
+
const s = n.match(/^#{1,3}\s+(.+)/m), r = s ? s[1].trim() : ((c = n.trim().split(`
|
|
1110
|
+
`)[0]) == null ? void 0 : c.trim()) ?? "Untitled", i = r.match(os), a = (i == null ? void 0 : i[1]) ?? null, o = a ? r.slice(i[0].length) : r;
|
|
1111
|
+
return { id: a, title: o, body: n.trim() };
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
const Ne = 40;
|
|
1115
|
+
function ds(e, t = []) {
|
|
1116
|
+
const n = [];
|
|
1117
|
+
for (const s of e)
|
|
1118
|
+
if (!s.archived && (t.length > 0 && s.subject && !t.includes(s.subject) && n.push({
|
|
1119
|
+
kind: "orphan-subject",
|
|
1120
|
+
section: "plans",
|
|
1121
|
+
title: s.title,
|
|
1122
|
+
planId: s.id,
|
|
1123
|
+
message: `Subject "${s.subject}" isn't in the roadmap vocabulary — "${s.title}"`
|
|
1124
|
+
}), s.status !== "done" && s.status !== "dropped")) {
|
|
1125
|
+
const r = [];
|
|
1126
|
+
s.title.length > Ne && r.push(`${s.title.length} chars over the ${Ne}-char limit`), s.title.includes("—") && r.push("em-dash subtitle"), r.length > 0 && n.push({
|
|
1127
|
+
kind: "title-style",
|
|
1128
|
+
section: "plans",
|
|
1129
|
+
title: s.title,
|
|
1130
|
+
planId: s.id,
|
|
1131
|
+
message: `Title style — ${r.join(", ")}; the detail belongs in the body: "${s.title}"`
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
return n;
|
|
1135
|
+
}
|
|
1136
|
+
function us(e) {
|
|
1137
|
+
const t = /* @__PURE__ */ new Map(), n = [];
|
|
1138
|
+
for (const s of e.split(`
|
|
1139
|
+
`)) {
|
|
1140
|
+
const r = s.trim();
|
|
1141
|
+
if (!r) continue;
|
|
1142
|
+
let i;
|
|
1143
|
+
try {
|
|
1144
|
+
i = JSON.parse(r);
|
|
1145
|
+
} catch {
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1148
|
+
const a = t.get(i.id);
|
|
1149
|
+
a ? t.set(i.id, { ...a, ...i }) : (t.set(i.id, i), n.push(i.id));
|
|
1150
|
+
}
|
|
1151
|
+
return n.map((s) => t.get(s));
|
|
1152
|
+
}
|
|
1153
|
+
function Li(e) {
|
|
1154
|
+
const t = [];
|
|
1155
|
+
for (const n of e.split(`
|
|
1156
|
+
`)) {
|
|
1157
|
+
const s = n.trim();
|
|
1158
|
+
if (s)
|
|
1159
|
+
try {
|
|
1160
|
+
const r = ts.safeParse(JSON.parse(s));
|
|
1161
|
+
r.success && t.push(r.data);
|
|
1162
|
+
} catch {
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
return t;
|
|
1166
|
+
}
|
|
1167
|
+
const ut = /^-\s+(\d{4}-\d{2}-\d{2}):\s+(.+?)\s+—\s+(.*)$/;
|
|
1168
|
+
function Fi(e) {
|
|
1169
|
+
const t = [];
|
|
1170
|
+
for (const n of e.split(`
|
|
1171
|
+
`)) {
|
|
1172
|
+
const s = n.match(ut);
|
|
1173
|
+
s && t.push({ date: s[1], title: s[2].trim(), description: s[3].trim() });
|
|
1174
|
+
}
|
|
1175
|
+
return t;
|
|
1176
|
+
}
|
|
1177
|
+
const se = " — ";
|
|
1178
|
+
function ls(e) {
|
|
1179
|
+
return e.split(`
|
|
1180
|
+
`).map((t) => t.trim()).filter((t) => t.length > 0).map((t) => {
|
|
1181
|
+
const n = t.indexOf(se);
|
|
1182
|
+
return n === -1 ? { id: t, title: "" } : {
|
|
1183
|
+
id: t.slice(0, n).trim(),
|
|
1184
|
+
title: t.slice(n + se.length).trim()
|
|
1185
|
+
};
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
function Hi(e) {
|
|
1189
|
+
return e.length === 0 ? "" : `${e.map((t) => `${t.id}${se}${t.title}`).join(`
|
|
1190
|
+
`)}
|
|
1191
|
+
`;
|
|
1192
|
+
}
|
|
1193
|
+
async function fs(e) {
|
|
1194
|
+
try {
|
|
1195
|
+
return await z(e);
|
|
1196
|
+
} catch {
|
|
1197
|
+
return [];
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
async function lt(e) {
|
|
1201
|
+
try {
|
|
1202
|
+
return await v(e, "utf-8");
|
|
1203
|
+
} catch {
|
|
1204
|
+
return "";
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
async function ps(e) {
|
|
1208
|
+
const t = await lt(p(e, "..", "run-order.md"));
|
|
1209
|
+
return new Map(ls(t).map((n, s) => [n.id, s + 1]));
|
|
1210
|
+
}
|
|
1211
|
+
async function x(e) {
|
|
1212
|
+
const t = [], n = [];
|
|
1213
|
+
let s = 0;
|
|
1214
|
+
const r = await ps(e);
|
|
1215
|
+
for (const i of [e, p(e, "archive")]) {
|
|
1216
|
+
const a = i !== e, o = (await fs(i)).filter((u) => u.endsWith(".md") && u !== "index.md");
|
|
1217
|
+
s += o.length;
|
|
1218
|
+
const c = await Promise.all(
|
|
1219
|
+
o.map(async (u) => {
|
|
1220
|
+
const l = await lt(p(i, u));
|
|
1221
|
+
return l ? dt(l) : { warnings: [{ title: u, message: "Could not read entity file" }] };
|
|
1222
|
+
})
|
|
1223
|
+
);
|
|
1224
|
+
for (const u of c)
|
|
1225
|
+
"entries" in u && t.push(
|
|
1226
|
+
...u.entries.map((l) => ({
|
|
1227
|
+
...l,
|
|
1228
|
+
archived: a,
|
|
1229
|
+
storedOrder: l.order,
|
|
1230
|
+
order: r.get(l.id) ?? l.order
|
|
1231
|
+
}))
|
|
1232
|
+
), n.push(...u.warnings);
|
|
1233
|
+
}
|
|
1234
|
+
return { entries: t, warnings: n, fileCount: s };
|
|
1235
|
+
}
|
|
1236
|
+
async function ye(e, t) {
|
|
1237
|
+
const { entries: n, warnings: s } = await x(e), r = p(e, "..", ".."), [i, a] = await Promise.all([
|
|
1238
|
+
tt(r, t),
|
|
1239
|
+
Ke(r)
|
|
1240
|
+
]);
|
|
1241
|
+
return { entries: n, warnings: s, prs: i, resolved: i !== void 0, mainActivityIds: a };
|
|
1242
|
+
}
|
|
1243
|
+
async function Gi(e) {
|
|
1244
|
+
const { entries: t, warnings: n, prs: s, resolved: r, mainActivityIds: i } = await ye(e), a = t.map((c) => ({
|
|
1245
|
+
...c,
|
|
1246
|
+
status: X(c, s == null ? void 0 : s.get(c.id), r, i.has(c.id))
|
|
1247
|
+
}));
|
|
1248
|
+
return { entries: a.map((c) => {
|
|
1249
|
+
if (c.kind !== "board" || c.archived || c.status === "done" || c.status === "dropped") return c;
|
|
1250
|
+
const u = a.filter((l) => l.kind === "ticket" && l.idea === c.id).map((l) => l.status ?? "idea");
|
|
1251
|
+
return { ...c, status: Be(u) };
|
|
1252
|
+
}), warnings: n };
|
|
1253
|
+
}
|
|
1254
|
+
async function Bi(e, t) {
|
|
1255
|
+
const { entries: n, warnings: s, prs: r, resolved: i, mainActivityIds: a } = await ye(
|
|
1256
|
+
e,
|
|
1257
|
+
t
|
|
1258
|
+
), o = n.filter((u) => u.kind !== "note").map((u) => qe(u, r == null ? void 0 : r.get(u.id), i, a.has(u.id)));
|
|
1259
|
+
return { entries: o.map((u) => {
|
|
1260
|
+
if (u.entityKind !== "board" || u.archived || u.status === "done" || u.status === "dropped")
|
|
1261
|
+
return u;
|
|
1262
|
+
const l = o.filter((f) => f.entityKind === "ticket" && f.idea === u.id).map((f) => f.status);
|
|
1263
|
+
return { ...u, status: Be(l) };
|
|
1264
|
+
}), warnings: s, resolved: i };
|
|
1265
|
+
}
|
|
1266
|
+
async function Yi(e) {
|
|
1267
|
+
const { entries: t, prs: n, resolved: s } = await ye(e);
|
|
1268
|
+
return {
|
|
1269
|
+
entries: t.flatMap((r) => {
|
|
1270
|
+
const i = n == null ? void 0 : n.get(r.id);
|
|
1271
|
+
return i && tn(r, i) ? [{ id: r.id, title: r.title, pr: i }] : [];
|
|
1272
|
+
}),
|
|
1273
|
+
resolved: s
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
async function qi(e) {
|
|
1277
|
+
const { entries: t, warnings: n } = await x(e);
|
|
1278
|
+
return {
|
|
1279
|
+
entries: t.filter((s) => s.kind === "note").map(on),
|
|
1280
|
+
warnings: n
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
const hs = [
|
|
1284
|
+
{
|
|
1285
|
+
id: "frontmatter-schema",
|
|
1286
|
+
category: "metadata",
|
|
1287
|
+
severity: "error",
|
|
1288
|
+
summary: "Frontmatter fails entityFrontmatterSchema — missing required field, bad enum, malformed date, or a violated note/status refinement."
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
id: "filename-id-mismatch",
|
|
1292
|
+
category: "metadata",
|
|
1293
|
+
severity: "error",
|
|
1294
|
+
summary: "Frontmatter id does not match the file name (IDEA-N.md); references break silently."
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
id: "duplicate-id",
|
|
1298
|
+
category: "metadata",
|
|
1299
|
+
severity: "error",
|
|
1300
|
+
summary: "Two entity files share one id; whichever loads last wins and the other disappears."
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
id: "id-counter-stale",
|
|
1304
|
+
category: "metadata",
|
|
1305
|
+
severity: "error",
|
|
1306
|
+
summary: "An entity id is greater than or equal to config.nextId.idea, so the next mint collides with an existing file."
|
|
1307
|
+
},
|
|
1308
|
+
{
|
|
1309
|
+
id: "corpus-format-too-new",
|
|
1310
|
+
category: "metadata",
|
|
1311
|
+
severity: "error",
|
|
1312
|
+
summary: "config.version is newer than the format this paper-camp understands; reads stay tolerant but writes are refused until it upgrades."
|
|
1313
|
+
},
|
|
1314
|
+
{
|
|
1315
|
+
id: "phases-list-split",
|
|
1316
|
+
category: "structural",
|
|
1317
|
+
severity: "error",
|
|
1318
|
+
summary: "A checkbox line lives outside the Phases section — a mid-file heading split the list and orphaned phases, so the entity parses as fewer phases than it has."
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
id: "note-has-phases",
|
|
1322
|
+
category: "structural",
|
|
1323
|
+
severity: "error",
|
|
1324
|
+
summary: "A kind: note entity carries a Phases section; notes never grow phases."
|
|
1325
|
+
},
|
|
1326
|
+
{
|
|
1327
|
+
id: "duplicate-phases-section",
|
|
1328
|
+
category: "structural",
|
|
1329
|
+
severity: "error",
|
|
1330
|
+
summary: "A file carries more than one Phases heading — a redraft appended instead of replacing the existing list in place."
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
id: "archive-placement",
|
|
1334
|
+
category: "structural",
|
|
1335
|
+
severity: "warning",
|
|
1336
|
+
summary: "File location contradicts status — a done/dropped entity still under ideas/, or an active entity already under ideas/archive/."
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
id: "dangling-link",
|
|
1340
|
+
category: "structural",
|
|
1341
|
+
severity: "warning",
|
|
1342
|
+
summary: "A [[IDEA-N]] wikilink targets an id that no entity in the corpus defines."
|
|
1343
|
+
},
|
|
1344
|
+
{
|
|
1345
|
+
id: "missing-permissions-allow",
|
|
1346
|
+
category: "tooling",
|
|
1347
|
+
severity: "warning",
|
|
1348
|
+
summary: ".claude/settings.json has no permissions.allow list, so a headless run denies every edit and shell command outside the defaults — run `paper-camp init --settings` to add it."
|
|
1349
|
+
}
|
|
1350
|
+
], ms = Object.fromEntries(
|
|
1351
|
+
hs.map((e) => [e.id, e])
|
|
1352
|
+
);
|
|
1353
|
+
function U(e) {
|
|
1354
|
+
return ms[e.rule].severity;
|
|
1355
|
+
}
|
|
1356
|
+
const xe = { error: 0, warning: 1 };
|
|
1357
|
+
function ft(e) {
|
|
1358
|
+
return [...e].sort(
|
|
1359
|
+
(t, n) => t.file.localeCompare(n.file) || t.line - n.line || xe[U(t)] - xe[U(n)] || t.rule.localeCompare(n.rule)
|
|
1360
|
+
);
|
|
1361
|
+
}
|
|
1362
|
+
function Ui(e) {
|
|
1363
|
+
const t = ft(e).map((n) => ({
|
|
1364
|
+
...n,
|
|
1365
|
+
severity: U(n)
|
|
1366
|
+
}));
|
|
1367
|
+
return {
|
|
1368
|
+
findings: t,
|
|
1369
|
+
errorCount: t.filter((n) => n.severity === "error").length,
|
|
1370
|
+
warningCount: t.filter((n) => n.severity === "warning").length
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
function Ki(e) {
|
|
1374
|
+
const t = ft(e);
|
|
1375
|
+
let n = 0, s = 0;
|
|
1376
|
+
const r = t.map((a) => {
|
|
1377
|
+
const o = U(a);
|
|
1378
|
+
return o === "error" ? n++ : s++, `${a.file}:${a.line} ${o.padEnd(7)} ${a.rule} ${a.message}`;
|
|
1379
|
+
}), i = t.length === 0 ? "paper-camp doctor: no issues found." : `paper-camp doctor: ${n} error(s), ${s} warning(s).`;
|
|
1380
|
+
return {
|
|
1381
|
+
text: [...r, ...r.length > 0 ? [""] : [], i].join(`
|
|
1382
|
+
`),
|
|
1383
|
+
errorCount: n,
|
|
1384
|
+
warningCount: s
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
const R = 1;
|
|
1388
|
+
class gs extends Error {
|
|
1389
|
+
constructor(t) {
|
|
1390
|
+
super(
|
|
1391
|
+
`This corpus is in format version ${t}, newer than the format version ${R} this paper-camp understands. Writes are refused so a field this version doesn’t recognise is never dropped — upgrade paper-camp to edit this corpus.`
|
|
1392
|
+
), this.name = "CorpusTooNewError";
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
async function pt(e) {
|
|
1396
|
+
let t;
|
|
1397
|
+
try {
|
|
1398
|
+
t = await v(e, "utf-8");
|
|
1399
|
+
} catch {
|
|
1400
|
+
return null;
|
|
1401
|
+
}
|
|
1402
|
+
try {
|
|
1403
|
+
const n = JSON.parse(t);
|
|
1404
|
+
return n && typeof n == "object" && !Array.isArray(n) ? n : null;
|
|
1405
|
+
} catch {
|
|
1406
|
+
return null;
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
function ht(e) {
|
|
1410
|
+
const t = e == null ? void 0 : e.version;
|
|
1411
|
+
return typeof t == "number" ? t : null;
|
|
1412
|
+
}
|
|
1413
|
+
async function Wi(e) {
|
|
1414
|
+
const t = ht(await pt(e));
|
|
1415
|
+
if (t !== null && t > R)
|
|
1416
|
+
throw new gs(t);
|
|
1417
|
+
}
|
|
1418
|
+
async function Ji(e) {
|
|
1419
|
+
const t = await pt(e);
|
|
1420
|
+
if (!t) return null;
|
|
1421
|
+
const n = ht(t);
|
|
1422
|
+
return n !== null && n >= R ? null : (t.version = R, await E(e, `${JSON.stringify(t, null, 2)}
|
|
1423
|
+
`, "utf-8"), { from: n, to: R });
|
|
1424
|
+
}
|
|
1425
|
+
const mt = /^---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n)?/, ys = 2;
|
|
1426
|
+
function we(e) {
|
|
1427
|
+
const t = e.content.match(mt);
|
|
1428
|
+
if (!t) return null;
|
|
1429
|
+
let n = null;
|
|
1430
|
+
try {
|
|
1431
|
+
const s = V(t[1]);
|
|
1432
|
+
s && typeof s == "object" && !Array.isArray(s) && (n = s);
|
|
1433
|
+
} catch {
|
|
1434
|
+
}
|
|
1435
|
+
return { yaml: t[1], data: n };
|
|
1436
|
+
}
|
|
1437
|
+
function gt(e, t) {
|
|
1438
|
+
const n = new RegExp(`^\\s*${t}:`), s = e.split(`
|
|
1439
|
+
`).findIndex((r) => n.test(r));
|
|
1440
|
+
return s === -1 ? 1 : ys + s;
|
|
1441
|
+
}
|
|
1442
|
+
function be(e) {
|
|
1443
|
+
const t = we(e);
|
|
1444
|
+
return t ? gt(t.yaml, "id") : 1;
|
|
1445
|
+
}
|
|
1446
|
+
function yt(e) {
|
|
1447
|
+
var n, s;
|
|
1448
|
+
const t = (s = (n = we(e)) == null ? void 0 : n.data) == null ? void 0 : s.id;
|
|
1449
|
+
return typeof t == "string" ? t : e.id;
|
|
1450
|
+
}
|
|
1451
|
+
function A(e, t, n, s) {
|
|
1452
|
+
return { file: e.path, line: t, rule: n, message: s };
|
|
1453
|
+
}
|
|
1454
|
+
const ws = ({ files: e }) => e.flatMap((t) => {
|
|
1455
|
+
const n = t.content.match(mt);
|
|
1456
|
+
if (!n)
|
|
1457
|
+
return [A(t, 1, "frontmatter-schema", "missing YAML frontmatter block")];
|
|
1458
|
+
let s;
|
|
1459
|
+
try {
|
|
1460
|
+
s = V(n[1]);
|
|
1461
|
+
} catch (i) {
|
|
1462
|
+
return [A(t, 1, "frontmatter-schema", `invalid YAML: ${i.message}`)];
|
|
1463
|
+
}
|
|
1464
|
+
if (typeof s != "object" || s === null || Array.isArray(s))
|
|
1465
|
+
return [A(t, 1, "frontmatter-schema", "frontmatter is not a key/value mapping")];
|
|
1466
|
+
const r = ct.safeParse(s);
|
|
1467
|
+
return r.success ? [] : r.error.issues.map((i) => {
|
|
1468
|
+
const a = String(i.path[0] ?? ""), o = i.path.length > 0 ? `${i.path.join(".")}: ${i.message}` : i.message;
|
|
1469
|
+
return A(t, a ? gt(n[1], a) : 1, "frontmatter-schema", o);
|
|
1470
|
+
});
|
|
1471
|
+
}), bs = ({ files: e }) => e.flatMap((t) => {
|
|
1472
|
+
var s, r;
|
|
1473
|
+
const n = (r = (s = we(t)) == null ? void 0 : s.data) == null ? void 0 : r.id;
|
|
1474
|
+
return typeof n != "string" || n === t.id ? [] : [
|
|
1475
|
+
A(
|
|
1476
|
+
t,
|
|
1477
|
+
be(t),
|
|
1478
|
+
"filename-id-mismatch",
|
|
1479
|
+
`frontmatter id "${n}" does not match file name ${t.id}.md`
|
|
1480
|
+
)
|
|
1481
|
+
];
|
|
1482
|
+
}), vs = ({ files: e }) => {
|
|
1483
|
+
const t = /* @__PURE__ */ new Map();
|
|
1484
|
+
for (const s of e) {
|
|
1485
|
+
const r = yt(s), i = t.get(r);
|
|
1486
|
+
i ? i.push(s) : t.set(r, [s]);
|
|
1487
|
+
}
|
|
1488
|
+
const n = [];
|
|
1489
|
+
for (const [s, r] of t) {
|
|
1490
|
+
if (r.length < 2) continue;
|
|
1491
|
+
const i = r.map((a) => a.path).join(", ");
|
|
1492
|
+
for (const a of r)
|
|
1493
|
+
n.push(
|
|
1494
|
+
A(
|
|
1495
|
+
a,
|
|
1496
|
+
be(a),
|
|
1497
|
+
"duplicate-id",
|
|
1498
|
+
`id ${s} is defined by ${r.length} files: ${i}`
|
|
1499
|
+
)
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
return n;
|
|
1503
|
+
}, Es = ({ files: e, config: t }) => {
|
|
1504
|
+
var s;
|
|
1505
|
+
const n = (s = t == null ? void 0 : t.nextId) == null ? void 0 : s.idea;
|
|
1506
|
+
return n == null ? [] : e.flatMap((r) => {
|
|
1507
|
+
const i = yt(r), a = i.match(/^IDEA-(\d+)$/);
|
|
1508
|
+
return a ? Number(a[1]) < n ? [] : [
|
|
1509
|
+
A(
|
|
1510
|
+
r,
|
|
1511
|
+
be(r),
|
|
1512
|
+
"id-counter-stale",
|
|
1513
|
+
`id ${i} is >= config nextId.idea (${n}); the next minted id would collide`
|
|
1514
|
+
)
|
|
1515
|
+
] : [];
|
|
1516
|
+
});
|
|
1517
|
+
}, ks = ({ config: e }) => {
|
|
1518
|
+
const t = e == null ? void 0 : e.version;
|
|
1519
|
+
return typeof t != "number" || t <= R ? [] : [
|
|
1520
|
+
{
|
|
1521
|
+
file: "papercamp/config.json",
|
|
1522
|
+
line: 1,
|
|
1523
|
+
rule: "corpus-format-too-new",
|
|
1524
|
+
message: `config.version ${t} is newer than the format version ${R} this paper-camp understands; writes are refused until it's upgraded`
|
|
1525
|
+
}
|
|
1526
|
+
];
|
|
1527
|
+
}, Ss = [
|
|
1528
|
+
ws,
|
|
1529
|
+
bs,
|
|
1530
|
+
vs,
|
|
1531
|
+
Es,
|
|
1532
|
+
ks
|
|
1533
|
+
], $s = /^---\s*\r?\n([\s\S]*?)\r?\n---\s*(?:\r?\n)?/, Is = /^#{1,6}\s+(.+?)\s*$/, Rs = /^[-*]\s+\[[ xX]\]\s+(.*)$/, As = /^(phases|fixes)$/i, wt = /^#{1,6}\s+Phases\s*$/i, Ps = /^(?:\d{4}-\d{2}-\d{2}\s+)?\[(?:log|clarification|review|note|decision|question|chat)\]/, Cs = /^\[(?:phase:\d+|body)\]/, _s = /\[\[\s*((?:IDEA|TICKET)-\d+)(?:\s*\|[^\]]*)?\s*\]\]/g, Ts = /* @__PURE__ */ new Set(["idea", "planned", "in-progress", "review", "open"]), Ns = /* @__PURE__ */ new Set(["done", "dropped"]);
|
|
1534
|
+
function ve(e) {
|
|
1535
|
+
const t = e.match($s);
|
|
1536
|
+
if (!t) return null;
|
|
1537
|
+
try {
|
|
1538
|
+
const n = V(t[1]);
|
|
1539
|
+
if (n && typeof n == "object" && !Array.isArray(n))
|
|
1540
|
+
return n;
|
|
1541
|
+
} catch {
|
|
1542
|
+
}
|
|
1543
|
+
return null;
|
|
1544
|
+
}
|
|
1545
|
+
function xs(e, t) {
|
|
1546
|
+
const n = e.split(`
|
|
1547
|
+
`).findIndex((s) => t.test(s));
|
|
1548
|
+
return n === -1 ? 1 : n + 1;
|
|
1549
|
+
}
|
|
1550
|
+
function T(e, t, n, s) {
|
|
1551
|
+
return { file: e.path, line: t, rule: n, message: s };
|
|
1552
|
+
}
|
|
1553
|
+
const Os = ({ files: e }) => e.flatMap((t) => {
|
|
1554
|
+
const n = t.content.split(`
|
|
1555
|
+
`), s = [];
|
|
1556
|
+
let r = !1;
|
|
1557
|
+
for (let i = 0; i < n.length; i++) {
|
|
1558
|
+
const a = n[i].match(Is);
|
|
1559
|
+
if (a) {
|
|
1560
|
+
r = As.test(a[1].trim());
|
|
1561
|
+
continue;
|
|
1562
|
+
}
|
|
1563
|
+
if (r) continue;
|
|
1564
|
+
const o = n[i].match(Rs);
|
|
1565
|
+
if (!o) continue;
|
|
1566
|
+
const c = o[1].trim();
|
|
1567
|
+
Ps.test(c) || Cs.test(c) || s.push(
|
|
1568
|
+
T(
|
|
1569
|
+
t,
|
|
1570
|
+
i + 1,
|
|
1571
|
+
"phases-list-split",
|
|
1572
|
+
`orphaned phase checkbox outside any Phases section: "${n[i].trim()}"`
|
|
1573
|
+
)
|
|
1574
|
+
);
|
|
1575
|
+
}
|
|
1576
|
+
return s;
|
|
1577
|
+
}), Ds = ({ files: e }) => e.flatMap((t) => {
|
|
1578
|
+
var r;
|
|
1579
|
+
if (((r = ve(t.content)) == null ? void 0 : r.kind) !== "note") return [];
|
|
1580
|
+
const s = t.content.split(`
|
|
1581
|
+
`).findIndex((i) => wt.test(i));
|
|
1582
|
+
return s === -1 ? [] : [T(t, s + 1, "note-has-phases", "a kind: note entity carries a Phases section")];
|
|
1583
|
+
}), js = ({ files: e }) => e.flatMap((t) => t.content.split(`
|
|
1584
|
+
`).flatMap((r, i) => wt.test(r) ? [i] : []).slice(1).map(
|
|
1585
|
+
(r) => T(
|
|
1586
|
+
t,
|
|
1587
|
+
r + 1,
|
|
1588
|
+
"duplicate-phases-section",
|
|
1589
|
+
"a second Phases heading exists — a redraft must replace the existing list in place, not append a new one"
|
|
1590
|
+
)
|
|
1591
|
+
)), Ms = ({ files: e }) => e.flatMap((t) => {
|
|
1592
|
+
var r;
|
|
1593
|
+
const n = (r = ve(t.content)) == null ? void 0 : r.status;
|
|
1594
|
+
if (typeof n != "string") return [];
|
|
1595
|
+
const s = xs(t.content, /^status:/);
|
|
1596
|
+
return t.archived && Ts.has(n) ? [
|
|
1597
|
+
T(
|
|
1598
|
+
t,
|
|
1599
|
+
s,
|
|
1600
|
+
"archive-placement",
|
|
1601
|
+
`status "${n}" is active but the file is under ideas/archive/`
|
|
1602
|
+
)
|
|
1603
|
+
] : !t.archived && Ns.has(n) ? [
|
|
1604
|
+
T(
|
|
1605
|
+
t,
|
|
1606
|
+
s,
|
|
1607
|
+
"archive-placement",
|
|
1608
|
+
`status "${n}" is closed but the file is still under ideas/ — it should be archived`
|
|
1609
|
+
)
|
|
1610
|
+
] : [];
|
|
1611
|
+
}), Ls = ({ files: e }) => {
|
|
1612
|
+
var n;
|
|
1613
|
+
const t = /* @__PURE__ */ new Set();
|
|
1614
|
+
for (const s of e) {
|
|
1615
|
+
t.add(s.id);
|
|
1616
|
+
const r = (n = ve(s.content)) == null ? void 0 : n.id;
|
|
1617
|
+
typeof r == "string" && t.add(r);
|
|
1618
|
+
}
|
|
1619
|
+
return e.flatMap((s) => {
|
|
1620
|
+
const r = s.content.split(`
|
|
1621
|
+
`), i = [];
|
|
1622
|
+
for (let a = 0; a < r.length; a++)
|
|
1623
|
+
for (const o of r[a].matchAll(_s))
|
|
1624
|
+
t.has(o[1]) || i.push(
|
|
1625
|
+
T(
|
|
1626
|
+
s,
|
|
1627
|
+
a + 1,
|
|
1628
|
+
"dangling-link",
|
|
1629
|
+
`[[${o[1]}]] points at an id no entity in the corpus defines`
|
|
1630
|
+
)
|
|
1631
|
+
);
|
|
1632
|
+
return i;
|
|
1633
|
+
});
|
|
1634
|
+
}, Fs = [
|
|
1635
|
+
Os,
|
|
1636
|
+
Ds,
|
|
1637
|
+
js,
|
|
1638
|
+
Ms,
|
|
1639
|
+
Ls
|
|
1640
|
+
], Hs = ".claude/settings.json", Gs = ({ hasPermissionsAllow: e }) => e === !1 ? [
|
|
1641
|
+
{
|
|
1642
|
+
file: Hs,
|
|
1643
|
+
line: 1,
|
|
1644
|
+
rule: "missing-permissions-allow",
|
|
1645
|
+
message: "no permissions.allow list — headless runs deny every edit and shell command outside the defaults; run `paper-camp init --settings` to add it."
|
|
1646
|
+
}
|
|
1647
|
+
] : [], Bs = [Gs], Ys = [
|
|
1648
|
+
...Ss,
|
|
1649
|
+
...Fs,
|
|
1650
|
+
...Bs
|
|
1651
|
+
];
|
|
1652
|
+
function Ee(e) {
|
|
1653
|
+
return (e == null ? void 0 : e.code) === "ENOENT";
|
|
1654
|
+
}
|
|
1655
|
+
async function qs(e) {
|
|
1656
|
+
try {
|
|
1657
|
+
return await z(e);
|
|
1658
|
+
} catch (t) {
|
|
1659
|
+
if (Ee(t)) return [];
|
|
1660
|
+
throw t;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
async function Us(e) {
|
|
1664
|
+
let t;
|
|
1665
|
+
try {
|
|
1666
|
+
t = await v(e, "utf-8");
|
|
1667
|
+
} catch (n) {
|
|
1668
|
+
if (Ee(n)) return null;
|
|
1669
|
+
throw n;
|
|
1670
|
+
}
|
|
1671
|
+
try {
|
|
1672
|
+
return JSON.parse(t);
|
|
1673
|
+
} catch {
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
async function Ks(e) {
|
|
1678
|
+
var n;
|
|
1679
|
+
let t;
|
|
1680
|
+
try {
|
|
1681
|
+
t = await v(p(e, ".claude", "settings.json"), "utf-8");
|
|
1682
|
+
} catch (s) {
|
|
1683
|
+
if (Ee(s)) return !1;
|
|
1684
|
+
throw s;
|
|
1685
|
+
}
|
|
1686
|
+
try {
|
|
1687
|
+
const s = JSON.parse(t);
|
|
1688
|
+
return Array.isArray((n = s.permissions) == null ? void 0 : n.allow) && s.permissions.allow.length > 0;
|
|
1689
|
+
} catch {
|
|
1690
|
+
return !1;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
async function Ws(e) {
|
|
1694
|
+
const t = p(e, "ideas"), n = [], s = [
|
|
1695
|
+
{ dir: t, archived: !1, names: await z(t) },
|
|
1696
|
+
{
|
|
1697
|
+
dir: p(t, "archive"),
|
|
1698
|
+
archived: !0,
|
|
1699
|
+
names: await qs(p(t, "archive"))
|
|
1700
|
+
}
|
|
1701
|
+
];
|
|
1702
|
+
for (const { dir: r, archived: i, names: a } of s) {
|
|
1703
|
+
const o = a.filter((c) => c.endsWith(".md") && c !== "index.md").sort();
|
|
1704
|
+
for (const c of o)
|
|
1705
|
+
n.push({
|
|
1706
|
+
id: Ft(c, ".md"),
|
|
1707
|
+
path: `papercamp/ideas${i ? "/archive" : ""}/${c}`,
|
|
1708
|
+
content: await v(p(r, c), "utf-8"),
|
|
1709
|
+
archived: i
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
return {
|
|
1713
|
+
files: n,
|
|
1714
|
+
config: await Us(p(e, "config.json")),
|
|
1715
|
+
hasPermissionsAllow: await Ks(M(e))
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
function Js(e) {
|
|
1719
|
+
return Ys.flatMap((t) => t(e));
|
|
1720
|
+
}
|
|
1721
|
+
async function zi(e) {
|
|
1722
|
+
return Js(await Ws(e));
|
|
1723
|
+
}
|
|
1724
|
+
const zs = {
|
|
1725
|
+
rule: "archive-placement",
|
|
1726
|
+
fix: (e, t) => ({
|
|
1727
|
+
kind: "move",
|
|
1728
|
+
from: t.path,
|
|
1729
|
+
to: t.archived ? t.path.replace("/archive/", "/") : t.path.replace(/\/(?=[^/]+$)/, "/archive/")
|
|
1730
|
+
})
|
|
1731
|
+
}, Vs = [zs], Xs = new Map(
|
|
1732
|
+
Vs.map((e) => [e.rule, e])
|
|
1733
|
+
);
|
|
1734
|
+
function Vi(e, t) {
|
|
1735
|
+
const n = new Map(e.files.map((o) => [o.path, o])), s = [], r = [], i = [], a = [];
|
|
1736
|
+
for (const o of t) {
|
|
1737
|
+
const c = Xs.get(o.rule), u = n.get(o.file), l = c && u ? c.fix(o, u) : null;
|
|
1738
|
+
if (!l) {
|
|
1739
|
+
i.push(o);
|
|
1740
|
+
continue;
|
|
1741
|
+
}
|
|
1742
|
+
if (l.kind === "move" && n.has(l.to)) {
|
|
1743
|
+
a.push(o);
|
|
1744
|
+
continue;
|
|
1745
|
+
}
|
|
1746
|
+
s.push(l), r.push(o);
|
|
1747
|
+
}
|
|
1748
|
+
return { actions: s, fixed: r, unfixable: i, rejected: a };
|
|
1749
|
+
}
|
|
1750
|
+
async function K(e) {
|
|
1751
|
+
try {
|
|
1752
|
+
return await v(e, "utf-8");
|
|
1753
|
+
} catch {
|
|
1754
|
+
return "";
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
function bt(e, t) {
|
|
1758
|
+
var n;
|
|
1759
|
+
return (n = e.split(`
|
|
1760
|
+
`).find((s) => s.includes(`(${t})`))) == null ? void 0 : n.trim();
|
|
1761
|
+
}
|
|
1762
|
+
const Zs = /^## \[.+?\]\(.*\/compare\/(.+?)\.\.\.(.+?)\)/;
|
|
1763
|
+
function Qs(e) {
|
|
1764
|
+
return e.split(`
|
|
1765
|
+
`).map((t) => Zs.exec(t)).filter((t) => t !== null).map((t) => ({ version: t[2], range: `${t[1]}..${t[2]}` }));
|
|
1766
|
+
}
|
|
1767
|
+
function er(e, t) {
|
|
1768
|
+
return e.split(`
|
|
1769
|
+
`).find((n) => {
|
|
1770
|
+
const s = n.match(/\/commit\/([0-9a-f]+)\)/i);
|
|
1771
|
+
return s ? s[1].startsWith(t) || t.startsWith(s[1]) : !1;
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
const tr = /^[a-z]+\/([a-z]+-\d+)-/;
|
|
1775
|
+
async function nr(e, t) {
|
|
1776
|
+
var r;
|
|
1777
|
+
const n = await S(e, [
|
|
1778
|
+
"for-each-ref",
|
|
1779
|
+
"--format=%(refname)",
|
|
1780
|
+
"refs/heads",
|
|
1781
|
+
"refs/remotes"
|
|
1782
|
+
]), s = t.toLowerCase();
|
|
1783
|
+
for (const i of n.split(`
|
|
1784
|
+
`)) {
|
|
1785
|
+
const a = i.replace(/^refs\/heads\//, "").replace(/^refs\/remotes\/[^/]+\//, "");
|
|
1786
|
+
if (((r = tr.exec(a)) == null ? void 0 : r[1]) === s) return a;
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
async function sr(e, t) {
|
|
1790
|
+
const n = await nr(e, t);
|
|
1791
|
+
if (!n) return [];
|
|
1792
|
+
const s = await Ue(e);
|
|
1793
|
+
return (await S(e, ["log", "--format=%s", `${s}..${n}`])).split(`
|
|
1794
|
+
`).map((i) => i.trim()).filter(Boolean);
|
|
1795
|
+
}
|
|
1796
|
+
async function rr(e, t) {
|
|
1797
|
+
if (!cn.test(t)) return null;
|
|
1798
|
+
const n = await S(e, ["log", "-1", "--format=%B", t]), s = n ? ne(n) : null;
|
|
1799
|
+
if (s) return s;
|
|
1800
|
+
const r = await K(p(e, "CHANGELOG.md")), i = er(r, t);
|
|
1801
|
+
return i ? ne(i) : null;
|
|
1802
|
+
}
|
|
1803
|
+
async function ir(e, t) {
|
|
1804
|
+
const s = (await S(e, ["log", "--format=%H", "--reverse", t])).split(`
|
|
1805
|
+
`).map((a) => a.trim()).filter(Boolean), r = await Promise.all(s.map((a) => rr(e, a))), i = /* @__PURE__ */ new Map();
|
|
1806
|
+
return s.forEach((a, o) => {
|
|
1807
|
+
const c = r[o];
|
|
1808
|
+
if (!c) return;
|
|
1809
|
+
const u = i.get(c);
|
|
1810
|
+
u ? u.push(a) : i.set(c, [a]);
|
|
1811
|
+
}), i;
|
|
1812
|
+
}
|
|
1813
|
+
async function Xi(e, t) {
|
|
1814
|
+
const [{ entries: n }, s, r, i, a, o] = await Promise.all([
|
|
1815
|
+
x(p(e, "papercamp", "ideas")),
|
|
1816
|
+
tt(e),
|
|
1817
|
+
K(p(e, "papercamp", "tasks.log")),
|
|
1818
|
+
K(p(e, "CHANGELOG.md")),
|
|
1819
|
+
sr(e, t),
|
|
1820
|
+
Ke(e)
|
|
1821
|
+
]), c = n.find((h) => h.id === t), u = s == null ? void 0 : s.get(t), l = us(r).filter((h) => h.planId === t), f = bt(i, t);
|
|
1822
|
+
return {
|
|
1823
|
+
id: t,
|
|
1824
|
+
idea: c ? {
|
|
1825
|
+
reached: !0,
|
|
1826
|
+
data: {
|
|
1827
|
+
title: c.title,
|
|
1828
|
+
status: X(c, u, s !== void 0, o.has(t)),
|
|
1829
|
+
type: c.type
|
|
1830
|
+
}
|
|
1831
|
+
} : { reached: !1 },
|
|
1832
|
+
phases: c ? { reached: c.phases.length > 0, data: c.phases } : { reached: !1 },
|
|
1833
|
+
taskRuns: l.length > 0 ? { reached: !0, data: l } : { reached: !1 },
|
|
1834
|
+
commits: a.length > 0 ? { reached: !0, data: a } : { reached: !1 },
|
|
1835
|
+
pr: u ? { reached: !0, data: u } : { reached: !1 },
|
|
1836
|
+
releaseLine: f ? { reached: !0, data: f } : { reached: !1 }
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
const B = /^##\s+/, ar = /^##\s+The goal\s*$/i, vt = /^##\s+(Horizon\s+\d+\s*[—-].*)\r?$/i, or = /^##\s+Standing concerns\s*$/i, N = /^-\s+\*\*(.+?)\*\*\s+[—-]\s+(.*)\r?$/, cr = /^\s+-\s+→\s+(.+?)\r?$/, dr = /^([A-Z]+-\d+)/, Et = /^\s+-\s+✓\s+shipped\s+(.+?)\r?$/, ke = /^\s+-\s+(.+?)\r?$/, Se = /^\s+\S/;
|
|
1840
|
+
function Oe(e, t, n) {
|
|
1841
|
+
var i;
|
|
1842
|
+
const s = [];
|
|
1843
|
+
let r = t;
|
|
1844
|
+
for (; r < n; ) {
|
|
1845
|
+
const a = e[r].match(N);
|
|
1846
|
+
if (!a) {
|
|
1847
|
+
r++;
|
|
1848
|
+
continue;
|
|
1849
|
+
}
|
|
1850
|
+
const o = [a[2].trim()], c = [], u = [];
|
|
1851
|
+
let l;
|
|
1852
|
+
for (r++; r < n && !N.test(e[r]); ) {
|
|
1853
|
+
const f = e[r].match(cr);
|
|
1854
|
+
if (f) {
|
|
1855
|
+
const w = f[1].trim();
|
|
1856
|
+
u.push(((i = w.match(dr)) == null ? void 0 : i[1]) ?? w), r++;
|
|
1857
|
+
continue;
|
|
1858
|
+
}
|
|
1859
|
+
const h = e[r].match(Et);
|
|
1860
|
+
if (h) {
|
|
1861
|
+
l = h[1].trim(), r++;
|
|
1862
|
+
continue;
|
|
1863
|
+
}
|
|
1864
|
+
const g = e[r].match(ke);
|
|
1865
|
+
if (g) {
|
|
1866
|
+
c.push(g[1].trim()), r++;
|
|
1867
|
+
continue;
|
|
1868
|
+
}
|
|
1869
|
+
if (!Se.test(e[r])) break;
|
|
1870
|
+
o.push(e[r].trim()), r++;
|
|
1871
|
+
}
|
|
1872
|
+
s.push({
|
|
1873
|
+
name: a[1].trim(),
|
|
1874
|
+
description: o.join(" "),
|
|
1875
|
+
candidates: c,
|
|
1876
|
+
linked: u,
|
|
1877
|
+
...l !== void 0 ? { shippedOn: l } : {}
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
return s;
|
|
1881
|
+
}
|
|
1882
|
+
function ur(e) {
|
|
1883
|
+
const t = e.split(`
|
|
1884
|
+
`);
|
|
1885
|
+
let n = "";
|
|
1886
|
+
const s = [];
|
|
1887
|
+
let r = [];
|
|
1888
|
+
for (let i = 0; i < t.length; i++) {
|
|
1889
|
+
if (ar.test(t[i])) {
|
|
1890
|
+
let o = i + 1;
|
|
1891
|
+
for (; o < t.length && !B.test(t[o]); ) o++;
|
|
1892
|
+
n = t.slice(i + 1, o).join(`
|
|
1893
|
+
`).trim(), i = o - 1;
|
|
1894
|
+
continue;
|
|
1895
|
+
}
|
|
1896
|
+
const a = t[i].match(vt);
|
|
1897
|
+
if (a) {
|
|
1898
|
+
let o = i + 1;
|
|
1899
|
+
for (; o < t.length && !B.test(t[o]); ) o++;
|
|
1900
|
+
let c = i + 1;
|
|
1901
|
+
for (; c < o && !N.test(t[c]); ) c++;
|
|
1902
|
+
const u = t.slice(i + 1, c).join(`
|
|
1903
|
+
`).trim();
|
|
1904
|
+
s.push({
|
|
1905
|
+
title: a[1].trim(),
|
|
1906
|
+
intro: u,
|
|
1907
|
+
items: Oe(t, i + 1, o)
|
|
1908
|
+
}), i = o - 1;
|
|
1909
|
+
continue;
|
|
1910
|
+
}
|
|
1911
|
+
if (or.test(t[i])) {
|
|
1912
|
+
let o = i + 1;
|
|
1913
|
+
for (; o < t.length && !B.test(t[o]); ) o++;
|
|
1914
|
+
r = Oe(t, i + 1, o), i = o - 1;
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
return { goal: n, horizons: s, standingConcerns: r };
|
|
1918
|
+
}
|
|
1919
|
+
function W(e, t) {
|
|
1920
|
+
for (let n = 0; n < e.length; n++) {
|
|
1921
|
+
const s = e[n].match(vt);
|
|
1922
|
+
if (!s || s[1].trim() !== t) continue;
|
|
1923
|
+
let r = n + 1;
|
|
1924
|
+
for (; r < e.length && !B.test(e[r]); ) r++;
|
|
1925
|
+
return { start: n + 1, end: r };
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
function O(e, t, n) {
|
|
1929
|
+
const s = W(e, t);
|
|
1930
|
+
if (s)
|
|
1931
|
+
for (let r = s.start; r < s.end; r++) {
|
|
1932
|
+
const i = e[r].match(N);
|
|
1933
|
+
if (!i || i[1].trim() !== n) continue;
|
|
1934
|
+
let a = r + 1;
|
|
1935
|
+
for (; a < s.end && !N.test(e[a]) && Se.test(e[a]); )
|
|
1936
|
+
a++;
|
|
1937
|
+
return { start: r, end: a };
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
function Zi(e, t, n, s) {
|
|
1941
|
+
const r = e.split(`
|
|
1942
|
+
`), i = O(r, t, n);
|
|
1943
|
+
if (!i) return e;
|
|
1944
|
+
if (s === void 0)
|
|
1945
|
+
return r.splice(i.start, i.end - i.start), r.join(`
|
|
1946
|
+
`);
|
|
1947
|
+
for (let a = i.start + 1; a < i.end; a++) {
|
|
1948
|
+
const o = r[a].match(ke);
|
|
1949
|
+
if (o && o[1].trim() === s)
|
|
1950
|
+
return r.splice(a, 1), r.join(`
|
|
1951
|
+
`);
|
|
1952
|
+
}
|
|
1953
|
+
return e;
|
|
1954
|
+
}
|
|
1955
|
+
function Qi(e, t, n, s) {
|
|
1956
|
+
var u, l;
|
|
1957
|
+
const r = e.split(`
|
|
1958
|
+
`), i = O(r, t, n);
|
|
1959
|
+
if (!i) return e;
|
|
1960
|
+
const a = r[i.start].match(N);
|
|
1961
|
+
if (!a) return e;
|
|
1962
|
+
const o = ((u = s.name) == null ? void 0 : u.trim()) ?? a[1].trim(), c = ((l = s.description) == null ? void 0 : l.trim()) ?? a[2].trim();
|
|
1963
|
+
if (r[i.start] = `- **${o}** — ${c}`, s.description !== void 0)
|
|
1964
|
+
for (let f = i.end - 1; f > i.start; f--)
|
|
1965
|
+
Se.test(r[f]) && !ke.test(r[f]) && r.splice(f, 1);
|
|
1966
|
+
return r.join(`
|
|
1967
|
+
`);
|
|
1968
|
+
}
|
|
1969
|
+
function ea(e, t, n, s) {
|
|
1970
|
+
if (t === s) return e;
|
|
1971
|
+
const r = e.split(`
|
|
1972
|
+
`), i = O(r, t, n);
|
|
1973
|
+
if (!i || !W(r, s)) return e;
|
|
1974
|
+
const a = r.splice(i.start, i.end - i.start), o = W(r, s);
|
|
1975
|
+
if (!o) return e;
|
|
1976
|
+
let c = o.end;
|
|
1977
|
+
for (; c > o.start && r[c - 1].trim() === ""; ) c--;
|
|
1978
|
+
return r.splice(c, 0, ...a), r.join(`
|
|
1979
|
+
`);
|
|
1980
|
+
}
|
|
1981
|
+
function ta(e, t, n, s) {
|
|
1982
|
+
const r = e.split(`
|
|
1983
|
+
`), i = O(r, t, n);
|
|
1984
|
+
if (!i) return e;
|
|
1985
|
+
let a = i.end;
|
|
1986
|
+
for (let o = i.start + 1; o < a; o++)
|
|
1987
|
+
if (Et.test(r[o])) {
|
|
1988
|
+
r.splice(o, 1), a--;
|
|
1989
|
+
break;
|
|
1990
|
+
}
|
|
1991
|
+
return s !== void 0 && r.splice(a, 0, ` - ✓ shipped ${s}`), r.join(`
|
|
1992
|
+
`);
|
|
1993
|
+
}
|
|
1994
|
+
function na(e, t, n, s) {
|
|
1995
|
+
const r = e.split(`
|
|
1996
|
+
`), i = W(r, t);
|
|
1997
|
+
if (!i) return e;
|
|
1998
|
+
let a = i.end;
|
|
1999
|
+
for (; a > i.start && r[a - 1].trim() === ""; ) a--;
|
|
2000
|
+
return r.splice(a, 0, `- **${n}** — ${s}`), r.join(`
|
|
2001
|
+
`);
|
|
2002
|
+
}
|
|
2003
|
+
function sa(e, t, n, s) {
|
|
2004
|
+
const r = e.split(`
|
|
2005
|
+
`), i = O(r, t, n);
|
|
2006
|
+
return i ? (r.splice(i.end, 0, ` - ${s}`), r.join(`
|
|
2007
|
+
`)) : e;
|
|
2008
|
+
}
|
|
2009
|
+
function ra(e, t, n, s) {
|
|
2010
|
+
const r = e.split(`
|
|
2011
|
+
`), i = O(r, t, n);
|
|
2012
|
+
return i ? (r.splice(i.end, 0, ` - → ${s}`), r.join(`
|
|
2013
|
+
`)) : e;
|
|
2014
|
+
}
|
|
2015
|
+
function kt(e) {
|
|
2016
|
+
return [
|
|
2017
|
+
...e.horizons.flatMap((t) => t.items.map((n) => n.name)),
|
|
2018
|
+
...e.standingConcerns.map((t) => t.name)
|
|
2019
|
+
];
|
|
2020
|
+
}
|
|
2021
|
+
function lr(e, t, n, s) {
|
|
2022
|
+
const r = /* @__PURE__ */ new Map();
|
|
2023
|
+
for (const i of t)
|
|
2024
|
+
i.id && i.subject === e.name && r.set(i.id, i);
|
|
2025
|
+
for (const i of e.linked) {
|
|
2026
|
+
const a = n.get(i);
|
|
2027
|
+
a && r.set(i, a);
|
|
2028
|
+
}
|
|
2029
|
+
return [...r.entries()].map(([i, a]) => ({
|
|
2030
|
+
id: i,
|
|
2031
|
+
title: a.title,
|
|
2032
|
+
status: a.status,
|
|
2033
|
+
pr: a.pr,
|
|
2034
|
+
released: bt(s, i) !== void 0
|
|
2035
|
+
}));
|
|
2036
|
+
}
|
|
2037
|
+
function fr(e) {
|
|
2038
|
+
const t = e.filter((s) => s.status !== "dropped"), n = t.filter((s) => s.status === "done").length;
|
|
2039
|
+
return { total: t.length, done: n, open: t.length - n };
|
|
2040
|
+
}
|
|
2041
|
+
function pr(e, t) {
|
|
2042
|
+
return e.shippedOn !== void 0 ? { state: "shipped", readyToShip: !1 } : t.total === 0 ? { state: "not-started", readyToShip: !1 } : { state: "in-progress", readyToShip: t.done === t.total };
|
|
2043
|
+
}
|
|
2044
|
+
function De(e, t, n, s) {
|
|
2045
|
+
const r = lr(e, t, n, s), i = fr(r), { state: a, readyToShip: o } = pr(e, i);
|
|
2046
|
+
return { ...e, ideas: r, rollup: i, state: a, readyToShip: o };
|
|
2047
|
+
}
|
|
2048
|
+
function ia(e, t, n = "") {
|
|
2049
|
+
const s = new Map(t.filter((c) => c.id).map((c) => [c.id, c])), r = e.horizons.map((c) => {
|
|
2050
|
+
const u = c.items.map((f) => De(f, t, s, n)), l = u.reduce(
|
|
2051
|
+
(f, h) => ({
|
|
2052
|
+
total: f.total + h.rollup.total,
|
|
2053
|
+
done: f.done + h.rollup.done,
|
|
2054
|
+
open: f.open + h.rollup.open
|
|
2055
|
+
}),
|
|
2056
|
+
{ total: 0, done: 0, open: 0 }
|
|
2057
|
+
);
|
|
2058
|
+
return { title: c.title, intro: c.intro, items: u, rollup: l };
|
|
2059
|
+
}), i = e.standingConcerns.map(
|
|
2060
|
+
(c) => De(c, t, s, n)
|
|
2061
|
+
), a = new Set(kt(e)), o = t.filter(
|
|
2062
|
+
(c) => !c.subject || !a.has(c.subject)
|
|
2063
|
+
);
|
|
2064
|
+
return { goal: e.goal, horizons: r, standingConcerns: i, unfiled: o };
|
|
2065
|
+
}
|
|
2066
|
+
function hr(e) {
|
|
2067
|
+
const t = JSON.stringify({
|
|
2068
|
+
body: e.body,
|
|
2069
|
+
phases: e.phases.map((n) => ({
|
|
2070
|
+
done: n.done,
|
|
2071
|
+
text: n.text,
|
|
2072
|
+
description: n.description ?? null,
|
|
2073
|
+
source: n.source ?? null
|
|
2074
|
+
}))
|
|
2075
|
+
});
|
|
2076
|
+
return qt("sha256").update(t).digest("hex");
|
|
2077
|
+
}
|
|
2078
|
+
const $e = /* @__PURE__ */ new Set([
|
|
2079
|
+
"core",
|
|
2080
|
+
"cli",
|
|
2081
|
+
"app",
|
|
2082
|
+
"server",
|
|
2083
|
+
"agent",
|
|
2084
|
+
"audit",
|
|
2085
|
+
"plans",
|
|
2086
|
+
"ideas",
|
|
2087
|
+
"docs",
|
|
2088
|
+
"settings",
|
|
2089
|
+
"stack",
|
|
2090
|
+
"ui",
|
|
2091
|
+
"ci",
|
|
2092
|
+
"config",
|
|
2093
|
+
"deps",
|
|
2094
|
+
"repo",
|
|
2095
|
+
"release",
|
|
2096
|
+
"main"
|
|
2097
|
+
]);
|
|
2098
|
+
function mr(e, t) {
|
|
2099
|
+
return (e == null ? void 0 : e.find((n) => $e.has(n))) ?? t;
|
|
2100
|
+
}
|
|
2101
|
+
function St(e, t) {
|
|
2102
|
+
return new Promise((n) => {
|
|
2103
|
+
var i, a;
|
|
2104
|
+
const s = b(
|
|
2105
|
+
"gh",
|
|
2106
|
+
["pr", "view", t, "--json", "title,body,headRefName,labels,isDraft,state,url,comments"],
|
|
2107
|
+
{
|
|
2108
|
+
cwd: e,
|
|
2109
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2110
|
+
}
|
|
2111
|
+
);
|
|
2112
|
+
let r = "";
|
|
2113
|
+
(i = s.stdout) == null || i.on("data", (o) => {
|
|
2114
|
+
r += o.toString();
|
|
2115
|
+
}), (a = s.stderr) == null || a.on("data", () => {
|
|
2116
|
+
}), s.on("close", (o) => {
|
|
2117
|
+
if (o !== 0) {
|
|
2118
|
+
n(void 0);
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
try {
|
|
2122
|
+
n(JSON.parse(r));
|
|
2123
|
+
} catch {
|
|
2124
|
+
n(void 0);
|
|
2125
|
+
}
|
|
2126
|
+
}), s.on("error", () => n(void 0));
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
const gr = 6e4;
|
|
2130
|
+
function aa(e, t, n = gr) {
|
|
2131
|
+
return new Promise((s) => {
|
|
2132
|
+
var a, o;
|
|
2133
|
+
const r = b("gh", ["pr", "diff", t], { cwd: e, stdio: ["ignore", "pipe", "pipe"] });
|
|
2134
|
+
let i = "";
|
|
2135
|
+
(a = r.stdout) == null || a.on("data", (c) => {
|
|
2136
|
+
i += c.toString();
|
|
2137
|
+
}), (o = r.stderr) == null || o.on("data", () => {
|
|
2138
|
+
}), r.on("close", (c) => {
|
|
2139
|
+
if (c !== 0) {
|
|
2140
|
+
s(void 0);
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
s(
|
|
2144
|
+
i.length > n ? `${i.slice(0, n)}
|
|
2145
|
+
... (diff truncated, exceeds size cap)` : i
|
|
2146
|
+
);
|
|
2147
|
+
}), r.on("error", () => s(void 0));
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
async function yr(e, t) {
|
|
2151
|
+
for (const n of ["ideas", p("ideas", "archive")]) {
|
|
2152
|
+
const s = p(e, "papercamp", n, `${t}.md`);
|
|
2153
|
+
try {
|
|
2154
|
+
return await jt(s), s;
|
|
2155
|
+
} catch {
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
return null;
|
|
2159
|
+
}
|
|
2160
|
+
async function C(e, t) {
|
|
2161
|
+
const n = await St(e, t), s = ze(n == null ? void 0 : n.body, (n == null ? void 0 : n.headRefName) ?? t);
|
|
2162
|
+
if (!s) return;
|
|
2163
|
+
const r = await yr(e, s);
|
|
2164
|
+
if (!r) return;
|
|
2165
|
+
const { entries: i } = dt(await v(r, "utf-8")), a = i[0];
|
|
2166
|
+
if (a)
|
|
2167
|
+
return { id: s, view: n, entry: a };
|
|
2168
|
+
}
|
|
2169
|
+
async function oa(e, t) {
|
|
2170
|
+
const n = await C(e, t);
|
|
2171
|
+
if (!n) return;
|
|
2172
|
+
const { id: s, entry: r } = n;
|
|
2173
|
+
return { id: s, kind: r.type, tags: r.tags, phases: r.phases };
|
|
2174
|
+
}
|
|
2175
|
+
const $t = "<!-- papercamp:phases:start -->", It = "<!-- papercamp:phases:end -->", je = new RegExp(`${$t}[\\s\\S]*?${It}`);
|
|
2176
|
+
function wr(e, t) {
|
|
2177
|
+
const n = t.map((i) => `- [${i.done ? "x" : " "}] ${i.text}`).join(`
|
|
2178
|
+
`), s = `${$t}
|
|
2179
|
+
### Phases
|
|
2180
|
+
${n}
|
|
2181
|
+
${It}`;
|
|
2182
|
+
if (je.test(e)) return e.replace(je, () => s);
|
|
2183
|
+
const r = e.trimEnd();
|
|
2184
|
+
return r.length > 0 ? `${r}
|
|
2185
|
+
|
|
2186
|
+
${s}` : s;
|
|
2187
|
+
}
|
|
2188
|
+
function br(e, t, n) {
|
|
2189
|
+
return new Promise((s) => {
|
|
2190
|
+
var i, a;
|
|
2191
|
+
const r = b("gh", ["pr", "edit", t, "--body-file", "-"], {
|
|
2192
|
+
cwd: e,
|
|
2193
|
+
stdio: ["pipe", "ignore", "pipe"]
|
|
2194
|
+
});
|
|
2195
|
+
(i = r.stderr) == null || i.on("data", () => {
|
|
2196
|
+
}), r.on("close", (o) => s(o === 0)), r.on("error", () => s(!1)), (a = r.stdin) == null || a.end(n);
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
async function ca(e, t) {
|
|
2200
|
+
const n = await C(e, t);
|
|
2201
|
+
if (!(n != null && n.view)) return "unresolved";
|
|
2202
|
+
const { view: s, entry: r } = n, i = wr(s.body, r.phases);
|
|
2203
|
+
return i === s.body ? "unchanged" : await br(e, t, i) ? "updated" : "unresolved";
|
|
2204
|
+
}
|
|
2205
|
+
function vr(e) {
|
|
2206
|
+
const t = /* @__PURE__ */ new Set();
|
|
2207
|
+
e.kind && t.add(e.kind);
|
|
2208
|
+
for (const n of e.tags)
|
|
2209
|
+
$e.has(n) && t.add(n);
|
|
2210
|
+
return [...t];
|
|
2211
|
+
}
|
|
2212
|
+
function Er(e) {
|
|
2213
|
+
return new Promise((t) => {
|
|
2214
|
+
var r, i;
|
|
2215
|
+
const n = b("gh", ["label", "list", "--limit", "200", "--json", "name"], {
|
|
2216
|
+
cwd: e,
|
|
2217
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2218
|
+
});
|
|
2219
|
+
let s = "";
|
|
2220
|
+
(r = n.stdout) == null || r.on("data", (a) => {
|
|
2221
|
+
s += a.toString();
|
|
2222
|
+
}), (i = n.stderr) == null || i.on("data", () => {
|
|
2223
|
+
}), n.on("close", (a) => {
|
|
2224
|
+
if (a !== 0) {
|
|
2225
|
+
t(void 0);
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
try {
|
|
2229
|
+
const o = JSON.parse(s);
|
|
2230
|
+
t(new Set(o.map((c) => c.name)));
|
|
2231
|
+
} catch {
|
|
2232
|
+
t(void 0);
|
|
2233
|
+
}
|
|
2234
|
+
}), n.on("error", () => t(void 0));
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
function kr(e, t) {
|
|
2238
|
+
return new Promise((n) => {
|
|
2239
|
+
var r;
|
|
2240
|
+
const s = b("gh", ["label", "create", t, "--color", "ededed"], {
|
|
2241
|
+
cwd: e,
|
|
2242
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
2243
|
+
});
|
|
2244
|
+
(r = s.stderr) == null || r.on("data", () => {
|
|
2245
|
+
}), s.on("close", (i) => n(i === 0)), s.on("error", () => n(!1));
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
function Sr(e, t, n) {
|
|
2249
|
+
return new Promise((s) => {
|
|
2250
|
+
var i;
|
|
2251
|
+
const r = b("gh", ["pr", "edit", t, "--add-label", n.join(",")], {
|
|
2252
|
+
cwd: e,
|
|
2253
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
2254
|
+
});
|
|
2255
|
+
(i = r.stderr) == null || i.on("data", () => {
|
|
2256
|
+
}), r.on("close", (a) => s(a === 0)), r.on("error", () => s(!1));
|
|
2257
|
+
});
|
|
2258
|
+
}
|
|
2259
|
+
async function da(e, t) {
|
|
2260
|
+
const n = await C(e, t);
|
|
2261
|
+
if (!(n != null && n.view)) return "unresolved";
|
|
2262
|
+
const { view: s, entry: r } = n, i = vr({ kind: r.type, tags: r.tags }), a = new Set((s.labels ?? []).map((l) => l.name)), o = i.filter((l) => !a.has(l));
|
|
2263
|
+
if (o.length === 0) return "unchanged";
|
|
2264
|
+
const c = await Er(e);
|
|
2265
|
+
if (c) {
|
|
2266
|
+
const l = o.filter((f) => !c.has(f));
|
|
2267
|
+
for (const f of l)
|
|
2268
|
+
await kr(e, f);
|
|
2269
|
+
}
|
|
2270
|
+
return await Sr(e, t, o) ? "updated" : "unresolved";
|
|
2271
|
+
}
|
|
2272
|
+
function Rt(e, t) {
|
|
2273
|
+
const n = t.type ?? "feat", s = mr(t.tags, "repo");
|
|
2274
|
+
return `${n}(${s}): ${t.title} (${e})`;
|
|
2275
|
+
}
|
|
2276
|
+
const $r = new RegExp(`^(${Yt.join("|")})\\(([a-z-]+)\\): .+$`);
|
|
2277
|
+
function Ir(e) {
|
|
2278
|
+
const t = e.match($r);
|
|
2279
|
+
return !!t && $e.has(t[2]);
|
|
2280
|
+
}
|
|
2281
|
+
function Rr(e, t, n) {
|
|
2282
|
+
return new Promise((s) => {
|
|
2283
|
+
var i;
|
|
2284
|
+
const r = b("gh", ["pr", "edit", t, "--title", n], {
|
|
2285
|
+
cwd: e,
|
|
2286
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
2287
|
+
});
|
|
2288
|
+
(i = r.stderr) == null || i.on("data", () => {
|
|
2289
|
+
}), r.on("close", (a) => s(a === 0)), r.on("error", () => s(!1));
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
async function ua(e, t) {
|
|
2293
|
+
const n = await C(e, t);
|
|
2294
|
+
if (!(n != null && n.view)) return "unresolved";
|
|
2295
|
+
const { id: s, view: r, entry: i } = n, a = Rt(s, i);
|
|
2296
|
+
return r.title === a ? "unchanged" : await Rr(e, t, a) ? "updated" : "unresolved";
|
|
2297
|
+
}
|
|
2298
|
+
async function la(e, t) {
|
|
2299
|
+
const n = await St(e, t);
|
|
2300
|
+
if (!n) return "no-pr";
|
|
2301
|
+
const s = await C(e, t);
|
|
2302
|
+
return s ? n.title === Rt(s.id, s.entry) ? "valid" : "invalid" : Ir(n.title) ? "valid" : "invalid";
|
|
2303
|
+
}
|
|
2304
|
+
function fa(e, t) {
|
|
2305
|
+
return new Promise((n) => {
|
|
2306
|
+
var i;
|
|
2307
|
+
const s = b("gh", ["pr", "merge", t, "--squash"], {
|
|
2308
|
+
cwd: e,
|
|
2309
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
2310
|
+
});
|
|
2311
|
+
let r = "";
|
|
2312
|
+
(i = s.stderr) == null || i.on("data", (a) => {
|
|
2313
|
+
r += a.toString();
|
|
2314
|
+
}), s.on("close", (a) => {
|
|
2315
|
+
n(a === 0 ? { ok: !0 } : {
|
|
2316
|
+
ok: !1,
|
|
2317
|
+
message: r.trim() || `gh pr merge ${t} --squash exited with code ${a}`
|
|
2318
|
+
});
|
|
2319
|
+
}), s.on("error", (a) => n({ ok: !1, message: a.message }));
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
function Ar(e, t) {
|
|
2323
|
+
return new Promise((n) => {
|
|
2324
|
+
var r;
|
|
2325
|
+
const s = b("gh", ["pr", "ready", t], {
|
|
2326
|
+
cwd: e,
|
|
2327
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
2328
|
+
});
|
|
2329
|
+
(r = s.stderr) == null || r.on("data", () => {
|
|
2330
|
+
}), s.on("close", (i) => n(i === 0)), s.on("error", () => n(!1));
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
function Pr(e, t) {
|
|
2334
|
+
return new Promise((n) => {
|
|
2335
|
+
var r;
|
|
2336
|
+
const s = b("gh", ["pr", "close", t], {
|
|
2337
|
+
cwd: e,
|
|
2338
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
2339
|
+
});
|
|
2340
|
+
(r = s.stderr) == null || r.on("data", () => {
|
|
2341
|
+
}), s.on("close", (i) => n(i === 0)), s.on("error", () => n(!1));
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
async function pa(e, t) {
|
|
2345
|
+
const n = await C(e, t);
|
|
2346
|
+
if (!(n != null && n.view)) return "unresolved";
|
|
2347
|
+
const { view: s, entry: r } = n;
|
|
2348
|
+
return r.status === "dropped" ? s.state !== "OPEN" ? "unchanged" : await Pr(e, t) ? "closed" : "unresolved" : !(r.phases.length > 0 && r.phases.every((o) => o.done)) || !s.isDraft ? "unchanged" : await Ar(e, t) ? "ready" : "unresolved";
|
|
2349
|
+
}
|
|
2350
|
+
const At = "<!-- papercamp:consistency:start -->", Cr = "<!-- papercamp:consistency:end -->";
|
|
2351
|
+
function _r(e, t) {
|
|
2352
|
+
const n = ["### Paper Camp checks", ""];
|
|
2353
|
+
if (e.length === 0)
|
|
2354
|
+
n.push("No consistency issues found.");
|
|
2355
|
+
else
|
|
2356
|
+
for (const s of e)
|
|
2357
|
+
n.push(`- **${s.kind}** (${s.section}): ${s.message}`);
|
|
2358
|
+
return t && (n.push(""), n.push(
|
|
2359
|
+
t.stale ? `Convergence audit: last run \`${t.audited}\`, plan has changed since — due for a re-audit.` : `Convergence audit: last run \`${t.audited}\`, still current.`
|
|
2360
|
+
)), `${At}
|
|
2361
|
+
${n.join(`
|
|
2362
|
+
`)}
|
|
2363
|
+
${Cr}`;
|
|
2364
|
+
}
|
|
2365
|
+
function Tr(e, t, n) {
|
|
2366
|
+
return new Promise((s) => {
|
|
2367
|
+
var i, a;
|
|
2368
|
+
const r = b("gh", ["pr", "comment", t, "--body-file", "-"], {
|
|
2369
|
+
cwd: e,
|
|
2370
|
+
stdio: ["pipe", "ignore", "pipe"]
|
|
2371
|
+
});
|
|
2372
|
+
(i = r.stderr) == null || i.on("data", () => {
|
|
2373
|
+
}), r.on("close", (o) => s(o === 0)), r.on("error", () => s(!1)), (a = r.stdin) == null || a.end(n);
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
function Nr(e, t, n, s, r) {
|
|
2377
|
+
return new Promise((i) => {
|
|
2378
|
+
var o, c;
|
|
2379
|
+
const a = b(
|
|
2380
|
+
"gh",
|
|
2381
|
+
[
|
|
2382
|
+
"api",
|
|
2383
|
+
`repos/${t}/${n}/issues/comments/${s}`,
|
|
2384
|
+
"-X",
|
|
2385
|
+
"PATCH",
|
|
2386
|
+
"-F",
|
|
2387
|
+
"body=@-"
|
|
2388
|
+
],
|
|
2389
|
+
{ cwd: e, stdio: ["pipe", "ignore", "pipe"] }
|
|
2390
|
+
);
|
|
2391
|
+
(o = a.stderr) == null || o.on("data", () => {
|
|
2392
|
+
}), a.on("close", (u) => i(u === 0)), a.on("error", () => i(!1)), (c = a.stdin) == null || c.end(r);
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
async function ha(e, t) {
|
|
2396
|
+
var w, y;
|
|
2397
|
+
const n = await C(e, t);
|
|
2398
|
+
if (!((w = n == null ? void 0 : n.view) != null && w.url)) return "unresolved";
|
|
2399
|
+
const { view: s, entry: r } = n, [{ entries: i }, a] = await Promise.all([
|
|
2400
|
+
x(p(e, "papercamp", "ideas")),
|
|
2401
|
+
v(p(e, "ROADMAP.md"), "utf-8").catch(() => "")
|
|
2402
|
+
]), o = i.filter((m) => m.kind !== "note").map((m) => qe(m)), c = a ? kt(ur(a)) : [], u = ds(o, c), l = r.audited && r.auditedHash ? {
|
|
2403
|
+
audited: r.audited,
|
|
2404
|
+
stale: hr(r) !== r.auditedHash
|
|
2405
|
+
} : void 0, f = _r(u, l), h = (s.comments ?? []).find((m) => m.body.includes(At));
|
|
2406
|
+
if (h) {
|
|
2407
|
+
if (h.body === f) return "unchanged";
|
|
2408
|
+
const m = F(s.url), D = (y = h.url.match(/issuecomment-(\d+)/)) == null ? void 0 : y[1];
|
|
2409
|
+
return !m || !D ? "unresolved" : await Nr(e, m.owner, m.repo, D, f) ? "updated" : "unresolved";
|
|
2410
|
+
}
|
|
2411
|
+
return await Tr(e, t, f) ? "created" : "unresolved";
|
|
2412
|
+
}
|
|
2413
|
+
function ma(e, t, n) {
|
|
2414
|
+
if (!e) return;
|
|
2415
|
+
const s = (t ?? "feat").toLowerCase(), r = n.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, ""), i = r.length <= 40 ? r : r[40] === "-" ? r.slice(0, 40) : r.slice(0, 40).replace(/-[^-]*$/, "");
|
|
2416
|
+
return `${s}/${e.toLowerCase()}-${i}`;
|
|
2417
|
+
}
|
|
2418
|
+
function Q(e, t) {
|
|
2419
|
+
for (const { entries: n, section: s } of t)
|
|
2420
|
+
n && n.length > 0 && e.push(s.formatLines(n).join(`
|
|
2421
|
+
`));
|
|
2422
|
+
}
|
|
2423
|
+
function Pt() {
|
|
2424
|
+
return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2425
|
+
}
|
|
2426
|
+
function ga(e, t = "log", n) {
|
|
2427
|
+
return {
|
|
2428
|
+
kind: t,
|
|
2429
|
+
date: Pt(),
|
|
2430
|
+
text: e,
|
|
2431
|
+
from: "agent",
|
|
2432
|
+
...t === "question" ? { state: "open" } : {},
|
|
2433
|
+
...n ? { entityId: n } : {}
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
function ya(e) {
|
|
2437
|
+
const t = [`## ${e.title}`, "", `**Status:** ${e.status}`];
|
|
2438
|
+
e.kind && t.push(`**Kind:** ${e.kind}`), e.id && t.push(`**Id:** ${e.id}`), e.idea && t.push(`**Idea:** ${e.idea}`), e.agent && t.push(`**Agent:** ${e.agent}`), t.push(`**Created:** ${e.created}`), e.updated && t.push(`**Updated:** ${e.updated}`), e.tags && e.tags.length > 0 && t.push(`**Tags:** ${e.tags.join(", ")}`);
|
|
2439
|
+
const n = [t.join(`
|
|
2440
|
+
`)];
|
|
2441
|
+
return e.body && n.push(e.body), Q(n, [
|
|
2442
|
+
{ entries: e.clarifications, section: pe },
|
|
2443
|
+
{ entries: e.phases, section: Z },
|
|
2444
|
+
{ entries: e.log, section: H },
|
|
2445
|
+
{ entries: e.notes, section: he }
|
|
2446
|
+
]), n.join(`
|
|
2447
|
+
|
|
2448
|
+
`).trimEnd();
|
|
2449
|
+
}
|
|
2450
|
+
function Ie(e) {
|
|
2451
|
+
return `---
|
|
2452
|
+
${Ht(e).trimEnd()}
|
|
2453
|
+
---`;
|
|
2454
|
+
}
|
|
2455
|
+
function wa(e) {
|
|
2456
|
+
const t = {
|
|
2457
|
+
id: e.id,
|
|
2458
|
+
title: e.title,
|
|
2459
|
+
kind: e.kind,
|
|
2460
|
+
status: e.status,
|
|
2461
|
+
created: e.created
|
|
2462
|
+
};
|
|
2463
|
+
e.idea && (t.idea = e.idea), e.agent && (t.agent = e.agent), e.updated && (t.updated = e.updated), e.audited && (t.audited = e.audited), e.auditedHash && (t["audited-hash"] = e.auditedHash), e.tags && e.tags.length > 0 && (t.tags = e.tags);
|
|
2464
|
+
const n = [Ie(t)];
|
|
2465
|
+
return e.body && n.push(e.body), Q(n, [
|
|
2466
|
+
{ entries: e.clarifications, section: pe },
|
|
2467
|
+
{ entries: e.phases, section: Z },
|
|
2468
|
+
{ entries: e.log, section: H },
|
|
2469
|
+
{ entries: e.notes, section: he }
|
|
2470
|
+
]), n.join(`
|
|
2471
|
+
|
|
2472
|
+
`).trimEnd();
|
|
2473
|
+
}
|
|
2474
|
+
function xr(e) {
|
|
2475
|
+
const t = {
|
|
2476
|
+
id: e.id,
|
|
2477
|
+
title: e.title
|
|
2478
|
+
};
|
|
2479
|
+
e.type && (t.type = e.type), e.kind && (t.kind = e.kind), e.status && (t.status = e.status), e.idea && (t.idea = e.idea), t.created = e.created, e.agent && (t.agent = e.agent), e.updated && (t.updated = e.updated), e.audited && (t.audited = e.audited), e.auditedHash && (t["audited-hash"] = e.auditedHash), e.released && (t.released = e.released), e.tags && e.tags.length > 0 && (t.tags = e.tags), e.subject && (t.subject = e.subject), e.order !== void 0 && (t.order = e.order), e.issueSource && (t.issueSource = e.issueSource);
|
|
2480
|
+
for (const s of Object.keys(e.unknownFrontmatter ?? {}).sort())
|
|
2481
|
+
t[s] = e.unknownFrontmatter[s];
|
|
2482
|
+
const n = [Ie(t)];
|
|
2483
|
+
return e.body && n.push(e.body), Q(n, [
|
|
2484
|
+
{ entries: e.phases, section: Z },
|
|
2485
|
+
{ entries: e.fixes, section: it },
|
|
2486
|
+
{ entries: e.thread, section: at }
|
|
2487
|
+
]), n.join(`
|
|
2488
|
+
|
|
2489
|
+
`).trimEnd();
|
|
2490
|
+
}
|
|
2491
|
+
function ba(e) {
|
|
2492
|
+
const t = {
|
|
2493
|
+
id: e.id,
|
|
2494
|
+
title: e.title
|
|
2495
|
+
};
|
|
2496
|
+
e.kind && (t.kind = e.kind), e.status && (t.status = e.status);
|
|
2497
|
+
const n = [Ie(t)], s = `## ${e.id}: ${e.title}`;
|
|
2498
|
+
return n.push(e.body ? `${s}
|
|
2499
|
+
|
|
2500
|
+
${e.body}` : s), Q(n, [{ entries: e.log, section: H }]), n.join(`
|
|
2501
|
+
|
|
2502
|
+
`).trimEnd();
|
|
2503
|
+
}
|
|
2504
|
+
function va(e, t) {
|
|
2505
|
+
let n = !1;
|
|
2506
|
+
const s = e.split(`
|
|
2507
|
+
`).filter((r) => {
|
|
2508
|
+
if (!n) {
|
|
2509
|
+
const i = r.match(ut);
|
|
2510
|
+
if (i && i[1] === t.date && i[2].trim() === t.title && i[3].trim() === t.description)
|
|
2511
|
+
return n = !0, !1;
|
|
2512
|
+
}
|
|
2513
|
+
return !0;
|
|
2514
|
+
});
|
|
2515
|
+
return n ? s.join(`
|
|
2516
|
+
`) : e;
|
|
2517
|
+
}
|
|
2518
|
+
let J = Promise.resolve();
|
|
2519
|
+
async function Or(e, t) {
|
|
2520
|
+
const n = new RegExp(`^${t.toUpperCase()}-(\\d+)\\.md$`), s = [
|
|
2521
|
+
p(e, "ideas"),
|
|
2522
|
+
p(e, "ideas", "archive"),
|
|
2523
|
+
p(e, "plans"),
|
|
2524
|
+
p(e, "plans", "archive")
|
|
2525
|
+
];
|
|
2526
|
+
let r = 0;
|
|
2527
|
+
for (const i of s) {
|
|
2528
|
+
let a;
|
|
2529
|
+
try {
|
|
2530
|
+
a = await z(i);
|
|
2531
|
+
} catch {
|
|
2532
|
+
continue;
|
|
2533
|
+
}
|
|
2534
|
+
for (const o of a) {
|
|
2535
|
+
const c = n.exec(o);
|
|
2536
|
+
c && (r = Math.max(r, Number(c[1])));
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
return r;
|
|
2540
|
+
}
|
|
2541
|
+
async function Ct(e, t) {
|
|
2542
|
+
const n = J.then(async () => {
|
|
2543
|
+
let s = null;
|
|
2544
|
+
try {
|
|
2545
|
+
s = JSON.parse(await v(e, "utf-8"));
|
|
2546
|
+
} catch {
|
|
2547
|
+
return;
|
|
2548
|
+
}
|
|
2549
|
+
if (!(s != null && s.nextId)) return;
|
|
2550
|
+
const r = s.nextId[t] ?? 1, i = await Or(M(e), t), a = Math.max(r, i + 1), o = `${t.toUpperCase()}-${a}`;
|
|
2551
|
+
return s.nextId[t] = a + 1, await E(e, `${JSON.stringify(s, null, 2)}
|
|
2552
|
+
`), o;
|
|
2553
|
+
});
|
|
2554
|
+
return J = n.catch(() => {
|
|
2555
|
+
}), n;
|
|
2556
|
+
}
|
|
2557
|
+
async function Ea(e) {
|
|
2558
|
+
return Ct(e, "idea");
|
|
2559
|
+
}
|
|
2560
|
+
async function ka(e) {
|
|
2561
|
+
return Ct(e, "ticket");
|
|
2562
|
+
}
|
|
2563
|
+
async function Sa(e, t) {
|
|
2564
|
+
const n = J.then(async () => {
|
|
2565
|
+
let s = null;
|
|
2566
|
+
try {
|
|
2567
|
+
s = JSON.parse(await v(e, "utf-8"));
|
|
2568
|
+
} catch {
|
|
2569
|
+
return;
|
|
2570
|
+
}
|
|
2571
|
+
const r = s.subjects ?? [];
|
|
2572
|
+
r.includes(t) || (s.subjects = [...r, t], await E(e, `${JSON.stringify(s, null, 2)}
|
|
2573
|
+
`));
|
|
2574
|
+
});
|
|
2575
|
+
return J = n.catch(() => {
|
|
2576
|
+
}), n;
|
|
2577
|
+
}
|
|
2578
|
+
async function $a(e, t) {
|
|
2579
|
+
const n = p(e, "papercamp", "ideas"), s = p(n, "archive"), r = p(n, `${t}.md`), i = p(s, `${t}.md`);
|
|
2580
|
+
await P(s, { recursive: !0 });
|
|
2581
|
+
try {
|
|
2582
|
+
return await Mt(r, i), !0;
|
|
2583
|
+
} catch (a) {
|
|
2584
|
+
if (a.code === "ENOENT") return !1;
|
|
2585
|
+
throw a;
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
const Dr = [
|
|
2589
|
+
["pnpm-lock.yaml", "pnpm"],
|
|
2590
|
+
["yarn.lock", "yarn"],
|
|
2591
|
+
["bun.lockb", "bun"],
|
|
2592
|
+
["package-lock.json", "npm"]
|
|
2593
|
+
];
|
|
2594
|
+
function _t(e) {
|
|
2595
|
+
for (const [t, n] of Dr)
|
|
2596
|
+
if (ae(p(e, t))) return n;
|
|
2597
|
+
return "npm";
|
|
2598
|
+
}
|
|
2599
|
+
function jr(e) {
|
|
2600
|
+
const t = p(e, "package.json");
|
|
2601
|
+
if (ae(t))
|
|
2602
|
+
try {
|
|
2603
|
+
return JSON.parse(He(t, "utf-8"));
|
|
2604
|
+
} catch {
|
|
2605
|
+
return;
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
const Me = "@dendelion/paper-camp";
|
|
2609
|
+
function Mr(e) {
|
|
2610
|
+
const t = jr(e);
|
|
2611
|
+
if (!t) return !1;
|
|
2612
|
+
const n = t.dependencies, s = t.devDependencies;
|
|
2613
|
+
return !!(n != null && n[Me] || s != null && s[Me]);
|
|
2614
|
+
}
|
|
2615
|
+
const Lr = ["*.json", "*.ts", "*.tsx", "*.md", "*.config.*"], Fr = ["src/**", "app/**", "scripts/**", "papercamp/**"], Hr = ["git status*", "git diff*", "git log*"], Gr = ["ls*", "cat*", "wc*"], Br = ["run *", "test*", "install*", "view *", "pack*", "ls*"], Yr = ["npx tsc*", "npx biome check*", "npx vitest*", "npx jest*", "npx expo *"];
|
|
2616
|
+
function Tt(e) {
|
|
2617
|
+
const t = Fr.flatMap((r) => [`Edit(${r})`, `Write(${r})`]), n = Lr.flatMap((r) => [`Edit(${r})`, `Write(${r})`]), s = [
|
|
2618
|
+
...Hr,
|
|
2619
|
+
...Gr,
|
|
2620
|
+
...Br.map((r) => `${e} ${r}`),
|
|
2621
|
+
...Yr
|
|
2622
|
+
].map((r) => `Bash(${r})`);
|
|
2623
|
+
return [...t, ...n, ...s];
|
|
2624
|
+
}
|
|
2625
|
+
function qr(e) {
|
|
2626
|
+
return e ? `"${Jr}" session-focus` : "paper-camp session-focus";
|
|
2627
|
+
}
|
|
2628
|
+
function Ur(e, t) {
|
|
2629
|
+
let n;
|
|
2630
|
+
try {
|
|
2631
|
+
n = JSON.parse(e);
|
|
2632
|
+
} catch {
|
|
2633
|
+
return e;
|
|
2634
|
+
}
|
|
2635
|
+
const s = Tt(_t(t)), r = n.permissions ?? {}, i = Array.isArray(r.allow) ? r.allow : [], a = s.filter((o) => !i.includes(o));
|
|
2636
|
+
return a.length === 0 && n.permissions !== void 0 ? e : (n.permissions = { ...r, allow: [...i, ...a] }, `${JSON.stringify(n, null, 2)}
|
|
2637
|
+
`);
|
|
2638
|
+
}
|
|
2639
|
+
function Kr(e) {
|
|
2640
|
+
const t = _t(e), n = qr(Mr(e));
|
|
2641
|
+
return `${JSON.stringify(
|
|
2642
|
+
{
|
|
2643
|
+
permissions: {
|
|
2644
|
+
allow: Tt(t)
|
|
2645
|
+
},
|
|
2646
|
+
hooks: {
|
|
2647
|
+
SessionStart: [
|
|
2648
|
+
{
|
|
2649
|
+
matcher: "*",
|
|
2650
|
+
hooks: [{ type: "command", command: n }]
|
|
2651
|
+
}
|
|
2652
|
+
]
|
|
2653
|
+
}
|
|
2654
|
+
},
|
|
2655
|
+
null,
|
|
2656
|
+
2
|
|
2657
|
+
)}
|
|
2658
|
+
`;
|
|
2659
|
+
}
|
|
2660
|
+
const Wr = `---
|
|
2661
|
+
name: paper-camp
|
|
2662
|
+
description: Work inside a project that has a papercamp/ folder — its unified idea entities (each holding its plan as a section), with decisions and open questions logged as notes on the idea they bind. Use this whenever the working directory contains papercamp/ (papercamp/ideas/), and especially before starting, continuing, or completing any plan phase, drafting an idea, logging a decision, or answering "what are we working on / what's next".
|
|
2663
|
+
---
|
|
2664
|
+
|
|
2665
|
+
# Paper Camp
|
|
2666
|
+
|
|
2667
|
+
Paper Camp is this project's planning methodology: plans and ideas are one
|
|
2668
|
+
thing, a unified entity file under \`papercamp/ideas/\`, with decisions and
|
|
2669
|
+
open questions logged as notes bound to the idea they concern. This skill
|
|
2670
|
+
tells you how to read that state before acting and how to keep it honest as
|
|
2671
|
+
you work.
|
|
2672
|
+
|
|
2673
|
+
If a \`papercamp\` MCP server is connected in this session, prefer its tools
|
|
2674
|
+
(list/get plans, update phase, etc.) over raw file access —
|
|
2675
|
+
they enforce the same guards (id allocation, branch conflicts) that the file
|
|
2676
|
+
grammar below assumes. Everything in this skill still applies conceptually;
|
|
2677
|
+
only the mechanism changes.
|
|
2678
|
+
|
|
2679
|
+
## Before doing any work
|
|
2680
|
+
|
|
2681
|
+
Read, in this order, whatever exists:
|
|
2682
|
+
|
|
2683
|
+
1. \`papercamp/ideas/\` — one file per entity, named by id. Ideas and plans are
|
|
2684
|
+
one thing: an entity is an *idea* for its whole life, and its plan is a
|
|
2685
|
+
\`### Phases\` section inside the same file.
|
|
2686
|
+
2. The specific entity file at \`papercamp/ideas/<ID>.md\` (e.g. \`IDEA-43.md\`)
|
|
2687
|
+
for the work you're about to do — YAML frontmatter (\`id\`, \`title\`,
|
|
2688
|
+
\`type\`, \`status\`, \`tags\`, ...) plus prose rationale, then optionally a
|
|
2689
|
+
\`### Phases\` list of \`- [ ]\`/\`- [x]\` checkboxes with an indented
|
|
2690
|
+
description under each. Done/dropped entities live in
|
|
2691
|
+
\`papercamp/ideas/archive/\`.
|
|
2692
|
+
Its notes carry any decision or open question bound to it — settled calls
|
|
2693
|
+
you shouldn't re-litigate without flagging it to the user first, and
|
|
2694
|
+
unresolved questions that might block or redirect the work you're about
|
|
2695
|
+
to start.
|
|
2696
|
+
|
|
2697
|
+
Skip files that don't exist yet (a fresh project may have empty logs).
|
|
2698
|
+
|
|
2699
|
+
## While working
|
|
2700
|
+
|
|
2701
|
+
- Work one plan phase at a time unless told otherwise — don't cascade into
|
|
2702
|
+
later phases just because they look quick.
|
|
2703
|
+
- If a phase's boundary or intent is unclear, ask before continuing.
|
|
2704
|
+
- Prose in plans and ideas is more current than your memory of past
|
|
2705
|
+
conversations. If they conflict, the files win — say so and resync.
|
|
2706
|
+
|
|
2707
|
+
## Keep the project current as you go
|
|
2708
|
+
|
|
2709
|
+
- **Plan phases**: when you finish a phase, flip its checkbox from \`- [ ]\` to
|
|
2710
|
+
\`- [x]\` in the plan's frontmatter file. Change only that line — don't touch
|
|
2711
|
+
other phases or prose.
|
|
2712
|
+
- **Plan status**: keep the plan's \`status:\` frontmatter honest
|
|
2713
|
+
(\`planned\` / \`in-progress\` / \`review\` / \`done\`). When every phase is
|
|
2714
|
+
checked, set status to \`review\` — never \`done\`. \`done\` is a human-only
|
|
2715
|
+
promotion after review; an agent finishing the last phase does not close
|
|
2716
|
+
the plan itself.
|
|
2717
|
+
- **Decisions / open questions**: if you settle something ambiguous while
|
|
2718
|
+
working, log it as a decision note on the idea it bounds; if you surface a
|
|
2719
|
+
question you can't resolve yourself, add it as a question note on that idea
|
|
2720
|
+
rather than guessing silently.
|
|
2721
|
+
|
|
2722
|
+
## What this skill deliberately does not do
|
|
2723
|
+
|
|
2724
|
+
It does not maintain a separate "current focus" file — that's derived at
|
|
2725
|
+
session start from live plan data, not hand-maintained here. It does
|
|
2726
|
+
not define the file formats in full; treat the existing files under
|
|
2727
|
+
\`papercamp/\` as the grammar reference (mirror their structure exactly rather
|
|
2728
|
+
than inventing a new shape).
|
|
2729
|
+
`, Jr = "$CLAUDE_PROJECT_DIR/node_modules/.bin/paper-camp", zr = 5;
|
|
2730
|
+
function Vr() {
|
|
2731
|
+
try {
|
|
2732
|
+
let e = M(Ut(import.meta.url));
|
|
2733
|
+
for (let t = 0; t < zr; t++) {
|
|
2734
|
+
const n = p(e, "package.json");
|
|
2735
|
+
if (ae(n))
|
|
2736
|
+
return JSON.parse(He(n, "utf-8")).version ?? "0.0.0";
|
|
2737
|
+
e = M(e);
|
|
2738
|
+
}
|
|
2739
|
+
return "0.0.0";
|
|
2740
|
+
} catch {
|
|
2741
|
+
return "0.0.0";
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
const Ia = Vr();
|
|
2745
|
+
class Xr extends Error {
|
|
2746
|
+
constructor(t) {
|
|
2747
|
+
super(`Paper Camp is already initialized in ${t} (papercamp/config.json exists).`);
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
async function _(e) {
|
|
2751
|
+
try {
|
|
2752
|
+
return await Lt(e), !0;
|
|
2753
|
+
} catch {
|
|
2754
|
+
return !1;
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
const Zr = ["suggestions.md"];
|
|
2758
|
+
async function Ra(e, t) {
|
|
2759
|
+
const n = p(e, "papercamp"), s = p(n, "config.json");
|
|
2760
|
+
if (await _(s))
|
|
2761
|
+
throw new Xr(e);
|
|
2762
|
+
const r = {
|
|
2763
|
+
version: R,
|
|
2764
|
+
projectName: t.projectName,
|
|
2765
|
+
initializedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2766
|
+
nextId: { idea: 2 }
|
|
2767
|
+
};
|
|
2768
|
+
es.parse(r), await P(n, { recursive: !0 });
|
|
2769
|
+
const i = p(n, "ideas");
|
|
2770
|
+
await P(i, { recursive: !0 });
|
|
2771
|
+
const a = p(i, "archive");
|
|
2772
|
+
await P(a, { recursive: !0 });
|
|
2773
|
+
const o = p(i, "IDEA-1.md");
|
|
2774
|
+
if (!await _(o)) {
|
|
2775
|
+
const c = xr({
|
|
2776
|
+
id: "IDEA-1",
|
|
2777
|
+
title: "Capture your first idea",
|
|
2778
|
+
status: "idea",
|
|
2779
|
+
created: Pt(),
|
|
2780
|
+
body: `This is an example idea, in the format Paper Camp expects: a short title, a status, and a paragraph of context. Read it, then archive or delete it once you've written your own.
|
|
2781
|
+
|
|
2782
|
+
Use the New idea button to capture what you're building next, or ask an agent for suggestions.`
|
|
2783
|
+
});
|
|
2784
|
+
await E(o, `${c}
|
|
2785
|
+
`, "utf-8");
|
|
2786
|
+
}
|
|
2787
|
+
for (const c of Zr) {
|
|
2788
|
+
const u = p(n, c);
|
|
2789
|
+
await _(u) || await E(u, "", "utf-8");
|
|
2790
|
+
}
|
|
2791
|
+
await E(s, `${JSON.stringify(r, null, 2)}
|
|
2792
|
+
`, "utf-8"), await ei(e), await ti(e), await Qr(e, t.projectName);
|
|
2793
|
+
}
|
|
2794
|
+
async function Qr(e, t) {
|
|
2795
|
+
const n = Jt(), s = await zt(n), { registry: r, created: i } = Vt(s, e, t);
|
|
2796
|
+
i && await Xt(n, r);
|
|
2797
|
+
}
|
|
2798
|
+
const te = "papercamp/.pairing.json";
|
|
2799
|
+
async function ei(e) {
|
|
2800
|
+
const t = p(e, ".gitignore"), n = await _(t) ? await v(t, "utf-8") : "", s = n.length > 0 ? n.split(`
|
|
2801
|
+
`) : [];
|
|
2802
|
+
if (s.some((i) => i.trim() === te)) return;
|
|
2803
|
+
const r = s.reduce(
|
|
2804
|
+
(i, a, o) => a.startsWith("papercamp/") ? o : i,
|
|
2805
|
+
-1
|
|
2806
|
+
);
|
|
2807
|
+
if (r === -1) {
|
|
2808
|
+
const i = n.length > 0 && !n.endsWith(`
|
|
2809
|
+
`) ? `
|
|
2810
|
+
` : "";
|
|
2811
|
+
await E(t, `${n}${i}${te}
|
|
2812
|
+
`, "utf-8");
|
|
2813
|
+
return;
|
|
2814
|
+
}
|
|
2815
|
+
s.splice(r + 1, 0, te), await E(t, s.join(`
|
|
2816
|
+
`), "utf-8");
|
|
2817
|
+
}
|
|
2818
|
+
async function ti(e) {
|
|
2819
|
+
const t = p(e, ".claude", "skills", "paper-camp");
|
|
2820
|
+
await P(t, { recursive: !0 });
|
|
2821
|
+
const n = p(t, "SKILL.md");
|
|
2822
|
+
await _(n) || await E(n, Wr, "utf-8");
|
|
2823
|
+
const s = p(e, ".claude");
|
|
2824
|
+
await P(s, { recursive: !0 });
|
|
2825
|
+
const r = p(s, "settings.json");
|
|
2826
|
+
if (await _(r)) {
|
|
2827
|
+
const i = await v(r, "utf-8"), a = Ur(i, e);
|
|
2828
|
+
a !== i && await E(r, a, "utf-8");
|
|
2829
|
+
} else
|
|
2830
|
+
await E(r, Kr(e), "utf-8");
|
|
2831
|
+
}
|
|
2832
|
+
const Nt = {
|
|
2833
|
+
feat: "Features",
|
|
2834
|
+
fix: "Bug Fixes",
|
|
2835
|
+
refactor: "Code Refactoring",
|
|
2836
|
+
docs: "Documentation",
|
|
2837
|
+
chore: "Miscellaneous"
|
|
2838
|
+
}, ni = Array.from(new Set(Object.values(Nt)));
|
|
2839
|
+
async function Aa(e, t) {
|
|
2840
|
+
const n = await K(p(e, "CHANGELOG.md")), s = Qs(n).find((o) => o.version === t);
|
|
2841
|
+
if (!s) return null;
|
|
2842
|
+
const [{ entries: r }, i] = await Promise.all([
|
|
2843
|
+
x(p(e, "papercamp", "ideas")),
|
|
2844
|
+
ir(e, s.range)
|
|
2845
|
+
]), a = /* @__PURE__ */ new Map();
|
|
2846
|
+
for (const o of i.keys()) {
|
|
2847
|
+
const c = r.find((f) => f.id === o);
|
|
2848
|
+
if (!c) continue;
|
|
2849
|
+
const u = Nt[c.type ?? "chore"], l = a.get(u) ?? [];
|
|
2850
|
+
l.push({ id: c.id, title: c.title }), a.set(u, l);
|
|
2851
|
+
}
|
|
2852
|
+
return ni.filter((o) => a.has(o)).map((o) => ({
|
|
2853
|
+
label: o,
|
|
2854
|
+
ideas: a.get(o)
|
|
2855
|
+
}));
|
|
2856
|
+
}
|
|
2857
|
+
function Pa(e, t) {
|
|
2858
|
+
const n = [`## ${e}`];
|
|
2859
|
+
for (const s of t) {
|
|
2860
|
+
n.push("", `### ${s.label}`, "");
|
|
2861
|
+
for (const r of s.ideas)
|
|
2862
|
+
n.push(`- ${r.title} (${r.id})`);
|
|
2863
|
+
}
|
|
2864
|
+
return n.join(`
|
|
2865
|
+
`);
|
|
2866
|
+
}
|
|
2867
|
+
function si(e) {
|
|
2868
|
+
return Math.floor((Date.now() - Date.parse(e)) / 864e5);
|
|
2869
|
+
}
|
|
2870
|
+
const xt = (e, t) => e === "question" && (t ?? "open") === "open", Ot = (e) => !!e.archived || e.status === "done" || e.status === "dropped";
|
|
2871
|
+
function ri(e) {
|
|
2872
|
+
return e.filter((t) => !Ot(t)).flatMap(
|
|
2873
|
+
(t) => (t.thread ?? []).filter((n) => xt(n.kind, n.state)).map((n) => ({
|
|
2874
|
+
entityId: t.id,
|
|
2875
|
+
entityTitle: t.title,
|
|
2876
|
+
text: n.text,
|
|
2877
|
+
date: n.date,
|
|
2878
|
+
ageDays: n.date ? si(n.date) : Number.POSITIVE_INFINITY
|
|
2879
|
+
}))
|
|
2880
|
+
).sort((t, n) => n.ageDays - t.ageDays);
|
|
2881
|
+
}
|
|
2882
|
+
async function Ca(e) {
|
|
2883
|
+
const { entries: t } = await x(e);
|
|
2884
|
+
return ri(t);
|
|
2885
|
+
}
|
|
2886
|
+
function _a(e, t) {
|
|
2887
|
+
const n = new Set(t.filter(Ot).map((s) => s.id));
|
|
2888
|
+
return e.map((s) => xt(s.kind, s.state) && s.entityId && n.has(s.entityId) ? { ...s, state: "resolved" } : s);
|
|
2889
|
+
}
|
|
2890
|
+
const re = 0.95, Dt = 3e4, ie = {
|
|
2891
|
+
implement: { from: 0, to: 0.6 },
|
|
2892
|
+
verify: { from: 0.6, to: 0.9 },
|
|
2893
|
+
checkbox: { from: 0.95, to: 0.95 }
|
|
2894
|
+
}, Le = {
|
|
2895
|
+
implement: 0,
|
|
2896
|
+
verify: 1,
|
|
2897
|
+
checkbox: 2
|
|
2898
|
+
};
|
|
2899
|
+
function Fe(e, ...t) {
|
|
2900
|
+
for (const n of t)
|
|
2901
|
+
if (typeof (e == null ? void 0 : e[n]) == "string") return e[n];
|
|
2902
|
+
return "";
|
|
2903
|
+
}
|
|
2904
|
+
function Ta(e, t) {
|
|
2905
|
+
const n = e.toLowerCase();
|
|
2906
|
+
if (n === "bash")
|
|
2907
|
+
return (typeof (t == null ? void 0 : t.command) == "string" ? t.command : "").includes("check-types") ? "verify" : null;
|
|
2908
|
+
if (n === "edit" || n === "multiedit" || n === "write") {
|
|
2909
|
+
const s = Fe(t, "old_string", "oldString"), r = Fe(t, "new_string", "newString");
|
|
2910
|
+
return s.includes("- [ ]") && r.includes("- [x]") ? "checkbox" : "implement";
|
|
2911
|
+
}
|
|
2912
|
+
return null;
|
|
2913
|
+
}
|
|
2914
|
+
function Na(e, t) {
|
|
2915
|
+
return e ? Le[t] > Le[e] ? t : e : t;
|
|
2916
|
+
}
|
|
2917
|
+
function xa(e, t) {
|
|
2918
|
+
return e === void 0 ? !1 : t - e >= Dt;
|
|
2919
|
+
}
|
|
2920
|
+
function ii(e) {
|
|
2921
|
+
const t = [...e].sort((s, r) => s - r), n = Math.floor(t.length / 2);
|
|
2922
|
+
return t.length % 2 === 0 ? (t[n - 1] + t[n]) / 2 : t[n];
|
|
2923
|
+
}
|
|
2924
|
+
function Oa(e) {
|
|
2925
|
+
const t = e.filter((r) => r.taskKind === "phase" && r.outcome === "done").map(
|
|
2926
|
+
(r) => (r.endedAt ? Date.parse(r.endedAt) : Number.NaN) - Date.parse(r.startedAt)
|
|
2927
|
+
).filter((r) => Number.isFinite(r) && r > 0);
|
|
2928
|
+
if (t.length === 0) return {};
|
|
2929
|
+
const n = ii(t), s = {};
|
|
2930
|
+
for (const r of ["implement", "verify"]) {
|
|
2931
|
+
const i = ie[r].to - ie[r].from;
|
|
2932
|
+
s[r] = n * i / re;
|
|
2933
|
+
}
|
|
2934
|
+
return s;
|
|
2935
|
+
}
|
|
2936
|
+
function Da({
|
|
2937
|
+
anchor: e,
|
|
2938
|
+
anchorEnteredAt: t,
|
|
2939
|
+
lastStreamAt: n,
|
|
2940
|
+
now: s,
|
|
2941
|
+
medians: r
|
|
2942
|
+
}) {
|
|
2943
|
+
if (!e) return 0;
|
|
2944
|
+
const i = ie[e], a = Math.min(i.from, re), o = r == null ? void 0 : r[e];
|
|
2945
|
+
if (!o || o <= 0 || t === void 0 || i.to === i.from)
|
|
2946
|
+
return a;
|
|
2947
|
+
const c = n === void 0 ? s : Math.min(s, n + Dt), u = Math.min(1, Math.max(0, c - t) / o);
|
|
2948
|
+
return Math.min(i.from + u * (i.to - i.from), re);
|
|
2949
|
+
}
|
|
2950
|
+
export {
|
|
2951
|
+
ds as $,
|
|
2952
|
+
Xr as A,
|
|
2953
|
+
Rt as B,
|
|
2954
|
+
$e as C,
|
|
2955
|
+
Ys as D,
|
|
2956
|
+
Ri as E,
|
|
2957
|
+
I as F,
|
|
2958
|
+
vr as G,
|
|
2959
|
+
kt as H,
|
|
2960
|
+
Ui as I,
|
|
2961
|
+
Kn as J,
|
|
2962
|
+
Wn as K,
|
|
2963
|
+
Jn as L,
|
|
2964
|
+
Ne as M,
|
|
2965
|
+
Un as N,
|
|
2966
|
+
_t as O,
|
|
2967
|
+
Ia as P,
|
|
2968
|
+
Ai as Q,
|
|
2969
|
+
Sa as R,
|
|
2970
|
+
Wr as S,
|
|
2971
|
+
Ci as T,
|
|
2972
|
+
qn as U,
|
|
2973
|
+
ct as V,
|
|
2974
|
+
on as W,
|
|
2975
|
+
qe as X,
|
|
2976
|
+
aa as Y,
|
|
2977
|
+
Si as Z,
|
|
2978
|
+
Yi as _,
|
|
2979
|
+
cn as a,
|
|
2980
|
+
Qs as a$,
|
|
2981
|
+
bt as a0,
|
|
2982
|
+
U as a1,
|
|
2983
|
+
xr as a2,
|
|
2984
|
+
ba as a3,
|
|
2985
|
+
ya as a4,
|
|
2986
|
+
wa as a5,
|
|
2987
|
+
Pa as a6,
|
|
2988
|
+
_i as a7,
|
|
2989
|
+
Mr as a8,
|
|
2990
|
+
Yn as a9,
|
|
2991
|
+
Vi as aA,
|
|
2992
|
+
Gn as aB,
|
|
2993
|
+
Bn as aC,
|
|
2994
|
+
Ni as aD,
|
|
2995
|
+
xi as aE,
|
|
2996
|
+
x as aF,
|
|
2997
|
+
Gi as aG,
|
|
2998
|
+
K as aH,
|
|
2999
|
+
qi as aI,
|
|
3000
|
+
Ca as aJ,
|
|
3001
|
+
us as aK,
|
|
3002
|
+
Bi as aL,
|
|
3003
|
+
Zi as aM,
|
|
3004
|
+
va as aN,
|
|
3005
|
+
_r as aO,
|
|
3006
|
+
wr as aP,
|
|
3007
|
+
Ii as aQ,
|
|
3008
|
+
Ki as aR,
|
|
3009
|
+
_a as aS,
|
|
3010
|
+
rr as aT,
|
|
3011
|
+
Xi as aU,
|
|
3012
|
+
ne as aV,
|
|
3013
|
+
ir as aW,
|
|
3014
|
+
oa as aX,
|
|
3015
|
+
mr as aY,
|
|
3016
|
+
tt as aZ,
|
|
3017
|
+
Aa as a_,
|
|
3018
|
+
Ra as aa,
|
|
3019
|
+
Ot as ab,
|
|
3020
|
+
Ir as ac,
|
|
3021
|
+
xa as ad,
|
|
3022
|
+
ra as ae,
|
|
3023
|
+
Oa as af,
|
|
3024
|
+
Ur as ag,
|
|
3025
|
+
ea as ah,
|
|
3026
|
+
Xn as ai,
|
|
3027
|
+
Vn as aj,
|
|
3028
|
+
zn as ak,
|
|
3029
|
+
Zn as al,
|
|
3030
|
+
es as am,
|
|
3031
|
+
dt as an,
|
|
3032
|
+
gi as ao,
|
|
3033
|
+
ge as ap,
|
|
3034
|
+
ji as aq,
|
|
3035
|
+
Mi as ar,
|
|
3036
|
+
Li as as,
|
|
3037
|
+
Di as at,
|
|
3038
|
+
Oi as au,
|
|
3039
|
+
rs as av,
|
|
3040
|
+
ur as aw,
|
|
3041
|
+
Fi as ax,
|
|
3042
|
+
Pi as ay,
|
|
3043
|
+
Da as az,
|
|
3044
|
+
Vs as b,
|
|
3045
|
+
$i as b0,
|
|
3046
|
+
ia as b1,
|
|
3047
|
+
zi as b2,
|
|
3048
|
+
Js as b3,
|
|
3049
|
+
ti as b4,
|
|
3050
|
+
Sn as b5,
|
|
3051
|
+
Ie as b6,
|
|
3052
|
+
ta as b7,
|
|
3053
|
+
ft as b8,
|
|
3054
|
+
fa as b9,
|
|
3055
|
+
ts as ba,
|
|
3056
|
+
ha as bb,
|
|
3057
|
+
ca as bc,
|
|
3058
|
+
da as bd,
|
|
3059
|
+
pa as be,
|
|
3060
|
+
ua as bf,
|
|
3061
|
+
Pt as bg,
|
|
3062
|
+
Qi as bh,
|
|
3063
|
+
la as bi,
|
|
3064
|
+
Qn as bj,
|
|
3065
|
+
at as bk,
|
|
3066
|
+
Wi as bl,
|
|
3067
|
+
ls as bm,
|
|
3068
|
+
Hi as bn,
|
|
3069
|
+
wi as bo,
|
|
3070
|
+
vi as bp,
|
|
3071
|
+
Ye as bq,
|
|
3072
|
+
S as br,
|
|
3073
|
+
Ei as bs,
|
|
3074
|
+
bi as bt,
|
|
3075
|
+
ki as bu,
|
|
3076
|
+
nn as bv,
|
|
3077
|
+
Ji as bw,
|
|
3078
|
+
hs as c,
|
|
3079
|
+
ms as d,
|
|
3080
|
+
re as e,
|
|
3081
|
+
Dt as f,
|
|
3082
|
+
ut as g,
|
|
3083
|
+
sa as h,
|
|
3084
|
+
na as i,
|
|
3085
|
+
Na as j,
|
|
3086
|
+
$ as k,
|
|
3087
|
+
ga as l,
|
|
3088
|
+
yi as m,
|
|
3089
|
+
$a as n,
|
|
3090
|
+
Ea as o,
|
|
3091
|
+
Ct as p,
|
|
3092
|
+
ka as q,
|
|
3093
|
+
ma as r,
|
|
3094
|
+
Kr as s,
|
|
3095
|
+
Tt as t,
|
|
3096
|
+
qr as u,
|
|
3097
|
+
Ta as v,
|
|
3098
|
+
Ti as w,
|
|
3099
|
+
Ws as x,
|
|
3100
|
+
ri as y,
|
|
3101
|
+
hr as z
|
|
3102
|
+
};
|
|
3103
|
+
//# sourceMappingURL=phase-progress.C97wkNMK.js.map
|