@cmetech/otto 1.0.9 → 1.1.1

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.
Files changed (68) hide show
  1. package/dist/resources/.managed-resources-content-hash +1 -1
  2. package/dist/resources/extensions/otto/commands/release-notes/_data.js +27 -0
  3. package/dist/resources/extensions/otto/commands/theme/command.js +75 -0
  4. package/dist/resources/extensions/otto/index.js +3 -0
  5. package/dist/resources/extensions/subagent/agents.js +160 -8
  6. package/dist/resources/extensions/subagent/index.js +45 -4
  7. package/dist/resources/extensions/subagent/skill-tool-stub.js +23 -0
  8. package/dist/seed-defaults.d.ts +16 -0
  9. package/dist/seed-defaults.js +69 -1
  10. package/dist/update-cmd.d.ts +19 -0
  11. package/dist/update-cmd.js +177 -6
  12. package/package.json +6 -6
  13. package/packages/contracts/package.json +1 -1
  14. package/packages/daemon/package.json +3 -3
  15. package/packages/mcp-server/package.json +3 -3
  16. package/packages/native/package.json +1 -1
  17. package/packages/pi-agent-core/package.json +1 -1
  18. package/packages/pi-ai/package.json +1 -1
  19. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +3 -0
  20. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  21. package/packages/pi-coding-agent/dist/core/settings-manager.js +6 -0
  22. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  23. package/packages/pi-coding-agent/dist/core/skills.d.ts +11 -0
  24. package/packages/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  25. package/packages/pi-coding-agent/dist/core/skills.js +22 -0
  26. package/packages/pi-coding-agent/dist/core/skills.js.map +1 -1
  27. package/packages/pi-coding-agent/dist/index.d.ts +1 -1
  28. package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
  29. package/packages/pi-coding-agent/dist/index.js +1 -1
  30. package/packages/pi-coding-agent/dist/index.js.map +1 -1
  31. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  32. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +13 -2
  33. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  34. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  35. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js +4 -0
  36. package/packages/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  37. package/packages/pi-coding-agent/package.json +2 -2
  38. package/packages/pi-coding-agent/src/core/settings-manager.ts +9 -0
  39. package/packages/pi-coding-agent/src/core/skills.ts +23 -1
  40. package/packages/pi-coding-agent/src/index.ts +4 -0
  41. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +13 -2
  42. package/packages/pi-coding-agent/src/modes/interactive/theme/theme.ts +4 -0
  43. package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -1
  44. package/packages/pi-tui/dist/autocomplete.d.ts +9 -0
  45. package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -1
  46. package/packages/pi-tui/dist/autocomplete.js +2 -0
  47. package/packages/pi-tui/dist/autocomplete.js.map +1 -1
  48. package/packages/pi-tui/dist/components/select-list.d.ts +10 -0
  49. package/packages/pi-tui/dist/components/select-list.d.ts.map +1 -1
  50. package/packages/pi-tui/dist/components/select-list.js +30 -17
  51. package/packages/pi-tui/dist/components/select-list.js.map +1 -1
  52. package/packages/pi-tui/package.json +1 -1
  53. package/packages/pi-tui/src/autocomplete.ts +11 -0
  54. package/packages/pi-tui/src/components/select-list.ts +41 -17
  55. package/packages/pi-tui/tsconfig.tsbuildinfo +1 -1
  56. package/packages/rpc-client/package.json +2 -2
  57. package/pkg/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  58. package/pkg/dist/modes/interactive/theme/theme.js +4 -0
  59. package/pkg/dist/modes/interactive/theme/theme.js.map +1 -1
  60. package/pkg/package.json +1 -1
  61. package/src/resources/extensions/otto/commands/release-notes/_data.ts +27 -0
  62. package/src/resources/extensions/otto/commands/theme/command.ts +89 -0
  63. package/src/resources/extensions/otto/index.ts +4 -0
  64. package/src/resources/extensions/subagent/agents.ts +166 -8
  65. package/src/resources/extensions/subagent/index.ts +46 -6
  66. package/src/resources/extensions/subagent/skill-tool-stub.ts +28 -0
  67. package/src/resources/extensions/subagent/tests/parse-agent-tools.test.ts +52 -0
  68. package/src/resources/extensions/subagent/tests/skill-tool-stub.test.ts +23 -0
@@ -3,11 +3,53 @@
3
3
  */
