@hop-top/kit 0.5.0-alpha.4 → 0.5.0-alpha.6

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/CHANGELOG.md CHANGED
@@ -4,6 +4,25 @@ All notable changes to `@hop-top/kit` are documented in this file.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/);
5
5
  versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.5.0-alpha.6](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.5...kit-ts/v0.5.0-alpha.6) (2026-10-29)
8
+
9
+
10
+ ### Features
11
+
12
+ * **ts:** publish log, completion and toolspec subpaths ([a349521](https://github.com/hop-top/poly-kit/commit/a3495219b223e25703df3da3f030813345d49525))
13
+
14
+ ## [0.5.0-alpha.5](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.4...kit-ts/v0.5.0-alpha.5) (2026-10-29)
15
+
16
+ The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.5. This release includes maintenance release with bug fixes.
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **ts/cli:** render ARGUMENTS section in help ([ea98594](https://github.com/hop-top/poly-kit/commit/ea98594023b5082e965e476edf2148e68130d63d))
22
+ * **ts/cli:** route help <command> to command help ([6ce7c4c](https://github.com/hop-top/poly-kit/commit/6ce7c4c0f55a4b13359e4fa72c83414796664353))
23
+
24
+ Full diff: [kit-ts/v0.5.0-alpha.4...kit-ts/v0.5.0-alpha.5](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.4...kit-ts/v0.5.0-alpha.5)
25
+
7
26
  ## [0.5.0-alpha.4](https://github.com/hop-top/poly-kit/compare/kit-ts/v0.5.0-alpha.3...kit-ts/v0.5.0-alpha.4) (2026-10-29)
8
27
 
9
28
  The hop-top team is happy to announce Kit's TS SDK 0.5.0-alpha.4. This release includes new features and bug fixes.
package/README.md CHANGED
@@ -50,14 +50,14 @@ hidden completion command.
50
50
  | [`src/router/`](src/router/README.md) | RouteLLM strong/weak model routing and its Hono handler | a prompt must pick a model in-process |
51
51
  | [`src/triton/`](src/triton/README.md) | Triton Inference Server client, KServe v2 over HTTP | you call a model hosted on Triton |
52
52
 
53
- Non-directory subpaths: `cli` (CLI factory), `serve` (serve hierarchy
54
- and service lifecycle), `netpolicy` (`--offline` enforcement, guards
55
- `globalThis.fetch`), `xdg` (base directory paths), `config`
56
- (config-file loading), `sqlstore` (embedded SQLite key/value store),
57
- `upgrade` (semver upgrade detection), `llm`, `anthropic`, `openai`,
58
- `routellm`, `alias`, `uri` (facade over `@hop-top/cite`), `api`,
59
- `rpc`, `aim`, `scope`, `safety`, `provenance`, `stream`, `progress`,
60
- `auth`, `errcorrect`. See `package.json` `exports` for the full list.
53
+ Non-directory subpaths: `cli` (CLI factory), `serve` (serve hierarchy and
54
+ service lifecycle), `netpolicy` (`--offline` enforcement, guards
55
+ `globalThis.fetch`), `xdg` (base directory paths), `config` (config-file
56
+ loading), `sqlstore` (embedded SQLite key/value store), `upgrade` (semver
57
+ upgrade detection), `llm`, `anthropic`, `openai`, `routellm`, `alias`, `uri`
58
+ (facade over `@hop-top/cite`), `api`, `rpc`, `aim`, `scope`, `safety`,
59
+ `provenance`, `stream`, `progress`, `auth`, `errcorrect`, `log`,
60
+ `completion`, `toolspec`. See `package.json` `exports` for the full list.
61
61
 
62
62
  ## Contract
63
63
 
@@ -0,0 +1,128 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
4
+
5
+ // src/completion.ts
6
+ var completion_exports = {};
7
+ _chunkR5U7XKVJjs.__export.call(void 0, completion_exports, {
8
+ completionCommand: () => completionCommand,
9
+ generateBashCompletion: () => generateBashCompletion,
10
+ generateFishCompletion: () => generateFishCompletion,
11
+ generateZshCompletion: () => generateZshCompletion
12
+ });
13
+ var _commander = require('commander');
14
+ function collectCommands(cmd) {
15
+ return cmd.commands.filter((c) => !c._hidden && c.name() !== "help").flatMap((c) => [c.name(), ...c.aliases()]);
16
+ }
17
+ function collectFlags(cmd) {
18
+ return cmd.options.map((o) => o.long).filter(Boolean);
19
+ }
20
+ function generateBashCompletion(program) {
21
+ const name = program.name();
22
+ const cmds = collectCommands(program);
23
+ const flags = collectFlags(program);
24
+ const words = [...cmds, ...flags].join(" ");
25
+ return `# bash completion for ${name}
26
+ # eval "$(${name} completion bash)"
27
+
28
+ _${name}_completions() {
29
+ local cur="\${COMP_WORDS[COMP_CWORD]}"
30
+ local commands="${words}"
31
+
32
+ COMPREPLY=( $(compgen -W "\${commands}" -- "\${cur}") )
33
+ }
34
+
35
+ complete -F _${name}_completions ${name}
36
+ `;
37
+ }
38
+ function generateZshCompletion(program) {
39
+ const name = program.name();
40
+ const cmds = collectCommands(program);
41
+ const flags = collectFlags(program);
42
+ const cmdEntries = cmds.map((c) => {
43
+ const sub = program.commands.find(
44
+ (s) => s.name() === c || s.aliases().includes(c)
45
+ );
46
+ const desc = _nullishCoalesce(_optionalChain([sub, 'optionalAccess', _ => _.description, 'call', _2 => _2()]), () => ( ""));
47
+ return ` '${c}:${desc}'`;
48
+ }).join("\n");
49
+ const flagEntries = flags.map((f) => ` '${f}[${f}]'`).join("\n");
50
+ return `#compdef ${name}
51
+ # eval "$(${name} completion zsh)"
52
+
53
+ _${name}() {
54
+ local -a commands flags
55
+
56
+ commands=(
57
+ ${cmdEntries}
58
+ )
59
+
60
+ flags=(
61
+ ${flagEntries}
62
+ )
63
+
64
+ _arguments -s \\
65
+ '1:command:->cmds' \\
66
+ '*::flags:->flags'
67
+
68
+ case "$state" in
69
+ cmds)
70
+ _describe -t commands 'commands' commands
71
+ ;;
72
+ flags)
73
+ _describe -t flags 'flags' flags
74
+ ;;
75
+ esac
76
+ }
77
+
78
+ compdef _${name} ${name}
79
+ `;
80
+ }
81
+ function generateFishCompletion(program) {
82
+ const name = program.name();
83
+ const cmds = collectCommands(program);
84
+ const flags = collectFlags(program);
85
+ const lines = [
86
+ `# fish completion for ${name}`,
87
+ `# ${name} completion fish | source`,
88
+ ""
89
+ ];
90
+ for (const c of cmds) {
91
+ const sub = program.commands.find(
92
+ (s) => s.name() === c || s.aliases().includes(c)
93
+ );
94
+ const desc = _nullishCoalesce(_optionalChain([sub, 'optionalAccess', _3 => _3.description, 'call', _4 => _4()]), () => ( ""));
95
+ lines.push(
96
+ `complete -c ${name} -n '__fish_use_subcommand' -a '${c}' -d '${desc}'`
97
+ );
98
+ }
99
+ for (const f of flags) {
100
+ const long = f.replace(/^--/, "");
101
+ lines.push(
102
+ `complete -c ${name} -l '${long}'`
103
+ );
104
+ }
105
+ lines.push("");
106
+ return lines.join("\n");
107
+ }
108
+ function completionCommand(program) {
109
+ const cmd = new (0, _commander.Command)("completion").description("Generate shell completion scripts");
110
+ cmd.command("bash").description("Generate bash completion script").action(() => {
111
+ process.stdout.write(generateBashCompletion(program));
112
+ });
113
+ cmd.command("zsh").description("Generate zsh completion script").action(() => {
114
+ process.stdout.write(generateZshCompletion(program));
115
+ });
116
+ cmd.command("fish").description("Generate fish completion script").action(() => {
117
+ process.stdout.write(generateFishCompletion(program));
118
+ });
119
+ return cmd;
120
+ }
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+ exports.generateBashCompletion = generateBashCompletion; exports.generateZshCompletion = generateZshCompletion; exports.generateFishCompletion = generateFishCompletion; exports.completionCommand = completionCommand; exports.completion_exports = completion_exports;
@@ -3,7 +3,6 @@
3
3
  var _chunkQPUCXQXTjs = require('./chunk-QPUCXQXT.js');
4
4
 
5
5
 
6
- var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
7
6
 
8
7
 
9
8
 
@@ -11,9 +10,13 @@ var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
11
10
 
12
11
 
13
12
 
13
+ var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
14
14
 
15
15
 
16
- var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
16
+ var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
17
+
18
+
19
+ var _chunkPOR5L2DGjs = require('./chunk-POR5L2DG.js');
17
20
 
18
21
 
19
22
  var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
@@ -341,6 +344,18 @@ function applyHelpTheme(program, theme, noColor, sectionOrder, showAliases, grou
341
344
  output.push(helper.styleCommandDescription(desc));
342
345
  output.push("");
343
346
  }
347
+ const argList = helper.visibleArguments(cmd);
348
+ if (argList.length > 0) {
349
+ const title = _nullishCoalesce(_optionalChain([_chunkQPUCXQXTjs.parity, 'access', _10 => _10.help, 'access', _11 => _11.sections, 'optionalAccess', _12 => _12["arguments"], 'optionalAccess', _13 => _13.title]), () => ( "ARGUMENTS"));
350
+ output.push(helper.styleTitle(`${title}:`));
351
+ for (const a of argList) {
352
+ output.push(callFormatItem(
353
+ helper.styleArgumentTerm(helper.argumentTerm(a)),
354
+ helper.styleArgumentDescription(helper.argumentDescription(a))
355
+ ));
356
+ }
357
+ output.push("");
358
+ }
344
359
  const helpSections = [];
345
360
  const helpAll = process.argv.includes("--help-all");
346
361
  let helpGroupFilter;
@@ -413,7 +428,7 @@ function applyHelpTheme(program, theme, noColor, sectionOrder, showAliases, grou
413
428
  const resolveTitle = (name) => {
414
429
  const gdef = groupDefs.get(name);
415
430
  if (gdef) return gdef.title;
416
- return _nullishCoalesce(_optionalChain([sectionTitles, 'access', _10 => _10[name], 'optionalAccess', _11 => _11.title]), () => ( name.charAt(0).toUpperCase() + name.slice(1)));
431
+ return _nullishCoalesce(_optionalChain([sectionTitles, 'access', _14 => _14[name], 'optionalAccess', _15 => _15.title]), () => ( name.charAt(0).toUpperCase() + name.slice(1)));
417
432
  };
418
433
  for (const name of effectiveOrder) {
419
434
  if (name === "flags") continue;
@@ -438,8 +453,8 @@ function applyHelpTheme(program, theme, noColor, sectionOrder, showAliases, grou
438
453
  }
439
454
  const defs = getStreamDefs(cmd);
440
455
  if (defs.length > 0) {
441
- const styleTerm = _nullishCoalesce(_optionalChain([helper, 'access', _12 => _12.styleOptionTerm, 'optionalAccess', _13 => _13.bind, 'call', _14 => _14(helper)]), () => ( ((s) => s)));
442
- const styleDesc = _nullishCoalesce(_optionalChain([helper, 'access', _15 => _15.styleDescriptionText, 'optionalAccess', _16 => _16.bind, 'call', _17 => _17(helper)]), () => ( ((s) => s)));
456
+ const styleTerm = _nullishCoalesce(_optionalChain([helper, 'access', _16 => _16.styleOptionTerm, 'optionalAccess', _17 => _17.bind, 'call', _18 => _18(helper)]), () => ( ((s) => s)));
457
+ const styleDesc = _nullishCoalesce(_optionalChain([helper, 'access', _19 => _19.styleDescriptionText, 'optionalAccess', _20 => _20.bind, 'call', _21 => _21(helper)]), () => ( ((s) => s)));
443
458
  output.push(helper.styleTitle("STREAMS:"));
444
459
  for (const d of defs) {
445
460
  output.push(callFormatItem(styleTerm(d.name), styleDesc(d.description)));
@@ -450,27 +465,37 @@ function applyHelpTheme(program, theme, noColor, sectionOrder, showAliases, grou
450
465
  }
451
466
  });
452
467
  }
468
+ function findHelpTarget(root, operands) {
469
+ let cmd;
470
+ let scope = root;
471
+ for (const word of operands) {
472
+ cmd = scope.commands.find((c) => c.name() === word || c.aliases().includes(word));
473
+ if (!cmd) return void 0;
474
+ scope = cmd;
475
+ }
476
+ return cmd;
477
+ }
453
478
  function createCLI(cfg) {
454
479
  const theme = buildTheme(cfg.accent);
455
- const desc = _optionalChain([cfg, 'access', _18 => _18.help, 'optionalAccess', _19 => _19.disclaimer]) ? `${cfg.description}
480
+ const desc = _optionalChain([cfg, 'access', _22 => _22.help, 'optionalAccess', _23 => _23.disclaimer]) ? `${cfg.description}
456
481
 
457
482
  ${cfg.help.disclaimer}` : cfg.description;
458
483
  const normalizedVersion = cfg.version.startsWith("v") ? cfg.version : `v${cfg.version}`;
459
484
  const versionOutput = `${cfg.name} ${normalizedVersion}`;
460
485
  const program = new (0, _commander.Command)(cfg.name).description(desc).version(versionOutput, "-v, --version", `Print ${cfg.name} version and exit`).helpOption("-h, --help", "Display help").addHelpCommand(false).showHelpAfterError(true);
461
- if (!_optionalChain([cfg, 'access', _20 => _20.disable, 'optionalAccess', _21 => _21.format])) {
486
+ if (!_optionalChain([cfg, 'access', _24 => _24.disable, 'optionalAccess', _25 => _25.format])) {
462
487
  _chunk72XZWQX7js.registerOutputFlags.call(void 0, program);
463
488
  }
464
- if (!_optionalChain([cfg, 'access', _22 => _22.disable, 'optionalAccess', _23 => _23.quiet])) {
489
+ if (!_optionalChain([cfg, 'access', _26 => _26.disable, 'optionalAccess', _27 => _27.quiet])) {
465
490
  program.option("--quiet", "Suppress non-essential output", false);
466
491
  }
467
- if (!_optionalChain([cfg, 'access', _24 => _24.disable, 'optionalAccess', _25 => _25.noColor])) {
492
+ if (!_optionalChain([cfg, 'access', _28 => _28.disable, 'optionalAccess', _29 => _29.noColor])) {
468
493
  program.option("--no-color", "Disable ANSI colour", false);
469
494
  }
470
- if (!_optionalChain([cfg, 'access', _26 => _26.disable, 'optionalAccess', _27 => _27.hints])) {
495
+ if (!_optionalChain([cfg, 'access', _30 => _30.disable, 'optionalAccess', _31 => _31.hints])) {
471
496
  program.option("--no-hints", "Suppress next-step hints after command output", false);
472
497
  }
473
- if (!_optionalChain([cfg, 'access', _28 => _28.disable, 'optionalAccess', _29 => _29.offline])) {
498
+ if (!_optionalChain([cfg, 'access', _32 => _32.disable, 'optionalAccess', _33 => _33.offline])) {
474
499
  program.option("--offline", "Disable network access", false);
475
500
  _chunkKVG7YCTSjs.install.call(void 0, );
476
501
  const stamp = (thisCmd) => {
@@ -491,7 +516,7 @@ ${cfg.help.disclaimer}` : cfg.description;
491
516
  quietMap.set(thisCmd, quiet);
492
517
  verboseCountMap.set(thisCmd, quiet ? 0 : _nullishCoalesce(opts.verbose, () => ( 0)));
493
518
  });
494
- if (_optionalChain([cfg, 'access', _30 => _30.groups, 'optionalAccess', _31 => _31.some, 'call', _32 => _32((g) => g.hidden)])) {
519
+ if (_optionalChain([cfg, 'access', _34 => _34.groups, 'optionalAccess', _35 => _35.some, 'call', _36 => _36((g) => g.hidden)])) {
495
520
  program.option("--help-all", "Show all commands including hidden groups");
496
521
  program.on("option:help-all", () => {
497
522
  program.help();
@@ -505,16 +530,26 @@ ${cfg.help.disclaimer}` : cfg.description;
505
530
  }
506
531
  if (cfg.groups && cfg.groups.length > 0) {
507
532
  const groupIds = cfg.groups.map((g) => g.id);
508
- const helpCmd = program.command("help [group]").description("Show help for a command group").action((group) => {
509
- if (group === "all") {
510
- process.argv.push("--help-all");
533
+ const helpCmd = program.command("help [operands...]").description("Show help for a command or command group").action((operands) => {
534
+ if (operands.length === 0) {
511
535
  program.help();
512
- } else if (group && groupIds.includes(group)) {
513
- process.argv.push(`--help-${group}`);
536
+ }
537
+ if (operands.length === 1 && operands[0] === "all") {
538
+ process.argv.push("--help-all");
514
539
  program.help();
515
- } else {
540
+ }
541
+ const target = findHelpTarget(program, operands);
542
+ if (target) {
543
+ target.help();
544
+ }
545
+ if (operands.length === 1 && groupIds.includes(operands[0])) {
546
+ process.argv.push(`--help-${operands[0]}`);
516
547
  program.help();
517
548
  }
549
+ program.error(
550
+ `error: unknown help topic '${operands.join(" ")}' for '${program.name()}'`,
551
+ { exitCode: _chunkPOR5L2DGjs.EXIT_USAGE, code: "commander.unknownCommand" }
552
+ );
518
553
  });
519
554
  helpCmd.hideHelp = true;
520
555
  helpCmd._hidden = true;
@@ -527,8 +562,8 @@ ${cfg.help.disclaimer}` : cfg.description;
527
562
  program,
528
563
  theme,
529
564
  false,
530
- _optionalChain([cfg, 'access', _33 => _33.help, 'optionalAccess', _34 => _34.sectionOrder]),
531
- _optionalChain([cfg, 'access', _35 => _35.help, 'optionalAccess', _36 => _36.showAliases]),
565
+ _optionalChain([cfg, 'access', _37 => _37.help, 'optionalAccess', _38 => _38.sectionOrder]),
566
+ _optionalChain([cfg, 'access', _39 => _39.help, 'optionalAccess', _40 => _40.showAliases]),
532
567
  cfg.groups
533
568
  );
534
569
  const existing = _nullishCoalesce(program._outputConfiguration, () => ( {}));
@@ -0,0 +1,120 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkQPUCXQXTjs = require('./chunk-QPUCXQXT.js');
4
+
5
+
6
+ var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
7
+
8
+ // src/log.ts
9
+ var log_exports = {};
10
+ _chunkR5U7XKVJjs.__export.call(void 0, log_exports, {
11
+ createLogger: () => createLogger,
12
+ quietLevel: () => quietLevel,
13
+ verbosityLevel: () => verbosityLevel,
14
+ withVerbose: () => withVerbose
15
+ });
16
+ var _pino = require('pino'); var _pino2 = _interopRequireDefault(_pino);
17
+ var CHERRY = [237, 74, 94];
18
+ var YAM = [229, 161, 78];
19
+ var SQUID = [133, 129, 131];
20
+ var SMOKE = [191, 188, 200];
21
+ function fg(rgb, text) {
22
+ return `\x1B[38;2;${rgb[0]};${rgb[1]};${rgb[2]}m${text}\x1B[0m`;
23
+ }
24
+ function bold(text) {
25
+ return `\x1B[1m${text}\x1B[22m`;
26
+ }
27
+ var LEVEL_STYLES = {
28
+ 10: { label: "TRAC", color: SMOKE, bold: false },
29
+ 20: { label: "DEBU", color: SMOKE, bold: false },
30
+ 30: { label: "INFO", color: SQUID, bold: false },
31
+ 40: { label: "WARN", color: YAM, bold: true },
32
+ 50: { label: "ERRO", color: CHERRY, bold: true },
33
+ 60: { label: "ERRO", color: CHERRY, bold: true }
34
+ };
35
+ function kitTransport(noColor) {
36
+ return {
37
+ write(chunk) {
38
+ try {
39
+ const obj = JSON.parse(chunk);
40
+ const style = _nullishCoalesce(LEVEL_STYLES[obj.level], () => ( LEVEL_STYLES[30]));
41
+ let prefix = noColor ? style.label : fg(style.color, style.label);
42
+ if (style.bold && !noColor) prefix = bold(prefix);
43
+ const msg = _nullishCoalesce(obj.msg, () => ( ""));
44
+ const kvParts = [];
45
+ for (const [k, v] of Object.entries(obj)) {
46
+ if (["level", "time", "pid", "hostname", "msg", "v"].includes(k)) continue;
47
+ const sv = String(v);
48
+ kvParts.push(sv.includes(" ") ? `${k}="${sv}"` : `${k}=${sv}`);
49
+ }
50
+ const kv = kvParts.length ? " " + kvParts.join(" ") : "";
51
+ process.stderr.write(`${prefix} ${msg}${kv}
52
+ `);
53
+ } catch (e) {
54
+ process.stderr.write(chunk);
55
+ }
56
+ }
57
+ };
58
+ }
59
+ function kvToObj(keyvals) {
60
+ const obj = {};
61
+ for (let i = 0; i < keyvals.length; i += 2) {
62
+ const key = String(keyvals[i]);
63
+ obj[key] = i + 1 < keyvals.length ? keyvals[i + 1] : "";
64
+ }
65
+ return obj;
66
+ }
67
+ var PINO_LEVELS = /* @__PURE__ */ new Set(["trace", "debug", "info", "warn", "error", "fatal"]);
68
+ function levelByName(name) {
69
+ return PINO_LEVELS.has(name) ? name : void 0;
70
+ }
71
+ function verbosityLevel(d, verbose) {
72
+ const levels = _nullishCoalesce(_optionalChain([d, 'access', _ => _.verbosity, 'optionalAccess', _2 => _2.levels]), () => ( {}));
73
+ let best = -1;
74
+ for (const key of Object.keys(levels)) {
75
+ const n = Number(key);
76
+ if (!Number.isInteger(n)) continue;
77
+ if (n <= verbose && n > best) best = n;
78
+ }
79
+ if (best < 0) return "info";
80
+ return _nullishCoalesce(levelByName(levels[String(best)]), () => ( "info"));
81
+ }
82
+ function quietLevel(d) {
83
+ return _nullishCoalesce(levelByName(_nullishCoalesce(_optionalChain([d, 'access', _3 => _3.verbosity, 'optionalAccess', _4 => _4.quiet_override]), () => ( ""))), () => ( "warn"));
84
+ }
85
+ function createLogger(opts) {
86
+ const quiet = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _5 => _5.quiet]), () => ( false));
87
+ const noColor = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _6 => _6.noColor]), () => ( false));
88
+ const p = _pino2.default.call(void 0, {
89
+ level: quiet ? quietLevel(_chunkQPUCXQXTjs.parity) : "debug"
90
+ }, kitTransport(noColor));
91
+ return {
92
+ info: (msg, ...kv) => p.info(kvToObj(kv), msg),
93
+ warn: (msg, ...kv) => p.warn(kvToObj(kv), msg),
94
+ error: (msg, ...kv) => p.error(kvToObj(kv), msg),
95
+ debug: (msg, ...kv) => p.debug(kvToObj(kv), msg),
96
+ trace: (msg, ...kv) => p.trace(kvToObj(kv), msg)
97
+ };
98
+ }
99
+ function withVerbose(opts) {
100
+ const quiet = _nullishCoalesce(opts.quiet, () => ( false));
101
+ const noColor = _nullishCoalesce(opts.noColor, () => ( false));
102
+ const v = _nullishCoalesce(opts.verbose, () => ( 0));
103
+ const level = quiet ? quietLevel(_chunkQPUCXQXTjs.parity) : verbosityLevel(_chunkQPUCXQXTjs.parity, v);
104
+ const p = _pino2.default.call(void 0, { level }, kitTransport(noColor));
105
+ return {
106
+ info: (msg, ...kv) => p.info(kvToObj(kv), msg),
107
+ warn: (msg, ...kv) => p.warn(kvToObj(kv), msg),
108
+ error: (msg, ...kv) => p.error(kvToObj(kv), msg),
109
+ debug: (msg, ...kv) => p.debug(kvToObj(kv), msg),
110
+ trace: (msg, ...kv) => p.trace(kvToObj(kv), msg)
111
+ };
112
+ }
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ exports.verbosityLevel = verbosityLevel; exports.quietLevel = quietLevel; exports.createLogger = createLogger; exports.withVerbose = withVerbose; exports.log_exports = log_exports;
@@ -0,0 +1,171 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
4
+
5
+ // src/toolspec.ts
6
+ var toolspec_exports = {};
7
+ _chunkR5U7XKVJjs.__export.call(void 0, toolspec_exports, {
8
+ findCommand: () => findCommand,
9
+ loadToolSpec: () => loadToolSpec,
10
+ validateToolSpec: () => validateToolSpec
11
+ });
12
+ var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
13
+ var _jsyaml = require('js-yaml'); var yaml = _interopRequireWildcard(_jsyaml);
14
+ function mapFlag(raw) {
15
+ return {
16
+ name: _nullishCoalesce(raw.name, () => ( "")),
17
+ short: raw.short,
18
+ type: raw.type,
19
+ description: raw.description,
20
+ deprecated: raw.deprecated,
21
+ replacedBy: raw.replaced_by
22
+ };
23
+ }
24
+ function mapProvenance(raw) {
25
+ if (!raw) return void 0;
26
+ return {
27
+ source: raw.source,
28
+ retrievedAt: raw.retrieved_at,
29
+ confidence: raw.confidence
30
+ };
31
+ }
32
+ function mapContract(raw) {
33
+ if (!raw) return void 0;
34
+ return {
35
+ idempotent: _nullishCoalesce(raw.idempotent, () => ( false)),
36
+ sideEffects: raw.side_effects,
37
+ retryable: _nullishCoalesce(raw.retryable, () => ( false)),
38
+ preConditions: raw.pre_conditions
39
+ };
40
+ }
41
+ function mapSafety(raw) {
42
+ if (!raw) return void 0;
43
+ return {
44
+ level: raw.level,
45
+ requiresConfirmation: raw.requires_confirmation,
46
+ permissions: raw.permissions
47
+ };
48
+ }
49
+ function mapOutputSchema(raw) {
50
+ if (!raw) return void 0;
51
+ return {
52
+ format: raw.format,
53
+ fields: raw.fields,
54
+ example: raw.example
55
+ };
56
+ }
57
+ function mapIntent(raw) {
58
+ if (!raw) return void 0;
59
+ return {
60
+ domain: raw.domain,
61
+ category: raw.category,
62
+ tags: raw.tags
63
+ };
64
+ }
65
+ function mapCommand(raw) {
66
+ return {
67
+ name: _nullishCoalesce(raw.name, () => ( "")),
68
+ aliases: raw.aliases,
69
+ flags: _optionalChain([raw, 'access', _ => _.flags, 'optionalAccess', _2 => _2.map, 'call', _3 => _3(mapFlag)]),
70
+ children: _optionalChain([raw, 'access', _4 => _4.children, 'optionalAccess', _5 => _5.map, 'call', _6 => _6(mapCommand)]),
71
+ contract: mapContract(raw.contract),
72
+ safety: mapSafety(raw.safety),
73
+ previewModes: raw.preview_modes,
74
+ outputSchema: mapOutputSchema(raw.output_schema),
75
+ deprecated: raw.deprecated,
76
+ deprecatedSince: raw.deprecated_since,
77
+ replacedBy: raw.replaced_by,
78
+ intent: mapIntent(raw.intent),
79
+ suggestedNext: raw.suggested_next
80
+ };
81
+ }
82
+ function mapStateIntrospection(raw) {
83
+ if (!raw) return void 0;
84
+ return {
85
+ configCommands: raw.config_commands,
86
+ envVars: raw.env_vars,
87
+ authCommands: raw.auth_commands
88
+ };
89
+ }
90
+ function mapErrorPattern(raw) {
91
+ return {
92
+ pattern: _nullishCoalesce(raw.pattern, () => ( "")),
93
+ fix: _nullishCoalesce(raw.fix, () => ( "")),
94
+ source: raw.source,
95
+ cause: raw.cause,
96
+ fixes: raw.fixes,
97
+ confidence: raw.confidence,
98
+ provenance: mapProvenance(raw.provenance)
99
+ };
100
+ }
101
+ function mapWorkflow(raw) {
102
+ return {
103
+ name: _nullishCoalesce(raw.name, () => ( "")),
104
+ steps: _nullishCoalesce(raw.steps, () => ( [])),
105
+ after: raw.after,
106
+ provenance: mapProvenance(raw.provenance)
107
+ };
108
+ }
109
+ function loadToolSpec(yamlPath) {
110
+ const content = fs.readFileSync(yamlPath, "utf-8");
111
+ const raw = yaml.load(content);
112
+ return {
113
+ name: _nullishCoalesce(raw.name, () => ( "")),
114
+ schemaVersion: _nullishCoalesce(raw.schema_version, () => ( "")),
115
+ commands: (_nullishCoalesce(raw.commands, () => ( []))).map(mapCommand),
116
+ flags: _optionalChain([raw, 'access', _7 => _7.flags, 'optionalAccess', _8 => _8.map, 'call', _9 => _9(mapFlag)]),
117
+ errorPatterns: _optionalChain([raw, 'access', _10 => _10.error_patterns, 'optionalAccess', _11 => _11.map, 'call', _12 => _12(mapErrorPattern)]),
118
+ workflows: _optionalChain([raw, 'access', _13 => _13.workflows, 'optionalAccess', _14 => _14.map, 'call', _15 => _15(mapWorkflow)]),
119
+ stateIntrospection: mapStateIntrospection(
120
+ raw.state_introspection
121
+ )
122
+ };
123
+ }
124
+ var VALID_SAFETY_LEVELS = /* @__PURE__ */ new Set([
125
+ "safe",
126
+ "caution",
127
+ "dangerous"
128
+ ]);
129
+ function validateToolSpec(spec) {
130
+ const errors = [];
131
+ if (!spec.name) errors.push("name is required");
132
+ if (!spec.schemaVersion) errors.push("schemaVersion is required");
133
+ if (!spec.commands || spec.commands.length === 0) {
134
+ errors.push("at least one command is required");
135
+ }
136
+ const validateCmd = (cmd, path) => {
137
+ if (!cmd.name) {
138
+ errors.push(`${path}: command name is required`);
139
+ }
140
+ if (cmd.safety && !VALID_SAFETY_LEVELS.has(cmd.safety.level)) {
141
+ errors.push(
142
+ `${path}: invalid safety level "${cmd.safety.level}" (must be safe|caution|dangerous)`
143
+ );
144
+ }
145
+ if (cmd.children) {
146
+ for (const child of cmd.children) {
147
+ validateCmd(child, `${path}/${child.name || "<unnamed>"}`);
148
+ }
149
+ }
150
+ };
151
+ for (const cmd of _nullishCoalesce(spec.commands, () => ( []))) {
152
+ validateCmd(cmd, cmd.name || "<unnamed>");
153
+ }
154
+ return errors;
155
+ }
156
+ function findCommand(spec, name) {
157
+ const queue = [...spec.commands];
158
+ while (queue.length > 0) {
159
+ const c = queue.shift();
160
+ if (c.name === name) return c;
161
+ if (c.children) queue.push(...c.children);
162
+ }
163
+ return void 0;
164
+ }
165
+
166
+
167
+
168
+
169
+
170
+
171
+ exports.loadToolSpec = loadToolSpec; exports.validateToolSpec = validateToolSpec; exports.findCommand = findCommand; exports.toolspec_exports = toolspec_exports;