@aigne/cli 1.74.0-beta.1 → 1.74.0-beta.2
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 +153 -14
- package/dist/commands/aigne.cjs +3 -4
- package/dist/commands/aigne.mjs +3 -4
- package/dist/commands/aigne.mjs.map +1 -1
- package/dist/commands/app/agent.cjs +2 -27
- package/dist/commands/app/agent.mjs +2 -26
- package/dist/commands/app/agent.mjs.map +1 -1
- package/dist/commands/create.cjs +1 -1
- package/dist/commands/create.mjs +1 -1
- package/dist/commands/eval.cjs +42 -3
- package/dist/commands/eval.mjs +43 -4
- package/dist/commands/eval.mjs.map +1 -1
- package/dist/commands/explain.cjs +340 -0
- package/dist/commands/explain.mjs +340 -0
- package/dist/commands/explain.mjs.map +1 -0
- package/dist/commands/hub.cjs +111 -14
- package/dist/commands/hub.mjs +111 -14
- package/dist/commands/hub.mjs.map +1 -1
- package/dist/commands/observe.cjs +44 -1
- package/dist/commands/observe.mjs +44 -1
- package/dist/commands/observe.mjs.map +1 -1
- package/dist/commands/run-skill.cjs +29 -13
- package/dist/commands/run-skill.mjs +29 -13
- package/dist/commands/run-skill.mjs.map +1 -1
- package/dist/commands/run.cjs +5 -4
- package/dist/commands/run.mjs +5 -4
- package/dist/commands/run.mjs.map +1 -1
- package/dist/commands/serve-mcp.cjs +49 -4
- package/dist/commands/serve-mcp.mjs +49 -3
- package/dist/commands/serve-mcp.mjs.map +1 -1
- package/dist/commands/shell.cjs +106 -0
- package/dist/commands/shell.mjs +105 -0
- package/dist/commands/shell.mjs.map +1 -0
- package/dist/shell/repl.cjs +544 -0
- package/dist/shell/repl.mjs +543 -0
- package/dist/shell/repl.mjs.map +1 -0
- package/dist/shell/tools/ask-user.cjs +191 -0
- package/dist/shell/tools/ask-user.mjs +187 -0
- package/dist/shell/tools/ask-user.mjs.map +1 -0
- package/dist/shell/tools/index.cjs +2 -0
- package/dist/shell/tools/index.mjs +4 -0
- package/dist/shell/tools/render.cjs +189 -0
- package/dist/shell/tools/render.mjs +186 -0
- package/dist/shell/tools/render.mjs.map +1 -0
- package/dist/tracer/terminal.cjs +120 -133
- package/dist/tracer/terminal.mjs +121 -134
- package/dist/tracer/terminal.mjs.map +1 -1
- package/dist/ui/utils/terminal-select.cjs +73 -0
- package/dist/ui/utils/terminal-select.mjs +72 -0
- package/dist/ui/utils/terminal-select.mjs.map +1 -0
- package/dist/utils/agent-v1.cjs +2 -2
- package/dist/utils/agent-v1.mjs +2 -2
- package/dist/utils/aigne-hub/credential.cjs +3 -3
- package/dist/utils/aigne-hub/credential.mjs +3 -3
- package/dist/utils/aigne-hub/model.cjs +2 -2
- package/dist/utils/aigne-hub/model.mjs +1 -1
- package/dist/utils/ascii-logo.cjs +12 -13
- package/dist/utils/ascii-logo.d.cts.map +1 -1
- package/dist/utils/ascii-logo.d.mts.map +1 -1
- package/dist/utils/ascii-logo.mjs +12 -13
- package/dist/utils/ascii-logo.mjs.map +1 -1
- package/dist/utils/evaluation/evaluator.cjs +1 -1
- package/dist/utils/evaluation/evaluator.mjs +1 -1
- package/dist/utils/evaluation/reporter.cjs +78 -1
- package/dist/utils/evaluation/reporter.mjs +76 -1
- package/dist/utils/evaluation/reporter.mjs.map +1 -1
- package/dist/utils/exit-codes.cjs +73 -0
- package/dist/utils/exit-codes.d.cts +52 -0
- package/dist/utils/exit-codes.d.cts.map +1 -0
- package/dist/utils/exit-codes.d.mts +52 -0
- package/dist/utils/exit-codes.d.mts.map +1 -0
- package/dist/utils/exit-codes.mjs +71 -0
- package/dist/utils/exit-codes.mjs.map +1 -0
- package/dist/utils/output.cjs +61 -0
- package/dist/utils/output.d.cts +43 -0
- package/dist/utils/output.d.cts.map +1 -0
- package/dist/utils/output.d.mts +43 -0
- package/dist/utils/output.d.mts.map +1 -0
- package/dist/utils/output.mjs +56 -0
- package/dist/utils/output.mjs.map +1 -0
- package/dist/utils/run-chat-loop.cjs +1 -1
- package/dist/utils/run-chat-loop.mjs +1 -1
- package/dist/utils/run-with-aigne.cjs +10 -3
- package/dist/utils/run-with-aigne.d.cts.map +1 -1
- package/dist/utils/run-with-aigne.d.mts.map +1 -1
- package/dist/utils/run-with-aigne.mjs +10 -3
- package/dist/utils/run-with-aigne.mjs.map +1 -1
- package/dist/utils/serve-mcp.cjs +1 -1
- package/dist/utils/serve-mcp.mjs +1 -1
- package/dist/utils/view.cjs +34 -0
- package/dist/utils/view.d.cts +47 -0
- package/dist/utils/view.d.cts.map +1 -0
- package/dist/utils/view.d.mts +47 -0
- package/dist/utils/view.d.mts.map +1 -0
- package/dist/utils/view.mjs +33 -0
- package/dist/utils/view.mjs.map +1 -0
- package/dist/utils/yargs.cjs +27 -5
- package/dist/utils/yargs.d.cts +13 -0
- package/dist/utils/yargs.d.cts.map +1 -1
- package/dist/utils/yargs.d.mts +14 -1
- package/dist/utils/yargs.d.mts.map +1 -1
- package/dist/utils/yargs.mjs +32 -10
- package/dist/utils/yargs.mjs.map +1 -1
- package/package.json +21 -17
- package/dist/commands/app/app.cjs +0 -92
- package/dist/commands/app/app.mjs +0 -90
- package/dist/commands/app/app.mjs.map +0 -1
- package/dist/commands/app/cli.cjs +0 -6
- package/dist/commands/app/cli.d.cts +0 -1
- package/dist/commands/app/cli.d.mts +0 -1
- package/dist/commands/app/cli.mjs +0 -8
- package/dist/commands/app/cli.mjs.map +0 -1
- package/dist/commands/app/upgrade.cjs +0 -243
- package/dist/commands/app/upgrade.mjs +0 -240
- package/dist/commands/app/upgrade.mjs.map +0 -1
- package/dist/commands/app.cjs +0 -53
- package/dist/commands/app.mjs +0 -53
- package/dist/commands/app.mjs.map +0 -1
- package/dist/commands/deploy.cjs +0 -237
- package/dist/commands/deploy.mjs +0 -237
- package/dist/commands/deploy.mjs.map +0 -1
- package/dist/utils/listr.cjs +0 -226
- package/dist/utils/listr.d.cts +0 -71
- package/dist/utils/listr.d.cts.map +0 -1
- package/dist/utils/listr.d.mts +0 -71
- package/dist/utils/listr.d.mts.map +0 -1
- package/dist/utils/listr.mjs +0 -222
- package/dist/utils/listr.mjs.map +0 -1
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/commands/explain.ts
|
|
3
|
+
/**
|
|
4
|
+
* List of all available commands with their descriptions.
|
|
5
|
+
* Used by `aigne explain` without arguments.
|
|
6
|
+
*/
|
|
7
|
+
const availableCommands = [
|
|
8
|
+
{
|
|
9
|
+
name: "run",
|
|
10
|
+
description: "Run an AIGNE agent"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
name: "skill",
|
|
14
|
+
description: "Run Agent Skills from directories"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "eval",
|
|
18
|
+
description: "Evaluate an agent against test cases"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "test",
|
|
22
|
+
description: "Run agent tests"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "create",
|
|
26
|
+
description: "Create a new agent project"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "serve-mcp",
|
|
30
|
+
description: "Serve agent as MCP server"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "observe",
|
|
34
|
+
description: "Start observability server"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "hub",
|
|
38
|
+
description: "Manage AIGNE Hub connections"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "explain",
|
|
42
|
+
description: "Show command documentation"
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Registry of all command documentation.
|
|
47
|
+
*/
|
|
48
|
+
const commandDocs = {
|
|
49
|
+
"hub list": {
|
|
50
|
+
command: "aigne hub list",
|
|
51
|
+
purpose: "List all connected AIGNE Hub instances",
|
|
52
|
+
input: ["--json: Output in JSON format", "--view=<type>: Output view (default|json|llm|human)"],
|
|
53
|
+
outputs: {
|
|
54
|
+
default: "<url> <status> (one per line, space-separated)",
|
|
55
|
+
json: "{\"schema_version\":\"1.0\",\"hubs\":[{\"url\":\"...\",\"status\":\"active|inactive\"}]}",
|
|
56
|
+
llm: "URL <url>\\nSTATUS <status> (per hub)"
|
|
57
|
+
},
|
|
58
|
+
errors: ["No hubs connected: outputs nothing (default) or empty array (json)"],
|
|
59
|
+
sideEffects: ["None - read-only operation"],
|
|
60
|
+
defaultBehavior: "In TTY: displays formatted table. Non-TTY: outputs machine truth (url status per line)"
|
|
61
|
+
},
|
|
62
|
+
"hub status": {
|
|
63
|
+
command: "aigne hub status",
|
|
64
|
+
purpose: "Show detailed status of the active AIGNE Hub connection",
|
|
65
|
+
input: [
|
|
66
|
+
"--json: Output in JSON format",
|
|
67
|
+
"--view=<type>: Output view (default|json|llm|human)",
|
|
68
|
+
"In TTY: prompts to select hub"
|
|
69
|
+
],
|
|
70
|
+
outputs: {
|
|
71
|
+
default: "<hub> <status> <user_name> <email> (space-separated)",
|
|
72
|
+
json: "{\"schema_version\":\"1.0\",\"hub\":\"...\",\"status\":\"...\",\"user\":{...},\"credits\":{...}}",
|
|
73
|
+
llm: "HUB <url>\\nSTATUS <status>\\nUSER_NAME <name>\\nUSER_EMAIL <email>\\nCREDITS_AVAILABLE <n>"
|
|
74
|
+
},
|
|
75
|
+
errors: ["No hubs connected: outputs error message", "Network error: displays connection failure"],
|
|
76
|
+
sideEffects: ["None - read-only operation"],
|
|
77
|
+
defaultBehavior: "In TTY: prompts to select hub, shows formatted status. Non-TTY: uses active hub, outputs machine truth"
|
|
78
|
+
},
|
|
79
|
+
"hub connect": {
|
|
80
|
+
command: "aigne hub connect [url]",
|
|
81
|
+
purpose: "Connect to an AIGNE Hub instance",
|
|
82
|
+
input: ["url (optional): Hub URL to connect to", "If no URL: prompts for selection"],
|
|
83
|
+
outputs: { default: "Success or error message" },
|
|
84
|
+
errors: ["Invalid URL: validation error", "Connection failed: network error"],
|
|
85
|
+
sideEffects: ["Stores hub credentials in secure storage", "Sets connected hub as active"],
|
|
86
|
+
defaultBehavior: "Prompts for official or custom hub, then opens browser for authentication"
|
|
87
|
+
},
|
|
88
|
+
"hub use": {
|
|
89
|
+
command: "aigne hub use",
|
|
90
|
+
purpose: "Switch to a different connected AIGNE Hub",
|
|
91
|
+
input: ["Prompts to select from connected hubs"],
|
|
92
|
+
outputs: { default: "Success message with selected hub" },
|
|
93
|
+
errors: ["No hubs connected: displays warning"],
|
|
94
|
+
sideEffects: ["Updates active hub in secure storage"],
|
|
95
|
+
defaultBehavior: "Displays list of connected hubs, sets selected as active"
|
|
96
|
+
},
|
|
97
|
+
"hub remove": {
|
|
98
|
+
command: "aigne hub remove",
|
|
99
|
+
purpose: "Remove a connected AIGNE Hub",
|
|
100
|
+
input: ["Prompts to select hub to remove"],
|
|
101
|
+
outputs: { default: "Success message with removed hub" },
|
|
102
|
+
errors: ["No hubs connected: displays warning"],
|
|
103
|
+
sideEffects: ["Removes hub credentials from secure storage", "If removing active hub, switches to next available"],
|
|
104
|
+
defaultBehavior: "Prompts to select hub, removes credentials, updates active if needed"
|
|
105
|
+
},
|
|
106
|
+
run: {
|
|
107
|
+
command: "aigne run [path]",
|
|
108
|
+
purpose: "Run an AIGNE agent from a directory or URL",
|
|
109
|
+
input: [
|
|
110
|
+
"path (optional): Path to agent directory or URL to an aigne project",
|
|
111
|
+
"entry-agent (optional): Name of the agent to run",
|
|
112
|
+
"--interactive/--chat: Run in interactive chat mode",
|
|
113
|
+
"--input/-i: Input to the agent",
|
|
114
|
+
"--model: AI model to use",
|
|
115
|
+
"--json: Output in JSON format",
|
|
116
|
+
"--view: Output view type (default|json|llm|human)"
|
|
117
|
+
],
|
|
118
|
+
outputs: {
|
|
119
|
+
default: "Agent response output",
|
|
120
|
+
json: "{\"schema_version\":\"1.0\",\"input\":{...},\"output\":{...},\"duration_ms\":N}",
|
|
121
|
+
llm: "AGENT <name>\\nINPUT <message>\\nOUTPUT <response>\\nDURATION <ms>"
|
|
122
|
+
},
|
|
123
|
+
errors: [
|
|
124
|
+
"exit 1: Agent not found",
|
|
125
|
+
"exit 5: Agent execution failed",
|
|
126
|
+
"exit 6: Invalid input format",
|
|
127
|
+
"exit 7: Model connection failed"
|
|
128
|
+
],
|
|
129
|
+
sideEffects: ["May create files if agent has file tools", "May make network requests"],
|
|
130
|
+
defaultBehavior: "Loads agent from current directory if no path. Interactive mode if TTY and no --input"
|
|
131
|
+
},
|
|
132
|
+
skill: {
|
|
133
|
+
command: "aigne skill <paths..>",
|
|
134
|
+
purpose: "Run Agent Skills from specified directories",
|
|
135
|
+
input: [
|
|
136
|
+
"paths: One or more paths to Agent Skill directories",
|
|
137
|
+
"--interactive/--chat: Run in interactive chat mode",
|
|
138
|
+
"--input/-i: Input message to the skill",
|
|
139
|
+
"--model: AI model to use",
|
|
140
|
+
"--json: Output in JSON format",
|
|
141
|
+
"--view: Output view type (default|json|llm|human)"
|
|
142
|
+
],
|
|
143
|
+
outputs: {
|
|
144
|
+
default: "Skill execution output",
|
|
145
|
+
json: "{\"schema_version\":\"1.0\",\"input\":{...},\"output\":{...},\"duration_ms\":N}"
|
|
146
|
+
},
|
|
147
|
+
errors: [
|
|
148
|
+
"exit 1: Skill directory not found",
|
|
149
|
+
"exit 5: Skill execution failed",
|
|
150
|
+
"exit 6: Invalid input"
|
|
151
|
+
],
|
|
152
|
+
sideEffects: [
|
|
153
|
+
"May execute bash commands (with user confirmation)",
|
|
154
|
+
"May create/modify files in workspace",
|
|
155
|
+
"May make network requests"
|
|
156
|
+
],
|
|
157
|
+
defaultBehavior: "Creates AgentSkillManager with BashAgent and AskUserQuestion. Mounts skill directories as AFS modules"
|
|
158
|
+
},
|
|
159
|
+
eval: {
|
|
160
|
+
command: "aigne eval [path]",
|
|
161
|
+
purpose: "Evaluate an AIGNE agent against test cases",
|
|
162
|
+
input: [
|
|
163
|
+
"path (optional): Path to agent directory",
|
|
164
|
+
"--json: Output in JSON format",
|
|
165
|
+
"--view: Output view type"
|
|
166
|
+
],
|
|
167
|
+
outputs: {
|
|
168
|
+
default: "<test-id> <status> <score> <duration> (one per line)",
|
|
169
|
+
json: "{\"schema_version\":\"1.0\",\"results\":[...],\"summary\":{...}}",
|
|
170
|
+
llm: "EVAL <test-id>\\nSTATUS <PASS|FAIL>\\nSCORE <n>"
|
|
171
|
+
},
|
|
172
|
+
errors: [
|
|
173
|
+
"exit 1: Agent not found",
|
|
174
|
+
"exit 4: Partial test failure",
|
|
175
|
+
"exit 5: Evaluation error"
|
|
176
|
+
],
|
|
177
|
+
sideEffects: ["May make LLM API calls for evaluation"],
|
|
178
|
+
defaultBehavior: "Loads agent from current directory, runs all test cases, reports results"
|
|
179
|
+
},
|
|
180
|
+
test: {
|
|
181
|
+
command: "aigne test",
|
|
182
|
+
purpose: "Run agent tests in the specified directory",
|
|
183
|
+
input: ["--filter: Filter tests by name pattern", "--json: Output in JSON format"],
|
|
184
|
+
outputs: {
|
|
185
|
+
default: "<spec> <status> <passed> <failed> (one per line)",
|
|
186
|
+
json: "{\"schema_version\":\"1.0\",\"specs\":[...],\"summary\":{...}}"
|
|
187
|
+
},
|
|
188
|
+
errors: ["exit 1: No tests found", "exit 4: Some tests failed"],
|
|
189
|
+
sideEffects: ["None - read-only operation"],
|
|
190
|
+
defaultBehavior: "Runs all tests in the current directory using node --test"
|
|
191
|
+
},
|
|
192
|
+
create: {
|
|
193
|
+
command: "aigne create [path]",
|
|
194
|
+
purpose: "Create a new AIGNE agent project",
|
|
195
|
+
input: [
|
|
196
|
+
"path (optional): Directory to create the project in",
|
|
197
|
+
"--template: Project template to use",
|
|
198
|
+
"--json: Output in JSON format"
|
|
199
|
+
],
|
|
200
|
+
outputs: {
|
|
201
|
+
default: "created <path>",
|
|
202
|
+
json: "{\"schema_version\":\"1.0\",\"path\":\"...\",\"template\":\"...\",\"files_created\":[...]}"
|
|
203
|
+
},
|
|
204
|
+
errors: ["exit 3: Directory already exists", "exit 6: Invalid template"],
|
|
205
|
+
sideEffects: ["Creates directory structure", "Creates configuration files"],
|
|
206
|
+
defaultBehavior: "Interactive prompts for project name and template if not specified"
|
|
207
|
+
},
|
|
208
|
+
"serve-mcp": {
|
|
209
|
+
command: "aigne serve-mcp [path]",
|
|
210
|
+
purpose: "Serve agents as an MCP (Model Context Protocol) server",
|
|
211
|
+
input: [
|
|
212
|
+
"path (optional): Path to agent directory",
|
|
213
|
+
"--host: Host to bind (default: localhost)",
|
|
214
|
+
"--port: Port to listen on",
|
|
215
|
+
"--pathname: URL pathname (default: /mcp)",
|
|
216
|
+
"--json: Output startup info in JSON format"
|
|
217
|
+
],
|
|
218
|
+
outputs: {
|
|
219
|
+
default: "listening <host>:<port><pathname>",
|
|
220
|
+
json: "{\"schema_version\":\"1.0\",\"status\":\"listening\",\"host\":\"...\",\"port\":N,\"path\":\"...\"}"
|
|
221
|
+
},
|
|
222
|
+
errors: [
|
|
223
|
+
"exit 1: Agent not found",
|
|
224
|
+
"exit 5: Server startup failed",
|
|
225
|
+
"exit 7: Port already in use"
|
|
226
|
+
],
|
|
227
|
+
sideEffects: ["Starts HTTP server", "Listens for MCP connections"],
|
|
228
|
+
defaultBehavior: "Loads agent from current directory, starts MCP server on localhost"
|
|
229
|
+
},
|
|
230
|
+
observe: {
|
|
231
|
+
command: "aigne observe",
|
|
232
|
+
purpose: "Start the observability server for agent debugging",
|
|
233
|
+
input: [
|
|
234
|
+
"--port: Port to listen on",
|
|
235
|
+
"--host: Host to bind",
|
|
236
|
+
"--json: Output startup info in JSON format"
|
|
237
|
+
],
|
|
238
|
+
outputs: {
|
|
239
|
+
default: "listening <host>:<port>",
|
|
240
|
+
json: "{\"schema_version\":\"1.0\",\"status\":\"listening\",\"host\":\"...\",\"port\":N}"
|
|
241
|
+
},
|
|
242
|
+
errors: ["exit 5: Server startup failed", "exit 7: Port already in use"],
|
|
243
|
+
sideEffects: ["Starts HTTP server", "Provides tracing and debugging UI"],
|
|
244
|
+
defaultBehavior: "Starts observability server on default port"
|
|
245
|
+
},
|
|
246
|
+
hub: {
|
|
247
|
+
command: "aigne hub <command>",
|
|
248
|
+
purpose: "Manage AIGNE Hub connections",
|
|
249
|
+
input: ["command: list|connect|use|status|remove"],
|
|
250
|
+
outputs: { default: "Varies by subcommand" },
|
|
251
|
+
errors: ["See individual subcommand documentation"],
|
|
252
|
+
sideEffects: ["Varies by subcommand - see aigne explain hub <subcommand>"],
|
|
253
|
+
defaultBehavior: "Shows hub command help if no subcommand specified"
|
|
254
|
+
},
|
|
255
|
+
explain: {
|
|
256
|
+
command: "aigne explain [command..]",
|
|
257
|
+
purpose: "Show machine-readable documentation for CLI commands",
|
|
258
|
+
input: ["command (optional): Command path to explain (e.g., hub list)"],
|
|
259
|
+
outputs: { default: "Without args: lists available commands. With args: shows structured documentation for the command" },
|
|
260
|
+
errors: ["ERROR unknown_command: Command not found in documentation"],
|
|
261
|
+
sideEffects: ["None - read-only operation"],
|
|
262
|
+
defaultBehavior: "Lists all available commands if no command specified"
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* Print command documentation in structured format.
|
|
267
|
+
*/
|
|
268
|
+
function printCommandDoc(doc) {
|
|
269
|
+
console.log(`COMMAND ${doc.command}`);
|
|
270
|
+
console.log("");
|
|
271
|
+
console.log("PURPOSE");
|
|
272
|
+
console.log(` ${doc.purpose}`);
|
|
273
|
+
console.log("");
|
|
274
|
+
console.log("INPUT");
|
|
275
|
+
for (const input of doc.input) console.log(` ${input}`);
|
|
276
|
+
console.log("");
|
|
277
|
+
console.log("OUTPUT default:");
|
|
278
|
+
console.log(` ${doc.outputs.default}`);
|
|
279
|
+
if (doc.outputs.json) {
|
|
280
|
+
console.log("OUTPUT --json:");
|
|
281
|
+
console.log(` ${doc.outputs.json}`);
|
|
282
|
+
}
|
|
283
|
+
if (doc.outputs.llm) {
|
|
284
|
+
console.log("OUTPUT --view=llm:");
|
|
285
|
+
console.log(` ${doc.outputs.llm}`);
|
|
286
|
+
}
|
|
287
|
+
console.log("");
|
|
288
|
+
console.log("ERRORS");
|
|
289
|
+
for (const error of doc.errors) console.log(` ${error}`);
|
|
290
|
+
console.log("");
|
|
291
|
+
console.log("SIDE EFFECTS");
|
|
292
|
+
for (const effect of doc.sideEffects) console.log(` ${effect}`);
|
|
293
|
+
console.log("");
|
|
294
|
+
console.log("DEFAULT BEHAVIOR");
|
|
295
|
+
console.log(` ${doc.defaultBehavior}`);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Print list of all available commands.
|
|
299
|
+
*/
|
|
300
|
+
function printAvailableCommands() {
|
|
301
|
+
console.log("AVAILABLE COMMANDS");
|
|
302
|
+
for (const cmd of availableCommands) console.log(` ${cmd.name.padEnd(12)} ${cmd.description}`);
|
|
303
|
+
console.log("");
|
|
304
|
+
console.log("Use 'aigne explain <command>' for detailed documentation.");
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Create the explain command.
|
|
308
|
+
*/
|
|
309
|
+
function createExplainCommand() {
|
|
310
|
+
return {
|
|
311
|
+
command: "explain [command..]",
|
|
312
|
+
describe: "Show machine-readable documentation for a command",
|
|
313
|
+
builder: (yargs) => yargs.positional("command", {
|
|
314
|
+
type: "string",
|
|
315
|
+
describe: "Command path to explain (e.g., hub list)",
|
|
316
|
+
array: true,
|
|
317
|
+
default: []
|
|
318
|
+
}),
|
|
319
|
+
handler: (args) => {
|
|
320
|
+
const commands = args.command;
|
|
321
|
+
if (commands.length === 0) {
|
|
322
|
+
printAvailableCommands();
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const commandPath = commands.join(" ");
|
|
326
|
+
const doc = commandDocs[commandPath];
|
|
327
|
+
if (!doc) {
|
|
328
|
+
console.log(`ERROR unknown_command ${commandPath}`);
|
|
329
|
+
console.log("");
|
|
330
|
+
printAvailableCommands();
|
|
331
|
+
process.exitCode = 1;
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
printCommandDoc(doc);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
//#endregion
|
|
340
|
+
exports.createExplainCommand = createExplainCommand;
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
//#region src/commands/explain.ts
|
|
2
|
+
/**
|
|
3
|
+
* List of all available commands with their descriptions.
|
|
4
|
+
* Used by `aigne explain` without arguments.
|
|
5
|
+
*/
|
|
6
|
+
const availableCommands = [
|
|
7
|
+
{
|
|
8
|
+
name: "run",
|
|
9
|
+
description: "Run an AIGNE agent"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "skill",
|
|
13
|
+
description: "Run Agent Skills from directories"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "eval",
|
|
17
|
+
description: "Evaluate an agent against test cases"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "test",
|
|
21
|
+
description: "Run agent tests"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "create",
|
|
25
|
+
description: "Create a new agent project"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "serve-mcp",
|
|
29
|
+
description: "Serve agent as MCP server"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "observe",
|
|
33
|
+
description: "Start observability server"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "hub",
|
|
37
|
+
description: "Manage AIGNE Hub connections"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "explain",
|
|
41
|
+
description: "Show command documentation"
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Registry of all command documentation.
|
|
46
|
+
*/
|
|
47
|
+
const commandDocs = {
|
|
48
|
+
"hub list": {
|
|
49
|
+
command: "aigne hub list",
|
|
50
|
+
purpose: "List all connected AIGNE Hub instances",
|
|
51
|
+
input: ["--json: Output in JSON format", "--view=<type>: Output view (default|json|llm|human)"],
|
|
52
|
+
outputs: {
|
|
53
|
+
default: "<url> <status> (one per line, space-separated)",
|
|
54
|
+
json: "{\"schema_version\":\"1.0\",\"hubs\":[{\"url\":\"...\",\"status\":\"active|inactive\"}]}",
|
|
55
|
+
llm: "URL <url>\\nSTATUS <status> (per hub)"
|
|
56
|
+
},
|
|
57
|
+
errors: ["No hubs connected: outputs nothing (default) or empty array (json)"],
|
|
58
|
+
sideEffects: ["None - read-only operation"],
|
|
59
|
+
defaultBehavior: "In TTY: displays formatted table. Non-TTY: outputs machine truth (url status per line)"
|
|
60
|
+
},
|
|
61
|
+
"hub status": {
|
|
62
|
+
command: "aigne hub status",
|
|
63
|
+
purpose: "Show detailed status of the active AIGNE Hub connection",
|
|
64
|
+
input: [
|
|
65
|
+
"--json: Output in JSON format",
|
|
66
|
+
"--view=<type>: Output view (default|json|llm|human)",
|
|
67
|
+
"In TTY: prompts to select hub"
|
|
68
|
+
],
|
|
69
|
+
outputs: {
|
|
70
|
+
default: "<hub> <status> <user_name> <email> (space-separated)",
|
|
71
|
+
json: "{\"schema_version\":\"1.0\",\"hub\":\"...\",\"status\":\"...\",\"user\":{...},\"credits\":{...}}",
|
|
72
|
+
llm: "HUB <url>\\nSTATUS <status>\\nUSER_NAME <name>\\nUSER_EMAIL <email>\\nCREDITS_AVAILABLE <n>"
|
|
73
|
+
},
|
|
74
|
+
errors: ["No hubs connected: outputs error message", "Network error: displays connection failure"],
|
|
75
|
+
sideEffects: ["None - read-only operation"],
|
|
76
|
+
defaultBehavior: "In TTY: prompts to select hub, shows formatted status. Non-TTY: uses active hub, outputs machine truth"
|
|
77
|
+
},
|
|
78
|
+
"hub connect": {
|
|
79
|
+
command: "aigne hub connect [url]",
|
|
80
|
+
purpose: "Connect to an AIGNE Hub instance",
|
|
81
|
+
input: ["url (optional): Hub URL to connect to", "If no URL: prompts for selection"],
|
|
82
|
+
outputs: { default: "Success or error message" },
|
|
83
|
+
errors: ["Invalid URL: validation error", "Connection failed: network error"],
|
|
84
|
+
sideEffects: ["Stores hub credentials in secure storage", "Sets connected hub as active"],
|
|
85
|
+
defaultBehavior: "Prompts for official or custom hub, then opens browser for authentication"
|
|
86
|
+
},
|
|
87
|
+
"hub use": {
|
|
88
|
+
command: "aigne hub use",
|
|
89
|
+
purpose: "Switch to a different connected AIGNE Hub",
|
|
90
|
+
input: ["Prompts to select from connected hubs"],
|
|
91
|
+
outputs: { default: "Success message with selected hub" },
|
|
92
|
+
errors: ["No hubs connected: displays warning"],
|
|
93
|
+
sideEffects: ["Updates active hub in secure storage"],
|
|
94
|
+
defaultBehavior: "Displays list of connected hubs, sets selected as active"
|
|
95
|
+
},
|
|
96
|
+
"hub remove": {
|
|
97
|
+
command: "aigne hub remove",
|
|
98
|
+
purpose: "Remove a connected AIGNE Hub",
|
|
99
|
+
input: ["Prompts to select hub to remove"],
|
|
100
|
+
outputs: { default: "Success message with removed hub" },
|
|
101
|
+
errors: ["No hubs connected: displays warning"],
|
|
102
|
+
sideEffects: ["Removes hub credentials from secure storage", "If removing active hub, switches to next available"],
|
|
103
|
+
defaultBehavior: "Prompts to select hub, removes credentials, updates active if needed"
|
|
104
|
+
},
|
|
105
|
+
run: {
|
|
106
|
+
command: "aigne run [path]",
|
|
107
|
+
purpose: "Run an AIGNE agent from a directory or URL",
|
|
108
|
+
input: [
|
|
109
|
+
"path (optional): Path to agent directory or URL to an aigne project",
|
|
110
|
+
"entry-agent (optional): Name of the agent to run",
|
|
111
|
+
"--interactive/--chat: Run in interactive chat mode",
|
|
112
|
+
"--input/-i: Input to the agent",
|
|
113
|
+
"--model: AI model to use",
|
|
114
|
+
"--json: Output in JSON format",
|
|
115
|
+
"--view: Output view type (default|json|llm|human)"
|
|
116
|
+
],
|
|
117
|
+
outputs: {
|
|
118
|
+
default: "Agent response output",
|
|
119
|
+
json: "{\"schema_version\":\"1.0\",\"input\":{...},\"output\":{...},\"duration_ms\":N}",
|
|
120
|
+
llm: "AGENT <name>\\nINPUT <message>\\nOUTPUT <response>\\nDURATION <ms>"
|
|
121
|
+
},
|
|
122
|
+
errors: [
|
|
123
|
+
"exit 1: Agent not found",
|
|
124
|
+
"exit 5: Agent execution failed",
|
|
125
|
+
"exit 6: Invalid input format",
|
|
126
|
+
"exit 7: Model connection failed"
|
|
127
|
+
],
|
|
128
|
+
sideEffects: ["May create files if agent has file tools", "May make network requests"],
|
|
129
|
+
defaultBehavior: "Loads agent from current directory if no path. Interactive mode if TTY and no --input"
|
|
130
|
+
},
|
|
131
|
+
skill: {
|
|
132
|
+
command: "aigne skill <paths..>",
|
|
133
|
+
purpose: "Run Agent Skills from specified directories",
|
|
134
|
+
input: [
|
|
135
|
+
"paths: One or more paths to Agent Skill directories",
|
|
136
|
+
"--interactive/--chat: Run in interactive chat mode",
|
|
137
|
+
"--input/-i: Input message to the skill",
|
|
138
|
+
"--model: AI model to use",
|
|
139
|
+
"--json: Output in JSON format",
|
|
140
|
+
"--view: Output view type (default|json|llm|human)"
|
|
141
|
+
],
|
|
142
|
+
outputs: {
|
|
143
|
+
default: "Skill execution output",
|
|
144
|
+
json: "{\"schema_version\":\"1.0\",\"input\":{...},\"output\":{...},\"duration_ms\":N}"
|
|
145
|
+
},
|
|
146
|
+
errors: [
|
|
147
|
+
"exit 1: Skill directory not found",
|
|
148
|
+
"exit 5: Skill execution failed",
|
|
149
|
+
"exit 6: Invalid input"
|
|
150
|
+
],
|
|
151
|
+
sideEffects: [
|
|
152
|
+
"May execute bash commands (with user confirmation)",
|
|
153
|
+
"May create/modify files in workspace",
|
|
154
|
+
"May make network requests"
|
|
155
|
+
],
|
|
156
|
+
defaultBehavior: "Creates AgentSkillManager with BashAgent and AskUserQuestion. Mounts skill directories as AFS modules"
|
|
157
|
+
},
|
|
158
|
+
eval: {
|
|
159
|
+
command: "aigne eval [path]",
|
|
160
|
+
purpose: "Evaluate an AIGNE agent against test cases",
|
|
161
|
+
input: [
|
|
162
|
+
"path (optional): Path to agent directory",
|
|
163
|
+
"--json: Output in JSON format",
|
|
164
|
+
"--view: Output view type"
|
|
165
|
+
],
|
|
166
|
+
outputs: {
|
|
167
|
+
default: "<test-id> <status> <score> <duration> (one per line)",
|
|
168
|
+
json: "{\"schema_version\":\"1.0\",\"results\":[...],\"summary\":{...}}",
|
|
169
|
+
llm: "EVAL <test-id>\\nSTATUS <PASS|FAIL>\\nSCORE <n>"
|
|
170
|
+
},
|
|
171
|
+
errors: [
|
|
172
|
+
"exit 1: Agent not found",
|
|
173
|
+
"exit 4: Partial test failure",
|
|
174
|
+
"exit 5: Evaluation error"
|
|
175
|
+
],
|
|
176
|
+
sideEffects: ["May make LLM API calls for evaluation"],
|
|
177
|
+
defaultBehavior: "Loads agent from current directory, runs all test cases, reports results"
|
|
178
|
+
},
|
|
179
|
+
test: {
|
|
180
|
+
command: "aigne test",
|
|
181
|
+
purpose: "Run agent tests in the specified directory",
|
|
182
|
+
input: ["--filter: Filter tests by name pattern", "--json: Output in JSON format"],
|
|
183
|
+
outputs: {
|
|
184
|
+
default: "<spec> <status> <passed> <failed> (one per line)",
|
|
185
|
+
json: "{\"schema_version\":\"1.0\",\"specs\":[...],\"summary\":{...}}"
|
|
186
|
+
},
|
|
187
|
+
errors: ["exit 1: No tests found", "exit 4: Some tests failed"],
|
|
188
|
+
sideEffects: ["None - read-only operation"],
|
|
189
|
+
defaultBehavior: "Runs all tests in the current directory using node --test"
|
|
190
|
+
},
|
|
191
|
+
create: {
|
|
192
|
+
command: "aigne create [path]",
|
|
193
|
+
purpose: "Create a new AIGNE agent project",
|
|
194
|
+
input: [
|
|
195
|
+
"path (optional): Directory to create the project in",
|
|
196
|
+
"--template: Project template to use",
|
|
197
|
+
"--json: Output in JSON format"
|
|
198
|
+
],
|
|
199
|
+
outputs: {
|
|
200
|
+
default: "created <path>",
|
|
201
|
+
json: "{\"schema_version\":\"1.0\",\"path\":\"...\",\"template\":\"...\",\"files_created\":[...]}"
|
|
202
|
+
},
|
|
203
|
+
errors: ["exit 3: Directory already exists", "exit 6: Invalid template"],
|
|
204
|
+
sideEffects: ["Creates directory structure", "Creates configuration files"],
|
|
205
|
+
defaultBehavior: "Interactive prompts for project name and template if not specified"
|
|
206
|
+
},
|
|
207
|
+
"serve-mcp": {
|
|
208
|
+
command: "aigne serve-mcp [path]",
|
|
209
|
+
purpose: "Serve agents as an MCP (Model Context Protocol) server",
|
|
210
|
+
input: [
|
|
211
|
+
"path (optional): Path to agent directory",
|
|
212
|
+
"--host: Host to bind (default: localhost)",
|
|
213
|
+
"--port: Port to listen on",
|
|
214
|
+
"--pathname: URL pathname (default: /mcp)",
|
|
215
|
+
"--json: Output startup info in JSON format"
|
|
216
|
+
],
|
|
217
|
+
outputs: {
|
|
218
|
+
default: "listening <host>:<port><pathname>",
|
|
219
|
+
json: "{\"schema_version\":\"1.0\",\"status\":\"listening\",\"host\":\"...\",\"port\":N,\"path\":\"...\"}"
|
|
220
|
+
},
|
|
221
|
+
errors: [
|
|
222
|
+
"exit 1: Agent not found",
|
|
223
|
+
"exit 5: Server startup failed",
|
|
224
|
+
"exit 7: Port already in use"
|
|
225
|
+
],
|
|
226
|
+
sideEffects: ["Starts HTTP server", "Listens for MCP connections"],
|
|
227
|
+
defaultBehavior: "Loads agent from current directory, starts MCP server on localhost"
|
|
228
|
+
},
|
|
229
|
+
observe: {
|
|
230
|
+
command: "aigne observe",
|
|
231
|
+
purpose: "Start the observability server for agent debugging",
|
|
232
|
+
input: [
|
|
233
|
+
"--port: Port to listen on",
|
|
234
|
+
"--host: Host to bind",
|
|
235
|
+
"--json: Output startup info in JSON format"
|
|
236
|
+
],
|
|
237
|
+
outputs: {
|
|
238
|
+
default: "listening <host>:<port>",
|
|
239
|
+
json: "{\"schema_version\":\"1.0\",\"status\":\"listening\",\"host\":\"...\",\"port\":N}"
|
|
240
|
+
},
|
|
241
|
+
errors: ["exit 5: Server startup failed", "exit 7: Port already in use"],
|
|
242
|
+
sideEffects: ["Starts HTTP server", "Provides tracing and debugging UI"],
|
|
243
|
+
defaultBehavior: "Starts observability server on default port"
|
|
244
|
+
},
|
|
245
|
+
hub: {
|
|
246
|
+
command: "aigne hub <command>",
|
|
247
|
+
purpose: "Manage AIGNE Hub connections",
|
|
248
|
+
input: ["command: list|connect|use|status|remove"],
|
|
249
|
+
outputs: { default: "Varies by subcommand" },
|
|
250
|
+
errors: ["See individual subcommand documentation"],
|
|
251
|
+
sideEffects: ["Varies by subcommand - see aigne explain hub <subcommand>"],
|
|
252
|
+
defaultBehavior: "Shows hub command help if no subcommand specified"
|
|
253
|
+
},
|
|
254
|
+
explain: {
|
|
255
|
+
command: "aigne explain [command..]",
|
|
256
|
+
purpose: "Show machine-readable documentation for CLI commands",
|
|
257
|
+
input: ["command (optional): Command path to explain (e.g., hub list)"],
|
|
258
|
+
outputs: { default: "Without args: lists available commands. With args: shows structured documentation for the command" },
|
|
259
|
+
errors: ["ERROR unknown_command: Command not found in documentation"],
|
|
260
|
+
sideEffects: ["None - read-only operation"],
|
|
261
|
+
defaultBehavior: "Lists all available commands if no command specified"
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Print command documentation in structured format.
|
|
266
|
+
*/
|
|
267
|
+
function printCommandDoc(doc) {
|
|
268
|
+
console.log(`COMMAND ${doc.command}`);
|
|
269
|
+
console.log("");
|
|
270
|
+
console.log("PURPOSE");
|
|
271
|
+
console.log(` ${doc.purpose}`);
|
|
272
|
+
console.log("");
|
|
273
|
+
console.log("INPUT");
|
|
274
|
+
for (const input of doc.input) console.log(` ${input}`);
|
|
275
|
+
console.log("");
|
|
276
|
+
console.log("OUTPUT default:");
|
|
277
|
+
console.log(` ${doc.outputs.default}`);
|
|
278
|
+
if (doc.outputs.json) {
|
|
279
|
+
console.log("OUTPUT --json:");
|
|
280
|
+
console.log(` ${doc.outputs.json}`);
|
|
281
|
+
}
|
|
282
|
+
if (doc.outputs.llm) {
|
|
283
|
+
console.log("OUTPUT --view=llm:");
|
|
284
|
+
console.log(` ${doc.outputs.llm}`);
|
|
285
|
+
}
|
|
286
|
+
console.log("");
|
|
287
|
+
console.log("ERRORS");
|
|
288
|
+
for (const error of doc.errors) console.log(` ${error}`);
|
|
289
|
+
console.log("");
|
|
290
|
+
console.log("SIDE EFFECTS");
|
|
291
|
+
for (const effect of doc.sideEffects) console.log(` ${effect}`);
|
|
292
|
+
console.log("");
|
|
293
|
+
console.log("DEFAULT BEHAVIOR");
|
|
294
|
+
console.log(` ${doc.defaultBehavior}`);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Print list of all available commands.
|
|
298
|
+
*/
|
|
299
|
+
function printAvailableCommands() {
|
|
300
|
+
console.log("AVAILABLE COMMANDS");
|
|
301
|
+
for (const cmd of availableCommands) console.log(` ${cmd.name.padEnd(12)} ${cmd.description}`);
|
|
302
|
+
console.log("");
|
|
303
|
+
console.log("Use 'aigne explain <command>' for detailed documentation.");
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Create the explain command.
|
|
307
|
+
*/
|
|
308
|
+
function createExplainCommand() {
|
|
309
|
+
return {
|
|
310
|
+
command: "explain [command..]",
|
|
311
|
+
describe: "Show machine-readable documentation for a command",
|
|
312
|
+
builder: (yargs) => yargs.positional("command", {
|
|
313
|
+
type: "string",
|
|
314
|
+
describe: "Command path to explain (e.g., hub list)",
|
|
315
|
+
array: true,
|
|
316
|
+
default: []
|
|
317
|
+
}),
|
|
318
|
+
handler: (args) => {
|
|
319
|
+
const commands = args.command;
|
|
320
|
+
if (commands.length === 0) {
|
|
321
|
+
printAvailableCommands();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const commandPath = commands.join(" ");
|
|
325
|
+
const doc = commandDocs[commandPath];
|
|
326
|
+
if (!doc) {
|
|
327
|
+
console.log(`ERROR unknown_command ${commandPath}`);
|
|
328
|
+
console.log("");
|
|
329
|
+
printAvailableCommands();
|
|
330
|
+
process.exitCode = 1;
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
printCommandDoc(doc);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
//#endregion
|
|
339
|
+
export { createExplainCommand };
|
|
340
|
+
//# sourceMappingURL=explain.mjs.map
|