Skip to content
Myr

install-channels.test.ts

This file

Path

packages/agent-kit/test/install-channels.test.ts

134 lines · 4.1 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 1–134why, one step back
1import { describe, expect, it } from "@effect/vitest";
2import { Brand } from "@repo/brand";3import { Array as Arr, Option } from "effect";45import { agentSetup } from "../src/agent-setup.ts";6import type { CommandDoc } from "../src/command-doc.ts";7import { installChannels } from "../src/install-channels.ts";8import type { InstallChannel } from "../src/install-channels.ts";9import { commands as someCommands } from "./fixtures.ts";1011const platformUrl = "https://platform-test.example.workers.dev";1213const webUrl = "https://web-test.example.workers.dev";1415const local = (path: string, summary: string): CommandDoc => ({16 flags: [],17 needsApproval: false,18 path: [path],19 positional: [],20 readOnly: false,21 source: "local",22 summary,23});2425const commands: readonly CommandDoc[] = [26 ...someCommands,27 local("login", "Sign in to a platform."),28 local("mcp", "Serve the platform's tools over MCP on stdio."),29];3031const channels = installChannels({ commands, platformUrl, webUrl });3233const channel = (id: string, from: readonly InstallChannel[] = channels) =>34 Option.getOrThrow(Arr.findFirst(from, (each) => each.id === id));3536const textsOf = ({ snippets }: InstallChannel) =>37 snippets.map(({ text }) => text);3839describe("the Install page's channels", () => {40 it("are every way in, in order, each saying what it is for", () => {41 expect(channels.map(({ id }) => id)).toStrictEqual([42 "cli",43 "mcp",44 "skills",45 "text",46 "git",47 "web",48 "pi",49 ]);5051 for (const each of channels) {52 expect([each.id, each.title, each.audience, each.summary]).not.toContain(53 ""54 );55 }56 });5758 it("install the CLI by script or from npm, then sign in to the platform", () => {59 expect(textsOf(channel("cli"))).toStrictEqual([60 `curl -fsSL ${webUrl}/install.sh | sh`,61 `npm install -g ${Brand.cliPackage}`,62 `${Brand.cli} login --url ${platformUrl}`,63 ]);64 });6566 it("give MCP one tab per client and stdio, with the snippets agentSetup gives", () => {67 const mcp = channel("mcp");6869 const setup = agentSetup({ commands, platformUrl, webUrl }).filter(70 ({ title }) => title === "Remote MCP" || title === "MCP over stdio"71 );7273 expect(mcp.tabbed).toBeTruthy();74 expect(mcp.snippets.map(({ name }) => name)).toStrictEqual([75 "Claude Code",76 "Cursor",77 "VS Code",78 "stdio",79 ]);80 expect(textsOf(mcp)).toStrictEqual(81 setup.flatMap(({ snippets }) => snippets.map(({ text }) => text))82 );83 });8485 it("leave out stdio when the CLI has no mcp command", () => {86 const without = installChannels({87 commands: commands.filter(({ path }) => path.join(" ") !== "mcp"),88 platformUrl,89 webUrl,90 });9192 expect(93 channel("mcp", without).snippets.map(({ name }) => name)94 ).toStrictEqual(["Claude Code", "Cursor", "VS Code"]);95 });9697 it("point any agent at llms.txt, llms-full.txt and Markdown by Accept", () => {98 const text = channel("text");99100 expect(text.links.map(({ path }) => path)).toStrictEqual(101 expect.arrayContaining(["/llms.txt", "/llms-full.txt"])102 );103 expect(textsOf(text)).toContain(104 `curl -H 'Accept: text/markdown' ${webUrl}/<owner>/<name>`105 );106 expect(textsOf(channel("skills"))).toStrictEqual([107 `npx skills add ${webUrl}`,108 ]);109 });110111 it("run git over HTTPS with the CLI as its credential helper, never SSH", () => {112 const git = channel("git");113114 expect(textsOf(git)).toStrictEqual([115 `git clone ${platformUrl}/<owner>/<name>.git`,116 ]);117 expect(git.summary).toContain("HTTPS");118 expect(git.summary).toContain("credential helper");119 expect(120 channels.flatMap(textsOf).filter((each) => /ssh:|git@|ssh-/iu.test(each))121 ).toStrictEqual([]);122 });123124 it("show the web and the pi extension with no command, the extension as planned", () => {125 const pi = channel("pi");126127 expect(128 channels.filter(({ planned }) => planned).map(({ id }) => id)129 ).toStrictEqual(["pi"]);130 expect([pi.snippets, channel("web").snippets]).toStrictEqual([[], []]);131 expect(pi.summary).toContain("MCP");132 expect(pi.summary).toContain("skills");133 });134});