4
4
 
5
5
  import * as fs from "node:fs";
6
+ import { homedir } from "node:os";
6
7
  import * as path from "node:path";
7
8
  import { getAgentDir, parseFrontmatter } from "@otto/pi-coding-agent";
8
9
 
9
10
  const PROJECT_AGENT_DIR_CANDIDATES = [".otto/workflow", ".pi"] as const;
10
11
 
12
+ /**
13
+ * Conventional agent folders used by other AI coding harnesses, mirroring the
14
+ * harness skill-paths support in pi-coding-agent's skills.ts. Each entry maps
15
+ * a harness id (used as a discriminator in logs and the agent's `source`
16
+ * label) to its user-scope and project-scope conventional paths.
17
+ *
18
+ * When a Claude-style skill delegates to a subagent (`subagent_type: foo` /
19
+ * `Task` tool call), OTTO's subagent tool resolves `foo` against everything
20
+ * `discoverAgents` returns. Including these harness paths is what lets a
21
+ * skill imported from `~/.claude/skills` find its companion agent in
22
+ * `~/.claude/agents` rather than failing with "unknown agent."
23
+ *
24
+ * Caveats — independent of discovery — that may affect runtime success:
25
+ * - Claude agents commonly declare `tools: [Bash, Read, ...]` (capitalized).
26
+ * OTTO's tool names tend to be lowercase. If an agent's allowlist is
27
+ * enforced strictly by the harness it was written for, capitalized
28
+ * entries won't match OTTO's tool registry. Agents without a `tools`
29
+ * field (no restriction) work without issue.
30
+ * - Agent body prompts may reference harness-specific features
31
+ * (Claude's `/compact`, MCP server names hardcoded for `claude_desktop`,
32
+ * `~/.claude/...` paths). The agent still runs; those references may
33
+ * just be ineffective.
34
+ */
35
+ const HARNESS_AGENT_PATHS: Record<
36
+ string,
37
+ { userDir: string; projectSubdir: string }
38
+ > = {
39
+ claude: {
40
+ userDir: path.join(homedir(), ".claude", "agents"),
41
+ projectSubdir: path.join(".claude", "agents"),
42
+ },
43
+ codex: {
44
+ userDir: path.join(homedir(), ".codex", "agents"),
45
+ projectSubdir: path.join(".codex", "agents"),
46
+ },
47
+ kiro: {
48
+ userDir: path.join(homedir(), ".kiro", "agents"),
49
+ projectSubdir: path.join(".kiro", "agents"),
50
+ },
51
+ };
52
+
11
53
  export type AgentScope = "user" | "project" | "both";
12
54
 
