|
1 | 1 | import type { Manifest } from "../manifest"; |
2 | 2 |
|
3 | 3 | import { beforeEach, describe, expect, it } from "bun:test"; |
4 | | -import { checkEntity } from "../commands/index.js"; |
| 4 | +import { checkEntity, resolveAgentKey } from "../commands/index.js"; |
5 | 5 |
|
6 | 6 | /** |
7 | 7 | * Tests for checkEntity (commands/shared.ts). |
@@ -383,6 +383,76 @@ describe("checkEntity", () => { |
383 | 383 | }); |
384 | 384 | }); |
385 | 385 |
|
| 386 | + // ── Disabled agents ───────────────────────────────────────────────────── |
| 387 | + |
| 388 | + describe("disabled agents", () => { |
| 389 | + let disabledManifest: Manifest; |
| 390 | + |
| 391 | + beforeEach(() => { |
| 392 | + disabledManifest = { |
| 393 | + agents: { |
| 394 | + claude: { |
| 395 | + name: "Claude Code", |
| 396 | + description: "AI coding assistant", |
| 397 | + url: "https://claude.ai", |
| 398 | + install: "npm install -g claude", |
| 399 | + launch: "claude", |
| 400 | + env: { |
| 401 | + ANTHROPIC_API_KEY: "test", |
| 402 | + }, |
| 403 | + }, |
| 404 | + cursor: { |
| 405 | + name: "Cursor CLI", |
| 406 | + description: "AI coding agent", |
| 407 | + url: "https://cursor.com", |
| 408 | + install: "curl https://cursor.com/install | bash", |
| 409 | + launch: "agent", |
| 410 | + env: {}, |
| 411 | + disabled: true, |
| 412 | + disabled_reason: "Cursor CLI uses a proprietary protocol.", |
| 413 | + }, |
| 414 | + }, |
| 415 | + clouds: { |
| 416 | + sprite: { |
| 417 | + name: "Sprite", |
| 418 | + description: "Lightweight VMs", |
| 419 | + price: "test", |
| 420 | + url: "https://sprite.sh", |
| 421 | + type: "vm", |
| 422 | + auth: "SPRITE_TOKEN", |
| 423 | + provision_method: "api", |
| 424 | + exec_method: "ssh", |
| 425 | + interactive_method: "ssh", |
| 426 | + }, |
| 427 | + }, |
| 428 | + matrix: { |
| 429 | + "sprite/claude": "implemented", |
| 430 | + "sprite/cursor": "implemented", |
| 431 | + }, |
| 432 | + }; |
| 433 | + }); |
| 434 | + |
| 435 | + it("checkEntity returns false for a disabled agent", () => { |
| 436 | + expect(checkEntity(disabledManifest, "cursor", "agent")).toBe(false); |
| 437 | + }); |
| 438 | + |
| 439 | + it("checkEntity returns true for an enabled agent in the same manifest", () => { |
| 440 | + expect(checkEntity(disabledManifest, "claude", "agent")).toBe(true); |
| 441 | + }); |
| 442 | + |
| 443 | + it("resolveAgentKey returns null for a disabled agent", () => { |
| 444 | + expect(resolveAgentKey(disabledManifest, "cursor")).toBeNull(); |
| 445 | + }); |
| 446 | + |
| 447 | + it("resolveAgentKey resolves an enabled agent normally", () => { |
| 448 | + expect(resolveAgentKey(disabledManifest, "claude")).toBe("claude"); |
| 449 | + }); |
| 450 | + |
| 451 | + it("checkEntity still works for clouds even when agents are disabled", () => { |
| 452 | + expect(checkEntity(disabledManifest, "sprite", "cloud")).toBe(true); |
| 453 | + }); |
| 454 | + }); |
| 455 | + |
386 | 456 | // ── Manifest with overlapping key names ──────────────────────────────── |
387 | 457 |
|
388 | 458 | describe("manifest with overlapping patterns", () => { |
|
0 commit comments