@aiyou-dev/cli 0.1.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.
- package/bin/aiyoucli-mcp.js +7 -0
- package/bin/aiyoucli.js +29 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +968 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +99 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +149 -0
- package/dist/index.js.map +1 -0
- package/dist/init/agentsmd-generator.d.ts +13 -0
- package/dist/init/agentsmd-generator.d.ts.map +1 -0
- package/dist/init/agentsmd-generator.js +138 -0
- package/dist/init/agentsmd-generator.js.map +1 -0
- package/dist/init/interactive.d.ts +6 -0
- package/dist/init/interactive.d.ts.map +1 -0
- package/dist/init/interactive.js +288 -0
- package/dist/init/interactive.js.map +1 -0
- package/dist/init/settings-generator.d.ts +17 -0
- package/dist/init/settings-generator.d.ts.map +1 -0
- package/dist/init/settings-generator.js +132 -0
- package/dist/init/settings-generator.js.map +1 -0
- package/dist/mcp/client.d.ts +27 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +93 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/server.d.ts +8 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +74 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/agent-tools.d.ts +6 -0
- package/dist/mcp/tools/agent-tools.d.ts.map +1 -0
- package/dist/mcp/tools/agent-tools.js +196 -0
- package/dist/mcp/tools/agent-tools.js.map +1 -0
- package/dist/mcp/tools/analyze-tools.d.ts +6 -0
- package/dist/mcp/tools/analyze-tools.d.ts.map +1 -0
- package/dist/mcp/tools/analyze-tools.js +49 -0
- package/dist/mcp/tools/analyze-tools.js.map +1 -0
- package/dist/mcp/tools/config-tools.d.ts +6 -0
- package/dist/mcp/tools/config-tools.d.ts.map +1 -0
- package/dist/mcp/tools/config-tools.js +69 -0
- package/dist/mcp/tools/config-tools.js.map +1 -0
- package/dist/mcp/tools/coordination-tools.d.ts +6 -0
- package/dist/mcp/tools/coordination-tools.d.ts.map +1 -0
- package/dist/mcp/tools/coordination-tools.js +44 -0
- package/dist/mcp/tools/coordination-tools.js.map +1 -0
- package/dist/mcp/tools/distiller-tools.d.ts +7 -0
- package/dist/mcp/tools/distiller-tools.d.ts.map +1 -0
- package/dist/mcp/tools/distiller-tools.js +50 -0
- package/dist/mcp/tools/distiller-tools.js.map +1 -0
- package/dist/mcp/tools/gcc-tools.d.ts +6 -0
- package/dist/mcp/tools/gcc-tools.d.ts.map +1 -0
- package/dist/mcp/tools/gcc-tools.js +37 -0
- package/dist/mcp/tools/gcc-tools.js.map +1 -0
- package/dist/mcp/tools/hooks-tools.d.ts +7 -0
- package/dist/mcp/tools/hooks-tools.d.ts.map +1 -0
- package/dist/mcp/tools/hooks-tools.js +125 -0
- package/dist/mcp/tools/hooks-tools.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +5 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +43 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/memory-tools.d.ts +7 -0
- package/dist/mcp/tools/memory-tools.d.ts.map +1 -0
- package/dist/mcp/tools/memory-tools.js +153 -0
- package/dist/mcp/tools/memory-tools.js.map +1 -0
- package/dist/mcp/tools/metrics-tools.d.ts +6 -0
- package/dist/mcp/tools/metrics-tools.d.ts.map +1 -0
- package/dist/mcp/tools/metrics-tools.js +126 -0
- package/dist/mcp/tools/metrics-tools.js.map +1 -0
- package/dist/mcp/tools/neural-tools.d.ts +11 -0
- package/dist/mcp/tools/neural-tools.d.ts.map +1 -0
- package/dist/mcp/tools/neural-tools.js +68 -0
- package/dist/mcp/tools/neural-tools.js.map +1 -0
- package/dist/mcp/tools/performance-tools.d.ts +6 -0
- package/dist/mcp/tools/performance-tools.d.ts.map +1 -0
- package/dist/mcp/tools/performance-tools.js +54 -0
- package/dist/mcp/tools/performance-tools.js.map +1 -0
- package/dist/mcp/tools/security-tools.d.ts +6 -0
- package/dist/mcp/tools/security-tools.d.ts.map +1 -0
- package/dist/mcp/tools/security-tools.js +51 -0
- package/dist/mcp/tools/security-tools.js.map +1 -0
- package/dist/mcp/tools/session-tools.d.ts +6 -0
- package/dist/mcp/tools/session-tools.d.ts.map +1 -0
- package/dist/mcp/tools/session-tools.js +85 -0
- package/dist/mcp/tools/session-tools.js.map +1 -0
- package/dist/mcp/tools/skills-tools.d.ts +9 -0
- package/dist/mcp/tools/skills-tools.d.ts.map +1 -0
- package/dist/mcp/tools/skills-tools.js +167 -0
- package/dist/mcp/tools/skills-tools.js.map +1 -0
- package/dist/mcp/tools/statusline-tools.d.ts +6 -0
- package/dist/mcp/tools/statusline-tools.d.ts.map +1 -0
- package/dist/mcp/tools/statusline-tools.js +26 -0
- package/dist/mcp/tools/statusline-tools.js.map +1 -0
- package/dist/mcp/tools/swarm-tools.d.ts +6 -0
- package/dist/mcp/tools/swarm-tools.d.ts.map +1 -0
- package/dist/mcp/tools/swarm-tools.js +75 -0
- package/dist/mcp/tools/swarm-tools.js.map +1 -0
- package/dist/mcp/tools/system-tools.d.ts +6 -0
- package/dist/mcp/tools/system-tools.d.ts.map +1 -0
- package/dist/mcp/tools/system-tools.js +68 -0
- package/dist/mcp/tools/system-tools.js.map +1 -0
- package/dist/mcp/tools/task-tools.d.ts +6 -0
- package/dist/mcp/tools/task-tools.d.ts.map +1 -0
- package/dist/mcp/tools/task-tools.js +102 -0
- package/dist/mcp/tools/task-tools.js.map +1 -0
- package/dist/mcp/types.d.ts +19 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +5 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/metrics/benchmark.d.ts +95 -0
- package/dist/metrics/benchmark.d.ts.map +1 -0
- package/dist/metrics/benchmark.js +195 -0
- package/dist/metrics/benchmark.js.map +1 -0
- package/dist/metrics/builtin-benchmarks.d.ts +9 -0
- package/dist/metrics/builtin-benchmarks.d.ts.map +1 -0
- package/dist/metrics/builtin-benchmarks.js +171 -0
- package/dist/metrics/builtin-benchmarks.js.map +1 -0
- package/dist/metrics/collector.d.ts +89 -0
- package/dist/metrics/collector.d.ts.map +1 -0
- package/dist/metrics/collector.js +181 -0
- package/dist/metrics/collector.js.map +1 -0
- package/dist/napi/index.d.ts +159 -0
- package/dist/napi/index.d.ts.map +1 -0
- package/dist/napi/index.js +111 -0
- package/dist/napi/index.js.map +1 -0
- package/dist/output.d.ts +44 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +138 -0
- package/dist/output.js.map +1 -0
- package/dist/parser.d.ts +12 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +135 -0
- package/dist/parser.js.map +1 -0
- package/dist/production/circuit-breaker.d.ts +31 -0
- package/dist/production/circuit-breaker.d.ts.map +1 -0
- package/dist/production/circuit-breaker.js +87 -0
- package/dist/production/circuit-breaker.js.map +1 -0
- package/dist/production/error-handler.d.ts +13 -0
- package/dist/production/error-handler.d.ts.map +1 -0
- package/dist/production/error-handler.js +52 -0
- package/dist/production/error-handler.js.map +1 -0
- package/dist/production/index.d.ts +9 -0
- package/dist/production/index.d.ts.map +1 -0
- package/dist/production/index.js +5 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/rate-limiter.d.ts +22 -0
- package/dist/production/rate-limiter.d.ts.map +1 -0
- package/dist/production/rate-limiter.js +44 -0
- package/dist/production/rate-limiter.js.map +1 -0
- package/dist/production/retry.d.ts +9 -0
- package/dist/production/retry.d.ts.map +1 -0
- package/dist/production/retry.js +32 -0
- package/dist/production/retry.js.map +1 -0
- package/dist/services/worker-daemon.d.ts +44 -0
- package/dist/services/worker-daemon.d.ts.map +1 -0
- package/dist/services/worker-daemon.js +99 -0
- package/dist/services/worker-daemon.js.map +1 -0
- package/dist/services/worker-queue.d.ts +38 -0
- package/dist/services/worker-queue.d.ts.map +1 -0
- package/dist/services/worker-queue.js +86 -0
- package/dist/services/worker-queue.js.map +1 -0
- package/dist/statusline/generator.d.ts +12 -0
- package/dist/statusline/generator.d.ts.map +1 -0
- package/dist/statusline/generator.js +361 -0
- package/dist/statusline/generator.js.map +1 -0
- package/dist/suggest.d.ts +5 -0
- package/dist/suggest.d.ts.map +1 -0
- package/dist/suggest.js +40 -0
- package/dist/suggest.js.map +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +23 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command definitions — thin wrappers over MCP tools.
|
|
3
|
+
*
|
|
4
|
+
* Each command parses flags/args, calls the appropriate MCP tool via
|
|
5
|
+
* `callTool`, and formats the result using `output`/`color`.
|
|
6
|
+
*/
|
|
7
|
+
import { callTool, registry } from "../mcp/client.js";
|
|
8
|
+
import { output, color } from "../output.js";
|
|
9
|
+
import { registerAllTools } from "../mcp/tools/index.js";
|
|
10
|
+
import { startMCPServer } from "../mcp/server.js";
|
|
11
|
+
import { generateAgentsMd } from "../init/agentsmd-generator.js";
|
|
12
|
+
import { generateSettings } from "../init/settings-generator.js";
|
|
13
|
+
import { interactiveInit } from "../init/interactive.js";
|
|
14
|
+
import { renderStatusline, generateStatuslineScript } from "../statusline/generator.js";
|
|
15
|
+
// ── Helpers ────────────────────────────────────────────────────────
|
|
16
|
+
let toolsRegistered = false;
|
|
17
|
+
function ensureTools() {
|
|
18
|
+
if (!toolsRegistered) {
|
|
19
|
+
registerAllTools();
|
|
20
|
+
toolsRegistered = true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Print the text content from a tool result. */
|
|
24
|
+
function printResult(result) {
|
|
25
|
+
const text = result.content[0]?.text ?? "";
|
|
26
|
+
if (result.isError) {
|
|
27
|
+
output.error(text);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
output.log(text);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Try to pretty-print JSON, fall back to raw text. */
|
|
34
|
+
function printJson(result) {
|
|
35
|
+
const raw = result.content[0]?.text ?? "";
|
|
36
|
+
if (result.isError) {
|
|
37
|
+
output.error(raw);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const data = JSON.parse(raw);
|
|
42
|
+
output.json(data);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
output.log(raw);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// ── 1. init ────────────────────────────────────────────────────────
|
|
49
|
+
const initCommand = {
|
|
50
|
+
name: "init",
|
|
51
|
+
description: "Initialize project (AGENTS.md, settings, skills)",
|
|
52
|
+
options: [
|
|
53
|
+
{ name: "force", short: "f", description: "Overwrite existing files", type: "boolean" },
|
|
54
|
+
{ name: "skip-skills", description: "Skip interactive skills setup", type: "boolean" },
|
|
55
|
+
],
|
|
56
|
+
action: async (ctx) => {
|
|
57
|
+
const cwd = ctx.cwd;
|
|
58
|
+
const spinner = output.spinner("Initializing project...");
|
|
59
|
+
spinner.start();
|
|
60
|
+
const created = [];
|
|
61
|
+
try {
|
|
62
|
+
const agentsMdPath = await generateAgentsMd(cwd);
|
|
63
|
+
created.push(agentsMdPath);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
67
|
+
if (msg.includes("already exists") && !ctx.flags.force) {
|
|
68
|
+
output.debug("AGENTS.md already exists, skipping");
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
spinner.fail(`Failed to generate AGENTS.md: ${msg}`);
|
|
72
|
+
return { success: false, exitCode: 1 };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const settingsPaths = await generateSettings(cwd);
|
|
77
|
+
created.push(...settingsPaths);
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
81
|
+
spinner.fail(`Failed to generate settings: ${msg}`);
|
|
82
|
+
return { success: false, exitCode: 1 };
|
|
83
|
+
}
|
|
84
|
+
spinner.succeed("Project initialized");
|
|
85
|
+
for (const path of created) {
|
|
86
|
+
output.log(` ${color.green("+")} ${path.replace(cwd + "/", "")}`);
|
|
87
|
+
}
|
|
88
|
+
// Interactive skills setup (if terminal is interactive)
|
|
89
|
+
if (!ctx.flags["skip-skills"] && ctx.interactive) {
|
|
90
|
+
try {
|
|
91
|
+
const skillPaths = await interactiveInit(cwd);
|
|
92
|
+
created.push(...skillPaths);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Non-critical — skills are optional
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
output.log("");
|
|
99
|
+
return { success: true };
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
// ── 2. agent ───────────────────────────────────────────────────────
|
|
103
|
+
const agentCommand = {
|
|
104
|
+
name: "agent",
|
|
105
|
+
description: "Agent lifecycle (spawn, list, stop, record, metrics)",
|
|
106
|
+
subcommands: [
|
|
107
|
+
{
|
|
108
|
+
name: "spawn",
|
|
109
|
+
description: "Spawn a new agent",
|
|
110
|
+
options: [
|
|
111
|
+
{ name: "type", short: "t", description: "Agent type", type: "string" },
|
|
112
|
+
{ name: "name", short: "n", description: "Agent name", type: "string" },
|
|
113
|
+
{ name: "model", short: "m", description: "Model: haiku, sonnet, opus", type: "string" },
|
|
114
|
+
],
|
|
115
|
+
action: async (ctx) => {
|
|
116
|
+
ensureTools();
|
|
117
|
+
const result = await callTool("agent_spawn", {
|
|
118
|
+
type: ctx.flags.type || ctx.flags.t || ctx.args[0] || "coder",
|
|
119
|
+
name: ctx.flags.name || ctx.flags.n || ctx.args[1],
|
|
120
|
+
model: ctx.flags.model || ctx.flags.m,
|
|
121
|
+
});
|
|
122
|
+
printJson(result);
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "list",
|
|
127
|
+
description: "List active agents",
|
|
128
|
+
action: async () => {
|
|
129
|
+
ensureTools();
|
|
130
|
+
const result = await callTool("agent_list", {});
|
|
131
|
+
printJson(result);
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: "status",
|
|
136
|
+
description: "Get agent status",
|
|
137
|
+
options: [
|
|
138
|
+
{ name: "id", description: "Agent ID", type: "string", required: true },
|
|
139
|
+
],
|
|
140
|
+
action: async (ctx) => {
|
|
141
|
+
ensureTools();
|
|
142
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
143
|
+
if (!id) {
|
|
144
|
+
output.error("Agent ID required: --id <id>");
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const result = await callTool("agent_status", { id });
|
|
148
|
+
printJson(result);
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "stop",
|
|
153
|
+
description: "Stop an agent",
|
|
154
|
+
options: [
|
|
155
|
+
{ name: "id", description: "Agent ID", type: "string", required: true },
|
|
156
|
+
],
|
|
157
|
+
action: async (ctx) => {
|
|
158
|
+
ensureTools();
|
|
159
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
160
|
+
if (!id) {
|
|
161
|
+
output.error("Agent ID required: --id <id>");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const result = await callTool("agent_stop", { id });
|
|
165
|
+
printResult(result);
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "record",
|
|
170
|
+
description: "Record a task outcome for an agent",
|
|
171
|
+
options: [
|
|
172
|
+
{ name: "id", description: "Agent ID", type: "string", required: true },
|
|
173
|
+
{ name: "success", description: "Task succeeded (true/false)", type: "string", required: true },
|
|
174
|
+
{ name: "duration-ms", description: "Task duration in ms", type: "number" },
|
|
175
|
+
],
|
|
176
|
+
action: async (ctx) => {
|
|
177
|
+
ensureTools();
|
|
178
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
179
|
+
if (!id) {
|
|
180
|
+
output.error("Agent ID required: --id <id>");
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const success = String(ctx.flags.success ?? ctx.args[1]).toLowerCase() === "true";
|
|
184
|
+
const result = await callTool("agent_record", {
|
|
185
|
+
id,
|
|
186
|
+
success,
|
|
187
|
+
duration_ms: ctx.flags["duration-ms"] ?? 0,
|
|
188
|
+
});
|
|
189
|
+
printJson(result);
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "metrics",
|
|
194
|
+
description: "Get aggregated metrics across all agents",
|
|
195
|
+
action: async () => {
|
|
196
|
+
ensureTools();
|
|
197
|
+
const result = await callTool("agent_metrics", {});
|
|
198
|
+
printJson(result);
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
};
|
|
203
|
+
// ── 3. swarm ───────────────────────────────────────────────────────
|
|
204
|
+
const swarmCommand = {
|
|
205
|
+
name: "swarm",
|
|
206
|
+
description: "Swarm coordination (init, status, stop)",
|
|
207
|
+
subcommands: [
|
|
208
|
+
{
|
|
209
|
+
name: "init",
|
|
210
|
+
description: "Initialize a multi-agent swarm",
|
|
211
|
+
options: [
|
|
212
|
+
{ name: "topology", description: "hierarchical, mesh, ring, star, hybrid", type: "string" },
|
|
213
|
+
{ name: "maxAgents", description: "Maximum agents (default: 8)", type: "number" },
|
|
214
|
+
{ name: "strategy", description: "specialized, balanced, adaptive", type: "string" },
|
|
215
|
+
],
|
|
216
|
+
action: async (ctx) => {
|
|
217
|
+
ensureTools();
|
|
218
|
+
const result = await callTool("swarm_init", {
|
|
219
|
+
topology: ctx.flags.topology || "hierarchical",
|
|
220
|
+
maxAgents: ctx.flags.maxAgents || 8,
|
|
221
|
+
strategy: ctx.flags.strategy || "specialized",
|
|
222
|
+
});
|
|
223
|
+
printJson(result);
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "status",
|
|
228
|
+
description: "Get swarm status",
|
|
229
|
+
action: async () => {
|
|
230
|
+
ensureTools();
|
|
231
|
+
const result = await callTool("swarm_status", {});
|
|
232
|
+
printJson(result);
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: "stop",
|
|
237
|
+
description: "Stop the active swarm",
|
|
238
|
+
action: async () => {
|
|
239
|
+
ensureTools();
|
|
240
|
+
const result = await callTool("swarm_stop", {});
|
|
241
|
+
printResult(result);
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
};
|
|
246
|
+
// ── 4. memory ──────────────────────────────────────────────────────
|
|
247
|
+
const memoryCommand = {
|
|
248
|
+
name: "memory",
|
|
249
|
+
description: "Vector memory (store, search, list)",
|
|
250
|
+
subcommands: [
|
|
251
|
+
{
|
|
252
|
+
name: "init",
|
|
253
|
+
description: "Initialize memory database",
|
|
254
|
+
options: [
|
|
255
|
+
{ name: "path", short: "p", description: "Storage path (omit for in-memory)", type: "string" },
|
|
256
|
+
{ name: "dimensions", short: "d", description: "Vector dimensions (default: 384)", type: "number" },
|
|
257
|
+
],
|
|
258
|
+
action: async (ctx) => {
|
|
259
|
+
ensureTools();
|
|
260
|
+
const result = await callTool("memory_init", {
|
|
261
|
+
path: ctx.flags.path || ctx.flags.p,
|
|
262
|
+
dimensions: ctx.flags.dimensions || ctx.flags.d,
|
|
263
|
+
});
|
|
264
|
+
printResult(result);
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "store",
|
|
269
|
+
description: "Store a vector",
|
|
270
|
+
options: [
|
|
271
|
+
{ name: "vector", description: "Comma-separated vector values", type: "string", required: true },
|
|
272
|
+
{ name: "id", description: "Optional vector ID", type: "string" },
|
|
273
|
+
],
|
|
274
|
+
action: async (ctx) => {
|
|
275
|
+
ensureTools();
|
|
276
|
+
const raw = ctx.flags.vector || ctx.args[0];
|
|
277
|
+
if (!raw) {
|
|
278
|
+
output.error("Vector required: --vector '1.0,2.0,3.0'");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const cleaned = String(raw).replace(/[\[\]\s]/g, "");
|
|
282
|
+
const vector = cleaned.split(",").map(Number);
|
|
283
|
+
const result = await callTool("memory_store", {
|
|
284
|
+
vector,
|
|
285
|
+
id: ctx.flags.id,
|
|
286
|
+
});
|
|
287
|
+
printResult(result);
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: "search",
|
|
292
|
+
description: "Search similar vectors",
|
|
293
|
+
options: [
|
|
294
|
+
{ name: "vector", description: "Comma-separated query vector", type: "string", required: true },
|
|
295
|
+
{ name: "k", short: "k", description: "Number of results (default: 5)", type: "number" },
|
|
296
|
+
],
|
|
297
|
+
action: async (ctx) => {
|
|
298
|
+
ensureTools();
|
|
299
|
+
const raw = ctx.flags.vector || ctx.args[0];
|
|
300
|
+
if (!raw) {
|
|
301
|
+
output.error("Query vector required: --vector '1.0,2.0,3.0'");
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
const cleaned = String(raw).replace(/[\[\]\s]/g, "");
|
|
305
|
+
const vector = cleaned.split(",").map(Number);
|
|
306
|
+
const result = await callTool("memory_search", {
|
|
307
|
+
vector,
|
|
308
|
+
k: ctx.flags.k || 5,
|
|
309
|
+
});
|
|
310
|
+
printJson(result);
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
name: "list",
|
|
315
|
+
description: "Show vector count",
|
|
316
|
+
action: async () => {
|
|
317
|
+
ensureTools();
|
|
318
|
+
const result = await callTool("memory_count", {});
|
|
319
|
+
printResult(result);
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "stats",
|
|
324
|
+
description: "Show memory statistics",
|
|
325
|
+
action: async () => {
|
|
326
|
+
ensureTools();
|
|
327
|
+
const result = await callTool("memory_stats", {});
|
|
328
|
+
printJson(result);
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: "delete",
|
|
333
|
+
description: "Delete a vector by ID",
|
|
334
|
+
options: [
|
|
335
|
+
{ name: "id", description: "Vector ID", type: "string", required: true },
|
|
336
|
+
],
|
|
337
|
+
action: async (ctx) => {
|
|
338
|
+
ensureTools();
|
|
339
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
340
|
+
if (!id) {
|
|
341
|
+
output.error("Vector ID required: --id <id>");
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const result = await callTool("memory_delete", { id });
|
|
345
|
+
printResult(result);
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
};
|
|
350
|
+
// ── 5. mcp ─────────────────────────────────────────────────────────
|
|
351
|
+
const mcpCommand = {
|
|
352
|
+
name: "mcp",
|
|
353
|
+
description: "MCP server management",
|
|
354
|
+
subcommands: [
|
|
355
|
+
{
|
|
356
|
+
name: "start",
|
|
357
|
+
description: "Start MCP stdio server",
|
|
358
|
+
action: async () => {
|
|
359
|
+
startMCPServer();
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "status",
|
|
364
|
+
description: "Show MCP server info",
|
|
365
|
+
action: async () => {
|
|
366
|
+
ensureTools();
|
|
367
|
+
const tools = registry.list();
|
|
368
|
+
output.log(color.bold("MCP Server"));
|
|
369
|
+
output.log(` Transport: stdio`);
|
|
370
|
+
output.log(` Protocol: 2024-11-05`);
|
|
371
|
+
output.log(` Tools: ${tools.length} registered`);
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: "tools",
|
|
376
|
+
description: "List available MCP tools",
|
|
377
|
+
action: async () => {
|
|
378
|
+
ensureTools();
|
|
379
|
+
const tools = registry.listForMCP();
|
|
380
|
+
const rows = tools.map((t) => [t.name, t.description]);
|
|
381
|
+
output.table(["Tool", "Description"], rows);
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
],
|
|
385
|
+
};
|
|
386
|
+
// ── 6. task ────────────────────────────────────────────────────────
|
|
387
|
+
const taskCommand = {
|
|
388
|
+
name: "task",
|
|
389
|
+
description: "Task management",
|
|
390
|
+
subcommands: [
|
|
391
|
+
{
|
|
392
|
+
name: "create",
|
|
393
|
+
description: "Create a new task",
|
|
394
|
+
options: [
|
|
395
|
+
{ name: "description", short: "d", description: "Task description", type: "string", required: true },
|
|
396
|
+
{ name: "priority", short: "p", description: "low, normal, high, critical", type: "string" },
|
|
397
|
+
{ name: "assignTo", short: "a", description: "Agent ID to assign", type: "string" },
|
|
398
|
+
],
|
|
399
|
+
action: async (ctx) => {
|
|
400
|
+
ensureTools();
|
|
401
|
+
const description = ctx.flags.description || ctx.flags.d || ctx.args.join(" ");
|
|
402
|
+
if (!description) {
|
|
403
|
+
output.error("Description required: --description <text>");
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const result = await callTool("task_create", {
|
|
407
|
+
description,
|
|
408
|
+
priority: ctx.flags.priority || ctx.flags.p,
|
|
409
|
+
assignTo: ctx.flags.assignTo || ctx.flags.a,
|
|
410
|
+
});
|
|
411
|
+
printJson(result);
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name: "list",
|
|
416
|
+
description: "List all tasks",
|
|
417
|
+
options: [
|
|
418
|
+
{ name: "status", short: "s", description: "Filter by status", type: "string" },
|
|
419
|
+
],
|
|
420
|
+
action: async (ctx) => {
|
|
421
|
+
ensureTools();
|
|
422
|
+
const result = await callTool("task_list", {
|
|
423
|
+
status: ctx.flags.status || ctx.flags.s,
|
|
424
|
+
});
|
|
425
|
+
printJson(result);
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
name: "status",
|
|
430
|
+
description: "Get task status",
|
|
431
|
+
options: [
|
|
432
|
+
{ name: "id", description: "Task ID", type: "string", required: true },
|
|
433
|
+
],
|
|
434
|
+
action: async (ctx) => {
|
|
435
|
+
ensureTools();
|
|
436
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
437
|
+
if (!id) {
|
|
438
|
+
output.error("Task ID required: --id <id>");
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const result = await callTool("task_status", { id });
|
|
442
|
+
printJson(result);
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
name: "complete",
|
|
447
|
+
description: "Mark a task as completed",
|
|
448
|
+
options: [
|
|
449
|
+
{ name: "id", description: "Task ID", type: "string", required: true },
|
|
450
|
+
],
|
|
451
|
+
action: async (ctx) => {
|
|
452
|
+
ensureTools();
|
|
453
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
454
|
+
if (!id) {
|
|
455
|
+
output.error("Task ID required: --id <id>");
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
const result = await callTool("task_complete", { id });
|
|
459
|
+
printResult(result);
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
],
|
|
463
|
+
};
|
|
464
|
+
// ── 7. session ─────────────────────────────────────────────────────
|
|
465
|
+
const sessionCommand = {
|
|
466
|
+
name: "session",
|
|
467
|
+
description: "Session management",
|
|
468
|
+
subcommands: [
|
|
469
|
+
{
|
|
470
|
+
name: "start",
|
|
471
|
+
description: "Start a new session",
|
|
472
|
+
options: [
|
|
473
|
+
{ name: "id", description: "Session ID (auto-generated if omitted)", type: "string" },
|
|
474
|
+
],
|
|
475
|
+
action: async (ctx) => {
|
|
476
|
+
ensureTools();
|
|
477
|
+
const result = await callTool("session_start", {
|
|
478
|
+
id: ctx.flags.id || ctx.args[0],
|
|
479
|
+
});
|
|
480
|
+
printJson(result);
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
name: "end",
|
|
485
|
+
description: "End a session",
|
|
486
|
+
options: [
|
|
487
|
+
{ name: "id", description: "Session ID", type: "string", required: true },
|
|
488
|
+
],
|
|
489
|
+
action: async (ctx) => {
|
|
490
|
+
ensureTools();
|
|
491
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
492
|
+
if (!id) {
|
|
493
|
+
output.error("Session ID required: --id <id>");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const result = await callTool("session_end", { id });
|
|
497
|
+
printResult(result);
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
name: "list",
|
|
502
|
+
description: "List all sessions",
|
|
503
|
+
action: async () => {
|
|
504
|
+
ensureTools();
|
|
505
|
+
const result = await callTool("session_list", {});
|
|
506
|
+
printJson(result);
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
],
|
|
510
|
+
};
|
|
511
|
+
// ── 8. hooks ───────────────────────────────────────────────────────
|
|
512
|
+
const hooksCommand = {
|
|
513
|
+
name: "hooks",
|
|
514
|
+
description: "Lifecycle hooks + workers",
|
|
515
|
+
subcommands: [
|
|
516
|
+
{
|
|
517
|
+
name: "route",
|
|
518
|
+
description: "Route a task to optimal agent",
|
|
519
|
+
options: [
|
|
520
|
+
{ name: "task", short: "t", description: "Task description", type: "string", required: true },
|
|
521
|
+
],
|
|
522
|
+
action: async (ctx) => {
|
|
523
|
+
ensureTools();
|
|
524
|
+
const task = ctx.flags.task || ctx.flags.t || ctx.args.join(" ");
|
|
525
|
+
if (!task) {
|
|
526
|
+
output.error("Task description required: --task <text>");
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const result = await callTool("hooks_route", { task });
|
|
530
|
+
printJson(result);
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
name: "pre-task",
|
|
535
|
+
description: "Pre-task hook (routing recommendation)",
|
|
536
|
+
options: [
|
|
537
|
+
{ name: "description", short: "d", description: "Task description", type: "string", required: true },
|
|
538
|
+
],
|
|
539
|
+
action: async (ctx) => {
|
|
540
|
+
ensureTools();
|
|
541
|
+
const description = ctx.flags.description || ctx.flags.d || ctx.args.join(" ");
|
|
542
|
+
if (!description) {
|
|
543
|
+
output.error("Description required: --description <text>");
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const result = await callTool("hooks_pre_task", { description });
|
|
547
|
+
printJson(result);
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
name: "post-task",
|
|
552
|
+
description: "Post-task hook (record outcome)",
|
|
553
|
+
options: [
|
|
554
|
+
{ name: "description", short: "d", description: "Task description", type: "string", required: true },
|
|
555
|
+
{ name: "agent", short: "a", description: "Agent type used", type: "string", required: true },
|
|
556
|
+
{ name: "success", short: "s", description: "Whether task succeeded", type: "boolean", required: true },
|
|
557
|
+
],
|
|
558
|
+
action: async (ctx) => {
|
|
559
|
+
ensureTools();
|
|
560
|
+
const description = ctx.flags.description || ctx.flags.d;
|
|
561
|
+
const agent = ctx.flags.agent || ctx.flags.a;
|
|
562
|
+
const success = ctx.flags.success ?? ctx.flags.s ?? true;
|
|
563
|
+
if (!description || !agent) {
|
|
564
|
+
output.error("Required: --description <text> --agent <type> --success");
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
const result = await callTool("hooks_post_task", {
|
|
568
|
+
description,
|
|
569
|
+
agent,
|
|
570
|
+
success: success === true || success === "true",
|
|
571
|
+
});
|
|
572
|
+
printResult(result);
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: "stats",
|
|
577
|
+
description: "Routing engine statistics",
|
|
578
|
+
action: async () => {
|
|
579
|
+
ensureTools();
|
|
580
|
+
const result = await callTool("hooks_stats", {});
|
|
581
|
+
printJson(result);
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
],
|
|
585
|
+
};
|
|
586
|
+
// ── 9. config ──────────────────────────────────────────────────────
|
|
587
|
+
const configCommand = {
|
|
588
|
+
name: "config",
|
|
589
|
+
description: "Configuration",
|
|
590
|
+
subcommands: [
|
|
591
|
+
{
|
|
592
|
+
name: "get",
|
|
593
|
+
description: "Get configuration value",
|
|
594
|
+
options: [
|
|
595
|
+
{ name: "key", short: "k", description: "Config key path (omit for full config)", type: "string" },
|
|
596
|
+
],
|
|
597
|
+
action: async (ctx) => {
|
|
598
|
+
ensureTools();
|
|
599
|
+
const result = await callTool("config_get", {
|
|
600
|
+
key: ctx.flags.key || ctx.flags.k || ctx.args[0],
|
|
601
|
+
});
|
|
602
|
+
printJson(result);
|
|
603
|
+
},
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
name: "set",
|
|
607
|
+
description: "Set configuration value",
|
|
608
|
+
options: [
|
|
609
|
+
{ name: "key", short: "k", description: "Config key path", type: "string", required: true },
|
|
610
|
+
{ name: "value", short: "v", description: "New value", type: "string", required: true },
|
|
611
|
+
],
|
|
612
|
+
action: async (ctx) => {
|
|
613
|
+
ensureTools();
|
|
614
|
+
const key = ctx.flags.key || ctx.flags.k || ctx.args[0];
|
|
615
|
+
const value = ctx.flags.value || ctx.flags.v || ctx.args[1];
|
|
616
|
+
if (!key || value === undefined) {
|
|
617
|
+
output.error("Required: --key <path> --value <val>");
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const result = await callTool("config_set", { key, value });
|
|
621
|
+
printResult(result);
|
|
622
|
+
},
|
|
623
|
+
},
|
|
624
|
+
],
|
|
625
|
+
};
|
|
626
|
+
// ── 10. status ─────────────────────────────────────────────────────
|
|
627
|
+
const statusCommand = {
|
|
628
|
+
name: "status",
|
|
629
|
+
description: "System status",
|
|
630
|
+
action: async () => {
|
|
631
|
+
ensureTools();
|
|
632
|
+
const result = await callTool("system_status", {});
|
|
633
|
+
printJson(result);
|
|
634
|
+
},
|
|
635
|
+
};
|
|
636
|
+
// ── 11. doctor ─────────────────────────────────────────────────────
|
|
637
|
+
const doctorCommand = {
|
|
638
|
+
name: "doctor",
|
|
639
|
+
description: "Health diagnostics",
|
|
640
|
+
action: async () => {
|
|
641
|
+
ensureTools();
|
|
642
|
+
const result = await callTool("system_doctor", {});
|
|
643
|
+
const raw = result.content[0]?.text ?? "{}";
|
|
644
|
+
try {
|
|
645
|
+
const data = JSON.parse(raw);
|
|
646
|
+
output.log(color.bold("\naiyoucli doctor\n"));
|
|
647
|
+
for (const check of data.checks) {
|
|
648
|
+
const icon = check.status === "ok" ? color.green("OK") : color.red("FAIL");
|
|
649
|
+
const detail = check.detail ? ` (${check.detail})` : "";
|
|
650
|
+
output.log(` ${check.name.padEnd(16)}${icon}${detail}`);
|
|
651
|
+
}
|
|
652
|
+
output.log("");
|
|
653
|
+
}
|
|
654
|
+
catch {
|
|
655
|
+
printJson(result);
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
};
|
|
659
|
+
// ── 12. neural ─────────────────────────────────────────────────────
|
|
660
|
+
const neuralCommand = {
|
|
661
|
+
name: "neural",
|
|
662
|
+
description: "Neural training + prediction",
|
|
663
|
+
subcommands: [
|
|
664
|
+
{
|
|
665
|
+
name: "observe",
|
|
666
|
+
description: "Submit observation to SONA engine",
|
|
667
|
+
options: [
|
|
668
|
+
{ name: "embedding", description: "Comma-separated embedding vector", type: "string", required: true },
|
|
669
|
+
{ name: "quality", short: "q", description: "Quality score 0.0-1.0", type: "number", required: true },
|
|
670
|
+
{ name: "kind", short: "k", description: "Kind: commit, test, edit", type: "string" },
|
|
671
|
+
],
|
|
672
|
+
action: async (ctx) => {
|
|
673
|
+
ensureTools();
|
|
674
|
+
const raw = ctx.flags.embedding;
|
|
675
|
+
const quality = ctx.flags.quality || ctx.flags.q;
|
|
676
|
+
if (!raw || quality === undefined) {
|
|
677
|
+
output.error("Required: --embedding '1,2,3' --quality 0.8");
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
const embedding = String(raw).split(",").map(Number);
|
|
681
|
+
const result = await callTool("neural_observe", {
|
|
682
|
+
embedding,
|
|
683
|
+
quality,
|
|
684
|
+
kind: ctx.flags.kind || ctx.flags.k,
|
|
685
|
+
});
|
|
686
|
+
printResult(result);
|
|
687
|
+
},
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
name: "learn",
|
|
691
|
+
description: "Force background learning on buffered observations",
|
|
692
|
+
action: async () => {
|
|
693
|
+
ensureTools();
|
|
694
|
+
const result = await callTool("neural_learn", {});
|
|
695
|
+
printResult(result);
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
name: "stats",
|
|
700
|
+
description: "SONA engine statistics",
|
|
701
|
+
action: async () => {
|
|
702
|
+
ensureTools();
|
|
703
|
+
const result = await callTool("neural_stats", {});
|
|
704
|
+
printJson(result);
|
|
705
|
+
},
|
|
706
|
+
},
|
|
707
|
+
],
|
|
708
|
+
};
|
|
709
|
+
// ── 13. security ───────────────────────────────────────────────────
|
|
710
|
+
const securityCommand = {
|
|
711
|
+
name: "security",
|
|
712
|
+
description: "Security scanning",
|
|
713
|
+
subcommands: [
|
|
714
|
+
{
|
|
715
|
+
name: "scan",
|
|
716
|
+
description: "Run security scan",
|
|
717
|
+
action: async () => {
|
|
718
|
+
ensureTools();
|
|
719
|
+
const spinner = output.spinner("Running security scan...");
|
|
720
|
+
spinner.start();
|
|
721
|
+
const result = await callTool("security_scan", {});
|
|
722
|
+
spinner.stop();
|
|
723
|
+
printJson(result);
|
|
724
|
+
},
|
|
725
|
+
},
|
|
726
|
+
],
|
|
727
|
+
};
|
|
728
|
+
// ── 14. analyze ────────────────────────────────────────────────────
|
|
729
|
+
const analyzeCommand = {
|
|
730
|
+
name: "analyze",
|
|
731
|
+
description: "Code analysis",
|
|
732
|
+
subcommands: [
|
|
733
|
+
{
|
|
734
|
+
name: "diff",
|
|
735
|
+
description: "Classify a git diff",
|
|
736
|
+
options: [
|
|
737
|
+
{ name: "diff", short: "d", description: "Git diff content (reads stdin if omitted)", type: "string" },
|
|
738
|
+
],
|
|
739
|
+
action: async (ctx) => {
|
|
740
|
+
ensureTools();
|
|
741
|
+
const diff = ctx.flags.diff || ctx.flags.d || ctx.args.join(" ");
|
|
742
|
+
if (!diff) {
|
|
743
|
+
output.error("Diff content required: --diff <content> or pipe via stdin");
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
const result = await callTool("analyze_diff", { diff });
|
|
747
|
+
printJson(result);
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
name: "commit",
|
|
752
|
+
description: "Classify a commit message",
|
|
753
|
+
options: [
|
|
754
|
+
{ name: "message", short: "m", description: "Commit message", type: "string", required: true },
|
|
755
|
+
],
|
|
756
|
+
action: async (ctx) => {
|
|
757
|
+
ensureTools();
|
|
758
|
+
const message = ctx.flags.message || ctx.flags.m || ctx.args.join(" ");
|
|
759
|
+
if (!message) {
|
|
760
|
+
output.error("Commit message required: --message <text>");
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
const result = await callTool("analyze_commit", { message });
|
|
764
|
+
printResult(result);
|
|
765
|
+
},
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
name: "complexity",
|
|
769
|
+
description: "Score code complexity",
|
|
770
|
+
options: [
|
|
771
|
+
{ name: "source", short: "s", description: "Source code content", type: "string", required: true },
|
|
772
|
+
],
|
|
773
|
+
action: async (ctx) => {
|
|
774
|
+
ensureTools();
|
|
775
|
+
const source = ctx.flags.source || ctx.flags.s || ctx.args.join(" ");
|
|
776
|
+
if (!source) {
|
|
777
|
+
output.error("Source code required: --source <code>");
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
const result = await callTool("analyze_complexity", { source });
|
|
781
|
+
printJson(result);
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
],
|
|
785
|
+
};
|
|
786
|
+
// ── 15. route ──────────────────────────────────────────────────────
|
|
787
|
+
const routeCommand = {
|
|
788
|
+
name: "route",
|
|
789
|
+
description: "Task routing",
|
|
790
|
+
options: [
|
|
791
|
+
{ name: "task", short: "t", description: "Task description", type: "string", required: true },
|
|
792
|
+
],
|
|
793
|
+
action: async (ctx) => {
|
|
794
|
+
ensureTools();
|
|
795
|
+
const task = ctx.flags.task || ctx.flags.t || ctx.args.join(" ");
|
|
796
|
+
if (!task) {
|
|
797
|
+
output.error("Task description required: --task <text>");
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
const result = await callTool("hooks_route", { task });
|
|
801
|
+
printJson(result);
|
|
802
|
+
},
|
|
803
|
+
};
|
|
804
|
+
// ── 16. gcc ────────────────────────────────────────────────────────
|
|
805
|
+
const gccCommand = {
|
|
806
|
+
name: "gcc",
|
|
807
|
+
description: "Git context",
|
|
808
|
+
action: async () => {
|
|
809
|
+
ensureTools();
|
|
810
|
+
const result = await callTool("git_context", {});
|
|
811
|
+
printJson(result);
|
|
812
|
+
},
|
|
813
|
+
};
|
|
814
|
+
// ── 17. daemon ─────────────────────────────────────────────────────
|
|
815
|
+
const daemonCommand = {
|
|
816
|
+
name: "daemon",
|
|
817
|
+
description: "Background workers",
|
|
818
|
+
action: async () => {
|
|
819
|
+
output.log(color.yellow("daemon not yet implemented"));
|
|
820
|
+
},
|
|
821
|
+
};
|
|
822
|
+
// ── 18. completions ────────────────────────────────────────────────
|
|
823
|
+
const completionsCommand = {
|
|
824
|
+
name: "completions",
|
|
825
|
+
description: "Shell completions",
|
|
826
|
+
options: [
|
|
827
|
+
{ name: "shell", short: "s", description: "Shell type: bash, zsh", type: "string" },
|
|
828
|
+
],
|
|
829
|
+
action: async (ctx) => {
|
|
830
|
+
const shell = (ctx.flags.shell || ctx.flags.s || ctx.args[0] || "bash");
|
|
831
|
+
const cmdNames = commands.map((c) => c.name).join(" ");
|
|
832
|
+
if (shell === "zsh") {
|
|
833
|
+
output.log(`#compdef aiyoucli
|
|
834
|
+
_aiyoucli() {
|
|
835
|
+
local -a commands
|
|
836
|
+
commands=(${commands.map((c) => `'${c.name}:${c.description.replace(/'/g, "")}'`).join(" ")})
|
|
837
|
+
_describe 'command' commands
|
|
838
|
+
}
|
|
839
|
+
compdef _aiyoucli aiyoucli`);
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
output.log(`# bash completion for aiyoucli
|
|
843
|
+
_aiyoucli() {
|
|
844
|
+
local cur=\${COMP_WORDS[COMP_CWORD]}
|
|
845
|
+
COMPREPLY=( $(compgen -W "${cmdNames}" -- "$cur") )
|
|
846
|
+
}
|
|
847
|
+
complete -F _aiyoucli aiyoucli`);
|
|
848
|
+
}
|
|
849
|
+
},
|
|
850
|
+
};
|
|
851
|
+
// ── 19. update ─────────────────────────────────────────────────────
|
|
852
|
+
const updateCommand = {
|
|
853
|
+
name: "update",
|
|
854
|
+
description: "Self-update",
|
|
855
|
+
action: async () => {
|
|
856
|
+
output.log(color.yellow("update not yet implemented"));
|
|
857
|
+
},
|
|
858
|
+
};
|
|
859
|
+
// ── 20. performance ────────────────────────────────────────────────
|
|
860
|
+
const performanceCommand = {
|
|
861
|
+
name: "performance",
|
|
862
|
+
description: "Performance profiling",
|
|
863
|
+
subcommands: [
|
|
864
|
+
{
|
|
865
|
+
name: "benchmark",
|
|
866
|
+
description: "Run vector search benchmark",
|
|
867
|
+
options: [
|
|
868
|
+
{ name: "vectors", short: "n", description: "Number of vectors (default: 1000)", type: "number" },
|
|
869
|
+
{ name: "dimensions", short: "d", description: "Dimensions (default: 128)", type: "number" },
|
|
870
|
+
{ name: "queries", short: "q", description: "Number of queries (default: 100)", type: "number" },
|
|
871
|
+
],
|
|
872
|
+
action: async (ctx) => {
|
|
873
|
+
ensureTools();
|
|
874
|
+
const spinner = output.spinner("Running benchmark...");
|
|
875
|
+
spinner.start();
|
|
876
|
+
const result = await callTool("perf_benchmark", {
|
|
877
|
+
vectors: ctx.flags.vectors || ctx.flags.n,
|
|
878
|
+
dimensions: ctx.flags.dimensions || ctx.flags.d,
|
|
879
|
+
queries: ctx.flags.queries || ctx.flags.q,
|
|
880
|
+
});
|
|
881
|
+
spinner.stop();
|
|
882
|
+
printJson(result);
|
|
883
|
+
},
|
|
884
|
+
},
|
|
885
|
+
],
|
|
886
|
+
};
|
|
887
|
+
// ── 21. statusline ────────────────────────────────────────────────
|
|
888
|
+
const statuslineCommand = {
|
|
889
|
+
name: "statusline",
|
|
890
|
+
description: "Display rich status dashboard",
|
|
891
|
+
options: [
|
|
892
|
+
{ name: "json", description: "Output as JSON", type: "boolean" },
|
|
893
|
+
{ name: "compact", description: "Compact JSON output", type: "boolean" },
|
|
894
|
+
{ name: "generate", description: "Generate standalone script to .aiyoucli/helpers/", type: "boolean" },
|
|
895
|
+
],
|
|
896
|
+
action: async (ctx) => {
|
|
897
|
+
if (ctx.flags.generate) {
|
|
898
|
+
const path = generateStatuslineScript(ctx.cwd);
|
|
899
|
+
output.success(`Generated statusline script: ${path}`);
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const result = renderStatusline(ctx.cwd, {
|
|
903
|
+
json: ctx.flags.json,
|
|
904
|
+
compact: ctx.flags.compact,
|
|
905
|
+
});
|
|
906
|
+
console.log(result);
|
|
907
|
+
},
|
|
908
|
+
};
|
|
909
|
+
// ── 22. skills ────────────────────────────────────────────────────
|
|
910
|
+
const skillsCommand = {
|
|
911
|
+
name: "skills",
|
|
912
|
+
description: "Manage project skills (sync, list)",
|
|
913
|
+
subcommands: [
|
|
914
|
+
{
|
|
915
|
+
name: "sync",
|
|
916
|
+
description: "Detect new skills, distill to TOON, clean MDs",
|
|
917
|
+
action: async (ctx) => {
|
|
918
|
+
ensureTools();
|
|
919
|
+
const result = await callTool("skills_sync", { project_dir: ctx.cwd });
|
|
920
|
+
printResult(result);
|
|
921
|
+
},
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
name: "list",
|
|
925
|
+
description: "List installed TOON skills",
|
|
926
|
+
action: async (ctx) => {
|
|
927
|
+
ensureTools();
|
|
928
|
+
const result = await callTool("skills_list", { project_dir: ctx.cwd });
|
|
929
|
+
printJson(result);
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
name: "detect",
|
|
934
|
+
description: "Detect project technologies",
|
|
935
|
+
action: async (ctx) => {
|
|
936
|
+
ensureTools();
|
|
937
|
+
const result = await callTool("skills_detect", { project_dir: ctx.cwd });
|
|
938
|
+
printJson(result);
|
|
939
|
+
},
|
|
940
|
+
},
|
|
941
|
+
],
|
|
942
|
+
};
|
|
943
|
+
// ── Export ──────────────────────────────────────────────────────────
|
|
944
|
+
export const commands = [
|
|
945
|
+
initCommand,
|
|
946
|
+
agentCommand,
|
|
947
|
+
swarmCommand,
|
|
948
|
+
memoryCommand,
|
|
949
|
+
mcpCommand,
|
|
950
|
+
taskCommand,
|
|
951
|
+
sessionCommand,
|
|
952
|
+
hooksCommand,
|
|
953
|
+
configCommand,
|
|
954
|
+
statusCommand,
|
|
955
|
+
doctorCommand,
|
|
956
|
+
neuralCommand,
|
|
957
|
+
securityCommand,
|
|
958
|
+
analyzeCommand,
|
|
959
|
+
routeCommand,
|
|
960
|
+
gccCommand,
|
|
961
|
+
daemonCommand,
|
|
962
|
+
completionsCommand,
|
|
963
|
+
updateCommand,
|
|
964
|
+
performanceCommand,
|
|
965
|
+
statuslineCommand,
|
|
966
|
+
skillsCommand,
|
|
967
|
+
];
|
|
968
|
+
//# sourceMappingURL=index.js.map
|