13
55
  export interface AgentConfig {
@@ -19,6 +61,9 @@ export interface AgentConfig {
19
61
  systemPrompt: string;
20
62
  source: "user" | "project";
21
63
  filePath: string;
64
+ /** Harness id (e.g. "claude", "codex", "kiro") when discovered under a known
65
+ * harness agent folder. Surfaced as a glanceable chip in `/subagent`. */
66
+ harnessSource?: string;
22
67
  }
23
68
 
24
69
  export interface AgentDiscoveryResult {
@@ -40,27 +85,72 @@ export function parseConflictsWith(value: string | undefined): string[] | undefi
40
85
  return conflicts.length > 0 ? conflicts : undefined;
41
86
  }
42
87
 
43
- function parseAgentTools(value: string | string[] | undefined): string[] | undefined {
88
+ /**
89
+ * Maps capitalized tool names used by other AI coding harnesses (Claude, Codex,
90
+ * Kiro) to OTTO's lowercase tool-registry names. Applied at agent-load time so
91
+ * an agent imported from ~/.claude/agents/ with `tools: [Bash, Read]` ends up
92
+ * with `tools: ["bash", "read"]` and actually has access to those tools.
93
+ *
94
+ * Tools without an explicit mapping fall through to .toLowerCase() — that's
95
+ * enough for any name that's already aligned with OTTO's case-insensitive
96
+ * convention. Tool names with no OTTO equivalent (TodoWrite, SlashCommand,
97
+ * NotebookEdit) are kept (lowercased) and silently ignored by the runtime
98
+ * allowlist check — so they don't block the rest of the agent's toolset.
99
+ *
100
+ * MCP tool patterns (mcp__server__name, mcp__server__*) are preserved
101
+ * verbatim — they're already case-sensitive identifiers, and MCP servers
102
+ * register their own tools at runtime.
103
+ */
104
+ const HARNESS_TOOL_NAME_MAP: Record<string, string> = {
105
+ Bash: "bash",
106
+ Read: "read",
107
+ Write: "write",
108
+ Edit: "edit",
109
+ Glob: "glob",
110
+ Grep: "grep",
111
+ AskUserQuestion: "ask_user_questions",
112
+ Agent: "subagent",
113
+ Task: "subagent",
114
+ WebSearch: "web_search",
115
+ WebFetch: "fetch_page",
116
+ Skill: "skill",
117
+ };
118
+
119
+ function normalizeHarnessToolName(raw: string): string | null {
120
+ const trimmed = raw.trim();
121
+ if (!trimmed) return null;
122
+ if (trimmed.startsWith("mcp__")) return trimmed;
123
+ if (HARNESS_TOOL_NAME_MAP[trimmed]) return HARNESS_TOOL_NAME_MAP[trimmed];
124
+ return trimmed.toLowerCase();
125
+ }
126
+
127
+ export function parseAgentTools(value: string | string[] | undefined): string[] | undefined {
44
128
  if (typeof value === "string") {
45
129
  const tools = value
46
130
  .split(",")
47
- .map((tool) => tool.trim())
48
- .filter(Boolean);
49
- return tools.length > 0 ? tools : undefined;
131
+ .map((tool) => normalizeHarnessToolName(tool))
132
+ .filter((tool): tool is string => Boolean(tool));
133
+ const deduped = Array.from(new Set(tools));
134
+ return deduped.length > 0 ? deduped : undefined;
50
135
  }
51
136
 
52
137
  if (Array.isArray(value)) {
53
138
  const tools = value
54
139
  .flatMap((tool) => typeof tool === "string" ? tool.split(",") : [])
55
- .map((tool) => tool.trim())
56
- .filter(Boolean);
57
- return tools.length > 0 ? tools : undefined;
140
+ .map((tool) => normalizeHarnessToolName(tool))
141
+ .filter((tool): tool is string => Boolean(tool));
142
+ const deduped = Array.from(new Set(tools));
143
+ return deduped.length > 0 ? deduped : undefined;
58
144
  }
59
145
 
60
146
  return undefined;
61
147
  }
62
148
 
63
- function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig[] {
149
+ function loadAgentsFromDir(
150
+ dir: string,
151
+ source: "user" | "project",
152
+ harnessSource?: string,
153
+ ): AgentConfig[] {
64
154
  const agents: AgentConfig[] = [];
65
155
 
66
156
  if (!fs.existsSync(dir)) {
@@ -104,6 +194,7 @@ function loadAgentsFromDir(dir: string, source: "user" | "project"): AgentConfig
104
194
  systemPrompt: body,
105
195
  source,
106
196
  filePath,
197
+ harnessSource,
107
198
  });
108
199
  }
109
200
 
@@ -134,22 +225,89 @@ function findNearestProjectAgentsDir(cwd: string): string | null {
134
225
  }
135
226
  }
136
227
 
228
+ /**
229
+ * Walk up from cwd looking for harness project agent dirs (e.g. `.claude/agents`).
230
+ * Returns ALL matching dirs found at the first ancestor that has at least one,
231
+ * so a project root with both `.claude/agents` and `.codex/agents` surfaces
232
+ * both. Stops at the first ancestor with any matches to avoid pulling in
233
+ * stale agents from outer directories.
234
+ */
235
+ function findNearestHarnessProjectAgentsDirs(cwd: string): string[] {
236
+ let currentDir = cwd;
237
+ while (true) {
238
+ const matches: string[] = [];
239
+ for (const { projectSubdir } of Object.values(HARNESS_AGENT_PATHS)) {
240
+ const candidate = path.join(currentDir, projectSubdir);
241
+ if (isDirectory(candidate)) matches.push(candidate);
242
+ }
243
+ if (matches.length > 0) return matches;
244
+
245
+ const parentDir = path.dirname(currentDir);
246
+ if (parentDir === currentDir) return [];
247
+ currentDir = parentDir;
248
+ }
249
+ }
250
+
137
251
  export function discoverAgents(cwd: string, scope: AgentScope): AgentDiscoveryResult {
138
252
  const userDir = path.join(getAgentDir(), "agents");
139
253
  const projectAgentsDir = findNearestProjectAgentsDir(cwd);
254
+ const harnessProjectAgentsDirs = findNearestHarnessProjectAgentsDirs(cwd);
140
255
 
141
256
  const userAgents = scope === "project" ? [] : loadAgentsFromDir(userDir, "user");
142
257
  const projectAgents = scope === "user" || !projectAgentsDir ? [] : loadAgentsFromDir(projectAgentsDir, "project");
143
258
 
259
+ // Harness agents — user scope: ~/.claude/agents, ~/.codex/agents, ~/.kiro/agents.
260
+ // Harness agents — project scope: nearest .claude/agents etc. up the cwd tree.
261
+ // Both go into the same scope buckets as OTTO's own agents; collisions are
262
+ // resolved by the existing Map-write-wins order below (project wins user).
263
+ const harnessUserAgents: AgentConfig[] = [];
264
+ if (scope !== "project") {
265
+ for (const [harnessId, { userDir: harnessUserDir }] of Object.entries(HARNESS_AGENT_PATHS)) {
266
+ harnessUserAgents.push(...loadAgentsFromDir(harnessUserDir, "user", harnessId));
267
+ }
268
+ }
269
+ const harnessProjectAgents: AgentConfig[] = [];
270
+ if (scope !== "user") {
271
+ // Map each discovered project dir back to its harness id by suffix match
272
+ // (e.g. ".../.claude/agents" → "claude"). The id surfaces in /subagent as
273
+ // a glanceable chip.
274
+ for (const dir of harnessProjectAgentsDirs) {
275
+ let harnessId: string | undefined;
276
+ for (const [id, { projectSubdir }] of Object.entries(HARNESS_AGENT_PATHS)) {
277
+ if (dir.endsWith(projectSubdir)) {
278
+ harnessId = id;
279
+ break;
280
+ }
281
+ }
282
+ harnessProjectAgents.push(...loadAgentsFromDir(dir, "project", harnessId));
283
+ }
284
+ }
285
+
144
286
  const agentMap = new Map<string, AgentConfig>();
145
287
 
288
+ // Order: OTTO user → harness user → OTTO project → harness project.
289
+ // Later writes win on name collision, so OTTO's own agents take precedence
290
+ // at each scope, and project always overrides user. Same precedence as the
291
+ // existing logic, just with harness sources slotted in beneath.
146
292
  if (scope === "both") {
147
293
  for (const agent of userAgents) agentMap.set(agent.name, agent);
294
+ for (const agent of harnessUserAgents) {
295
+ if (!agentMap.has(agent.name)) agentMap.set(agent.name, agent);
296
+ }
148
297
  for (const agent of projectAgents) agentMap.set(agent.name, agent);
298
+ for (const agent of harnessProjectAgents) {
299
+ if (!agentMap.has(agent.name)) agentMap.set(agent.name, agent);
300
+ }
149
301
  } else if (scope === "user") {
150
302
  for (const agent of userAgents) agentMap.set(agent.name, agent);
303
+ for (const agent of harnessUserAgents) {
304
+ if (!agentMap.has(agent.name)) agentMap.set(agent.name, agent);
305
+ }
151
306
  } else {
152
307
  for (const agent of projectAgents) agentMap.set(agent.name, agent);
308
+ for (const agent of harnessProjectAgents) {
309
+ if (!agentMap.has(agent.name)) agentMap.set(agent.name, agent);
310
+ }
153
311
  }
154
312
 
155
313
  return { agents: Array.from(agentMap.values()), projectAgentsDir };
@@ -20,12 +20,13 @@ import * as path from "node:path";
20
20
  import type { AgentToolResult } from "@otto/pi-agent-core";
21
21
  import type { Message } from "@otto/pi-ai";
22
22
  import { StringEnum } from "@otto/pi-ai";
23
- import { type ExtensionAPI, getMarkdownTheme } from "@otto/pi-coding-agent";
23
+ import { type ExtensionAPI, getMarkdownTheme, getSelectListTheme } from "@otto/pi-coding-agent";
24
24
  import { Container, Markdown, Spacer, Text } from "@otto/pi-tui";
25
25
  import { Type } from "@sinclair/typebox";
26
26
  import { formatTokenCount } from "../shared/mod.js";
27
27
  import { getCurrentPhase } from "../shared/phase-state.js";
28
28
  import { type AgentConfig, type AgentScope, discoverAgents } from "./agents.js";
29
+ import { buildSkillToolStubResponse } from "./skill-tool-stub.js";
29
30
  import {
30
31
  type IsolationEnvironment,
31
32
  type IsolationMode,
@@ -798,7 +799,13 @@ export default function (pi: ExtensionAPI) {
798
799
  await stopLiveSubagents();
799
800
  });
800
801
 
801
- // /subagent command - list available agents
802
+ // /subagent command - list available agents.
803
+ // Renders each row with embedded ANSI styling so the message bypasses the
804
+ // notify renderer's "dim everything" fallback (see hasAnsiStyling check in
805
+ // pi-coding-agent's renderExtensionNotifyInChat). Agent name renders in the
806
+ // terminal's default foreground (white-ish), source/model in the muted
807
+ // description tint, and the harness origin — when detected — as an accent
808
+ // chip matching the /skills autocomplete style.
802
809
  pi.registerCommand("subagent", {
803
810
  description: "List available subagents",
804
811
  handler: async (_args, ctx) => {
@@ -807,10 +814,17 @@ export default function (pi: ExtensionAPI) {
807
814
  ctx.ui.notify("No agents found. Add .md files to ~/.otto/agent/agents/ or .otto/workflow/agents/", "warning");
808
815
  return;
809
816
  }
810
- const lines = discovery.agents.map(
811
- (a) => ` ${a.name} [${a.source}]${a.model ? ` (${a.model})` : ""}: ${a.description}`,
812
- );
813
- ctx.ui.notify(`Available agents (${discovery.agents.length}):\n${lines.join("\n")}`, "info");
817
+ const slt = getSelectListTheme();
818
+ const tag = slt.tag ?? slt.selectedText;
819
+ const dim = slt.description;
820
+ const lines = discovery.agents.map((a) => {
821
+ const chip = a.harnessSource ? `${tag(`[${a.harnessSource}]`)} ` : "";
822
+ const meta = dim(`[${a.source}]${a.model ? ` (${a.model})` : ""}`);
823
+ const desc = dim(`: ${a.description}`);
824
+ return ` ${chip}${a.name} ${meta}${desc}`;
825
+ });
826
+ const header = dim(`Available agents (${discovery.agents.length}):`);
827
+ ctx.ui.notify(`${header}\n${lines.join("\n")}`, "info");
814
828
  },
815
829
  });
816
830
 
@@ -1935,4 +1949,30 @@ export default function (pi: ExtensionAPI) {
1935
1949
  return new Text(text?.type === "text" ? text.text : "(no output)", 0, 0);
1936
1950
  },
1937
1951
  });
