@hop-top/kit 0.5.0-alpha.5 → 0.5.0-alpha.7

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 (70) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE-cobra.txt +174 -0
  3. package/NOTICE +15 -0
  4. package/README.md +10 -10
  5. package/dist/{alias-BOj0-VAr.d.ts → alias-BsJ2jGqQ.d.ts} +9 -1
  6. package/dist/alias.d.ts +1 -1
  7. package/dist/alias.js +4 -2
  8. package/dist/chunk-263IZ6Z6.js +915 -0
  9. package/dist/{chunk-S45UHXQF.js → chunk-DIDN4X5C.js} +8 -6
  10. package/dist/{chunk-ZC5TZYZJ.js → chunk-GHPJJV5L.js} +7 -3
  11. package/dist/chunk-JKMQSAJP.js +174 -0
  12. package/dist/chunk-JZ22ZUFA.js +1131 -0
  13. package/dist/chunk-NLMS7HGP.js +178 -0
  14. package/dist/chunk-QQQYCWSC.js +240 -0
  15. package/dist/chunk-XJTRY453.js +868 -0
  16. package/dist/{cli-8rfITnv4.d.ts → cli-C5B5tnpA.d.ts} +1 -60
  17. package/dist/cli.d.ts +2 -1
  18. package/dist/cli.js +5 -3
  19. package/dist/completion-sDKVXPUL.d.ts +109 -0
  20. package/dist/completion-values-By-mnjNt.d.ts +142 -0
  21. package/dist/completion-values.d.ts +1 -0
  22. package/dist/completion-values.js +29 -0
  23. package/dist/completion.d.ts +3 -0
  24. package/dist/completion.js +34 -0
  25. package/dist/compliance-AxFf-uMy.d.ts +60 -0
  26. package/dist/compliance.d.ts +1 -0
  27. package/dist/compliance.js +17 -0
  28. package/dist/config-CaK60ByQ.d.ts +241 -0
  29. package/dist/config.d.ts +1 -1
  30. package/dist/config.js +4 -2
  31. package/dist/{index-DEyjGoo2.d.ts → index-DCe1boBz.d.ts} +1 -1
  32. package/dist/index.d.ts +10 -4
  33. package/dist/index.js +40 -20
  34. package/dist/log-CkaxMX3U.d.ts +115 -0
  35. package/dist/log.d.ts +2 -0
  36. package/dist/log.js +14 -0
  37. package/dist/parity-CvMuYcVI.d.ts +61 -0
  38. package/dist/toolspec-UrWnoJ3Y.d.ts +336 -0
  39. package/dist/toolspec.d.ts +2 -0
  40. package/dist/toolspec.js +36 -0
  41. package/dist/tui/index.d.ts +3 -2
  42. package/package.json +43 -3
  43. package/src/alias.test.ts +110 -1
  44. package/src/alias.ts +19 -4
  45. package/src/cli.ts +5 -0
  46. package/src/completion-scripts.ts +16 -0
  47. package/src/completion-values.test.ts +70 -10
  48. package/src/completion-values.ts +170 -66
  49. package/src/completion.conformance.test.ts +297 -0
  50. package/src/completion.test.ts +256 -145
  51. package/src/completion.ts +764 -121
  52. package/src/config-merge.test.ts +425 -0
  53. package/src/config.test.ts +41 -0
  54. package/src/config.ts +265 -18
  55. package/src/index.test.ts +2 -1
  56. package/src/index.ts +8 -1
  57. package/src/log.test.ts +270 -1
  58. package/src/log.ts +172 -44
  59. package/src/published-types.test.ts +18 -0
  60. package/src/toolspec-internal.ts +197 -0
  61. package/src/toolspec-manifest.test.ts +82 -0
  62. package/src/toolspec-manifest.ts +404 -0
  63. package/src/toolspec-spec-schemas.ts +12 -0
  64. package/src/toolspec-spec.test.ts +273 -0
  65. package/src/toolspec-spec.ts +458 -0
  66. package/src/toolspec.from-command.test.ts +216 -0
  67. package/src/toolspec.ts +159 -0
  68. package/test/toolspec/fixture.ts +73 -0
  69. package/dist/chunk-IQXEISMC.js +0 -142
  70. package/dist/config-Bm9fBXch.d.ts +0 -134
@@ -1,5 +1,8 @@
1
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
2
 
3
+ var _chunkJZ22ZUFAjs = require('./chunk-JZ22ZUFA.js');
4
+
5
+
3
6
  var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
4
7
 
5
8
  // src/alias.ts
