glimmervoid 0.52.2-next.676 → 0.52.2-next.677

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 (147) hide show
  1. package/dist/bin/glimmervoid.js +19 -14
  2. package/dist/chunks/{adapters-D3Jz5ubD.js → adapters-Cc8ALffl.js} +6 -6
  3. package/dist/chunks/{adapters-BR9uXgFY.js → adapters-DjtWvxmJ.js} +1 -1
  4. package/dist/chunks/{agent-api-cli-CdspB0dx.js → agent-api-cli-7xxfflVL.js} +3 -3
  5. package/dist/chunks/agent-api-cli-ivGOfIyv.js +1 -0
  6. package/dist/chunks/{agent-api-core-BVqCeZzP.js → agent-api-core-BxJOL6Ye.js} +27 -2
  7. package/dist/chunks/{agent-setup-cli-D5_viu2B.js → agent-setup-cli-DWGQIduP.js} +1 -1
  8. package/dist/chunks/{config-62c4QXQt.js → config-C43Ovt64.js} +5 -1
  9. package/dist/chunks/config-store-BopqXIii.js +1 -0
  10. package/dist/chunks/{config-store-3MDjeSxI.js → config-store-Bqag5_2n.js} +50 -14
  11. package/dist/chunks/{grok-9XjPCcq0.js → grok-CstIMQXr.js} +1 -1
  12. package/dist/chunks/kimi-DgpeyWvz.js +1 -0
  13. package/dist/chunks/{kimi-BcpjSEBw.js → kimi-DjNUuBkC.js} +2 -2
  14. package/dist/chunks/{main-15MNtLEZ.js → main-mQr6p3Ev.js} +203 -32
  15. package/dist/chunks/{pair-cli-DX6XERYG.js → pair-cli-rFzuZV0h.js} +2 -2
  16. package/dist/chunks/{pr-flows-cli-BCB9p1ex.js → pr-flows-cli-Bdt0p04k.js} +117 -4
  17. package/dist/chunks/{pr-flows-external-CgzY34kz.js → pr-flows-external-CbLPEQzZ.js} +470 -30
  18. package/dist/chunks/{remote-config-DuHGnyrW.js → remote-config-C3nVcK84.js} +1 -1
  19. package/dist/chunks/{session-d-TA-Vaa.js → session-D0gNPAv6.js} +102 -7
  20. package/dist/chunks/{settings-cli-DlsLA8Zz.js → settings-cli-Bp7SFXNh.js} +5 -5
  21. package/dist/chunks/{settings-readout-core-CdqNElBs.js → settings-readout-core-DhpeT094.js} +2 -2
  22. package/dist/chunks/{shown-files-core-DKEbS44S.js → shown-files-core-DJ4Uu8g4.js} +1 -1
  23. package/dist/chunks/{spawn-env-BEQeEK4h.js → spawn-env-gxqKNJaO.js} +1 -1
  24. package/dist/chunks/{ssh-sign-cli-CgDEJU9V.js → ssh-sign-cli-B8sdxV3y.js} +2 -2
  25. package/dist/client/assets/{action-status-DXlvWNQ7.js → action-status-B0E-UYey.js} +1 -1
  26. package/dist/client/assets/action-status-B0E-UYey.js.br +0 -0
  27. package/dist/client/assets/{benchmark-panel-Dt3vGyms.js → benchmark-panel-Dzhmjdmr.js} +1 -1
  28. package/dist/client/assets/benchmark-panel-Dzhmjdmr.js.br +0 -0
  29. package/dist/client/assets/{boards-view-BeZKxEeC.js → boards-view-Cz0vbt34.js} +1 -1
  30. package/dist/client/assets/boards-view-Cz0vbt34.js.br +0 -0
  31. package/dist/client/assets/button-Cnom-MQM.js +1 -0
  32. package/dist/client/assets/button-Cnom-MQM.js.br +0 -0
  33. package/dist/client/assets/{card-actions-xWiBLo91.js → card-actions-unth0mGA.js} +1 -1
  34. package/dist/client/assets/{card-registry-D1vs5tMh.js → card-registry-W9ss4JHS.js} +1 -1
  35. package/dist/client/assets/card-registry-W9ss4JHS.js.br +0 -0
  36. package/dist/client/assets/{community-panel-Cs7qRZIs.js → community-panel-BlEfUgu7.js} +1 -1
  37. package/dist/client/assets/community-panel-BlEfUgu7.js.br +0 -0
  38. package/dist/client/assets/{control-ws-XKBNUN2v.js → control-ws-t9cKDDGy.js} +1 -1
  39. package/dist/client/assets/control-ws-t9cKDDGy.js.br +0 -0
  40. package/dist/client/assets/{dialogs-i4MvWfcJ.js → dialogs-CvazD02b.js} +1 -1
  41. package/dist/client/assets/dialogs-CvazD02b.js.br +0 -0
  42. package/dist/client/assets/{doc-editor-ui-CRHea59O.js → doc-editor-ui-7FVQ5FEn.js} +1 -1
  43. package/dist/client/assets/doc-editor-ui-7FVQ5FEn.js.br +0 -0
  44. package/dist/client/assets/{feature-hint-BUbxqM6i.js → feature-hint-BuFmpFSY.js} +1 -1
  45. package/dist/client/assets/feature-hint-BuFmpFSY.js.br +0 -0
  46. package/dist/client/assets/{first-run-checklist-CmyO-Hst.js → first-run-checklist-CnlRPXrW.js} +1 -1
  47. package/dist/client/assets/first-run-checklist-CnlRPXrW.js.br +0 -0
  48. package/dist/client/assets/{hooks-panel-CG3S0SRu.js → hooks-panel-CHcww_jI.js} +1 -1
  49. package/dist/client/assets/hooks-panel-CHcww_jI.js.br +0 -0
  50. package/dist/client/assets/{index-Q9jU5kU4.js → index-CiJEE2GW.js} +24 -24
  51. package/dist/client/assets/index-CiJEE2GW.js.br +0 -0
  52. package/dist/client/assets/{issues-panel-DMIurtjb.js → issues-panel-C-WU_OpW.js} +1 -1
  53. package/dist/client/assets/issues-panel-C-WU_OpW.js.br +0 -0
  54. package/dist/client/assets/{lane-read-token-step-CoeCjZG1.js → lane-read-token-step-Bl2wOyl9.js} +6 -6
  55. package/dist/client/assets/lane-read-token-step-Bl2wOyl9.js.br +0 -0
  56. package/dist/client/assets/{menu-D9GiYN6D.js → menu-DK4rQWp6.js} +1 -1
  57. package/dist/client/assets/menu-DK4rQWp6.js.br +0 -0
  58. package/dist/client/assets/{modal-B1bP8CnK.js → modal-C-Lb5-jJ.js} +1 -1
  59. package/dist/client/assets/modal-C-Lb5-jJ.js.br +0 -0
  60. package/dist/client/assets/my-prs-panel-rsZ0yjXe.js +1 -0
  61. package/dist/client/assets/my-prs-panel-rsZ0yjXe.js.br +0 -0
  62. package/dist/client/assets/{nyan-cat-BJJIa95f.js → nyan-cat-DzIDMDM4.js} +1 -1
  63. package/dist/client/assets/nyan-cat-DzIDMDM4.js.br +0 -0
  64. package/dist/client/assets/{phone-shell-CAEfiwKo.js → phone-shell-BjFYeULh.js} +1 -1
  65. package/dist/client/assets/phone-shell-BjFYeULh.js.br +0 -0
  66. package/dist/client/assets/{plan-face-CosMfmeH.js → plan-face-ttBdxmdT.js} +1 -1
  67. package/dist/client/assets/plan-face-ttBdxmdT.js.br +0 -0
  68. package/dist/client/assets/{plan-render-COb_RToy.js → plan-render-DcEs6x-w.js} +1 -1
  69. package/dist/client/assets/plan-render-DcEs6x-w.js.br +0 -0
  70. package/dist/client/assets/{pr-queue-columns-Cvq0YbUw.js → pr-queue-columns-Dno6qOMY.js} +1 -1
  71. package/dist/client/assets/pr-queue-columns-Dno6qOMY.js.br +10 -0
  72. package/dist/client/assets/{pr-status-icon-BPdB3x-u.js → pr-status-icon-D1RIxNiH.js} +1 -1
  73. package/dist/client/assets/pr-status-icon-D1RIxNiH.js.br +0 -0
  74. package/dist/client/assets/{radar-panel-DplX3jhC.js → radar-panel-BaC23VCe.js} +1 -1
  75. package/dist/client/assets/radar-panel-BaC23VCe.js.br +0 -0
  76. package/dist/client/assets/{repo-roots-adder-BIUsOw3v.js → repo-roots-adder-DcY8QZax.js} +1 -1
  77. package/dist/client/assets/repo-roots-adder-DcY8QZax.js.br +0 -0
  78. package/dist/client/assets/{resume-dialog-1NN1elB8.js → resume-dialog-CvC8QV7Y.js} +1 -1
  79. package/dist/client/assets/resume-dialog-CvC8QV7Y.js.br +0 -0
  80. package/dist/client/assets/{review-queue-panel-DIr1VGtt.js → review-queue-panel-CNKVV6RH.js} +1 -1
  81. package/dist/client/assets/review-queue-panel-CNKVV6RH.js.br +0 -0
  82. package/dist/client/assets/{session-actions-D9RGL-qn.js → session-actions-HPImbYVb.js} +2 -2
  83. package/dist/client/assets/session-actions-HPImbYVb.js.br +0 -0
  84. package/dist/client/assets/{session-row-C8fi8nZv.js → session-row-CNI0g3fQ.js} +1 -1
  85. package/dist/client/assets/session-row-CNI0g3fQ.js.br +0 -0
  86. package/dist/client/assets/{session-tick-COTMmIoE.js → session-tick-CY_ByGke.js} +1 -1
  87. package/dist/client/assets/session-tick-CY_ByGke.js.br +0 -0
  88. package/dist/client/assets/settings-panel-BvXNdZZu.js +4 -0
  89. package/dist/client/assets/settings-panel-BvXNdZZu.js.br +0 -0
  90. package/dist/client/assets/{setup-step-C7wDcLSD.js → setup-step-DTtM5S-5.js} +1 -1
  91. package/dist/client/assets/setup-step-DTtM5S-5.js.br +0 -0
  92. package/dist/client/assets/{shown-face-B55zt8_T.js → shown-face-DD4AnY8c.js} +1 -1
  93. package/dist/client/assets/shown-face-DD4AnY8c.js.br +0 -0
  94. package/dist/client/assets/{trace-panel-BrUZR4UO.js → trace-panel-BfPys80r.js} +1 -1
  95. package/dist/client/assets/trace-panel-BfPys80r.js.br +0 -0
  96. package/dist/client/assets/{usage-panel-CVPMCuPf.js → usage-panel-Dt93pqYo.js} +1 -1
  97. package/dist/client/assets/usage-panel-Dt93pqYo.js.br +0 -0
  98. package/dist/client/assets/{your-day-tip-CjQ6fqIw.js → your-day-tip-CUTVfQI4.js} +1 -1
  99. package/dist/client/assets/your-day-tip-CUTVfQI4.js.br +0 -0
  100. package/dist/client/index.html +12 -12
  101. package/dist/client/index.html.br +0 -0
  102. package/dist/schema/pr-pack.v1.json +272 -0
  103. package/dist/server/index.js +1 -1
  104. package/package.json +1 -1
  105. package/dist/chunks/agent-api-cli-BowH6sQb.js +0 -1
  106. package/dist/chunks/config-store-B8yJlCWU.js +0 -1
  107. package/dist/chunks/kimi-C_c8wPl5.js +0 -1
  108. package/dist/client/assets/action-status-DXlvWNQ7.js.br +0 -0
  109. package/dist/client/assets/benchmark-panel-Dt3vGyms.js.br +0 -0
  110. package/dist/client/assets/boards-view-BeZKxEeC.js.br +0 -0
  111. package/dist/client/assets/button-DyD4Mzjw.js +0 -1
  112. package/dist/client/assets/button-DyD4Mzjw.js.br +0 -0
  113. package/dist/client/assets/card-registry-D1vs5tMh.js.br +0 -0
  114. package/dist/client/assets/community-panel-Cs7qRZIs.js.br +0 -0
  115. package/dist/client/assets/control-ws-XKBNUN2v.js.br +0 -0
  116. package/dist/client/assets/dialogs-i4MvWfcJ.js.br +0 -0
  117. package/dist/client/assets/doc-editor-ui-CRHea59O.js.br +0 -0
  118. package/dist/client/assets/feature-hint-BUbxqM6i.js.br +0 -0
  119. package/dist/client/assets/first-run-checklist-CmyO-Hst.js.br +0 -0
  120. package/dist/client/assets/hooks-panel-CG3S0SRu.js.br +0 -0
  121. package/dist/client/assets/index-Q9jU5kU4.js.br +0 -0
  122. package/dist/client/assets/issues-panel-DMIurtjb.js.br +0 -0
  123. package/dist/client/assets/lane-read-token-step-CoeCjZG1.js.br +0 -0
  124. package/dist/client/assets/menu-D9GiYN6D.js.br +0 -0
  125. package/dist/client/assets/modal-B1bP8CnK.js.br +0 -0
  126. package/dist/client/assets/my-prs-panel-BlzzWsq0.js +0 -1
  127. package/dist/client/assets/my-prs-panel-BlzzWsq0.js.br +0 -0
  128. package/dist/client/assets/nyan-cat-BJJIa95f.js.br +0 -0
  129. package/dist/client/assets/phone-shell-CAEfiwKo.js.br +0 -0
  130. package/dist/client/assets/plan-face-CosMfmeH.js.br +0 -0
  131. package/dist/client/assets/plan-render-COb_RToy.js.br +0 -0
  132. package/dist/client/assets/pr-queue-columns-Cvq0YbUw.js.br +0 -0
  133. package/dist/client/assets/pr-status-icon-BPdB3x-u.js.br +0 -0
  134. package/dist/client/assets/radar-panel-DplX3jhC.js.br +0 -0
  135. package/dist/client/assets/repo-roots-adder-BIUsOw3v.js.br +0 -0
  136. package/dist/client/assets/resume-dialog-1NN1elB8.js.br +0 -0
  137. package/dist/client/assets/review-queue-panel-DIr1VGtt.js.br +0 -0
  138. package/dist/client/assets/session-actions-D9RGL-qn.js.br +0 -0
  139. package/dist/client/assets/session-row-C8fi8nZv.js.br +0 -0
  140. package/dist/client/assets/session-tick-COTMmIoE.js.br +0 -0
  141. package/dist/client/assets/settings-panel-bZNhVPcC.js +0 -4
  142. package/dist/client/assets/settings-panel-bZNhVPcC.js.br +0 -0
  143. package/dist/client/assets/setup-step-C7wDcLSD.js.br +0 -0
  144. package/dist/client/assets/shown-face-B55zt8_T.js.br +0 -0
  145. package/dist/client/assets/trace-panel-BrUZR4UO.js.br +0 -0
  146. package/dist/client/assets/usage-panel-CVPMCuPf.js.br +0 -0
  147. package/dist/client/assets/your-day-tip-CjQ6fqIw.js.br +0 -0
