@kweaver-ai/kweaver-sdk 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +26 -52
  2. package/README.zh.md +27 -46
  3. package/dist/api/resources.d.ts +94 -0
  4. package/dist/api/resources.js +166 -0
  5. package/dist/cli.js +102 -10
  6. package/dist/client.d.ts +3 -3
  7. package/dist/client.js +5 -5
  8. package/dist/commands/agent-members.js +27 -11
  9. package/dist/commands/agent.js +383 -272
  10. package/dist/commands/auth.js +184 -71
  11. package/dist/commands/bkn-metric.js +37 -16
  12. package/dist/commands/bkn-ops.js +164 -86
  13. package/dist/commands/bkn-query.js +99 -31
  14. package/dist/commands/bkn-schema.d.ts +3 -3
  15. package/dist/commands/bkn-schema.js +127 -86
  16. package/dist/commands/bkn.js +153 -114
  17. package/dist/commands/call.js +23 -13
  18. package/dist/commands/config.js +22 -12
  19. package/dist/commands/context-loader.js +98 -92
  20. package/dist/commands/dataflow.js +14 -6
  21. package/dist/commands/ds.js +52 -30
  22. package/dist/commands/explore.js +18 -15
  23. package/dist/commands/model.js +53 -42
  24. package/dist/commands/resource.d.ts +1 -0
  25. package/dist/commands/{dataview.js → resource.js} +62 -84
  26. package/dist/commands/skill.js +201 -65
  27. package/dist/commands/token.js +11 -0
  28. package/dist/commands/tool.js +46 -29
  29. package/dist/commands/toolbox.js +31 -15
  30. package/dist/commands/vega.js +466 -250
  31. package/dist/help/format.d.ts +65 -0
  32. package/dist/help/format.js +141 -0
  33. package/dist/index.d.ts +3 -3
  34. package/dist/index.js +2 -2
  35. package/dist/resources/{dataviews.d.ts → resources.d.ts} +10 -11
  36. package/dist/resources/{dataviews.js → resources.js} +12 -13
  37. package/package.json +1 -1
  38. package/dist/api/dataviews.d.ts +0 -117
  39. package/dist/api/dataviews.js +0 -265
  40. package/dist/commands/dataview.d.ts +0 -8
@@ -4,129 +4,265 @@ import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/
4
4
  import { resolveBusinessDomain } from "../config/store.js";
5
5
  import { deleteSkill, downloadSkill, downloadSkillManagementArchive, fetchSkillContent, fetchSkillFile, getSkill, getSkillMarketDetail, getSkillContentIndex, getSkillManagementContent, installSkillArchive, listSkillMarket, listSkillHistory, listSkills, publishSkillHistory, readSkillFile, readSkillManagementFile, republishSkillHistory, registerSkillZip, updateSkillMetadata, updateSkillPackageContent, updateSkillPackageZip, updateSkillStatus, } from "../api/skills.js";
6
6
  import { bundleSkillDirectoryToZip, bundleSkillFileToZip } from "../utils/skill-bundle.js";
