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