glimmervoid 0.52.2-next.696 → 0.52.2-next.698
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.
- package/dist/bin/glimmervoid.js +15 -10
- package/dist/chunks/{adapters-BbOhEt3K.js → adapters-BQVgsufG.js} +1 -1
- package/dist/chunks/{adapters-KsgiBN7g.js → adapters-BwrJAzEk.js} +2 -2
- package/dist/chunks/agent-api-cli-CAVmc6oB.js +1 -0
- package/dist/chunks/{agent-api-cli-oEczDo6J.js → agent-api-cli-CtQRT4Db.js} +1 -1
- package/dist/chunks/{agent-api-core-Bx7YtsJX.js → agent-api-core-Ddnr3HgI.js} +45 -1
- package/dist/chunks/{config-DMO8GHVh.js → config-BL8YQ3Ak.js} +1 -1
- package/dist/chunks/config-store-CEM4SJvM.js +1 -0
- package/dist/chunks/{config-store-BZU0pwDi.js → config-store-aB3AE95Q.js} +1 -1
- package/dist/chunks/{main-BJFZUB8b.js → main-D6DExe_h.js} +9 -104
- package/dist/chunks/{pr-flows-external-BRtHbSYM.js → pack-agent-DlW4j1b6.js} +267 -170
- package/dist/chunks/pack-bridge-CQ2Jlear.js +153 -0
- package/dist/chunks/packs-cli-DCKa39sG.js +502 -0
- package/dist/chunks/packs-cli-DV__4MB_.js +1 -0
- package/dist/chunks/{pair-cli-COUf3oqu.js → pair-cli-Dud8jpuO.js} +2 -2
- package/dist/chunks/{pr-flows-cli-CXEWmN7B.js → pr-flows-cli-Clw5RPyH.js} +7 -16
- package/dist/chunks/pr-flows-external-DfN4780W.js +147 -0
- package/dist/chunks/{remote-config-DGikQcIX.js → remote-config-dHj-Qfux.js} +1 -1
- package/dist/chunks/{settings-cli-C1MpfiMd.js → settings-cli-9Z0TOaxK.js} +4 -4
- package/dist/chunks/{settings-readout-core-CmSf-Xx7.js → settings-readout-core-c06UYQ-8.js} +1 -1
- package/dist/chunks/{ssh-sign-cli-CzTz9BiL.js → ssh-sign-cli-CtLGtrUf.js} +1 -1
- package/dist/client/assets/{action-status-DP6ioCmx.js → action-status-Bbo7Fyia.js} +1 -1
- package/dist/client/assets/action-status-Bbo7Fyia.js.br +0 -0
- package/dist/client/assets/{arena-panel-DTCrFsxM.js → arena-panel-BGtzm6-h.js} +2 -2
- package/dist/client/assets/arena-panel-BGtzm6-h.js.br +0 -0
- package/dist/client/assets/{benchmark-panel-ChX5JowB.js → benchmark-panel-BS86mOhW.js} +1 -1
- package/dist/client/assets/benchmark-panel-BS86mOhW.js.br +0 -0
- package/dist/client/assets/{boards-view-Jd7gKYBw.js → boards-view-Ducqesi-.js} +1 -1
- package/dist/client/assets/boards-view-Ducqesi-.js.br +0 -0
- package/dist/client/assets/button-CeEmJCQe.js +1 -0
- package/dist/client/assets/button-CeEmJCQe.js.br +0 -0
- package/dist/client/assets/{card-actions-zCz9tHtX.js → card-actions-D5VASOyl.js} +1 -1
- package/dist/client/assets/{card-registry-BDFzrxQP.js → card-registry-CxPu9XGn.js} +1 -1
- package/dist/client/assets/card-registry-CxPu9XGn.js.br +0 -0
- package/dist/client/assets/{community-panel-DiqdtI0j.js → community-panel-B2aGz3M_.js} +1 -1
- package/dist/client/assets/community-panel-B2aGz3M_.js.br +0 -0
- package/dist/client/assets/{control-ws-UoNejDTB.js → control-ws-DxQoY1aG.js} +1 -1
- package/dist/client/assets/control-ws-DxQoY1aG.js.br +0 -0
- package/dist/client/assets/{dialogs-DAxdV4Ya.js → dialogs-BGW6bYC1.js} +1 -1
- package/dist/client/assets/dialogs-BGW6bYC1.js.br +0 -0
- package/dist/client/assets/{doc-editor-ui-B2DWcFwB.js → doc-editor-ui-DBTRgzEJ.js} +1 -1
- package/dist/client/assets/doc-editor-ui-DBTRgzEJ.js.br +0 -0
- package/dist/client/assets/{feature-hint-MM2QjFQe.js → feature-hint-6SXhqHn6.js} +1 -1
- package/dist/client/assets/feature-hint-6SXhqHn6.js.br +0 -0
- package/dist/client/assets/{first-run-checklist-C9tFDANC.js → first-run-checklist-OEwjiMsu.js} +1 -1
- package/dist/client/assets/first-run-checklist-OEwjiMsu.js.br +0 -0
- package/dist/client/assets/{hooks-panel-BvdwdaLU.js → hooks-panel-DJeHk5WE.js} +1 -1
- package/dist/client/assets/hooks-panel-DJeHk5WE.js.br +0 -0
- package/dist/client/assets/index-DUwZcJUo.js +75 -0
- package/dist/client/assets/index-DUwZcJUo.js.br +0 -0
- package/dist/client/assets/{issues-panel-CNKO97cT.js → issues-panel-Cn5zZjaR.js} +1 -1
- package/dist/client/assets/issues-panel-Cn5zZjaR.js.br +0 -0
- package/dist/client/assets/{lane-read-token-step-ryHfcWWE.js → lane-read-token-step-CC6NhoTq.js} +1 -1
- package/dist/client/assets/lane-read-token-step-CC6NhoTq.js.br +0 -0
- package/dist/client/assets/{menu-ER74fqs1.js → menu-ByAf-D4t.js} +1 -1
- package/dist/client/assets/menu-ByAf-D4t.js.br +0 -0
- package/dist/client/assets/{modal-T0t68alc.js → modal-Cccq9QKp.js} +1 -1
- package/dist/client/assets/modal-Cccq9QKp.js.br +0 -0
- package/dist/client/assets/{my-prs-panel-CZAe96On.js → my-prs-panel-DZNJ3COA.js} +1 -1
- package/dist/client/assets/my-prs-panel-DZNJ3COA.js.br +0 -0
- package/dist/client/assets/{nyan-cat-BaCicPsF.js → nyan-cat-vOSaeGZZ.js} +1 -1
- package/dist/client/assets/nyan-cat-vOSaeGZZ.js.br +0 -0
- package/dist/client/assets/{phone-shell-BAPtgQEw.js → phone-shell-B1Xy8dV0.js} +1 -1
- package/dist/client/assets/phone-shell-B1Xy8dV0.js.br +0 -0
- package/dist/client/assets/{plan-face-D4LgyDxJ.js → plan-face-DwF3CM5Q.js} +1 -1
- package/dist/client/assets/plan-face-DwF3CM5Q.js.br +0 -0
- package/dist/client/assets/{plan-render-DKucc3fP.js → plan-render-BDZCII8j.js} +1 -1
- package/dist/client/assets/plan-render-BDZCII8j.js.br +0 -0
- package/dist/client/assets/{pr-queue-columns-D5W6JOUJ.js → pr-queue-columns-Ckwk8h4C.js} +1 -1
- package/dist/client/assets/pr-queue-columns-Ckwk8h4C.js.br +3 -0
- package/dist/client/assets/{pr-status-icon-Bt7cQdYv.js → pr-status-icon-DxYoCfBP.js} +1 -1
- package/dist/client/assets/pr-status-icon-DxYoCfBP.js.br +0 -0
- package/dist/client/assets/{radar-panel-B7tYNfQs.js → radar-panel-C44LvXWs.js} +1 -1
- package/dist/client/assets/radar-panel-C44LvXWs.js.br +0 -0
- package/dist/client/assets/{repo-roots-adder-BgJFf5r9.js → repo-roots-adder-fAYDtwvT.js} +1 -1
- package/dist/client/assets/repo-roots-adder-fAYDtwvT.js.br +0 -0
- package/dist/client/assets/{resume-dialog-_7bYQ8oc.js → resume-dialog-D65npA5q.js} +1 -1
- package/dist/client/assets/resume-dialog-D65npA5q.js.br +0 -0
- package/dist/client/assets/{review-queue-panel-Dys39rVA.js → review-queue-panel-BaEU-YqX.js} +1 -1
- package/dist/client/assets/review-queue-panel-BaEU-YqX.js.br +0 -0
- package/dist/client/assets/{session-actions-I1pBKLzG.js → session-actions-xAzCcHSr.js} +2 -2
- package/dist/client/assets/session-actions-xAzCcHSr.js.br +0 -0
- package/dist/client/assets/{session-row-BOtCbuSs.js → session-row-DIuYJKHP.js} +1 -1
- package/dist/client/assets/session-row-DIuYJKHP.js.br +0 -0
- package/dist/client/assets/{session-tick-CICZHafe.js → session-tick-lPppK7OC.js} +1 -1
- package/dist/client/assets/session-tick-lPppK7OC.js.br +0 -0
- package/dist/client/assets/{settings-panel-ud7ZNSSr.js → settings-panel-BAhxUmv4.js} +2 -2
- package/dist/client/assets/settings-panel-BAhxUmv4.js.br +0 -0
- package/dist/client/assets/{setup-step-CaBKPldA.js → setup-step-B0XzLQJc.js} +1 -1
- package/dist/client/assets/setup-step-B0XzLQJc.js.br +0 -0
- package/dist/client/assets/{shown-face-CrNgbkwC.js → shown-face-Diy41qjX.js} +1 -1
- package/dist/client/assets/shown-face-Diy41qjX.js.br +0 -0
- package/dist/client/assets/{trace-panel-BpnR135w.js → trace-panel-GzPpn55L.js} +1 -1
- package/dist/client/assets/trace-panel-GzPpn55L.js.br +0 -0
- package/dist/client/assets/{usage-panel-CRy1hQbJ.js → usage-panel-Bl1jCdeG.js} +1 -1
- package/dist/client/assets/usage-panel-Bl1jCdeG.js.br +0 -0
- package/dist/client/assets/{your-day-tip-Bjx_1PU1.js → your-day-tip-yVmvLHsf.js} +1 -1
- package/dist/client/assets/your-day-tip-yVmvLHsf.js.br +0 -0
- package/dist/client/index.html +12 -12
- package/dist/client/index.html.br +0 -0
- package/dist/examples/packs/plan-usage/icon.svg +1 -0
- package/dist/examples/packs/plan-usage/pack.json +11 -0
- package/dist/examples/packs/plan-usage/panel/bridge.js +23 -0
- package/dist/examples/packs/plan-usage/panel/index.html +15 -0
- package/dist/examples/packs/plan-usage/panel/panel.css +15 -0
- package/dist/examples/packs/plan-usage/panel/panel.js +56 -0
- package/dist/schema/pack.v1.json +43 -21
- package/dist/server/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/agent-api-cli-D93znXwp.js +0 -1
- package/dist/chunks/config-store-DT65GJMG.js +0 -1
- package/dist/chunks/pack-bridge-DifQHfqf.js +0 -152
- package/dist/client/assets/action-status-DP6ioCmx.js.br +0 -0
- package/dist/client/assets/arena-panel-DTCrFsxM.js.br +0 -0
- package/dist/client/assets/benchmark-panel-ChX5JowB.js.br +0 -0
- package/dist/client/assets/boards-view-Jd7gKYBw.js.br +0 -0
- package/dist/client/assets/button-CBoNTVJe.js +0 -1
- package/dist/client/assets/button-CBoNTVJe.js.br +0 -0
- package/dist/client/assets/card-registry-BDFzrxQP.js.br +0 -0
- package/dist/client/assets/community-panel-DiqdtI0j.js.br +0 -0
- package/dist/client/assets/control-ws-UoNejDTB.js.br +0 -0
- package/dist/client/assets/dialogs-DAxdV4Ya.js.br +0 -0
- package/dist/client/assets/doc-editor-ui-B2DWcFwB.js.br +0 -0
- package/dist/client/assets/feature-hint-MM2QjFQe.js.br +0 -0
- package/dist/client/assets/first-run-checklist-C9tFDANC.js.br +0 -0
- package/dist/client/assets/hooks-panel-BvdwdaLU.js.br +0 -0
- package/dist/client/assets/index-B2rff7bh.js +0 -75
- package/dist/client/assets/index-B2rff7bh.js.br +0 -0
- package/dist/client/assets/issues-panel-CNKO97cT.js.br +0 -0
- package/dist/client/assets/lane-read-token-step-ryHfcWWE.js.br +0 -0
- package/dist/client/assets/menu-ER74fqs1.js.br +0 -0
- package/dist/client/assets/modal-T0t68alc.js.br +0 -0
- package/dist/client/assets/my-prs-panel-CZAe96On.js.br +0 -0
- package/dist/client/assets/nyan-cat-BaCicPsF.js.br +0 -0
- package/dist/client/assets/phone-shell-BAPtgQEw.js.br +0 -0
- package/dist/client/assets/plan-face-D4LgyDxJ.js.br +0 -0
- package/dist/client/assets/plan-render-DKucc3fP.js.br +0 -0
- package/dist/client/assets/pr-queue-columns-D5W6JOUJ.js.br +0 -0
- package/dist/client/assets/pr-status-icon-Bt7cQdYv.js.br +0 -0
- package/dist/client/assets/radar-panel-B7tYNfQs.js.br +0 -0
- package/dist/client/assets/repo-roots-adder-BgJFf5r9.js.br +0 -0
- package/dist/client/assets/resume-dialog-_7bYQ8oc.js.br +0 -0
- package/dist/client/assets/review-queue-panel-Dys39rVA.js.br +0 -0
- package/dist/client/assets/session-actions-I1pBKLzG.js.br +0 -0
- package/dist/client/assets/session-row-BOtCbuSs.js.br +0 -0
- package/dist/client/assets/session-tick-CICZHafe.js.br +0 -0
- package/dist/client/assets/settings-panel-ud7ZNSSr.js.br +0 -0
- package/dist/client/assets/setup-step-CaBKPldA.js.br +0 -0
- package/dist/client/assets/shown-face-CrNgbkwC.js.br +0 -0
- package/dist/client/assets/trace-panel-BpnR135w.js.br +0 -0
- package/dist/client/assets/usage-panel-CRy1hQbJ.js.br +0 -0
- package/dist/client/assets/your-day-tip-Bjx_1PU1.js.br +0 -0
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
import { r as errorMessage } from "./text-DoirglWV.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { r as ThemePalette, t as PackBridgeTopic } from "./pack-bridge-DifQHfqf.js";
|
|
2
|
+
import { Mn as prFlowRulesJsonSchema, Sn as PrFlowRule, Tn as PrFlowsSettings, hn as PrFlowCommand, xn as PrFlowPrAction, yn as PrFlowPackRequires } from "./session-BrX33men.js";
|
|
3
|
+
import { i as ThemePalette, n as packBridgeJsonSchemaText, t as PackBridgeTopic } from "./pack-bridge-CQ2Jlear.js";
|
|
5
4
|
import { t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
|
|
6
5
|
import { n as withoutGlimmervoidSecrets } from "./spawn-env-C9TqrBFa.js";
|
|
7
6
|
import fs from "node:fs";
|
|
8
7
|
import path from "node:path";
|
|
9
8
|
import { z } from "zod";
|
|
10
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
|
|
11
39
|
//#region server/github/core/pr-flows-core.ts
|
|
12
40
|
var MERGE_LINE_DISTANCE = 3;
|
|
13
41
|
var BODY_PREFIX_CHARACTERS = 120;
|
|
@@ -686,6 +714,14 @@ var PACK_PANEL_CONTENT_POLICY = [
|
|
|
686
714
|
function packFileMime(filePath) {
|
|
687
715
|
return PACK_FILE_MIME_BY_EXTENSION[path.posix.extname(filePath).toLowerCase()] ?? "application/octet-stream";
|
|
688
716
|
}
|
|
717
|
+
function packFileHeaders(filePath) {
|
|
718
|
+
return {
|
|
719
|
+
"Content-Security-Policy": PACK_PANEL_CONTENT_POLICY,
|
|
720
|
+
"X-Content-Type-Options": "nosniff",
|
|
721
|
+
"Referrer-Policy": "no-referrer",
|
|
722
|
+
"Content-Type": packFileMime(filePath)
|
|
723
|
+
};
|
|
724
|
+
}
|
|
689
725
|
function uiSectionErrors(pack) {
|
|
690
726
|
return pack.ui && !pack.ui.ok ? pack.ui.errors : [];
|
|
691
727
|
}
|
|
@@ -738,6 +774,57 @@ function packRow(packDir, read, approvedFingerprints) {
|
|
|
738
774
|
function pendingPackNote(row) {
|
|
739
775
|
return `The pack '${row.name}' waits for your approval in Settings, Packs`;
|
|
740
776
|
}
|
|
777
|
+
var MAX_REFERENCE_LENGTH = 512;
|
|
778
|
+
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");
|
|
779
|
+
var CSS_REFERENCE_PATTERN = new RegExp(`url\\(\\s*["']?([^"')]{0,${MAX_REFERENCE_LENGTH}})["']?\\s*\\)|@import\\s+["']([^"']{1,${MAX_REFERENCE_LENGTH}})["']`, "gi");
|
|
780
|
+
var INERT_REFERENCE_PATTERN = /^(?:#|data:|blob:|javascript:|about:|mailto:)/i;
|
|
781
|
+
var REMOTE_REFERENCE_PATTERN = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
782
|
+
function withoutDelimited(text, opener, closer) {
|
|
783
|
+
const keptParts = [];
|
|
784
|
+
let cursor = 0;
|
|
785
|
+
while (cursor < text.length) {
|
|
786
|
+
const openAt = text.indexOf(opener, cursor);
|
|
787
|
+
if (openAt === -1) return [...keptParts, text.slice(cursor)].join("");
|
|
788
|
+
keptParts.push(text.slice(cursor, openAt));
|
|
789
|
+
const closeAt = text.indexOf(closer, openAt + opener.length);
|
|
790
|
+
if (closeAt === -1) return keptParts.join("");
|
|
791
|
+
cursor = closeAt + closer.length;
|
|
792
|
+
}
|
|
793
|
+
return keptParts.join("");
|
|
794
|
+
}
|
|
795
|
+
function attributeUrls(attributeName, value) {
|
|
796
|
+
if (!attributeName.toLowerCase().endsWith("srcset")) return [value];
|
|
797
|
+
return value.split(",").map((candidate) => candidate.trim().split(/\s+/)[0] ?? "");
|
|
798
|
+
}
|
|
799
|
+
function referencesIn(filePath, text) {
|
|
800
|
+
const withoutComments = withoutDelimited(withoutDelimited(text, "<!--", "-->"), "/*", "*/");
|
|
801
|
+
const cssReferences = [...withoutComments.matchAll(CSS_REFERENCE_PATTERN)].map((match) => match[1] ?? match[2] ?? "");
|
|
802
|
+
return [...filePath.endsWith(".html") ? [...withoutComments.matchAll(HTML_REFERENCE_PATTERN)].flatMap((match) => attributeUrls(match[1] ?? "", match[2] ?? match[3] ?? match[4] ?? "")) : [], ...cssReferences].map((reference) => reference.trim()).filter((reference) => reference !== "" && !INERT_REFERENCE_PATTERN.test(reference));
|
|
803
|
+
}
|
|
804
|
+
function decodedPath(reference) {
|
|
805
|
+
try {
|
|
806
|
+
return decodeURIComponent(reference);
|
|
807
|
+
} catch {
|
|
808
|
+
return reference;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function referenceError(filePath, reference, filesByPath) {
|
|
812
|
+
if (REMOTE_REFERENCE_PATTERN.test(reference)) return `${filePath} loads ${reference}, but a panel has no network; put that file in the pack`;
|
|
813
|
+
if (reference.startsWith("/")) return `${filePath} refers to ${reference}, an absolute path that leaves the pack; use a path relative to ${filePath}`;
|
|
814
|
+
const referencedPath = path.posix.normalize(path.posix.join(path.posix.dirname(filePath), decodedPath(reference.replace(/[?#].*$/, ""))));
|
|
815
|
+
if (referencedPath.startsWith("../")) return `${filePath} refers to ${reference}, which is outside the pack`;
|
|
816
|
+
return filesByPath.has(referencedPath) ? null : `${filePath} refers to ${reference}, which is not a file in the pack`;
|
|
817
|
+
}
|
|
818
|
+
function panelReferenceErrors(filesByPath) {
|
|
819
|
+
return [...filesByPath].filter(([filePath]) => filePath.endsWith(".html") || filePath.endsWith(".css")).flatMap(([filePath, bytes]) => referencesIn(filePath, bytes.toString("utf8")).map((reference) => referenceError(filePath, reference, filesByPath)).filter((error) => error !== null));
|
|
820
|
+
}
|
|
821
|
+
var SUBSCRIBED_TOPICS_PATTERN = /subscribe\(\s*\[([^\]]{0,500})\]|kind\s*:\s*['"]subscribe['"][^}]{0,500}?topics\s*:\s*\[([^\]]{0,500})\]/g;
|
|
822
|
+
function undeclaredSubscriptionErrors(filesByPath, declaredReads) {
|
|
823
|
+
return [...filesByPath].filter(([filePath]) => filePath.endsWith(".js") || filePath.endsWith(".html")).flatMap(([filePath, bytes]) => {
|
|
824
|
+
const subscribedTopics = [...bytes.toString("utf8").matchAll(SUBSCRIBED_TOPICS_PATTERN)].flatMap((match) => [...(match[1] ?? match[2] ?? "").matchAll(/['"]([^'"]+)['"]/g)].map((topic) => topic[1] ?? ""));
|
|
825
|
+
return [...new Set(subscribedTopics)].filter((topic) => !declaredReads.has(topic)).map((topic) => `${filePath} subscribes to '${topic}', which no panel lists under reads, so it never arrives; add it to reads or drop it`);
|
|
826
|
+
});
|
|
827
|
+
}
|
|
741
828
|
//#endregion
|
|
742
829
|
//#region shared/contracts/pack.ts
|
|
743
830
|
var PACK_SCHEMA_URL = "https://glimmervoid.dev/schema/pack.v1.json";
|
|
@@ -745,8 +832,8 @@ var PACK_FILE_NAME = "pack.json";
|
|
|
745
832
|
var PackName = 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" });
|
|
746
833
|
var PackHeader = z.strictObject({
|
|
747
834
|
$schema: z.string().optional(),
|
|
748
|
-
name: PackName,
|
|
749
|
-
version: z.number().int().positive(),
|
|
835
|
+
name: PackName.describe("Unique among installed packs; a second pack with the same name is refused. Theme and panel ids are scoped to it, so they never clash with another pack"),
|
|
836
|
+
version: z.number().int().positive().describe("Your release number, shown to the operator beside the pack; raise it with each change. Approval follows the files, not this number: any changed file asks again"),
|
|
750
837
|
description: z.string().max(500).optional(),
|
|
751
838
|
requires: PrFlowPackRequires.default({
|
|
752
839
|
env: [],
|
|
@@ -786,9 +873,9 @@ var PackFilePath = z.string().regex(/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[A-Za-z0-
|
|
|
786
873
|
var PackPanel = z.strictObject({
|
|
787
874
|
id: PackItemId,
|
|
788
875
|
label: z.string().trim().min(1).max(24),
|
|
789
|
-
entry: PackFilePath.refine((filePath) => filePath.endsWith(".html"), { error: "a panel entry is an .html file" }),
|
|
876
|
+
entry: PackFilePath.refine((filePath) => filePath.endsWith(".html"), { error: "a panel entry is an .html file" }).describe("The HTML page the panel opens, relative to the pack folder"),
|
|
790
877
|
icon: PackFilePath.refine((filePath) => filePath.endsWith(".svg"), { error: "a panel icon is an .svg file" }).optional(),
|
|
791
|
-
reads: z.array(PackBridgeTopic).default([])
|
|
878
|
+
reads: z.array(PackBridgeTopic).default([]).describe("The bridge topics this panel may receive; the operator sees them before approving, and a subscribe for any other topic is ignored")
|
|
792
879
|
});
|
|
793
880
|
var PackUi = z.strictObject({
|
|
794
881
|
themes: z.array(ThemePalette.extend({ id: PackItemId })).max(8).default([]),
|
|
@@ -830,29 +917,35 @@ var PACKS_STATE_FILE_NAME = "packs-state.json";
|
|
|
830
917
|
function packsStatePath(homeDir) {
|
|
831
918
|
return path.join(homeDir, PACKS_STATE_FILE_NAME);
|
|
832
919
|
}
|
|
920
|
+
function readApprovedPackFingerprints(homeDir) {
|
|
921
|
+
const statePath = packsStatePath(homeDir);
|
|
922
|
+
if (!fs.existsSync(statePath)) return /* @__PURE__ */ new Set();
|
|
923
|
+
return new Set(PacksState.safeParse(parseJsonOrNull(fs.readFileSync(statePath, "utf8"))).data?.approvedFingerprints ?? []);
|
|
924
|
+
}
|
|
833
925
|
function sha256(bytes) {
|
|
834
926
|
return crypto.createHash("sha256").update(bytes).digest("hex");
|
|
835
927
|
}
|
|
836
928
|
async function readPackFiles(packDir) {
|
|
837
929
|
const filesByPath = /* @__PURE__ */ new Map();
|
|
930
|
+
const errors = [];
|
|
838
931
|
const pendingDirs = [""];
|
|
839
932
|
let totalBytes = 0;
|
|
840
933
|
while (pendingDirs.length > 0) {
|
|
841
934
|
const relativeDir = pendingDirs.pop() ?? "";
|
|
842
935
|
for (const entry of await fs.promises.readdir(path.join(packDir, relativeDir), { withFileTypes: true })) {
|
|
843
936
|
const relativePath = path.posix.join(relativeDir, entry.name);
|
|
844
|
-
if (entry.isSymbolicLink())
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
}
|
|
937
|
+
if (entry.isSymbolicLink()) {
|
|
938
|
+
errors.push(`${relativePath} is a symlink, and a pack holds only its own files`);
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
848
941
|
if (entry.isDirectory()) {
|
|
849
942
|
pendingDirs.push(relativePath);
|
|
850
943
|
continue;
|
|
851
944
|
}
|
|
852
|
-
if (!entry.isFile())
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
945
|
+
if (!entry.isFile()) {
|
|
946
|
+
errors.push(`${relativePath} is not a regular file`);
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
856
949
|
totalBytes += (await fs.promises.lstat(path.join(packDir, relativePath))).size;
|
|
857
950
|
if (totalBytes > PACK_MAX_TOTAL_BYTES) return {
|
|
858
951
|
ok: false,
|
|
@@ -863,7 +956,8 @@ async function readPackFiles(packDir) {
|
|
|
863
956
|
}
|
|
864
957
|
return {
|
|
865
958
|
ok: true,
|
|
866
|
-
filesByPath
|
|
959
|
+
filesByPath,
|
|
960
|
+
errors
|
|
867
961
|
};
|
|
868
962
|
}
|
|
869
963
|
function packFingerprint(filesByPath) {
|
|
@@ -883,14 +977,54 @@ async function missingRequires(requires, env) {
|
|
|
883
977
|
for (const program of requires.programs) if (!await isProgramOnPath(program, env)) missingPrograms.push(`program ${program}`);
|
|
884
978
|
return [...requires.env.filter((name) => !commandEnv[name]).map((name) => `env ${name}`), ...missingPrograms];
|
|
885
979
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
888
|
-
|
|
980
|
+
function missingPanelFiles(panel, index, filesByPath) {
|
|
981
|
+
return [panel.entry, ...panel.icon ? [panel.icon] : []].filter((filePath) => !filesByPath.has(filePath)).map((filePath) => `${PACK_FILE_NAME} ui.panels.${index}: ${filePath} is not a file in the pack`);
|
|
982
|
+
}
|
|
983
|
+
function rawPanels(rawUi) {
|
|
984
|
+
if (rawUi === null || typeof rawUi !== "object" || !("panels" in rawUi) || !Array.isArray(rawUi.panels)) return [];
|
|
985
|
+
return rawUi.panels;
|
|
986
|
+
}
|
|
987
|
+
function declaredPanelReads(rawUi) {
|
|
988
|
+
const panels = validRawPanels(rawUi);
|
|
989
|
+
return panels.length === rawPanels(rawUi).length ? new Set(panels.flatMap(({ panel }) => panel.reads)) : null;
|
|
990
|
+
}
|
|
991
|
+
function validRawPanels(rawUi) {
|
|
992
|
+
return rawPanels(rawUi).flatMap((rawPanel, index) => {
|
|
993
|
+
const panel = PackPanel.safeParse(rawPanel);
|
|
994
|
+
return panel.success ? [{
|
|
995
|
+
index,
|
|
996
|
+
panel: panel.data
|
|
997
|
+
}] : [];
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
function withPanelFilesPresent(ui, rawUi, filesByPath) {
|
|
1001
|
+
if (ui === null) return null;
|
|
1002
|
+
const missing = validRawPanels(rawUi).flatMap(({ index, panel }) => missingPanelFiles(panel, index, filesByPath));
|
|
1003
|
+
if (!ui.ok) return {
|
|
1004
|
+
ok: false,
|
|
1005
|
+
errors: [...ui.errors, ...missing]
|
|
1006
|
+
};
|
|
889
1007
|
return missing.length === 0 ? ui : {
|
|
890
1008
|
ok: false,
|
|
891
1009
|
errors: missing
|
|
892
1010
|
};
|
|
893
1011
|
}
|
|
1012
|
+
function manifestJson(manifest) {
|
|
1013
|
+
try {
|
|
1014
|
+
return {
|
|
1015
|
+
ok: true,
|
|
1016
|
+
value: JSON.parse(manifest.toString("utf8"))
|
|
1017
|
+
};
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
return {
|
|
1020
|
+
ok: false,
|
|
1021
|
+
error: `${PACK_FILE_NAME} is not valid JSON: ${errorMessage(error)}`
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
function sectionErrors(section) {
|
|
1026
|
+
return section && !section.ok ? section.errors : [];
|
|
1027
|
+
}
|
|
894
1028
|
function issueLines(error, sectionLabel) {
|
|
895
1029
|
return error.issues.map((issue) => `${[sectionLabel, ...issue.path.map(String)].join(".")}: ${issue.message}`);
|
|
896
1030
|
}
|
|
@@ -922,14 +1056,35 @@ async function readPackDirUnguarded(packDir, env) {
|
|
|
922
1056
|
errors: [read.error]
|
|
923
1057
|
};
|
|
924
1058
|
const manifest = read.filesByPath.get(PACK_FILE_NAME);
|
|
1059
|
+
const { filesByPath } = read;
|
|
925
1060
|
if (!manifest) return {
|
|
926
1061
|
ok: false,
|
|
927
|
-
errors: [`there is no ${PACK_FILE_NAME}`]
|
|
1062
|
+
errors: [...read.errors, `there is no ${PACK_FILE_NAME}`],
|
|
1063
|
+
filesByPath
|
|
928
1064
|
};
|
|
929
|
-
const
|
|
1065
|
+
const manifestValue = manifestJson(manifest);
|
|
1066
|
+
if (!manifestValue.ok) return {
|
|
1067
|
+
ok: false,
|
|
1068
|
+
errors: [...read.errors, manifestValue.error],
|
|
1069
|
+
filesByPath
|
|
1070
|
+
};
|
|
1071
|
+
const header = PackHeader.safeParse(manifestValue.value);
|
|
930
1072
|
if (!header.success) return {
|
|
931
1073
|
ok: false,
|
|
932
|
-
errors: header.error.issues.map((issue) => `${PACK_FILE_NAME} ${issue.path.join(".") || "(root)"}: ${issue.message}`)
|
|
1074
|
+
errors: [...read.errors, ...header.error.issues.map((issue) => `${PACK_FILE_NAME} ${issue.path.join(".") || "(root)"}: ${issue.message}`)],
|
|
1075
|
+
filesByPath
|
|
1076
|
+
};
|
|
1077
|
+
const prFlows = parseSection(PackPrFlows, header.data.prFlows, "prFlows");
|
|
1078
|
+
const ui = withPanelFilesPresent(parseSection(PackUi, header.data.ui, "ui"), header.data.ui, read.filesByPath);
|
|
1079
|
+
if (read.errors.length > 0) return {
|
|
1080
|
+
ok: false,
|
|
1081
|
+
errors: [
|
|
1082
|
+
...read.errors,
|
|
1083
|
+
...sectionErrors(prFlows),
|
|
1084
|
+
...sectionErrors(ui)
|
|
1085
|
+
],
|
|
1086
|
+
filesByPath,
|
|
1087
|
+
header: header.data
|
|
933
1088
|
};
|
|
934
1089
|
return {
|
|
935
1090
|
ok: true,
|
|
@@ -938,8 +1093,8 @@ async function readPackDirUnguarded(packDir, env) {
|
|
|
938
1093
|
header: header.data,
|
|
939
1094
|
fingerprint: packFingerprint(read.filesByPath),
|
|
940
1095
|
filesByPath: read.filesByPath,
|
|
941
|
-
prFlows
|
|
942
|
-
ui
|
|
1096
|
+
prFlows,
|
|
1097
|
+
ui,
|
|
943
1098
|
missingRequires: await missingRequires(header.data.requires, env)
|
|
944
1099
|
}
|
|
945
1100
|
};
|
|
@@ -1003,19 +1158,26 @@ var PR_FLOW_PLACEHOLDERS_BY_KIND = {
|
|
|
1003
1158
|
"baseRef"
|
|
1004
1159
|
]
|
|
1005
1160
|
};
|
|
1161
|
+
function pageErrors(filesByPath, header) {
|
|
1162
|
+
const declaredReads = header ? declaredPanelReads(header.ui) : null;
|
|
1163
|
+
return [...panelReferenceErrors(filesByPath), ...declaredReads ? undeclaredSubscriptionErrors(filesByPath, declaredReads) : []];
|
|
1164
|
+
}
|
|
1006
1165
|
async function checkPack(packDir, env, isApprovedFingerprint) {
|
|
1007
1166
|
const read = await readPackDir(packDir, env);
|
|
1008
|
-
if (!read.ok)
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1167
|
+
if (!read.ok) {
|
|
1168
|
+
const name = read.header ? `${read.header.name} v${read.header.version}` : null;
|
|
1169
|
+
return {
|
|
1170
|
+
packDir: path.resolve(packDir),
|
|
1171
|
+
name,
|
|
1172
|
+
isApproved: false,
|
|
1173
|
+
errors: [...read.errors, ...pageErrors(read.filesByPath ?? /* @__PURE__ */ new Map(), read.header)],
|
|
1174
|
+
missingRequires: [],
|
|
1175
|
+
entries: [],
|
|
1176
|
+
rules: [],
|
|
1177
|
+
panels: [],
|
|
1178
|
+
themes: []
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1019
1181
|
const { pack } = read;
|
|
1020
1182
|
const { prFlowsPacks, warnings: prFlowsErrors } = prFlowsPacksOf([pack]);
|
|
1021
1183
|
const ui = pack.ui?.ok ? pack.ui.value : {
|
|
@@ -1026,7 +1188,11 @@ async function checkPack(packDir, env, isApprovedFingerprint) {
|
|
|
1026
1188
|
packDir: pack.dir,
|
|
1027
1189
|
name: `${pack.header.name} v${pack.header.version}`,
|
|
1028
1190
|
isApproved: isApprovedFingerprint(pack.fingerprint),
|
|
1029
|
-
errors: [
|
|
1191
|
+
errors: [
|
|
1192
|
+
...prFlowsErrors,
|
|
1193
|
+
...uiSectionErrors(pack),
|
|
1194
|
+
...pageErrors(pack.filesByPath, pack.header)
|
|
1195
|
+
],
|
|
1030
1196
|
missingRequires: pack.missingRequires,
|
|
1031
1197
|
entries: [],
|
|
1032
1198
|
rules: [],
|
|
@@ -1059,9 +1225,14 @@ async function checkPack(packDir, env, isApprovedFingerprint) {
|
|
|
1059
1225
|
function packCheckHasProblem(report) {
|
|
1060
1226
|
return report.errors.length > 0 || report.missingRequires.length > 0 || report.entries.some((entry) => entry.error !== null);
|
|
1061
1227
|
}
|
|
1228
|
+
function reportHeading(report) {
|
|
1229
|
+
const checked = report.name === null ? `Checked the pack at ${report.packDir}` : `Checked pack ${report.name} at ${report.packDir}`;
|
|
1230
|
+
if (packCheckHasProblem(report)) return `${checked}: fix the problems below, then check it again`;
|
|
1231
|
+
return `${checked}: no problems; ${report.isApproved ? "it is approved" : "once installed, it waits for the operator to approve it in Settings, Packs"}`;
|
|
1232
|
+
}
|
|
1062
1233
|
function packReportText(report) {
|
|
1063
1234
|
return [
|
|
1064
|
-
report
|
|
1235
|
+
reportHeading(report),
|
|
1065
1236
|
...report.panels.map((panel) => `panel ${panel}`),
|
|
1066
1237
|
...report.themes.map((theme) => `theme ${theme}`),
|
|
1067
1238
|
...report.entries.map((entry) => `${entry.kind} ${entry.id} (${entry.label}): ${entry.error === null ? `valid\n would run ${JSON.stringify(entry.argv)}` : `invalid, ${entry.error}`}`),
|
|
@@ -1071,145 +1242,71 @@ function packReportText(report) {
|
|
|
1071
1242
|
].join("\n");
|
|
1072
1243
|
}
|
|
1073
1244
|
//#endregion
|
|
1074
|
-
//#region server/
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
function firstCharacters(text) {
|
|
1084
|
-
return [...text.replace(CONTROL_CHARACTERS, " ").trim()].slice(0, ERROR_MAX_CHARACTERS).join("");
|
|
1085
|
-
}
|
|
1086
|
-
function reportedActionOutcome(stdout) {
|
|
1087
|
-
const lastLine = stdout.trim().split("\n").at(-1) ?? "";
|
|
1088
|
-
const reported = ReportedPrFlowActionOutcome.safeParse(parseJsonOrNull(stdout)).data ?? ReportedPrFlowActionOutcome.safeParse(parseJsonOrNull(lastLine)).data;
|
|
1089
|
-
if (!reported) return null;
|
|
1090
|
-
return {
|
|
1091
|
-
outcome: reported.outcome,
|
|
1092
|
-
message: firstCharacters(reported.message ?? "")
|
|
1093
|
-
};
|
|
1245
|
+
//#region server/packs/pack-agent.ts
|
|
1246
|
+
async function exampleLines(examplePacksDir) {
|
|
1247
|
+
const entries = await fs.promises.readdir(examplePacksDir, { withFileTypes: true }).catch(() => []);
|
|
1248
|
+
const lines = await Promise.all(entries.filter((entry) => entry.isDirectory()).map(async (entry) => {
|
|
1249
|
+
const manifestText = await fs.promises.readFile(path.join(examplePacksDir, entry.name, PACK_FILE_NAME), "utf8").catch(() => "");
|
|
1250
|
+
const header = PackHeader.safeParse(parseJsonOrNull(manifestText));
|
|
1251
|
+
return `- ${path.join(examplePacksDir, entry.name)}${header.success && header.data.description ? `: ${header.data.description}` : ""}`;
|
|
1252
|
+
}));
|
|
1253
|
+
return lines.length === 0 ? ["(this install ships no example packs)"] : lines.sort();
|
|
1094
1254
|
}
|
|
1095
|
-
function
|
|
1096
|
-
return
|
|
1255
|
+
async function packGuideText({ homeDir, examplePacksDir }, schemaLines) {
|
|
1256
|
+
return [
|
|
1257
|
+
"Glimmervoid packs",
|
|
1258
|
+
"",
|
|
1259
|
+
`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.`,
|
|
1260
|
+
"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.",
|
|
1261
|
+
"",
|
|
1262
|
+
"Sections of pack.json, each checked on its own:",
|
|
1263
|
+
"- prFlows: commands My PRs runs on pull requests (prActions, sources, actions, rules).",
|
|
1264
|
+
"- ui.themes: color themes for the Theme picker; every chrome and state color is a #rrggbb hex.",
|
|
1265
|
+
"- 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; inline <script> and <style> work too. Every panel file is served with this Content-Security-Policy:",
|
|
1266
|
+
` ${PACK_PANEL_CONTENT_POLICY}`,
|
|
1267
|
+
"",
|
|
1268
|
+
"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.",
|
|
1269
|
+
"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).",
|
|
1270
|
+
"",
|
|
1271
|
+
"Examples to copy and adapt:",
|
|
1272
|
+
...await exampleLines(examplePacksDir),
|
|
1273
|
+
"",
|
|
1274
|
+
"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.",
|
|
1275
|
+
"",
|
|
1276
|
+
...schemaLines
|
|
1277
|
+
].join("\n");
|
|
1097
1278
|
}
|
|
1098
|
-
function
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
ok: false,
|
|
1120
|
-
error: unknownPlaceholderError(expanded.unknown, "{prUrl}, {repo}, {number} or {head}")
|
|
1121
|
-
};
|
|
1122
|
-
const [program, ...args] = expanded.argv;
|
|
1123
|
-
if (program === void 0) return {
|
|
1124
|
-
ok: false,
|
|
1125
|
-
error: "The command is empty."
|
|
1126
|
-
};
|
|
1127
|
-
const run = await runCommand(program, args, {
|
|
1128
|
-
cwd: homeDir,
|
|
1129
|
-
env: commandEnv(pr),
|
|
1130
|
-
timeoutMs: source.timeoutSeconds * 1e3,
|
|
1131
|
-
maxBufferBytes: OUTPUT_MAX_BYTES
|
|
1132
|
-
});
|
|
1133
|
-
if (!run.ok) return {
|
|
1134
|
-
ok: false,
|
|
1135
|
-
error: `The command failed: ${firstCharacters(run.stderr) || "no error output"}`
|
|
1136
|
-
};
|
|
1137
|
-
const output = PrFlowSourceOutput.safeParse(parseJsonOrNull(run.stdout));
|
|
1138
|
-
if (!output.success) return {
|
|
1139
|
-
ok: false,
|
|
1140
|
-
error: `The command printed no valid findings JSON: ${output.error.issues[0]?.message ?? "unreadable output"}`
|
|
1141
|
-
};
|
|
1142
|
-
return {
|
|
1143
|
-
ok: true,
|
|
1144
|
-
output: output.data
|
|
1145
|
-
};
|
|
1146
|
-
}
|
|
1147
|
-
function itemInvocation(pr, item) {
|
|
1148
|
-
return {
|
|
1149
|
-
values: {
|
|
1150
|
-
...placeholderValues(pr),
|
|
1151
|
-
itemPath: item.path,
|
|
1152
|
-
itemLine: item.lineStart === null ? "" : String(item.lineStart)
|
|
1153
|
-
},
|
|
1154
|
-
knownNames: "{prUrl}, {repo}, {number}, {head}, {itemPath} or {itemLine}",
|
|
1155
|
-
env: {
|
|
1156
|
-
...commandEnv(pr),
|
|
1157
|
-
GLIMMERVOID_ITEM_JSON: JSON.stringify(item)
|
|
1158
|
-
}
|
|
1159
|
-
};
|
|
1160
|
-
}
|
|
1161
|
-
function prInvocation(pr, extraEnv) {
|
|
1162
|
-
return {
|
|
1163
|
-
values: prActionPlaceholderValues(pr),
|
|
1164
|
-
knownNames: "{prUrl}, {repo}, {number}, {head}, {headRef} or {baseRef}",
|
|
1165
|
-
env: {
|
|
1166
|
-
...commandEnv(pr),
|
|
1167
|
-
GLIMMERVOID_PR_HEAD_REF: pr.headRefName,
|
|
1168
|
-
GLIMMERVOID_PR_BASE_REF: pr.baseRefName,
|
|
1169
|
-
GLIMMERVOID_PR_JSON: boundedPrJson(pr),
|
|
1170
|
-
...extraEnv
|
|
1171
|
-
}
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
async function runAction(action, pr, item, extraEnv = {}) {
|
|
1175
|
-
const { values, knownNames, env } = item === void 0 ? prInvocation(pr, extraEnv) : itemInvocation(pr, item);
|
|
1176
|
-
const expanded = expandPlaceholders(action.command, values);
|
|
1177
|
-
if (!expanded.ok) return {
|
|
1178
|
-
outcome: "failed",
|
|
1179
|
-
message: unknownPlaceholderError(expanded.unknown, knownNames)
|
|
1180
|
-
};
|
|
1181
|
-
const [program, ...args] = expanded.argv;
|
|
1182
|
-
if (program === void 0) return {
|
|
1183
|
-
outcome: "failed",
|
|
1184
|
-
message: "The command is empty."
|
|
1185
|
-
};
|
|
1186
|
-
const timeoutMs = action.timeoutSeconds * 1e3;
|
|
1187
|
-
const startedAtMs = performance.now();
|
|
1188
|
-
const run = await runCommand(program, args, {
|
|
1189
|
-
cwd: homeDir,
|
|
1190
|
-
env,
|
|
1191
|
-
timeoutMs,
|
|
1192
|
-
maxBufferBytes: ACTION_OUTPUT_MAX_BYTES
|
|
1193
|
-
});
|
|
1194
|
-
const reported = reportedActionOutcome(run.stdout);
|
|
1195
|
-
if (reported) return reported;
|
|
1196
|
-
if (run.ok) return {
|
|
1197
|
-
outcome: "done",
|
|
1198
|
-
message: ""
|
|
1199
|
-
};
|
|
1200
|
-
if (performance.now() - startedAtMs >= timeoutMs) return {
|
|
1201
|
-
outcome: "failed",
|
|
1202
|
-
message: `timed out after ${action.timeoutSeconds}s`
|
|
1203
|
-
};
|
|
1279
|
+
function rowLines(row) {
|
|
1280
|
+
return [
|
|
1281
|
+
`${row.name}${row.version === null ? "" : ` v${row.version}`}: ${row.state} at ${row.dir}`,
|
|
1282
|
+
...row.panels.map((panel) => ` panel ${panel.id} (${panel.label})${panel.reads.length === 0 ? "" : `, reads ${panel.reads.join(", ")}`}`),
|
|
1283
|
+
...row.themes.map((theme) => ` theme ${theme.id} (${theme.label}, ${theme.mode})`),
|
|
1284
|
+
...row.missingRequires.map((missing) => ` missing on this machine: ${missing}`),
|
|
1285
|
+
...row.errors.map((error) => ` error: ${error}`)
|
|
1286
|
+
];
|
|
1287
|
+
}
|
|
1288
|
+
async function readPacksForAgent(request, deps) {
|
|
1289
|
+
if (request.command === "guide") return {
|
|
1290
|
+
text: await packGuideText(deps, [
|
|
1291
|
+
`${PACK_FILE_NAME} JSON Schema:`,
|
|
1292
|
+
packJsonSchemaText(),
|
|
1293
|
+
"Panel bridge messages JSON Schema:",
|
|
1294
|
+
packBridgeJsonSchemaText()
|
|
1295
|
+
]),
|
|
1296
|
+
hasProblem: false
|
|
1297
|
+
};
|
|
1298
|
+
if (request.command === "list") {
|
|
1299
|
+
const rows = deps.packRows();
|
|
1204
1300
|
return {
|
|
1205
|
-
|
|
1206
|
-
|
|
1301
|
+
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"),
|
|
1302
|
+
hasProblem: rows.some((row) => row.errors.length > 0)
|
|
1207
1303
|
};
|
|
1208
1304
|
}
|
|
1305
|
+
const report = await checkPack(request.path ?? "", deps.env, deps.isApproved);
|
|
1209
1306
|
return {
|
|
1210
|
-
|
|
1211
|
-
|
|
1307
|
+
text: packReportText(report),
|
|
1308
|
+
hasProblem: packCheckHasProblem(report)
|
|
1212
1309
|
};
|
|
1213
1310
|
}
|
|
1214
1311
|
//#endregion
|
|
1215
|
-
export {
|
|
1312
|
+
export { prActionPlaceholderValues as A, threadCandidates as B, expandPlaceholders as C, mergeItems as D, itemLocation as E, prFlowSetup as F, withOnlyOpenPrs as G, visibleRun as H, savedRuleFor as I, withRuleRun as J, withPrActionRun as K, shouldTellBranchMoved as L, prActionsForRepo as M, prFlowCommands as N, packPathsOf as O, prFlowRules as P, sourceCandidates as R, commandFingerprint as S, flaggingReviewers as T, withHandled as U, unknownActionWarnings as V, withInterruptedRuns as W, decideHostAllowed as Y, packFileHeaders as _, packCheckHasProblem as a, acceptReport as b, packDirsUnder as c, readPackDir as d, PACK_FILE_NAME as f, approvedPackThemes as g, approvedPackPanels as h, checkPack as i, prActionRunAfterExit as j, plannedActions as k, packsStatePath as l, packJsonSchemaText as m, readPacksForAgent as n, packReportText as o, PacksState as p, withReopened as q, PR_FLOW_PLACEHOLDERS_BY_KIND as r, PACKS_DIR_NAME as s, packGuideText as t, readApprovedPackFingerprints as u, packRow as v, fixLocallyPrompt as w, branchMovedNote as x, pendingPackNote as y, teammateThreadItems as z };
|