@engenty/wizards-runtime 0.7.8 → 0.7.10

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 (113) hide show
  1. package/README.md +2 -1
  2. package/apps/runtime/dist/app.js +2 -2
  3. package/apps/runtime/dist/cli/autostart.js +90 -7
  4. package/apps/runtime/dist/cli/autoupdate.js +18 -5
  5. package/apps/runtime/dist/cli/clients.js +25 -6
  6. package/apps/runtime/dist/cli/connect.js +7 -2
  7. package/apps/runtime/dist/cli/environment.js +33 -2
  8. package/apps/runtime/dist/cli/exec.js +38 -1
  9. package/apps/runtime/dist/cli/home.js +15 -0
  10. package/apps/runtime/dist/cli/machine.js +18 -8
  11. package/apps/runtime/dist/cli/processes.js +23 -3
  12. package/apps/runtime/dist/cli/setup.js +11 -1
  13. package/apps/runtime/dist/cli/start.js +33 -7
  14. package/apps/runtime/dist/cli/uninstall.js +100 -6
  15. package/apps/runtime/dist/cli/update.js +28 -12
  16. package/apps/runtime/dist/cli/versions.js +16 -4
  17. package/apps/runtime/dist/clients.js +118 -0
  18. package/apps/runtime/dist/db/client.js +37 -3
  19. package/apps/runtime/dist/db/migrations/tenant/0017_run_client.sql +1 -0
  20. package/apps/runtime/dist/db/migrations/tenant/meta/0017_snapshot.json +3333 -0
  21. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  22. package/apps/runtime/dist/db/schema.js +2 -0
  23. package/apps/runtime/dist/docs/dev/api.md +39 -0
  24. package/apps/runtime/dist/docs/dev/index.md +1 -0
  25. package/apps/runtime/dist/docs/dev/integration/openui.md +5 -3
  26. package/apps/runtime/dist/docs/dev/meta.json +1 -1
  27. package/apps/runtime/dist/docs/user/ai-apps.md +14 -3
  28. package/apps/runtime/dist/docs/user/install.md +18 -8
  29. package/apps/runtime/dist/engine/runner.js +1 -0
  30. package/apps/runtime/dist/harness/env.js +41 -8
  31. package/apps/runtime/dist/harness/index.js +10 -1
  32. package/apps/runtime/dist/harness/model.js +1 -1
  33. package/apps/runtime/dist/index.js +13 -4
  34. package/apps/runtime/dist/plugin.js +24 -8
  35. package/apps/runtime/dist/render/browser-path.js +43 -11
  36. package/apps/runtime/dist/routes/runs.js +9 -0
  37. package/apps/runtime/dist/update.js +4 -0
  38. package/apps/web/dist/assets/AboutDialog-B2LuZ_mC.js +1 -0
  39. package/apps/web/dist/assets/ChangelogDialog-B0lS0BdL.js +1 -0
  40. package/apps/web/dist/assets/ChatView-BcPDcU2d.js +10 -0
  41. package/apps/web/dist/assets/EditorPage-erduYKNM.js +4 -0
  42. package/apps/web/dist/assets/{FlowPreview-Dx8AjXvE.js → FlowPreview-oX_Emm7u.js} +1 -1
  43. package/apps/web/dist/assets/{Harness-NvIb36TG.js → Harness-Dv9ln5xB.js} +2 -2
  44. package/apps/web/dist/assets/{NewWizardChannels-B2YgtJlt.js → NewWizardChannels-JveYyh-U.js} +1 -1
  45. package/apps/web/dist/assets/NewWizardPage-Dfk-WOhX.js +7 -0
  46. package/apps/web/dist/assets/OnboardingPage-CT9dL4ke.js +1 -0
  47. package/apps/web/dist/assets/ProjectPage-5_Wsk9Hv.js +1 -0
  48. package/apps/web/dist/assets/PublicRunner-Cw1WzTze.js +1 -0
  49. package/apps/web/dist/assets/{ReadOnly-CGNHlgUT.js → ReadOnly-S9vGVQHr.js} +1 -1
  50. package/apps/web/dist/assets/RunDrawer-O4rEFCL8.js +4 -0
  51. package/apps/web/dist/assets/RunnerView-BW1h4x63.js +1 -0
  52. package/apps/web/dist/assets/SettingsPage-DmhN7OTy.js +1 -0
  53. package/apps/web/dist/assets/SetupPage-BlWd7Uln.js +1 -0
  54. package/apps/web/dist/assets/{SharePage-hG7Z6SLy.js → SharePage-ktqm-jWI.js} +1 -1
  55. package/apps/web/dist/assets/changelog-FJJS0Tpt.js +1 -0
  56. package/apps/web/dist/assets/engenty-WpMi3xwq.js +1 -0
  57. package/apps/web/dist/assets/{esm-DVk3RJij.js → esm-C-ZWeuhU.js} +1 -1
  58. package/apps/web/dist/assets/{fluffy-engenty-ClRou7yu.js → fluffy-engenty-DPNHytrz.js} +135 -16
  59. package/apps/web/dist/assets/goose-helmet-Cvc7KjUg.bin +0 -0
  60. package/apps/web/dist/assets/goose-helmet-livery-CZD9u0XS.webp +0 -0
  61. package/apps/web/dist/assets/index-C4aHMcg9.css +1 -0
  62. package/apps/web/dist/assets/index-xH9uN8Nh.js +14 -0
  63. package/apps/web/dist/assets/oss-credits-Bc05Qv5H.js +1 -0
  64. package/apps/web/dist/assets/{phone-CXXHXYnA.js → phone-BjmhIKuT.js} +1 -1
  65. package/apps/web/dist/assets/{settings-menu-DXzZCIMx.js → settings-menu-Dpkp3f56.js} +1 -1
  66. package/apps/web/dist/assets/{ui-DQ4L2npj.js → ui-DMmT-cSO.js} +4 -4
  67. package/apps/web/dist/assets/{upload-BnYHIfu5.js → upload-JX9BcMTq.js} +1 -1
  68. package/apps/web/dist/assets/{wrench-BrUJ7SV6.js → wrench-BSxnPs2_.js} +1 -1
  69. package/apps/web/dist/index.html +4 -4
  70. package/apps/web/dist/install.ps1 +307 -0
  71. package/apps/web/dist/mcp/flow.html +141 -22
  72. package/bin/wizards.mjs +59 -35
  73. package/node_modules/@engenty/wizards/package.json +1 -4
  74. package/node_modules/@engenty-wizards/shared/dist/claude-plugin.d.ts +7 -0
  75. package/node_modules/@engenty-wizards/shared/dist/claude-plugin.js +10 -0
  76. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +2 -0
  77. package/node_modules/@engenty-wizards/shared/dist/run.js +4 -0
  78. package/package.json +2 -5
  79. package/plugin/.claude-plugin/plugin.json +28 -6
  80. package/plugin/README.md +58 -0
  81. package/plugin/hooks/engenty.ts +140 -0
  82. package/plugin/hooks/hooks.json +1 -0
  83. package/plugin/hooks/pane.test.tsx +177 -0
  84. package/plugin/hooks/register.tsx +396 -0
  85. package/plugin/types/index.d.ts +44 -0
  86. package/apps/web/dist/assets/AboutDialog-ByZyHXDj.js +0 -1
  87. package/apps/web/dist/assets/ChangelogDialog-QHYP0jAv.js +0 -1
  88. package/apps/web/dist/assets/ChatView-DupTtI8K.js +0 -10
  89. package/apps/web/dist/assets/EditorPage-k6qouLeS.js +0 -4
  90. package/apps/web/dist/assets/NewWizardPage-BgLY6SL6.js +0 -7
  91. package/apps/web/dist/assets/OnboardingPage-CxhwefJU.js +0 -1
  92. package/apps/web/dist/assets/ProjectPage-6ceSSS7W.js +0 -1
  93. package/apps/web/dist/assets/PublicRunner-6lQvReDx.js +0 -1
  94. package/apps/web/dist/assets/RunDrawer-TVGNnWyx.js +0 -4
  95. package/apps/web/dist/assets/RunnerView-DInSK0VZ.js +0 -1
  96. package/apps/web/dist/assets/SettingsPage-D3k5pXN5.js +0 -1
  97. package/apps/web/dist/assets/SetupPage-Bj5frdzY.js +0 -1
  98. package/apps/web/dist/assets/changelog-CO9vKjV0.js +0 -1
  99. package/apps/web/dist/assets/engenty-eXZ-EAwd.js +0 -1
  100. package/apps/web/dist/assets/index-DfaoPjNW.css +0 -1
  101. package/apps/web/dist/assets/index-DlDsr9Lc.js +0 -14
  102. package/apps/web/dist/assets/oss-credits-X2JPiMOR.js +0 -1
  103. package/node_modules/@engenty/wizards/dist/openui/Wizard.d.ts +0 -20
  104. package/node_modules/@engenty/wizards/dist/openui/Wizard.js +0 -62
  105. package/node_modules/@engenty/wizards/dist/openui/index.d.ts +0 -9
  106. package/node_modules/@engenty/wizards/dist/openui/index.js +0 -9
  107. package/node_modules/@engenty/wizards/dist/openui/message.d.ts +0 -11
  108. package/node_modules/@engenty/wizards/dist/openui/message.js +0 -69
  109. package/node_modules/@engenty/wizards/dist/openui/run.d.ts +0 -8
  110. package/node_modules/@engenty/wizards/dist/openui/run.js +0 -137
  111. package/node_modules/@engenty/wizards/dist/openui/server.d.ts +0 -37
  112. package/node_modules/@engenty/wizards/dist/openui/server.js +0 -77
  113. package/plugin/.mcp.json +0 -8
