glimmervoid 0.52.2-next.719 → 0.52.2-next.721

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 (150) hide show
  1. package/dist/bin/glimmervoid.js +16 -16
  2. package/dist/chunks/{adapters-QeHAvLKT.js → adapters-C4VBHYHo.js} +6 -6
  3. package/dist/chunks/{adapters-Dvb7KXnO.js → adapters-C7CEI0fq.js} +1 -1
  4. package/dist/chunks/{agent-api-cli-CZPOzaRb.js → agent-api-cli-B571XTNc.js} +3 -3
  5. package/dist/chunks/agent-api-cli-DdnM_H4H.js +1 -0
  6. package/dist/chunks/{agent-api-core-B3qq8oek.js → agent-api-core-CvNwRgNZ.js} +3 -9
  7. package/dist/chunks/{agent-setup-cli-Dbwb7jtf.js → agent-setup-cli-DxlHDthm.js} +1 -1
  8. package/dist/chunks/{config-BdItI6F3.js → config-ClF7i8C6.js} +2 -2
  9. package/dist/chunks/{config-store-CHFS_vNw.js → config-store-201cn0A1.js} +4 -4
  10. package/dist/chunks/config-store-BrDX0ssT.js +1 -0
  11. package/dist/chunks/{grok-B_9N78_d.js → grok-kT9nCRev.js} +1 -1
  12. package/dist/chunks/kimi-CSCbrloe.js +1 -0
  13. package/dist/chunks/{kimi-YAqn6G1W.js → kimi-DJOALMiY.js} +2 -2
  14. package/dist/chunks/{main-BHMjdBfS.js → main-HIBk_nyb.js} +52 -30
  15. package/dist/chunks/pack-agent-BkxnZGft.js +432 -0
  16. package/dist/chunks/{pack-bridge-BgB2p-Hg.js → pack-bridge-CMzPKvPZ.js} +1 -1
  17. package/dist/chunks/{pack-agent-BY3gEwjx.js → pack-files-CKm6gcGR.js} +110 -573
  18. package/dist/chunks/{packs-cli-CjAfzj-I.js → packs-cli-ByiipDas.js} +6 -5
  19. package/dist/chunks/{pair-cli-BG4FUb5y.js → pair-cli-CDhWmGKV.js} +2 -2
  20. package/dist/chunks/{pr-flows-cli-D8Njf3EF.js → pr-flows-cli-QUMg7_Oz.js} +63 -37
  21. package/dist/chunks/{pr-flows-external-CaziHHty.js → pr-flows-external-QJdRYWnW.js} +10 -21
  22. package/dist/chunks/{remote-config-Dm7-_lHb.js → remote-config-eN6GelcO.js} +1 -1
  23. package/dist/chunks/{session-DC6dGYjf.js → session-C_EdlPyW.js} +35 -22
  24. package/dist/chunks/{settings-cli-C39NaAB1.js → settings-cli-D9dmhoSG.js} +5 -5
  25. package/dist/chunks/{settings-readout-core-CtligFID.js → settings-readout-core-87Ajew__.js} +2 -2
  26. package/dist/chunks/{spawn-env-aigWM-7F.js → spawn-env-_fjRJ34f.js} +3 -2
  27. package/dist/chunks/{ssh-sign-cli-DmT55jSe.js → ssh-sign-cli-Lh9uTM9h.js} +2 -2
  28. package/dist/chunks/{whiteboard-svg-core-tSYpbhy7.js → whiteboard-svg-core-D6_Clunv.js} +1 -1
  29. package/dist/client/assets/{action-status-CsphqLIp.js → action-status-57cP9fbP.js} +1 -1
  30. package/dist/client/assets/action-status-57cP9fbP.js.br +0 -0
  31. package/dist/client/assets/{arena-panel-Dwp8y2NZ.js → arena-panel-DBK3FOgW.js} +2 -2
  32. package/dist/client/assets/arena-panel-DBK3FOgW.js.br +0 -0
  33. package/dist/client/assets/{benchmark-panel-CYRs6njt.js → benchmark-panel-DzF5soM-.js} +1 -1
  34. package/dist/client/assets/benchmark-panel-DzF5soM-.js.br +0 -0
  35. package/dist/client/assets/{boards-view-BNqEed2T.js → boards-view-BD_SWx3l.js} +1 -1
  36. package/dist/client/assets/boards-view-BD_SWx3l.js.br +0 -0
  37. package/dist/client/assets/button-CVmKU9qL.js +1 -0
  38. package/dist/client/assets/button-CVmKU9qL.js.br +0 -0
  39. package/dist/client/assets/{card-actions-BF783lHX.js → card-actions-BNX4cQ22.js} +1 -1
  40. package/dist/client/assets/{card-registry-D_kyKNFR.js → card-registry-B2RFZmB2.js} +1 -1
  41. package/dist/client/assets/card-registry-B2RFZmB2.js.br +0 -0
  42. package/dist/client/assets/{community-panel-DS3UkApo.js → community-panel-BvMkWjmy.js} +1 -1
  43. package/dist/client/assets/community-panel-BvMkWjmy.js.br +0 -0
  44. package/dist/client/assets/{control-ws-BFTcI_Sk.js → control-ws-BpCKssAD.js} +1 -1
  45. package/dist/client/assets/control-ws-BpCKssAD.js.br +0 -0
  46. package/dist/client/assets/{dialogs-Cx0QONjF.js → dialogs-BA9rPYGx.js} +1 -1
  47. package/dist/client/assets/dialogs-BA9rPYGx.js.br +0 -0
  48. package/dist/client/assets/{doc-editor-ui-CQ-SsVYm.js → doc-editor-ui-njV-48Mt.js} +1 -1
  49. package/dist/client/assets/doc-editor-ui-njV-48Mt.js.br +0 -0
  50. package/dist/client/assets/{feature-hint-Bo_OZ6CQ.js → feature-hint-DT1NDTe-.js} +1 -1
  51. package/dist/client/assets/feature-hint-DT1NDTe-.js.br +0 -0
  52. package/dist/client/assets/{first-run-checklist-CZMpSceK.js → first-run-checklist-Dt8GFysX.js} +1 -1
  53. package/dist/client/assets/first-run-checklist-Dt8GFysX.js.br +0 -0
  54. package/dist/client/assets/{hooks-panel-D_WWcD6R.js → hooks-panel-B1SRjYyy.js} +1 -1
  55. package/dist/client/assets/hooks-panel-B1SRjYyy.js.br +0 -0
  56. package/dist/client/assets/{index-DuWDE9I2.js → index-D4HOaloI.js} +5 -5
  57. package/dist/client/assets/index-D4HOaloI.js.br +0 -0
  58. package/dist/client/assets/{issues-panel-D1qL_x0F.js → issues-panel-Cgckhdt0.js} +1 -1
  59. package/dist/client/assets/issues-panel-Cgckhdt0.js.br +0 -0
  60. package/dist/client/assets/{lane-read-token-step-bzSufW14.js → lane-read-token-step-DuSAEY-V.js} +1 -1
  61. package/dist/client/assets/lane-read-token-step-DuSAEY-V.js.br +0 -0
  62. package/dist/client/assets/{menu-YgFIqpxB.js → menu-CgH4aQPE.js} +1 -1
  63. package/dist/client/assets/menu-CgH4aQPE.js.br +0 -0
  64. package/dist/client/assets/{modal-CmB-mwt3.js → modal-DKFrxnH8.js} +1 -1
  65. package/dist/client/assets/modal-DKFrxnH8.js.br +0 -0
  66. package/dist/client/assets/{my-prs-panel-C_GmBrXA.js → my-prs-panel-D98hfuOw.js} +1 -1
  67. package/dist/client/assets/my-prs-panel-D98hfuOw.js.br +0 -0
  68. package/dist/client/assets/{nyan-cat-nQzxNUPN.js → nyan-cat-C1hMNKIf.js} +1 -1
  69. package/dist/client/assets/nyan-cat-C1hMNKIf.js.br +0 -0
  70. package/dist/client/assets/{phone-shell-qUdIewhB.js → phone-shell-DSKoMk_-.js} +1 -1
  71. package/dist/client/assets/phone-shell-DSKoMk_-.js.br +0 -0
  72. package/dist/client/assets/{plan-face-BD13Z8Nm.js → plan-face-DaeKVB_n.js} +1 -1
  73. package/dist/client/assets/plan-face-DaeKVB_n.js.br +0 -0
  74. package/dist/client/assets/{plan-render-BrxIi33z.js → plan-render-7BMe1GQQ.js} +1 -1
  75. package/dist/client/assets/plan-render-7BMe1GQQ.js.br +0 -0
  76. package/dist/client/assets/{pr-queue-columns-B5uPcvV4.js → pr-queue-columns-B9V9mLXw.js} +1 -1
  77. package/dist/client/assets/pr-queue-columns-B9V9mLXw.js.br +0 -0
  78. package/dist/client/assets/{pr-status-icon-C-44DKID.js → pr-status-icon-Bx6wInOj.js} +1 -1
  79. package/dist/client/assets/pr-status-icon-Bx6wInOj.js.br +0 -0
  80. package/dist/client/assets/{radar-panel-BWqCzwjR.js → radar-panel-F_mlKslB.js} +1 -1
  81. package/dist/client/assets/radar-panel-F_mlKslB.js.br +0 -0
  82. package/dist/client/assets/{repo-roots-adder-ByJ8XDCb.js → repo-roots-adder-DQQmm200.js} +1 -1
  83. package/dist/client/assets/repo-roots-adder-DQQmm200.js.br +0 -0
  84. package/dist/client/assets/{resume-dialog-q81xS4Fg.js → resume-dialog-CF4AwHD4.js} +1 -1
  85. package/dist/client/assets/resume-dialog-CF4AwHD4.js.br +0 -0
  86. package/dist/client/assets/{review-queue-panel-BBIesmKx.js → review-queue-panel-D-vbTvIc.js} +1 -1
  87. package/dist/client/assets/review-queue-panel-D-vbTvIc.js.br +0 -0
  88. package/dist/client/assets/{session-actions-D-XfZCX_.js → session-actions-Oqr5gh-y.js} +2 -2
  89. package/dist/client/assets/session-actions-Oqr5gh-y.js.br +0 -0
  90. package/dist/client/assets/{session-row-MJx4kfgA.js → session-row-BNMG0b7h.js} +1 -1
  91. package/dist/client/assets/session-row-BNMG0b7h.js.br +0 -0
  92. package/dist/client/assets/{session-tick-Cu958tSf.js → session-tick-CHJ0mY2-.js} +1 -1
  93. package/dist/client/assets/session-tick-CHJ0mY2-.js.br +0 -0
  94. package/dist/client/assets/{settings-panel-DVDMeuHO.js → settings-panel-BG7RfpWI.js} +2 -2
  95. package/dist/client/assets/settings-panel-BG7RfpWI.js.br +0 -0
  96. package/dist/client/assets/{setup-step-qMoYS0vS.js → setup-step-B8uQtgL-.js} +1 -1
  97. package/dist/client/assets/setup-step-B8uQtgL-.js.br +0 -0
  98. package/dist/client/assets/{trace-panel-CPRamHl5.js → trace-panel-DXuMaFQf.js} +1 -1
  99. package/dist/client/assets/trace-panel-DXuMaFQf.js.br +0 -0
  100. package/dist/client/assets/{usage-panel-DBHS_Yxm.js → usage-panel-DTeMQgAs.js} +1 -1
  101. package/dist/client/assets/usage-panel-DTeMQgAs.js.br +0 -0
  102. package/dist/client/assets/{your-day-tip-BRzwTD3I.js → your-day-tip-npG2dZYF.js} +1 -1
  103. package/dist/client/assets/your-day-tip-npG2dZYF.js.br +0 -0
  104. package/dist/client/index.html +12 -12
  105. package/dist/client/index.html.br +0 -0
  106. package/dist/schema/pack.v1.json +23 -11
  107. package/dist/server/index.js +1 -1
  108. package/package.json +1 -1
  109. package/dist/chunks/agent-api-cli-CqfBqnBN.js +0 -1
  110. package/dist/chunks/config-store-CoLRNzto.js +0 -1
  111. package/dist/chunks/kimi-_j4Imdso.js +0 -1
  112. package/dist/chunks/packs-cli-DE8O3Xt5.js +0 -1
  113. package/dist/client/assets/action-status-CsphqLIp.js.br +0 -0
  114. package/dist/client/assets/arena-panel-Dwp8y2NZ.js.br +0 -0
  115. package/dist/client/assets/benchmark-panel-CYRs6njt.js.br +0 -0
  116. package/dist/client/assets/boards-view-BNqEed2T.js.br +0 -0
  117. package/dist/client/assets/button-oL7ZznmQ.js +0 -1
  118. package/dist/client/assets/button-oL7ZznmQ.js.br +0 -0
  119. package/dist/client/assets/card-registry-D_kyKNFR.js.br +0 -0
  120. package/dist/client/assets/community-panel-DS3UkApo.js.br +0 -0
  121. package/dist/client/assets/control-ws-BFTcI_Sk.js.br +0 -0
  122. package/dist/client/assets/dialogs-Cx0QONjF.js.br +0 -0
  123. package/dist/client/assets/doc-editor-ui-CQ-SsVYm.js.br +0 -0
  124. package/dist/client/assets/feature-hint-Bo_OZ6CQ.js.br +0 -0
  125. package/dist/client/assets/first-run-checklist-CZMpSceK.js.br +0 -0
  126. package/dist/client/assets/hooks-panel-D_WWcD6R.js.br +0 -0
  127. package/dist/client/assets/index-DuWDE9I2.js.br +0 -0
  128. package/dist/client/assets/issues-panel-D1qL_x0F.js.br +0 -0
  129. package/dist/client/assets/lane-read-token-step-bzSufW14.js.br +0 -0
  130. package/dist/client/assets/menu-YgFIqpxB.js.br +0 -0
  131. package/dist/client/assets/modal-CmB-mwt3.js.br +0 -0
  132. package/dist/client/assets/my-prs-panel-C_GmBrXA.js.br +0 -0
  133. package/dist/client/assets/nyan-cat-nQzxNUPN.js.br +0 -0
  134. package/dist/client/assets/phone-shell-qUdIewhB.js.br +0 -0
  135. package/dist/client/assets/plan-face-BD13Z8Nm.js.br +0 -0
  136. package/dist/client/assets/plan-render-BrxIi33z.js.br +0 -0
  137. package/dist/client/assets/pr-queue-columns-B5uPcvV4.js.br +0 -4
  138. package/dist/client/assets/pr-status-icon-C-44DKID.js.br +0 -0
  139. package/dist/client/assets/radar-panel-BWqCzwjR.js.br +0 -0
  140. package/dist/client/assets/repo-roots-adder-ByJ8XDCb.js.br +0 -0
  141. package/dist/client/assets/resume-dialog-q81xS4Fg.js.br +0 -0
  142. package/dist/client/assets/review-queue-panel-BBIesmKx.js.br +0 -0
  143. package/dist/client/assets/session-actions-D-XfZCX_.js.br +0 -0
  144. package/dist/client/assets/session-row-MJx4kfgA.js.br +0 -0
  145. package/dist/client/assets/session-tick-Cu958tSf.js.br +0 -0
  146. package/dist/client/assets/settings-panel-DVDMeuHO.js.br +0 -0
  147. package/dist/client/assets/setup-step-qMoYS0vS.js.br +0 -0
  148. package/dist/client/assets/trace-panel-CPRamHl5.js.br +0 -0
  149. package/dist/client/assets/usage-panel-DBHS_Yxm.js.br +0 -0
  150. package/dist/client/assets/your-day-tip-BRzwTD3I.js.br +0 -0
