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.
- package/README.md +11 -3
- package/dist/cli.d.ts +0 -20
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +40 -88
- package/dist/cli.js.map +1 -1
- package/dist/guide.d.ts +45 -0
- package/dist/guide.d.ts.map +1 -0
- package/dist/guide.js +133 -0
- package/dist/guide.js.map +1 -0
- package/dist/host.js +1 -1
- package/dist/host.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/needs.d.ts +3 -1
- package/dist/needs.d.ts.map +1 -1
- package/dist/needs.js +20 -17
- package/dist/needs.js.map +1 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +19 -24
- package/dist/sdk.js.map +1 -1
- package/dist/stream.d.ts +6 -2
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +23 -16
- package/dist/stream.js.map +1 -1
- package/package.json +1 -1
- package/src/cli.test.ts +23 -150
- package/src/cli.ts +51 -135
- package/src/guide.test.ts +246 -0
- package/src/guide.ts +177 -0
- package/src/host.ts +1 -1
- package/src/index.ts +2 -0
- package/src/needs.test.ts +4 -5
- package/src/needs.ts +38 -23
- package/src/sdk.test.ts +8 -14
- package/src/sdk.ts +21 -31
- package/src/stream.test.ts +8 -5
- package/src/stream.ts +32 -26
- package/src/tests/guide-fixture.ts +39 -0
- package/src/tests/setup.ts +15 -0
|
@@ -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
|
+
});
|