@staff0rd/assist 0.1167.0 → 0.1168.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/.build-files +79 -79
  2. package/dist/{addActivity-KFTWNCJC.js → addActivity-7BL2QCUP.js} +2 -2
  3. package/dist/{addPhase-CYLS4KF3.js → addPhase-UYBZKSW4.js} +3 -3
  4. package/dist/{advise-3NMJIWEG.js → advise-46JSXUDW.js} +3 -3
  5. package/dist/{askCheck-QZQNTYSB.js → askCheck-BCCZCYOI.js} +7 -7
  6. package/dist/{askDesign-XJWLHIKM.js → askDesign-C55JXS4W.js} +1 -1
  7. package/dist/{branch-7NZPUOFY.js → branch-7L5HGHC3.js} +3 -3
  8. package/dist/built-version +1 -1
  9. package/dist/chunk-3HNTLFII.js +50 -0
  10. package/dist/{chunk-PIZ5WHKY.js → chunk-3PESUAUN.js} +2 -2
  11. package/dist/{chunk-ZAMEG3EN.js → chunk-425LLTMS.js} +24 -21
  12. package/dist/{chunk-2IH2A3JK.js → chunk-43MJXI4R.js} +71 -19
  13. package/dist/{chunk-LRMCAFO3.js → chunk-6ULWRB6I.js} +1 -1
  14. package/dist/{chunk-KFTPCHSO.js → chunk-6W44RUSM.js} +1 -1
  15. package/dist/{chunk-SRSCOXZE.js → chunk-7MUNT7JI.js} +5 -1
  16. package/dist/{chunk-WC7ROMSZ.js → chunk-7QAFWJTK.js} +1 -1
  17. package/dist/{chunk-3OL7AV66.js → chunk-B7VURMUV.js} +2 -2
  18. package/dist/{chunk-FF5VHS2Q.js → chunk-DTRDXHGW.js} +1 -1
  19. package/dist/{chunk-4JI4SMBQ.js → chunk-E3WWV4JR.js} +475 -129
  20. package/dist/{chunk-4OZ6ULV6.js → chunk-EAREJAOY.js} +1 -1
  21. package/dist/{chunk-NCTA64LR.js → chunk-FAZEGCRS.js} +2 -2
  22. package/dist/{chunk-Z4EP2FTM.js → chunk-FYSUHMKS.js} +1 -1
  23. package/dist/{chunk-IYOKTOCX.js → chunk-H7SSIEZ2.js} +3 -3
  24. package/dist/{chunk-GSTZWNA7.js → chunk-HL26MMZX.js} +1 -1
  25. package/dist/{chunk-K3JNJGLB.js → chunk-I3TEQBTO.js} +25 -7
  26. package/dist/{chunk-HUUPDV55.js → chunk-I552VSJV.js} +1 -1
  27. package/dist/{chunk-4YTZUN24.js → chunk-IL4DISAP.js} +6 -6
  28. package/dist/{chunk-BTMRIDZC.js → chunk-KH72TT53.js} +1 -1
  29. package/dist/{chunk-J4SHN7I2.js → chunk-MVSLFBWG.js} +1 -1
  30. package/dist/{chunk-PVL3555C.js → chunk-NQRZKLIK.js} +1 -1
  31. package/dist/{chunk-5TJEQ6SM.js → chunk-QF5UR5N2.js} +1 -1
  32. package/dist/{chunk-AY4KVQZ2.js → chunk-QTF6XFHS.js} +1 -1
  33. package/dist/{chunk-W2TBOOCR.js → chunk-RW2B5RU5.js} +1 -1
  34. package/dist/{chunk-F4ADOEV4.js → chunk-S4FTKZLS.js} +1 -1
  35. package/dist/{chunk-LD3C7W3Q.js → chunk-UCTFPC6X.js} +2 -2
  36. package/dist/{chunk-B6TSGDM3.js → chunk-UY75YJI5.js} +1 -1
  37. package/dist/{chunk-VZ6K4LLZ.js → chunk-VEHHPXW6.js} +1 -1
  38. package/dist/{chunk-BUX5FETL.js → chunk-WWWNWP3Z.js} +1 -1
  39. package/dist/{chunk-DRCSMAFZ.js → chunk-X54VUNBQ.js} +1 -1
  40. package/dist/{chunk-HK7P5QGC.js → chunk-XERYO3NC.js} +1 -1
  41. package/dist/{chunk-5A63PEQ4.js → chunk-XRLD3NYP.js} +1 -1
  42. package/dist/{chunk-HL5PHECL.js → chunk-XWSDOQSQ.js} +4 -4
  43. package/dist/{chunk-XHYDG7UZ.js → chunk-YQJBSNEL.js} +1 -1
  44. package/dist/{chunk-LMXSHIFC.js → chunk-ZAS2ZWEK.js} +1 -1
  45. package/dist/{chunk-4AIX7WAZ.js → chunk-ZKPXMOR6.js} +1 -1
  46. package/dist/{chunk-XRXDSR4I.js → chunk-ZRJFYESX.js} +2 -2
  47. package/dist/{cliHook-PQ4DICPB.js → cliHook-LXPHXYTG.js} +5 -5
  48. package/dist/{cliHookCheck-XPQZAA7K.js → cliHookCheck-X3OTARTS.js} +2 -2
  49. package/dist/{codexHook-OU6CL4R6.js → codexHook-JHA7XAJI.js} +7 -7
  50. package/dist/commands/extension/extension/content.js +1 -1
  51. package/dist/commands/extension/extension/docs.js +1 -1
  52. package/dist/commands/sessions/web/bundle.js +470 -470
  53. package/dist/{commit-XSLHSHPA.js → commit-S237TZOH.js} +3 -3
  54. package/dist/{doctorNodes-UJSW3KXP.js → doctorNodes-ZGGPDVHQ.js} +3 -3
  55. package/dist/{done-RZTGTNXG.js → done-B5OPZGM4.js} +4 -4
  56. package/dist/{editHook-KBXSEJDB.js → editHook-TIPNG6CB.js} +5 -5
  57. package/dist/{fixConflict-IQPXBWTV.js → fixConflict-GLENPF7A.js} +4 -4
  58. package/dist/index.js +48 -48
  59. package/dist/{indexRules-4M2TAWOE.js → indexRules-65H3IE33.js} +1 -2
  60. package/dist/{launchMode-CUMEGSJ2.js → launchMode-OATTOTYW.js} +13 -13
  61. package/dist/{list-6KAXN2EU.js → list-TGEC6P3Q.js} +5 -5
  62. package/dist/{next-M6ES2GM5.js → next-P63EVBB6.js} +12 -12
  63. package/dist/{piHook-SMWFJWJW.js → piHook-GCKOXN5A.js} +5 -5
  64. package/dist/{propose-UZ32UXI7.js → propose-D3F4C3EJ.js} +4 -4
  65. package/dist/{refine-IMF3B622.js → refine-W7HULKNY.js} +14 -14
  66. package/dist/{restartNode-DRKXN7BO.js → restartNode-AYPAGM32.js} +5 -5
  67. package/dist/{review-LV46YDUO.js → review-LQGEHHIW.js} +4 -4
  68. package/dist/{reviewPrComments-2XMV6JYB.js → reviewPrComments-RXADKZLV.js} +4 -4
  69. package/dist/{rewindPhase-CIBJCOEB.js → rewindPhase-BPVRXMD5.js} +8 -8
  70. package/dist/{rulesAdd-T62MTCFM.js → rulesAdd-V4SWWQKL.js} +8 -44
  71. package/dist/{run-OCENG6SA.js → run-TVFL4EWV.js} +10 -10
  72. package/dist/{run-LIMV7FRM.js → run-UH5KYOU7.js} +10 -10
  73. package/dist/{runDaemon-ZWJ5RXI3.js → runDaemon-YEDFUDNN.js} +263 -28
  74. package/dist/{runRefine-JDE7UBYZ.js → runRefine-FPTFYFMX.js} +14 -14
  75. package/dist/{scan-DKZKXE2I.js → scan-BO23G2MD.js} +2 -2
  76. package/dist/{schemaConfirm-JYOLGGGL.js → schemaConfirm-AB6SR5SC.js} +2 -2
  77. package/dist/{schemaUnlock-4JRJS5RQ.js → schemaUnlock-AT5T43PB.js} +2 -2
  78. package/dist/{search-CD5NUNSZ.js → search-5EA654VD.js} +5 -5
  79. package/dist/{show-CQEX3RE3.js → show-OLER6JJU.js} +3 -3
  80. package/dist/{show-EBJJQQ5G.js → show-QHB5ZN54.js} +3 -3
  81. package/dist/{signExtension-R2SUZ2TV.js → signExtension-Y5WU4OLB.js} +1 -1
  82. package/dist/{updateNode-OWAXUOKT.js → updateNode-YBE4MBAO.js} +5 -5
  83. package/dist/{updatePlan-U6PK425R.js → updatePlan-FWJBNYWK.js} +4 -4
  84. package/dist/{web-HE7B2H3B.js → web-DL44YNRY.js} +18 -17
  85. package/dist/{web-C6UIA5QL.js → web-VAXMLL35.js} +18 -17
  86. package/package.json +1 -1
  87. package/dist/chunk-IZZJUZZY.js +0 -21
