Skip to content

Commit bf5a3ea

Browse files
committed
fix: resolve TypeScript CI errors from victor's branch merge
- registry.ts: remove duplicate Command/OptionDef/CommandSpec/defineCommand definitions, import from command.ts; change printHelp param type to NodeJS.WriteStream to accept process.stderr - utils/schema.ts: fix unknown type access on input_schema properties - test files: add missing nonInteractive/async fields to all Config and GlobalFlags objects Made-with: Cursor
1 parent d01c512 commit bf5a3ea

19 files changed

Lines changed: 99 additions & 47 deletions

bun.lock

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/registry.ts

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineCommand } from './command';
1+
import type { Command } from './command';
22
import { CLIError } from './errors/base';
33
import { ExitCode } from './errors/codes';
44

@@ -25,44 +25,7 @@ import fileList from './commands/file/list';
2525
import fileDelete from './commands/file/delete';
2626
import update from './commands/update';
2727

28-
import type { Config } from './config/schema';
29-
import type { GlobalFlags } from './types/flags';
30-
31-
export interface OptionDef {
32-
flag: string;
33-
description: string;
34-
type?: 'string' | 'number' | 'boolean' | 'array';
35-
required?: boolean;
36-
}
37-
38-
export interface Command {
39-
name: string;
40-
description: string;
41-
usage?: string;
42-
options?: OptionDef[];
43-
examples?: string[];
44-
execute(config: Config, flags: GlobalFlags): Promise<void>;
45-
}
46-
47-
export interface CommandSpec {
48-
name: string;
49-
description: string;
50-
usage?: string;
51-
options?: OptionDef[];
52-
examples?: string[];
53-
run(config: Config, flags: GlobalFlags): Promise<void>;
54-
}
55-
56-
export function defineCommand(spec: CommandSpec): Command {
57-
return {
58-
name: spec.name,
59-
description: spec.description,
60-
usage: spec.usage,
61-
options: spec.options,
62-
examples: spec.examples,
63-
execute: spec.run,
64-
};
65-
}
28+
export type { Command, OptionDef } from './command';
6629