@@ -147,6 +150,7 @@ function findCommand(program, cmdPath) {
147
150
  function bridgeAliases(program, store) {
148
151
  const all = store.all();
149
152
  for (const [name, target] of Object.entries(all)) {
153
+ _chunkJZ22ZUFAjs.registerRootAlias.call(void 0, program, name, target);
150
154
  const parts = target.split(/\s+/);
151
155
  if (parts.length === 1) {
152
156
  const targetCmd = findCommand(program, target);
@@ -157,12 +161,10 @@ function bridgeAliases(program, store) {
157
161
  }
158
162
  const proxy = new (0, _commander.Command)(name).description(`Alias for ${target}`).allowUnknownOption(true).allowExcessArguments(true).action(function() {
159
163
  const expanded = target.split(/\s+/);
160
- program.parse([
161
- "node",
162
- program.name(),
163
- ...expanded,
164
- ...this.args
165
- ]);
164
+ return program._parseCommand(
165
+ [],
166
+ [...expanded, ...this.args]
167
+ );
166
168
  });
167
169
  proxy.helpOption(false);
168
170
  proxy._hidden = true;
@@ -1,14 +1,14 @@
1
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
2
 
3
- var _chunkQPUCXQXTjs = require('./chunk-QPUCXQXT.js');
4
-
5
-
6
3
  var _chunk72XZWQX7js = require('./chunk-72XZWQX7.js');
7
4
 
8
5
 
9
6
  var _chunkPOR5L2DGjs = require('./chunk-POR5L2DG.js');
10
7
 
11
8
 
9
+ var _chunkQPUCXQXTjs = require('./chunk-QPUCXQXT.js');
10
+
11
+
12
12
 
13
13
 
14
14
 
@@ -19,6 +19,9 @@ var _chunkPOR5L2DGjs = require('./chunk-POR5L2DG.js');
19
19
  var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
20
20
 
21
21
 
22
+ var _chunkJZ22ZUFAjs = require('./chunk-JZ22ZUFA.js');
23
+
24
+
22
25
  var _chunkR5U7XKVJjs = require('./chunk-R5U7XKVJ.js');
23
26
 
24
27
  // src/cli.ts
@@ -558,6 +561,7 @@ ${cfg.help.disclaimer}` : cfg.description;
558
561
  const flag = g.short ? `-${g.short}, --${g.name} <value>` : `--${g.name} <value>`;
559
562
  program.option(flag, g.usage, _nullishCoalesce(g.default, () => ( "")));
560
563
  }
564
+ _chunkJZ22ZUFAjs.installCompletionRequest.call(void 0, program);
561
565
  applyHelpTheme(
562
566
  program,
563
567
  theme,
@@ -0,0 +1,174 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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-values.ts
6
+ var completion_values_exports = {};
7
+ _chunkR5U7XKVJjs.__export.call(void 0, completion_values_exports, {
8
+ CompletionRegistry: () => CompletionRegistry,
9
+ ShellCompDirective: () => ShellCompDirective,
10
+ configKeysCompleter: () => configKeysCompleter,
11
+ dirCompleter: () => dirCompleter,
12
+ directiveName: () => directiveName,
13
+ fileCompleter: () => fileCompleter,
14
+ funcCompleter: () => funcCompleter,
15
+ prefixedCompleter: () => prefixedCompleter,
16
+ resolveCompletions: () => resolveCompletions,
17
+ staticCompleter: () => staticCompleter,
18
+ staticValues: () => staticValues,
19
+ withDescription: () => withDescription
20
+ });
21
+ var ShellCompDirective = {
22
+ Default: 0,
23
+ Error: 1,
24
+ NoSpace: 2,
25
+ NoFileComp: 4,
26
+ FilterFileExt: 8,
27
+ FilterDirs: 16,
28
+ KeepOrder: 32
29
+ };
30
+ function directiveName(d) {
31
+ if (d >= 64) return `ERROR: unexpected ShellCompDirective value: ${d}`;
32
+ const names = [
33
+ [ShellCompDirective.Error, "ShellCompDirectiveError"],
34
+ [ShellCompDirective.NoSpace, "ShellCompDirectiveNoSpace"],
35
+ [ShellCompDirective.NoFileComp, "ShellCompDirectiveNoFileComp"],
36
+ [ShellCompDirective.FilterFileExt, "ShellCompDirectiveFilterFileExt"],
37
+ [ShellCompDirective.FilterDirs, "ShellCompDirectiveFilterDirs"],
38
+ [ShellCompDirective.KeepOrder, "ShellCompDirectiveKeepOrder"]
39
+ ];
40
+ const set = names.filter(([bit]) => (d & bit) === bit).map(([, n]) => n);
41
+ return set.length ? set.join(", ") : "ShellCompDirectiveDefault";
42
+ }
43
+ async function resolveCompletions(c, toComplete, ctx = { commandPath: "", args: [] }) {
44
+ const f = c.fileFilter;
45
+ if (_optionalChain([f, 'optionalAccess', _ => _.kind]) === "dirs") {
46
+ return { completions: [], directive: ShellCompDirective.FilterDirs };
47
+ }
48
+ if (_optionalChain([f, 'optionalAccess', _2 => _2.kind]) === "extensions") {
49
+ return f.extensions.length === 0 ? { completions: [], directive: ShellCompDirective.Default } : { completions: [...f.extensions], directive: ShellCompDirective.FilterFileExt };
50
+ }
51
+ try {
52
+ const items = await c.complete(toComplete, ctx);
53
+ return {
54
+ completions: items.map(withDescription),
55
+ directive: ShellCompDirective.NoFileComp
56
+ };
57
+ } catch (e2) {
58
+ return { completions: [], directive: ShellCompDirective.Error };
59
+ }
60
+ }
61
+ function withDescription(i) {
62
+ return i.description ? `${i.value} ${i.description}` : i.value;
63
+ }
64
+ var CompletionRegistry = class {
65
+ constructor() {
66
+ this.flags = /* @__PURE__ */ new Map();
67
+ this.args = /* @__PURE__ */ new Map();
68
+ }
69
+ register(flag, completer) {
70
+ this.flags.set(flag, completer);
71
+ }
72
+ registerArg(cmd, pos, completer) {
73
+ this.args.set(`${cmd}:${pos}`, completer);
74
+ }
75
+ forFlag(flag) {
76
+ return this.flags.get(flag);
77
+ }
78
+ forArg(cmd, pos) {
79
+ return this.args.get(`${cmd}:${pos}`);
80
+ }
81
+ };
82
+ function filterByPrefix(items, prefix) {
83
+ if (!prefix) return [...items];
84
+ const lp = prefix.toLowerCase();
85
+ return items.filter((i) => i.value.toLowerCase().startsWith(lp));
86
+ }
87
+ function staticCompleter(...items) {
88
+ return {
89
+ complete(prefix) {
90
+ return filterByPrefix(items, prefix);
91
+ }
92
+ };
93
+ }
94
+ function staticValues(...values) {
95
+ const items = values.map((v) => ({ value: v }));
96
+ return staticCompleter(...items);
97
+ }
98
+ function funcCompleter(fn) {
99
+ return {
100
+ complete(prefix, ctx = { commandPath: "", args: [] }) {
101
+ return fn(prefix, ctx);
102
+ }
103
+ };
104
+ }
105
+ function prefixedCompleter(dimension, values) {
106
+ const lower = dimension.toLowerCase();
107
+ const prepend = (items) => items.map((i) => {
108
+ const v = `${dimension}:${i.value}`;
109
+ return i.description ? { value: v, description: i.description } : { value: v };
110
+ });
111
+ return {
112
+ complete(prefix, ctx) {
113
+ const colonIdx = prefix.indexOf(":");
114
+ if (colonIdx < 0) {
115
+ const dim = `${dimension}:`;
116
+ return dim.toLowerCase().startsWith(prefix.toLowerCase()) ? [{ value: dim, description: `${dimension} values` }] : [];
117
+ }
118
+ if (prefix.slice(0, colonIdx).toLowerCase() !== lower) return [];
119
+ const inner = values.complete(prefix.slice(colonIdx + 1), ctx);
120
+ return Array.isArray(inner) ? prepend(inner) : inner.then(prepend);
121
+ }
122
+ };
123
+ }
124
+ function leafKeys(obj, prefix, out) {
125
+ for (const [k, v] of Object.entries(obj)) {
126
+ const full = prefix ? `${prefix}.${k.toLowerCase()}` : k.toLowerCase();
127
+ if (v != null && typeof v === "object" && !Array.isArray(v)) {
128
+ leafKeys(v, full, out);
129
+ } else {
130
+ out.add(full);
131
+ }
132
+ }
133
+ }
134
+ function configKeysCompleter(config) {
135
+ return {
136
+ complete(prefix) {
137
+ const keys = /* @__PURE__ */ new Set();
138
+ leafKeys(config, "", keys);
139
+ return filterByPrefix([...keys].map((k) => ({ value: k })), prefix);
140
+ }
141
+ };
142
+ }
143
+ function fileCompleter(...extensions) {
144
+ return {
145
+ fileFilter: { kind: "extensions", extensions: [...extensions] },
146
+ complete() {
147
+ return extensions.map((e) => ({ value: e }));
148
+ }
149
+ };
150
+ }
151
+ function dirCompleter() {
152
+ return {
153
+ fileFilter: { kind: "dirs" },
154
+ complete() {
155
+ return [];
156
+ }
157
+ };
158
+ }
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+ exports.ShellCompDirective = ShellCompDirective; exports.directiveName = directiveName; exports.resolveCompletions = resolveCompletions; exports.withDescription = withDescription; exports.CompletionRegistry = CompletionRegistry; exports.staticCompleter = staticCompleter; exports.staticValues = staticValues; exports.funcCompleter = funcCompleter; exports.prefixedCompleter = prefixedCompleter; exports.configKeysCompleter = configKeysCompleter; exports.fileCompleter = fileCompleter; exports.dirCompleter = dirCompleter; exports.completion_values_exports = completion_values_exports;