@@ -11,7 +11,7 @@ import {
11
11
  resolveLinkTarget,
12
12
  usageWindowKey,
13
13
  watcherLogPath
14
- } from "./chunk-Z4EP2FTM.js";
14
+ } from "./chunk-FYSUHMKS.js";
15
15
  import {
16
16
  readLogTail
17
17
  } from "./chunk-JNCFHWBK.js";
@@ -26,7 +26,7 @@ import {
26
26
  } from "./chunk-3NPVVAAT.js";
27
27
  import {
28
28
  firstBrokenHop
29
- } from "./chunk-LRMCAFO3.js";
29
+ } from "./chunk-6ULWRB6I.js";
30
30
  import {
31
31
  TRACE_HEADER,
32
32
  newTraceId
@@ -34,7 +34,7 @@ import {
34
34
  import {
35
35
  ASSIST_VERSION,
36
36
  PROTOCOL_VERSION
37
- } from "./chunk-HK7P5QGC.js";
37
+ } from "./chunk-XERYO3NC.js";
38
38
  import {
39
39
  queryNodes
40
40
  } from "./chunk-OD7CMDGZ.js";
@@ -79,7 +79,7 @@ import {
79
79
  } from "./chunk-UJBW7FVI.js";
80
80
  import {
81
81
  targetConversationEvents
82
- } from "./chunk-LD3C7W3Q.js";
82
+ } from "./chunk-UCTFPC6X.js";
83
83
  import {
84
84
  configEntryLayers,
85
85
  ghFailure,
@@ -89,13 +89,21 @@ import {
89
89
  import {
90
90
  stripAnsi
91
91
  } from "./chunk-YJ72SXVD.js";
92
+ import {
93
+ insertRuleBullet,
94
+ nextRuleCode,
95
+ ruleBullet
96
+ } from "./chunk-3HNTLFII.js";
92
97
  import {
93
98
  readScopedRules
94
99
  } from "./chunk-W5FPQALS.js";
95
100
  import {
96
- findClaudeFiles
97
- } from "./chunk-IZZJUZZY.js";
101
+ findClaudeFiles,
102
+ updateScopedRulesIndex
103
+ } from "./chunk-I3TEQBTO.js";
98
104
  import {
105
+ RULE_BULLET,
106
+ contentLines,
99
107
  parseRulesSection,
100
108
  rulesSectionRange
101
109
  } from "./chunk-ADLCDG2V.js";
@@ -228,7 +236,7 @@ import {
228
236
  } from "./chunk-AOTNNZPH.js";
229
237
  import {
230
238
  rewindItemToPhase
231
- } from "./chunk-KFTPCHSO.js";
239
+ } from "./chunk-6W44RUSM.js";
232
240
  import {
233
241
  loadBacklogSummaries,
234
242
  searchBacklogSummaries
@@ -255,7 +263,7 @@ import {
255
263
  } from "./chunk-IZBQH3LW.js";
256
264
  import {
257
265
  resolveRewindPlan
258
- } from "./chunk-3OL7AV66.js";
266
+ } from "./chunk-B7VURMUV.js";
259
267
  import {
260
268
  deleteItem,
261
269
  getOrigin,
@@ -304,7 +312,7 @@ import {
304
312
  discoverSessionJsonlPaths,
305
313
  harnessAdapter,
306
314
  parseSessionFile
307
- } from "./chunk-2IH2A3JK.js";
315
+ } from "./chunk-43MJXI4R.js";
308
316
  import {
309
317
  harnessLabel
310
318
  } from "./chunk-DUNO7WBT.js";
@@ -398,10 +406,10 @@ function sweepStagedAttachments(dir = stagedAttachmentsDir, now = Date.now()) {
398
406
  }
399
407
  for (const name of entries2) {
400
408
  if (!name.startsWith("upload-")) continue;
401
- const path6 = join(dir, name);
409
+ const path7 = join(dir, name);
402
410
  try {
403
- if (now - statSync(path6).mtimeMs > PANE_PERSIST_TTL_MS)
404
- rmSync(path6, { recursive: true, force: true });
411
+ if (now - statSync(path7).mtimeMs > PANE_PERSIST_TTL_MS)
412
+ rmSync(path7, { recursive: true, force: true });
405
413
  } catch {
406
414
  }
407
415
  }
@@ -696,7 +704,7 @@ function createPendingReplies() {
696
704
  return entry;
697
705
  }
