setup-agent 0.1.2 → 0.2.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.
@@ -0,0 +1,39 @@
1
+ import { GUIDE_PROTOCOL, GUIDE_TEXT_KEYS } from "../guide";
2
+ import type { Guide, GuideTextKey } from "../guide";
3
+
4
+ const PLACEHOLDERS: Partial<Record<GuideTextKey, string[]>> = {
5
+ briefing: ["cmd", "url", "icons"],
6
+ "stream.briefing": ["name", "cmd", "url", "browserUrl"],
7
+ "stream.briefing-footer": ["browserUrl"],
8
+ "stream.opened.input": ["prompt", "url", "wait"],
9
+ "stream.opened.plan": ["url", "wait"],
10
+ "stream.opened.finish": ["url"],
11
+ "stream.ask.recently-opened": ["agoSeconds", "wait", "question"],
12
+ "stream.ask.browser-closed": ["question"],
13
+ "stream.ask.no-browser": ["page", "question"],
14
+ "need.finish.question-preview": ["preview"],
15
+ "need.product.add": ["product"],
16
+ };
17
+
18
+ /**
19
+ * A guide whose every text is its key followed by its placeholders, such as
20
+ * `[stream.ask.no-browser] {{page}} {{question}}`, so tests see what the CLI
21
+ * filled in without depending on the server's wording.
22
+ */
23
+ export const testGuide: Guide = {
24
+ protocol: GUIDE_PROTOCOL,
25
+ texts: Object.fromEntries(
26
+ GUIDE_TEXT_KEYS.map((key) => [
27
+ key,
28
+ [`[${key}]`, ...(PLACEHOLDERS[key] ?? []).map((p) => `{{${p}}}`)].join(
29
+ " ",
30
+ ),
31
+ ]),
32
+ ) as Record<GuideTextKey, string>,
33
+ intro: [
34
+ { action: "announce-agent" },
35
+ { action: "print", text: "briefing" },
36
+ { action: "print", text: "intro.status-heading" },
37
+ { action: "print-status" },
38
+ ],
39
+ };
@@ -0,0 +1,15 @@
1
+ import { beforeEach, vi } from "vitest";
2
+ import { testGuide } from "./guide-fixture";
3
+
4
+ // Commands fetch their guide from the setup server; tests serve the fixture
5
+ // unless they stub fetch themselves.
6
+ beforeEach(() => {
7
+ vi.stubGlobal(
8
+ "fetch",
9
+ vi.fn(async (url: string) =>
10
+ /\/guide\?/.test(String(url))
11
+ ? Response.json(testGuide)
12
+ : new Response("not stubbed", { status: 500 }),
13
+ ),
14
+ );
15
+ });