voyageai-cli 1.12.1 → 1.15.0

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 (44) hide show
  1. package/README.md +3 -3
  2. package/demo-readme.gif +0 -0
  3. package/package.json +1 -1
  4. package/src/cli.js +2 -0
  5. package/src/commands/benchmark.js +164 -0
  6. package/src/commands/completions.js +18 -1
  7. package/src/commands/estimate.js +209 -0
  8. package/src/commands/models.js +32 -4
  9. package/src/lib/catalog.js +42 -18
  10. package/src/lib/explanations.js +183 -0
  11. package/.github/workflows/ci.yml +0 -22
  12. package/CONTRIBUTING.md +0 -81
  13. package/demo.gif +0 -0
  14. package/demo.tape +0 -39
  15. package/scripts/record-demo.sh +0 -63
  16. package/test/commands/about.test.js +0 -23
  17. package/test/commands/benchmark.test.js +0 -319
  18. package/test/commands/completions.test.js +0 -166
  19. package/test/commands/config.test.js +0 -35
  20. package/test/commands/demo.test.js +0 -46
  21. package/test/commands/embed.test.js +0 -42
  22. package/test/commands/explain.test.js +0 -207
  23. package/test/commands/ingest.test.js +0 -261
  24. package/test/commands/models.test.js +0 -132
  25. package/test/commands/ping.test.js +0 -172
  26. package/test/commands/playground.test.js +0 -137
  27. package/test/commands/rerank.test.js +0 -32
  28. package/test/commands/similarity.test.js +0 -79
  29. package/test/commands/store.test.js +0 -26
  30. package/test/fixtures/sample.csv +0 -6
  31. package/test/fixtures/sample.json +0 -7
  32. package/test/fixtures/sample.jsonl +0 -5
  33. package/test/fixtures/sample.txt +0 -5
  34. package/test/lib/api.test.js +0 -133
  35. package/test/lib/banner.test.js +0 -44
  36. package/test/lib/catalog.test.js +0 -99
  37. package/test/lib/config.test.js +0 -124
  38. package/test/lib/explanations.test.js +0 -141
  39. package/test/lib/format.test.js +0 -75
  40. package/test/lib/input.test.js +0 -48
  41. package/test/lib/math.test.js +0 -43
  42. package/test/lib/ui.test.js +0 -79
  43. package/voyageai-cli-playground.png +0 -0
  44. package/voyageai-cli.png +0 -0
