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