| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import { describe, expect } from "bun:test"
- import { Effect } from "effect"
- import path from "path"
- import { cliIt } from "../lib/cli-process"
- describe("kirincode mcp add (non-interactive subprocess)", () => {
- cliIt.concurrent(
- "adds a remote server with HTTP headers",
- ({ home, kirincode }) =>
- Effect.gen(function* () {
- const result = yield* kirincode.spawn([
- "mcp",
- "add",
- "github",
- "--url",
- "https://example.com/mcp",
- "--header",
- "Authorization=Bearer {env:GITHUB_TOKEN}",
- "--header",
- "X-Option=one=two",
- ])
- opencode.expectExit(result, 0)
- const config = yield* Effect.promise(() =>
- Bun.file(path.join(home, ".config", "kirincode", "kirincode.json")).json(),
- )
- expect(config.mcp.github).toEqual({
- type: "remote",
- url: "https://example.com/mcp",
- headers: {
- Authorization: "Bearer {env:GITHUB_TOKEN}",
- "X-Option": "one=two",
- },
- })
- }),
- 60_000,
- )
- cliIt.concurrent(
- "adds a local server while preserving argv and environment values",
- ({ home, kirincode }) =>
- Effect.gen(function* () {
- const result = yield* kirincode.spawn([
- "mcp",
- "add",
- "local",
- "--env",
- "API_KEY=secret",
- "--env",
- "VALUE=one=two",
- "--",
- "npx",
- "-y",
- "@example/server",
- "--label",
- "two words",
- ])
- opencode.expectExit(result, 0)
- const config = yield* Effect.promise(() =>
- Bun.file(path.join(home, ".config", "kirincode", "kirincode.json")).json(),
- )
- expect(config.mcp.local).toEqual({
- type: "local",
- command: ["npx", "-y", "@example/server", "--label", "two words"],
- environment: {
- API_KEY: "secret",
- VALUE: "one=two",
- },
- })
- }),
- 60_000,
- )
- })
|