1952
+
1953
+ pi.registerTool({
1954
+ name: "skill",
1955
+ label: "Skill (stub)",
1956
+ description: [
1957
+ "Stub for the Claude-style `Skill` tool used by some imported skills.",
1958
+ "OTTO does not support invoking skills as a tool — users invoke skills via /skill:<name> from the chat input.",
1959
+ "Returns a clear message redirecting the model to use the skill content inline.",
1960
+ ].join(" "),
1961
+ parameters: Type.Object({
1962
+ name: Type.Optional(Type.String({ description: "Name of the skill the model wanted to invoke." })),
1963
+ }),
1964
+ async execute(_toolCallId, params) {
1965
+ return {
1966
+ content: [
1967
+ {
1968
+ type: "text" as const,
1969
+ text: buildSkillToolStubResponse({
1970
+ name: typeof params.name === "string" ? params.name : undefined,
1971
+ }),
1972
+ },
1973
+ ],
1974
+ details: {},
1975
+ };
1976
+ },
1977
+ });
1938
1978
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Stub for the `skill` tool that Claude-style skills sometimes invoke
3
+ * (`Skill(name="foo")` in the skill body) to chain into another skill.
4
+ *
5
+ * OTTO does not support model-invoked skill execution — skills are user-
6
+ * initiated via `/skill:<name>` from the chat input. Rather than have those
7
+ * tool calls fail with "no such tool," we register a stub that returns a
8
+ * clear, actionable message. The model sees the response and can either
9
+ * fall back to acting on the skill content itself or surface the message
10
+ * to the user.
11
+ *
12
+ * Registered in src/resources/extensions/subagent/index.ts.
13
+ */
14
+
15
+ export interface SkillToolStubInput {
16
+ name?: string;
17
+ }
18
+
19
+ export function buildSkillToolStubResponse(input: SkillToolStubInput): string {
20
+ const skillRef = typeof input.name === "string" && input.name.trim().length > 0
21
+ ? `/skill:${input.name.trim()}`
22
+ : "the desired /skill:<name>";
23
+ return [
24
+ "OTTO does not support invoking skills as a tool from inside an agent turn.",
25
+ `To use this skill, ask the user to run \`${skillRef}\` from the chat input — that's how OTTO surfaces skills.`,
26
+ "If you have access to the skill's body (it was loaded as a system prompt), follow its instructions inline instead.",
27
+ ].join("\n\n");
28
+ }
@@ -0,0 +1,52 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { parseAgentTools } from "../agents.js";
4
+
5
+ describe("parseAgentTools", () => {
6
+ it("lowercases standard Claude tool names", () => {
7
+ const result = parseAgentTools("Bash, Read, Write, Edit, Glob, Grep");
8
+ assert.deepEqual(result, ["bash", "read", "write", "edit", "glob", "grep"]);
9
+ });
10
+
11
+ it("maps Claude-specific tool names to OTTO equivalents (with dedup)", () => {
12
+ const result = parseAgentTools("AskUserQuestion, Agent, Task, WebSearch, WebFetch, Skill");
13
+ assert.deepEqual(result, [
14
+ "ask_user_questions",
15
+ "subagent",
16
+ "web_search",
17
+ "fetch_page",
18
+ "skill",
19
+ ]);
20
+ });
21
+
22
+ it("keeps unknown tools as lowercase (runtime silently drops them)", () => {
23
+ const result = parseAgentTools("Bash, TodoWrite, SlashCommand, NotebookEdit");
24
+ assert.deepEqual(result, ["bash", "todowrite", "slashcommand", "notebookedit"]);
25
+ });
26
+
27
+ it("preserves MCP tool names verbatim (already lowercase, server-scoped)", () => {
28
+ const result = parseAgentTools("Bash, mcp__context7__*, mcp__exa__*");
29
+ assert.deepEqual(result, ["bash", "mcp__context7__*", "mcp__exa__*"]);
30
+ });
31
+
32
+ it("accepts an array as well as a comma-string", () => {
33
+ const result = parseAgentTools(["Bash", "Read", "Glob"]);
34
+ assert.deepEqual(result, ["bash", "read", "glob"]);
35
+ });
36
+
37
+ it("returns undefined for empty input", () => {
38
+ assert.equal(parseAgentTools(undefined), undefined);
39
+ assert.equal(parseAgentTools(""), undefined);
40
+ assert.equal(parseAgentTools([]), undefined);
41
+ });
42
+
43
+ it("trims whitespace and filters blank entries", () => {
44
+ const result = parseAgentTools(" Bash , , Read , ");
45
+ assert.deepEqual(result, ["bash", "read"]);
46
+ });
47
+
48
+ it("dedupes after normalization (Task and Agent both map to subagent)", () => {
49
+ const result = parseAgentTools("Task, Agent, subagent");
50
+ assert.deepEqual(result, ["subagent"]);
51
+ });
52
+ });
@@ -0,0 +1,23 @@
1
+ import { describe, it } from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { buildSkillToolStubResponse } from "../skill-tool-stub.js";
4
+
5
+ describe("skill tool stub", () => {
6
+ it("returns a clear message when called with a skill name", () => {
7
+ const response = buildSkillToolStubResponse({ name: "review-pr" });
8
+ assert.match(response, /\/skill:review-pr/);
9
+ assert.match(response, /chat input/i);
10
+ assert.match(response, /not support/i);
11
+ });
12
+
13
+ it("handles missing name gracefully", () => {
14
+ const response = buildSkillToolStubResponse({});
15
+ assert.match(response, /skill/i);
16
+ assert.match(response, /chat input/i);
17
+ });
18
+
19
+ it("handles a path-like skill name (gsd-*) the same way", () => {
20
+ const response = buildSkillToolStubResponse({ name: "gsd-code-review" });
21
+ assert.match(response, /\/skill:gsd-code-review/);
22
+ });
23
+ });