7
+ import { renderHelp } from "../help/format.js";
8
+ const SKILL_HELP = renderHelp({
9
+ tagline: "Skill registry and market — register, market, content, lifecycle",
10
+ usage: "kweaver skill <subcommand> [flags]",
11
+ sections: [
12
+ {
13
+ title: "REGISTRY",
14
+ items: [
15
+ { name: "list", desc: "List skills (filter by --name / --status / --source / --create-user)" },
16
+ { name: "get", desc: "Get a skill by id" },
17
+ { name: "register", desc: "Register a skill (--content-file <SKILL.md|dir> | --zip-file <path>)" },
18
+ { name: "set-status", desc: "Change status: unpublish | published | offline" },
19
+ { name: "delete", desc: "Delete a skill" },
20
+ ],
21
+ },
22
+ {
23
+ title: "MARKET",
24
+ items: [
25
+ { name: "market", desc: "Browse the skill market" },
26
+ { name: "market-get", desc: "Get a market skill by id" },
27
+ { name: "download", desc: "Download a skill package archive" },
28
+ { name: "install", desc: "Install a skill locally" },
29
+ ],
30
+ },
31
+ {
32
+ title: "CONTENT",
33
+ items: [
34
+ { name: "content", desc: "Read SKILL.md content" },
35
+ { name: "read-file", desc: "Read a file inside a skill (progressive)" },
36
+ { name: "management-content", desc: "Read SKILL.md via management endpoint" },
37
+ { name: "management-read-file", desc: "Read file inside skill via management endpoint" },
38
+ { name: "management-download", desc: "Download via management endpoint" },
39
+ ],
40
+ },
41
+ {
42
+ title: "LIFECYCLE",
43
+ items: [
44
+ { name: "update-metadata", desc: "Update metadata (name / description / category / source)" },
45
+ { name: "update-package", desc: "Update package content or zip" },
46
+ { name: "history", desc: "Show version history" },
47
+ { name: "republish", desc: "Republish a specific historical version" },
48
+ { name: "publish-history", desc: "Publish a historical version" },
49
+ ],
50
+ },
51
+ ],
52
+ flags: [
53
+ { name: "-bd, --biz-domain <s>", desc: "Business domain (default: bd_public)" },
54
+ { name: "--pretty / --compact", desc: "JSON output style (default: pretty)" },
55
+ ],
56
+ inheritedFlags: "--base-url, --token, --user, --help",
57
+ examples: [
58
+ "kweaver skill list --name kweaver",
59
+ "kweaver skill register --zip-file ./demo-skill.zip --source upload_zip",
60
+ "kweaver skill install skill-123 ./skills/demo-skill --force",
61
+ ],
62
+ learnMore: ["Use `kweaver skill <subcommand> --help` for flag details"],
63
+ });
7
64
  function printSkillHelp(subcommand) {
8
65
  if (subcommand === "list") {
9
- console.log(`kweaver skill list [--name kw] [--source src] [--status status] [--create-user user]
10
- [--page N] [--page-size N|--limit N] [--all] [-bd value] [--pretty|--compact]`);
66
+ console.log(renderHelp({
67
+ tagline: "List installed skills.",
68
+ usage: "kweaver skill list [--name kw] [--source src] [--status status] [--create-user user] [--page N] [--page-size N|--limit N] [--all] [-bd value] [--pretty|--compact]",
69
+ flags: [
70
+ { name: "--name kw", desc: "Filter by name keyword." },
71
+ { name: "--source src", desc: "Filter by source." },
72
+ { name: "--status status", desc: "Filter by status." },
73
+ { name: "--create-user user", desc: "Filter by creator." },
74
+ { name: "--page N", desc: "Page number." },
75
+ { name: "--page-size N", desc: "Page size (alias: --limit)." },
76
+ { name: "--all", desc: "Fetch all pages." },
77
+ { name: "-bd value", desc: "Override base URL." },
78
+ { name: "--pretty|--compact", desc: "Toggle pretty JSON output." },
79
+ ],
80
+ inheritedFlags: "--base-url, --token, --user, --help",
81
+ }));
11
82
  return;
12
83
  }
13
84
  if (subcommand === "market") {
14
- console.log(`kweaver skill market [--name kw] [--source src] [--page N] [--page-size N|--limit N]
15
- [--all] [-bd value] [--pretty|--compact]`);
85
+ console.log(renderHelp({
86
+ tagline: "Browse the skill marketplace.",
87
+ usage: "kweaver skill market [--name kw] [--source src] [--page N] [--page-size N|--limit N] [--all] [-bd value] [--pretty|--compact]",
88
+ flags: [
89
+ { name: "--name kw", desc: "Filter by name keyword." },
90
+ { name: "--source src", desc: "Filter by source." },
91
+ { name: "--page N", desc: "Page number." },
92
+ { name: "--page-size N", desc: "Page size (alias: --limit)." },
93
+ { name: "--all", desc: "Fetch all pages." },
94
+ { name: "-bd value", desc: "Override base URL." },
95
+ { name: "--pretty|--compact", desc: "Toggle pretty JSON output." },
96
+ ],
97
+ inheritedFlags: "--base-url, --token, --user, --help",
98
+ }));
16
99
  return;
17
100
  }
18
101
  if (subcommand === "get") {
19
- console.log("kweaver skill get <skill-id> [-bd value] [--pretty|--compact]");
102
+ console.log(renderHelp({
103
+ tagline: "Show installed skill details.",
104
+ usage: "kweaver skill get <skill-id> [-bd value] [--pretty|--compact]",
105
+ inheritedFlags: "--base-url, --token, --user, --help",
106
+ }));
20
107
  return;
21
108
  }
22
109
  if (subcommand === "market-get") {
23
- console.log("kweaver skill market-get <skill-id> [-bd value] [--pretty|--compact]");
110
+ console.log(renderHelp({
111
+ tagline: "Show marketplace skill details.",
112
+ usage: "kweaver skill market-get <skill-id> [-bd value] [--pretty|--compact]",
113
+ inheritedFlags: "--base-url, --token, --user, --help",
114
+ }));
24
115
  return;
25
116
  }
26
117
  if (subcommand === "register") {
27
- console.log(`kweaver skill register (--content-file <path> | --zip-file <path>)
28
- [--source src] [--extend-info json] [-bd value] [--pretty|--compact]
29
-
30
- --content-file accepts either:
31
- - a single file named SKILL.md (auto-bundled into a 1-file zip)
32
- - a skill directory containing SKILL.md (bundled into a zip)
33
- Both paths upload as multipart zip; the backend's file_type=content
34
- registration is unreliable (publish-then-read returns 404) so the CLI
35
- always goes through zip.
36
- --zip-file accepts a pre-built .zip with SKILL.md at the archive root.`);
118
+ console.log(renderHelp({
119
+ tagline: "Register a new skill (multipart zip upload).",
120
+ usage: "kweaver skill register (--content-file <path> | --zip-file <path>) [--source src] [--extend-info json] [-bd value] [--pretty|--compact]",
121
+ flags: [
122
+ { name: "--content-file <path>", desc: "SKILL.md file or skill directory containing SKILL.md (auto-bundled into a zip)." },
123
+ { name: "--zip-file <path>", desc: "Pre-built .zip with SKILL.md at the archive root." },
124
+ { name: "--source src", desc: "Source tag." },
125
+ { name: "--extend-info json", desc: "Extra metadata as JSON object." },
126
+ { name: "-bd value", desc: "Override base URL." },
127
+ { name: "--pretty|--compact", desc: "Toggle pretty JSON output." },
128
+ ],
129
+ inheritedFlags: "--base-url, --token, --user, --help",
130
+ learnMore: [
131
+ "Both --content-file and --zip-file upload as multipart zip; the backend's",
132
+ "file_type=content registration is unreliable (publish-then-read returns 404)",
133
+ "so the CLI always goes through zip.",
134
+ ],
135
+ }));
37
136
  return;
38
137
  }
39
138
  if (subcommand === "set-status" || subcommand === "status") {
40
- console.log("kweaver skill set-status <skill-id> <unpublish|published|offline> [-bd value] [--pretty|--compact]");
139
+ console.log(renderHelp({
140
+ tagline: "Set skill publish status.",
141
+ usage: "kweaver skill set-status <skill-id> <unpublish|published|offline> [-bd value] [--pretty|--compact]",
142
+ inheritedFlags: "--base-url, --token, --user, --help",
143
+ }));
41
144
  return;
42
145
  }
43
146
  if (subcommand === "delete") {
44
- console.log("kweaver skill delete <skill-id> [-y|--yes] [-bd value] [--pretty|--compact]");
147
+ console.log(renderHelp({
148
+ tagline: "Delete a skill.",
149
+ usage: "kweaver skill delete <skill-id> [-y|--yes] [-bd value] [--pretty|--compact]",
150
+ inheritedFlags: "--base-url, --token, --user, --help",
151
+ }));
45
152
  return;
46
153
  }
47
154
  if (subcommand === "update-metadata") {
48
- console.log(`kweaver skill update-metadata <skill-id> --name <name> --description <text> --category <other_category|system>
49
- [--source <custom|internal>] [--extend-info json] [-bd value] [--pretty|--compact]`);
155
+ console.log(renderHelp({
156
+ tagline: "Update skill metadata fields.",
157
+ usage: "kweaver skill update-metadata <skill-id> --name <name> --description <text> --category <other_category|system> [--source <custom|internal>] [--extend-info json] [-bd value] [--pretty|--compact]",
158
+ flags: [
159
+ { name: "--name <name>", desc: "Skill name." },
160
+ { name: "--description <text>", desc: "Skill description." },
161
+ { name: "--category <other_category|system>", desc: "Skill category." },
162
+ { name: "--source <custom|internal>", desc: "Source tag." },
163
+ { name: "--extend-info json", desc: "Extra metadata as JSON object." },
164
+ { name: "-bd value", desc: "Override base URL." },
165
+ { name: "--pretty|--compact", desc: "Toggle pretty JSON output." },
166
+ ],
167
+ inheritedFlags: "--base-url, --token, --user, --help",
168
+ }));
50
169
  return;
51
170
  }
52
171
  if (subcommand === "update-package") {
53
- console.log(`kweaver skill update-package <skill-id> (--content-file <path> | --zip-file <path>)
54
- [-bd value] [--pretty|--compact]`);
172
+ console.log(renderHelp({
173
+ tagline: "Replace skill package contents.",
174
+ usage: "kweaver skill update-package <skill-id> (--content-file <path> | --zip-file <path>) [-bd value] [--pretty|--compact]",
175
+ flags: [
176
+ { name: "--content-file <path>", desc: "SKILL.md file or skill directory (auto-bundled into a zip)." },
177
+ { name: "--zip-file <path>", desc: "Pre-built .zip with SKILL.md at the archive root." },
178
+ { name: "-bd value", desc: "Override base URL." },
179
+ { name: "--pretty|--compact", desc: "Toggle pretty JSON output." },
180
+ ],
181
+ inheritedFlags: "--base-url, --token, --user, --help",
182
+ }));
55
183
  return;
56
184
  }
57
185
  if (subcommand === "history") {
58
- console.log("kweaver skill history <skill-id> [-bd value] [--pretty|--compact]");
186
+ console.log(renderHelp({
187
+ tagline: "Show skill edit history.",
188
+ usage: "kweaver skill history <skill-id> [-bd value] [--pretty|--compact]",
189
+ inheritedFlags: "--base-url, --token, --user, --help",
190
+ }));
59
191
  return;
60
192
  }
61
193
  if (subcommand === "republish") {
62
- console.log("kweaver skill republish <skill-id> --version <version> [-bd value] [--pretty|--compact]");
194
+ console.log(renderHelp({
195
+ tagline: "Republish a previous skill version.",
196
+ usage: "kweaver skill republish <skill-id> --version <version> [-bd value] [--pretty|--compact]",
197
+ inheritedFlags: "--base-url, --token, --user, --help",
198
+ }));
63
199
  return;
64
200
  }
65
201
  if (subcommand === "publish-history") {
66
- console.log("kweaver skill publish-history <skill-id> --version <version> [-bd value] [--pretty|--compact]");
202
+ console.log(renderHelp({
203
+ tagline: "Show publish history for a version.",
204
+ usage: "kweaver skill publish-history <skill-id> --version <version> [-bd value] [--pretty|--compact]",
205
+ inheritedFlags: "--base-url, --token, --user, --help",
206
+ }));
67
207
  return;
68
208
  }
69
209
  if (subcommand === "content") {
70
- console.log("kweaver skill content <skill-id> [--raw] [--output file] [-bd value] [--pretty|--compact]");
210
+ console.log(renderHelp({
211
+ tagline: "Fetch installed skill SKILL.md content.",
212
+ usage: "kweaver skill content <skill-id> [--raw] [--output file] [-bd value] [--pretty|--compact]",
213
+ inheritedFlags: "--base-url, --token, --user, --help",
214
+ }));
71
215
  return;
72
216
  }
73
217
  if (subcommand === "read-file") {
74
- console.log("kweaver skill read-file <skill-id> <rel-path> [--raw] [--output file] [-bd value] [--pretty|--compact]");
218
+ console.log(renderHelp({
219
+ tagline: "Read a file from an installed skill.",
220
+ usage: "kweaver skill read-file <skill-id> <rel-path> [--raw] [--output file] [-bd value] [--pretty|--compact]",
221
+ inheritedFlags: "--base-url, --token, --user, --help",
222
+ }));
75
223
  return;
76
224
  }
77
225
  if (subcommand === "download") {
78
- console.log("kweaver skill download <skill-id> [--output file] [-bd value] [--pretty|--compact]");
226
+ console.log(renderHelp({
227
+ tagline: "Download an installed skill package.",
228
+ usage: "kweaver skill download <skill-id> [--output file] [-bd value] [--pretty|--compact]",
229
+ inheritedFlags: "--base-url, --token, --user, --help",
230
+ }));
79
231
  return;
80
232
  }
81
233
  if (subcommand === "install") {
82
- console.log("kweaver skill install <skill-id> [directory] [--force] [-bd value] [--pretty|--compact]");
234
+ console.log(renderHelp({
235
+ tagline: "Install a skill locally.",
236
+ usage: "kweaver skill install <skill-id> [directory] [--force] [-bd value] [--pretty|--compact]",
237
+ inheritedFlags: "--base-url, --token, --user, --help",
238
+ }));
83
239
  return;
84
240
  }
85
241
  if (subcommand === "management-content") {
86
- console.log("kweaver skill management-content <skill-id> [--raw] [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]");
242
+ console.log(renderHelp({
243
+ tagline: "Fetch management-side skill SKILL.md content.",
244
+ usage: "kweaver skill management-content <skill-id> [--raw] [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]",
245
+ inheritedFlags: "--base-url, --token, --user, --help",
246
+ }));
87
247
  return;
88
248
  }
89
249
  if (subcommand === "management-read-file") {
90
- console.log("kweaver skill management-read-file <skill-id> <rel-path> [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]");
250
+ console.log(renderHelp({
251
+ tagline: "Read a file via management API.",
252
+ usage: "kweaver skill management-read-file <skill-id> <rel-path> [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]",
253
+ inheritedFlags: "--base-url, --token, --user, --help",
254
+ }));
91
255
  return;
92
256
  }
93
257
  if (subcommand === "management-download") {
94
- console.log("kweaver skill management-download <skill-id> [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]");
258
+ console.log(renderHelp({
259
+ tagline: "Download a skill via management API.",
260
+ usage: "kweaver skill management-download <skill-id> [--response-mode url|content] [--output file] [-bd value] [--pretty|--compact]",
261
+ inheritedFlags: "--base-url, --token, --user, --help",
262
+ }));
95
263
  return;
96
264
  }
97
- console.log(`kweaver skill
98
-
99
- Subcommands:
100
- list [--name kw] [--status status] [--page N] [--page-size N] [-bd value]
101
- market [--name kw] [--source src] [--page N] [--page-size N] [-bd value]
102
- get <skill-id> [-bd value]
103
- market-get <skill-id> [-bd value]
104
- register --content-file <path> | --zip-file <path> [--source src] [--extend-info json]
105
- (--content-file accepts a file named SKILL.md or a directory; both auto-zip)
106
- set-status <skill-id> <unpublish|published|offline> [-bd value]
107
- delete <skill-id> [-y] [-bd value]
108
- update-metadata <skill-id> --name <name> --description <text> --category <other_category|system> [--source <custom|internal>] [--extend-info json]
109
- update-package <skill-id> (--content-file <path> | --zip-file <path>) [-bd value]
110
- history <skill-id> [-bd value]
111
- republish <skill-id> --version <version> [-bd value]
112
- publish-history <skill-id> --version <version> [-bd value]
113
- content <skill-id> [--raw] [--output file] [-bd value]
114
- read-file <skill-id> <rel-path> [--raw] [--output file] [-bd value]
115
- download <skill-id> [--output file] [-bd value]
116
- install <skill-id> [directory] [--force] [-bd value]
117
- management-content <skill-id> [--raw] [--response-mode url|content] [--output file] [-bd value]
118
- management-read-file <skill-id> <rel-path> [--response-mode url|content] [--output file] [-bd value]
119
- management-download <skill-id> [--response-mode url|content] [--output file] [-bd value]
120
-
121
- Examples:
122
- kweaver skill list --name kweaver
123
- kweaver skill register --zip-file ./demo-skill.zip --source upload_zip
124
- kweaver skill update-metadata skill-123 --name "Demo" --description "Demo skill" --category system
125
- kweaver skill update-package skill-123 --content-file ./SKILL.md
126
- kweaver skill history skill-123
127
- kweaver skill content skill-123 --raw
128
- kweaver skill read-file skill-123 references/guide.md --output ./guide.md
129
- kweaver skill install skill-123 ./skills/demo-skill --force`);
265
+ console.log(SKILL_HELP);
130
266
  }