@@ -1,7 +1,10 @@
1
- import { bn as ReportedPrFlowActionOutcome, cn as PrFlowCommand, fn as PrFlowRule, hn as PrFlowsSettings, mn as PrFlowSourceOutput } from "./session-d-TA-Vaa.js";
1
+ import { r as errorMessage } from "./text-DoirglWV.js";
2
+ import { Cn as PrFlowsSettings, On as ReportedPrFlowActionOutcome, Sn as PrFlowSourceOutput, bn as PrFlowRule, mn as PrFlowCommand, vn as PrFlowPackRequires, yn as PrFlowPrAction } from "./session-D0gNPAv6.js";
2
3
  import { c as runCommandSafely } from "./child-process-safe-BIh8yQ0I.js";
3
4
  import { t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
4
- import { n as withoutGlimmervoidSecrets } from "./spawn-env-BEQeEK4h.js";
5
+ import { n as withoutGlimmervoidSecrets } from "./spawn-env-gxqKNJaO.js";
6
+ import fs from "node:fs";
7
+ import path from "node:path";
5
8
  import { z } from "zod";
6
9
  import crypto from "node:crypto";
7
10
  //#region server/github/core/pr-flows-core.ts
@@ -178,7 +181,12 @@ function withOnlyOpenPrs(state, openPrKeys) {
178
181
  ...state,
179
182
  handledByPr: Object.fromEntries(Object.entries(state.handledByPr).filter(isOpen)),
180
183
  reopenedByPr: Object.fromEntries(Object.entries(state.reopenedByPr).filter(isOpen)),
181
- ruleRunsByPr: Object.fromEntries(Object.entries(state.ruleRunsByPr).filter(isOpen))
184
+ ruleRunsByPr: Object.fromEntries(Object.entries(state.ruleRunsByPr).filter(isOpen)),
185
+ prActionRunByPr: Object.fromEntries(Object.entries(state.prActionRunByPr).flatMap(([prKey, runsByAction]) => {
186
+ if (openPrKeys.has(prKey)) return [[prKey, runsByAction]];
187
+ const liveRuns = Object.entries(runsByAction).filter(([, run]) => run.state === "running" || run.state === "started");
188
+ return liveRuns.length === 0 ? [] : [[prKey, Object.fromEntries(liveRuns)]];
189
+ }))
182
190
  };
183
191
  }
