@hansenexus/hud 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -14
- package/dist/{access-Bc709qpl.d.ts → access-CwPCPsv0.d.ts} +1 -1
- package/dist/auto/runtime.d.ts +9 -9
- package/dist/auto.d.ts +2 -2
- package/dist/auto.js +1 -1
- package/dist/cli.js +34 -1
- package/dist/{define-hud-DTv3njuU.d.ts → define-hud-B0aFXrcK.d.ts} +1 -1
- package/dist/{design-BXG1a4we.js → design-BIXY1-Ex.js} +26 -8
- package/dist/{force-state-panel-mu-txJnA.js → force-state-panel-D5oDydLs.js} +1 -1
- package/dist/{handler-DMzSTqyG.d.ts → handler-BmFhaA2D.d.ts} +1 -1
- package/dist/{index-C3wzZS3o.d.ts → index-5B7foZut.d.ts} +2 -2
- package/dist/{index-D-hI-DRJ.d.ts → index-B2KCKkN0.d.ts} +1 -1
- package/dist/index-B7qaEUgh.d.ts +44 -0
- package/dist/{index-CQXiuMZQ.d.ts → index-BGFyuJyN.d.ts} +1 -1
- package/dist/{index-Caohnz3B.d.ts → index-BeqWehuh.d.ts} +38 -10
- package/dist/{index-BJJoAXJ2.d.ts → index-BqKysxTq.d.ts} +1 -1
- package/dist/{index-DLCSLWW4.d.ts → index-D97Fnoie.d.ts} +2 -2
- package/dist/{index-BR5OB7DO.d.ts → index-DS0yT0c-.d.ts} +1 -1
- package/dist/{index-BNoPbSYD.d.ts → index-DvlCkGB1.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +45 -196
- package/dist/navigation-CX6AXm7H.js +176 -0
- package/dist/next.d.ts +4 -1
- package/dist/next.js +12 -1
- package/dist/obstacles-CCmRFTcZ.js +176 -0
- package/dist/plugins/a11y.d.ts +1 -1
- package/dist/plugins/access/server.d.ts +3 -3
- package/dist/plugins/access.d.ts +2 -2
- package/dist/plugins/agent/server.js +1 -1
- package/dist/plugins/agent.d.ts +2 -2
- package/dist/plugins/capture.d.ts +2 -2
- package/dist/plugins/data/server.d.ts +1 -1
- package/dist/plugins/data/server.js +1 -1
- package/dist/plugins/data.d.ts +1 -1
- package/dist/plugins/design/server.d.ts +55 -15
- package/dist/plugins/design/server.js +187 -122
- package/dist/plugins/design.d.ts +3 -3
- package/dist/plugins/design.js +1 -1
- package/dist/plugins/inspect.d.ts +1 -1
- package/dist/plugins/observe.d.ts +1 -1
- package/dist/plugins/ops/server.d.ts +1 -1
- package/dist/plugins/ops.d.ts +1 -1
- package/dist/plugins/routes/server.d.ts +1 -1
- package/dist/plugins/routes.d.ts +3 -3
- package/dist/plugins/routes.js +381 -52
- package/dist/plugins/seo.d.ts +1 -1
- package/dist/plugins/vitals.d.ts +1 -1
- package/dist/{plugins-BZT-1LBe.d.ts → plugins-pL2CoWzI.d.ts} +7 -0
- package/dist/same-origin-BHuZO1_H.js +36 -0
- package/dist/server.d.ts +2 -2
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/dist/{meta-C_G7MB5w.d.ts → types-Dc6JWZR7.d.ts} +6 -6
- package/dist/variant-bar-BzZ0ln-C.js +768 -0
- package/dist/variant-picks-Byc0hC8a.js +144 -0
- package/dist/variants-export-vEtZ-OGC.js +75 -0
- package/dist/{variants-panel-B6zWcknV.js → variants-panel-D23v5KIp.js} +71 -54
- package/dist/variants-types-BOsZ5fDz.js +65 -0
- package/dist/variants-types-VkW7vFZF.d.ts +139 -0
- package/dist/variants.d.ts +1 -1
- package/dist/variants.js +1 -1
- package/dist/vite.d.ts +2 -2
- package/package.json +1 -1
- package/dist/index-B1vHAY9p.d.ts +0 -20
- package/dist/same-origin-BGet22CC.js +0 -21
- package/dist/variants-types-CcRf119M.d.ts +0 -63
package/dist/plugins/a11y.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as A11yFinding, c as AxeImpact, i as A11yStatus, n as a11y, o as AXE_URL, r as A11ySnapshot, s as AXE_VERSION, t as A11yOptions } from "../index-
|
|
1
|
+
import { a as A11yFinding, c as AxeImpact, i as A11yStatus, n as a11y, o as AXE_URL, r as A11ySnapshot, s as AXE_VERSION, t as A11yOptions } from "../index-D97Fnoie.js";
|
|
2
2
|
export { type A11yFinding, A11yOptions, type A11ySnapshot, type A11yStatus, AXE_URL, AXE_VERSION, type AxeImpact, a11y };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as HudCapability } from "../../plugins-
|
|
1
|
+
import { a as HudCapability } from "../../plugins-pL2CoWzI.js";
|
|
2
2
|
import { t as HudEnv } from "../../env-CApnbI0r.js";
|
|
3
|
-
import { a as signHudUnlockToken, c as CAPABILITY_MATRIX, d as hasCapability, f as isHudVisible, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, o as verifyHudUnlockToken, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, t as HUD_UNLOCK_COOKIE, u as HUD_CAPABILITIES } from "../../access-
|
|
4
|
-
import { t as HudGuard } from "../../handler-
|
|
3
|
+
import { a as signHudUnlockToken, c as CAPABILITY_MATRIX, d as hasCapability, f as isHudVisible, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, o as verifyHudUnlockToken, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, t as HUD_UNLOCK_COOKIE, u as HUD_CAPABILITIES } from "../../access-CwPCPsv0.js";
|
|
4
|
+
import { t as HudGuard } from "../../handler-BmFhaA2D.js";
|
|
5
5
|
//#region src/plugins/access/server/settings.d.ts
|
|
6
6
|
/** What the server half reads from its environment, per request. */
|
|
7
7
|
interface AccessSettings {
|
package/dist/plugins/access.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as HudCapability, r as HudBadge, u as HudPluginProps } from "../plugins-
|
|
2
|
-
import { c as CAPABILITY_MATRIX, d as hasCapability, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, u as HUD_CAPABILITIES } from "../access-
|
|
1
|
+
import { a as HudCapability, r as HudBadge, u as HudPluginProps } from "../plugins-pL2CoWzI.js";
|
|
2
|
+
import { c as CAPABILITY_MATRIX, d as hasCapability, i as resolveHudAccess, l as CapabilityMatrixOverride, n as HudAccess, p as isProductionDenied, r as hudRequiresUnlock, s as ACCESS_UNLOCK_CAPABILITY, u as HUD_CAPABILITIES } from "../access-CwPCPsv0.js";
|
|
3
3
|
//#region src/plugins/access/access-pill.d.ts
|
|
4
4
|
declare function AccessPill(): import("react").JSX.Element;
|
|
5
5
|
declare function useAccessBadge(): HudBadge;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
|
|
2
|
-
import { t as refuseCrossSite } from "../../same-origin-
|
|
2
|
+
import { t as refuseCrossSite } from "../../same-origin-BHuZO1_H.js";
|
|
3
3
|
//#region src/plugins/agent/prompt.ts
|
|
4
4
|
/** The task text every provider receives: grab context first, then the instruction. */
|
|
5
5
|
function dispatchPrompt({ note, payload, hints = [] }) {
|
package/dist/plugins/agent.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as GrabPayload, t as ComponentHint } from "../payload-MUQ9ciER.js";
|
|
2
|
-
import { l as HudPluginContext, u as HudPluginProps } from "../plugins-
|
|
3
|
-
import "../index-
|
|
2
|
+
import { l as HudPluginContext, u as HudPluginProps } from "../plugins-pL2CoWzI.js";
|
|
3
|
+
import "../index-5B7foZut.js";
|
|
4
4
|
import { a as DispatchTargetInfo, i as DispatchReceipt, n as AgentSessionStatus, o as SessionsResponse, r as DispatchBody, t as AgentSession } from "../types-Cxh4twqc.js";
|
|
5
5
|
//#region src/plugins/agent/index.d.ts
|
|
6
6
|
export interface AgentDispatchOptions {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as GrabPayload } from "../payload-MUQ9ciER.js";
|
|
2
|
-
import { l as HudPluginContext } from "../plugins-
|
|
3
|
-
import "../index-
|
|
2
|
+
import { l as HudPluginContext } from "../plugins-pL2CoWzI.js";
|
|
3
|
+
import "../index-5B7foZut.js";
|
|
4
4
|
import { n as ScreenshotRequest, r as ScreenshotResponse, t as CAPTURE_CAPABILITY } from "../types-BIgGf-0C.js";
|
|
5
5
|
//#region src/plugins/capture/index.d.ts
|
|
6
6
|
export interface ScreenshotOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as HudRouteContext } from "../../plugins-
|
|
1
|
+
import { d as HudRouteContext } from "../../plugins-pL2CoWzI.js";
|
|
2
2
|
import { _ as validateScenarios, a as HudMockRegistry, c as HudMockScenarioInfo, d as MOCK_SCENARIO_ID, f as createMockResolver, g as toMockActive, h as readMockRegistry, i as HudMockNodeStatus, l as MOCKS_COLLECTION, m as parseEndpoint, n as HudMockContext, o as HudMockResolve, p as matchEndpoint, r as HudMockMethod, s as HudMockScenario, t as HudMockActive, u as MOCKS_DOCUMENT } from "../../mocks-CA-wM2SB.js";
|
|
3
3
|
import { c as HudFlagValue, g as serializeFlagOverrides, h as readFlagOverrides, l as flagCookieString, n as FLAGS_STORAGE_KEY, o as HudFlagOverride, r as FLAG_KEY, s as HudFlagScope, t as FLAGS_COOKIE } from "../../flags-DVtaJ8pQ.js";
|
|
4
4
|
import { a as FlagsResponse, c as HudFlagDefinition, d as HudSeedInfo, f as MocksResponse, h as SeedRunResponse, i as FlagOverrideBody, l as HudFlagType, m as RoleSwitchResponse, n as FLAGS_COLLECTION, o as HudAuthUser, p as RoleSwitchBody, r as FLAGS_DOCUMENT, s as HudAuthUserInfo, t as DataStateResponse, u as HudSeed } from "../../types-Dn68psVz.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
|
|
2
2
|
import { FLAGS_COOKIE, FLAGS_STORAGE_KEY, FLAG_KEY, flagCookieString, isFlagScope, isFlagValue, readFlagOverrides, serializeFlagOverrides } from "../../flags.js";
|
|
3
3
|
import { a as matchEndpoint, c as readMockRegistry, d as validateScenarios, i as createMockResolver, l as scenarioInfo, n as MOCKS_DOCUMENT, o as nodeMockStatus, r as MOCK_SCENARIO_ID, s as parseEndpoint, t as MOCKS_COLLECTION, u as toMockActive } from "../../mocks-ESiRqk9o.js";
|
|
4
|
-
import { t as refuseCrossSite } from "../../same-origin-
|
|
4
|
+
import { t as refuseCrossSite } from "../../same-origin-BHuZO1_H.js";
|
|
5
5
|
import { t as HudStoreError } from "../../types-BIkI-qN8.js";
|
|
6
6
|
import { t as file } from "../../file-xdSaQ2uR.js";
|
|
7
7
|
import { a as readCookie, c as timingSafeEqual } from "../../access-C7zlaqj6.js";
|
package/dist/plugins/data.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as HudMockClientStatus, n as data, r as HudMockClientOptions, t as DataOptions } from "../index-
|
|
1
|
+
import { i as HudMockClientStatus, n as data, r as HudMockClientOptions, t as DataOptions } from "../index-BqKysxTq.js";
|
|
2
2
|
import { c as HudMockScenarioInfo, i as HudMockNodeStatus, n as HudMockContext, o as HudMockResolve, r as HudMockMethod, s as HudMockScenario, t as HudMockActive } from "../mocks-CA-wM2SB.js";
|
|
3
3
|
import { n as HudMockWorkerModule, r as MockWorkerOptions, t as HudMockWorkerHandle } from "../msw-browser-wjaYgkB7.js";
|
|
4
4
|
import { c as HudFlagValue, h as readFlagOverrides, n as FLAGS_STORAGE_KEY, o as HudFlagOverride, r as FLAG_KEY, s as HudFlagScope, t as FLAGS_COOKIE, u as flagOverride } from "../flags-DVtaJ8pQ.js";
|
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
import { d as HudRouteContext } from "../../plugins-
|
|
2
|
-
import { a as
|
|
1
|
+
import { d as HudRouteContext } from "../../plugins-pL2CoWzI.js";
|
|
2
|
+
import { a as VariantGroupRecord, c as VariantStatus, d as toGroupRecord, f as toVariantRecord, i as VARIANTS_COLLECTION, l as VariantsListResponse, n as PickBody, o as VariantLogEntry, r as PickResponse, s as VariantRecord, t as CleanupResponse, u as recordKey } from "../../variants-types-VkW7vFZF.js";
|
|
3
3
|
import { n as DispatchProvider } from "../../types-szkr2QOF.js";
|
|
4
4
|
import { t as HudStore } from "../../types-DaJcsEjO.js";
|
|
5
5
|
import "../../server.js";
|
|
6
|
+
//#region src/plugins/design/variants-export.d.ts
|
|
7
|
+
/** One group's decision, as `hud variants` prints it. */
|
|
8
|
+
interface VariantGroupExport {
|
|
9
|
+
group: string;
|
|
10
|
+
label: string;
|
|
11
|
+
/** The picked variant, or null while the group is open. */
|
|
12
|
+
pick: {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
decidedAt?: string;
|
|
16
|
+
} | null;
|
|
17
|
+
note: string;
|
|
18
|
+
variants: {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
status: string;
|
|
22
|
+
score?: number;
|
|
23
|
+
rationale?: string;
|
|
24
|
+
}[];
|
|
25
|
+
log: VariantLogEntry[];
|
|
26
|
+
}
|
|
27
|
+
interface VariantsExport {
|
|
28
|
+
groups: VariantGroupExport[];
|
|
29
|
+
}
|
|
30
|
+
/** Every group of the store's `variants` collection with its pick, note and log, by group id. */
|
|
31
|
+
export declare function readVariants(store: HudStore): Promise<VariantsExport>;
|
|
32
|
+
/** The decisions as Markdown, for an issue comment or an agent's context. */
|
|
33
|
+
export declare function formatVariantsMarkdown({ groups }: VariantsExport): string;
|
|
34
|
+
//#endregion
|
|
6
35
|
//#region src/plugins/design/server.d.ts
|
|
7
36
|
export interface VariantDecision {
|
|
8
37
|
group: string;
|
|
@@ -16,27 +45,35 @@ export interface VariantDecision {
|
|
|
16
45
|
label: string;
|
|
17
46
|
}[];
|
|
18
47
|
decidedAt: string;
|
|
48
|
+
/** The owner's note on the pick; empty when there is none. */
|
|
49
|
+
note?: string;
|
|
19
50
|
}
|
|
20
51
|
export interface VariantsServerOptions {
|
|
21
|
-
/** Where scores and
|
|
52
|
+
/** Where scores, picks and notes live. `file()` keeps them in `.hud/variants.json`. */
|
|
22
53
|
store: HudStore;
|
|
23
54
|
/**
|
|
24
|
-
* The dispatch seam:
|
|
25
|
-
* `hermes()` from `@hansenexus/hud/plugins/agent/server`,
|
|
26
|
-
* the same shape).
|
|
55
|
+
* The dispatch seam: "Queue cleanup" hands the brief for a picked group to
|
|
56
|
+
* it (`claudeCode()`, `hermes()` from `@hansenexus/hud/plugins/agent/server`,
|
|
57
|
+
* or anything with the same shape). A pick never reaches it.
|
|
27
58
|
*/
|
|
28
59
|
dispatch?: DispatchProvider;
|
|
29
60
|
/** The brief's text. Default: `cleanupBrief`. */
|
|
30
61
|
brief?: (decision: VariantDecision) => string;
|
|
31
62
|
}
|
|
32
|
-
/** The cleanup brief
|
|
33
|
-
export declare function cleanupBrief({ group, label, winner, losers, decidedAt }: VariantDecision): string;
|
|
63
|
+
/** The cleanup brief "Queue cleanup" hands the dispatch seam. */
|
|
64
|
+
export declare function cleanupBrief({ group, label, winner, losers, decidedAt, note }: VariantDecision): string;
|
|
34
65
|
/**
|
|
35
|
-
* Server half of `variants()
|
|
36
|
-
*
|
|
37
|
-
* `
|
|
38
|
-
*
|
|
39
|
-
*
|
|
66
|
+
* Server half of `variants()`.
|
|
67
|
+
*
|
|
68
|
+
* - `GET /` lists every record of the store's `variants` collection, with the
|
|
69
|
+
* groups' notes and logs.
|
|
70
|
+
* - `POST /:group/pick` records a pick and a note through the storage seam
|
|
71
|
+
* (`status` and `decidedAt` on the variants, note and log on the group).
|
|
72
|
+
* It never touches the dispatch seam.
|
|
73
|
+
* - `POST /:group/cleanup` queues the cleanup brief of a picked group through
|
|
74
|
+
* the dispatch seam; the panel's "Queue cleanup" button is the only caller.
|
|
75
|
+
*
|
|
76
|
+
* Carries `variants.decide`, which only development grants by default.
|
|
40
77
|
*/
|
|
41
78
|
export declare function variantsServer({ store, dispatch, brief }: VariantsServerOptions): {
|
|
42
79
|
readonly id: "variants";
|
|
@@ -45,10 +82,13 @@ export declare function variantsServer({ store, dispatch, brief }: VariantsServe
|
|
|
45
82
|
readonly "/": {
|
|
46
83
|
GET: () => Promise<Response>;
|
|
47
84
|
};
|
|
48
|
-
readonly "/:group/
|
|
85
|
+
readonly "/:group/pick": {
|
|
86
|
+
readonly POST: (request: Request, { params }: HudRouteContext) => Promise<Response>;
|
|
87
|
+
};
|
|
88
|
+
readonly "/:group/cleanup": {
|
|
49
89
|
readonly POST: (request: Request, { params }: HudRouteContext) => Promise<Response>;
|
|
50
90
|
};
|
|
51
91
|
};
|
|
52
92
|
};
|
|
53
93
|
//#endregion
|
|
54
|
-
export { type
|
|
94
|
+
export { type CleanupResponse, type PickBody, type PickResponse, VARIANTS_COLLECTION, type VariantGroupExport, type VariantGroupRecord, type VariantLogEntry, type VariantRecord, type VariantStatus, type VariantsExport, type VariantsListResponse, recordKey, toGroupRecord, toVariantRecord };
|
|
@@ -1,45 +1,8 @@
|
|
|
1
1
|
import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
|
|
2
|
-
import { t as refuseCrossSite } from "../../same-origin-
|
|
2
|
+
import { t as refuseCrossSite } from "../../same-origin-BHuZO1_H.js";
|
|
3
3
|
import { t as HudStoreError } from "../../types-BIkI-qN8.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** The store collection scores and decisions live in: `.hud/variants.json` with `file()`. */
|
|
7
|
-
const VARIANTS_COLLECTION = "variants";
|
|
8
|
-
function recordKey(group, id) {
|
|
9
|
-
return `${group}:${id}`;
|
|
10
|
-
}
|
|
11
|
-
function isRecord$1(value) {
|
|
12
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
-
}
|
|
14
|
-
const STATUSES = [
|
|
15
|
-
"open",
|
|
16
|
-
"decided",
|
|
17
|
-
"rejected"
|
|
18
|
-
];
|
|
19
|
-
/**
|
|
20
|
-
* A store entry as a `VariantRecord`: group and id come from the fields, or
|
|
21
|
-
* from a `<group>:<id>` key when the file omits them. Unknown fields are
|
|
22
|
-
* dropped, wrong types ignored; null when neither names the variant.
|
|
23
|
-
*/
|
|
24
|
-
function toVariantRecord(id, value) {
|
|
25
|
-
if (!isRecord$1(value)) return null;
|
|
26
|
-
const separator = id.indexOf(":");
|
|
27
|
-
const group = typeof value.group === "string" ? value.group : separator > 0 ? id.slice(0, separator) : "";
|
|
28
|
-
const variant = typeof value.id === "string" ? value.id : separator > 0 ? id.slice(separator + 1) : "";
|
|
29
|
-
if (!group || !variant) return null;
|
|
30
|
-
const record = {
|
|
31
|
-
group,
|
|
32
|
-
id: variant
|
|
33
|
-
};
|
|
34
|
-
if (typeof value.label === "string") record.label = value.label;
|
|
35
|
-
if (typeof value.status === "string" && STATUSES.includes(value.status)) record.status = value.status;
|
|
36
|
-
if (typeof value.score === "number" && Number.isFinite(value.score)) record.score = value.score;
|
|
37
|
-
if (typeof value.rationale === "string") record.rationale = value.rationale;
|
|
38
|
-
if (typeof value.scoredBy === "string") record.scoredBy = value.scoredBy;
|
|
39
|
-
if (typeof value.decidedAt === "string") record.decidedAt = value.decidedAt;
|
|
40
|
-
return record;
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
4
|
+
import { a as toGroupRecord, i as recordKey, n as VARIANTS_COLLECTION, o as toVariantRecord, r as pickedRecord } from "../../variants-types-BOsZ5fDz.js";
|
|
5
|
+
import { n as readVariants, t as formatVariantsMarkdown } from "../../variants-export-vEtZ-OGC.js";
|
|
43
6
|
//#region src/plugins/design/server.ts
|
|
44
7
|
const NO_STORE = { "cache-control": "no-store" };
|
|
45
8
|
function isRecord(value) {
|
|
@@ -59,41 +22,162 @@ function failed(error, what) {
|
|
|
59
22
|
error: `${what} failed`
|
|
60
23
|
}, { status: 500 });
|
|
61
24
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
25
|
+
const ID_MAX = 100;
|
|
26
|
+
const BODY_MAX = 65536;
|
|
27
|
+
const isId = (value) => typeof value === "string" && value.length > 0 && value.length <= ID_MAX;
|
|
28
|
+
function parsePick(value) {
|
|
29
|
+
if (!isRecord(value)) return null;
|
|
30
|
+
const body = {};
|
|
31
|
+
if (value.id === null || isId(value.id)) body.id = value.id;
|
|
32
|
+
else if (value.id !== void 0) return null;
|
|
33
|
+
if (typeof value.note === "string") body.note = value.note.trim();
|
|
34
|
+
else if (value.note !== void 0) return null;
|
|
35
|
+
if (body.note !== void 0 && body.note.length > 4e3) return null;
|
|
36
|
+
if (body.id === void 0 && body.note === void 0) return null;
|
|
65
37
|
if (typeof value.label === "string") body.label = value.label;
|
|
66
|
-
if (Array.isArray(value.variants)) body.variants = value.variants.flatMap((v) => isRecord(v) &&
|
|
38
|
+
if (Array.isArray(value.variants)) body.variants = value.variants.flatMap((v) => isRecord(v) && isId(v.id) ? [{
|
|
67
39
|
id: v.id,
|
|
68
40
|
label: typeof v.label === "string" ? v.label : v.id
|
|
69
41
|
}] : []);
|
|
70
42
|
return body;
|
|
71
43
|
}
|
|
44
|
+
async function readJson(request) {
|
|
45
|
+
const text = await request.text().catch(() => "");
|
|
46
|
+
if (text.length > BODY_MAX) return null;
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(text);
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** A group id the store can key and a `<group>:<id>` record cannot collide with. */
|
|
54
|
+
const isGroup = (group) => isId(group) && !group.includes(":");
|
|
55
|
+
const invalid = (error, status = 400) => Response.json({
|
|
56
|
+
ok: false,
|
|
57
|
+
error
|
|
58
|
+
}, { status });
|
|
72
59
|
const quote = (v) => v.label === v.id ? `"${v.id}"` : `"${v.id}" (${v.label})`;
|
|
73
|
-
/** The cleanup brief
|
|
74
|
-
function cleanupBrief({ group, label, winner, losers, decidedAt }) {
|
|
60
|
+
/** The cleanup brief "Queue cleanup" hands the dispatch seam. */
|
|
61
|
+
function cleanupBrief({ group, label, winner, losers, decidedAt, note }) {
|
|
75
62
|
const name = label === group ? `"${group}"` : `"${group}" (${label})`;
|
|
76
63
|
const remove = losers.length > 0 ? `remove ${losers.map(quote).join(", ")}` : "there are no other variants";
|
|
77
64
|
return [
|
|
78
|
-
`Variant group ${name} was decided on ${decidedAt}: keep ${quote(winner)}, ${remove}.`,
|
|
65
|
+
`Variant group ${name} was decided on ${decidedAt || "an unknown date"}: keep ${quote(winner)}, ${remove}.`,
|
|
79
66
|
"",
|
|
67
|
+
...note ? [`Note on the pick: ${note}`, ""] : [],
|
|
80
68
|
`Task: find <VariantGroup id="${group}"> in the app, inline the winning variant's markup where the group renders, delete the losing variants and the VariantGroup wrapper, remove the group's entries from .hud/variants.json, and run the project's checks.`
|
|
81
69
|
].join("\n");
|
|
82
70
|
}
|
|
83
|
-
async function
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
async function readAll(store) {
|
|
72
|
+
const entries = await store.list(VARIANTS_COLLECTION);
|
|
73
|
+
const stored = {
|
|
74
|
+
records: [],
|
|
75
|
+
groups: []
|
|
76
|
+
};
|
|
77
|
+
for (const { id, value } of entries) {
|
|
78
|
+
const record = toVariantRecord(id, value);
|
|
79
|
+
if (record) stored.records.push(record);
|
|
80
|
+
else {
|
|
81
|
+
const group = toGroupRecord(id, value);
|
|
82
|
+
if (group) stored.groups.push(group);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return stored;
|
|
86
|
+
}
|
|
87
|
+
/** Writes the pick onto the group's variant records: winner, rejected, or all open again. */
|
|
88
|
+
async function writePick(store, group, id, records, variants, at) {
|
|
89
|
+
const byId = new Map(records.map((r) => [r.id, r]));
|
|
90
|
+
const known = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const r of records) known.set(r.id, r.label ?? r.id);
|
|
92
|
+
for (const v of variants ?? []) known.set(v.id, v.label);
|
|
93
|
+
if (id !== null && !known.has(id)) known.set(id, id);
|
|
94
|
+
for (const [variant, label] of known) {
|
|
95
|
+
const { decidedAt: _previous, ...rest } = byId.get(variant) ?? {
|
|
96
|
+
group,
|
|
97
|
+
id: variant
|
|
98
|
+
};
|
|
99
|
+
const record = {
|
|
100
|
+
...rest,
|
|
101
|
+
group,
|
|
102
|
+
id: variant,
|
|
103
|
+
label,
|
|
104
|
+
status: "open"
|
|
105
|
+
};
|
|
106
|
+
if (id !== null) record.status = variant === id ? "decided" : "rejected";
|
|
107
|
+
if (variant === id) record.decidedAt = at;
|
|
108
|
+
await store.set(VARIANTS_COLLECTION, recordKey(group, variant), { ...record });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Applies a pick: variant records, then the group's note and log. Reads and writes the store only. */
|
|
112
|
+
async function applyPick(store, group, body) {
|
|
113
|
+
const stored = await readAll(store);
|
|
114
|
+
const records = stored.records.filter((r) => r.group === group);
|
|
115
|
+
const previous = stored.groups.find((g) => g.group === group);
|
|
116
|
+
const current = pickedRecord(records, group);
|
|
117
|
+
const before = {
|
|
118
|
+
pick: current?.id ?? null,
|
|
119
|
+
note: previous?.note ?? ""
|
|
120
|
+
};
|
|
121
|
+
const pick = body.id === void 0 ? before.pick : body.id;
|
|
122
|
+
const note = body.note ?? before.note;
|
|
123
|
+
if (pick === before.pick && note === before.note) {
|
|
124
|
+
const response = {
|
|
125
|
+
ok: true,
|
|
126
|
+
group,
|
|
127
|
+
pick,
|
|
128
|
+
note,
|
|
129
|
+
changed: false
|
|
130
|
+
};
|
|
131
|
+
if (current?.decidedAt) response.decidedAt = current.decidedAt;
|
|
132
|
+
return response;
|
|
133
|
+
}
|
|
134
|
+
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
135
|
+
if (pick !== before.pick) await writePick(store, group, pick, records, body.variants, at);
|
|
136
|
+
const label = body.label ?? previous?.label;
|
|
137
|
+
await store.set(VARIANTS_COLLECTION, group, {
|
|
138
|
+
...label === void 0 ? {} : { label },
|
|
139
|
+
note,
|
|
140
|
+
log: [...previous?.log ?? [], {
|
|
141
|
+
at,
|
|
142
|
+
pick,
|
|
143
|
+
note
|
|
144
|
+
}].map((entry) => ({ ...entry }))
|
|
87
145
|
});
|
|
146
|
+
const response = {
|
|
147
|
+
ok: true,
|
|
148
|
+
group,
|
|
149
|
+
pick,
|
|
150
|
+
note,
|
|
151
|
+
changed: true
|
|
152
|
+
};
|
|
153
|
+
const decidedAt = pick === null ? void 0 : pick === before.pick ? current?.decidedAt : at;
|
|
154
|
+
if (decidedAt) response.decidedAt = decidedAt;
|
|
155
|
+
return response;
|
|
88
156
|
}
|
|
89
157
|
/**
|
|
90
|
-
* Server half of `variants()
|
|
91
|
-
*
|
|
92
|
-
* `
|
|
93
|
-
*
|
|
94
|
-
*
|
|
158
|
+
* Server half of `variants()`.
|
|
159
|
+
*
|
|
160
|
+
* - `GET /` lists every record of the store's `variants` collection, with the
|
|
161
|
+
* groups' notes and logs.
|
|
162
|
+
* - `POST /:group/pick` records a pick and a note through the storage seam
|
|
163
|
+
* (`status` and `decidedAt` on the variants, note and log on the group).
|
|
164
|
+
* It never touches the dispatch seam.
|
|
165
|
+
* - `POST /:group/cleanup` queues the cleanup brief of a picked group through
|
|
166
|
+
* the dispatch seam; the panel's "Queue cleanup" button is the only caller.
|
|
167
|
+
*
|
|
168
|
+
* Carries `variants.decide`, which only development grants by default.
|
|
95
169
|
*/
|
|
96
170
|
function variantsServer({ store, dispatch, brief = cleanupBrief }) {
|
|
171
|
+
const queues = /* @__PURE__ */ new Map();
|
|
172
|
+
const serial = (group, run) => {
|
|
173
|
+
const result = (queues.get(group) ?? Promise.resolve()).then(run, run);
|
|
174
|
+
const settled = result.catch(() => {});
|
|
175
|
+
queues.set(group, settled);
|
|
176
|
+
settled.then(() => {
|
|
177
|
+
if (queues.get(group) === settled) queues.delete(group);
|
|
178
|
+
});
|
|
179
|
+
return result;
|
|
180
|
+
};
|
|
97
181
|
return definePlugin({
|
|
98
182
|
id: "variants",
|
|
99
183
|
capability: "variants.decide",
|
|
@@ -102,97 +186,78 @@ function variantsServer({ store, dispatch, brief = cleanupBrief }) {
|
|
|
102
186
|
try {
|
|
103
187
|
const body = {
|
|
104
188
|
ok: true,
|
|
105
|
-
|
|
189
|
+
...await readAll(store),
|
|
190
|
+
dispatch: dispatch?.id ?? null
|
|
106
191
|
};
|
|
107
192
|
return Response.json(body, { headers: NO_STORE });
|
|
108
193
|
} catch (error) {
|
|
109
194
|
return failed(error, "list");
|
|
110
195
|
}
|
|
111
196
|
} },
|
|
112
|
-
"/:group/
|
|
197
|
+
"/:group/pick": { POST: async (request, { params }) => {
|
|
113
198
|
const refusal = refuseCrossSite(request);
|
|
114
199
|
if (refusal) return refusal;
|
|
115
200
|
const group = params.group ?? "";
|
|
116
|
-
const body =
|
|
117
|
-
if (!group || !body) return
|
|
118
|
-
ok: false,
|
|
119
|
-
error: "invalid decision"
|
|
120
|
-
}, { status: 400 });
|
|
201
|
+
const body = parsePick(await readJson(request));
|
|
202
|
+
if (!isGroup(group) || !body) return invalid("invalid pick");
|
|
121
203
|
try {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
group,
|
|
144
|
-
id,
|
|
145
|
-
label,
|
|
146
|
-
status: "rejected"
|
|
147
|
-
};
|
|
148
|
-
await store.set(VARIANTS_COLLECTION, recordKey(group, id), { ...record });
|
|
149
|
-
}
|
|
150
|
-
const winnerLabel = known.get(body.id) ?? body.id;
|
|
151
|
-
const decision = {
|
|
152
|
-
group,
|
|
153
|
-
label: body.label ?? group,
|
|
154
|
-
winner: {
|
|
155
|
-
id: body.id,
|
|
156
|
-
label: winnerLabel
|
|
157
|
-
},
|
|
158
|
-
losers: [...known].filter(([id]) => id !== body.id).map(([id, label]) => ({
|
|
159
|
-
id,
|
|
160
|
-
label
|
|
161
|
-
})),
|
|
162
|
-
decidedAt
|
|
163
|
-
};
|
|
164
|
-
const response = {
|
|
165
|
-
ok: true,
|
|
204
|
+
return Response.json(await serial(group, () => applyPick(store, group, body)), { headers: NO_STORE });
|
|
205
|
+
} catch (error) {
|
|
206
|
+
return failed(error, "pick");
|
|
207
|
+
}
|
|
208
|
+
} },
|
|
209
|
+
"/:group/cleanup": { POST: async (request, { params }) => {
|
|
210
|
+
const refusal = refuseCrossSite(request);
|
|
211
|
+
if (refusal) return refusal;
|
|
212
|
+
const group = params.group ?? "";
|
|
213
|
+
if (!isGroup(group)) return invalid("invalid group");
|
|
214
|
+
if (!dispatch) return invalid("no dispatch provider configured", 409);
|
|
215
|
+
try {
|
|
216
|
+
const stored = await readAll(store);
|
|
217
|
+
const records = stored.records.filter((r) => r.group === group);
|
|
218
|
+
const winner = pickedRecord(records, group);
|
|
219
|
+
if (!winner) return invalid(`nothing is picked in "${group}"`, 409);
|
|
220
|
+
const named = (r) => ({
|
|
221
|
+
id: r.id,
|
|
222
|
+
label: r.label ?? r.id
|
|
223
|
+
});
|
|
224
|
+
const prompt = brief({
|
|
166
225
|
group,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
226
|
+
label: stored.groups.find((g) => g.group === group)?.label ?? group,
|
|
227
|
+
winner: named(winner),
|
|
228
|
+
losers: records.filter((r) => r.id !== winner.id).map(named),
|
|
229
|
+
decidedAt: winner.decidedAt ?? "",
|
|
230
|
+
note: stored.groups.find((g) => g.group === group)?.note ?? ""
|
|
231
|
+
});
|
|
232
|
+
try {
|
|
172
233
|
const status = await dispatch.status?.() ?? { available: true };
|
|
173
234
|
if (!status.available) throw new Error(status.reason);
|
|
174
|
-
const prompt = brief(decision);
|
|
175
235
|
const run = await dispatch.dispatch({
|
|
176
|
-
note: `Clean up variant group "${group}": keep "${
|
|
236
|
+
note: `Clean up variant group "${group}": keep "${winner.id}"`,
|
|
177
237
|
payload: null,
|
|
178
238
|
hints: [],
|
|
179
239
|
prompt
|
|
180
240
|
});
|
|
181
|
-
response
|
|
182
|
-
|
|
183
|
-
|
|
241
|
+
const response = {
|
|
242
|
+
ok: true,
|
|
243
|
+
group,
|
|
244
|
+
id: winner.id,
|
|
245
|
+
queued: {
|
|
246
|
+
target: dispatch.id,
|
|
247
|
+
runId: run.runId,
|
|
248
|
+
...run.detail ? { detail: run.detail } : {}
|
|
249
|
+
}
|
|
184
250
|
};
|
|
185
|
-
|
|
251
|
+
return Response.json(response);
|
|
186
252
|
} catch (error) {
|
|
187
|
-
|
|
253
|
+
return invalid(`brief not queued: ${message(error)}`, 502);
|
|
188
254
|
}
|
|
189
|
-
return Response.json(response);
|
|
190
255
|
} catch (error) {
|
|
191
|
-
return failed(error, "
|
|
256
|
+
return failed(error, "cleanup");
|
|
192
257
|
}
|
|
193
258
|
} }
|
|
194
259
|
}
|
|
195
260
|
});
|
|
196
261
|
}
|
|
197
262
|
//#endregion
|
|
198
|
-
export { VARIANTS_COLLECTION, cleanupBrief, recordKey, toVariantRecord, variantsServer };
|
|
263
|
+
export { VARIANTS_COLLECTION, cleanupBrief, formatVariantsMarkdown, readVariants, recordKey, toGroupRecord, toVariantRecord, variantsServer };
|
package/dist/plugins/design.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as HudGenerateRequest, c as HudVariantsAdapter, d as HudTokenGroup, f as HudTokenScope, i as variants, l as HudVariantPage, n as forceState, o as HudGenerateResult, p as HudTokensAdapter, r as tokens, s as HudVariantCategory, t as HudVariantsOptions, u as HudTokenDescriptor } from "../index-BeqWehuh.js";
|
|
2
2
|
import { a as formatVariantParam, i as VariantOption, n as VARIANT_PARAM, o as parseVariantParam, r as VariantGroupInfo, t as VARIANT_MARKER } from "../variant-groups-aAIrcNK5.js";
|
|
3
|
-
import { a as VariantStatus,
|
|
3
|
+
import { a as VariantGroupRecord, c as VariantStatus, l as VariantsListResponse, n as PickBody, o as VariantLogEntry, r as PickResponse, s as VariantRecord, t as CleanupResponse } from "../variants-types-VkW7vFZF.js";
|
|
4
4
|
import { i as ForcedState, n as FORCE_STATE_MARKER, r as FORCE_STATE_PARAM, t as FORCED_STATES } from "../force-state-CCqoTfVB.js";
|
|
5
|
-
export { type
|
|
5
|
+
export { type CleanupResponse, FORCED_STATES, FORCE_STATE_MARKER, FORCE_STATE_PARAM, type ForcedState, type HudGenerateRequest, type HudGenerateResult, type HudTokenDescriptor, type HudTokenGroup, type HudTokenScope, type HudTokensAdapter, type HudVariantCategory, type HudVariantPage, type HudVariantsAdapter, HudVariantsOptions, type PickBody, type PickResponse, VARIANT_MARKER, VARIANT_PARAM, type VariantGroupInfo, type VariantGroupRecord, type VariantLogEntry, type VariantOption, type VariantRecord, type VariantStatus, type VariantsListResponse, forceState, formatVariantParam, parseVariantParam, tokens, variants };
|
package/dist/plugins/design.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as FORCE_STATE_MARKER, r as FORCE_STATE_PARAM, t as FORCED_STATES } from "../force-state-BaqWsmrf.js";
|
|
2
|
-
import { n as tokens, r as variants, t as forceState } from "../design-
|
|
2
|
+
import { n as tokens, r as variants, t as forceState } from "../design-BIXY1-Ex.js";
|
|
3
3
|
import { n as VARIANT_PARAM, o as parseVariantParam, r as formatVariantParam, t as VARIANT_MARKER } from "../variant-groups-TIfO3NIj.js";
|
|
4
4
|
export { FORCED_STATES, FORCE_STATE_MARKER, FORCE_STATE_PARAM, VARIANT_MARKER, VARIANT_PARAM, forceState, formatVariantParam, parseVariantParam, tokens, variants };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as requestBuffer, n as RequestPayload, r as RequestTransport, t as InspectRequest } from "../requests-CJrUf465.js";
|
|
2
2
|
import { t as InspectAdapter } from "../adapter-BYoxPYTI.js";
|
|
3
|
-
import { a as replay, c as isSensitiveKey, d as redactUrl, i as InspectFilter, l as redactBody, n as InspectOptions, o as replayBlocker, r as inspect, s as REDACTED, t as INSPECT_CAPABILITY, u as redactHeaders } from "../index-
|
|
3
|
+
import { a as replay, c as isSensitiveKey, d as redactUrl, i as InspectFilter, l as redactBody, n as InspectOptions, o as replayBlocker, r as inspect, s as REDACTED, t as INSPECT_CAPABILITY, u as redactHeaders } from "../index-DS0yT0c-.js";
|
|
4
4
|
export { INSPECT_CAPABILITY, type InspectAdapter, type InspectFilter, InspectOptions, type InspectRequest, REDACTED, type RequestPayload, type RequestTransport, inspect, isSensitiveKey, redactBody, redactHeaders, redactUrl, replay, replayBlocker, requestBuffer };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { a as CaptureOptions, n as RequestPayload, r as RequestTransport, t as InspectRequest } from "../requests-CJrUf465.js";
|
|
2
2
|
import { n as CaptureKind, t as CaptureEntry } from "../capture-buffer-Bbbo6omF.js";
|
|
3
|
-
import { n as observe, r as HudUserInfo, t as ObserveOptions } from "../index-
|
|
3
|
+
import { n as observe, r as HudUserInfo, t as ObserveOptions } from "../index-DvlCkGB1.js";
|
|
4
4
|
export { type CaptureEntry, type CaptureKind, type CaptureOptions, type HudUserInfo, type InspectRequest, ObserveOptions, type RequestPayload, type RequestTransport, observe };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as HudRoutes } from "../../plugins-
|
|
1
|
+
import { p as HudRoutes } from "../../plugins-pL2CoWzI.js";
|
|
2
2
|
import { a as CiSnapshot, c as TelemetryRange, i as CiRun, l as TelemetryResponse, n as CiProvider, o as CiState, r as CiResponse, s as TelemetryProvider, t as CiDeployment, u as TelemetrySnapshot } from "../../types-f3jlNxzw.js";
|
|
3
3
|
//#region src/plugins/ops/errors.d.ts
|
|
4
4
|
/**
|
package/dist/plugins/ops.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as HudBadge, u as HudPluginProps } from "../plugins-
|
|
1
|
+
import { r as HudBadge, u as HudPluginProps } from "../plugins-pL2CoWzI.js";
|
|
2
2
|
import { c as TelemetryRange, i as CiRun, l as TelemetryResponse, o as CiState, r as CiResponse, t as CiDeployment } from "../types-f3jlNxzw.js";
|
|
3
3
|
//#region src/plugins/ops/index.d.ts
|
|
4
4
|
declare function OpsPill({ ctx }: HudPluginProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as ROUTES_CAPABILITY, i as RoutesResponse, n as RouteSegment, o as ROUTES_ID, r as RouteUrl, t as RouteEntry } from "../../types-Dc6JWZR7.js";
|
|
2
2
|
//#region src/plugins/routes/scan.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Pure derivation over a Next `app/` tree: folder names to patterns, patterns
|
package/dist/plugins/routes.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
export { ROUTES_CAPABILITY, ROUTES_ID, type RouteEntry, type RouteSegment, type RouteUrl, type RoutesResponse, routes };
|
|
1
|
+
import { a as ROUTES_CAPABILITY, i as RoutesResponse, n as RouteSegment, o as ROUTES_ID, r as RouteUrl, t as RouteEntry } from "../types-Dc6JWZR7.js";
|
|
2
|
+
import { n as routes, t as RoutesOptions } from "../index-B7qaEUgh.js";
|
|
3
|
+
export { ROUTES_CAPABILITY, ROUTES_ID, type RouteEntry, type RouteSegment, type RouteUrl, RoutesOptions, type RoutesResponse, routes };
|