Files
coucou/windows/tests/agents.test.mjs
Claude 5461634c49 Windows and Linux: approve Antigravity commands from the island
Port of the Mac's "Approve commands from the notch" (#934). Antigravity has
no permission request: it runs PreToolUse before its own permission check and
waits for the hook's decision. With Settings → Agents → Antigravity →
Approve commands from the notch (off by default, shown once the hooks are
installed), a run_command that none of Antigravity's command(...) rules
covers waits on the island's card: Allow prints {"decision":"allow"}, Deny
{"decision":"deny","reason":"Denied from Coucou"}, and Reply in terminal, no
click, a full card or Coucou closed print {"decision":"ask"}. Coucou never
allows a command without a click.

- agy_rules.rs: AgyPermissionRules.swift in Rust (CLI settings, global
  grants, the session's project or "outside of project"), with the Swift
  tests plus Windows folder URIs and paths.
- agy_approvals.rs: the gate (setting, run_command, hooks.json timeout >=
  120 s, rules verdict unknown, wait min(timeout - 10, 110) s) and the
  setting's commands, owned by Rust like the phone switches.
- Relay: Antigravity's PreToolUse is tagged coucou_kind agy_pre_tool and
  reads one line: "ask" at once, or "pending" then allow / deny / ask. 3 s
  for the first line, 115 s once pending. A command longer than what the
  relay forwards is flagged and gets no card.
- App (pipe.rs): the event goes to the island as usual, then the card as a
  PermissionRequest; "pending" once the island acks it.
- PreToolUse hook installed with a 120 s timeout; Settings shows the Mac's
  "install again" hint for hooks written with 10 s.
- Card: Deny, Allow and Reply in terminal for Antigravity only. Mac strings
  reused (all already in strings.json), no extra.json entries needed.
- CHANGELOG, windows/README.md, docs/AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LJm3SRL9k3gBPaVtfPhwcT
2026-11-06 13:13:25 +01:00

48 lines
2.1 KiB
JavaScript

// Agents other than Claude Code (src/island/agents.ts): the pill names and
// colours of PillCatalog.swift, and who may get an approval card.
import { test } from "node:test";
import assert from "node:assert/strict";
import {
AGY_CARD_KIND, APPROVAL_AGENTS, KNOWN_AGENTS, agentColor, agentName, takesCard, validateAgent,
} from "../src/island/agents.ts";
test("known agents carry the Mac's names and colours", () => {
assert.equal(agentName("gemini"), "Gemini CLI");
assert.equal(agentColor("gemini"), "#8AB4F8");
assert.equal(agentName("copilot"), "Copilot CLI");
assert.equal(agentColor("codex"), "#2DD4BF");
assert.equal(agentColor("cursor"), "#C0C4CC");
for (const [id, { color }] of Object.entries(KNOWN_AGENTS)) {
assert.equal(validateAgent(id), id, id);
assert.match(color, /^#[0-9A-F]{6}$/, id);
}
});
test("an unknown agent keeps its id and gets a stable colour", () => {
assert.equal(agentName("my-tool"), "my-tool");
assert.equal(agentColor("my-tool"), agentColor("my-tool"));
assert.match(agentColor("my-tool"), /^#[0-9A-F]{6}$/);
});
test("the agent tag is checked the Mac's way, and claude is reserved", () => {
for (const bad of ["claude", "Gemini", "has space", "a".repeat(25), "", undefined, "x_y"]) {
assert.equal(validateAgent(bad), null, String(bad));
}
assert.equal(validateAgent("a".repeat(24)), "a".repeat(24));
});
test("approval cards are for the agents the relay answers, no one else", () => {
// Must match takes_decisions() in hook/src/reply.rs.
assert.deepEqual([...APPROVAL_AGENTS].sort(), ["claude-desktop", "codex", "copilot", "muse", "opencode"]);
});
test("Antigravity gets a card only for the commands Coucou itself puts on one", () => {
assert.equal(AGY_CARD_KIND, "agy_pre_tool"); // agy_approvals::KIND in Rust
assert.equal(takesCard(null, undefined), true); // Claude Code
assert.equal(takesCard("codex", undefined), true);
assert.equal(takesCard("antigravity", "agy_pre_tool"), true);
assert.equal(takesCard("antigravity", undefined), false);
assert.equal(takesCard("gemini", "agy_pre_tool"), false);
});