@@ -1,41 +1,12 @@
1
1
  import { r as errorMessage } from "./text-DoirglWV.js";
2
- import { Cn as PrFlowPrAction, En as PrFlowSourceCommand, In as prFlowRulesJsonSchema, Nn as RepoScope, On as PrFlowsSettings, fn as PR_FLOW_PLACEHOLDERS_BY_KIND, gn as PrFlowCommand, wn as PrFlowRule, xn as PrFlowPackRequires, yn as PrFlowItemAction } from "./session-DC6dGYjf.js";
3
- import { i as ThemePalette, n as packBridgeJsonSchemaText, t as PackBridgeTopic } from "./pack-bridge-BgB2p-Hg.js";
2
+ import { Dn as PrFlowSourceCommand, Ln as prFlowRulesJsonSchema, Pn as RepoScope, Sn as PrFlowPackRequires, Tn as PrFlowRule, _n as PrFlowCommand, bn as PrFlowItemAction, fn as PR_FLOW_PLACEHOLDERS_BY_KIND, kn as PrFlowsSettings, pn as PackPrFlowRule, wn as PrFlowPrAction } from "./session-C_EdlPyW.js";
3
+ import { i as ThemePalette, t as PackBridgeTopic } from "./pack-bridge-CMzPKvPZ.js";
4
4
  import { t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
5
- import { n as withoutGlimmervoidSecrets } from "./spawn-env-aigWM-7F.js";
5
+ import { r as withoutGlimmervoidSecrets } from "./spawn-env-_fjRJ34f.js";
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { z } from "zod";
9
9
  import crypto from "node:crypto";
10
- //#region server/core/host-policy.ts
11
- var LOOPBACK_HOST_RE = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\]|\[::ffff:127(?:\.\d{1,3}){3}\])$/;
12
- function hostOnly(value) {
13
- const trimmed = String(value == null ? "" : value).trim().toLowerCase();
14
- if (trimmed === "") return "";
15
- if (trimmed.startsWith("[")) {
16
- const close = trimmed.indexOf("]");
17
- if (close === -1) return "";
18
- return trimmed.slice(0, close + 1);
19
- }
20
- const colon = trimmed.lastIndexOf(":");
21
- if (colon === -1) return trimmed;
22
- return trimmed.slice(0, colon);
23
- }
24
- function hostMatches(allowed, candidate) {
25
- if (allowed === "") return false;
26
- if (allowed === candidate) return true;
27
- if (!allowed.startsWith("*.")) return false;
28
- const suffix = allowed.slice(1);
29
- return candidate.endsWith(suffix) && candidate.length > suffix.length;
30
- }
31
- function decideHostAllowed(hostHeader, allowedHosts = []) {
32
- if (hostHeader == null || hostHeader === "") return true;
33
- const host = hostOnly(hostHeader);
34
- if (host === "") return false;
35
- if (LOOPBACK_HOST_RE.test(host)) return true;
36
- return (Array.isArray(allowedHosts) ? allowedHosts : [allowedHosts]).some((entry) => hostMatches(hostOnly(entry), host));
37
- }
38
- //#endregion
39
10
  //#region server/github/core/pr-flows-core.ts