6730
interface CommandNode {
6831
command?: Command;
@@ -145,7 +108,7 @@ class CommandRegistry {
145108
* Defaults to stdout; pass stderr (or a non-TTY stream) to keep stdout
146109
* clean for piped / JSON output.
147110
*/
148-
printHelp(commandPath: string[], out: typeof process.stdout = process.stdout): void {
111+
printHelp(commandPath: string[], out: NodeJS.WriteStream = process.stdout): void {
149112
if (commandPath.length === 0) {
150113
this.printRootHelp(out);
151114
return;
@@ -173,7 +136,7 @@ class CommandRegistry {
173136
out.write('\n');
174137
}
175138

176-
private printRootHelp(out: typeof process.stdout): void {
139+
private printRootHelp(out: NodeJS.WriteStream): void {
177140
out.write(`
178141
__ __ ___ _ _ ___ __ __ _ __ __
179142
| \\/ |_ _| \\ | |_ _| \\/ | / \\ \\ \\/ /
@@ -219,7 +182,7 @@ Getting Help:
219182
`);
220183
}
221184

222-
private printCommandHelp(cmd: Command, out: typeof process.stdout): void {
185+
private printCommandHelp(cmd: Command, out: NodeJS.WriteStream): void {
223186
out.write(`\n${cmd.description}\n`);
224187
if (cmd.usage) out.write(`Usage: ${cmd.usage}\n`);
225188
if (cmd.options && cmd.options.length > 0) {
@@ -241,7 +204,7 @@ Getting Help:
241204
out.write(`Run 'minimax --help' for the full list.\n`);
242205
}
243206

244-
private printChildren(node: CommandNode, prefix: string, out: typeof process.stdout): void {
207+
private printChildren(node: CommandNode, prefix: string, out: NodeJS.WriteStream): void {
245208
for (const [name, child] of node.children) {
246209
if (child.command) {
247210
out.write(` ${prefix} ${name.padEnd(12)} ${child.command.description}\n`);

src/utils/schema.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ export function generateToolSchema(cmd: Command): Record<string, unknown> {
6666
propSchema.type = effectiveType;
6767
}
6868

69-
(schema.input_schema as Record<string, unknown>).properties[name] = propSchema;
69+
const inputSchema = schema.input_schema as Record<string, unknown>;
70+
(inputSchema.properties as Record<string, unknown>)[name] = propSchema;
7071

7172
if (opt.required) {
72-
(schema.input_schema.required as string[]).push(name);
73+
(inputSchema.required as string[]).push(name);
7374
}
7475
}
7576
}

test/auth/resolver.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function makeConfig(overrides: Partial<Config> = {}): Config {
1313
noColor: false,
1414
yes: false,
1515
dryRun: false,
16+
nonInteractive: false,
17+
async: false,
1618
...overrides,
1719
};
1820
}

test/client/http.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ function makeConfig(baseUrl: string): Config {
1515
noColor: false,
1616
yes: false,
1717
dryRun: false,
18+
nonInteractive: false,
19+
async: false,
1820
};
1921
}
2022

test/commands/auth/login.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ describe('auth login command', () => {
1818
noColor: true,
1919
yes: false,
2020
dryRun: false,
21+
nonInteractive: false,
22+
async: false,
2123
};
2224

2325
await expect(
@@ -29,6 +31,8 @@ describe('auth login command', () => {
2931
yes: false,
3032
dryRun: false,
3133
help: false,
34+
nonInteractive: false,
35+
async: false,
3236
}),
3337
).rejects.toThrow('--api-key is required');
3438
});

test/commands/auth/logout.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ describe('auth logout command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: true,
20+
nonInteractive: false,
21+
async: false,
2022
};
2123

2224
const originalLog = console.log;
@@ -31,6 +33,8 @@ describe('auth logout command', () => {
3133
yes: false,
3234
dryRun: true,
3335
help: false,
36+
nonInteractive: false,
37+
async: false,
3438
});
3539

3640
expect(output).toContain('No changes made');

test/commands/auth/refresh.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ describe('auth refresh command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: false,
20+
nonInteractive: false,
21+
async: false,
2022
};
2123

2224
await expect(
@@ -27,6 +29,8 @@ describe('auth refresh command', () => {
2729
yes: false,
2830
dryRun: false,
2931
help: false,
32+
nonInteractive: false,
33+
async: false,
3034
}),
3135
).rejects.toThrow('not authenticated via OAuth');
3236
});

test/commands/auth/status.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ describe('auth status command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: false,
20+
nonInteractive: false,
21+
async: false,
2022
};
2123

2224
const originalLog = console.log;
@@ -31,6 +33,8 @@ describe('auth status command', () => {
3133
yes: false,
3234
dryRun: false,
3335
help: false,
36+
nonInteractive: false,
37+
async: false,
3438
});
3539

3640
const parsed = JSON.parse(output);

test/commands/config/set.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ describe('config set command', () => {
1717
noColor: true,
1818
yes: false,
1919
dryRun: false,
20+
nonInteractive: false,
21+
async: false,
2022
};
2123

2224
await expect(
@@ -27,6 +29,8 @@ describe('config set command', () => {
2729
yes: false,
2830
dryRun: false,
2931
help: false,
32+
nonInteractive: false,
33+
async: false,
3034
}),
3135
).rejects.toThrow('--key and --value are required');
3236
});
@@ -42,6 +46,8 @@ describe('config set command', () => {
4246
noColor: true,
4347
yes: false,
4448
dryRun: false,
49+
nonInteractive: false,
50+
async: false,
4551
};
4652

4753
await expect(
@@ -54,6 +60,8 @@ describe('config set command', () => {
5460
yes: false,
5561
dryRun: false,
5662
help: false,
63+
nonInteractive: false,
64+
async: false,
5765
}),
5866
).rejects.toThrow('Invalid config key');
5967
});

0 commit comments

Comments
 (0)