@@ -1,319 +0,0 @@
1
- 'use strict';
2
-
3
- const { describe, it } = require('node:test');
4
- const assert = require('node:assert/strict');
5
- const { Command } = require('commander');
6
- const { registerBenchmark } = require('../../src/commands/benchmark');
7
-
8
- describe('benchmark command', () => {
9
- it('registers as benchmark with bench alias', () => {
10
- const program = new Command();
11
- registerBenchmark(program);
12
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
13
- assert.ok(benchCmd, 'benchmark command should be registered');
14
- assert.ok(benchCmd.aliases().includes('bench'), 'should have "bench" alias');
15
- });
16
-
17
- it('has embed subcommand', () => {
18
- const program = new Command();
19
- registerBenchmark(program);
20
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
21
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
22
- assert.ok(embedSub, 'embed subcommand should be registered');
23
- });
24
-
25
- it('embed has --models option', () => {
26
- const program = new Command();
27
- registerBenchmark(program);
28
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
29
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
30
- const optionNames = embedSub.options.map(o => o.long);
31
- assert.ok(optionNames.includes('--models'), 'should have --models option');
32
- });
33
-
34
- it('embed has --rounds option', () => {
35
- const program = new Command();
36
- registerBenchmark(program);
37
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
38
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
39
- const optionNames = embedSub.options.map(o => o.long);
40
- assert.ok(optionNames.includes('--rounds'), 'should have --rounds option');
41
- });
42
-
43
- it('embed has --input option for custom text', () => {
44
- const program = new Command();
45
- registerBenchmark(program);
46
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
47
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
48
- const optionNames = embedSub.options.map(o => o.long);
49
- assert.ok(optionNames.includes('--input'), 'should have --input option');
50
- });
51
-
52
- it('embed has --file option', () => {
53
- const program = new Command();
54
- registerBenchmark(program);
55
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
56
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
57
- const optionNames = embedSub.options.map(o => o.long);
58
- assert.ok(optionNames.includes('--file'), 'should have --file option');
59
- });
60
-
61
- it('embed has --json and --quiet options', () => {
62
- const program = new Command();
63
- registerBenchmark(program);
64
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
65
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
66
- const optionNames = embedSub.options.map(o => o.long);
67
- assert.ok(optionNames.includes('--json'), 'should have --json option');
68
- assert.ok(optionNames.includes('--quiet'), 'should have --quiet option');
69
- });
70
-
71
- it('embed has --dimensions option', () => {
72
- const program = new Command();
73
- registerBenchmark(program);
74
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
75
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
76
- const optionNames = embedSub.options.map(o => o.long);
77
- assert.ok(optionNames.includes('--dimensions'), 'should have --dimensions option');
78
- });
79
-
80
- it('has rerank subcommand', () => {
81
- const program = new Command();
82
- registerBenchmark(program);
83
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
84
- const rerankSub = benchCmd.commands.find(c => c.name() === 'rerank');
85
- assert.ok(rerankSub, 'rerank subcommand should be registered');
86
- });
87
-
88
- it('rerank has --models and --rounds options', () => {
89
- const program = new Command();
90
- registerBenchmark(program);
91
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
92
- const rerankSub = benchCmd.commands.find(c => c.name() === 'rerank');
93
- const optionNames = rerankSub.options.map(o => o.long);
94
- assert.ok(optionNames.includes('--models'), 'should have --models option');
95
- assert.ok(optionNames.includes('--rounds'), 'should have --rounds option');
96
- });
97
-
98
- it('rerank has --query option', () => {
99
- const program = new Command();
100
- registerBenchmark(program);
101
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
102
- const rerankSub = benchCmd.commands.find(c => c.name() === 'rerank');
103
- const optionNames = rerankSub.options.map(o => o.long);
104
- assert.ok(optionNames.includes('--query'), 'should have --query option');
105
- });
106
-
107
- it('rerank has --documents-file and --top-k options', () => {
108
- const program = new Command();
109
- registerBenchmark(program);
110
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
111
- const rerankSub = benchCmd.commands.find(c => c.name() === 'rerank');
112
- const optionNames = rerankSub.options.map(o => o.long);
113
- assert.ok(optionNames.includes('--documents-file'), 'should have --documents-file option');
114
- assert.ok(optionNames.includes('--top-k'), 'should have --top-k option');
115
- });
116
-
117
- it('has similarity subcommand', () => {
118
- const program = new Command();
119
- registerBenchmark(program);
120
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
121
- const simSub = benchCmd.commands.find(c => c.name() === 'similarity');
122
- assert.ok(simSub, 'similarity subcommand should be registered');
123
- });
124
-
125
- it('similarity has --models, --query, --file, --top-k options', () => {
126
- const program = new Command();
127
- registerBenchmark(program);
128
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
129
- const simSub = benchCmd.commands.find(c => c.name() === 'similarity');
130
- const optionNames = simSub.options.map(o => o.long);
131
- assert.ok(optionNames.includes('--models'), 'should have --models');
132
- assert.ok(optionNames.includes('--query'), 'should have --query');
133
- assert.ok(optionNames.includes('--file'), 'should have --file');
134
- assert.ok(optionNames.includes('--top-k'), 'should have --top-k');
135
- });
136
-
137
- it('has cost subcommand', () => {
138
- const program = new Command();
139
- registerBenchmark(program);
140
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
141
- const costSub = benchCmd.commands.find(c => c.name() === 'cost');
142
- assert.ok(costSub, 'cost subcommand should be registered');
143
- });
144
-
145
- it('cost has --models, --tokens, --volumes options', () => {
146
- const program = new Command();
147
- registerBenchmark(program);
148
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
149
- const costSub = benchCmd.commands.find(c => c.name() === 'cost');
150
- const optionNames = costSub.options.map(o => o.long);
151
- assert.ok(optionNames.includes('--models'), 'should have --models');
152
- assert.ok(optionNames.includes('--tokens'), 'should have --tokens');
153
- assert.ok(optionNames.includes('--volumes'), 'should have --volumes');
154
- });
155
-
156
- it('has batch subcommand', () => {
157
- const program = new Command();
158
- registerBenchmark(program);
159
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
160
- const batchSub = benchCmd.commands.find(c => c.name() === 'batch');
161
- assert.ok(batchSub, 'batch subcommand should be registered');
162
- });
163
-
164
- it('batch has --model, --batch-sizes, --rounds options', () => {
165
- const program = new Command();
166
- registerBenchmark(program);
167
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
168
- const batchSub = benchCmd.commands.find(c => c.name() === 'batch');
169
- const optionNames = batchSub.options.map(o => o.long);
170
- assert.ok(optionNames.includes('--model'), 'should have --model');
171
- assert.ok(optionNames.includes('--batch-sizes'), 'should have --batch-sizes');
172
- assert.ok(optionNames.includes('--rounds'), 'should have --rounds');
173
- });
174
-
175
- it('all subcommands have --json output option', () => {
176
- const program = new Command();
177
- registerBenchmark(program);
178
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
179
-
180
- for (const sub of benchCmd.commands) {
181
- if (sub.name() === 'help') continue;
182
- const optionNames = sub.options.map(o => o.long);
183
- assert.ok(optionNames.includes('--json'), `${sub.name()} should have --json option`);
184
- }
185
- });
186
-
187
- it('all subcommands have --quiet option', () => {
188
- const program = new Command();
189
- registerBenchmark(program);
190
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
191
-
192
- for (const sub of benchCmd.commands) {
193
- if (sub.name() === 'help') continue;
194
- const optionNames = sub.options.map(o => o.long);
195
- assert.ok(optionNames.includes('--quiet'), `${sub.name()} should have --quiet option`);
196
- }
197
- });
198
-
199
- it('embed defaults models to voyage-4-large,voyage-4,voyage-4-lite', () => {
200
- const program = new Command();
201
- registerBenchmark(program);
202
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
203
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
204
- const modelsOpt = embedSub.options.find(o => o.long === '--models');
205
- assert.equal(modelsOpt.defaultValue, 'voyage-4-large,voyage-4,voyage-4-lite');
206
- });
207
-
208
- it('rerank defaults models to rerank-2.5,rerank-2.5-lite', () => {
209
- const program = new Command();
210
- registerBenchmark(program);
211
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
212
- const rerankSub = benchCmd.commands.find(c => c.name() === 'rerank');
213
- const modelsOpt = rerankSub.options.find(o => o.long === '--models');
214
- assert.equal(modelsOpt.defaultValue, 'rerank-2.5,rerank-2.5-lite');
215
- });
216
-
217
- it('cost defaults volumes to 100,1000,10000,100000', () => {
218
- const program = new Command();
219
- registerBenchmark(program);
220
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
221
- const costSub = benchCmd.commands.find(c => c.name() === 'cost');
222
- const volOpt = costSub.options.find(o => o.long === '--volumes');
223
- assert.equal(volOpt.defaultValue, '100,1000,10000,100000');
224
- });
225
-
226
- it('embed has --save option', () => {
227
- const program = new Command();
228
- registerBenchmark(program);
229
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
230
- const embedSub = benchCmd.commands.find(c => c.name() === 'embed');
231
- const optionNames = embedSub.options.map(o => o.long);
232
- assert.ok(optionNames.includes('--save'), 'should have --save option');
233
- });
234
-
235
- it('rerank has --save option', () => {
236
- const program = new Command();
237
- registerBenchmark(program);
238
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
239
- const rerankSub = benchCmd.commands.find(c => c.name() === 'rerank');
240
- const optionNames = rerankSub.options.map(o => o.long);
241
- assert.ok(optionNames.includes('--save'), 'should have --save option');
242
- });
243
-
244
- it('has asymmetric subcommand', () => {
245
- const program = new Command();
246
- registerBenchmark(program);
247
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
248
- const asymSub = benchCmd.commands.find(c => c.name() === 'asymmetric');
249
- assert.ok(asymSub, 'asymmetric subcommand should be registered');
250
- });
251
-
252
- it('asymmetric has --doc-model and --query-models options', () => {
253
- const program = new Command();
254
- registerBenchmark(program);
255
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
256
- const asymSub = benchCmd.commands.find(c => c.name() === 'asymmetric');
257
- const optionNames = asymSub.options.map(o => o.long);
258
- assert.ok(optionNames.includes('--doc-model'), 'should have --doc-model');
259
- assert.ok(optionNames.includes('--query-models'), 'should have --query-models');
260
- });
261
-
262
- it('asymmetric defaults doc-model to voyage-4-large', () => {
263
- const program = new Command();
264
- registerBenchmark(program);
265
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
266
- const asymSub = benchCmd.commands.find(c => c.name() === 'asymmetric');
267
- const opt = asymSub.options.find(o => o.long === '--doc-model');
268
- assert.equal(opt.defaultValue, 'voyage-4-large');
269
- });
270
-
271
- it('has quantization subcommand with quant alias', () => {
272
- const program = new Command();
273
- registerBenchmark(program);
274
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
275
- const quantSub = benchCmd.commands.find(c => c.name() === 'quantization');
276
- assert.ok(quantSub, 'quantization subcommand should be registered');
277
- assert.ok(quantSub.aliases().includes('quant'), 'should have "quant" alias');
278
- });
279
-
280
- it('quantization has --model, --dtypes, --query options', () => {
281
- const program = new Command();
282
- registerBenchmark(program);
283
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
284
- const quantSub = benchCmd.commands.find(c => c.name() === 'quantization');
285
- const optionNames = quantSub.options.map(o => o.long);
286
- assert.ok(optionNames.includes('--model'), 'should have --model');
287
- assert.ok(optionNames.includes('--dtypes'), 'should have --dtypes');
288
- assert.ok(optionNames.includes('--query'), 'should have --query');
289
- });
290
-
291
- it('quantization defaults dtypes to float,int8,ubinary', () => {
292
- const program = new Command();
293
- registerBenchmark(program);
294
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
295
- const quantSub = benchCmd.commands.find(c => c.name() === 'quantization');
296
- const dtypesOpt = quantSub.options.find(o => o.long === '--dtypes');
297
- assert.equal(dtypesOpt.defaultValue, 'float,int8,ubinary');
298
- });
299
-
300
- it('quantization has --dimensions, --save, --file options', () => {
301
- const program = new Command();
302
- registerBenchmark(program);
303
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
304
- const quantSub = benchCmd.commands.find(c => c.name() === 'quantization');
305
- const optionNames = quantSub.options.map(o => o.long);
306
- assert.ok(optionNames.includes('--dimensions'), 'should have --dimensions');
307
- assert.ok(optionNames.includes('--save'), 'should have --save');
308
- assert.ok(optionNames.includes('--file'), 'should have --file');
309
- });
310
-
311
- it('batch defaults batch-sizes to 1,5,10,25,50', () => {
312
- const program = new Command();
313
- registerBenchmark(program);
314
- const benchCmd = program.commands.find(c => c.name() === 'benchmark');
315
- const batchSub = benchCmd.commands.find(c => c.name() === 'batch');
316
- const sizesOpt = batchSub.options.find(o => o.long === '--batch-sizes');
317
- assert.equal(sizesOpt.defaultValue, '1,5,10,25,50');
318
- });
319
- });
@@ -1,166 +0,0 @@
1
- 'use strict';
2
-
3
- const { describe, it, beforeEach, afterEach } = require('node:test');
4
- const assert = require('node:assert/strict');
5
- const { Command } = require('commander');
6
- const { registerCompletions, generateBashCompletions, generateZshCompletions } = require('../../src/commands/completions');
7
-
8
- describe('completions command', () => {
9
- let originalLog;
10
- let originalWrite;
11
- let originalError;
12
- let originalExit;
13
- let output;
14
- let stdoutOutput;
15
- let stderrOutput;
16
-
17
- beforeEach(() => {
18
- originalLog = console.log;
19
- originalWrite = process.stdout.write;
20
- originalError = console.error;
21
- originalExit = process.exit;
22
- output = [];
23
- stdoutOutput = [];
24
- stderrOutput = [];
25
- console.log = (...args) => output.push(args.join(' '));
26
- process.stdout.write = (data) => { stdoutOutput.push(data); return true; };
27
- console.error = (...args) => stderrOutput.push(args.join(' '));
28
- process.exit = (code) => { throw new Error(`EXIT_${code}`); };
29
- });
30
-
31
- afterEach(() => {
32
- console.log = originalLog;
33
- process.stdout.write = originalWrite;
34
- console.error = originalError;
35
- process.exit = originalExit;
36
- });
37
-
38
- it('registers correctly on a program', () => {
39
- const program = new Command();
40
- registerCompletions(program);
41
- const cmd = program.commands.find(c => c.name() === 'completions');
42
- assert.ok(cmd, 'completions command should be registered');
43
- assert.ok(cmd.description().includes('completion'), 'should have a description about completions');
44
- });
45
-
46
- it('shows usage when called without shell argument', async () => {
47
- const program = new Command();
48
- program.exitOverride();
49
- registerCompletions(program);
50
-
51
- await program.parseAsync(['node', 'test', 'completions']);
52
-
53
- const combined = output.join('\n');
54
- assert.ok(combined.includes('bash'), 'should mention bash');
55
- assert.ok(combined.includes('zsh'), 'should mention zsh');
56
- });
57
-
58
- it('outputs bash completion script', async () => {
59
- const program = new Command();
60
- program.exitOverride();
61
- registerCompletions(program);
62
-
63
- await program.parseAsync(['node', 'test', 'completions', 'bash']);
64
-
65
- const combined = stdoutOutput.join('');
66
- assert.ok(combined.includes('_vai_completions'), 'should contain bash completion function');
67
- assert.ok(combined.includes('complete -F _vai_completions vai'), 'should register completion');
68
- });
69
-
70
- it('outputs zsh completion script', async () => {
71
- const program = new Command();
72
- program.exitOverride();
73
- registerCompletions(program);
74
-
75
- await program.parseAsync(['node', 'test', 'completions', 'zsh']);
76
-
77
- const combined = stdoutOutput.join('');
78
- assert.ok(combined.includes('#compdef vai'), 'should contain zsh compdef header');
79
- assert.ok(combined.includes('_vai'), 'should contain zsh completion function');
80
- });
81
-
82
- it('rejects unknown shell', async () => {
83
- const program = new Command();
84
- program.exitOverride();
85
- registerCompletions(program);
86
-
87
- await assert.rejects(
88
- () => program.parseAsync(['node', 'test', 'completions', 'fish']),
89
- /EXIT_1/,
90
- 'should exit with code 1 for unsupported shell'
91
- );
92
- const combined = stderrOutput.join('\n');
93
- assert.ok(combined.includes('fish'), 'should mention the unknown shell name');
94
- });
95
- });
96
-
97
- describe('generateBashCompletions', () => {
98
- it('includes all 14 commands (including completions)', () => {
99
- const script = generateBashCompletions();
100
- const commands = ['embed', 'rerank', 'store', 'search', 'index', 'models', 'ping', 'config', 'demo', 'explain', 'similarity', 'ingest', 'completions', 'help'];
101
- for (const cmd of commands) {
102
- assert.ok(script.includes(cmd), `should include command: ${cmd}`);
103
- }
104
- });
105
-
106
- it('includes model completions', () => {
107
- const script = generateBashCompletions();
108
- assert.ok(script.includes('voyage-4-large'), 'should include voyage-4-large model');
109
- assert.ok(script.includes('rerank-2.5'), 'should include rerank-2.5 model');
110
- });
111
-
112
- it('includes flag completions for embed', () => {
113
- const script = generateBashCompletions();
114
- assert.ok(script.includes('--model'), 'should include --model flag');
115
- assert.ok(script.includes('--dimensions'), 'should include --dimensions flag');
116
- assert.ok(script.includes('--input-type'), 'should include --input-type flag');
117
- });
118
-
119
- it('includes index subcommands', () => {
120
- const script = generateBashCompletions();
121
- assert.ok(script.includes('create list delete'), 'should include index subcommands');
122
- });
123
-
124
- it('includes config subcommands', () => {
125
- const script = generateBashCompletions();
126
- assert.ok(script.includes('set get delete path reset'), 'should include config subcommands');
127
- });
128
-
129
- it('includes input-type values', () => {
130
- const script = generateBashCompletions();
131
- assert.ok(script.includes('query document'), 'should include input-type values');
132
- });
133
- });
134
-
135
- describe('generateZshCompletions', () => {
136
- it('includes compdef header', () => {
137
- const script = generateZshCompletions();
138
- assert.ok(script.startsWith('#compdef vai'), 'should start with #compdef vai');
139
- });
140
-
141
- it('includes all commands with descriptions', () => {
142
- const script = generateZshCompletions();
143
- const commands = ['embed', 'rerank', 'store', 'search', 'index', 'models', 'ping', 'config', 'demo', 'explain', 'similarity', 'ingest', 'completions'];
144
- for (const cmd of commands) {
145
- assert.ok(script.includes(`'${cmd}:`), `should include command with description: ${cmd}`);
146
- }
147
- });
148
-
149
- it('includes model names', () => {
150
- const script = generateZshCompletions();
151
- assert.ok(script.includes('voyage-4-large'), 'should include voyage-4-large model');
152
- assert.ok(script.includes('voyage-code-3'), 'should include voyage-code-3 model');
153
- });
154
-
155
- it('includes explain topics', () => {
156
- const script = generateZshCompletions();
157
- assert.ok(script.includes('embeddings'), 'should include embeddings topic');
158
- assert.ok(script.includes('cosine-similarity'), 'should include cosine-similarity topic');
159
- assert.ok(script.includes('batch-processing'), 'should include batch-processing topic');
160
- });
161
-
162
- it('includes file completion for --file flags', () => {
163
- const script = generateZshCompletions();
164
- assert.ok(script.includes('_files'), 'should use _files completion');
165
- });
166
- });
@@ -1,35 +0,0 @@
1
- 'use strict';
2
-
3
- const { describe, it, beforeEach, afterEach } = require('node:test');
4
- const assert = require('node:assert/strict');
5
- const { Command } = require('commander');
6
- const { registerConfig } = require('../../src/commands/config');
7
-
8
- describe('config command', () => {
9
- it('registers config command with subcommands', () => {
10
- const program = new Command();
11
- program.exitOverride();
12
- registerConfig(program);
13
-
14
- const configCmd = program.commands.find(c => c.name() === 'config');
15
- assert.ok(configCmd, 'config command should be registered');
16
-
17
- const subNames = configCmd.commands.map(c => c.name());
18
- assert.ok(subNames.includes('set'), 'should have set subcommand');
19
- assert.ok(subNames.includes('get'), 'should have get subcommand');
20
- assert.ok(subNames.includes('delete'), 'should have delete subcommand');
21
- assert.ok(subNames.includes('path'), 'should have path subcommand');
22
- assert.ok(subNames.includes('reset'), 'should have reset subcommand');
23
- });
24
-
25
- it('config set/get/delete round-trip via lib functions', () => {
26
- // This test exercises the underlying lib (already tested in config.test.js)
27
- // but validates the key mapping used by the command
28
- const { KEY_MAP } = require('../../src/lib/config');
29
-
30
- assert.equal(KEY_MAP['api-key'], 'apiKey');
31
- assert.equal(KEY_MAP['mongodb-uri'], 'mongodbUri');
32
- assert.equal(KEY_MAP['default-model'], 'defaultModel');
33
- assert.equal(KEY_MAP['default-dimensions'], 'defaultDimensions');
34
- });
35
- });
@@ -1,46 +0,0 @@
1
- 'use strict';
2
-
3
- const { describe, it } = require('node:test');
4
- const assert = require('node:assert/strict');
5
- const { Command } = require('commander');
6
- const { registerDemo } = require('../../src/commands/demo');
7
-
8
- describe('demo command', () => {
9
- it('registers correctly on a program', () => {
10
- const program = new Command();
11
- registerDemo(program);
12
- const demoCmd = program.commands.find(c => c.name() === 'demo');
13
- assert.ok(demoCmd, 'demo command should be registered');
14
- });
15
-
16
- it('has --no-pause option', () => {
17
- const program = new Command();
18
- registerDemo(program);
19
- const demoCmd = program.commands.find(c => c.name() === 'demo');
20
- const opts = demoCmd.options.map(o => o.long);
21
- assert.ok(opts.includes('--no-pause'), 'Should have --no-pause option');
22
- });
23
-
24
- it('has --skip-pipeline option', () => {
25
- const program = new Command();
26
- registerDemo(program);
27
- const demoCmd = program.commands.find(c => c.name() === 'demo');
28
- const opts = demoCmd.options.map(o => o.long);
29
- assert.ok(opts.includes('--skip-pipeline'), 'Should have --skip-pipeline option');
30
- });
31
-
32
- it('has --keep option', () => {
33
- const program = new Command();
34
- registerDemo(program);
35
- const demoCmd = program.commands.find(c => c.name() === 'demo');
36
- const opts = demoCmd.options.map(o => o.long);
37
- assert.ok(opts.includes('--keep'), 'Should have --keep option');
38
- });
39
-
40
- it('has correct description', () => {
41
- const program = new Command();
42
- registerDemo(program);
43
- const demoCmd = program.commands.find(c => c.name() === 'demo');
44
- assert.ok(demoCmd.description().includes('walkthrough'), 'Should mention walkthrough');
45
- });
46
- });
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- const { describe, it, beforeEach, afterEach, mock } = require('node:test');
4
- const assert = require('node:assert/strict');
5
- const { Command } = require('commander');
6
- const { registerEmbed } = require('../../src/commands/embed');
7
-
8
- describe('embed command', () => {
9
- it('registers correctly on a program', () => {
10
- const program = new Command();
11
- registerEmbed(program);
12
- const embedCmd = program.commands.find(c => c.name() === 'embed');
13
- assert.ok(embedCmd, 'embed command should be registered');
14
- });
15
-
16
- it('has --truncation flag', () => {
17
- const program = new Command();
18
- registerEmbed(program);
19
- const embedCmd = program.commands.find(c => c.name() === 'embed');
20
- const optionNames = embedCmd.options.map(o => o.long);
21
- assert.ok(optionNames.includes('--truncation'), 'should have --truncation option');
22
- assert.ok(optionNames.includes('--no-truncation'), 'should have --no-truncation option');
23
- });
24
-
25
- it('has --input-type flag', () => {
26
- const program = new Command();
27
- registerEmbed(program);
28
- const embedCmd = program.commands.find(c => c.name() === 'embed');
29
- const optionNames = embedCmd.options.map(o => o.long);
30
- assert.ok(optionNames.includes('--input-type'), 'should have --input-type option');
31
- });
32
-
33
- it('has --output-dtype flag with float default', () => {
34
- const program = new Command();
35
- registerEmbed(program);
36
- const embedCmd = program.commands.find(c => c.name() === 'embed');
37
- const optionNames = embedCmd.options.map(o => o.long);
38
- assert.ok(optionNames.includes('--output-dtype'), 'should have --output-dtype option');
39
- const opt = embedCmd.options.find(o => o.long === '--output-dtype');
40
- assert.equal(opt.defaultValue, 'float');
41
- });
42
- });