@desplega.ai/agent-swarm 1.51.2 → 1.52.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.
- package/README.md +131 -0
- package/openapi.json +767 -4
- package/package.json +3 -1
- package/src/be/db.ts +669 -0
- package/src/be/migrations/019_skills.sql +65 -0
- package/src/be/migrations/020_approval_requests.sql +41 -0
- package/src/be/migrations/runner.ts +4 -4
- package/src/be/skill-parser.ts +70 -0
- package/src/be/skill-sync.ts +106 -0
- package/src/commands/runner.ts +299 -52
- package/src/http/agents.ts +29 -0
- package/src/http/approval-requests.ts +310 -0
- package/src/http/config.ts +3 -3
- package/src/http/index.ts +26 -2
- package/src/http/poll.ts +15 -0
- package/src/http/skills.ts +479 -0
- package/src/http/tasks.ts +94 -0
- package/src/linear/outbound.ts +12 -12
- package/src/prompts/base-prompt.ts +8 -0
- package/src/providers/claude-adapter.ts +19 -3
- package/src/scheduler/scheduler.ts +24 -1
- package/src/server.ts +29 -0
- package/src/slack/blocks.ts +1 -1
- package/src/tests/approval-requests.test.ts +948 -0
- package/src/tests/skill-parser.test.ts +178 -0
- package/src/tests/skill-sync.test.ts +171 -0
- package/src/tests/slack-blocks.test.ts +3 -2
- package/src/tests/structured-output.test.ts +1 -0
- package/src/tests/tool-annotations.test.ts +2 -1
- package/src/tests/tool-call-progress.test.ts +207 -0
- package/src/tests/tool-registrar-no-input.test.ts +114 -0
- package/src/tests/update-profile-auth.test.ts +1 -0
- package/src/tests/workflow-executors.test.ts +4 -2
- package/src/tools/request-human-input.ts +117 -0
- package/src/tools/skills/index.ts +11 -0
- package/src/tools/skills/skill-create.ts +105 -0
- package/src/tools/skills/skill-delete.ts +67 -0
- package/src/tools/skills/skill-get.ts +75 -0
- package/src/tools/skills/skill-install-remote.ts +152 -0
- package/src/tools/skills/skill-install.ts +101 -0
- package/src/tools/skills/skill-list.ts +77 -0
- package/src/tools/skills/skill-publish.ts +123 -0
- package/src/tools/skills/skill-search.ts +43 -0
- package/src/tools/skills/skill-sync-remote.ts +128 -0
- package/src/tools/skills/skill-uninstall.ts +60 -0
- package/src/tools/skills/skill-update.ts +128 -0
- package/src/tools/store-progress.ts +31 -0
- package/src/tools/templates.ts +28 -0
- package/src/tools/tool-config.ts +16 -0
- package/src/tools/utils.ts +9 -7
- package/src/types.ts +54 -0
- package/src/workflows/executors/human-in-the-loop.ts +273 -0
- package/src/workflows/executors/registry.ts +2 -0
- package/src/workflows/recovery.ts +72 -0
- package/src/workflows/resume.ts +65 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { parseSkillContent } from "../be/skill-parser";
|
|
3
|
+
|
|
4
|
+
// ─── Valid Parsing ──────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
describe("parseSkillContent — valid inputs", () => {
|
|
7
|
+
test("parses minimal frontmatter with body", () => {
|
|
8
|
+
const content = `---
|
|
9
|
+
name: my-skill
|
|
10
|
+
description: A test skill
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
This is the body.`;
|
|
14
|
+
|
|
15
|
+
const result = parseSkillContent(content);
|
|
16
|
+
expect(result.name).toBe("my-skill");
|
|
17
|
+
expect(result.description).toBe("A test skill");
|
|
18
|
+
expect(result.body).toBe("This is the body.");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("parses all optional frontmatter fields", () => {
|
|
22
|
+
const content = `---
|
|
23
|
+
name: full-skill
|
|
24
|
+
description: Full featured skill
|
|
25
|
+
allowed-tools: Read,Write,Bash
|
|
26
|
+
model: opus
|
|
27
|
+
effort: high
|
|
28
|
+
context: some-context
|
|
29
|
+
agent: worker-123
|
|
30
|
+
disable-model-invocation: true
|
|
31
|
+
user-invocable: true
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
Body content here.`;
|
|
35
|
+
|
|
36
|
+
const result = parseSkillContent(content);
|
|
37
|
+
expect(result.name).toBe("full-skill");
|
|
38
|
+
expect(result.description).toBe("Full featured skill");
|
|
39
|
+
expect(result.allowedTools).toBe("Read,Write,Bash");
|
|
40
|
+
expect(result.model).toBe("opus");
|
|
41
|
+
expect(result.effort).toBe("high");
|
|
42
|
+
expect(result.context).toBe("some-context");
|
|
43
|
+
expect(result.agent).toBe("worker-123");
|
|
44
|
+
expect(result.disableModelInvocation).toBe(true);
|
|
45
|
+
expect(result.userInvocable).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("returns undefined for unset optional fields", () => {
|
|
49
|
+
const content = `---
|
|
50
|
+
name: minimal
|
|
51
|
+
description: Minimal skill
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
Body.`;
|
|
55
|
+
|
|
56
|
+
const result = parseSkillContent(content);
|
|
57
|
+
expect(result.allowedTools).toBeUndefined();
|
|
58
|
+
expect(result.model).toBeUndefined();
|
|
59
|
+
expect(result.effort).toBeUndefined();
|
|
60
|
+
expect(result.context).toBeUndefined();
|
|
61
|
+
expect(result.agent).toBeUndefined();
|
|
62
|
+
expect(result.disableModelInvocation).toBeUndefined();
|
|
63
|
+
expect(result.userInvocable).toBeUndefined();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("handles empty body after frontmatter", () => {
|
|
67
|
+
const content = `---
|
|
68
|
+
name: no-body
|
|
69
|
+
description: Skill with no body
|
|
70
|
+
---`;
|
|
71
|
+
|
|
72
|
+
const result = parseSkillContent(content);
|
|
73
|
+
expect(result.name).toBe("no-body");
|
|
74
|
+
expect(result.body).toBe("");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("user-invocable defaults to true when present without value", () => {
|
|
78
|
+
// user-invocable with no value → empty string → not "false" → true
|
|
79
|
+
// Actually per the parser: if key has empty value, it's skipped (value check)
|
|
80
|
+
// Let's test explicit true/false
|
|
81
|
+
const contentTrue = `---
|
|
82
|
+
name: invocable
|
|
83
|
+
description: Test
|
|
84
|
+
user-invocable: true
|
|
85
|
+
---
|
|
86
|
+
Body`;
|
|
87
|
+
|
|
88
|
+
const contentFalse = `---
|
|
89
|
+
name: non-invocable
|
|
90
|
+
description: Test
|
|
91
|
+
user-invocable: false
|
|
92
|
+
---
|
|
93
|
+
Body`;
|
|
94
|
+
|
|
95
|
+
expect(parseSkillContent(contentTrue).userInvocable).toBe(true);
|
|
96
|
+
expect(parseSkillContent(contentFalse).userInvocable).toBe(false);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("disable-model-invocation only true for literal 'true'", () => {
|
|
100
|
+
const contentTrue = `---
|
|
101
|
+
name: disabled
|
|
102
|
+
description: Test
|
|
103
|
+
disable-model-invocation: true
|
|
104
|
+
---
|
|
105
|
+
Body`;
|
|
106
|
+
|
|
107
|
+
const contentFalse = `---
|
|
108
|
+
name: enabled
|
|
109
|
+
description: Test
|
|
110
|
+
disable-model-invocation: false
|
|
111
|
+
---
|
|
112
|
+
Body`;
|
|
113
|
+
|
|
114
|
+
expect(parseSkillContent(contentTrue).disableModelInvocation).toBe(true);
|
|
115
|
+
expect(parseSkillContent(contentFalse).disableModelInvocation).toBeUndefined();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("handles extra whitespace in frontmatter", () => {
|
|
119
|
+
const content = `---
|
|
120
|
+
name: spaced-skill
|
|
121
|
+
description: A spaced description
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
Body.`;
|
|
125
|
+
|
|
126
|
+
const result = parseSkillContent(content);
|
|
127
|
+
expect(result.name).toBe("spaced-skill");
|
|
128
|
+
expect(result.description).toBe("A spaced description");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("handles colons in frontmatter values", () => {
|
|
132
|
+
const content = `---
|
|
133
|
+
name: colon-skill
|
|
134
|
+
description: A skill with: colons in description
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
Body.`;
|
|
138
|
+
|
|
139
|
+
const result = parseSkillContent(content);
|
|
140
|
+
expect(result.description).toBe("A skill with: colons in description");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// ─── Invalid Inputs ─────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
describe("parseSkillContent — invalid inputs", () => {
|
|
147
|
+
test("throws if no frontmatter delimiter", () => {
|
|
148
|
+
expect(() => parseSkillContent("No frontmatter here")).toThrow("No frontmatter found");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("throws if frontmatter is unterminated", () => {
|
|
152
|
+
expect(() => parseSkillContent("---\nname: test\nno closing")).toThrow("Missing closing ---");
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("throws if name is missing", () => {
|
|
156
|
+
const content = `---
|
|
157
|
+
description: Missing name
|
|
158
|
+
---
|
|
159
|
+
Body`;
|
|
160
|
+
expect(() => parseSkillContent(content)).toThrow('missing required field: "name"');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
test("throws if description is missing", () => {
|
|
164
|
+
const content = `---
|
|
165
|
+
name: no-desc
|
|
166
|
+
---
|
|
167
|
+
Body`;
|
|
168
|
+
expect(() => parseSkillContent(content)).toThrow('missing required field: "description"');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("throws on empty string", () => {
|
|
172
|
+
expect(() => parseSkillContent("")).toThrow("No frontmatter found");
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("throws on whitespace-only string", () => {
|
|
176
|
+
expect(() => parseSkillContent(" \n\n ")).toThrow("No frontmatter found");
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
|
3
|
+
import { unlink } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { closeDb, createAgent, createSkill, initDb, installSkill } from "../be/db";
|
|
7
|
+
import { syncSkillsToFilesystem } from "../be/skill-sync";
|
|
8
|
+
|
|
9
|
+
const TEST_DB_PATH = `./test-skill-sync-${process.pid}.sqlite`;
|
|
10
|
+
const FAKE_HOME = join(tmpdir(), `skill-sync-test-${process.pid}`);
|
|
11
|
+
|
|
12
|
+
describe("syncSkillsToFilesystem", () => {
|
|
13
|
+
let agentId: string;
|
|
14
|
+
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
initDb(TEST_DB_PATH);
|
|
17
|
+
|
|
18
|
+
const agent = createAgent({
|
|
19
|
+
name: "Skill Sync Test Worker",
|
|
20
|
+
description: "Test agent for skill sync",
|
|
21
|
+
role: "worker",
|
|
22
|
+
isLead: false,
|
|
23
|
+
status: "idle",
|
|
24
|
+
maxTasks: 1,
|
|
25
|
+
capabilities: [],
|
|
26
|
+
});
|
|
27
|
+
agentId = agent.id;
|
|
28
|
+
|
|
29
|
+
// Create and install a simple skill
|
|
30
|
+
const skill = createSkill({
|
|
31
|
+
name: "test-skill",
|
|
32
|
+
description: "A test skill",
|
|
33
|
+
content: "---\nname: test-skill\ndescription: A test skill\n---\n\nTest body.",
|
|
34
|
+
type: "personal",
|
|
35
|
+
scope: "agent",
|
|
36
|
+
});
|
|
37
|
+
installSkill(agentId, skill.id);
|
|
38
|
+
|
|
39
|
+
// Create a complex skill (should be skipped)
|
|
40
|
+
const complexSkill = createSkill({
|
|
41
|
+
name: "complex-skill",
|
|
42
|
+
description: "A complex skill",
|
|
43
|
+
content: "---\nname: complex-skill\ndescription: A complex skill\n---\n\nBody.",
|
|
44
|
+
type: "remote",
|
|
45
|
+
scope: "global",
|
|
46
|
+
isComplex: true,
|
|
47
|
+
});
|
|
48
|
+
installSkill(agentId, complexSkill.id);
|
|
49
|
+
|
|
50
|
+
mkdirSync(FAKE_HOME, { recursive: true });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
afterAll(async () => {
|
|
54
|
+
closeDb();
|
|
55
|
+
rmSync(FAKE_HOME, { recursive: true, force: true });
|
|
56
|
+
await unlink(TEST_DB_PATH).catch(() => {});
|
|
57
|
+
await unlink(`${TEST_DB_PATH}-wal`).catch(() => {});
|
|
58
|
+
await unlink(`${TEST_DB_PATH}-shm`).catch(() => {});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("syncs simple skills to claude directory", () => {
|
|
62
|
+
const result = syncSkillsToFilesystem(agentId, "claude", FAKE_HOME);
|
|
63
|
+
|
|
64
|
+
expect(result.errors).toHaveLength(0);
|
|
65
|
+
expect(result.synced).toBeGreaterThanOrEqual(1);
|
|
66
|
+
|
|
67
|
+
const skillFile = join(FAKE_HOME, ".claude", "skills", "test-skill", "SKILL.md");
|
|
68
|
+
expect(existsSync(skillFile)).toBe(true);
|
|
69
|
+
expect(readFileSync(skillFile, "utf-8")).toContain("Test body.");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("syncs simple skills to pi directory", () => {
|
|
73
|
+
const result = syncSkillsToFilesystem(agentId, "pi", FAKE_HOME);
|
|
74
|
+
|
|
75
|
+
expect(result.errors).toHaveLength(0);
|
|
76
|
+
expect(result.synced).toBeGreaterThanOrEqual(1);
|
|
77
|
+
|
|
78
|
+
const skillFile = join(FAKE_HOME, ".pi", "agent", "skills", "test-skill", "SKILL.md");
|
|
79
|
+
expect(existsSync(skillFile)).toBe(true);
|
|
80
|
+
expect(readFileSync(skillFile, "utf-8")).toContain("Test body.");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("syncs to both claude and pi when harnessType is 'both'", () => {
|
|
84
|
+
// Clean up first to get accurate count
|
|
85
|
+
rmSync(join(FAKE_HOME, ".claude"), { recursive: true, force: true });
|
|
86
|
+
rmSync(join(FAKE_HOME, ".pi"), { recursive: true, force: true });
|
|
87
|
+
|
|
88
|
+
const result = syncSkillsToFilesystem(agentId, "both", FAKE_HOME);
|
|
89
|
+
|
|
90
|
+
expect(result.errors).toHaveLength(0);
|
|
91
|
+
expect(result.synced).toBe(2); // 1 skill × 2 dirs
|
|
92
|
+
|
|
93
|
+
const claudeFile = join(FAKE_HOME, ".claude", "skills", "test-skill", "SKILL.md");
|
|
94
|
+
const piFile = join(FAKE_HOME, ".pi", "agent", "skills", "test-skill", "SKILL.md");
|
|
95
|
+
expect(existsSync(claudeFile)).toBe(true);
|
|
96
|
+
expect(existsSync(piFile)).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("skips complex skills", () => {
|
|
100
|
+
const _result = syncSkillsToFilesystem(agentId, "claude", FAKE_HOME);
|
|
101
|
+
|
|
102
|
+
const complexDir = join(FAKE_HOME, ".claude", "skills", "complex-skill");
|
|
103
|
+
expect(existsSync(complexDir)).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("removes stale skill directories", () => {
|
|
107
|
+
const staleDir = join(FAKE_HOME, ".claude", "skills", "old-removed-skill");
|
|
108
|
+
mkdirSync(staleDir, { recursive: true });
|
|
109
|
+
expect(existsSync(staleDir)).toBe(true);
|
|
110
|
+
|
|
111
|
+
const result = syncSkillsToFilesystem(agentId, "claude", FAKE_HOME);
|
|
112
|
+
|
|
113
|
+
expect(result.removed).toBeGreaterThanOrEqual(1);
|
|
114
|
+
expect(existsSync(staleDir)).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("defaults to 'both' when no harnessType provided", () => {
|
|
118
|
+
// Clean up first
|
|
119
|
+
rmSync(join(FAKE_HOME, ".claude"), { recursive: true, force: true });
|
|
120
|
+
rmSync(join(FAKE_HOME, ".pi"), { recursive: true, force: true });
|
|
121
|
+
|
|
122
|
+
// Use 'both' explicitly with homeOverride (default harnessType would use real home)
|
|
123
|
+
const result = syncSkillsToFilesystem(agentId, "both", FAKE_HOME);
|
|
124
|
+
|
|
125
|
+
expect(result.errors).toHaveLength(0);
|
|
126
|
+
expect(result.synced).toBe(2);
|
|
127
|
+
|
|
128
|
+
const claudeFile = join(FAKE_HOME, ".claude", "skills", "test-skill", "SKILL.md");
|
|
129
|
+
const piFile = join(FAKE_HOME, ".pi", "agent", "skills", "test-skill", "SKILL.md");
|
|
130
|
+
expect(existsSync(claudeFile)).toBe(true);
|
|
131
|
+
expect(existsSync(piFile)).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("returns empty result for agent with no skills", () => {
|
|
135
|
+
const otherAgent = createAgent({
|
|
136
|
+
name: "Empty Agent",
|
|
137
|
+
description: "Agent with no skills",
|
|
138
|
+
role: "worker",
|
|
139
|
+
isLead: false,
|
|
140
|
+
status: "idle",
|
|
141
|
+
maxTasks: 1,
|
|
142
|
+
capabilities: [],
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const result = syncSkillsToFilesystem(otherAgent.id, "claude", FAKE_HOME);
|
|
146
|
+
|
|
147
|
+
expect(result.synced).toBe(0);
|
|
148
|
+
expect(result.errors).toHaveLength(0);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("sanitizes skill names with special characters", () => {
|
|
152
|
+
const skill = createSkill({
|
|
153
|
+
name: "my/dangerous/../skill",
|
|
154
|
+
description: "Path traversal attempt",
|
|
155
|
+
content:
|
|
156
|
+
"---\nname: my/dangerous/../skill\ndescription: Path traversal attempt\n---\n\nSafe.",
|
|
157
|
+
type: "personal",
|
|
158
|
+
scope: "agent",
|
|
159
|
+
});
|
|
160
|
+
installSkill(agentId, skill.id);
|
|
161
|
+
|
|
162
|
+
// Clean up first
|
|
163
|
+
rmSync(join(FAKE_HOME, ".claude"), { recursive: true, force: true });
|
|
164
|
+
|
|
165
|
+
const result = syncSkillsToFilesystem(agentId, "claude", FAKE_HOME);
|
|
166
|
+
|
|
167
|
+
expect(result.errors).toHaveLength(0);
|
|
168
|
+
const sanitizedDir = join(FAKE_HOME, ".claude", "skills", "my_dangerous____skill");
|
|
169
|
+
expect(existsSync(sanitizedDir)).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
@@ -145,9 +145,10 @@ describe("buildProgressBlocks", () => {
|
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
expect(blocks.length).toBe(2);
|
|
148
|
-
// Single line:
|
|
148
|
+
// Single line: *Gamma* (`aabbccdd`): Analyzing codebase...
|
|
149
|
+
// (no ⏳ prefix — progress strings now carry their own emoji)
|
|
149
150
|
expect(blocks[0].type).toBe("section");
|
|
150
|
-
expect(blocks[0].text.text).toContain("⏳");
|
|
151
|
+
expect(blocks[0].text.text).not.toContain("⏳");
|
|
151
152
|
expect(blocks[0].text.text).toContain("Gamma");
|
|
152
153
|
expect(blocks[0].text.text).toContain("aabbccdd");
|
|
153
154
|
expect(blocks[0].text.text).toContain("Analyzing codebase...");
|
|
@@ -233,6 +233,7 @@ describe("AgentTaskConfigSchema — outputSchema", () => {
|
|
|
233
233
|
test("accepts outputSchema in config", async () => {
|
|
234
234
|
const { AgentTaskExecutor } = await import("../workflows/executors/agent-task");
|
|
235
235
|
const executor = new AgentTaskExecutor({
|
|
236
|
+
// biome-ignore lint/suspicious/noExplicitAny: mock DB for test
|
|
236
237
|
db: {} as any,
|
|
237
238
|
eventBus: { emit: () => {}, on: () => {}, off: () => {} },
|
|
238
239
|
interpolate: (t: string) => t,
|
|
@@ -338,8 +338,9 @@ describe("Tool Annotations & Classification", () => {
|
|
|
338
338
|
test("registered tool count matches expected total", () => {
|
|
339
339
|
const count = Object.keys(tools).length;
|
|
340
340
|
// We expect all tools to be registered when all capabilities are enabled (default)
|
|
341
|
+
// Includes 11 skill tools added in the skill system feature
|
|
341
342
|
expect(count).toBeGreaterThanOrEqual(45);
|
|
342
|
-
expect(count).toBeLessThanOrEqual(
|
|
343
|
+
expect(count).toBeLessThanOrEqual(85);
|
|
343
344
|
});
|
|
344
345
|
|
|
345
346
|
test("core tools are fewer than deferred tools", () => {
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { humanizeToolName, toolCallToProgress } from "../commands/runner";
|
|
3
|
+
|
|
4
|
+
describe("toolCallToProgress", () => {
|
|
5
|
+
// --- Core Claude Code tools ---
|
|
6
|
+
|
|
7
|
+
test("Read tool includes emoji and short path", () => {
|
|
8
|
+
const result = toolCallToProgress("Read", {
|
|
9
|
+
file_path: "/Users/taras/Documents/code/agent-swarm/src/commands/runner.ts",
|
|
10
|
+
});
|
|
11
|
+
expect(result).toBe("📖 Reading commands/runner.ts");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("Edit tool includes emoji and short path", () => {
|
|
15
|
+
const result = toolCallToProgress("Edit", {
|
|
16
|
+
file_path: "/Users/taras/code/src/index.ts",
|
|
17
|
+
});
|
|
18
|
+
expect(result).toBe("✏️ Editing src/index.ts");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("MultiEdit uses same format as Edit", () => {
|
|
22
|
+
const result = toolCallToProgress("MultiEdit", {
|
|
23
|
+
file_path: "/a/b/c/d.ts",
|
|
24
|
+
});
|
|
25
|
+
expect(result).toBe("✏️ Editing c/d.ts");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("Write tool includes emoji and short path", () => {
|
|
29
|
+
const result = toolCallToProgress("Write", {
|
|
30
|
+
file_path: "/Users/taras/code/new-file.ts",
|
|
31
|
+
});
|
|
32
|
+
expect(result).toBe("📝 Writing code/new-file.ts");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("Bash tool uses description when available", () => {
|
|
36
|
+
const result = toolCallToProgress("Bash", {
|
|
37
|
+
description: "Running tests",
|
|
38
|
+
command: "bun test",
|
|
39
|
+
});
|
|
40
|
+
expect(result).toBe("⚡ Running tests");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("Bash tool falls back when no description", () => {
|
|
44
|
+
const result = toolCallToProgress("Bash", { command: "ls -la" });
|
|
45
|
+
expect(result).toBe("⚡ Running shell command");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Grep tool shows search pattern", () => {
|
|
49
|
+
const result = toolCallToProgress("Grep", { pattern: "TODO" });
|
|
50
|
+
expect(result).toBe('🔍 Searching for "TODO"');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("Glob tool shows file pattern", () => {
|
|
54
|
+
const result = toolCallToProgress("Glob", { pattern: "**/*.test.ts" });
|
|
55
|
+
expect(result).toBe("📁 Finding files matching **/*.test.ts");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("Agent tool uses description when available", () => {
|
|
59
|
+
const result = toolCallToProgress("Agent", {
|
|
60
|
+
description: "Exploring codebase structure",
|
|
61
|
+
});
|
|
62
|
+
expect(result).toBe("🤖 Exploring codebase structure");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("Agent tool falls back when no description", () => {
|
|
66
|
+
const result = toolCallToProgress("Agent", {});
|
|
67
|
+
expect(result).toBe("🤖 Delegating sub-task");
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("Task tool uses description", () => {
|
|
71
|
+
const result = toolCallToProgress("Task", {
|
|
72
|
+
description: "Running lint checks",
|
|
73
|
+
});
|
|
74
|
+
expect(result).toBe("🤖 Running lint checks");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("Skill tool shows skill name", () => {
|
|
78
|
+
const result = toolCallToProgress("Skill", { skill: "commit" });
|
|
79
|
+
expect(result).toBe("⚙️ Running /commit");
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// --- Skip list ---
|
|
83
|
+
|
|
84
|
+
test("ToolSearch is skipped (returns null)", () => {
|
|
85
|
+
expect(toolCallToProgress("ToolSearch", {})).toBeNull();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("TodoRead is skipped", () => {
|
|
89
|
+
expect(toolCallToProgress("TodoRead", {})).toBeNull();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("TodoWrite is skipped", () => {
|
|
93
|
+
expect(toolCallToProgress("TodoWrite", {})).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// --- Unknown default tools ---
|
|
97
|
+
|
|
98
|
+
test("unknown tool gets fallback with emoji", () => {
|
|
99
|
+
const result = toolCallToProgress("SomeNewTool", {});
|
|
100
|
+
expect(result).toBe("🔧 SomeNewTool");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// --- Agent-swarm MCP tools (with pretty labels) ---
|
|
104
|
+
|
|
105
|
+
test("agent-swarm:get-task-details has pretty label", () => {
|
|
106
|
+
const result = toolCallToProgress("mcp__agent-swarm__get-task-details", {});
|
|
107
|
+
expect(result).toBe("📋 Reviewing task details");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("agent-swarm:send-task has pretty label", () => {
|
|
111
|
+
const result = toolCallToProgress("mcp__agent-swarm__send-task", {});
|
|
112
|
+
expect(result).toBe("📤 Delegating task");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("agent-swarm:post-message has pretty label", () => {
|
|
116
|
+
const result = toolCallToProgress("mcp__agent-swarm__post-message", {});
|
|
117
|
+
expect(result).toBe("💬 Sending message");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test("agent-swarm:store-progress is skipped (meta/noise)", () => {
|
|
121
|
+
expect(toolCallToProgress("mcp__agent-swarm__store-progress", {})).toBeNull();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("agent-swarm:poll-task has pretty label", () => {
|
|
125
|
+
const result = toolCallToProgress("mcp__agent-swarm__poll-task", {});
|
|
126
|
+
expect(result).toBe("📡 Polling for tasks");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("agent-swarm:request-human-input has pretty label", () => {
|
|
130
|
+
const result = toolCallToProgress("mcp__agent-swarm__request-human-input", {});
|
|
131
|
+
expect(result).toBe("🙋 Requesting human input");
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test("agent-swarm:memory-search has pretty label", () => {
|
|
135
|
+
const result = toolCallToProgress("mcp__agent-swarm__memory-search", {});
|
|
136
|
+
expect(result).toBe("🧠 Searching memory");
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("agent-swarm:tracker-status has pretty label", () => {
|
|
140
|
+
const result = toolCallToProgress("mcp__agent-swarm__tracker-status", {});
|
|
141
|
+
expect(result).toBe("📊 Checking tracker status");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("agent-swarm:trigger-workflow has pretty label", () => {
|
|
145
|
+
const result = toolCallToProgress("mcp__agent-swarm__trigger-workflow", {});
|
|
146
|
+
expect(result).toBe("⚙️ Triggering workflow");
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test("agent-swarm:slack-post has pretty label", () => {
|
|
150
|
+
const result = toolCallToProgress("mcp__agent-swarm__slack-post", {});
|
|
151
|
+
expect(result).toBe("💬 Posting to Slack");
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// --- Agent-swarm MCP tool NOT in lookup (humanized fallback) ---
|
|
155
|
+
|
|
156
|
+
test("unknown agent-swarm tool gets humanized fallback", () => {
|
|
157
|
+
const result = toolCallToProgress("mcp__agent-swarm__some-new-tool", {});
|
|
158
|
+
expect(result).toBe("🔌 Some new tool");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// --- Other MCP servers ---
|
|
162
|
+
|
|
163
|
+
test("other MCP server tool gets server prefix + humanized name", () => {
|
|
164
|
+
const result = toolCallToProgress("mcp__linear__list-issues", {});
|
|
165
|
+
expect(result).toBe("🔌 linear: List issues");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("other MCP server with simple tool name", () => {
|
|
169
|
+
const result = toolCallToProgress("mcp__github__search", {});
|
|
170
|
+
expect(result).toBe("🔌 github: Search");
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("MCP tool with double underscores in tool name", () => {
|
|
174
|
+
const result = toolCallToProgress("mcp__context7__query-docs", {});
|
|
175
|
+
expect(result).toBe("🔌 context7: Query docs");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// --- Short path helper (tested implicitly) ---
|
|
179
|
+
|
|
180
|
+
test("Read with short path (<=2 segments) keeps full path", () => {
|
|
181
|
+
const result = toolCallToProgress("Read", { file_path: "file.ts" });
|
|
182
|
+
expect(result).toBe("📖 Reading file.ts");
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("Read with missing file_path shows empty", () => {
|
|
186
|
+
const result = toolCallToProgress("Read", {});
|
|
187
|
+
expect(result).toBe("📖 Reading ");
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
describe("humanizeToolName", () => {
|
|
192
|
+
test("converts kebab-case to sentence case", () => {
|
|
193
|
+
expect(humanizeToolName("get-task-details")).toBe("Get task details");
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("single word gets capitalized", () => {
|
|
197
|
+
expect(humanizeToolName("search")).toBe("Search");
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
test("multi-word kebab-case", () => {
|
|
201
|
+
expect(humanizeToolName("list-all-workflow-runs")).toBe("List all workflow runs");
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("empty string returns empty", () => {
|
|
205
|
+
expect(humanizeToolName("")).toBe("");
|
|
206
|
+
});
|
|
207
|
+
});
|