pi-soly 0.3.0 → 0.5.0

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.
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "pi-agented",
3
+ "version": "0.2.0",
4
+ "description": "Generic subagent switcher for pi. Header bar above chat, Ctrl+Shift+S to cycle, /agent slash command. Works with any agent in ~/.pi/agent/agents/.",
5
+ "type": "module",
6
+ "main": "index.ts",
7
+ "scripts": {
8
+ "test": "bun test",
9
+ "typecheck": "bun x tsc --noEmit"
10
+ },
11
+ "dependencies": {},
12
+ "peerDependencies": {
13
+ "@earendil-works/pi-coding-agent": "*",
14
+ "@earendil-works/pi-tui": "*"
15
+ },
16
+ "devDependencies": {
17
+ "@earendil-works/pi-coding-agent": "0.78.1",
18
+ "@earendil-works/pi-tui": "0.78.1",
19
+ "@types/node": "^25.9.1",
20
+ "bun-types": "^1.3.14",
21
+ "typebox": "1.1.38",
22
+ "typescript": "^6.0.3"
23
+ },
24
+ "files": [
25
+ "index.ts",
26
+ "core.ts",
27
+ "prompt.ts",
28
+ "README.md"
29
+ ],
30
+ "keywords": [
31
+ "pi",
32
+ "pi-extension",
33
+ "pi-package",
34
+ "subagent",
35
+ "agent-switcher",
36
+ "task-routing"
37
+ ],
38
+ "license": "MIT",
39
+ "pi": {
40
+ "extensions": [
41
+ "./index.ts"
42
+ ]
43
+ },
44
+ "publishConfig": {
45
+ "registry": "https://registry.npmjs.org/"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "http://git.local.stbl/lowern1ght/pi-soly.framework.git",
50
+ "directory": "packages/pi-switch"
51
+ }
52
+ }
@@ -0,0 +1,134 @@
1
+ // =============================================================================
2
+ // prompt.ts — System-prompt section for the pi-switch extension
3
+ // =============================================================================
4
+
5
+ /** Task-pattern → recommended agent. The LLM reads this and decides
6
+ * whether to invoke /agent before launching subagent(...). Match is
7
+ * by keyword (case-insensitive). First match wins; ties broken by order. */
8
+ export const TASK_AGENT_HINTS: ReadonlyArray<{
9
+ pattern: RegExp;
10
+ agent: string;
11
+ emoji: string;
12
+ why: string;
13
+ }> = [
14
+ // English keywords (use \b — ASCII word boundary works for English)
15
+ { pattern: /\b(research|investigate|look\s*up|find\s*out|explore|survey|compare\s+libraries|what\s+is\s+the\s+best)\b/i,
16
+ agent: "researcher", emoji: "\ud83d\udcda",
17
+ why: "external docs, ecosystem behavior, primary sources" },
18
+ { pattern: /\b(scout|scan|map|find\s+all|where\s+is|locate|explore\s+codebase|skim)\b/i,
19
+ agent: "scout", emoji: "\ud83d\udd0d",
20
+ why: "codebase recon, patterns, file locations" },
21
+ { pattern: /\b(plan|design|architect|outline|structure|break\s*down|steps|order)\b/i,
22
+ agent: "planner", emoji: "\ud83d\udccb",
23
+ why: "decompose into ordered steps, identify risks" },
24
+ { pattern: /\b(review|audit|check|adversarial|critique|find\s+bugs|qa)\b/i,
25
+ agent: "reviewer", emoji: "\ud83d\udc40",
26
+ why: "adversarial review of correctness, security, style" },
27
+ { pattern: /\b(oracle|decision|tradeoff|compare|which\s+approach|is\s+this\s+wise|drift)\b/i,
28
+ agent: "oracle", emoji: "\ud83d\udd2e",
29
+ why: "decision consistency, hidden assumptions, drift detection" },
30
+ { pattern: /\b(debug|bug|fix|crash|error|stack\s*trace|repro|why\s+is\s+this\s+broken)\b/i,
31
+ agent: "soly-debugger", emoji: "\ud83d\udc1e",
32
+ why: "isolated bug investigation with minimal repro" },
33
+ { pattern: /\b(test|tests|coverage|spec|assert)\b/i,
34
+ agent: "soly-tester", emoji: "\ud83e\uddea",
35
+ why: "test-only work, never modifies prod code" },
36
+ { pattern: /\b(refactor|clean\s*up|simplify|extract|rename|restructure|no\s+behavior\s+change)\b/i,
37
+ agent: "soly-refactor", emoji: "\ud83d\udd04",
38
+ why: "pure refactoring, behavior-preserving" },
39
+ { pattern: /\b(document|docs|readme|jsdoc|comment|annotate)\b/i,
40
+ agent: "soly-documenter", emoji: "\ud83d\udcdd",
41
+ why: "doc updates, READMEs, inline annotations" },
42
+ { pattern: /\b(implement|build|write\s+code|add\s+feature|create\s+the)\b/i,
43
+ agent: "worker", emoji: "\u26a1",
44
+ why: "generic implementation with all tools" },
45
+ { pattern: /\b(orchestrate|coordinate|dispatch|chain|run\s+in\s+parallel|first\s+.+\s+then)\b/i,
46
+ agent: "delegate", emoji: "\ud83e\udd1d",
47
+ why: "multi-agent orchestration" },
48
+ // Russian keywords (loose match — Russian words inflect heavily; we match
49
+ // word stems, accepting some false positives as the cost of broader coverage)
50
+ { pattern: /(изуч|исслед|разузн|найди\s+инфу|research|investigate|find\s+out)/i,
51
+ agent: "researcher", emoji: "\ud83d\udcda",
52
+ why: "external docs, ecosystem behavior, primary sources" },
53
+ { pattern: /(где\s+это|где\s+находит|find\s+all|locate)/i,
54
+ agent: "scout", emoji: "\ud83d\udd0d",
55
+ why: "codebase recon, patterns, file locations" },
56
+ { pattern: /(спланир|plan|design|architect)/i,
57
+ agent: "planner", emoji: "\ud83d\udccb",
58
+ why: "decompose into ordered steps, identify risks" },
59
+ { pattern: /(проверь|ревью|аудит|review|audit)/i,
60
+ agent: "reviewer", emoji: "\ud83d\udc40",
61
+ why: "adversarial review of correctness, security, style" },
62
+ { pattern: /(решени|выбор|decision|tradeoff|drift)/i,
63
+ agent: "oracle", emoji: "\ud83d\udd2e",
64
+ why: "decision consistency, hidden assumptions, drift detection" },
65
+ { pattern: /(баг|ошибк|почему\s+(?:падает|ломает)|debug|bug|crash|stack\s*trace|repro)/i,
66
+ agent: "soly-debugger", emoji: "\ud83d\udc1e",
67
+ why: "isolated bug investigation with minimal repro" },
68
+ { pattern: /(тест|покрыт|test|coverage|spec|assert)/i,
69
+ agent: "soly-tester", emoji: "\ud83e\uddea",
70
+ why: "test-only work, never modifies prod code" },
71
+ { pattern: /(рефактор|упрост|refactor|simplify|extract|restructure)/i,
72
+ agent: "soly-refactor", emoji: "\ud83d\udd04",
73
+ why: "pure refactoring, behavior-preserving" },
74
+ { pattern: /(документ|описани|document|readme|jsdoc)/i,
75
+ agent: "soly-documenter", emoji: "\ud83d\udcdd",
76
+ why: "doc updates, READMEs, inline annotations" },
77
+ { pattern: /(реализуй|сделай|напиши|создай|implement|build|add\s+feature|create\s+the)/i,
78
+ agent: "worker", emoji: "\u26a1",
79
+ why: "generic implementation with all tools" },
80
+ { pattern: /(оркестрируй|координируй|orchestrate|coordinate|dispatch|chain)/i,
81
+ agent: "delegate", emoji: "\ud83e\udd1d",
82
+ why: "multi-agent orchestration" },
83
+ ];
84
+
85
+ /** Heuristic: which agent does the task look like? Returns null if no
86
+ * pattern matches (caller should leave the current agent as-is). */
87
+ export function recommendAgent(taskText: string): { agent: string; emoji: string; why: string } | null {
88
+ for (const hint of TASK_AGENT_HINTS) {
89
+ if (hint.pattern.test(taskText)) {
90
+ return { agent: hint.agent, emoji: hint.emoji, why: hint.why };
91
+ }
92
+ }
93
+ return null;
94
+ }
95
+
96
+ export function buildPiSwitchSection(): string {
97
+ return `
98
+
99
+ ## pi-switch — when to use \`/agent\`
100
+
101
+ The \`/agent\` slash command + \`Ctrl+Shift+S\` shortcut cycle through available subagents. Use the right agent for the job:
102
+
103
+ - **Read-only / no edits** (oracle, scout, researcher, planner, reviewer): for analysis, planning, review. They won't modify files.
104
+ - **Write tools** (worker, context-builder, delegate): for implementation.
105
+ - **User-defined** in \`~/.pi/agent/agents/\`: any agent the user has added — drop a markdown file with YAML frontmatter (name, description) and it joins the cycle automatically.
106
+
107
+ The current agent is shown in a header bar above the chat (with emoji + description) and in the footer status line as \`[emoji name]\`. When the agent changes, a multi-line notification appears with the old → new diff and capability summary.
108
+
109
+ When you need a specialist for a sub-task, use the right agent via the parent LLM's \`subagent(...)\` call — the system will use the currently active agent. You can also use \`/agent <name>\` to switch explicitly, but in most cases the orchestrator picks the right agent for each step.
110
+
111
+ **Task → agent heuristics.** Before launching a generic \`subagent(...)\`, scan the request for these keywords and call \`/agent <name>\` first if it matches:
112
+
113
+ | Keywords in request | Suggested agent | Why |
114
+ |---|---|---|
115
+ | research, investigate, look up, find out, explore, compare libraries, what is the best | 📚 researcher | external docs, ecosystem behavior |
116
+ | scout, scan, map, find all, where is, locate, explore codebase, skim | 🔍 scout | codebase recon, patterns, file locations |
117
+ | plan, design, architect, outline, structure, break down, steps, order | 📋 planner | decompose into ordered steps, identify risks |
118
+ | review, audit, check, adversarial, critique, find bugs, qa | 👀 reviewer | adversarial correctness, security, style review |
119
+ | oracle, decision, tradeoff, compare, which approach, is this wise, drift | 🔮 oracle | decision consistency, hidden assumptions |
120
+ | debug, bug, fix, crash, error, stack trace, repro, why is this broken | 🐞 soly-debugger | isolated bug investigation with minimal repro |
121
+ | test, tests, coverage, spec, assert | 🧪 soly-tester | test-only work, never modifies prod code |
122
+ | refactor, clean up, simplify, extract, rename, restructure, no behavior change | 🔄 soly-refactor | pure refactoring, behavior-preserving |
123
+ | document, docs, readme, jsdoc, comment, annotate | 📝 soly-documenter | doc updates, READMEs, inline annotations |
124
+ | implement, build, write code, add feature, create the | ⚡ worker | generic implementation with all tools |
125
+ | orchestrate, coordinate, dispatch, chain, run in parallel | 🤝 delegate | multi-agent orchestration |
126
+
127
+ For multi-step tasks, the orchestrator (you) decides which agents run and in what order. You can chain agents via \`subagent({ chain: [...] })\` or run them in parallel via parallel tasks.
128
+
129
+ DON'T:
130
+ - Launch a worker for analysis (use oracle/scout)
131
+ - Launch an oracle for implementation (it has no write tools)
132
+ - Manually edit \`.soly/agent\` or \`~/.pi-switch/agent\` — use the slash command
133
+ `;
134
+ }
@@ -0,0 +1,188 @@
1
+ // =============================================================================
2
+ // tests/core.test.ts — Tests for pi-switch core
3
+ // =============================================================================
4
+
5
+ /// <reference types="bun-types" />
6
+ import { describe, test, expect, beforeAll, afterAll } from "bun:test";
7
+ import * as fs from "node:fs";
8
+ import * as os from "node:os";
9
+ import * as path from "node:path";
10
+ import {
11
+ DEFAULT_AGENT,
12
+ BUILTIN_AGENTS,
13
+ AGENT_META,
14
+ getAgentMeta,
15
+ isValidAgentName,
16
+ discoverUserAgents,
17
+ availableAgents,
18
+ nextAgent,
19
+ parseAgentName,
20
+ formatAgentBadge,
21
+ formatAgentSwitchNotify,
22
+ formatHeaderLine,
23
+ groupedAvailableAgents,
24
+ agentFilePath,
25
+ loadAgent,
26
+ saveAgent,
27
+ } from "../core.js";
28
+
29
+ describe("DEFAULT_AGENT", () => {
30
+ test("is 'worker'", () => {
31
+ expect(DEFAULT_AGENT).toBe("worker");
32
+ });
33
+ });
34
+
35
+ describe("isValidAgentName", () => {
36
+ test("accepts simple names", () => {
37
+ expect(isValidAgentName("worker")).toBe(true);
38
+ expect(isValidAgentName("my_agent")).toBe(true);
39
+ });
40
+ test("rejects invalid", () => {
41
+ expect(isValidAgentName("with space")).toBe(false);
42
+ expect(isValidAgentName("")).toBe(false);
43
+ expect(isValidAgentName("a".repeat(65))).toBe(false);
44
+ });
45
+ });
46
+
47
+ describe("AGENT_META", () => {
48
+ test("every built-in has metadata", () => {
49
+ for (const a of BUILTIN_AGENTS) {
50
+ expect(AGENT_META[a]).toBeDefined();
51
+ expect(AGENT_META[a]!.emoji.length).toBeGreaterThan(0);
52
+ }
53
+ });
54
+ test("meta has writesFiles flag", () => {
55
+ expect(AGENT_META.worker!.writesFiles).toBe(true);
56
+ expect(AGENT_META.oracle!.writesFiles).toBe(false);
57
+ });
58
+ });
59
+
60
+ describe("getAgentMeta", () => {
61
+ test("returns fallback for unknown", () => {
62
+ const m = getAgentMeta("zzz");
63
+ expect(m.emoji.length).toBeGreaterThan(0);
64
+ });
65
+ });
66
+
67
+ describe("nextAgent", () => {
68
+ test("cycles forward", () => {
69
+ expect(nextAgent("a", ["a", "b", "c"])).toBe("b");
70
+ expect(nextAgent("c", ["a", "b", "c"])).toBe("a");
71
+ });
72
+ test("returns first if current not in cycle", () => {
73
+ expect(nextAgent("zzz", ["a", "b"])).toBe("a");
74
+ });
75
+ });
76
+
77
+ describe("parseAgentName", () => {
78
+ test("trims and validates", () => {
79
+ expect(parseAgentName(" oracle ")).toBe("oracle");
80
+ expect(parseAgentName("with space")).toBeNull();
81
+ });
82
+ });
83
+
84
+ describe("formatAgentBadge", () => {
85
+ test("null for default", () => {
86
+ expect(formatAgentBadge(DEFAULT_AGENT)).toBeNull();
87
+ });
88
+ test("emoji + name for non-default", () => {
89
+ const b = formatAgentBadge("oracle");
90
+ expect(b).toContain("oracle");
91
+ });
92
+ });
93
+
94
+ describe("formatAgentSwitchNotify", () => {
95
+ test("multi-line: old → new + capability", () => {
96
+ const out = formatAgentSwitchNotify("worker", "oracle");
97
+ expect(out).toContain("pi-switch agent changed");
98
+ expect(out).toContain("worker");
99
+ expect(out).toContain("oracle");
100
+ expect(out).toContain("writes files: no");
101
+ });
102
+ });
103
+
104
+ describe("formatHeaderLine", () => {
105
+ test("always non-empty (even for default)", () => {
106
+ const h = formatHeaderLine("worker");
107
+ expect(h).toContain("worker");
108
+ expect(h).toContain("Ctrl+Shift+S");
109
+ });
110
+ test("includes read-only tag when applicable", () => {
111
+ const h = formatHeaderLine("oracle");
112
+ expect(h).toContain("read-only");
113
+ });
114
+ test("omits read-only tag when agent writes", () => {
115
+ const h = formatHeaderLine("worker");
116
+ expect(h).not.toContain("read-only");
117
+ });
118
+ });
119
+
120
+ describe("groupedAvailableAgents", () => {
121
+ test("includes built-in group", () => {
122
+ const groups = groupedAvailableAgents("/nonexistent");
123
+ expect(groups[0]?.header).toBe("built-in");
124
+ });
125
+ test("includes user group when present", () => {
126
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "pis-grp-"));
127
+ fs.writeFileSync(path.join(tmp, "my.md"), "---\nname: my-helper\n---\n# body\n");
128
+ const groups = groupedAvailableAgents(tmp);
129
+ const userGroup = groups.find((g) => g.header === "user-defined");
130
+ expect(userGroup?.agents).toContain("my-helper");
131
+ fs.rmSync(tmp, { recursive: true, force: true });
132
+ });
133
+ });
134
+
135
+ // ---------------------------------------------------------------------------
136
+ // Persistence
137
+ // ---------------------------------------------------------------------------
138
+
139
+ describe("agentFilePath", () => {
140
+ test("prefers .soly/agent when soly dir exists", () => {
141
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "pis-path-"));
142
+ fs.mkdirSync(path.join(cwd, ".soly"), { recursive: true });
143
+ expect(agentFilePath(cwd)).toBe(path.join(cwd, ".soly", "agent"));
144
+ fs.rmSync(cwd, { recursive: true, force: true });
145
+ });
146
+ test("falls back to ~/.pi-switch/agent when no soly", () => {
147
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "pis-fb-"));
148
+ // Ensure no .soly in cwd
149
+ expect(agentFilePath(cwd)).toContain(".pi-switch");
150
+ fs.rmSync(cwd, { recursive: true, force: true });
151
+ });
152
+ });
153
+
154
+ describe("loadAgent / saveAgent", () => {
155
+ let tmpCwd: string;
156
+ let origHome: string | undefined;
157
+ beforeAll(() => {
158
+ tmpCwd = fs.mkdtempSync(path.join(os.tmpdir(), "pis-rt-"));
159
+ origHome = process.env.HOME;
160
+ process.env.HOME = tmpCwd;
161
+ });
162
+ afterAll(() => {
163
+ if (origHome) process.env.HOME = origHome;
164
+ fs.rmSync(tmpCwd, { recursive: true, force: true });
165
+ });
166
+
167
+ test("round-trip", () => {
168
+ saveAgent(tmpCwd, "oracle");
169
+ expect(loadAgent(tmpCwd)).toBe("oracle");
170
+ });
171
+ test("returns null when file missing", () => {
172
+ const freshHome = fs.mkdtempSync(path.join(os.tmpdir(), "pis-fresh-"));
173
+ fs.mkdirSync(path.join(freshHome, ".pi-switch"), { recursive: true });
174
+ const prevHome = process.env.HOME;
175
+ process.env.HOME = freshHome;
176
+ try {
177
+ expect(loadAgent("/anywhere")).toBeNull();
178
+ } finally {
179
+ process.env.HOME = prevHome;
180
+ }
181
+ fs.rmSync(freshHome, { recursive: true, force: true });
182
+ });
183
+ test("rejects invalid name on load", () => {
184
+ const file = agentFilePath(tmpCwd);
185
+ fs.writeFileSync(file, "with space\n", "utf-8");
186
+ expect(loadAgent(tmpCwd)).toBeNull();
187
+ });
188
+ });
@@ -0,0 +1,47 @@
1
+ // =============================================================================
2
+ // tests/index.test.ts — Regression tests for index.ts handlers
3
+ // =============================================================================
4
+ //
5
+ // These exercise the agent-command dispatch without spinning up a real
6
+ // pi session. We test the parse logic by feeding the same input strings
7
+ // through a hand-rolled mock and inspecting the notify/output side-effects.
8
+
9
+ /// <reference types="bun-types" />
10
+ import { describe, test, expect } from "bun:test";
11
+ import { availableAgents } from "../core.js";
12
+
13
+ describe("/agent handler parse logic (regression for `/agent researcher` bug)", () => {
14
+ // The original bug: `/agent researcher` was interpreted as "show list"
15
+ // instead of "set agent to researcher" because the parser only checked
16
+ // the SECOND token, not the first.
17
+ test("single-arg '/agent <name>' is a set, not a list", () => {
18
+ const input = "researcher";
19
+ const parts = input.trim().split(/\s+/);
20
+ const subcommand = parts[0]?.toLowerCase();
21
+ const cycle = availableAgents();
22
+ // Single known agent → set, not show
23
+ expect(parts.length).toBe(1);
24
+ expect(cycle.includes(subcommand ?? "")).toBe(true);
25
+ });
26
+ test("'/agent create <name>' → create subcommand", () => {
27
+ const input = "create my-debugger";
28
+ const subcommand = input.trim().split(/\s+/)[0];
29
+ expect(subcommand).toBe("create");
30
+ });
31
+ test("'/agent doctor' → doctor subcommand", () => {
32
+ const input = "doctor";
33
+ const subcommand = input.trim().split(/\s+/)[0];
34
+ expect(subcommand).toBe("doctor");
35
+ });
36
+ test("'/agent recommend <task>' → recommend subcommand", () => {
37
+ const input = "recommend investigate the bug";
38
+ const subcommand = input.trim().split(/\s+/)[0];
39
+ expect(subcommand).toBe("recommend");
40
+ });
41
+ test("'/agent <unknown>' falls through to error (NOT set)", () => {
42
+ const input = "nonexistent-agent-xyz";
43
+ const subcommand = input.trim().split(/\s+/)[0];
44
+ const cycle = availableAgents();
45
+ expect(cycle.includes(subcommand ?? "")).toBe(false);
46
+ });
47
+ });
@@ -0,0 +1,106 @@
1
+ // =============================================================================
2
+ // tests/prompt.test.ts — Tests for the system-prompt section + recommendAgent
3
+ // =============================================================================
4
+
5
+ /// <reference types="bun-types" />
6
+ import { describe, test, expect } from "bun:test";
7
+ import { buildPiSwitchSection, recommendAgent, TASK_AGENT_HINTS } from "../prompt.js";
8
+
9
+ describe("buildPiSwitchSection", () => {
10
+ const s = buildPiSwitchSection();
11
+
12
+ test("starts with header", () => {
13
+ expect(s.trim().startsWith("## pi-switch")).toBe(true);
14
+ });
15
+ test("mentions /agent command and Ctrl+Shift+S", () => {
16
+ expect(s).toContain("/agent");
17
+ expect(s).toContain("Ctrl+Shift+S");
18
+ });
19
+ test("explains built-in categories", () => {
20
+ expect(s).toContain("oracle");
21
+ expect(s).toContain("scout");
22
+ expect(s).toContain("worker");
23
+ });
24
+ test("explains user-defined", () => {
25
+ expect(s).toMatch(/user[- ]?defined/i);
26
+ expect(s).toContain("~/.pi/agent/agents/");
27
+ });
28
+ test("has anti-patterns", () => {
29
+ expect(s).toContain("DON");
30
+ });
31
+ test("includes task→agent heuristics table", () => {
32
+ expect(s).toContain("researcher");
33
+ expect(s).toContain("debug");
34
+ expect(s).toContain("refactor");
35
+ });
36
+ test("is reasonably short (< 5KB)", () => {
37
+ expect(s.length).toBeLessThan(5000);
38
+ });
39
+ });
40
+
41
+ describe("TASK_AGENT_HINTS", () => {
42
+ test("every hint has required fields", () => {
43
+ for (const h of TASK_AGENT_HINTS) {
44
+ expect(h.agent.length).toBeGreaterThan(0);
45
+ expect(h.emoji.length).toBeGreaterThan(0);
46
+ expect(h.why.length).toBeGreaterThan(5);
47
+ expect(h.pattern).toBeInstanceOf(RegExp);
48
+ }
49
+ });
50
+ });
51
+
52
+ describe("recommendAgent", () => {
53
+ test("research keywords → researcher (English)", () => {
54
+ expect(recommendAgent("look up the latest pi-subagents API")?.agent).toBe("researcher");
55
+ expect(recommendAgent("what is the best lib for X?")?.agent).toBe("researcher");
56
+ });
57
+ test("research keywords → researcher (Russian)", () => {
58
+ expect(recommendAgent("Изучи React Server Components")?.agent).toBe("researcher");
59
+ expect(recommendAgent("Найди инфу про Zustand")?.agent).toBe("researcher");
60
+ });
61
+ test("debug keywords → soly-debugger", () => {
62
+ expect(recommendAgent("fix this bug")?.agent).toBe("soly-debugger");
63
+ expect(recommendAgent("why is this crash happening")?.agent).toBe("soly-debugger");
64
+ expect(recommendAgent("repro the failing test")?.agent).toBe("soly-debugger");
65
+ expect(recommendAgent("Почему падает тест?")?.agent).toBe("soly-debugger");
66
+ });
67
+ test("refactor keywords → soly-refactor", () => {
68
+ expect(recommendAgent("refactor this function")?.agent).toBe("soly-refactor");
69
+ expect(recommendAgent("simplify the auth flow")?.agent).toBe("soly-refactor");
70
+ expect(recommendAgent("Упрости эту функцию")?.agent).toBe("soly-refactor");
71
+ });
72
+ test("test keywords → soly-tester", () => {
73
+ expect(recommendAgent("write tests for the parser")?.agent).toBe("soly-tester");
74
+ expect(recommendAgent("improve coverage")?.agent).toBe("soly-tester");
75
+ expect(recommendAgent("Напиши тесты для парсера")?.agent).toBe("soly-tester");
76
+ });
77
+ test("review keywords → reviewer", () => {
78
+ expect(recommendAgent("review this PR")?.agent).toBe("reviewer");
79
+ expect(recommendAgent("audit the security")?.agent).toBe("reviewer");
80
+ expect(recommendAgent("Проверь этот код")?.agent).toBe("reviewer");
81
+ });
82
+ test("docs keywords → soly-documenter", () => {
83
+ expect(recommendAgent("update the readme")?.agent).toBe("soly-documenter");
84
+ expect(recommendAgent("add jsdoc to the function")?.agent).toBe("soly-documenter");
85
+ expect(recommendAgent("Обнови документацию")?.agent).toBe("soly-documenter");
86
+ });
87
+ test("plan keywords → planner", () => {
88
+ expect(recommendAgent("plan the migration")?.agent).toBe("planner");
89
+ expect(recommendAgent("design the API")?.agent).toBe("planner");
90
+ expect(recommendAgent("Спланируй миграцию")?.agent).toBe("planner");
91
+ });
92
+ test("implement keywords → worker", () => {
93
+ expect(recommendAgent("implement the feature")?.agent).toBe("worker");
94
+ expect(recommendAgent("build the auth module")?.agent).toBe("worker");
95
+ expect(recommendAgent("Сделай эту фичу")?.agent).toBe("worker");
96
+ });
97
+ test("no match → null", () => {
98
+ expect(recommendAgent("hello world")).toBeNull();
99
+ expect(recommendAgent("")).toBeNull();
100
+ });
101
+ test("returns emoji and why", () => {
102
+ const r = recommendAgent("fix this bug");
103
+ expect(r?.emoji).toBeTruthy();
104
+ expect(r?.why).toBeTruthy();
105
+ });
106
+ });
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "nodenext",
5
+ "moduleResolution": "nodenext",
6
+ "lib": [
7
+ "esnext"
8
+ ],
9
+ "types": [
10
+ "node"
11
+ ],
12
+ "skipLibCheck": true,
13
+ "noEmit": true,
14
+ "strict": true,
15
+ "esModuleInterop": true,
16
+ "allowSyntheticDefaultImports": true,
17
+ "resolveJsonModule": true,
18
+ "forceConsistentCasingInFileNames": true,
19
+ "noUncheckedIndexedAccess": false,
20
+ "allowImportingTsExtensions": true
21
+ },
22
+ "include": [
23
+ "**/*.ts"
24
+ ],
25
+ "exclude": [
26
+ "node_modules"
27
+ ]
28
+ }