698
706
  return {
699
- send(ws, timeoutMs, write) {
707
+ send(ws, timeoutMs, write2) {
700
708
  const id = randomUUID();
701
709
  return new Promise((resolve3, reject) => {
702
710
  const timer = setTimeout(() => {
@@ -709,7 +717,7 @@ function createPendingReplies() {
709
717
  );
710
718
  }, timeoutMs);
711
719
  pending.set(id, { ws, timer, resolve: resolve3, reject });
712
- write(id);
720
+ write2(id);
713
721
  });
714
722
  },
715
723
  settle(id, reply) {
@@ -1740,8 +1748,8 @@ async function loadCommittedPaths(key, cwd, session) {
1740
1748
  for (const commit of commits) {
1741
1749
  const resolved2 = await resolveCommitCached(key, cwd, commit.sha);
1742
1750
  if (!resolved2) continue;
1743
- for (const path6 of resolved2.paths) {
1744
- if (!bases.has(path6)) bases.set(path6, resolved2.base);
1751
+ for (const path7 of resolved2.paths) {
1752
+ if (!bases.has(path7)) bases.set(path7, resolved2.base);
1745
1753
  }
1746
1754
  }
1747
1755
  return { commits, bases };
@@ -1787,16 +1795,16 @@ async function itemChangeSet(cwd, session) {
1787
1795
  }
1788
1796
  function groupByBase(bases) {
1789
1797
  const groups = /* @__PURE__ */ new Map();
1790
- for (const [path6, base] of bases) {
1798
+ for (const [path7, base] of bases) {
1791
1799
  const paths = groups.get(base);
1792
- if (paths) paths.push(path6);
1793
- else groups.set(base, [path6]);
1800
+ if (paths) paths.push(path7);
1801
+ else groups.set(base, [path7]);
1794
1802
  }
1795
1803
  return [...groups].map(([base, paths]) => ({ base, paths: paths.sort() }));
1796
1804
  }
1797
1805
  async function dirtyPaths(cwd, bases) {
1798
1806
  const output = await execGit(cwd, ["diff", "--name-only", "HEAD"]);
1799
- return output.split("\n").filter((path6) => path6 && !bases.has(path6)).sort();
1807
+ return output.split("\n").filter((path7) => path7 && !bases.has(path7)).sort();
1800
1808
  }
1801
1809
 
1802
1810
  // src/commands/sessions/web/scopedDiff.ts
@@ -1805,8 +1813,8 @@ async function scopedDiff(cwd, session, scope) {
1805
1813
  if (scope.kind === "commit") return commitDiff(cwd, scope.sha);
1806
1814
  return await trackedScopeDiff(cwd, session, scope) + await untrackedDiff(cwd);
1807
1815
  }
1808
- async function untrackedFileDiff(cwd, path6) {
1809
- return execGit(cwd, ["diff", "--no-index", "--", "/dev/null", path6], {
1816
+ async function untrackedFileDiff(cwd, path7) {
1817
+ return execGit(cwd, ["diff", "--no-index", "--", "/dev/null", path7], {
1810
1818
  maxBuffer: MAX_DIFF_BYTES,
1811
1819
  allowFailure: true
1812
1820
  });
@@ -1819,7 +1827,7 @@ async function untrackedDiff(cwd) {
1819
1827
  ]);
1820
1828
  const paths = list.split("\n").filter(Boolean);
1821
1829
  const diffs = await Promise.all(
1822
- paths.map((path6) => untrackedFileDiff(cwd, path6))
1830
+ paths.map((path7) => untrackedFileDiff(cwd, path7))
1823
1831
  );
1824
1832
  return diffs.join("");
1825
1833
  }
@@ -1982,8 +1990,8 @@ import { readFile, stat } from "fs/promises";
1982
1990
  // src/commands/sessions/web/fileContent/respondCommitFile.ts
1983
1991
  import { relative, sep } from "path";
1984
1992
  var MAX_FILE_BYTES = 2 * 1024 * 1024;
1985
- async function commitBlob(cwd, sha, path6) {
1986
- const line = await execGit(cwd, ["ls-tree", "-l", sha, "--", path6]);
1993
+ async function commitBlob(cwd, sha, path7) {
1994
+ const line = await execGit(cwd, ["ls-tree", "-l", sha, "--", path7]);
1987
1995
  const match = /^\d+ blob ([0-9a-f]+)\s+(\d+)\t/.exec(line);
1988
1996
  if (!match) return void 0;
1989
1997
  return { hash: match[1], size: Number(match[2]) };
@@ -1999,8 +2007,8 @@ async function respondCommitFile(req, res, { cwd, target }, commit) {
1999
2007
  respondJson(res, 400, { error: "Invalid commit" });
2000
2008
  return;
2001
2009
  }
2002
- const path6 = relative(cwd, target).split(sep).join("/");
2003
- const blob = await commitBlob(cwd, scope.sha, path6);
2010
+ const path7 = relative(cwd, target).split(sep).join("/");
2011
+ const blob = await commitBlob(cwd, scope.sha, path7);
2004
2012
  if (!blob) {
2005
2013
  respondJson(res, 404, { error: "File not found" });
2006
2014
  return;
@@ -2023,9 +2031,9 @@ import { isAbsolute, relative as relative2, resolve } from "path";
2023
2031
  function repoRoot(cwd) {
2024
2032
  return resolve(cwd);
2025
2033
  }
2026
- function resolveWithinCwd(cwd, path6) {
2034
+ function resolveWithinCwd(cwd, path7) {
2027
2035
  const root = repoRoot(cwd);
2028
- const target = resolve(root, path6);
2036
+ const target = resolve(root, path7);
2029
2037
  const rel = relative2(root, target);
2030
2038
  if (rel === "" || rel.startsWith("..") || isAbsolute(rel)) return null;
2031
2039
  return target;
@@ -2035,14 +2043,14 @@ function resolveWithinCwd(cwd, path6) {
2035
2043
  function getFileTarget(req, res) {
2036
2044
  const cwd = getCwdParam(req, res);
2037
2045
  if (!cwd) return null;
2038
- const path6 = new URL(req.url ?? "/", "http://localhost").searchParams.get(
2046
+ const path7 = new URL(req.url ?? "/", "http://localhost").searchParams.get(
2039
2047
  "path"
2040
2048
  );
2041
- if (!path6) {
2049
+ if (!path7) {
2042
2050
  respondJson(res, 400, { error: "Missing path" });
2043
2051
  return null;
2044
2052
  }
2045
- const target = resolveWithinCwd(cwd, path6);
2053
+ const target = resolveWithinCwd(cwd, path7);
2046
2054
  if (!target) {
2047
2055
  respondJson(res, 400, { error: "Path outside cwd" });
2048
2056
  return null;
@@ -2681,7 +2689,7 @@ function findSynthesisForBranch(repoReviewsDir, branch) {
2681
2689
  const parent = dirname(branchKeyPath);
2682
2690
  const branchPrefix = basename3(branchKeyPath);
2683
2691
  if (!existsSync4(parent)) return null;
2684
- const synthesisFiles = readdirSync5(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join5(parent, name, "synthesis.md")).filter((path6) => existsSync4(path6)).map((path6) => ({ path: path6, mtime: statSync3(path6).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
2692
+ const synthesisFiles = readdirSync5(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join5(parent, name, "synthesis.md")).filter((path7) => existsSync4(path7)).map((path7) => ({ path: path7, mtime: statSync3(path7).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
2685
2693
  return synthesisFiles[0]?.path ?? null;
2686
2694
  }
2687
2695
 
@@ -2711,12 +2719,12 @@ async function getReviewSynthesis(req, res) {
2711
2719
  const cwd = getCwdParam(req, res);
2712
2720
  if (!cwd) return;
2713
2721
  try {
2714
- const path6 = await resolveSynthesisPath(cwd);
2715
- if (!path6) {
2722
+ const path7 = await resolveSynthesisPath(cwd);
2723
+ if (!path7) {
2716
2724
  respondJson(res, 404, { error: "No synthesis found" });
2717
2725
  return;
2718
2726
  }
2719
- respondJson(res, 200, { synthesis: readFileSync(path6, "utf8") });
2727
+ respondJson(res, 200, { synthesis: readFileSync(path7, "utf8") });
2720
2728
  } catch {
2721
2729
  respondJson(res, 404, { error: "No synthesis found" });
2722
2730
  }
@@ -2729,19 +2737,19 @@ var execFileAsync4 = promisify4(execFile4);
2729
2737
  var MAX_FILE_BYTES2 = 2 * 1024 * 1024;
2730
2738
  var REPO = /^[\w.-]+\/[\w.-]+$/;
2731
2739
  var SHA = /^[0-9a-f]{7,40}$/i;
2732
- function validPath(path6) {
2733
- return path6.length > 0 && !path6.startsWith("/") && path6.split("/").every((part) => part !== "" && part !== "..");
2740
+ function validPath(path7) {
2741
+ return path7.length > 0 && !path7.startsWith("/") && path7.split("/").every((part) => part !== "" && part !== "..");
2734
2742
  }
2735
2743
  async function githubFileContent(req, res) {
2736
2744
  const params = new URL(req.url ?? "/", "http://localhost").searchParams;
2737
2745
  const repo = params.get("repo") ?? "";
2738
2746
  const sha = params.get("sha") ?? "";
2739
- const path6 = params.get("path") ?? "";
2740
- if (!REPO.test(repo) || !SHA.test(sha) || !validPath(path6)) {
2747
+ const path7 = params.get("path") ?? "";
2748
+ if (!REPO.test(repo) || !SHA.test(sha) || !validPath(path7)) {
2741
2749
  respondJson(res, 400, { error: "Invalid repo, sha or path" });
2742
2750
  return;
2743
2751
  }
2744
- const encodedPath = path6.split("/").map(encodeURIComponent).join("/");
2752
+ const encodedPath = path7.split("/").map(encodeURIComponent).join("/");
2745
2753
  try {
2746
2754
  const { stdout } = await execFileAsync4(
2747
2755
  "gh",
@@ -2836,8 +2844,8 @@ function parseDiffNameStatus(output) {
2836
2844
  if (!status || fields.length < 2) continue;
2837
2845
  const category = categorize(status[0]);
2838
2846
  if (!category) continue;
2839
- const path6 = fields[fields.length - 1];
2840
- if (path6) result[category].push(path6);
2847
+ const path7 = fields[fields.length - 1];
2848
+ if (path7) result[category].push(path7);
2841
2849
  }
2842
2850
  return result;
2843
2851
  }
@@ -2879,7 +2887,7 @@ async function headCommit3(cwd) {
2879
2887
  }
2880
2888
  async function dirtyItemContents(cwd, groups, uncommitted) {
2881
2889
  const dirty = /* @__PURE__ */ new Set([...uncommitted.modified, ...uncommitted.new]);
2882
- const paths = groups.flatMap((group) => group.paths).filter((path6) => dirty.has(path6));
2890
+ const paths = groups.flatMap((group) => group.paths).filter((path7) => dirty.has(path7));
2883
2891
  if (paths.length === 0) return "";
2884
2892
  try {
2885
2893
  return await execGit(cwd, ["hash-object", "--", ...paths]);
@@ -3373,11 +3381,11 @@ function logLinkedRequest(req, res) {
3373
3381
  const started = Date.now();
3374
3382
  const from = req.headers[LINKED_FROM_HEADER2];
3375
3383
  const trace = req.headers[TRACE_HEADER] ?? "none";
3376
- const path6 = new URL(req.url ?? "/", "http://localhost").pathname;
3384
+ const path7 = new URL(req.url ?? "/", "http://localhost").pathname;
3377
3385
  res.once("finish", () => {
3378
- if (isQuietPoll(path6, res.statusCode)) return;
3386
+ if (isQuietPoll(path7, res.statusCode)) return;
3379
3387
  console.log(
3380
- `link-from ${from} http: ${req.method} ${path6} trace=${trace} -> ${res.statusCode} (${Date.now() - started}ms)`
3388
+ `link-from ${from} http: ${req.method} ${path7} trace=${trace} -> ${res.statusCode} (${Date.now() - started}ms)`
3381
3389
  );
3382
3390
  });
3383
3391
  }
@@ -3794,21 +3802,21 @@ function subsequenceScore(text, query) {
3794
3802
  }
3795
3803
  return score - Math.min(text.length, MAX_LENGTH_PENALTY);
3796
3804
  }
3797
- function scoreFilePath(path6, query) {
3805
+ function scoreFilePath(path7, query) {
3798
3806
  const needle = query.trim().toLowerCase();
3799
3807
  if (!needle) return 0;
3800
- const basename6 = path6.slice(path6.lastIndexOf("/") + 1);
3808
+ const basename6 = path7.slice(path7.lastIndexOf("/") + 1);
3801
3809
  const inBasename = subsequenceScore(basename6, needle);
3802
3810
  if (inBasename !== null) return BASENAME_WEIGHT + inBasename;
3803
- return subsequenceScore(path6, needle);
3811
+ return subsequenceScore(path7, needle);
3804
3812
  }
3805
3813
 
3806
3814
  // src/commands/sessions/web/rankFilePaths.ts
3807
3815
  function rankFilePaths(paths, query, limit) {
3808
3816
  const scored = [];
3809
- for (const path6 of paths) {
3810
- const score = scoreFilePath(path6, query);
3811
- if (score !== null) scored.push({ path: path6, score });
3817
+ for (const path7 of paths) {
3818
+ const score = scoreFilePath(path7, query);
3819
+ if (score !== null) scored.push({ path: path7, score });
3812
3820
  }
3813
3821
  scored.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));
3814
3822
  return scored.slice(0, limit).map((entry) => entry.path);
@@ -4692,8 +4700,343 @@ async function getRuleScopes(req, res) {
4692
4700
  }
4693
4701
  }
4694
4702
 
4695
- // src/commands/sessions/web/listScopedRules.ts
4703
+ // src/commands/sessions/web/ruleChanges/pendingRuleChanges.ts
4704
+ var pendingRuleChanges = /* @__PURE__ */ new Map();
4705
+
4706
+ // src/commands/sessions/web/ruleChanges/listRuleChanges.ts
4707
+ function listRuleChanges(cwd) {
4708
+ return [...pendingRuleChanges.values()].filter((stored) => stored.cwd === cwd).map(({ cwd: _cwd, ...pending }) => pending);
4709
+ }
4710
+
4711
+ // src/commands/sessions/web/ruleChanges/getRuleChanges.ts
4712
+ function getRuleChanges(req, res) {
4713
+ const cwd = getCwdParam(req, res);
4714
+ if (cwd) respondJson(res, 200, { changes: listRuleChanges(cwd) });
4715
+ }
4716
+
4717
+ // src/commands/sessions/web/ruleChanges/parseRuleChange.ts
4718
+ function optionalString2(value) {
4719
+ return value === void 0 || typeof value === "string";
4720
+ }
4721
+ function parseRuleEntry(value) {
4722
+ const rule = value;
4723
+ if (typeof rule?.text !== "string") return void 0;
4724
+ if (!optionalString2(rule.code) || !optionalString2(rule.title))
4725
+ return void 0;
4726
+ return { code: rule.code, title: rule.title, text: rule.text };
4727
+ }
4728
+ function parseRuleChange(value) {
4729
+ const change = value;
4730
+ const rule = parseRuleEntry(change?.rule);
4731
+ if (!change || !rule || typeof change.scopeId !== "string") return void 0;
4732
+ const { scopeId } = change;
4733
+ if (change.kind === "delete") return { kind: "delete", scopeId, rule };
4734
+ if (change.kind !== "edit") return void 0;
4735
+ const { to, title, text } = change;
4736
+ if (typeof to !== "string" || typeof text !== "string") return void 0;
4737
+ if (!optionalString2(title)) return void 0;
4738
+ return { kind: "edit", scopeId, rule, to, title, text };
4739
+ }
4740
+
4741
+ // src/commands/sessions/web/ruleChanges/proposeRuleChange.ts
4742
+ import { randomUUID as randomUUID2 } from "crypto";
4743
+
4744
+ // src/commands/rules/ruleScopeLocation.ts
4696
4745
  import path3 from "path";
4746
+ var ADVICE_SCOPES = {
4747
+ "user-db": "User (db)",
4748
+ "user-node": "User (node)",
4749
+ "repo-db": "Repo (db)"
4750
+ };
4751
+ var CLAUDE_MD_PREFIX = "claude-md:";
4752
+ function ruleScopeLocation(scopeId, root) {
4753
+ if (scopeId in ADVICE_SCOPES) {
4754
+ const scope = scopeId;
4755
+ return { kind: "advice", scope, name: ADVICE_SCOPES[scope] };
4756
+ }
4757
+ if (!scopeId.startsWith(CLAUDE_MD_PREFIX)) return void 0;
4758
+ const dir = scopeId.slice(CLAUDE_MD_PREFIX.length);
4759
+ const file = path3.resolve(root, dir, "CLAUDE.md");
4760
+ const relative5 = path3.relative(root, file);
4761
+ if (relative5.startsWith("..") || path3.isAbsolute(relative5)) return void 0;
4762
+ return { kind: "claude-md", file, name: `${dir}CLAUDE.md` };
4763
+ }
4764
+
4765
+ // src/commands/rules/planRuleAddition.ts
4766
+ import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync } from "fs";
4767
+
4768
+ // src/commands/rules/readAdviceRules.ts
4769
+ async function readRaw(scope, cwd, globalConfigPath) {
4770
+ if (scope === "user-node") return loadGlobalConfigRaw(globalConfigPath);
4771
+ const orm = await getDb();
4772
+ if (scope === "user-db") return readUserConfig(orm);
4773
+ return (await resolveSharedRepoBlock(orm, void 0, cwd)).block;
4774
+ }
4775
+ async function readAdviceRules(scope, cwd, globalConfigPath) {
4776
+ const advice = (await readRaw(scope, cwd, globalConfigPath)).advice;
4777
+ return Array.isArray(advice?.rules) ? advice.rules : [];
4778
+ }
4779
+
4780
+ // src/commands/rules/writeAdviceRules.ts
4781
+ var KEY = "advice.rules";
4782
+ async function write(scope, rules, cwd, globalConfigPath) {
4783
+ if (scope === "user-db") return applyUserConfigSet(KEY, rules);
4784
+ if (scope === "repo-db")
4785
+ return applySharedRepoConfigSet(KEY, rules, void 0, cwd);
4786
+ return applyConfigSet(KEY, rules, true, cwd, globalConfigPath);
4787
+ }
4788
+ async function writeAdviceRules(scope, rules, cwd, globalConfigPath) {
4789
+ const result = await write(scope, rules, cwd, globalConfigPath);
4790
+ return result.ok ? void 0 : result.errors.join("\n");
4791
+ }
4792
+
4793
+ // src/commands/rules/planRuleAddition.ts
4794
+ async function planRuleAddition(location, rule, ctx) {
4795
+ const { root, cwd, globalConfigPath } = ctx;
4796
+ if (location.kind === "claude-md") {
4797
+ const { file } = location;
4798
+ if (!existsSync5(file))
4799
+ return { ok: false, error: `${location.name} does not exist` };
4800
+ const code = nextRuleCode(root);
4801
+ const after = insertRuleBullet(readFileSync3(file, "utf8"), {
4802
+ code,
4803
+ ...rule
4804
+ });
4805
+ return {
4806
+ ok: true,
4807
+ code,
4808
+ write: async () => {
4809
+ writeFileSync(file, after);
4810
+ return void 0;
4811
+ }
4812
+ };
4813
+ }
4814
+ const rules = await readAdviceRules(location.scope, cwd, globalConfigPath);
4815
+ const entry = { title: rule.title ?? "", text: rule.text };
4816
+ return {
4817
+ ok: true,
4818
+ write: () => writeAdviceRules(
4819
+ location.scope,
4820
+ [...rules, entry],
4821
+ cwd,
4822
+ globalConfigPath
4823
+ )
4824
+ };
4825
+ }
4826
+
4827
+ // src/commands/rules/changedSince.ts
4828
+ function changedSince(rule, name) {
4829
+ const label = rule.code ?? rule.title ?? rule.text;
4830
+ return {
4831
+ ok: false,
4832
+ error: `${label} in ${name} has changed since it was shown; reload the Rules page and try again`
4833
+ };
4834
+ }
4835
+
4836
+ // src/commands/rules/sameRuleText.ts
4837
+ function sameRuleText(a, b) {
4838
+ return (a.title ?? "") === (b.title ?? "") && a.text === b.text;
4839
+ }
4840
+
4841
+ // src/commands/rules/planClaudeMd.ts
4842
+ import { existsSync as existsSync6, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
4843
+
4844
+ // src/commands/rules/rewriteRuleBullet.ts
4845
+ function rewriteRuleBullet(content, code, replacement) {
4846
+ const lines = contentLines(content);
4847
+ const range = rulesSectionRange(lines);
4848
+ if (!range) return void 0;
4849
+ const index = lines.findIndex(
4850
+ (line, i) => i > range.start && i < range.end && RULE_BULLET.exec(line)?.[1].trim() === code
4851
+ );
4852
+ if (index === -1) return void 0;
4853
+ const next = [...lines];
4854
+ if (replacement !== void 0) next[index] = replacement;
4855
+ else {
4856
+ const blankAround = next[index - 1]?.trim() === "" && (next[index + 1] ?? "").trim() === "";
4857
+ next.splice(index, blankAround ? 2 : 1);
4858
+ }
4859
+ return `${next.join("\n").trimEnd()}
4860
+ `;
4861
+ }
4862
+
4863
+ // src/commands/rules/planClaudeMd.ts
4864
+ function planClaudeMd(file, name, rule, replacement) {
4865
+ const { code } = rule;
4866
+ if (!code) return { ok: false, error: `Rules in ${name} need a code` };
4867
+ const content = existsSync6(file) ? readFileSync4(file, "utf8") : "";
4868
+ const current2 = parseRulesSection(content).find((r) => r.code === code);
4869
+ if (!current2 || !sameRuleText(current2, rule)) return changedSince(rule, name);
4870
+ const after = rewriteRuleBullet(
4871
+ content,
4872
+ code,
4873
+ replacement && ruleBullet({ code, ...replacement })
4874
+ );
4875
+ if (after === void 0) return changedSince(rule, name);
4876
+ return {
4877
+ ok: true,
4878
+ write: async () => {
4879
+ writeFileSync2(file, after);
4880
+ return void 0;
4881
+ }
4882
+ };
4883
+ }
4884
+
4885
+ // src/commands/rules/planSourceUpdate.ts
4886
+ function isRuleText(value) {
4887
+ return typeof value?.text === "string";
4888
+ }
4889
+ async function planSourceUpdate(location, rule, replacement, ctx) {
4890
+ if (location.kind === "claude-md")
4891
+ return planClaudeMd(location.file, location.name, rule, replacement);
4892
+ const { cwd, globalConfigPath } = ctx;
4893
+ const rules = await readAdviceRules(location.scope, cwd, globalConfigPath);
4894
+ const index = rules.findIndex(
4895
+ (entry) => isRuleText(entry) && sameRuleText(entry, rule)
4896
+ );
4897
+ if (index === -1) return changedSince(rule, location.name);
4898
+ const next = replacement ? rules.map(
4899
+ (entry, i) => i === index ? { ...entry, ...replacement } : entry
4900
+ ) : rules.filter((_, i) => i !== index);
4901
+ return {
4902
+ ok: true,
4903
+ write: () => writeAdviceRules(location.scope, next, cwd, globalConfigPath)
4904
+ };
4905
+ }
4906
+
4907
+ // src/commands/rules/planWrites.ts
4908
+ async function planWrites(change, source, ctx) {
4909
+ if (change.kind === "delete")
4910
+ return [await planSourceUpdate(source, change.rule, void 0, ctx)];
4911
+ const target = change.to === change.scopeId ? source : ruleScopeLocation(change.to, ctx.root);
4912
+ if (!target) return `Unknown scope ${change.to}`;
4913
+ const error = editError(change, target);
4914
+ if (error) return error;
4915
+ const rule = {
4916
+ title: change.title?.trim() || void 0,
4917
+ text: change.text.trim()
4918
+ };
4919
+ if (target === source)
4920
+ return [await planSourceUpdate(source, change.rule, rule, ctx)];
4921
+ return [
4922
+ await planRuleAddition(target, rule, ctx),
4923
+ await planSourceUpdate(source, change.rule, void 0, ctx)
4924
+ ];
4925
+ }
4926
+ function editError(change, target) {
4927
+ if (change.text.trim() === "") return "Rule text is required";
4928
+ if (target.kind === "advice" && !change.title?.trim())
4929
+ return `Rules in ${target.name} need a title`;
4930
+ return void 0;
4931
+ }
4932
+
4933
+ // src/commands/rules/planRuleChange.ts
4934
+ async function planRuleChange(change, ctx) {
4935
+ const root = findRepoRoot(ctx.cwd) ?? ctx.cwd;
4936
+ const source = ruleScopeLocation(change.scopeId, root);
4937
+ if (!source) return { ok: false, error: `Unknown scope ${change.scopeId}` };
4938
+ const plans = await planWrites(change, source, { ...ctx, root });
4939
+ if (typeof plans === "string") return { ok: false, error: plans };
4940
+ const failed = plans.find((plan) => !plan.ok);
4941
+ if (failed && !failed.ok) return failed;
4942
+ const writes = plans.flatMap((plan) => plan.ok ? [plan.write] : []);
4943
+ const code = plans.flatMap(
4944
+ (plan) => plan.ok && plan.code ? [plan.code] : []
4945
+ )[0];
4946
+ const touchesClaudeMd = [
4947
+ change.scopeId,
4948
+ change.kind === "edit" ? change.to : ""
4949
+ ].some((id) => id.startsWith("claude-md:"));
4950
+ if (touchesClaudeMd)
4951
+ writes.push(async () => {
4952
+ updateScopedRulesIndex(root);
4953
+ return void 0;
4954
+ });
4955
+ return { ok: true, code, writes };
4956
+ }
4957
+
4958
+ // src/commands/sessions/web/ruleChanges/sameRuleTarget.ts
4959
+ function sameRuleTarget(a, b) {
4960
+ return a.scopeId === b.scopeId && a.rule.code === b.rule.code && a.rule.title === b.rule.title && a.rule.text === b.rule.text;
4961
+ }
4962
+
4963
+ // src/commands/sessions/web/ruleChanges/proposeRuleChange.ts
4964
+ async function proposeRuleChange(change, cwd, globalConfigPath = getGlobalConfigPath()) {
4965
+ const clash = [...pendingRuleChanges.values()].some(
4966
+ (stored) => stored.cwd === cwd && sameRuleTarget(stored.change, change)
4967
+ );
4968
+ if (clash)
4969
+ return {
4970
+ ok: false,
4971
+ error: "That rule already has a change awaiting approval"
4972
+ };
4973
+ const plan = await planRuleChange(change, { cwd, globalConfigPath });
4974
+ if (!plan.ok) return plan;
4975
+ const pending = {
4976
+ id: randomUUID2(),
4977
+ change,
4978
+ code: plan.code
4979
+ };
4980
+ pendingRuleChanges.set(pending.id, { ...pending, cwd });
4981
+ return { ok: true, pending };
4982
+ }
4983
+
4984
+ // src/commands/sessions/web/ruleChanges/readJsonObject.ts
4985
+ async function readJsonObject(req) {
4986
+ try {
4987
+ return await readJsonBody(req) ?? void 0;
4988
+ } catch {
4989
+ return void 0;
4990
+ }
4991
+ }
4992
+
4993
+ // src/commands/sessions/web/ruleChanges/postRuleChange.ts
4994
+ async function postRuleChange(req, res) {
4995
+ const body = await readJsonObject(req);
4996
+ const change = parseRuleChange(body?.change);
4997
+ if (typeof body?.cwd !== "string" || !body.cwd || !change)
4998
+ return respondJson(res, 400, { error: "Expected { cwd, change }" });
4999
+ const result = await proposeRuleChange(change, body.cwd);
5000
+ if (!result.ok) return respondJson(res, 409, { error: result.error });
5001
+ respondJson(res, 200, { change: result.pending });
5002
+ }
5003
+
5004
+ // src/commands/rules/applyRuleChange.ts
5005
+ async function applyRuleChange(change, cwd, globalConfigPath = getGlobalConfigPath()) {
5006
+ const plan = await planRuleChange(change, { cwd, globalConfigPath });
5007
+ if (!plan.ok) return plan;
5008
+ for (const write2 of plan.writes) {
5009
+ const error = await write2();
5010
+ if (error) return { ok: false, error };
5011
+ }
5012
+ return { ok: true, code: plan.code };
5013
+ }
5014
+
5015
+ // src/commands/sessions/web/ruleChanges/decideRuleChange.ts
5016
+ async function decideRuleChange(id, decision, globalConfigPath = getGlobalConfigPath()) {
5017
+ const stored = pendingRuleChanges.get(id);
5018
+ if (!stored)
5019
+ return { ok: false, error: "No such rule change awaiting approval" };
5020
+ pendingRuleChanges.delete(id);
5021
+ if (decision === "reject") return { ok: true };
5022
+ return applyRuleChange(stored.change, stored.cwd, globalConfigPath);
5023
+ }
5024
+
5025
+ // src/commands/sessions/web/ruleChanges/postRuleChangeDecision.ts
5026
+ async function postRuleChangeDecision(req, res) {
5027
+ const body = await readJsonObject(req);
5028
+ const { id, decision } = body ?? {};
5029
+ if (typeof id !== "string" || decision !== "approve" && decision !== "reject")
5030
+ return respondJson(res, 400, {
5031
+ error: 'Expected { id, decision: "approve" | "reject" }'
5032
+ });
5033
+ const result = await decideRuleChange(id, decision);
5034
+ if (!result.ok) return respondJson(res, 409, { error: result.error });
5035
+ respondJson(res, 200, result);
5036
+ }
5037
+
5038
+ // src/commands/sessions/web/listScopedRules.ts
5039
+ import path4 from "path";
4697
5040
  function listScopedRules(req, res) {
4698
5041
  const cwd = getCwdParam(req, res);
4699
5042
  if (!cwd) return;
@@ -4711,7 +5054,7 @@ function listScopedRules(req, res) {
4711
5054
  respondJson(res, 200, {
4712
5055
  rules: readScopedRules(target).map((rule) => ({
4713
5056
  ...rule,
4714
- source: path3.relative(root, rule.source) || rule.source
5057
+ source: path4.relative(root, rule.source) || rule.source
4715
5058
  }))
4716
5059
  });
4717
5060
  } catch {
@@ -4720,11 +5063,11 @@ function listScopedRules(req, res) {
4720
5063
  }
4721
5064
 
4722
5065
  // src/commands/sessions/web/slashCommands/listSlashCommands.ts
4723
- import path5 from "path";
5066
+ import path6 from "path";
4724
5067
 
4725
5068
  // src/commands/sessions/web/slashCommands/readSlashCommands.ts
4726
5069
  import fs from "fs";
4727
- import path4 from "path";
5070
+ import path5 from "path";
4728
5071
  function readEntries(dir) {
4729
5072
  try {
4730
5073
  return fs.readdirSync(dir, { withFileTypes: true });
@@ -4740,22 +5083,22 @@ function describe(file) {
4740
5083
  }
4741
5084
  }
4742
5085
  function readSkills(dir) {
4743
- return readEntries(dir).filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => path4.join(dir, entry.name, "SKILL.md")).filter((file) => fs.existsSync(file)).map((file) => ({
4744
- name: path4.basename(path4.dirname(file)),
5086
+ return readEntries(dir).filter((entry) => entry.isDirectory() || entry.isSymbolicLink()).map((entry) => path5.join(dir, entry.name, "SKILL.md")).filter((file) => fs.existsSync(file)).map((file) => ({
5087
+ name: path5.basename(path5.dirname(file)),
4745
5088
  description: describe(file)
4746
5089
  }));
4747
5090
  }
4748
5091
  function readCommands(dir) {
4749
5092
  return readEntries(dir).filter((entry) => !entry.isDirectory() && entry.name.endsWith(".md")).map((entry) => ({
4750
5093
  name: entry.name.slice(0, -".md".length),
4751
- description: describe(path4.join(dir, entry.name))
5094
+ description: describe(path5.join(dir, entry.name))
4752
5095
  }));
4753
5096
  }
4754
5097
  function readSlashCommands(home, scope) {
4755
5098
  const byName = /* @__PURE__ */ new Map();
4756
5099
  for (const command of [
4757
- ...readCommands(path4.join(home, "commands")),
4758
- ...readSkills(path4.join(home, "skills"))
5100
+ ...readCommands(path5.join(home, "commands")),
5101
+ ...readSkills(path5.join(home, "skills"))
4759
5102
  ])
4760
5103
  byName.set(command.name, { ...command, scope });
4761
5104
  return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
@@ -4765,7 +5108,7 @@ function readSlashCommands(home, scope) {
4765
5108
  function listSlashCommands(claudeHome, cwd) {
4766
5109
  const user = readSlashCommands(claudeHome, "user");
4767
5110
  const userNames = new Set(user.map((command) => command.name));
4768
- const project = readSlashCommands(path5.join(cwd, ".claude"), "project");
5111
+ const project = readSlashCommands(path6.join(cwd, ".claude"), "project");
4769
5112
  return [
4770
5113
  ...user,
4771
5114
  ...project.filter((command) => !userNames.has(command.name))
@@ -5176,22 +5519,22 @@ import { createReadStream } from "fs";
5176
5519
  import { stat as stat2 } from "fs/promises";
5177
5520
  async function previewImage(req, res) {
5178
5521
  const url = new URL(req.url ?? "/", "http://localhost");
5179
- const path6 = url.searchParams.get("path") ?? "";
5180
- if (!isStagedAttachmentPath(path6)) {
5522
+ const path7 = url.searchParams.get("path") ?? "";
5523
+ if (!isStagedAttachmentPath(path7)) {
5181
5524
  respondJson(res, 400, { error: "Not a staged attachment." });
5182
5525
  return;
5183
5526
  }
5184
- const info = await stat2(path6).catch(() => null);
5527
+ const info = await stat2(path7).catch(() => null);
5185
5528
  if (!info?.isFile()) {
5186
5529
  respondJson(res, 404, { error: "Attachment is no longer staged." });
5187
5530
  return;
5188
5531
  }
5189
5532
  res.writeHead(200, {
5190
- "Content-Type": attachmentContentType(path6),
5533
+ "Content-Type": attachmentContentType(path7),
5191
5534
  "Content-Length": info.size,
5192
5535
  "Cache-Control": "no-store"
5193
5536
  });
5194
- createReadStream(path6).pipe(res);
5537
+ createReadStream(path7).pipe(res);
5195
5538
  }
5196
5539
 
5197
5540
  // src/commands/sessions/web/getCurrentBranch.ts
@@ -5628,8 +5971,8 @@ async function liveDeployments(cwd, repo, environments) {
5628
5971
 
5629
5972
  // src/commands/sessions/web/releases/latestRun.ts
5630
5973
  async function latestRun(cwd, repo, workflow) {
5631
- const path6 = `repos/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs?per_page=1&exclude_pull_requests=true`;
5632
- const response = await ghJson(cwd, ["api", path6]);
5974
+ const path7 = `repos/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs?per_page=1&exclude_pull_requests=true`;
5975
+ const response = await ghJson(cwd, ["api", path7]);
5633
5976
  const run = response.workflow_runs?.[0];
5634
5977
  if (!run) return null;
5635
5978
  return {
@@ -5883,36 +6226,36 @@ import { relative as relative3 } from "path";
5883
6226
  function git(cwd, args) {
5884
6227
  return execGit(cwd, ["--literal-pathspecs", ...args]);
5885
6228
  }
5886
- async function isTracked(cwd, path6) {
6229
+ async function isTracked(cwd, path7) {
5887
6230
  try {
5888
- await git(cwd, ["ls-files", "--error-unmatch", "--", path6]);
6231
+ await git(cwd, ["ls-files", "--error-unmatch", "--", path7]);
5889
6232
  return true;
5890
6233
  } catch {
5891
6234
  return false;
5892
6235
  }
5893
6236
  }
5894
- async function isInHead(cwd, path6) {
5895
- const listing = await git(cwd, ["ls-tree", "HEAD", "--", path6]);
6237
+ async function isInHead(cwd, path7) {
6238
+ const listing = await git(cwd, ["ls-tree", "HEAD", "--", path7]);
5896
6239
  return listing.trim().length > 0;
5897
6240
  }
5898
- async function hasChanges(cwd, path6) {
6241
+ async function hasChanges(cwd, path7) {
5899
6242
  const status = await git(cwd, [
5900
6243
  "status",
5901
6244
  "--porcelain",
5902
6245
  "-z",
5903
6246
  "--untracked-files=all",
5904
6247
  "--",
5905
- path6
6248
+ path7
5906
6249
  ]);
5907
6250
  return status.length > 0;
5908
6251
  }
5909
- async function renameSources(cwd, path6) {
6252
+ async function renameSources(cwd, path7) {
5910
6253
  const fields = (await git(cwd, ["diff", "HEAD", "--name-status", "-z"])).split("\0");
5911
6254
  const sources = [];
5912
6255
  for (let i = 0; i < fields.length; ) {
5913
6256
  const status = fields[i];
5914
6257
  if (status.startsWith("R")) {
5915
- if (fields[i + 2] === path6) sources.push(fields[i + 1]);
6258
+ if (fields[i + 2] === path7) sources.push(fields[i + 1]);
5916
6259
  i += 3;
5917
6260
  } else {
5918
6261
  i += status.startsWith("C") ? 3 : 2;
@@ -5920,34 +6263,34 @@ async function renameSources(cwd, path6) {
5920
6263
  }
5921
6264
  return sources;
5922
6265
  }
5923
- async function restorePath(cwd, path6) {
5924
- if (await isInHead(cwd, path6)) {
5925
- await git(cwd, ["checkout", "HEAD", "--", path6]);
6266
+ async function restorePath(cwd, path7) {
6267
+ if (await isInHead(cwd, path7)) {
6268
+ await git(cwd, ["checkout", "HEAD", "--", path7]);
5926
6269
  return;
5927
6270
  }
5928
- if (await isTracked(cwd, path6)) {
5929
- await git(cwd, ["rm", "-f", "--", path6]);
6271
+ if (await isTracked(cwd, path7)) {
6272
+ await git(cwd, ["rm", "-f", "--", path7]);
5930
6273
  return;
5931
6274
  }
5932
- await git(cwd, ["clean", "-f", "--", path6]);
6275
+ await git(cwd, ["clean", "-f", "--", path7]);
5933
6276
  }
5934
- async function revertPathChanges(cwd, path6) {
5935
- if (!await hasChanges(cwd, path6))
5936
- throw new Error(`No uncommitted changes found for ${path6}`);
5937
- for (const target of [...await renameSources(cwd, path6), path6])
6277
+ async function revertPathChanges(cwd, path7) {
6278
+ if (!await hasChanges(cwd, path7))
6279
+ throw new Error(`No uncommitted changes found for ${path7}`);
6280
+ for (const target of [...await renameSources(cwd, path7), path7])
5938
6281
  await restorePath(cwd, target);
5939
- if (await hasChanges(cwd, path6))
5940
- throw new Error(`${path6} still has uncommitted changes`);
6282
+ if (await hasChanges(cwd, path7))
6283
+ throw new Error(`${path7} still has uncommitted changes`);
5941
6284
  }
5942
6285
 
5943
6286
  // src/commands/sessions/web/revertDiffFile.ts
5944
6287
  async function revertDiffFile(req, res) {
5945
6288
  const resolved2 = getFileTarget(req, res);
5946
6289
  if (!resolved2) return;
5947
- const path6 = relative3(repoRoot(resolved2.cwd), resolved2.target);
6290
+ const path7 = relative3(repoRoot(resolved2.cwd), resolved2.target);
5948
6291
  try {
5949
- await revertPathChanges(resolved2.cwd, path6);
5950
- respondJson(res, 200, { reverted: path6 });
6292
+ await revertPathChanges(resolved2.cwd, path7);
6293
+ respondJson(res, 200, { reverted: path7 });
5951
6294
  } catch (error) {
5952
6295
  respondJson(res, 500, {
5953
6296
  error: error instanceof Error ? error.message : "Failed to revert file"
@@ -5991,7 +6334,7 @@ import { relative as relative4 } from "path";
5991
6334
  function requestedPaths(body) {
5992
6335
  const paths = body.paths;
5993
6336
  if (!Array.isArray(paths)) return null;
5994
- if (paths.some((path6) => typeof path6 !== "string")) return null;
6337
+ if (paths.some((path7) => typeof path7 !== "string")) return null;
5995
6338
  return paths;
5996
6339
  }
5997
6340
  async function revertDiffPaths(req, res) {
@@ -6011,10 +6354,10 @@ async function revertDiffPaths(req, res) {
6011
6354
  const root = repoRoot(cwd);
6012
6355
  const reverted = [];
6013
6356
  const failed = [];
6014
- for (const path6 of paths) {
6015
- const target = resolveWithinCwd(cwd, path6);
6357
+ for (const path7 of paths) {
6358
+ const target = resolveWithinCwd(cwd, path7);
6016
6359
  if (!target) {
6017
- failed.push({ path: path6, error: "Path outside cwd" });
6360
+ failed.push({ path: path7, error: "Path outside cwd" });
6018
6361
  continue;
6019
6362
  }
6020
6363
  const relativePath = relative4(root, target);
@@ -6263,7 +6606,7 @@ async function postTestflightTester(req, res) {
6263
6606
  }
6264
6607
 
6265
6608
  // src/commands/config/applyDbBackedConfigWrite.ts
6266
- async function applyDbBackedConfigWrite(key, scope, write) {
6609
+ async function applyDbBackedConfigWrite(key, scope, write2) {
6267
6610
  const target = configScopeNames.user;
6268
6611
  if (scope !== "user")
6269
6612
  return {
@@ -6272,19 +6615,19 @@ async function applyDbBackedConfigWrite(key, scope, write) {
6272
6615
  };
6273
6616
  const handler = dbBackedConfigKeys[key];
6274
6617
  const db = await getDb();
6275
- if ("unset" in write)
6618
+ if ("unset" in write2)
6276
6619
  return {
6277
6620
  ok: true,
6278
6621
  payload: { target, removed: await handler.unset(db) }
6279
6622
  };
6280
- await handler.write(db, write.value);
6623
+ await handler.write(db, write2.value);
6281
6624
  return { ok: true, payload: { target } };
6282
6625
  }
6283
6626
 
6284
6627
  // src/shared/valueAtConfigPath.ts
6285
- function valueAtConfigPath(value, path6) {
6628
+ function valueAtConfigPath(value, path7) {
6286
6629
  let current2 = value;
6287
- for (const key of path6) {
6630
+ for (const key of path7) {
6288
6631
  if (typeof key === "number") {
6289
6632
  if (!Array.isArray(current2)) return void 0;
6290
6633
  current2 = current2[key];
@@ -6301,7 +6644,7 @@ function restoreConfigSecrets(value, stored, node) {
6301
6644
  return mapConfigSecrets(
6302
6645
  value,
6303
6646
  node,
6304
- (secret, path6) => isRedactedSecret(secret) ? valueAtConfigPath(stored, path6) : secret
6647
+ (secret, path7) => isRedactedSecret(secret) ? valueAtConfigPath(stored, path7) : secret
6305
6648
  );
6306
6649
  }
6307
6650
 
@@ -6410,8 +6753,8 @@ function seesApp(item, appId) {
6410
6753
  const linked = item.relationships?.visibleApps?.data;
6411
6754
  return Array.isArray(linked) && linked.some((app) => app.id === appId);
6412
6755
  }
6413
- async function listEmails(client, path6, type, emailAttribute, appId) {
6414
- const { data } = await client.get(path6, {
6756
+ async function listEmails(client, path7, type, emailAttribute, appId) {
6757
+ const { data } = await client.get(path7, {
6415
6758
  include: "visibleApps",
6416
6759
  [`fields[${type}]`]: `${emailAttribute},allAppsVisible,visibleApps`,
6417
6760
  "fields[apps]": "bundleId",
@@ -6602,7 +6945,7 @@ function latestSignedExtension(now = Date.now()) {
6602
6945
  }
6603
6946
 
6604
6947
  // src/commands/sessions/web/updates/changedSince.ts
6605
- function changedSince(installDir) {
6948
+ function changedSince2(installDir) {
6606
6949
  return (commit) => {
6607
6950
  try {
6608
6951
  return changedPaths(commit, installDir);
@@ -6618,14 +6961,14 @@ function restartTargets(paths) {
6618
6961
  }
6619
6962
 
6620
6963
  // src/commands/sessions/web/updates/pendingRestarts.ts
6621
- function targetsSince(commit, target, changedSince2) {
6622
- return commit !== void 0 && restartTargets(changedSince2(commit)).includes(target);
6964
+ function targetsSince(commit, target, changedSince3) {
6965
+ return commit !== void 0 && restartTargets(changedSince3(commit)).includes(target);
6623
6966
  }
6624
6967
  function pendingRestarts(input) {
6625
6968
  if (input.buildPending) return [];
6626
- const { daemonVersion, built, changedSince: changedSince2 } = input;
6627
- const daemon = daemonVersion !== void 0 && (built !== "unknown" && daemonVersion !== built || targetsSince(input.daemonStartCommit, "daemon", changedSince2));
6628
- const web2 = targetsSince(input.webStartCommit, "webserver", changedSince2);
6969
+ const { daemonVersion, built, changedSince: changedSince3 } = input;
6970
+ const daemon = daemonVersion !== void 0 && (built !== "unknown" && daemonVersion !== built || targetsSince(input.daemonStartCommit, "daemon", changedSince3));
6971
+ const web2 = targetsSince(input.webStartCommit, "webserver", changedSince3);
6629
6972
  return [
6630
6973
  ...daemon ? ["daemon"] : [],
6631
6974
  ...web2 ? ["webserver"] : []
@@ -6650,7 +6993,7 @@ async function readRestartState(installDir) {
6650
6993
  webStartCommit: webStartCommit.value(),
6651
6994
  built,
6652
6995
  buildPending,
6653
- changedSince: changedSince(installDir)
6996
+ changedSince: changedSince2(installDir)
6654
6997
  })
6655
6998
  };
6656
6999
  }
@@ -6719,13 +7062,13 @@ function updateHistory(_req, res) {
6719
7062
  }
6720
7063
 
6721
7064
  // src/commands/sessions/web/updates/requestViaLink.ts
6722
- import { randomUUID as randomUUID2 } from "crypto";
7065
+ import { randomUUID as randomUUID3 } from "crypto";
6723
7066
  var LINK_REPLY_TIMEOUT_MS = 8e3;
6724
7067
  function requestViaLink(req, type) {
6725
7068
  const url = new URL(req.url ?? "/", "http://localhost");
6726
7069
  const node = url.searchParams.get("node") ?? void 0;
6727
7070
  return requestDaemonReply(
6728
- { type, node, requestId: randomUUID2() },
7071
+ { type, node, requestId: randomUUID3() },
6729
7072
  type,
6730
7073
  LINK_REPLY_TIMEOUT_MS
6731
7074
  );
@@ -6824,7 +7167,7 @@ import { readFile as readFile2, stat as stat3, writeFile } from "fs/promises";
6824
7167
 
6825
7168
  // src/commands/sessions/web/formatWithOxfmt.ts
6826
7169
  import { execFile as execFile9 } from "child_process";
6827
- import { existsSync as existsSync5 } from "fs";
7170
+ import { existsSync as existsSync7 } from "fs";
6828
7171
  import { dirname as dirname2, join as join7 } from "path";
6829
7172
  import { promisify as promisify9 } from "util";
6830
7173
  var execFileAsync8 = promisify9(execFile9);
@@ -6833,7 +7176,7 @@ function findOxfmtScript(root) {
6833
7176
  let dir = root;
6834
7177
  for (; ; ) {
6835
7178
  const candidate = join7(dir, "node_modules", "oxfmt", "bin", "oxfmt");
6836
- if (existsSync5(candidate)) return candidate;
7179
+ if (existsSync7(candidate)) return candidate;
6837
7180
  const parent = dirname2(dir);
6838
7181
  if (parent === dir) return void 0;
6839
7182
  dir = parent;
@@ -6904,7 +7247,7 @@ async function writeFileContent(req, res) {
6904
7247
 
6905
7248
  // src/shared/createBundleHandler.ts
6906
7249
  import { createHash } from "crypto";
6907
- import { readFileSync as readFileSync3, statSync as statSync4 } from "fs";
7250
+ import { readFileSync as readFileSync5, statSync as statSync4 } from "fs";
6908
7251
  import { dirname as dirname3, join as join8 } from "path";
6909
7252
  import { fileURLToPath } from "url";
6910
7253
  function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
@@ -6913,7 +7256,7 @@ function createBundleHandler(importMetaUrl, bundlePath, contentType = "applicati
6913
7256
  return (req, res) => {
6914
7257
  const mtimeMs = statSync4(file).mtimeMs;
6915
7258
  if (cache5?.mtimeMs !== mtimeMs) {
6916
- const body = readFileSync3(file);
7259
+ const body = readFileSync5(file);
6917
7260
  const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
6918
7261
  cache5 = { body, etag, mtimeMs };
6919
7262
  }
@@ -6936,7 +7279,7 @@ function createBundleHandler(importMetaUrl, bundlePath, contentType = "applicati
6936
7279
 
6937
7280
  // src/commands/sessions/web/createCssHandler.ts
6938
7281
  import { createHash as createHash2 } from "crypto";
6939
- import { readFileSync as readFileSync4 } from "fs";
7282
+ import { readFileSync as readFileSync6 } from "fs";
6940
7283
  import { createRequire } from "module";
6941
7284
  var require2 = createRequire(import.meta.url);
6942
7285
  function createCssHandler(packageEntry) {
@@ -6944,7 +7287,7 @@ function createCssHandler(packageEntry) {
6944
7287
  return (req, res) => {
6945
7288
  if (!cache5) {
6946
7289
  const resolved2 = require2.resolve(packageEntry);
6947
- const body = readFileSync4(resolved2, "utf8");
7290
+ const body = readFileSync6(resolved2, "utf8");
6948
7291
  const etag = `"${createHash2("sha256").update(body).digest("hex").slice(0, 16)}"`;
6949
7292
  cache5 = { body, etag };
6950
7293
  }
@@ -7045,6 +7388,9 @@ var routes2 = {
7045
7388
  "GET /api/history/search": historySearch,
7046
7389
  "GET /api/rules": listScopedRules,
7047
7390
  "GET /api/rules/scopes": getRuleScopes,
7391
+ "GET /api/rules/changes": getRuleChanges,
7392
+ "POST /api/rules/changes": postRuleChange,
7393
+ "POST /api/rules/changes/decide": postRuleChangeDecision,
7048
7394
  "GET /api/slash-commands": slashCommands,
7049
7395
  "GET /api/jira-site": jiraSite,
7050
7396
  "GET /api/harness": harnessCapabilities,
@@ -7353,25 +7699,25 @@ function scheduleReconnect() {
7353
7699
  }
7354
7700
 
7355
7701
  // src/commands/sessions/web/updates/autoRestart/autoRestartAttempts.ts
7356
- import { mkdirSync, readFileSync as readFileSync5, writeFileSync } from "fs";
7702
+ import { mkdirSync, readFileSync as readFileSync7, writeFileSync as writeFileSync3 } from "fs";
7357
7703
  import { dirname as dirname4, join as join9 } from "path";
7358
7704
  var defaultPath = join9(daemonPaths.dir, "auto-restart-attempts.json");
7359
- function read(path6) {
7705
+ function read(path7) {
7360
7706
  try {
7361
- return JSON.parse(readFileSync5(path6, "utf8"));
7707
+ return JSON.parse(readFileSync7(path7, "utf8"));
7362
7708
  } catch {
7363
7709
  return {};
7364
7710
  }
7365
7711
  }
7366
- function autoRestartAttempts(port, path6 = defaultPath) {
7712
+ function autoRestartAttempts(port, path7 = defaultPath) {
7367
7713
  const key = String(port);
7368
7714
  return {
7369
- get: () => read(path6)[key],
7715
+ get: () => read(path7)[key],
7370
7716
  set: (built) => {
7371
- mkdirSync(dirname4(path6), { recursive: true });
7372
- writeFileSync(
7373
- path6,
7374
- `${JSON.stringify({ ...read(path6), [key]: built }, null, 2)}
7717
+ mkdirSync(dirname4(path7), { recursive: true });
7718
+ writeFileSync3(
7719
+ path7,
7720
+ `${JSON.stringify({ ...read(path7), [key]: built }, null, 2)}
7375
7721
  `
7376
7722
  );
7377
7723
  }