131
267
  function format(value, pretty) {
132
268
  return JSON.stringify(value, null, pretty ? 2 : 0);
@@ -1,10 +1,21 @@
1
1
  import { ensureValidToken, formatHttpError } from "../auth/oauth.js";
2
+ import { renderHelp } from "../help/format.js";
3
+ const HELP = renderHelp({
4
+ tagline: "Print the current access token (auto-refresh first if needed)",
5
+ usage: "kweaver token",
6
+ inheritedFlags: "--base-url, --token, --user, --help",
7
+ examples: ["kweaver token", "kweaver --user alice token"],
8
+ });
2
9
  export function parseTokenArgs(args) {
3
10
  if (args.length > 0) {
4
11
  throw new Error("Usage: kweaver token");
5
12
  }
6
13
  }
7
14
  export async function runTokenCommand(args) {
15
+ if (args[0] === "--help" || args[0] === "-h") {
16
+ console.log(HELP);
17
+ return 0;
18
+ }
8
19
  try {
9
20
  parseTokenArgs(args);
10
21
  }
@@ -3,35 +3,52 @@ import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/
3
3
  import { debugTool, executeTool, listTools, setToolStatuses, uploadTool } from "../api/toolboxes.js";
4
4
  import { formatCallOutput } from "./call.js";
5
5
  import { resolveBusinessDomain } from "../config/store.js";
6
- const HELP = `kweaver tool
7
-
8
- Subcommands:
9
- upload --toolbox <box-id> <openapi-spec-path> [--metadata-type openapi]
10
- Upload an OpenAPI spec file as a tool
11
- list --toolbox <box-id> List tools in a toolbox
12
- enable --toolbox <box-id> <tool-id>... Enable one or more tools
13
- disable --toolbox <box-id> <tool-id>... Disable one or more tools
14
- execute --toolbox <box-id> <tool-id> [--body '<json>'|--body-file <path>]
15
- [--header|--query|--path '<json>']
16
- Invoke a published+enabled tool
17
- debug --toolbox <box-id> <tool-id> [--body '<json>'|--body-file <path>]
18
- [--header|--query|--path '<json>']
19
- Invoke a tool (works on draft/disabled too)
20
-
21
- Options for execute/debug:
22
- --header '<json>' Headers map forwarded to the downstream tool
23
- (Authorization is auto-injected from current session
24
- when --header omits it; pass {} to send none)
25
- --query '<json>' Query params map forwarded to the downstream tool
26
- --path '<json>' Path parameter map for OpenAPI path placeholders (e.g. {id})
27
- (JSON object: quote id and UUID, e.g. key id for get_dataview_detail /
28
- query_dataview_sql)
29
- --timeout <seconds> Per-call timeout (backend default applies when omitted)
30
-
31
- Common options:
32
- -bd, --biz-domain <s> Business domain (default: bd_public)
33
- --pretty Pretty-print JSON (default)
34
- --compact Single-line JSON (pipeline-friendly)`;
6
+ import { renderHelp } from "../help/format.js";
7
+ const HELP = renderHelp({
8
+ tagline: "Tools inside a toolbox — upload OpenAPI specs, enable/disable, execute",
9
+ usage: "kweaver tool <subcommand> --toolbox <box-id> [flags]",
10
+ sections: [
11
+ {
12
+ title: "AVAILABLE COMMANDS",
13
+ items: [
14
+ { name: "upload", desc: "Upload an OpenAPI spec file as a tool" },
15
+ { name: "list", desc: "List tools in a toolbox" },
16
+ { name: "enable", desc: "Enable one or more tools" },
17
+ { name: "disable", desc: "Disable one or more tools" },
18
+ { name: "execute", desc: "Invoke a published+enabled tool" },
19
+ { name: "debug", desc: "Invoke a tool (works on draft/disabled too)" },
20
+ ],
21
+ },
22
+ ],
23
+ flags: [
24
+ {
25
+ title: "Execute / debug",
26
+ flags: [
27
+ { name: "--body '<json>'", desc: "Request body" },
28
+ { name: "--body-file <path>", desc: "Request body from file" },
29
+ { name: "--header '<json>'", desc: "Headers map (Authorization auto-injected if omitted; pass {} to send none)" },
30
+ { name: "--query '<json>'", desc: "Query params map" },
31
+ { name: "--path '<json>'", desc: "Path params for OpenAPI placeholders, e.g. {\"id\":\"...\"}" },
32
+ { name: "--timeout <seconds>", desc: "Per-call timeout (backend default applies when omitted)" },
33
+ ],
34
+ },
35
+ {
36
+ title: "Common",
37
+ flags: [
38
+ { name: "-bd, --biz-domain <s>", desc: "Business domain (default: bd_public)" },
39
+ { name: "--pretty", desc: "Pretty-print JSON (default)" },
40
+ { name: "--compact", desc: "Single-line JSON (pipeline-friendly)" },
41
+ ],
42
+ },
43
+ ],
44
+ inheritedFlags: "--base-url, --token, --user, --help",
45
+ examples: [
46
+ "kweaver tool upload --toolbox <box-id> spec.yaml",
47
+ "kweaver tool list --toolbox <box-id>",
48
+ "kweaver tool execute --toolbox <box-id> <tool-id> --body '{\"key\":\"value\"}'",
49
+ ],
50
+ learnMore: ["Use `kweaver tool <subcommand> --help` for flag details"],
51
+ });
35
52
  export async function runToolCommand(args) {
36
53
  const [subcommand, ...rest] = args;
37
54
  if (!subcommand || subcommand === "--help" || subcommand === "-h") {
@@ -4,22 +4,38 @@ import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/
4
4
  import { createToolbox, deleteToolbox, exportConfig, importConfig, listToolboxes, setToolboxStatus, } from "../api/toolboxes.js";
5
5
  import { formatCallOutput } from "./call.js";
6
6
  import { resolveBusinessDomain } from "../config/store.js";
7
+ import { renderHelp } from "../help/format.js";
7
8
  const VALID_IMPEX_TYPES = new Set(["toolbox", "mcp", "operator"]);
8
- const HELP = `kweaver toolbox
9
-
10
- Subcommands:
11
- create --name <n> --service-url <url> [--description <d>] Create a new toolbox
12
- list [--keyword <s>] [--limit <n>] [--offset <n>] List toolboxes
13
- publish <box-id> Publish a toolbox (status=published)
14
- unpublish <box-id> Unpublish (status=draft)
15
- delete <box-id> [-y|--yes] Delete a toolbox
16
- export <box-id> [-o <file>|-] [--type toolbox|mcp|operator] Export toolbox config (.adp JSON)
17
- import <file> [--type toolbox|mcp|operator] Import a previously exported config
18
-
19
- Options:
20
- -bd, --biz-domain <s> Business domain (default: bd_public)
21
- --pretty Pretty-print JSON (default)
22
- --compact Single-line JSON (pipeline-friendly)`;
9
+ const HELP = renderHelp({
10
+ tagline: "Agent toolbox lifecycle — create, list, publish, delete, export/import",
11
+ usage: "kweaver toolbox <subcommand> [flags]",
12
+ sections: [
13
+ {
14
+ title: "AVAILABLE COMMANDS",
15
+ items: [
16
+ { name: "create", desc: "Create a new toolbox" },
17
+ { name: "list", desc: "List toolboxes" },
18
+ { name: "publish", desc: "Publish a toolbox (status=published)" },
19
+ { name: "unpublish", desc: "Unpublish (status=draft)" },
20
+ { name: "delete", desc: "Delete a toolbox" },
21
+ { name: "export", desc: "Export toolbox config (.adp JSON)" },
22
+ { name: "import", desc: "Import a previously exported config" },
23
+ ],
24
+ },
25
+ ],
26
+ flags: [
27
+ { name: "-bd, --biz-domain <s>", desc: "Business domain (default: bd_public)" },
28
+ { name: "--pretty", desc: "Pretty-print JSON (default)" },
29
+ { name: "--compact", desc: "Single-line JSON (pipeline-friendly)" },
30
+ ],
31
+ inheritedFlags: "--base-url, --token, --user, --help",
32
+ examples: [
33
+ "kweaver toolbox create --name MyBox --service-url https://svc.example.com",
34
+ "kweaver toolbox list --keyword analytics",
35
+ "kweaver toolbox export <box-id> -o box.adp",
36
+ ],
37
+ learnMore: ["Use `kweaver toolbox <subcommand> --help` for flag details"],
38
+ });
23
39
  export async function runToolboxCommand(args) {
24
40
  const [subcommand, ...rest] = args;
25
41
  if (!subcommand || subcommand === "--help" || subcommand === "-h") {