@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,6 +4,7 @@ import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/
4
4
  import { listKnowledgeNetworks, getKnowledgeNetwork, createKnowledgeNetwork, updateKnowledgeNetwork, deleteKnowledgeNetwork, } from "../api/knowledge-networks.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
  import { runKnObjectTypeCommand, runKnRelationTypeCommand, runKnActionTypeCommand, runKnConceptGroupCommand, } from "./bkn-schema.js";
8
9
  import { runKnSubgraphCommand, runKnActionExecutionCommand, runKnActionLogCommand, runKnSearchCommand, runKnRelationTypePathsCommand, runKnResourcesCommand, } from "./bkn-query.js";
9
10
  import { runKnBuildCommand, runKnValidateCommand, runKnPushCommand, runKnPullCommand, runKnCreateFromDsCommand, runKnCreateFromCsvCommand, runKnActionScheduleCommand, runKnJobCommand, } from "./bkn-ops.js";
@@ -357,57 +358,77 @@ export function parseKnDeleteArgs(args) {
357
358
  businessDomain = resolveBusinessDomain();
358
359
  return { knId, businessDomain, yes };
359
360
  }
360
- const KN_HELP = `kweaver bkn
361
-
362
- Subcommands:
363
- list [options] List business knowledge networks
364
- get <kn-id> [options] Get knowledge network detail (use --stats or --export)
365
- create [options] Create a knowledge network (empty or from --body-file)
366
- create-from-ds <ds-id> --name X [--tables a,b] [--build] Create KN from datasource
367
- create-from-csv <ds-id> --files <glob> --name X [--table-prefix P] [--build]
368
- Import CSVs then create knowledge network
369
- update <kn-id> [options] Update a knowledge network
370
- delete <kn-id> Delete a knowledge network
371
- build <kn-id> [--wait|--no-wait] [--timeout n] Trigger full build
372
- validate <directory> [--detect-encoding|--no-detect-encoding] [--source-encoding n] Validate local BKN (no upload)
373
- push <directory> [--branch main] [--detect-encoding|--no-detect-encoding] [--source-encoding n] Upload BKN as tar
374
- pull <kn-id> [<directory>] [--branch main] Download BKN tar and extract
375
- export <kn-id> Export knowledge network (alias for get --export)
376
- stats <kn-id> Get statistics (alias for get --stats)
377
- search <kn-id> <query> [options] Semantic search within a knowledge network
378
- object-type list <kn-id> List object types (schema)
379
- object-type get <kn-id> <ot-id> Get object type details
380
- object-type create <kn-id> [options] Create object type (--name --dataview-id --primary-key --display-key)
381
- object-type update <kn-id> <ot-id> [options] Update object type
382
- object-type delete <kn-id> <ot-ids> [-y] Delete object type(s)
383
- object-type query <kn-id> <ot-id> ['<json>'] Query object instances (ontology-query; supports --limit/--search-after)
384
- object-type properties <kn-id> <ot-id> '<json>' Query instance properties (json: {"_instance_identities":[{pk:val}],"properties":[...]})
385
- relation-type list <kn-id> List relation types (schema)
386
- relation-type get <kn-id> <rt-id> Get relation type details
387
- relation-type create <kn-id> [options] Create relation type (--name --source --target [--mapping src:tgt])
388
- relation-type update <kn-id> <rt-id> --source <ot-id> --target <ot-id> [--name X] [--type direct|data_view] [--mapping src:tgt ...] Update relation type
389
- relation-type delete <kn-id> <rt-ids> [-y] Delete relation type(s)
390
- subgraph <kn-id> '<json>' Query subgraph
391
- action-type list <kn-id> List action types (schema)
392
- action-type get <kn-id> <at-id> Get action type details
393
- action-type create <kn-id> '<json>' Create action type
394
- action-type update <kn-id> <at-id> '<json>' Update action type
395
- action-type delete <kn-id> <at-ids> [-y] Delete action type(s)
396
- action-type query <kn-id> <at-id> '<json>' Query action info
397
- action-type inputs <kn-id> <at-id> List value_from=input params + dynamic_params template
398
- action-type execute <kn-id> <at-id> '<envelope-json>' | --dynamic-params '<json>' [--instance '<json>']... [--trigger-type <v>] Execute action (has side effects)
399
- action-execution get <kn-id> <execution-id> Get execution status
400
- action-log list <kn-id> [options] List action execution logs
401
- action-log get <kn-id> <log-id> Get single execution log
402
- action-log cancel <kn-id> <log-id> Cancel running execution (has side effects)
403
- concept-group list|get|create|update|delete|add-members|remove-members <kn-id> ...
404
- action-schedule list|get|create|update|set-status|delete <kn-id> ...
405
- job list|get|tasks|delete <kn-id> ...
406
- relation-type-paths <kn-id> '<json>' Query relation type paths between OTs
407
- resources List available resources
408
- metric list|get|create|search|validate|update|delete|query|dry-run <kn-id> ... BKN metrics (definitions + data)
409
-
410
- Use 'kweaver bkn <subcommand> --help' for subcommand options.`;
361
+ const KN_HELP = renderHelp({
362
+ tagline: "Knowledge network — build, validate, push/pull, schema, instances, actions, metrics",
363
+ usage: "kweaver bkn <subcommand> [args] [flags]",
364
+ sections: [
365
+ {
366
+ title: "LIFECYCLE",
367
+ items: [
368
+ { name: "list", desc: "List knowledge networks" },
369
+ { name: "get", desc: "Get KN detail (use --stats or --export)" },
370
+ { name: "create", desc: "Create a KN (empty or from --body-file)" },
371
+ { name: "create-from-ds", desc: "Create KN from datasource (--name --tables --build)" },
372
+ { name: "create-from-csv", desc: "Import CSVs then create KN (--files glob --name --build)" },
373
+ { name: "update", desc: "Update a KN" },
374
+ { name: "delete", desc: "Delete a KN" },
375
+ { name: "build", desc: "Trigger full build (--wait / --timeout)" },
376
+ { name: "stats", desc: "Get statistics (alias for `get --stats`)" },
377
+ { name: "export", desc: "Export KN (alias for `get --export`)" },
378
+ ],
379
+ },
380
+ {
381
+ title: "LOCAL DIRECTORY",
382
+ items: [
383
+ { name: "validate", desc: "Validate local BKN directory (no upload)" },
384
+ { name: "push", desc: "Upload BKN directory as tar" },
385
+ { name: "pull", desc: "Download BKN tar and extract" },
386
+ ],
387
+ },
388
+ {
389
+ title: "SCHEMA",
390
+ items: [
391
+ { name: "object-type", desc: "list / get / create / update / delete / query / properties" },
392
+ { name: "relation-type", desc: "list / get / create / update / delete" },
393
+ { name: "relation-type-paths", desc: "Query relation-type paths between object types" },
394
+ { name: "action-type", desc: "list / get / create / update / delete / query / inputs / execute" },
395
+ { name: "concept-group", desc: "list / get / create / update / delete / add-members / remove-members" },
396
+ { name: "metric", desc: "list / get / create / search / validate / update / delete / query / dry-run" },
397
+ ],
398
+ },
399
+ {
400
+ title: "INSTANCES / SEARCH",
401
+ items: [
402
+ { name: "search", desc: "Semantic search within a KN" },
403
+ { name: "subgraph", desc: "Query subgraph (JSON body)" },
404
+ ],
405
+ },
406
+ {
407
+ title: "EXECUTION / JOBS",
408
+ items: [
409
+ { name: "action-execution", desc: "get execution status" },
410
+ { name: "action-log", desc: "list / get / cancel" },
411
+ { name: "action-schedule", desc: "list / get / create / update / set-status / delete" },
412
+ { name: "job", desc: "list / get / tasks / delete" },
413
+ ],
414
+ },
415
+ {
416
+ title: "MISC",
417
+ items: [{ name: "resources", desc: "List available resources" }],
418
+ },
419
+ ],
420
+ inheritedFlags: "--base-url, --token, --user, -bd, --help",
421
+ examples: [
422
+ "kweaver bkn list",
423
+ "kweaver bkn build <kn-id> --wait",
424
+ "kweaver bkn push ./my-network --branch main",
425
+ "kweaver bkn search <kn-id> 'customer churn'",
426
+ ],
427
+ learnMore: [
428
+ "Use `kweaver bkn <subcommand> --help` for action-level options",
429
+ "Use `kweaver help all` for full per-action signatures",
430
+ ],
431
+ });
411
432
  export async function runKnCommand(args) {
412
433
  const [subcommand, ...rest] = args;
413
434
  if (!subcommand || subcommand === "--help" || subcommand === "-h") {
@@ -522,69 +543,87 @@ async function runKnListCommand(args) {
522
543
  return 1;
523
544
  }
524
545
  }
525
- const KN_LIST_HELP = `kweaver bkn list [options]
526
-
527
- List business knowledge networks from the ontology-manager API.
528
-
529
- Options:
530
- --offset <n> Offset (default: 0)
531
- --limit <n> Limit (default: 30)
532
- --sort <key> Sort field (default: update_time)
533
- --direction <asc|desc> Sort direction (default: desc)
534
- --name-pattern <s> Filter by name pattern
535
- --tag <s> Filter by tag
536
- --detail Include the detail field in simplified output
537
- --verbose, -v Show full JSON response
538
- -bd, --biz-domain <value> Business domain (default: bd_public)
539
- --pretty Pretty-print JSON output (applies to both modes)`;
540
- const KN_GET_HELP = `kweaver bkn get <kn-id> [options]
541
-
542
- Get knowledge network detail.
543
-
544
- Options:
545
- --stats Include statistics
546
- --export Export mode (include sub-types)
547
- -bd, --biz-domain <value> Business domain (default: bd_public)
548
- --pretty Pretty-print JSON output`;
549
- const KN_CREATE_HELP = `kweaver bkn create [options]
550
-
551
- Create a knowledge network.
552
-
553
- Options:
554
- --name <s> Name (required unless --body-file)
555
- --comment <s> Comment
556
- --tags <t1,t2> Comma-separated tags
557
- --icon <s> Icon
558
- --color <s> Color
559
- --branch <s> Branch (default: main)
560
- --base-branch <s> Base branch (default: empty for main)
561
- --body-file <path> Read full JSON body from file (cannot combine with flags above)
562
- --import-mode <normal|ignore|overwrite> Import mode (default: normal)
563
- --validate-dependency <true|false> Validate dependency (default: true)
564
- -bd, --biz-domain <value> Business domain (default: bd_public)
565
- --pretty Pretty-print JSON output`;
566
- const KN_UPDATE_HELP = `kweaver bkn update <kn-id> [options]
567
-
568
- Update a knowledge network.
569
-
570
- Options:
571
- --name <s> Name (required unless --body-file)
572
- --comment <s> Comment
573
- --tags <t1,t2> Comma-separated tags
574
- --icon <s> Icon
575
- --color <s> Color
576
- --branch <s> Branch (default: main)
577
- --base-branch <s> Base branch (default: empty for main)
578
- --body-file <path> Read full JSON body from file (cannot combine with flags above)
579
- -bd, --biz-domain <value> Business domain (default: bd_public)
580
- --pretty Pretty-print JSON output`;
581
- const KN_DELETE_HELP = `kweaver bkn delete <kn-id>
582
-
583
- Delete a knowledge network and its object types, relation types, action types, and concept groups.
584
-
585
- Options:
586
- --yes, -y Skip confirmation prompt
587
- -bd, --biz-domain <value> Business domain (default: bd_public)`;
546
+ const KN_LIST_HELP = renderHelp({
547
+ tagline: "List business knowledge networks (ontology-manager API)",
548
+ usage: "kweaver bkn list [flags]",
549
+ flags: [
550
+ { name: "--offset <n>", desc: "Offset (default: 0)" },
551
+ { name: "--limit <n>", desc: "Limit (default: 30)" },
552
+ { name: "--sort <key>", desc: "Sort field (default: update_time)" },
553
+ { name: "--direction <asc|desc>", desc: "Sort direction (default: desc)" },
554
+ { name: "--name-pattern <s>", desc: "Filter by name pattern" },
555
+ { name: "--tag <s>", desc: "Filter by tag" },
556
+ { name: "--detail", desc: "Include the detail field in simplified output" },
557
+ { name: "--verbose, -v", desc: "Show full JSON response" },
558
+ { name: "-bd, --biz-domain <value>", desc: "Business domain (default: bd_public)" },
559
+ { name: "--pretty", desc: "Pretty-print JSON output (applies to both modes)" },
560
+ ],
561
+ inheritedFlags: "--base-url, --token, --user, --help",
562
+ examples: ["kweaver bkn list --limit 50 --tag analytics"],
563
+ });
564
+ const KN_GET_HELP = renderHelp({
565
+ tagline: "Get knowledge network detail",
566
+ usage: "kweaver bkn get <kn-id> [flags]",
567
+ flags: [
568
+ { name: "--stats", desc: "Include statistics" },
569
+ { name: "--export", desc: "Export mode (include sub-types)" },
570
+ { name: "-bd, --biz-domain <value>", desc: "Business domain (default: bd_public)" },
571
+ { name: "--pretty", desc: "Pretty-print JSON output" },
572
+ ],
573
+ inheritedFlags: "--base-url, --token, --user, --help",
574
+ examples: ["kweaver bkn get kn-123 --stats"],
575
+ });
576
+ const KN_CREATE_HELP = renderHelp({
577
+ tagline: "Create a knowledge network (empty or from --body-file)",
578
+ usage: "kweaver bkn create [flags]",
579
+ flags: [
580
+ { name: "--name <s>", desc: "Name (required unless --body-file)" },
581
+ { name: "--comment <s>", desc: "Comment" },
582
+ { name: "--tags <t1,t2>", desc: "Comma-separated tags" },
583
+ { name: "--icon <s>", desc: "Icon" },
584
+ { name: "--color <s>", desc: "Color" },
585
+ { name: "--branch <s>", desc: "Branch (default: main)" },
586
+ { name: "--base-branch <s>", desc: "Base branch (default: empty for main)" },
587
+ { name: "--body-file <path>", desc: "Read full JSON body from file (cannot combine with flags above)" },
588
+ { name: "--import-mode <normal|ignore|overwrite>", desc: "Import mode (default: normal)" },
589
+ { name: "--validate-dependency <true|false>", desc: "Validate dependency (default: true)" },
590
+ { name: "-bd, --biz-domain <value>", desc: "Business domain (default: bd_public)" },
591
+ { name: "--pretty", desc: "Pretty-print JSON output" },
592
+ ],
593
+ inheritedFlags: "--base-url, --token, --user, --help",
594
+ examples: [
595
+ "kweaver bkn create --name my-kn --tags a,b",
596
+ "kweaver bkn create --body-file ./kn.json",
597
+ ],
598
+ });
599
+ const KN_UPDATE_HELP = renderHelp({
600
+ tagline: "Update a knowledge network",
601
+ usage: "kweaver bkn update <kn-id> [flags]",
602
+ flags: [
603
+ { name: "--name <s>", desc: "Name (required unless --body-file)" },
604
+ { name: "--comment <s>", desc: "Comment" },
605
+ { name: "--tags <t1,t2>", desc: "Comma-separated tags" },
606
+ { name: "--icon <s>", desc: "Icon" },
607
+ { name: "--color <s>", desc: "Color" },
608
+ { name: "--branch <s>", desc: "Branch (default: main)" },
609
+ { name: "--base-branch <s>", desc: "Base branch (default: empty for main)" },
610
+ { name: "--body-file <path>", desc: "Read full JSON body from file (cannot combine with flags above)" },
611
+ { name: "-bd, --biz-domain <value>", desc: "Business domain (default: bd_public)" },
612
+ { name: "--pretty", desc: "Pretty-print JSON output" },
613
+ ],
614
+ inheritedFlags: "--base-url, --token, --user, --help",
615
+ examples: ["kweaver bkn update kn-123 --name renamed"],
616
+ });
617
+ const KN_DELETE_HELP = renderHelp({
618
+ tagline: "Delete a KN and its object/relation/action types and concept groups",
619
+ usage: "kweaver bkn delete <kn-id> [flags]",
620
+ flags: [
621
+ { name: "--yes, -y", desc: "Skip confirmation prompt" },
622
+ { name: "-bd, --biz-domain <value>", desc: "Business domain (default: bd_public)" },
623
+ ],
624
+ inheritedFlags: "--base-url, --token, --user, --help",
625
+ examples: ["kweaver bkn delete kn-123 -y"],
626
+ });
588
627
  async function runKnGetCommand(args) {
589
628
  let options;
590
629
  try {
@@ -4,6 +4,28 @@ import { ensureValidToken, formatHttpError, with401RefreshRetry } from "../auth/
4
4
  import { isNoAuth } from "../config/no-auth.js";
5
5
  import { HttpError } from "../utils/http.js";
6
6
  import { resolveBusinessDomain } from "../config/store.js";
7
+ import { renderHelp } from "../help/format.js";
8
+ const CALL_HELP = renderHelp({
9
+ tagline: "Call an API with curl-style flags and auto-injected auth headers",
10
+ usage: "kweaver call <url> [-X METHOD] [-H \"Name: value\"] [-d BODY|-F key=val] [flags]",
11
+ flags: [
12
+ { name: "<url>", desc: "API path, e.g. /api/ontology-manager/v1/knowledge-networks" },
13
+ { name: "-X, --request", desc: "HTTP method (default: GET)" },
14
+ { name: "-H, --header", desc: "Extra header (repeatable)" },
15
+ { name: "-d, --data, --data-raw", desc: "JSON request body (sets Content-Type: application/json if unset)" },
16
+ { name: "-F, --form", desc: "Multipart form field: key=value or key=@/path/to/file. Repeatable. Mutually exclusive with -d" },
17
+ { name: "-bd, --biz-domain", desc: "Override x-business-domain (default: bd_public)" },
18
+ { name: "-v, --verbose", desc: "Print request info to stderr" },
19
+ { name: "--pretty", desc: "Pretty-print JSON output (default)" },
20
+ ],
21
+ inheritedFlags: "--base-url, --token, --user, --help",
22
+ examples: [
23
+ "kweaver call /api/ontology-manager/v1/knowledge-networks",
24
+ "kweaver call -X POST /api/agents -d '{\"name\":\"demo\"}'",
25
+ "kweaver call -F file=@./spec.yaml /api/toolboxes/{id}/tools/upload",
26
+ ],
27
+ learnMore: ["Alias: `kweaver curl ...`"],
28
+ });
7
29
  export function parseCallArgs(args) {
8
30
  const headers = new Headers();
9
31
  let method = "GET";
@@ -160,19 +182,7 @@ export function formatVerboseRequest(invocation) {
160
182
  }
161
183
  export async function runCallCommand(args) {
162
184
  if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
163
- console.log(`kweaver call <url> [-X METHOD] [-H "Name: value"] [-d BODY] [-F key=value] [--pretty] [--verbose] [-bd value]
164
-
165
- Call an API with curl-style flags and auto-injected token headers.
166
-
167
- Options:
168
- <url> API path (e.g. /api/ontology-manager/v1/knowledge-networks)
169
- -X, --request HTTP method (default: GET)
170
- -H, --header Extra header (repeatable)
171
- -d, --data, --data-raw JSON request body (sets Content-Type: application/json if not set)
172
- -F, --form Multipart form field. -F key=value or -F key=@/path/to/file. Repeatable. Mutually exclusive with -d.
173
- -bd, --biz-domain Override x-business-domain (default: bd_public)
174
- -v, --verbose Print request info to stderr
175
- --pretty Pretty-print JSON output (default)`);
185
+ console.log(CALL_HELP);
176
186
  return 0;
177
187
  }
178
188
  let invocation;
@@ -3,18 +3,28 @@ import { fetchEacpUserInfo, resolveActivePlatform, withTokenRetry } from "../aut
3
3
  import { HttpError } from "../utils/http.js";
4
4
  import { loadPlatformBusinessDomain, resolveBusinessDomain, savePlatformBusinessDomain, } from "../config/store.js";
5
5
  import { assertNotStatelessForWrite } from "../config/stateless.js";
6
- const HELP = `kweaver config
7
-
8
- Subcommands:
9
- set-bd <value> Set the default business domain for the current platform
10
- list-bd List business domains as JSON (requires login)
11
- show Show current config (platform, business domain)
12
- --help Show this message
13
-
14
- Examples:
15
- kweaver config set-bd 54308785-4438-43df-9490-a7fd11df5765
16
- kweaver config list-bd
17
- kweaver config show`;
6
+ import { renderHelp } from "../help/format.js";
7
+ const HELP = renderHelp({
8
+ tagline: "Per-platform business-domain config",
9
+ usage: "kweaver config <subcommand> [flags]",
10
+ sections: [
11
+ {
12
+ title: "AVAILABLE COMMANDS",
13
+ items: [
14
+ { name: "set-bd", desc: "Set default business domain for current platform" },
15
+ { name: "list-bd", desc: "List business domains as JSON (requires login)" },
16
+ { name: "show", desc: "Show current config (platform, business domain)" },
17
+ ],
18
+ },
19
+ ],
20
+ inheritedFlags: "--base-url, --token, --user, --help",
21
+ examples: [
22
+ "kweaver config set-bd 54308785-4438-43df-9490-a7fd11df5765",
23
+ "kweaver config list-bd",
24
+ "kweaver config show",
25
+ ],
26
+ learnMore: ["Use `kweaver config <subcommand> --help` for flag details"],
27
+ });
18
28
  export async function runConfigCommand(args) {
19
29
  const [sub, ...rest] = args;
20
30
  if (!sub || sub === "--help" || sub === "-h" || sub === "help") {
@@ -3,6 +3,7 @@ import { callTool, searchSchema, queryObjectInstance, queryInstanceSubgraph, get
3
3
  import { knSearchHttp, semanticSearch } from "../api/semantic-search.js";
4
4
  import { addContextLoaderEntry, getCurrentContextLoaderKn, loadContextLoaderConfig, removeContextLoaderEntry, resolveBusinessDomain, setCurrentContextLoader, } from "../config/store.js";
5
5
  import { assertNotStatelessForWrite } from "../config/stateless.js";
6
+ import { renderHelp } from "../help/format.js";
6
7
  const CONTEXT_LOADER_CONFIG_DEPRECATION = "[deprecated] `kweaver context-loader config ...` will be removed in a future release. " +
7
8
  "Pass <kn-id> as the first positional to runtime subcommands instead, e.g. " +
8
9
  "`kweaver context-loader tools <kn-id>` (or use the `--kn-id <id>` flag).";
@@ -10,87 +11,102 @@ const MCP_NOT_CONFIGURED = "Context-loader MCP is not configured. Run: kweaver c
10
11
  const MCP_PATH = "/api/agent-retrieval/v1/mcp";
11
12
  const DEPRECATED_KN_SEARCH_MESSAGE = "[deprecated] context-loader kn-search is deprecated. Use context-loader search-schema instead.";
12
13
  const DEPRECATED_KN_SCHEMA_SEARCH_MESSAGE = "[deprecated] context-loader kn-schema-search is deprecated. Use context-loader search-schema instead.";
13
- const CONTEXT_LOADER_HELP = `kweaver context-loader
14
-
15
- USAGE
16
- kweaver context-loader <subcommand> [flags]
17
- kweaver context-loader help <subcommand>
18
- kweaver context-loader --help
19
- kweaver context-loader <subcommand> --help
20
-
21
- KN SELECTION
22
- Most runtime subcommands require a KN. Pass it as the first positional
23
- argument or use --kn-id <id> / -k <id>. Omitting KN falls back to the
24
- deprecated saved config managed by kweaver context-loader config.
25
-
26
- RECOMMENDED FLOW
27
- search-schema: Discover schema concepts
28
- query-*: Query instances using discovered schema IDs
29
- get-*/find-skills: Enrich instances or inspect actions
30
- tool-call: Raw MCP debugging or unsupported tools only
31
-
32
- SCHEMA DISCOVERY COMMANDS
33
- search-schema: Search object/relation/action/metric schemas
34
- kn-search: [deprecated] Use search-schema
35
- kn-schema-search: [deprecated] Use search-schema
36
-
37
- INSTANCE QUERY COMMANDS
38
- query-object-instance: Query object instances
39
- query-instance-subgraph: Query instance subgraphs
40
-
41
- INSTANCE ENRICHMENT AND ACTION COMMANDS
42
- get-logic-properties: Get calculated logic property values
43
- get-action-info: Get action metadata and executable info
44
- find-skills: Recall skills for an object type
45
-
46
- ADVANCED MCP COMMANDS
47
- tools: List MCP tools
48
- resources: List MCP resources
49
- resource: Read an MCP resource by URI
50
- templates: List MCP resource templates
51
- prompts: List MCP prompts
52
- prompt: Get an MCP prompt by name
53
- tool-call: Call any MCP tool directly
54
-
55
- DEPRECATED CONFIGURATION COMMANDS
56
- config: Manage legacy saved KN selection
57
-
58
- FLAGS
59
- -k, --kn-id <id> KN selector for runtime subcommands
60
- --pretty Pretty-print JSON output
61
- --compact Print compact JSON output
62
- -h, --help Show help
63
-
64
- LEARN MORE
65
- Use \`kweaver context-loader <subcommand> --help\` for arguments, JSON shapes, and examples.`;
66
- const CONTEXT_LOADER_CONFIG_HELP = `kweaver context-loader config [deprecated]
67
-
68
- Usage:
69
- kweaver context-loader config set --kn-id <id> [--name <name>]
70
- kweaver context-loader config use <name>
71
- kweaver context-loader config list
72
- kweaver context-loader config remove <name>
73
- kweaver context-loader config show
74
-
75
- Description:
76
- Manage the deprecated saved context-loader KN selection. Runtime commands should pass
77
- <kn-id> as the first positional or use --kn-id <id> / -k <id> instead.
78
-
79
- Arguments:
80
- <name> Saved config name.
81
-
82
- Options:
83
- --kn-id <id> KN ID to save for config set.
84
- --name <name> Saved config name for config set. Default: default.
85
- --help, -h Show this help and exit before auth/config/network checks.
86
-
87
- Examples:
88
- kweaver context-loader tools d5iv6c9818p72mpje8pg
89
- kweaver context-loader tools --kn-id d5iv6c9818p72mpje8pg
90
-
91
- Notes:
92
- This command group is deprecated and will be removed in a future release.
93
- It is disabled in stateless mode (--token).`;
14
+ const CONTEXT_LOADER_HELP = renderHelp({
15
+ tagline: "MCP / HTTP context-loader — schema discovery, instance query, action info, skill recall",
16
+ usage: [
17
+ "kweaver context-loader <subcommand> [flags]",
18
+ "kweaver context-loader help <subcommand>",
19
+ ],
20
+ sections: [
21
+ {
22
+ title: "RECOMMENDED FLOW",
23
+ items: [
24
+ { name: "1. search-schema", desc: "Discover schema concepts" },
25
+ { name: "2. query-*", desc: "Query instances using discovered schema IDs" },
26
+ { name: "3. get-* / find-skills", desc: "Enrich instances or inspect actions" },
27
+ { name: "— tool-call", desc: "Raw MCP debugging or unsupported tools only" },
28
+ ],
29
+ },
30
+ {
31
+ title: "SCHEMA DISCOVERY",
32
+ items: [
33
+ { name: "search-schema", desc: "Search object/relation/action/metric schemas" },
34
+ { name: "kn-search", desc: "[deprecated] Use search-schema" },
35
+ { name: "kn-schema-search", desc: "[deprecated] Use search-schema" },
36
+ ],
37
+ },
38
+ {
39
+ title: "INSTANCE QUERY",
40
+ items: [
41
+ { name: "query-object-instance", desc: "Query object instances" },
42
+ { name: "query-instance-subgraph", desc: "Query instance subgraphs" },
43
+ ],
44
+ },
45
+ {
46
+ title: "INSTANCE ENRICHMENT / ACTION",
47
+ items: [
48
+ { name: "get-logic-properties", desc: "Get calculated logic-property values" },
49
+ { name: "get-action-info", desc: "Get action metadata and executable info" },
50
+ { name: "find-skills", desc: "Recall skills for an object type" },
51
+ ],
52
+ },
53
+ {
54
+ title: "ADVANCED MCP",
55
+ items: [
56
+ { name: "tools", desc: "List MCP tools" },
57
+ { name: "resources", desc: "List MCP resources" },
58
+ { name: "resource", desc: "Read an MCP resource by URI" },
59
+ { name: "templates", desc: "List MCP resource templates" },
60
+ { name: "prompts", desc: "List MCP prompts" },
61
+ { name: "prompt", desc: "Get an MCP prompt by name" },
62
+ { name: "tool-call", desc: "Call any MCP tool directly" },
63
+ ],
64
+ },
65
+ {
66
+ title: "DEPRECATED",
67
+ items: [{ name: "config", desc: "Manage legacy saved KN selection (set/use/list/remove/show)" }],
68
+ },
69
+ ],
70
+ flags: [
71
+ { name: "-k, --kn-id <id>", desc: "KN selector for runtime subcommands" },
72
+ { name: "--pretty", desc: "Pretty-print JSON output" },
73
+ { name: "--compact", desc: "Compact JSON output" },
74
+ ],
75
+ inheritedFlags: "--base-url, --token, --user, --help",
76
+ examples: [
77
+ "kweaver context-loader search-schema <id> 'customer churn'",
78
+ "kweaver context-loader query-object-instance <id> --object-type-id <ot> --limit 10",
79
+ "kweaver context-loader find-skills <id> <ot-id>",
80
+ ],
81
+ learnMore: [
82
+ "Alias: `kweaver context ...`",
83
+ "Use `kweaver context-loader <subcommand> --help` for arguments, JSON shapes, examples",
84
+ "Most runtime subcommands require a KN first positional or --kn-id / -k",
85
+ ],
86
+ });
87
+ const CONTEXT_LOADER_CONFIG_HELP = renderHelp({
88
+ tagline: "[deprecated] Manage the saved context-loader KN selection",
89
+ usage: [
90
+ "kweaver context-loader config set --kn-id <id> [--name <name>]",
91
+ "kweaver context-loader config use <name>",
92
+ "kweaver context-loader config list",
93
+ "kweaver context-loader config remove <name>",
94
+ "kweaver context-loader config show",
95
+ ],
96
+ flags: [
97
+ { name: "--kn-id <id>", desc: "KN id to save (for `config set`)" },
98
+ { name: "--name <name>", desc: "Saved config name (for `config set`; default: default)" },
99
+ ],
100
+ inheritedFlags: "--base-url, --token, --user, --help",
101
+ examples: [
102
+ "kweaver context-loader tools d5iv6c9818p72mpje8pg",
103
+ "kweaver context-loader tools --kn-id d5iv6c9818p72mpje8pg",
104
+ ],
105
+ learnMore: [
106
+ "Deprecated: runtime commands should pass <kn-id> as the first positional or use --kn-id/-k",
107
+ "Disabled in stateless mode (--token); will be removed in a future release",
108
+ ],
109
+ });
94
110
  const CONTEXT_LOADER_SUBCOMMAND_HELP = {
95
111
  tools: `kweaver context-loader tools
96
112
 
@@ -734,17 +750,7 @@ export async function runContextLoaderCommand(args) {
734
750
  async function runConfigCommand(args) {
735
751
  const [action, ...rest] = args;
736
752
  if (!action || action === "--help" || action === "-h") {
737
- console.log(`kweaver context-loader config [deprecated]
738
-
739
- Subcommands:
740
- set --kn-id <id> [--name <name>] Add or update kn config (default name: default)
741
- use <name> Switch current config
742
- list List all configs and current
743
- remove <name> Remove a config
744
- show Show current config (knId + mcpUrl)
745
-
746
- Note: this command group is deprecated and will be removed in a future release.
747
- It is disabled entirely in stateless mode (\`--token\`).`);
753
+ console.log(CONTEXT_LOADER_CONFIG_HELP);
748
754
  return 0;
749
755
  }
750
756
  // Stateless mode (`--token`) does not support any context-loader config