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