40
11
  var MERGE_LINE_DISTANCE = 3;
41
12
  var BODY_PREFIX_CHARACTERS = 120;
@@ -69,19 +40,22 @@ function threadCandidates(threads) {
69
40
  function higherPriority(left, right) {
70
41
  return PRIORITY_RANK[right] < PRIORITY_RANK[left] ? right : left;
71
42
  }
72
- function dismissalKeyOf(sourceName, path, body) {
73
- return crypto.createHash("sha256").update(`${sourceName}\n${path}\n${normalizedBodyPrefix(body)}`).digest("hex").slice(0, 24);
43
+ function sourceIdentity(source) {
44
+ return source.sourceId ?? source.name;
45
+ }
46
+ function dismissalKeyOf(candidate) {
47
+ return crypto.createHash("sha256").update(`${sourceIdentity(candidate.source)}\n${candidate.path}\n${normalizedBodyPrefix(candidate.body)}`).digest("hex").slice(0, 24);
74
48
  }
75
49
  function sourceOf(candidate) {
76
50
  return {
77
51
  ...candidate.source,
78
52
  priority: candidate.priority,
79
53
  excerpt: candidate.body,
80
- dismissalKey: dismissalKeyOf(candidate.source.name, candidate.path, candidate.body)
54
+ dismissalKey: dismissalKeyOf(candidate)
81
55
  };
82
56
  }
83
57
  function itemOf(candidate) {
84
- const identity = candidate.source.threadId ?? `${candidate.source.kind}:${candidate.source.name}:${dismissalKeyOf(candidate.source.name, candidate.path, candidate.body)}`;
58
+ const identity = candidate.source.threadId ?? `${candidate.source.kind}:${sourceIdentity(candidate.source)}:${dismissalKeyOf(candidate)}`;
85
59
  return {
86
60
  key: `${candidate.path}:${candidate.lineStart ?? ""}:${identity}`,
87
61
  path: candidate.path,
@@ -252,26 +226,12 @@ function foldedRepoRules(repoRules, warnings) {
252
226
  } : entry), label, warnings);
253
227
  });
254
228
  }
255
- function prFlowRules(configFile) {
256
- const raw = ConfigFileWithPrFlows.safeParse(configFile).data?.prFlows;
257
- if (raw === void 0 || raw === null) return {
258
- rules: [],
259
- warnings: []
260
- };
261
- const settings = PrFlowsSettings.safeParse(raw);
262
- if (!settings.success) return {
263
- rules: [],
264
- warnings: [`prFlows was skipped: ${settings.error.issues[0]?.message ?? "invalid settings"}`]
265
- };
266
- const warnings = Object.keys(settings.data.repoRules ?? {}).length === 0 ? [] : [REPO_RULES_DEPRECATION];
267
- return {
268
- rules: [...foldedRepoRules(settings.data.repoRules ?? {}, warnings), ...parsedRuleList(settings.data.rules ?? [], "prFlows.rules", warnings)],
269
- warnings
270
- };
229
+ function isRepoListed(repos, repo) {
230
+ const wantedRepo = repo.toLowerCase();
231
+ return repos.some((listedRepo) => listedRepo.toLowerCase() === wantedRepo);
271
232
  }
272
233
  function scopedToRepo(entries, repo) {
273
- const wantedRepo = repo.toLowerCase();
274
- return entries.filter((entry) => entry.repos === void 0 || entry.repos.some((listedRepo) => listedRepo.toLowerCase() === wantedRepo));
234
+ return entries.filter((entry) => entry.repos === void 0 || isRepoListed(entry.repos, repo));
275
235
  }
276
236
  function parsedCommandList(schema, entries, label, warnings) {
277
237
  const seenIds = /* @__PURE__ */ new Set();
@@ -289,20 +249,27 @@ function parsedCommandList(schema, entries, label, warnings) {
289
249
  return [parsed.data];
290
250
  });
291
251
  }
