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