184
192
  function withRuleRun(state, prKey, run) {
@@ -220,10 +228,10 @@ function prFlowRules(configFile, repo) {
220
228
  warnings
221
229
  };
222
230
  }
223
- function parsedCommandList(entries, label, warnings) {
231
+ function parsedCommandList(schema, entries, label, warnings) {
224
232
  const seenIds = /* @__PURE__ */ new Set();
225
233
  return entries.flatMap((entry, index) => {
226
- const parsed = PrFlowCommand.safeParse(entry);
234
+ const parsed = schema.safeParse(entry);
227
235
  if (!parsed.success) {
228
236
  warnings.push(`${label}[${index}] was skipped: ${parsed.error.issues[0]?.message ?? "invalid entry"}`);
229
237
  return [];
@@ -242,43 +250,260 @@ function prFlowCommands(configFile) {
242
250
  if (!settings) return {
243
251
  sources: [],
244
252
  actions: [],
253
+ prActions: [],
245
254
  warnings: []
246
255
  };
247
256
  const warnings = [];
248
257
  return {
249
- sources: parsedCommandList(settings.sources ?? [], "prFlows.sources", warnings),
250
- actions: parsedCommandList(settings.actions ?? [], "prFlows.actions", warnings),
258
+ sources: parsedCommandList(PrFlowCommand, settings.sources ?? [], "prFlows.sources", warnings),
259
+ actions: parsedCommandList(PrFlowCommand, settings.actions ?? [], "prFlows.actions", warnings),
260
+ prActions: parsedCommandList(PrFlowPrAction, settings.prActions ?? [], "prFlows.prActions", warnings),
251
261
  warnings
252
262
  };
253
263
  }
264
+ function normalizedRepos(command) {
265
+ if (!("repos" in command) || command.repos === void 0) return null;
266
+ return [...new Set(command.repos.map((repo) => repo.toLowerCase()))].sort();
267
+ }
254
268
  function commandFingerprint(kind, command) {
255
- return crypto.createHash("sha256").update(JSON.stringify([
269
+ const repos = normalizedRepos(command);
270
+ const fingerprinted = [
256
271
  kind,
257
272
  command.id,
258
273
  command.command,
259
- command.timeoutSeconds
260
- ])).digest("hex");
274
+ command.timeoutSeconds,
275
+ ...repos === null ? [] : [repos]
276
+ ];
277
+ return crypto.createHash("sha256").update(JSON.stringify(fingerprinted)).digest("hex");
278
+ }
279
+ var PACK_DIR_PLACEHOLDER = "{packDir}";
280
+ function packCommand(command, loaded) {
281
+ return {
282
+ ...command,
283
+ id: `${loaded.pack.name}/${command.id}`,
284
+ command: command.command.map((element) => element.replaceAll(PACK_DIR_PLACEHOLDER, loaded.dir))
285
+ };
286
+ }
287
+ function packRule(rule, packName) {
288
+ if (!rule.action.startsWith("run:")) return rule;
289
+ return {
290
+ ...rule,
291
+ action: `run:${packName}/${rule.action.slice(4)}`
292
+ };
293
+ }
294
+ function packRuleText(rule, packName) {
295
+ const { name, ...matchAndAction } = packRule(rule, packName);
296
+ return `${name}: ${JSON.stringify(matchAndAction)}`;
297
+ }
298
+ function packCommands(loaded) {
299
+ return {
300
+ sources: loaded.pack.sources.map((command) => packCommand(command, loaded)),
301
+ actions: loaded.pack.actions.map((command) => packCommand(command, loaded)),
302
+ prActions: loaded.pack.prActions.map((command) => packCommand(command, loaded))
303
+ };
304
+ }
305
+ function kindedCommands(commands) {
306
+ return [
307
+ ...commands.prActions.map((command) => ({
308
+ kind: "pr-action",
309
+ command
310
+ })),
311
+ ...commands.sources.map((command) => ({
312
+ kind: "source",
313
+ command
314
+ })),
315
+ ...commands.actions.map((command) => ({
316
+ kind: "action",
317
+ command
318
+ }))
319
+ ];
320
+ }
321
+ function packApproval(loaded) {
322
+ const { pack } = loaded;
323
+ const commands = kindedCommands(packCommands(loaded)).map(({ kind, command }) => {
324
+ const repos = normalizedRepos(command);
325
+ return {
326
+ kind,
327
+ id: command.id,
328
+ label: command.label,
329
+ command: command.command,
330
+ ...repos === null ? {} : { repos }
331
+ };
332
+ });
333
+ return {
334
+ kind: "pack",
335
+ id: pack.name,
336
+ label: `${pack.name} v${pack.version}`,
337
+ command: [],
338
+ timeoutSeconds: 0,
339
+ fingerprint: loaded.fingerprint,
340
+ pack: {
341
+ version: pack.version,
342
+ requires: pack.requires,
343
+ missing: loaded.missingRequires,
344
+ commands,
345
+ rules: pack.rules.map((rule) => packRuleText(rule, pack.name))
346
+ }
347
+ };
348
+ }
349
+ function prFlowSetup(configFile, packLoad, approvedFingerprints) {
350
+ const personal = prFlowCommands(configFile);
351
+ const approved = new Set(approvedFingerprints);
352
+ const approvals = [...pendingApprovals(personal, approved), ...packLoad.packs.filter((loaded) => !approved.has(loaded.fingerprint)).map(packApproval)];
353
+ const approvedPacks = packLoad.packs.filter((loaded) => approved.has(loaded.fingerprint));
354
+ const enabledPacks = approvedPacks.filter((loaded) => loaded.missingRequires.length === 0);
355
+ const offNotes = approvedPacks.filter((loaded) => loaded.missingRequires.length > 0).map((loaded) => `The pack '${loaded.pack.name}' is off until this machine has ${loaded.missingRequires.join(", ")}`);
356
+ const enabledCommands = enabledPacks.map(packCommands);
357
+ for (const { kind, command } of enabledCommands.flatMap(kindedCommands)) approved.add(commandFingerprint(kind, command));
358
+ return {
359
+ commands: {
360
+ sources: [...personal.sources, ...enabledCommands.flatMap((commands) => commands.sources)],
361
+ actions: [...personal.actions, ...enabledCommands.flatMap((commands) => commands.actions)],
362
+ prActions: [...personal.prActions, ...enabledCommands.flatMap((commands) => commands.prActions)],
363
+ warnings: [
364
+ ...personal.warnings,
365
+ ...packLoad.warnings,
366
+ ...offNotes
367
+ ]
368
+ },
369
+ approved,
370
+ approvals,
371
+ packRules: enabledPacks.flatMap((loaded) => loaded.pack.rules.map((rule) => packRule(rule, loaded.pack.name)))
372
+ };
373
+ }
374
+ function packPathsOf(configFile) {
375
+ const raw = ConfigFileWithPrFlows.safeParse(configFile).data?.prFlows;
376
+ return PrFlowsSettings.safeParse(raw ?? {}).data?.packs ?? [];
261
377
  }
262
378
  function pendingApprovals(commands, approvedFingerprints) {
263
- return [...commands.sources.map((command) => ({
264
- kind: "source",
265
- command
266
- })), ...commands.actions.map((command) => ({
267
- kind: "action",
268
- command
269
- }))].flatMap(({ kind, command }) => {
379
+ return [
380
+ ...commands.sources.map((command) => ({
381
+ kind: "source",
382
+ command
383
+ })),
384
+ ...commands.actions.map((command) => ({
385
+ kind: "action",
386
+ command
387
+ })),
388
+ ...commands.prActions.map((command) => ({
389
+ kind: "pr-action",
390
+ command
391
+ }))
392
+ ].flatMap(({ kind, command }) => {
270
393
  const fingerprint = commandFingerprint(kind, command);
271
394
  if (approvedFingerprints.has(fingerprint)) return [];
395
+ const repos = normalizedRepos(command);
272
396
  return [{
273
397
  kind,
274
398
  id: command.id,
275
399
  label: command.label,
276
400
  command: command.command,
277
401
  timeoutSeconds: command.timeoutSeconds,
278
- fingerprint
402
+ fingerprint,
403
+ ...repos === null ? {} : { repos }
279
404
  }];
280
405
  });
281
406
  }
407
+ function prActionsForRepo(prActions, repo) {
408
+ const wantedRepo = repo.toLowerCase();
409
+ return prActions.filter((action) => action.repos === void 0 || action.repos.some((listedRepo) => listedRepo.toLowerCase() === wantedRepo));
410
+ }
411
+ function prActionPlaceholderValues(pr) {
412
+ return {
413
+ prUrl: pr.url,
414
+ repo: pr.repo,
415
+ number: String(pr.number),
416
+ head: pr.headRefOid,
417
+ headRef: pr.headRefName,
418
+ baseRef: pr.baseRefName
419
+ };
420
+ }
421
+ function withPrActionRun(state, prKey, run) {
422
+ return {
423
+ ...state,
424
+ prActionRunByPr: {
425
+ ...state.prActionRunByPr,
426
+ [prKey]: {
427
+ ...state.prActionRunByPr[prKey],
428
+ [run.actionId]: run
429
+ }
430
+ }
431
+ };
432
+ }
433
+ function prActionRunAfterExit(run, output, nowMs) {
434
+ if (output.outcome === "started") return {
435
+ ...run,
436
+ state: "started",
437
+ message: output.message
438
+ };
439
+ return {
440
+ ...run,
441
+ state: output.outcome,
442
+ message: output.message,
443
+ finishedAt: nowMs,
444
+ reportToken: null
445
+ };
446
+ }
447
+ function isSameToken(presented, expected) {
448
+ const presentedBytes = Buffer.from(presented, "utf8");
449
+ const expectedBytes = Buffer.from(expected, "utf8");
450
+ return presentedBytes.length === expectedBytes.length && crypto.timingSafeEqual(presentedBytes, expectedBytes);
451
+ }
452
+ function acceptReport(run, presentedToken, body, nowMs) {
453
+ if (run.state !== "running" && run.state !== "started") return {
454
+ ok: false,
455
+ status: 409
456
+ };
457
+ if (run.reportToken === null || !isSameToken(presentedToken, run.reportToken)) return {
458
+ ok: false,
459
+ status: 401
460
+ };
461
+ if (body.outcome === "started") return {
462
+ ok: true,
463
+ run: {
464
+ ...run,
465
+ state: "started",
466
+ message: body.message ?? run.message
467
+ }
468
+ };
469
+ return {
470
+ ok: true,
471
+ run: {
472
+ ...run,
473
+ state: body.outcome,
474
+ message: body.message ?? "",
475
+ finishedAt: nowMs,
476
+ reportToken: null
477
+ }
478
+ };
479
+ }
480
+ var INTERRUPTED_MESSAGE = "Glimmervoid restarted";
481
+ function interruptedOnLoad(run) {
482
+ if (run.state !== "running") return run;
483
+ return {
484
+ ...run,
485
+ state: "interrupted",
486
+ message: INTERRUPTED_MESSAGE,
487
+ reportToken: null
488
+ };
489
+ }
490
+ function withInterruptedRuns(state) {
491
+ const prActionRunByPr = Object.fromEntries(Object.entries(state.prActionRunByPr).map(([prKey, runs]) => [prKey, Object.fromEntries(Object.entries(runs).map(([actionId, run]) => [actionId, interruptedOnLoad(run)]))]));
492
+ return {
493
+ ...state,
494
+ prActionRunByPr
495
+ };
496
+ }
497
+ function visibleRun(run, pr) {
498
+ if (!run) return null;
499
+ if (!(run.state === "running" || run.state === "started") && run.head !== pr.headRefOid) return null;
500
+ return {
501
+ actionId: run.actionId,
502
+ label: run.label,
503
+ state: run.state,
504
+ message: run.message
505
+ };
506
+ }
282
507
  var PLACEHOLDER_PATTERN = /\{([A-Za-z][A-Za-z0-9_]*)\}/g;
283
508
  function expandPlaceholders(argv, values) {
284
509
  const unknownName = argv.flatMap((element) => [...element.matchAll(PLACEHOLDER_PATTERN)].map((match) => match[1] ?? "")).find((name) => !Object.hasOwn(values, name));
@@ -383,10 +608,199 @@ function fixLocallyPrompt(prUrl, item, fence) {
383
608
  ].join("\n\n");
384
609
  }
385
610
  //#endregion
611
+ //#region shared/contracts/pr-pack.ts
612
+ var PR_PACK_FILE_NAME = "pack.json";
613
+ var PrPack = z.strictObject({
614
+ $schema: z.string().optional(),
615
+ name: z.string().regex(/^[a-z0-9][a-z0-9-]{0,39}$/, { error: "a pack name is lowercase letters, digits and dashes, at most 40 characters" }),
616
+ version: z.number().int().positive(),
617
+ description: z.string().max(500).optional(),
618
+ requires: PrFlowPackRequires.default({
619
+ env: [],
620
+ programs: []
621
+ }),
622
+ prActions: z.array(PrFlowPrAction).default([]),
623
+ sources: z.array(PrFlowCommand).default([]),
624
+ actions: z.array(PrFlowCommand).default([]),
625
+ rules: z.array(PrFlowRule).default([])
626
+ }).superRefine((pack, context) => {
627
+ for (const kind of [
628
+ "prActions",
629
+ "sources",
630
+ "actions"
631
+ ]) {
632
+ const seenIds = /* @__PURE__ */ new Set();
633
+ pack[kind].forEach((command, index) => {
634
+ if (seenIds.has(command.id)) context.addIssue({
635
+ code: "custom",
636
+ path: [
637
+ kind,
638
+ index,
639
+ "id"
640
+ ],
641
+ message: `the id '${command.id}' is already used in ${kind}`
642
+ });
643
+ seenIds.add(command.id);
644
+ });
645
+ }
646
+ });
647
+ //#endregion
648
+ //#region server/github/pr-packs.ts
649
+ var PACK_MAX_TOTAL_BYTES = 1048576;
650
+ var PACKS_DIR_NAME = "packs";
651
+ function sha256(bytes) {
652
+ return crypto.createHash("sha256").update(bytes).digest("hex");
653
+ }
654
+ function readPackFiles(packDir) {
655
+ const files = [];
656
+ const pendingDirs = [""];
657
+ let totalBytes = 0;
658
+ while (pendingDirs.length > 0) {
659
+ const relativeDir = pendingDirs.pop() ?? "";
660
+ for (const entry of fs.readdirSync(path.join(packDir, relativeDir), { withFileTypes: true })) {
661
+ const relativePath = path.posix.join(relativeDir, entry.name);
662
+ if (entry.isSymbolicLink()) return {
663
+ ok: false,
664
+ error: `${relativePath} is a symlink, and a pack holds only its own files`
665
+ };
666
+ if (entry.isDirectory()) {
667
+ pendingDirs.push(relativePath);
668
+ continue;
669
+ }
670
+ if (!entry.isFile()) return {
671
+ ok: false,
672
+ error: `${relativePath} is not a regular file`
673
+ };
674
+ totalBytes += fs.lstatSync(path.join(packDir, relativePath)).size;
675
+ if (totalBytes > PACK_MAX_TOTAL_BYTES) return {
676
+ ok: false,
677
+ error: "the pack is over 1 MiB"
678
+ };
679
+ files.push({
680
+ relativePath,
681
+ bytes: fs.readFileSync(path.join(packDir, relativePath))
682
+ });
683
+ }
684
+ }
685
+ return {
686
+ ok: true,
687
+ files
688
+ };
689
+ }
690
+ function packFingerprint(files) {
691
+ const fileHashes = files.map((file) => [file.relativePath, sha256(file.bytes)]).sort(([left = ""], [right = ""]) => left.localeCompare(right));
692
+ return sha256(JSON.stringify(fileHashes));
693
+ }
694
+ function isProgramOnPath(program, env) {
695
+ return (env.PATH ?? "").split(path.delimiter).filter(Boolean).some((dir) => {
696
+ const candidate = path.join(dir, program);
697
+ try {
698
+ fs.accessSync(candidate, fs.constants.X_OK);
699
+ return fs.statSync(candidate).isFile();
700
+ } catch {
701
+ return false;
702
+ }
703
+ });
704
+ }
705
+ function missingRequires(requires, env) {
706
+ const commandEnv = withoutGlimmervoidSecrets(env);
707
+ return [...requires.env.filter((name) => !commandEnv[name]).map((name) => `env ${name}`), ...requires.programs.filter((program) => !isProgramOnPath(program, env)).map((program) => `program ${program}`)];
708
+ }
709
+ function readPackDirUnguarded(packDir, env) {
710
+ if (/[{}]/.test(packDir)) return {
711
+ ok: false,
712
+ errors: [`${packDir} has { or } in its path, which a command placeholder would misread`]
713
+ };
714
+ const stats = fs.lstatSync(packDir);
715
+ if (stats.isSymbolicLink() || !stats.isDirectory()) return {
716
+ ok: false,
717
+ errors: [`${packDir} is not a directory; a symlinked pack is refused`]
718
+ };
719
+ const read = readPackFiles(packDir);
720
+ if (!read.ok) return {
721
+ ok: false,
722
+ errors: [read.error]
723
+ };
724
+ const manifest = read.files.find((file) => file.relativePath === PR_PACK_FILE_NAME);
725
+ if (!manifest) return {
726
+ ok: false,
727
+ errors: [`there is no ${PR_PACK_FILE_NAME}`]
728
+ };
729
+ const parsed = PrPack.safeParse(parseJsonOrNull(manifest.bytes.toString("utf8")));
730
+ if (!parsed.success) return {
731
+ ok: false,
732
+ errors: parsed.error.issues.map((issue) => `${PR_PACK_FILE_NAME} ${issue.path.join(".") || "(root)"}: ${issue.message}`)
733
+ };
734
+ return {
735
+ ok: true,
736
+ pack: {
737
+ dir: packDir,
738
+ pack: parsed.data,
739
+ fingerprint: packFingerprint(read.files),
740
+ missingRequires: missingRequires(parsed.data.requires, env)
741
+ }
742
+ };
743
+ }
744
+ function readPackDir(packDir, env) {
745
+ const absoluteDir = path.resolve(packDir);
746
+ try {
747
+ return readPackDirUnguarded(absoluteDir, env);
748
+ } catch (error) {
749
+ return {
750
+ ok: false,
751
+ errors: [`could not read ${absoluteDir}: ${errorMessage(error)}`]
752
+ };
753
+ }
754
+ }
755
+ function packDirsUnder(homeDir) {
756
+ const packsDir = path.join(homeDir, PACKS_DIR_NAME);
757
+ if (!fs.existsSync(packsDir)) return {
758
+ packDirs: [],
759
+ warning: null
760
+ };
761
+ try {
762
+ return {
763
+ packDirs: fs.readdirSync(packsDir, { withFileTypes: true }).map((entry) => path.join(packsDir, entry.name)).filter((packDir) => fs.existsSync(path.join(packDir, PR_PACK_FILE_NAME))).sort(),
764
+ warning: null
765
+ };
766
+ } catch (error) {
767
+ return {
768
+ packDirs: [],
769
+ warning: `The packs folder ${packsDir} could not be read, so its packs were skipped: ${errorMessage(error)}`
770
+ };
771
+ }
772
+ }
773
+ function loadPacks({ homeDir, configPaths, env }) {
774
+ const packs = [];
775
+ const homePacks = packDirsUnder(homeDir);
776
+ const warnings = homePacks.warning === null ? [] : [homePacks.warning];
777
+ const packDirs = [.../* @__PURE__ */ new Set([...homePacks.packDirs, ...configPaths.map((configPath) => path.resolve(homeDir, configPath))])];
778
+ for (const packDir of packDirs) {
779
+ const read = readPackDir(packDir, env);
780
+ if (!read.ok) {
781
+ warnings.push(`The pack at ${packDir} was skipped: ${read.errors[0] ?? "unreadable"}`);
782
+ continue;
783
+ }
784
+ if (packs.some((loaded) => loaded.pack.name === read.pack.pack.name)) {
785
+ warnings.push(`The pack at ${packDir} was skipped: another pack is already named '${read.pack.pack.name}'`);
786
+ continue;
787
+ }
788
+ packs.push(read.pack);
789
+ }
790
+ return {
791
+ packs,
792
+ warnings
793
+ };
794
+ }
795
+ //#endregion
386
796
  //#region server/github/pr-flows-external.ts
387
797
  var OUTPUT_MAX_BYTES = 1048576;
388
798
  var ACTION_OUTPUT_MAX_BYTES = 67108864;
389
799
  var ERROR_MAX_CHARACTERS = 200;
800
+ var UNBOUNDED_PR_FIELDS = /* @__PURE__ */ new Set(["threads", "reviewItems"]);
801
+ function boundedPrJson(pr) {
802
+ return JSON.stringify(Object.fromEntries(Object.entries(pr).filter(([field]) => !UNBOUNDED_PR_FIELDS.has(field))));
803
+ }
390
804
  var CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]+/g;
391
805
  function firstCharacters(text) {
392
806
  return [...text.replace(CONTROL_CHARACTERS, " ").trim()].slice(0, ERROR_MAX_CHARACTERS).join("");
@@ -452,29 +866,51 @@ function createPrFlowsExternal({ homeDir, baseEnv = () => process.env, runComman
452
866
  output: output.data
453
867
  };
454
868
  }
455
- async function runAction(action, pr, item) {
456
- const values = {
457
- ...placeholderValues(pr),
458
- itemPath: item.path,
459
- itemLine: item.lineStart === null ? "" : String(item.lineStart)
869
+ function itemInvocation(pr, item) {
870
+ return {
871
+ values: {
872
+ ...placeholderValues(pr),
873
+ itemPath: item.path,
874
+ itemLine: item.lineStart === null ? "" : String(item.lineStart)
875
+ },
876
+ knownNames: "{prUrl}, {repo}, {number}, {head}, {itemPath} or {itemLine}",
877
+ env: {
878
+ ...commandEnv(pr),
879
+ GLIMMERVOID_ITEM_JSON: JSON.stringify(item)
880
+ }
881
+ };
882
+ }
883
+ function prInvocation(pr, extraEnv) {
884
+ return {
885
+ values: prActionPlaceholderValues(pr),
886
+ knownNames: "{prUrl}, {repo}, {number}, {head}, {headRef} or {baseRef}",
887
+ env: {
888
+ ...commandEnv(pr),
889
+ GLIMMERVOID_PR_HEAD_REF: pr.headRefName,
890
+ GLIMMERVOID_PR_BASE_REF: pr.baseRefName,
891
+ GLIMMERVOID_PR_JSON: boundedPrJson(pr),
892
+ ...extraEnv
893
+ }
460
894
  };
895
+ }
896
+ async function runAction(action, pr, item, extraEnv = {}) {
897
+ const { values, knownNames, env } = item === void 0 ? prInvocation(pr, extraEnv) : itemInvocation(pr, item);
461
898
  const expanded = expandPlaceholders(action.command, values);
462
899
  if (!expanded.ok) return {
463
900
  outcome: "failed",
464
- message: unknownPlaceholderError(expanded.unknown, "{prUrl}, {repo}, {number}, {head}, {itemPath} or {itemLine}")
901
+ message: unknownPlaceholderError(expanded.unknown, knownNames)
465
902
  };
466
903
  const [program, ...args] = expanded.argv;
467
904
  if (program === void 0) return {
468
905
  outcome: "failed",
469
906
  message: "The command is empty."
470
907
  };
908
+ const timeoutMs = action.timeoutSeconds * 1e3;
909
+ const startedAtMs = performance.now();
471
910
  const run = await runCommand(program, args, {
472
911
  cwd: homeDir,
473
- env: {
474
- ...commandEnv(pr),
475
- GLIMMERVOID_ITEM_JSON: JSON.stringify(item)
476
- },
477
- timeoutMs: action.timeoutSeconds * 1e3,
912
+ env,
913
+ timeoutMs,
478
914
  maxBufferBytes: ACTION_OUTPUT_MAX_BYTES
479
915
  });
480
916
  const reported = reportedActionOutcome(run.stdout);
@@ -483,6 +919,10 @@ function createPrFlowsExternal({ homeDir, baseEnv = () => process.env, runComman
483
919
  outcome: "done",
484
920
  message: ""
485
921
  };
922
+ if (performance.now() - startedAtMs >= timeoutMs) return {
923
+ outcome: "failed",
924
+ message: `timed out after ${action.timeoutSeconds}s`
925
+ };
486
926
  return {
487
927
  outcome: "failed",
488
928
  message: firstCharacters(run.stderr) || "The command failed with no error output."
@@ -494,4 +934,4 @@ function createPrFlowsExternal({ homeDir, baseEnv = () => process.env, runComman
494
934
  };
495
935
  }
496
936
  //#endregion
497
- export { withRuleRun as S, threadCandidates as _, fixLocallyPrompt as a, withOnlyOpenPrs as b, mergeItems as c, prFlowCommands as d, prFlowRules as f, teammateThreadItems as g, sourceCandidates as h, expandPlaceholders as i, pendingApprovals as l, shouldTellBranchMoved as m, branchMovedNote as n, flaggingReviewers as o, savedRuleFor as p, commandFingerprint as r, itemLocation as s, createPrFlowsExternal as t, plannedActions as u, unknownActionWarnings as v, withReopened as x, withHandled as y };
937
+ export { withPrActionRun as A, teammateThreadItems as C, withHandled as D, visibleRun as E, withRuleRun as M, withInterruptedRuns as O, sourceCandidates as S, unknownActionWarnings as T, prFlowCommands as _, branchMovedNote as a, savedRuleFor as b, fixLocallyPrompt as c, mergeItems as d, packApproval as f, prActionsForRepo as g, prActionRunAfterExit as h, acceptReport as i, withReopened as j, withOnlyOpenPrs as k, flaggingReviewers as l, plannedActions as m, loadPacks as n, commandFingerprint as o, packPathsOf as p, readPackDir as r, expandPlaceholders as s, createPrFlowsExternal as t, itemLocation as u, prFlowRules as v, threadCandidates as w, shouldTellBranchMoved as x, prFlowSetup as y };
@@ -2,7 +2,7 @@ import { n as errorLabel, r as errorMessage } from "./text-DoirglWV.js";
2
2
  import { u as equalsIgnoringCaseOnWindows } from "./runtime-paths-CYwF658V.js";
3
3
  import { n as isRecord } from "./coerce-oz_Z_6E7.js";
4
4
  import { a as jsonStateLoadError, d as writeJsonAtomicSync, l as sleepSync, s as loadJsonStateFileSync, u as writeJsonAtomic } from "./json-file-AKRVPqG1.js";
5
- import { b as DEFAULT_TIMER_FNS, o as glimmervoidHomeDir, x as unrefTimer, xt as canonicalizePath } from "./config-store-3MDjeSxI.js";
5
+ import { b as DEFAULT_TIMER_FNS, o as glimmervoidHomeDir, x as unrefTimer, xt as canonicalizePath } from "./config-store-Bqag5_2n.js";
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import crypto from "node:crypto";