@@ -0,0 +1,177 @@
1
+ import type { McpToolResult } from "claude-code";
2
+ import { expect, test } from "claude-code/testing";
3
+
4
+ const PANE_PROPS = {
5
+ title: "engenty.wizards",
6
+ isFocused: true,
7
+ bodyColumns: 80,
8
+ placement: "dock",
9
+ scroll: { offset: 0, bodyRows: 40 },
10
+ view: {},
11
+ } as const;
12
+
13
+ const answer = (value: unknown): McpToolResult => ({
14
+ content: [{ type: "text", text: JSON.stringify(value) }],
15
+ isError: false,
16
+ });
17
+
18
+ const BASE = "http://localhost:24368";
19
+
20
+ const wizard = (id: string, title: string, published: boolean, shared = published) => ({
21
+ wizardId: id,
22
+ draft: {
23
+ title,
24
+ description: `${title} macht etwas.`,
25
+ avatar: "round",
26
+ steps: [
27
+ { id: "first", type: "page", title: "Thema" },
28
+ { id: "write", type: "result", title: "Fertig" },
29
+ ],
30
+ },
31
+ shareEnabled: shared,
32
+ shareUrl: `${BASE}/w/t-${id}`,
33
+ studioUrl: `${BASE}/studio/edit/${id}`,
34
+ });
35
+
36
+ const waiting = {
37
+ runId: "r1",
38
+ wizardId: "w2",
39
+ mode: "live",
40
+ status: "waiting_input",
41
+ waitingFor: { page: "first", title: "Thema", fields: [] },
42
+ browserUrl: `${BASE}/w/t-w2/r1`,
43
+ };
44
+
45
+ test("lists the wizards; Run opens the page beside the chat, Edit asks the chat", async ($, on) => {
46
+ const calls: string[] = [];
47
+ const opened: string[] = [];
48
+ const filled: string[] = [];
49
+ on("prompt.fill", async (_, e) => {
50
+ filled.push(e.text);
51
+ return { isFilled: true };
52
+ });
53
+ on("mcp.call", { server: "engenty-wizards" }, async (_, e) => {
54
+ calls.push(e.tool);
55
+ if (e.tool === "list_wizards") {
56
+ return {
57
+ value: answer([
58
+ { id: "w1", title: "Brot", published: true, studioUrl: `${BASE}/studio/edit/w1` },
59
+ { id: "w2", title: "Ohne Link", published: true, studioUrl: `${BASE}/studio/edit/w2` },
60
+ { id: "w0", title: "Entwurf", published: false, studioUrl: `${BASE}/studio/edit/w0` },
61
+ ]),
62
+ };
63
+ }
64
+ if (e.tool === "get_wizard") {
65
+ const id = String(e.args.wizardId);
66
+ if (id === "w1") return { value: answer(wizard("w1", "Brot", true)) };
67
+ if (id === "w2") return { value: answer(wizard("w2", "Ohne Link", true, false)) };
68
+ return { value: answer(wizard("w0", "Entwurf", false)) };
69
+ }
70
+ if (e.tool === "run_wizard") return { value: answer(waiting) };
71
+ return { deny: `unexpected ${e.tool}` };
72
+ });
73
+ on("mcp.call", { server: "Claude_Browser" }, async (_, e) => {
74
+ opened.push(String(e.args.url));
75
+ return { value: { content: [], isError: false } };
76
+ });
77
+
78
+ for (const surface of ["terminal", "desktop"] as const) {
79
+ calls.length = 0;
80
+ opened.length = 0;
81
+ const ui = await $.ui.mount({
82
+ plugin: "wizards",
83
+ surface,
84
+ component: "Pane",
85
+ requestId: "wizards",
86
+ props: PANE_PROPS,
87
+ });
88
+ await ui.press({ key: "Reload" });
89
+ // Details are fetched once per wizard; the second surface finds them in the session's state.
90
+ expect(calls).toEqual(
91
+ surface === "terminal"
92
+ ? ["list_wizards", "get_wizard", "get_wizard", "get_wizard"]
93
+ : ["list_wizards"],
94
+ );
95
+ expect(await ui.find({ type: "Text", text: "Brot" })).toBeDefined();
96
+ expect(await ui.find({ type: "Text", text: /Entwurf · draft/ })).toBeDefined();
97
+ expect(await ui.find({ key: "run:w1" })).toBeDefined();
98
+ expect(await ui.find({ key: "run:w0" })).toBeUndefined();
99
+ expect(await ui.find({ key: "edit:w0" })).toBeDefined();
100
+ expect(await ui.find({ type: "Text", text: "localhost:24368" })).toBeDefined();
101
+
102
+ // A wizard with a page of its own opens there.
103
+ await ui.press({ key: "run:w1" });
104
+ expect(opened).toEqual([`${BASE}/w/t-w1`]);
105
+ // One without is started here, and its run's page opens.
106
+ await ui.press({ key: "run:w2" });
107
+ expect(calls.at(-1)).toBe("run_wizard");
108
+ expect(opened.at(-1)).toBe(`${BASE}/w/t-w2/r1`);
109
+
110
+ await ui.press({ key: "edit:w0" });
111
+ expect(filled.at(-1)).toBe('For my engenty wizard "Entwurf" I need the following changes: ');
112
+ await ui.press({ key: "Studio" });
113
+ expect(opened.at(-1)).toBe(`${BASE}/studio`);
114
+ await ui.unmount();
115
+ }
116
+ });
117
+
118
+ test("a run the model drives opens beside the chat once", async ($, on) => {
119
+ const opened: string[] = [];
120
+ on("mcp.call", { server: "Claude_Browser" }, async (_, e) => {
121
+ opened.push(String(e.args.url));
122
+ return { value: { content: [], isError: false } };
123
+ });
124
+ on("mcp.call", { server: "engenty-wizards" }, () => ({ deny: "not in this test" }));
125
+ on("tool.call", { tool: "mcp__engenty-wizards__get_run" }, async () => ({
126
+ result: { content: [{ type: "text", text: JSON.stringify(waiting) }] },
127
+ }));
128
+
129
+ const ui = await $.ui.mount({
130
+ plugin: "wizards",
131
+ surface: "desktop",
132
+ component: "Pane",
133
+ requestId: "wizards",
134
+ props: PANE_PROPS,
135
+ });
136
+ await $.tool.call({ tool: "mcp__engenty-wizards__get_run", tool_use_id: "t1", runId: "r1" });
137
+ await $.tool.call({ tool: "mcp__engenty-wizards__get_run", tool_use_id: "t2", runId: "r1" });
138
+ expect(opened).toEqual([`${BASE}/w/t-w2/r1`]);
139
+ await ui.unmount();
140
+ });
141
+
142
+ test("offers a plain link when the browser pane refuses", async ($, on) => {
143
+ on("mcp.call", { server: "engenty-wizards" }, async (_, e) => {
144
+ if (e.tool === "list_wizards") {
145
+ return { value: answer([{ id: "w1", title: "Brot", published: true }]) };
146
+ }
147
+ if (e.tool === "get_wizard") return { value: answer(wizard("w1", "Brot", true)) };
148
+ return { deny: `unexpected ${e.tool}` };
149
+ });
150
+ on("mcp.call", { server: "Claude_Browser" }, () => ({ deny: "no verdict for navigate" }));
151
+ const ui = await $.ui.mount({
152
+ plugin: "wizards",
153
+ surface: "desktop",
154
+ component: "Pane",
155
+ requestId: "wizards",
156
+ props: PANE_PROPS,
157
+ });
158
+ await ui.press({ key: "Reload" });
159
+ await ui.press({ key: "run:w1" });
160
+ expect(await ui.find({ type: "Text", text: /did not open/ })).toBeDefined();
161
+ expect((await ui.find({ type: "Link" }))?.props.href).toBe(`${BASE}/w/t-w1`);
162
+ await ui.unmount();
163
+ });
164
+
165
+ test("says why when the runtime cannot be reached", async ($, on) => {
166
+ on("mcp.call", { server: "engenty-wizards" }, () => ({ deny: "ECONNREFUSED" }));
167
+ const ui = await $.ui.mount({
168
+ plugin: "wizards",
169
+ surface: "terminal",
170
+ component: "Pane",
171
+ requestId: "wizards",
172
+ props: PANE_PROPS,
173
+ });
174
+ await ui.press({ key: "Reload" });
175
+ expect(await ui.find({ type: "Text", text: /ECONNREFUSED/ })).toBeDefined();
176
+ await ui.unmount();
177
+ });
@@ -0,0 +1,396 @@
1
+ import type { EngineInterface, Register, RenderSurface } from "claude-code";
2
+ import { atom, read, update } from "claude-code";
3
+
4
+ import type { RunView, WizardDetails, WizardRow } from "../types";
5
+ import { engentyColor, engentySvg } from "./engenty";
6
+
7
+ const PANE = "wizards";
8
+
9
+ const wizards = atom({ plugin: "wizards", key: "wizards" } as const, []);
10
+ const details = atom({ plugin: "wizards", key: "details" } as const, {}, { shape: "v2" });
11
+ const message = atom({ plugin: "wizards", key: "message" } as const, null);
12
+ const shown = atom({ plugin: "wizards", key: "shown" } as const, null);
13
+ const runtime = atom({ plugin: "wizards", key: "runtime" } as const, null);
14
+ const fallback = atom({ plugin: "wizards", key: "fallback" } as const, null);
15
+
16
+ /** The runtime's MCP tools whose answer is a run report: a run the model drives. */
17
+ const RUN_TOOLS = new Set([
18
+ "run_wizard",
19
+ "get_run",
20
+ "answer_page",
21
+ "answer_ask",
22
+ "review_step",
23
+ "control_run",
24
+ ]);
25
+
26
+ type Called = { ok: true; body: unknown } | { ok: false; error: string };
27
+
28
+ /** What the hooks need beyond `$`: the two MCP servers the pane talks to. */
29
+ type Servers = { server: string; browser: string };
30
+
31
+ /** This plugin's name in its manifest: a server bundled with it is listed under it. */
32
+ const PLUGIN = "wizards";
33
+
34
+ /** A server's spelling inside a tool name: anything but letters, digits, `_` and `-` becomes `_`. */
35
+ const slug = (name: string) => name.replace(/[^A-Za-z0-9_-]/g, "_");
36
+
37
+ /** The tool-name prefixes under which the runtime's tools may appear. */
38
+ const prefixesOf = (server: string) => [
39
+ `mcp__${slug(server)}__`,
40
+ `mcp__plugin_${PLUGIN}_${slug(server)}__`,
41
+ ];
42
+
43
+ const isRecord = (v: unknown): v is Record<string, unknown> =>
44
+ typeof v === "object" && v !== null && !Array.isArray(v);
45
+
46
+ const parse = (text: string): unknown => {
47
+ try {
48
+ return JSON.parse(text);
49
+ } catch {
50
+ return text;
51
+ }
52
+ };
53
+
54
+ /** The text of a tool result, whatever shape the engine hands it in. */
55
+ const textOf = (result: unknown): string | undefined => {
56
+ if (typeof result === "string") return result;
57
+ const blocks = Array.isArray(result)
58
+ ? result
59
+ : isRecord(result) && Array.isArray(result.content)
60
+ ? result.content
61
+ : [];
62
+ const block = blocks.find((b) => isRecord(b) && b.type === "text" && typeof b.text === "string");
63
+ return isRecord(block) ? String(block.text) : undefined;
64
+ };
65
+
66
+ const isReport = (v: unknown): v is RunView =>
67
+ isRecord(v) && typeof v.runId === "string" && typeof v.status === "string";
68
+
69
+ const isOver = (r: RunView) =>
70
+ r.status === "done" || r.status === "failed" || r.status === "cancelled";
71
+
72
+ const originOf = (url: string | null | undefined): string | undefined => {
73
+ if (!url) return undefined;
74
+ try {
75
+ return new URL(url).origin;
76
+ } catch {
77
+ return undefined;
78
+ }
79
+ };
80
+
81
+ /** What get_wizard answers, kept to what the pane draws. */
82
+ const detailsOf = (body: unknown): WizardDetails | undefined => {
83
+ if (!isRecord(body) || !isRecord(body.draft)) return undefined;
84
+ const d = body.draft;
85
+ const steps = Array.isArray(d.steps) ? d.steps.filter(isRecord) : [];
86
+ const shareUrl =
87
+ typeof body.shareUrl === "string" && body.shareEnabled !== false ? body.shareUrl : undefined;
88
+ return {
89
+ title: typeof d.title === "string" && d.title ? d.title : String(body.wizardId ?? ""),
90
+ ...(typeof d.description === "string" && d.description ? { description: d.description } : {}),
91
+ ...(typeof d.avatar === "string" ? { avatar: d.avatar } : {}),
92
+ ...(shareUrl ? { shareUrl } : {}),
93
+ steps: steps.map((s) => ({
94
+ id: String(s.id),
95
+ type: typeof s.type === "string" ? s.type : "step",
96
+ title: typeof s.title === "string" && s.title ? s.title : String(s.id),
97
+ })),
98
+ };
99
+ };
100
+
101
+ async function call(
102
+ $: EngineInterface,
103
+ server: string,
104
+ tool: string,
105
+ args: Record<string, unknown>,
106
+ isRetry = false,
107
+ ): Promise<Called> {
108
+ try {
109
+ const result = await $.mcp.call(server, tool, args);
110
+ const text = result.content.find((b) => b.type === "text")?.text ?? "";
111
+ const body = parse(text);
112
+ if (result.isError) {
113
+ const reason = isRecord(body) && typeof body.message === "string" ? body.message : text;
114
+ return { ok: false, error: reason || `${tool} failed.` };
115
+ }
116
+ return { ok: true, body };
117
+ } catch (err) {
118
+ const error = err instanceof Error ? err.message : String(err);
119
+ // The auto-mode classifier's "no verdict" asks for one more try, as-is.
120
+ if (!isRetry && /no verdict/i.test(error)) return call($, server, tool, args, true);
121
+ return { ok: false, error };
122
+ }
123
+ }
124
+
125
+ function say($: EngineInterface, text: string | null) {
126
+ return update($, message, () => text);
127
+ }
128
+
129
+ /** Opens a page in the app's browser pane, beside the transcript; refused, offers a link. */
130
+ async function show($: EngineInterface, browser: string, url: string) {
131
+ const got = await call($, browser, "navigate", { url });
132
+ if (got.ok) {
133
+ await update($, fallback, () => null);
134
+ await say($, null);
135
+ return true;
136
+ }
137
+ await update($, fallback, () => url);
138
+ await say($, `The browser pane did not open it: ${got.error}`);
139
+ return false;
140
+ }
141
+
142
+ /** The run's own page, the wizard as it greets a person; a test run has the studio instead. */
143
+ async function showRun($: EngineInterface, browser: string, current: RunView) {
144
+ const url = current.browserUrl ?? current.studioUrl;
145
+ if (!url) {
146
+ await say($, "This run has no page of its own.");
147
+ return false;
148
+ }
149
+ await update($, shown, () => current.runId);
150
+ return show($, browser, url);
151
+ }
152
+
153
+ /** A wizard's name, engenty, steps and page, fetched once per wizard. */
154
+ async function ensureDetails($: EngineInterface, server: string, wizardId: string) {
155
+ const known = await read($, details);
156
+ if (known[wizardId]) return;
157
+ const got = await call($, server, "get_wizard", { wizardId });
158
+ if (!got.ok) {
159
+ await say($, `The wizard's details did not load: ${got.error}`);
160
+ return;
161
+ }
162
+ const found = detailsOf(got.body);
163
+ if (found) await update($, details, (d) => ({ ...d, [wizardId]: found }));
164
+ }
165
+
166
+ /** The list, then each wizard's details, so every row has its engenty and page. */
167
+ async function loadWizards($: EngineInterface, server: string) {
168
+ const got = await call($, server, "list_wizards", {});
169
+ if (!got.ok) {
170
+ await say($, got.error);
171
+ return false;
172
+ }
173
+ const rows: WizardRow[] = (Array.isArray(got.body) ? got.body : []).filter(isRecord).map((w) => ({
174
+ id: String(w.id),
175
+ title: typeof w.title === "string" && w.title ? w.title : String(w.id),
176
+ published: Boolean(w.published),
177
+ ...(typeof w.studioUrl === "string" ? { studioUrl: w.studioUrl } : {}),
178
+ }));
179
+ await update($, wizards, () => rows);
180
+ await say($, null);
181
+ const origin = originOf(rows.find((r) => r.studioUrl)?.studioUrl);
182
+ if (origin) await update($, runtime, () => origin);
183
+ for (const row of rows) await ensureDetails($, server, row.id);
184
+ return true;
185
+ }
186
+
187
+ /** Runs a wizard: its own page where it has one, else a run started here and its page. */
188
+ async function runWizard($: EngineInterface, at: Servers, wizard: WizardRow) {
189
+ if (!wizard.published) {
190
+ await say($, `"${wizard.title}" is not published yet.`);
191
+ return false;
192
+ }
193
+ const page = (await read($, details))[wizard.id]?.shareUrl;
194
+ if (page) return show($, at.browser, page);
195
+ const got = await call($, at.server, "run_wizard", { wizardId: wizard.id, answers: {} });
196
+ if (!got.ok) {
197
+ await say($, got.error);
198
+ return false;
199
+ }
200
+ if (!isReport(got.body)) return false;
201
+ return showRun($, at.browser, got.body);
202
+ }
203
+
204
+ /**
205
+ * Puts a change request for the wizard into the chat, for the person to finish; where no box
206
+ * takes it, the sentence goes to the clipboard instead.
207
+ */
208
+ async function askForChanges($: EngineInterface, title: string, surface?: RenderSurface) {
209
+ const text = `For my engenty wizard "${title}" I need the following changes: `;
210
+ const filled = await $.prompt.fill({ text, mode: "replace" });
211
+ if (filled.isFilled) {
212
+ await say($, null);
213
+ return;
214
+ }
215
+ const copied = await $.ui.copy({ text, ...(surface ? { surface } : {}) });
216
+ const why =
217
+ filled.refusal === "dialog" ? "a dialog holds the keys" : "this surface has no prompt box";
218
+ await say(
219
+ $,
220
+ copied.isCopied
221
+ ? `The chat box did not take the text (${why}). It is on your clipboard: paste it into the chat.`
222
+ : `The chat box did not take the text (${why}), and the clipboard is not reachable either.`,
223
+ );
224
+ }
225
+
226
+ function openPane($: EngineInterface, focus?: true) {
227
+ return $.ui.open({ id: PANE, title: "engenty.wizards", ...(focus ? { focus } : {}) });
228
+ }
229
+
230
+ export const register: Register = (on, options) => {
231
+ const at: Servers = {
232
+ server:
233
+ typeof options.server === "string" && options.server ? options.server : "engenty-wizards",
234
+ browser:
235
+ typeof options.browser === "string" && options.browser ? options.browser : "Claude_Browser",
236
+ };
237
+ let prefixes = prefixesOf(at.server);
238
+
239
+ on("session.start", async ($, e, next) => {
240
+ // The plugin's own server (plugin/.mcp.json) answers under the name the engine gave it;
241
+ // a server configured elsewhere under the same name keeps it.
242
+ const own = await $.mcp.connect(at.server);
243
+ if (own.isConnected) {
244
+ at.server = own.server;
245
+ prefixes = prefixesOf(own.server);
246
+ }
247
+ await $.command.register({
248
+ name: "wizards",
249
+ description: "The engenty.wizards list in a pane; each runs beside the chat",
250
+ argumentHint: "[run <wizard> | reload | close]",
251
+ });
252
+ await say($, null);
253
+ // The list is a sidebar: it opens by itself where someone can see it.
254
+ if (e.isInteractive) await openPane($);
255
+ if ((await read($, wizards)).length === 0) await loadWizards($, at.server);
256
+ return next(e);
257
+ });
258
+
259
+ on("command.run", { command: "wizards" }, async ($, e) => {
260
+ const [verb = "", ...rest] = e.args.trim().split(/\s+/).filter(Boolean);
261
+ if (verb === "close") {
262
+ await $.ui.close({ id: PANE });
263
+ return { text: "Wizards pane closed." };
264
+ }
265
+ const opened = await openPane($, true);
266
+ const where = opened.isPlaced ? "" : ` It waits undrawn: ${opened.reason}`;
267
+ if (verb === "run" && rest.length) {
268
+ if (!(await loadWizards($, at.server))) return { text: `Wizards: ${await read($, message)}` };
269
+ const want = rest.join(" ").toLowerCase();
270
+ const list = await read($, wizards);
271
+ const found =
272
+ list.find((w) => w.id === want) ??
273
+ list.find((w) => w.title.toLowerCase() === want) ??
274
+ list.find((w) => w.title.toLowerCase().includes(want));
275
+ if (!found) return { text: `No wizard "${rest.join(" ")}".` };
276
+ const ran = await runWizard($, at, found);
277
+ return {
278
+ text: ran
279
+ ? `"${found.title}" is open beside the chat.${where}`
280
+ : `Wizards: ${await read($, message)}`,
281
+ };
282
+ }
283
+ if (verb === "reload" || (await read($, wizards)).length === 0) await loadWizards($, at.server);
284
+ return { text: `Wizards pane opened.${where}` };
285
+ });
286
+
287
+ // A run the model drives through the runtime's MCP tools opens beside the chat once it
288
+ // waits for the person, one time per run.
289
+ on("tool.call", async ($, e, next) => {
290
+ const ran = await next(e);
291
+ const prefix = prefixes.find((p) => e.tool.startsWith(p));
292
+ if (!prefix || ran.deny !== undefined || ran.result === undefined) return ran;
293
+ if (!RUN_TOOLS.has(e.tool.slice(prefix.length))) return ran;
294
+ const text = textOf(ran.result);
295
+ if (text === undefined) return ran;
296
+ const report = parse(text);
297
+ if (!isReport(report) || isOver(report) || !report.waitingFor) return ran;
298
+ if ((await read($, shown)) === report.runId) return ran;
299
+ const origin = originOf(report.browserUrl);
300
+ if (origin) await update($, runtime, () => origin);
301
+ await showRun($, at.browser, report);
302
+ return ran;
303
+ }).catch((_, e, next) => next(e));
304
+
305
+ on("ui.render", { component: "Pane", requestId: PANE }, async ($, e) => {
306
+ const table = $.ui.resolve(e);
307
+ const { Box, Text, Button, Link } = table;
308
+ const Svg = "Svg" in table ? table.Svg : undefined;
309
+ const width = e.props.bodyColumns;
310
+ const [list, known, note, origin, link] = await Promise.all([
311
+ read($, wizards),
312
+ read($, details),
313
+ read($, message),
314
+ read($, runtime),
315
+ read($, fallback),
316
+ ]);
317
+
318
+ /** The engenty of a wizard, as the studio draws it; a glyph where no surface draws SVG. */
319
+ const mascot = (kind: string | undefined, size: number) =>
320
+ Svg ? (
321
+ <Svg source={engentySvg(kind, size)} alt="engenty" width={size} height={size} />
322
+ ) : (
323
+ <Text color={engentyColor(kind)}>◉</Text>
324
+ );
325
+
326
+ /** One wizard: its engenty, name and description; Run opens its page, Edit asks the chat. */
327
+ const row = (w: WizardRow, i: number) => {
328
+ const about = known[w.id];
329
+ const title = about?.title ?? w.title;
330
+ return (
331
+ <Box key={`w:${w.id}`} gap={1} alignItems="center">
332
+ {mascot(about?.avatar, 36)}
333
+ <Box flexDirection="column" flexGrow={1}>
334
+ <Text bold={w.published} dimColor={!w.published}>
335
+ {title}
336
+ {w.published ? "" : " · draft"}
337
+ </Text>
338
+ {about?.description && (
339
+ <Text dimColor wrap="truncate">
340
+ {about.description}
341
+ </Text>
342
+ )}
343
+ </Box>
344
+ {w.published && (
345
+ <Button
346
+ key={`run:${w.id}`}
347
+ variant="primary"
348
+ {...(i < 9 ? { hotkey: String(i + 1) } : {})}
349
+ onPress={() => runWizard($, at, w)}
350
+ >
351
+ Run
352
+ </Button>
353
+ )}
354
+ <Button
355
+ key={`edit:${w.id}`}
356
+ plain
357
+ dimColor
358
+ onPress={(press) => askForChanges($, title, press.surface)}
359
+ >
360
+ Edit
361
+ </Button>
362
+ </Box>
363
+ );
364
+ };
365
+
366
+ return (
367
+ <Box flexDirection="column" width={width} gap={1}>
368
+ {note && <Text color="error">{note}</Text>}
369
+ {link && <Link href={link} label="Open it in your browser instead" />}
370
+ {list.length === 0 ? (
371
+ <Text dimColor>No wizards yet. Press Reload, or start the wizards runtime first.</Text>
372
+ ) : (
373
+ <Box flexDirection="column" gap={1}>
374
+ {list.map(row)}
375
+ </Box>
376
+ )}
377
+ <Box gap={1} alignItems="center">
378
+ {origin && <Text dimColor>{origin.replace(/^https?:\/\//, "")}</Text>}
379
+ {origin && (
380
+ <Button
381
+ plain
382
+ dimColor
383
+ hotkey="o"
384
+ onPress={() => show($, at.browser, `${origin}/studio`)}
385
+ >
386
+ Studio
387
+ </Button>
388
+ )}
389
+ <Button plain dimColor hotkey="l" onPress={() => loadWizards($, at.server)}>
390
+ Reload
391
+ </Button>
392
+ </Box>
393
+ </Box>
394
+ );
395
+ });
396
+ };
@@ -0,0 +1,44 @@
1
+ export type WizardRow = {
2
+ id: string;
3
+ title: string;
4
+ published: boolean;
5
+ studioUrl?: string;
6
+ };
7
+
8
+ /** What the pane keeps of a wizard: its name, its engenty, its steps, its own page. */
9
+ export type WizardDetails = {
10
+ title: string;
11
+ description?: string;
12
+ avatar?: string;
13
+ steps: { id: string; type: string; title: string }[];
14
+ /** The wizard's page behind its share link, where a person runs it. */
15
+ shareUrl?: string;
16
+ };
17
+
18
+ /** The run report the runtime's MCP tools answer (runReport in apps/runtime/src/services/runs.ts). */
19
+ export type RunView = {
20
+ runId: string;
21
+ wizardId: string;
22
+ mode: string;
23
+ status: string;
24
+ waitingFor?: unknown;
25
+ browserUrl: string | null;
26
+ studioUrl?: string;
27
+ };
28
+
29
+ declare module "claude-code" {
30
+ interface PluginState {
31
+ wizards: {
32
+ wizards: WizardRow[];
33
+ /** Kept under a shape tag: a newer module reading another tag starts afresh. */
34
+ details: { shape: string; value: Record<string, WizardDetails> };
35
+ message: string | null;
36
+ /** The run whose page the browser pane was opened at, so a polled run opens once. */
37
+ shown: string | null;
38
+ /** The runtime's origin, read off its links: where the pane is connected. */
39
+ runtime: string | null;
40
+ /** A page the browser pane refused to open, offered as a plain link instead. */
41
+ fallback: string | null;
42
+ };
43
+ }
44
+ }
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Ft as i,It as a,Kt as o,Nt as s,Pt as c,Vn as l,Vt as u,Wt as d,_r as f,dr as p}from"./ui-DQ4L2npj.js";import{t as m}from"./preload-helper-CNEI7N0N.js";import{Nt as h,nt as g,rt as _,tt as v}from"./index-DlDsr9Lc.js";import{c as y,f as b}from"./settings-menu-DXzZCIMx.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-QHYP0jAv.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:r,description:i}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,O.jsx)(p,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:r(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[i,o]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return m(()=>import(`./oss-credits-X2JPiMOR.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||o(``)},[e]);let s=i.trim().toLowerCase(),l=e=>s?e.filter(e=>k(s,e.name,e.license,r(e.description))):e,d=e=>s?e.filter(e=>k(s,e.name,e.license,e.version)):e,f=l(E),p=l(D),h=t?[{id:`shared`,label:r(`about.creditsShared`),packages:d(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:d(e.packages)}))].filter(e=>e.packages.length>0):[],g=f.length===0&&p.length===0&&h.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:r(`about.creditsHint`)}),(0,O.jsx)(a,{type:`search`,value:i,placeholder:r(`about.search`),onChange:e=>o(e.target.value)}),f.length>0?(0,O.jsx)(j,{title:r(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:f})}):null,p.length>0?(0,O.jsx)(j,{title:r(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:p})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(u,{})}):h.length>0?(0,O.jsx)(j,{title:r(`about.creditsDeps`),hint:s?void 0:r(`about.creditsDepsHint`),children:h.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(c,{children:r(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>r(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?r(`about.change`):r(`about.changes`,{n:e});function R({open:e,onClose:t,me:n}){let a=n?.mode===`local`,{data:c,latest:p}=_(a&&e),[m,E]=(0,T.useState)(null),[D,k]=(0,T.useState)(`new`),A=b(F.indexOf(D)),j=c?.newer&&p?p:g;(0,T.useEffect)(()=>{if(!e)return;let t=!1;return E(null),S(j===`0.7.8`?void 0:j).then(e=>{t||E(e)}),()=>{t=!0}},[e,j]);let M=m?.find(e=>e.version===`v${j}`)??m?.[0]??null,N=m?.filter(e=>e!==M)??[],R=a?c?.kind??null:`cloud`;return(0,O.jsxs)(s,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(i,{label:r(`common.close`),onClick:t,children:(0,O.jsx)(l,{className:`size-4`})})}),(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(h,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[r(`about.version`,{v:g}),R?` · ${r(`about.kind.${R}`)}`:``]})]}),a?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(v,{enabled:e})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(d,{value:D,onChange:k,options:F.map(e=>({id:e,label:I(e)})),label:r(`about.title`)})}),(0,O.jsxs)(`div`,{className:o(`mt-5`,y(A)),children:[D===`new`?m===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(u,{})}):M?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(M),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(M)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:M})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:r(`about.changelogEmpty`)}):null,D===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:N.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(f,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,D===`credits`?(0,O.jsx)(P,{active:!0}):null]},D)]})}export{R as AboutDialog};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,It as i,Kt as a,Nt as o,Pt as s,Vt as c}from"./ui-DQ4L2npj.js";import{t as l}from"./preload-helper-CNEI7N0N.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):r(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/engenty-wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await l(async()=>{let{default:e}=await import(`./changelog-CO9vKjV0.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:a(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:r(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[a,l]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||a)return;let t=!1;return _(n).then(e=>{t||l(e)}),()=>{t=!0}},[e,a,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=a?g(a,f):[];return(0,d.jsxs)(o,{open:e,onClose:t,title:r(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:r(`about.changelogHint`)}),a===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(c,{})}):a.length===0?(0,d.jsx)(s,{children:r(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(i,{type:`search`,value:f,placeholder:r(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(s,{children:r(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};