292
- function prFlowCommands(configFile) {
252
+ var EMPTY_PR_FLOWS_CONFIG = {
253
+ sources: [],
254
+ actions: [],
255
+ prActions: [],
256
+ rules: [],
257
+ warnings: []
258
+ };
259
+ function prFlowsConfig(configFile) {
293
260
  const raw = ConfigFileWithPrFlows.safeParse(configFile).data?.prFlows;
294
- const settings = raw === void 0 || raw === null ? null : PrFlowsSettings.safeParse(raw).data;
295
- if (!settings) return {
296
- sources: [],
297
- actions: [],
298
- prActions: [],
299
- warnings: []
261
+ if (raw === void 0 || raw === null) return EMPTY_PR_FLOWS_CONFIG;
262
+ const settings = PrFlowsSettings.safeParse(raw);
263
+ if (!settings.success) return {
264
+ ...EMPTY_PR_FLOWS_CONFIG,
265
+ warnings: [`prFlows was skipped: ${settings.error.issues[0]?.message ?? "invalid settings"}`]
300
266
  };
301
- const warnings = [];
267
+ const warnings = Object.keys(settings.data.repoRules ?? {}).length === 0 ? [] : [REPO_RULES_DEPRECATION];
302
268
  return {
303
- sources: parsedCommandList(PrFlowSourceCommand, settings.sources ?? [], "prFlows.sources", warnings),
304
- actions: parsedCommandList(PrFlowCommand, settings.actions ?? [], "prFlows.actions", warnings),
305
- prActions: parsedCommandList(PrFlowPrAction, settings.prActions ?? [], "prFlows.prActions", warnings),
269
+ sources: parsedCommandList(PrFlowSourceCommand, settings.data.sources ?? [], "prFlows.sources", warnings),
270
+ actions: parsedCommandList(PrFlowCommand, settings.data.actions ?? [], "prFlows.actions", warnings),
271
+ prActions: parsedCommandList(PrFlowPrAction, settings.data.prActions ?? [], "prFlows.prActions", warnings),
272
+ rules: [...foldedRepoRules(settings.data.repoRules ?? {}, warnings), ...parsedRuleList(settings.data.rules ?? [], "prFlows.rules", warnings)],
306
273
  warnings
307
274
  };
308
275
  }
@@ -322,43 +289,39 @@ function commandFingerprint(kind, command) {
322
289
  return crypto.createHash("sha256").update(JSON.stringify(fingerprinted)).digest("hex");
323
290
  }
324
291
  var PACK_DIR_PLACEHOLDER = "{packDir}";
292
+ function packEntryId(packName, id) {
293
+ return `${packName}/${id}`;
294
+ }
325
295
  function packCommand(command, loaded) {
326
296
  return {
327
297
  ...command,
328
- id: `${loaded.header.name}/${command.id}`,
298
+ id: packEntryId(loaded.header.name, command.id),
329
299
  command: command.command.map((element) => element.replaceAll(PACK_DIR_PLACEHOLDER, loaded.dir))
330
300
  };
331
301
  }
302
+ function narrowedRepos(entryRepos, packRepos) {
303
+ if (packRepos === void 0) return entryRepos;
304
+ if (entryRepos === void 0) return packRepos;
305
+ return entryRepos.filter((repo) => isRepoListed(packRepos, repo));
306
+ }
332
307
  function withPackRepos(entry, packRepos) {
333
- const repos = entry.repos ?? packRepos;
308
+ const repos = narrowedRepos(entry.repos, packRepos);
334
309
  return repos === void 0 ? entry : {
335
310
  ...entry,
336
311
  repos
337
312
  };
338
313
  }
339
- function packQualified(packName, id) {
340
- return id.startsWith(`${packName}/`) ? id : `${packName}/${id}`;
341
- }
342
- function packSourceRef(ruleSource, packName, sources) {
343
- return sources.some((source) => source.id === ruleSource) ? `${packName}/${ruleSource}` : ruleSource;
344
- }
345
- function packRule(rule, { header, prFlows }) {
346
- const repoScopedRule = withPackRepos(rule, prFlows.repos);
347
- const scopedRule = repoScopedRule.source === void 0 ? repoScopedRule : {
348
- ...repoScopedRule,
349
- source: packSourceRef(repoScopedRule.source, header.name, prFlows.sources)
350
- };
351
- if (!scopedRule.action.startsWith("run:")) return scopedRule;
314
+ function packRule(rule, packName, packRepos) {
315
+ const { sources, action, ...rest } = withPackRepos(rule, packRepos);
316
+ const packAction = action.startsWith("run:") ? `run:${packEntryId(packName, action.slice(4))}` : action;
352
317
  return {
353
- ...scopedRule,
354
- action: `run:${packQualified(header.name, scopedRule.action.slice(4))}`
318
+ ...rest,
319
+ ...sources === void 0 ? {} : { sources: sources.map((sourceId) => packEntryId(packName, sourceId)) },
320
+ action: packAction
355
321
  };
356
322
  }
357
323
  function packRuleText(rule, prFlowsPack) {
358
- const { name, ...matchAndAction } = packRule(rule, {
359
- header: prFlowsPack.loaded.header,
360
- prFlows: prFlowsPack.section
361
- });
324
+ const { name, ...matchAndAction } = packRule(rule, prFlowsPack.loaded.header.name, prFlowsPack.section.repos);
362
325
  return `${name}: ${JSON.stringify(matchAndAction)}`;
363
326
  }
364
327
  function packCommands({ loaded, section }) {
@@ -432,8 +395,7 @@ function prFlowsPacksOf(packs) {
432
395
  warnings
433
396
  };
434
397
  }
435
- function prFlowSetup(configFile, approvedPackLoad, approvedFingerprints) {
436
- const personal = prFlowCommands(configFile);
398
+ function prFlowSetup(personal, approvedPackLoad, approvedFingerprints) {
437
399
  const approved = new Set(approvedFingerprints);
438
400
  const { prFlowsPacks: approvedPacks, warnings: sectionWarnings } = prFlowsPacksOf(approvedPackLoad.packs);
439
401
  const approvals = pendingApprovals(personal, approved);
@@ -441,10 +403,13 @@ function prFlowSetup(configFile, approvedPackLoad, approvedFingerprints) {
441
403
  const offNotes = approvedPacks.filter(({ loaded }) => loaded.missingRequires.length > 0).map(({ loaded }) => `The pack '${loaded.header.name}' is off until this machine has ${loaded.missingRequires.join(", ")}`);
442
404
  const enabledCommands = enabledPacks.map(packCommands);
443
405
  for (const { kind, command } of enabledCommands.flatMap(kindedCommands)) approved.add(commandFingerprint(kind, command));
406
+ const actions = [...personal.actions, ...enabledCommands.flatMap((commands) => commands.actions)];
407
+ const rules = [...personal.rules, ...enabledPacks.flatMap(({ loaded, section }) => section.rules.map((rule) => packRule(rule, loaded.header.name, section.repos)))];
408
+ const sources = [...personal.sources, ...enabledCommands.flatMap((commands) => commands.sources)];
444
409
  return {
445
410
  commands: {
446
- sources: [...personal.sources, ...enabledCommands.flatMap((commands) => commands.sources)],
447
- actions: [...personal.actions, ...enabledCommands.flatMap((commands) => commands.actions)],
411
+ sources,
412
+ actions,
448
413
  prActions: [...personal.prActions, ...enabledCommands.flatMap((commands) => commands.prActions)],
449
414
  warnings: [
450
415
  ...personal.warnings,
@@ -455,10 +420,8 @@ function prFlowSetup(configFile, approvedPackLoad, approvedFingerprints) {
455
420
  },
456
421
  approved,
457
422
  approvals,
458
- packRules: enabledPacks.flatMap(({ loaded, section }) => section.rules.map((rule) => packRule(rule, {
459
- header: loaded.header,
460
- prFlows: section
461
- })))
423
+ rules,
424
+ ruleWarnings: [...unknownActionWarnings(rules, new Set(actions.map((action) => action.id))), ...unknownSourceWarnings(rules, new Set(sources.map((source) => source.id)))]
462
425
  };
463
426
  }
464
427
  var ConfigFileWithPacks = z.looseObject({ packs: z.array(z.string().min(1)).optional().catch(void 0) });
@@ -494,6 +457,17 @@ function pendingApprovals(commands, approvedFingerprints) {
494
457
  }];
495
458
  });
496
459
  }
460
+ function unknownPlaceholderMessage(kind, name) {
461
+ return `{${name}} is not a placeholder of a ${kind}; use ${PR_FLOW_PLACEHOLDERS_BY_KIND[kind].map((placeholderName) => `{${placeholderName}}`).join(", ")}`;
462
+ }
463
+ function sourcePlaceholderValues(pr) {
464
+ return {
465
+ prUrl: pr.url,
466
+ repo: pr.repo,
467
+ number: String(pr.number),
468
+ head: pr.headRefOid
469
+ };
470
+ }
497
471
  function prActionPlaceholderValues(pr) {
498
472
  return {
499
473
  prUrl: pr.url,
@@ -602,7 +576,7 @@ function expandPlaceholders(argv, values) {
602
576
  argv: argv.map((element) => element.replace(PLACEHOLDER_PATTERN, (_match, name) => values[name] ?? ""))
603
577
  };
604
578
  }
605
- function sourceCandidates(label, findings, sourceId) {
579
+ function sourceCandidates(source, findings) {
606
580
  return findings.map((finding) => ({
607
581
  path: finding.path,
608
582
  lineStart: finding.lineStart,
@@ -610,8 +584,8 @@ function sourceCandidates(label, findings, sourceId) {
610
584
  priority: finding.priority,
611
585
  source: {
612
586
  kind: "configured",
613
- name: label,
614
- ...sourceId === void 0 ? {} : { sourceId },
587
+ name: source.label,
588
+ sourceId: source.id,
615
589
  url: finding.url
616
590
  },
617
591
  body: finding.body,
@@ -621,12 +595,14 @@ function sourceCandidates(label, findings, sourceId) {
621
595
  function isPathCovered(path, rulePaths) {
622
596
  return rulePaths.some((rulePath) => path === rulePath || rulePath.endsWith("/") && path.startsWith(rulePath));
623
597
  }
624
- function isNamedSource(ruleSource, source) {
625
- if (ruleSource.includes("/")) return source.sourceId === ruleSource;
626
- return source.name === ruleSource;
598
+ function isListedSource(rule, source) {
599
+ if (rule.sources === void 0 && rule.authors === void 0) return true;
600
+ if (source.kind === "configured") return source.sourceId !== void 0 && (rule.sources?.includes(source.sourceId) ?? false);
601
+ const author = source.name.toLowerCase();
602
+ return rule.authors?.some((listedAuthor) => listedAuthor.toLowerCase() === author) ?? false;
627
603
  }
628
604
  function ruleMatchesSource(rule, source) {
629
- if (rule.source !== void 0 && !isNamedSource(rule.source, source)) return false;
605
+ if (!isListedSource(rule, source)) return false;
630
606
  if (rule.priority !== void 0 && !rule.priority.includes(source.priority ?? "unknown")) return false;
631
607
  const ruleText = rule.text?.toLowerCase();
632
608
  return ruleText === void 0 || source.excerpt.toLowerCase().includes(ruleText);
@@ -670,20 +646,22 @@ function unknownActionWarnings(rules, actionIds) {
670
646
  return [`Rule '${rule.name}' names ${rule.action}, which no entry in prFlows.actions defines, so its items wait for you.`];
671
647
  });
672
648
  }
649
+ function unknownSourceWarnings(rules, sourceIds) {
650
+ return rules.flatMap((rule) => (rule.sources ?? []).filter((sourceId) => !sourceIds.has(sourceId)).map((sourceId) => `Rule '${rule.name}' names the source '${sourceId}', which no entry in prFlows.sources or an enabled pack defines, so it never acts on that source.`));
651
+ }
673
652
  function reposOutside(repos, allowed) {
674
- const allowedLowercase = new Set(allowed.map((repo) => repo.toLowerCase()));
675
- return repos.filter((repo) => !allowedLowercase.has(repo.toLowerCase()));
653
+ return repos.filter((repo) => !isRepoListed(allowed, repo));
676
654
  }
677
- function widenedEntryNotes(section, packName) {
655
+ function entryReposOutsidePack(section, packName) {
678
656
  const packRepos = section.repos;
679
657
  if (packRepos === void 0) return [];
680
658
  return [
681
659
  ...section.prActions.map((entry) => ({
682
- title: `The prAction ${packName}/${entry.id}`,
660
+ title: `The prAction ${packEntryId(packName, entry.id)}`,
683
661
  repos: entry.repos
684
662
  })),
685
663
  ...section.sources.map((entry) => ({
686
- title: `The source ${packName}/${entry.id}`,
664
+ title: `The source ${packEntryId(packName, entry.id)}`,
687
665
  repos: entry.repos
688
666
  })),
689
667
  ...section.rules.map((entry) => ({
@@ -693,68 +671,26 @@ function widenedEntryNotes(section, packName) {
693
671
  ].flatMap(({ title, repos }) => {
694
672
  const outside = reposOutside(repos ?? [], packRepos);
695
673
  if (outside.length === 0) return [];
696
- return [`${title} reaches outside prFlows.repos to ${outside.join(", ")}, since an entry's own repos replace the pack default.`];
674
+ return [`${title} lists ${outside.join(", ")}, which prFlows.repos does not list, so it never reaches ${outside.length === 1 ? "it" : "them"}.`];
697
675
  });
698
676
  }
699
- function unknownSourceProblems(ruleName, ruleSource, packName, elsewhere) {
700
- if (ruleSource.startsWith(`${packName}/`)) return {
701
- errors: [`Rule '${ruleName}' names the source '${ruleSource}', which no source of this pack defines, so it never acts.`],
702
- notes: []
703
- };
704
- if (ruleSource.includes("/")) return {
705
- errors: [],
706
- notes: [`Rule '${ruleName}' names the source '${ruleSource}', which is no source of this pack, so it matches only the source with that id from another pack, and never acts while that pack is off.`]
707
- };
708
- return {
709
- errors: [],
710
- notes: [`Rule '${ruleName}' names the source '${ruleSource}', which is no source of this pack, so it matches only ${elsewhere}.`]
711
- };
712
- }
713
- function ruleSourceProblems(rule, section, packName) {
714
- if (rule.source === void 0) return {
715
- errors: [],
716
- notes: []
717
- };
718
- const elsewhere = "a source of that label from config.json or another pack, or review comments by a GitHub account of that name";
719
- const labelledSources = section.sources.filter((candidate) => candidate.label === rule.source);
720
- const namedSources = labelledSources.length > 0 ? labelledSources : section.sources.filter((candidate) => `${packName}/${candidate.id}` === rule.source);
721
- if (namedSources.length === 0) return unknownSourceProblems(rule.name, rule.source, packName, elsewhere);
722
- const sourceRepoLists = namedSources.map((source) => source.repos ?? section.repos);
723
- if (rule.repos === void 0 || sourceRepoLists.some((repos) => repos === void 0)) return {
724
- errors: [],
725
- notes: []
726
- };
727
- const sourceRepos = [...new Set(sourceRepoLists.flatMap((repos) => repos ?? []))];
728
- const reposWithoutSource = reposOutside(rule.repos, sourceRepos);
729
- if (reposWithoutSource.length === 0) return {
730
- errors: [],
731
- notes: []
732
- };
733
- const mismatch = `Rule '${rule.name}' is limited to ${rule.repos.join(", ")}, but this pack's source '${rule.source}' runs only on ${sourceRepos.join(", ")}`;
734
- const neverMeetsSource = new Set(reposWithoutSource.map((repo) => repo.toLowerCase())).size === new Set(rule.repos.map((repo) => repo.toLowerCase())).size;
735
- if (labelledSources.length === 0 && neverMeetsSource) return {
736
- errors: [`${mismatch}, so the rule never acts.`],
737
- notes: []
738
- };
739
- if (labelledSources.length === 0) return {
740
- errors: [],
741
- notes: [`${mismatch}, so on ${reposWithoutSource.join(", ")} the rule never acts.`]
742
- };
743
- return {
744
- errors: [],
745
- notes: [`${mismatch}, so on ${reposWithoutSource.join(", ")} the rule matches only ${elsewhere}.`]
746
- };
747
- }
748
- function packRuleChecks(section, packName) {
749
- const resolvedRules = section.rules.map((rule) => packRule(rule, {
750
- header: { name: packName },
751
- prFlows: section
752
- }));
753
- const sourceProblems = resolvedRules.map((rule) => ruleSourceProblems(rule, section, packName));
754
- return {
755
- errors: [...unknownActionWarnings(resolvedRules, new Set(section.actions.map((action) => `${packName}/${action.id}`))), ...sourceProblems.flatMap((problems) => problems.errors)],
756
- notes: [...widenedEntryNotes(section, packName), ...sourceProblems.flatMap((problems) => problems.notes)]
757
- };
677
+ function ruleSourceErrors(rule, section) {
678
+ if (rule.sources === void 0) return [];
679
+ const namedSources = section.sources.filter((source) => rule.sources?.includes(source.id));
680
+ const unknownErrors = rule.sources.filter((sourceId) => !namedSources.some((source) => source.id === sourceId)).map((sourceId) => `Rule '${rule.name}' names the source '${sourceId}', which no source of this pack defines, so it never acts on it.`);
681
+ const ruleRepos = narrowedRepos(rule.repos, section.repos);
682
+ const sourceRepoLists = namedSources.map((source) => narrowedRepos(source.repos, section.repos));
683
+ if (ruleRepos === void 0 || namedSources.length === 0 || sourceRepoLists.some((repos) => repos === void 0)) return unknownErrors;
684
+ const sourceRepos = sourceRepoLists.flatMap((repos) => repos ?? []);
685
+ if (ruleRepos.some((repo) => isRepoListed(sourceRepos, repo))) return unknownErrors;
686
+ return [...unknownErrors, `Rule '${rule.name}' is limited to ${ruleRepos.join(", ") || "no repository"}, but its sources run only on ${[...new Set(sourceRepos)].join(", ") || "no repository"}, so it never acts.`];
687
+ }
688
+ function packRuleErrors(section, packName) {
689
+ return [
690
+ ...unknownActionWarnings(section.rules.map((rule) => packRule(rule, packName, section.repos)), new Set(section.actions.map((action) => packEntryId(packName, action.id)))),
691
+ ...section.rules.flatMap((rule) => ruleSourceErrors(rule, section)),
692
+ ...entryReposOutsidePack(section, packName)
693
+ ];
758
694
  }
759
695
  function shouldTellBranchMoved(run, headNow, nowMs, windowMs) {
760
696
  if (headNow === run.headAtStart) return false;
@@ -765,10 +701,12 @@ function branchMovedNote(prUrl, actionLabels, headNow) {
765
701
  }
766
702
  var RULE_NAME_MAX_CHARACTERS = 80;
767
703
  function savedRuleFor(item, repo, reason) {
768
- const sourceName = item.sources[0]?.name ?? "unknown source";
704
+ const sourceIds = [...new Set(item.sources.flatMap((source) => source.kind === "configured" && source.sourceId !== void 0 ? [source.sourceId] : []))];
705
+ const authors = [...new Set(item.sources.flatMap((source) => source.kind === "configured" ? [] : [source.name]))];
769
706
  return {
770
- name: [...`Dismiss ${sourceName} on ${item.path || "the pull request"}`].slice(0, RULE_NAME_MAX_CHARACTERS).join(""),
771
- source: sourceName,
707
+ name: [...`Dismiss ${[...new Set(item.sources.map((source) => source.name))].join(", ")} on ${item.path || "the pull request"}`].slice(0, RULE_NAME_MAX_CHARACTERS).join(""),
708
+ ...sourceIds.length === 0 ? {} : { sources: sourceIds },
709
+ ...authors.length === 0 ? {} : { authors },
772
710
  ...item.path ? { paths: [item.path] } : {},
773
711
  scope: "mine",
774
712
  repos: [repo],
@@ -786,241 +724,6 @@ function fixLocallyPrompt(prUrl, item, fence) {
786
724
  ].join("\n\n");
787
725
  }
788
726
  //#endregion
789
- //#region server/packs/core/pack-core.ts
790
- function packNeeds(pack) {
791
- return [...pack.header.requires.env.map((name) => `env ${name}`), ...pack.header.requires.programs.map((program) => `program ${program}`)];
792
- }
793
- function packThemes(pack) {
794
- return pack.ui?.ok ? pack.ui.value.themes : [];
795
- }
796
- function approvedPackThemes(packs) {
797
- return packs.flatMap((pack) => packThemes(pack).map(({ id, ...palette }) => ({
798
- id: `${pack.header.name}/${id}`,
799
- palette
800
- })));
801
- }
802
- function packPanels(pack) {
803
- return pack.ui?.ok ? pack.ui.value.panels : [];
804
- }
805
- function packFileUrl(pack, accessKey, filePath) {
806
- return `/packs/${encodeURIComponent(pack.header.name)}/${accessKey}/files/${filePath.split("/").map(encodeURIComponent).join("/")}`;
807
- }
808
- function approvedPackPanels(packs, accessKeyOf) {
809
- return packs.flatMap((pack) => packPanels(pack).map((panel) => ({
810
- viewId: `pack:${pack.header.name}/${panel.id}`,
811
- label: panel.label,
812
- entryUrl: packFileUrl(pack, accessKeyOf(pack), panel.entry),
813
- iconUrl: panel.icon ? packFileUrl(pack, accessKeyOf(pack), panel.icon) : null,
814
- reads: panel.reads
815
- })));
816
- }
817
- var PACK_FILE_MIME_BY_EXTENSION = {
818
- ".html": "text/html; charset=utf-8",
819
- ".js": "text/javascript; charset=utf-8",
820
- ".mjs": "text/javascript; charset=utf-8",
821
- ".css": "text/css; charset=utf-8",
822
- ".json": "application/json; charset=utf-8",
823
- ".svg": "image/svg+xml",
824
- ".png": "image/png",
825
- ".jpg": "image/jpeg",
826
- ".jpeg": "image/jpeg",
827
- ".gif": "image/gif",
828
- ".webp": "image/webp",
829
- ".woff2": "font/woff2",
830
- ".txt": "text/plain; charset=utf-8"
831
- };
832
- var PACK_PANEL_CONTENT_POLICY = [
833
- "sandbox allow-scripts allow-forms",
834
- "default-src 'self' data: blob:",
835
- "script-src 'self' 'unsafe-inline'",
836
- "style-src 'self' 'unsafe-inline'",
837
- "connect-src 'none'",
838
- "form-action 'none'",
839
- "frame-src 'none'",
840
- "base-uri 'none'"
841
- ].join("; ");
842
- function packFileMime(filePath) {
843
- return PACK_FILE_MIME_BY_EXTENSION[path.posix.extname(filePath).toLowerCase()] ?? "application/octet-stream";
844
- }
845
- var OPAQUE_ORIGIN = "null";
846
- function packFileHeaders(filePath, requestOrigin) {
847
- const headers = {
848
- "Content-Security-Policy": PACK_PANEL_CONTENT_POLICY,
849
- "X-Content-Type-Options": "nosniff",
850
- "Referrer-Policy": "no-referrer",
851
- "Content-Type": packFileMime(filePath),
852
- Vary: "Origin"
853
- };
854
- return requestOrigin === OPAQUE_ORIGIN ? {
855
- ...headers,
856
- "Access-Control-Allow-Origin": OPAQUE_ORIGIN
857
- } : headers;
858
- }
859
- function uiSectionErrors(pack) {
860
- return pack.ui && !pack.ui.ok ? pack.ui.errors : [];
861
- }
862
- function validPackRow(pack, approvedFingerprints) {
863
- const { prFlowsPacks, warnings: prFlowsErrors } = prFlowsPacksOf([pack]);
864
- const sectionErrors = [...prFlowsErrors, ...uiSectionErrors(pack)];
865
- const [prFlowsPack] = prFlowsPacks;
866
- return {
867
- name: pack.header.name,
868
- version: pack.header.version,
869
- description: pack.header.description ?? null,
870
- dir: pack.dir,
871
- state: approvedFingerprints.has(pack.fingerprint) ? "approved" : "pending",
872
- fingerprint: pack.fingerprint,
873
- files: [...pack.filesByPath.keys()].sort(),
874
- needs: packNeeds(pack),
875
- missingRequires: pack.missingRequires,
876
- prFlows: prFlowsPack ? packApproval(prFlowsPack) : null,
877
- themes: packThemes(pack).map((theme) => ({
878
- id: theme.id,
879
- label: theme.label,
880
- mode: theme.mode
881
- })),
882
- panels: packPanels(pack).map((panel) => ({
883
- id: panel.id,
884
- label: panel.label,
885
- reads: panel.reads
886
- })),
887
- errors: sectionErrors
888
- };
889
- }
890
- function packRow(packDir, read, approvedFingerprints) {
891
- if (read.ok) return validPackRow(read.pack, approvedFingerprints);
892
- return {
893
- name: path.basename(packDir),
894
- version: null,
895
- description: null,
896
- dir: packDir,
897
- state: "invalid",
898
- fingerprint: null,
899
- files: [],
900
- needs: [],
901
- missingRequires: [],
902
- prFlows: null,
903
- themes: [],
904
- panels: [],
905
- errors: read.errors
906
- };
907
- }
908
- function pendingPackNote(row) {
909
- return `The pack '${row.name}' waits for your approval in Settings, Packs`;
910
- }
911
- var MAX_REFERENCE_LENGTH = 512;
912
- var HTML_REFERENCE_PATTERN = new RegExp(`\\b(src|href|poster|srcset|imagesrcset)\\s*=\\s*${`(?:"([^"]{0,${MAX_REFERENCE_LENGTH}})"|'([^']{0,${MAX_REFERENCE_LENGTH}})'|([^\\s"'>]{1,${MAX_REFERENCE_LENGTH}}))`}`, "gi");
913
- var CSS_REFERENCE_PATTERN = new RegExp(`url\\(\\s*["']?([^"')]{0,${MAX_REFERENCE_LENGTH}})["']?\\s*\\)|@import\\s+["']([^"']{1,${MAX_REFERENCE_LENGTH}})["']`, "gi");
914
- var INERT_REFERENCE_PATTERN = /^(?:#|data:|blob:|javascript:|about:|mailto:)/i;
915
- var REMOTE_REFERENCE_PATTERN = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
916
- function withoutDelimited(text, opener, closer) {
917
- const keptParts = [];
918
- let cursor = 0;
919
- while (cursor < text.length) {
920
- const openAt = text.indexOf(opener, cursor);
921
- if (openAt === -1) return [...keptParts, text.slice(cursor)].join("");
922
- keptParts.push(text.slice(cursor, openAt));
923
- const closeAt = text.indexOf(closer, openAt + opener.length);
924
- if (closeAt === -1) return keptParts.join("");
925
- cursor = closeAt + closer.length;
926
- }
927
- return keptParts.join("");
928
- }
929
- function attributeUrls(attributeName, value) {
930
- if (!attributeName.toLowerCase().endsWith("srcset")) return [value];
931
- return value.split(",").map((candidate) => candidate.trim().split(/\s+/)[0] ?? "");
932
- }
933
- var JS_IMPORT_PATTERN = new RegExp(`\\b(?:import|export)\\b[^;'"]{0,${MAX_REFERENCE_LENGTH}}?\\bfrom\\s{0,64}["']([^"']{1,${MAX_REFERENCE_LENGTH}})["']|\\bimport\\s{0,64}\\(?\\s{0,64}["']([^"']{1,${MAX_REFERENCE_LENGTH}})["']`, "g");
934
- var LINE_COMMENT_PATTERN = /^[ \t]*\/\/.*$/gm;
935
- var RELATIVE_IMPORT_PATTERN = /^\.{1,2}\//;
936
- function isScriptFile(filePath) {
937
- return filePath.endsWith(".js") || filePath.endsWith(".mjs");
938
- }
939
- function jsImportsIn(text) {
940
- return [...withoutDelimited(text, "/*", "*/").replace(LINE_COMMENT_PATTERN, "").matchAll(JS_IMPORT_PATTERN)].map((match) => ({
941
- url: match[1] ?? match[2] ?? "",
942
- isImport: true
943
- }));
944
- }
945
- function linkReferences(urls) {
946
- return urls.map((url) => ({
947
- url,
948
- isImport: false
949
- }));
950
- }
951
- function inlineScriptsIn(html) {
952
- const scriptBodies = [];
953
- const lowerHtml = html.toLowerCase();
954
- let cursor = 0;
955
- while (cursor < html.length) {
956
- const openAt = lowerHtml.indexOf("<script", cursor);
957
- const bodyStart = openAt === -1 ? -1 : lowerHtml.indexOf(">", openAt);
958
- const closeAt = bodyStart === -1 ? -1 : lowerHtml.indexOf("<\/script", bodyStart);
959
- if (closeAt === -1) return scriptBodies;
960
- scriptBodies.push(html.slice(bodyStart + 1, closeAt));
961
- cursor = closeAt;
962
- }
963
- return scriptBodies;
964
- }
965
- function rawReferencesIn(filePath, text) {
966
- if (isScriptFile(filePath)) return jsImportsIn(text);
967
- const withoutComments = withoutDelimited(withoutDelimited(text, "<!--", "-->"), "/*", "*/");
968
- const cssReferences = linkReferences([...withoutComments.matchAll(CSS_REFERENCE_PATTERN)].map((match) => match[1] ?? match[2] ?? ""));
969
- if (!filePath.endsWith(".html")) return cssReferences;
970
- return [
971
- ...linkReferences([...withoutComments.matchAll(HTML_REFERENCE_PATTERN)].flatMap((match) => attributeUrls(match[1] ?? "", match[2] ?? match[3] ?? match[4] ?? ""))),
972
- ...inlineScriptsIn(withoutComments).flatMap(jsImportsIn),
973
- ...cssReferences
974
- ];
975
- }
976
- function referencesIn(filePath, text) {
977
- return rawReferencesIn(filePath, text).map((reference) => ({
978
- ...reference,
979
- url: reference.url.trim()
980
- })).filter((reference) => reference.url !== "" && !INERT_REFERENCE_PATTERN.test(reference.url));
981
- }
982
- function decodedPath(reference) {
983
- try {
984
- return decodeURIComponent(reference);
985
- } catch {
986
- return reference;
987
- }
988
- }
989
- function referenceError(filePath, { url: reference, isImport }, filesByPath) {
990
- if (REMOTE_REFERENCE_PATTERN.test(reference)) return `${filePath} loads ${reference}, but a panel has no network; put that file in the pack`;
991
- if (reference.startsWith("/")) return `${filePath} refers to ${reference}, an absolute path that leaves the pack; use a path relative to ${filePath}`;
992
- if (isImport && !RELATIVE_IMPORT_PATTERN.test(reference)) return `${filePath} imports ${reference}, but a panel has no package resolver; import a file in the pack by a path starting with ./ or ../`;
993
- const referencedPath = referencedPackPath(filePath, reference);
994
- if (referencedPath.startsWith("../")) return `${filePath} refers to ${reference}, which is outside the pack`;
995
- return filesByPath.has(referencedPath) ? null : `${filePath} refers to ${reference}, which is not a file in the pack`;
996
- }
997
- function referencedPackPath(filePath, reference) {
998
- return path.posix.normalize(path.posix.join(path.posix.dirname(filePath), decodedPath(reference.replace(/[?#].*$/, ""))));
999
- }
1000
- function panelReferenceErrors(filesByPath) {
1001
- return [...filesByPath].filter(([filePath]) => filePath.endsWith(".html") || filePath.endsWith(".css") || isScriptFile(filePath)).flatMap(([filePath, bytes]) => referencesIn(filePath, bytes.toString("utf8")).map((reference) => referenceError(filePath, reference, filesByPath)).filter((error) => error !== null));
1002
- }
1003
- var SUBSCRIBED_TOPICS_PATTERN = /subscribe\(\s*\[([^\]]{0,500})\]|kind\s*:\s*['"]subscribe['"][^}]{0,500}?topics\s*:\s*\[([^\]]{0,500})\]/g;
1004
- function filesLoadedFrom(entry, filesByPath) {
1005
- const loadedPaths = /* @__PURE__ */ new Set();
1006
- const pendingPaths = [entry];
1007
- while (pendingPaths.length > 0) {
1008
- const filePath = pendingPaths.pop() ?? "";
1009
- const bytes = filesByPath.get(filePath);
1010
- if (loadedPaths.has(filePath) || bytes === void 0) continue;
1011
- loadedPaths.add(filePath);
1012
- if (!filePath.endsWith(".html") && !isScriptFile(filePath)) continue;
1013
- pendingPaths.push(...referencesIn(filePath, bytes.toString("utf8")).filter(({ url }) => !REMOTE_REFERENCE_PATTERN.test(url) && !url.startsWith("/")).map(({ url }) => referencedPackPath(filePath, url)));
1014
- }
1015
- return [...loadedPaths].filter((filePath) => filePath.endsWith(".html") || isScriptFile(filePath));
1016
- }
1017
- function subscribedTopicsIn(text) {
1018
- return [...text.matchAll(SUBSCRIBED_TOPICS_PATTERN)].flatMap((match) => [...(match[1] ?? match[2] ?? "").matchAll(/['"]([^'"]+)['"]/g)].map((topic) => topic[1] ?? ""));
1019
- }
1020
- function undeclaredSubscriptionErrors(filesByPath, panels) {
1021
- return panels.flatMap((panel) => filesLoadedFrom(panel.entry, filesByPath).flatMap((filePath) => [...new Set(subscribedTopicsIn(filesByPath.get(filePath)?.toString("utf8") ?? ""))].filter((topic) => !panel.reads.includes(topic)).map((topic) => `${filePath} subscribes to '${topic}', which panel ${panel.id} does not list under reads, so it never arrives there; add it to that panel's reads or drop it`)));
1022
- }
1023
- //#endregion
1024
727
  //#region shared/contracts/pack.ts
1025
728
  var PACK_SCHEMA_URL = "https://glimmervoid.dev/schema/pack.v1.json";
1026
729
  var PACK_FILE_NAME = "pack.json";
@@ -1038,11 +741,11 @@ var PackHeader = z.strictObject({
1038
741
  ui: z.unknown().optional()
1039
742
  });
1040
743
  var PackPrFlows = z.strictObject({
1041
- repos: RepoScope.describe("The default owner/name repositories, matched case-insensitively, for every prAction, source and rule of this pack that lists no repos of its own; an entry's own repos replace this default rather than narrowing it; every repository when absent"),
744
+ repos: RepoScope.describe("The default owner/name repositories, matched case-insensitively, for every prAction, source and rule of this pack that lists no repos of its own; an entry's own repos narrow this default to the repositories both list; every repository when absent"),
1042
745
  prActions: z.array(PrFlowPrAction).default([]).describe("Buttons on a pull request; the command prints {\"outcome\":\"done|started|refused|failed\",\"message\":\"...\"}, and one that prints started reports later with glimmervoid pr-action report"),
1043
746
  sources: z.array(PrFlowSourceCommand).default([]).describe("Commands run on each pull request that print {\"findings\":[{\"path\",\"lineStart\",\"lineEnd\",\"priority\",\"body\",\"url\"}],\"status\":[{\"label\",\"state\"}]}, at most 200 findings and 4 status lines"),
1044
747
  actions: z.array(PrFlowItemAction).default([]).describe("Commands rules run on one review item with run:<id>; they print {\"outcome\":\"done|started|refused|failed\",\"message\":\"...\"} and are limited to repositories only through the rules that name them"),
1045
- rules: z.array(PrFlowRule).default([]).describe("Run after your own config.json rules; the first rule that matches an item decides it")
748
+ rules: z.array(PackPrFlowRule).default([]).describe("Run after your own config.json rules; the first rule that matches an item decides it")
1046
749
  }).superRefine((section, context) => {
1047
750
  for (const kind of [
1048
751
  "prActions",
@@ -1333,170 +1036,4 @@ async function packDirsUnder(homeDir) {
1333
1036
  };
1334
1037
  }
1335
1038
  //#endregion
1336
- //#region server/packs/pack-check.ts
1337
- function pageErrors(filesByPath, header) {
1338
- return [...panelReferenceErrors(filesByPath), ...undeclaredSubscriptionErrors(filesByPath, header ? declaredPanels(header.ui) : [])];
1339
- }
1340
- async function checkPack(packDir, env, isApprovedFingerprint) {
1341
- const read = await readPackDir(packDir, env);
1342
- if (!read.ok) {
1343
- const name = read.header ? `${read.header.name} v${read.header.version}` : null;
1344
- return {
1345
- packDir: path.resolve(packDir),
1346
- name,
1347
- isApproved: false,
1348
- errors: [...read.errors, ...pageErrors(read.filesByPath ?? /* @__PURE__ */ new Map(), read.header)],
1349
- notes: [],
1350
- missingRequires: [],
1351
- entries: [],
1352
- rules: [],
1353
- panels: [],
1354
- themes: []
1355
- };
1356
- }
1357
- const { pack } = read;
1358
- const { prFlowsPacks, warnings: prFlowsErrors } = prFlowsPacksOf([pack]);
1359
- const ui = pack.ui?.ok ? pack.ui.value : {
1360
- panels: [],
1361
- themes: []
1362
- };
1363
- const report = {
1364
- packDir: pack.dir,
1365
- name: `${pack.header.name} v${pack.header.version}`,
1366
- isApproved: isApprovedFingerprint(pack.fingerprint),
1367
- errors: [
1368
- ...prFlowsErrors,
1369
- ...uiSectionErrors(pack),
1370
- ...pageErrors(pack.filesByPath, pack.header)
1371
- ],
1372
- notes: [],
1373
- missingRequires: pack.missingRequires,
1374
- entries: [],
1375
- rules: [],
1376
- panels: ui.panels.map((panel) => `${panel.id} (${panel.label}) opens ${panel.entry}${panel.reads.length === 0 ? ", reads nothing" : `, reads ${panel.reads.join(", ")}`}`),
1377
- themes: ui.themes.map((theme) => `${theme.id} (${theme.label}, ${theme.mode})`)
1378
- };
1379
- const [prFlowsPack] = prFlowsPacks;
1380
- if (!prFlowsPack) return report;
1381
- const approval = packApproval(prFlowsPack);
1382
- const entries = (approval.pack?.commands ?? []).map((command) => {
1383
- const names = PR_FLOW_PLACEHOLDERS_BY_KIND[command.kind];
1384
- const expanded = expandPlaceholders(command.command, Object.fromEntries(names.map((placeholderName) => [placeholderName, `{${placeholderName}}`])));
1385
- const error = expanded.ok ? null : `{${expanded.unknown}} is not a placeholder here; use {packDir}, ${names.map((placeholderName) => `{${placeholderName}}`).join(", ")}`;
1386
- return {
1387
- kind: command.kind,
1388
- id: command.id,
1389
- label: command.label,
1390
- argv: command.command,
1391
- repos: command.repos ?? null,
1392
- error
1393
- };
1394
- });
1395
- const ruleChecks = packRuleChecks(prFlowsPack.section, pack.header.name);
1396
- return {
1397
- ...report,
1398
- errors: [...report.errors, ...ruleChecks.errors],
1399
- notes: ruleChecks.notes,
1400
- entries,
1401
- rules: approval.pack?.rules ?? []
1402
- };
1403
- }
1404
- function packCheckHasProblem(report) {
1405
- return report.errors.length > 0 || report.entries.some((entry) => entry.error !== null);
1406
- }
1407
- function reportHeading(report) {
1408
- const checked = report.name === null ? `Checked the pack at ${report.packDir}` : `Checked pack ${report.name} at ${report.packDir}`;
1409
- if (packCheckHasProblem(report)) return `${checked}: fix the problems below, then check it again`;
1410
- return `${checked}: no problems; ${report.isApproved ? "it is approved" : "once installed, it waits for the operator to approve it in Settings, Packs"}`;
1411
- }
1412
- function entryReach(entry) {
1413
- if (entry.kind === "action") return ", on the repositories of the rules that name it";
1414
- if (entry.repos === null) return ", on every repository";
1415
- return `, limited to ${entry.repos.join(", ")}`;
1416
- }
1417
- function entryLine(entry) {
1418
- const heading = `${entry.kind} ${entry.id} (${entry.label}): `;
1419
- if (entry.error !== null) return `${heading}invalid, ${entry.error}`;
1420
- return `${heading}valid${entryReach(entry)}\n would run ${JSON.stringify(entry.argv)}`;
1421
- }
1422
- function packReportText(report) {
1423
- return [
1424
- reportHeading(report),
1425
- ...report.panels.map((panel) => `panel ${panel}`),
1426
- ...report.themes.map((theme) => `theme ${theme}`),
1427
- ...report.entries.map(entryLine),
1428
- ...report.rules.map((rule) => `rule ${rule}`),
1429
- ...report.errors.map((error) => `error: ${error}`),
1430
- ...report.notes.map((note) => `note: ${note}`),
1431
- ...report.missingRequires.map((missing) => `missing on this machine: ${missing}, so the pack stays off here until it has it; not a problem in the pack`)
1432
- ].join("\n");
1433
- }
1434
- //#endregion
1435
- //#region server/packs/pack-agent.ts
1436
- async function exampleLines(examplePacksDir) {
1437
- const entries = await fs.promises.readdir(examplePacksDir, { withFileTypes: true }).catch(() => []);
1438
- const lines = await Promise.all(entries.filter((entry) => entry.isDirectory()).map(async (entry) => {
1439
- const manifestText = await fs.promises.readFile(path.join(examplePacksDir, entry.name, PACK_FILE_NAME), "utf8").catch(() => "");
1440
- const header = PackHeader.safeParse(parseJsonOrNull(manifestText));
1441
- return `- ${path.join(examplePacksDir, entry.name)}${header.success && header.data.description ? `: ${header.data.description}` : ""}`;
1442
- }));
1443
- return lines.length === 0 ? ["(this install ships no example packs)"] : lines.sort();
1444
- }
1445
- async function packGuideText({ homeDir, examplePacksDir }, schemaLines) {
1446
- return [
1447
- "Glimmervoid packs",
1448
- "",
1449
- `A pack is a folder holding a ${PACK_FILE_NAME} and the files it names, at most 1 MiB in all and without symlinks. Install one by placing its folder under ${path.join(homeDir, PACKS_DIR_NAME)}, or by listing its path under "packs" in Glimmervoid's config.json.`,
1450
- "Nothing in a pack runs or shows until the operator approves it in Settings, Packs, and any change to any file in it asks again. Never approve a pack for the operator; check it, then tell them it waits for approval.",
1451
- "",
1452
- "Sections of pack.json, each checked on its own:",
1453
- "- prFlows: commands My PRs runs on pull requests (prActions, sources, actions, rules).",
1454
- "- ui.themes: color themes for the Theme picker; every chrome and state color is a #rrggbb hex.",
1455
- "- ui.panels: HTML pages shown as dashboard tabs. A panel runs sandboxed in an opaque origin: no network, no cookies, no storage, no popups or navigation (a link in a panel opens nothing), no access to the dashboard page. Put every script, style, image and font in the pack and refer to it by a relative path; ES module scripts with relative imports, fonts, inline <script> and <style> all work. localStorage, sessionStorage and cookies throw a SecurityError, so a panel keeps its state in memory and loses it on reload. Every panel file is served with this Content-Security-Policy:",
1456
- ` ${PACK_PANEL_CONTENT_POLICY}`,
1457
- "",
1458
- "Panel bridge: list the topics a panel needs under its reads in pack.json; the operator sees them before approving. The panel posts {\"v\":1,\"kind\":\"subscribe\",\"topics\":[...]} to window.parent and gets {\"v\":1,\"kind\":\"hello\",\"granted\":[...]}: the subscribed topics that are also in reads, so a topic left out of reads never arrives. Then a {\"v\":1,\"kind\":\"topic\",\"topic\":...,\"data\":...} message comes for each granted topic, right away and again whenever it changes. Accept messages only when event.source === window.parent. The descriptions in the bridge JSON Schema below give each field's units and meaning.",
1459
- "Each example panel ships the same bridge.js; copy it beside your panel and load it before your own script. It defines window.glimmervoid.subscribe(topics, onTopic) (it calls onTopic(\"hello\", granted) once, then onTopic(topic, data) per topic message), applyTheme(themeData) (pass it the theme topic data; it sets every color as a CSS custom property on the root, such as var(--bg) or var(--state-running)) and element(tag, className, text).",
1460
- "",
1461
- "Examples to copy and adapt:",
1462
- ...await exampleLines(examplePacksDir),
1463
- "",
1464
- "Workflow: write the pack in any folder, run glimmervoid packs check <folder> (exits 1 and lists every problem, including files a page loads that are missing or remote), then glimmervoid packs preview <folder> to open its panels in a browser with sample data and its themes, without installing or approving anything. Then install it and tell the operator it waits for approval. The packs tool with action check runs the same check.",
1465
- "",
1466
- ...schemaLines
1467
- ].join("\n");
1468
- }
1469
- function rowLines(row) {
1470
- return [
1471
- `${row.name}${row.version === null ? "" : ` v${row.version}`}: ${row.state} at ${row.dir}`,
1472
- ...row.panels.map((panel) => ` panel ${panel.id} (${panel.label})${panel.reads.length === 0 ? "" : `, reads ${panel.reads.join(", ")}`}`),
1473
- ...row.themes.map((theme) => ` theme ${theme.id} (${theme.label}, ${theme.mode})`),
1474
- ...row.missingRequires.map((missing) => ` missing on this machine: ${missing}`),
1475
- ...row.errors.map((error) => ` error: ${error}`)
1476
- ];
1477
- }
1478
- async function readPacksForAgent(request, deps) {
1479
- if (request.command === "guide") return {
1480
- text: await packGuideText(deps, [
1481
- `${PACK_FILE_NAME} JSON Schema:`,
1482
- packJsonSchemaText(),
1483
- "Panel bridge messages JSON Schema:",
1484
- packBridgeJsonSchemaText()
1485
- ]),
1486
- hasProblem: false
1487
- };
1488
- if (request.command === "list") {
1489
- const rows = deps.packRows();
1490
- return {
1491
- text: rows.length === 0 ? `No packs are installed; ${path.join(deps.homeDir, PACKS_DIR_NAME)} holds none and config.json lists none.` : rows.flatMap(rowLines).join("\n"),
1492
- hasProblem: rows.some((row) => row.errors.length > 0)
1493
- };
1494
- }
1495
- const report = await checkPack(request.path ?? "", deps.env, deps.isApproved);
1496
- return {
1497
- text: packReportText(report),
1498
- hasProblem: packCheckHasProblem(report)
1499
- };
1500
- }
1501
- //#endregion
1502
- export { prActionRunAfterExit as A, unknownActionWarnings as B, fixLocallyPrompt as C, packPathsOf as D, mergeItems as E, scopedToRepo as F, withPrActionRun as G, withHandled as H, shouldTellBranchMoved as I, decideHostAllowed as J, withReopened as K, sourceCandidates as L, prFlowRules as M, prFlowSetup as N, plannedActions as O, savedRuleFor as P, teammateThreadItems as R, expandPlaceholders as S, itemLocation as T, withInterruptedRuns as U, visibleRun as V, withOnlyOpenPrs as W, packRow as _, packReportText as a, branchMovedNote as b, packsStatePath as c, PACK_FILE_NAME as d, PacksState as f, packFileHeaders as g, approvedPackThemes as h, packCheckHasProblem as i, prFlowCommands as j, prActionPlaceholderValues as k, readApprovedPackFingerprints as l, approvedPackPanels as m, readPacksForAgent as n, PACKS_DIR_NAME as o, packJsonSchemaText as p, withRuleRun as q, checkPack as r, packDirsUnder as s, packGuideText as t, readPackDir as u, pendingPackNote as v, flaggingReviewers as w, commandFingerprint as x, acceptReport as y, threadCandidates as z };
1039
+ export { shouldTellBranchMoved as A, withPrActionRun as B, prActionPlaceholderValues as C, prFlowsPacksOf as D, prFlowsConfig as E, unknownPlaceholderMessage as F, withRuleRun as H, visibleRun as I, withHandled as L, sourcePlaceholderValues as M, teammateThreadItems as N, savedRuleFor as O, threadCandidates as P, withInterruptedRuns as R, plannedActions as S, prFlowSetup as T, withReopened as V, itemLocation as _, readApprovedPackFingerprints as a, packPathsOf as b, PackHeader as c, acceptReport as d, branchMovedNote as f, flaggingReviewers as g, fixLocallyPrompt as h, packsStatePath as i, sourceCandidates as j, scopedToRepo as k, PacksState as l, expandPlaceholders as m, declaredPanels as n, readPackDir as o, commandFingerprint as p, packDirsUnder as r, PACK_FILE_NAME as s, PACKS_DIR_NAME as t, packJsonSchemaText as u, mergeItems as v, prActionRunAfterExit as w, packRuleErrors as x, packApproval as y, withOnlyOpenPrs as z };