@midscene/shared 1.6.3-beta-20260403070857.0 → 1.6.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.
|
@@ -89,7 +89,7 @@ function printHelp(scriptName, commands, version) {
|
|
|
89
89
|
}
|
|
90
90
|
console.log(`\nUsage: ${scriptName} <command> [options]\n`);
|
|
91
91
|
console.log('Commands:');
|
|
92
|
-
for (const { name, def } of commands)console.log(` ${name.padEnd(30)} ${def.description}`);
|
|
92
|
+
for (const { name, def } of commands.filter((command)=>!command.hidden))console.log(` ${name.padEnd(30)} ${def.description}`);
|
|
93
93
|
console.log(` ${'version'.padEnd(30)} Show CLI version`);
|
|
94
94
|
console.log(`\nRun "${scriptName} <command> --help" for more info.`);
|
|
95
95
|
}
|
|
@@ -105,6 +105,18 @@ async function runToolsCLI(tools, scriptName, options) {
|
|
|
105
105
|
name: removePrefix(def.name, options?.stripPrefix).toLowerCase(),
|
|
106
106
|
def
|
|
107
107
|
}));
|
|
108
|
+
if (options?.extraCommands?.length) commands.push(...options.extraCommands.flatMap((cmd)=>[
|
|
109
|
+
{
|
|
110
|
+
name: cmd.name.toLowerCase(),
|
|
111
|
+
def: cmd.def,
|
|
112
|
+
hidden: cmd.hidden
|
|
113
|
+
},
|
|
114
|
+
...(cmd.aliases ?? []).map((alias)=>({
|
|
115
|
+
name: alias.toLowerCase(),
|
|
116
|
+
def: cmd.def,
|
|
117
|
+
hidden: true
|
|
118
|
+
}))
|
|
119
|
+
]));
|
|
108
120
|
const cliVersion = options?.version;
|
|
109
121
|
const [commandName, ...restArgs] = rawArgs;
|
|
110
122
|
if (!commandName || '--help' === commandName || '-h' === commandName) {
|
|
@@ -131,7 +131,7 @@ function printHelp(scriptName, commands, version) {
|
|
|
131
131
|
}
|
|
132
132
|
console.log(`\nUsage: ${scriptName} <command> [options]\n`);
|
|
133
133
|
console.log('Commands:');
|
|
134
|
-
for (const { name, def } of commands)console.log(` ${name.padEnd(30)} ${def.description}`);
|
|
134
|
+
for (const { name, def } of commands.filter((command)=>!command.hidden))console.log(` ${name.padEnd(30)} ${def.description}`);
|
|
135
135
|
console.log(` ${'version'.padEnd(30)} Show CLI version`);
|
|
136
136
|
console.log(`\nRun "${scriptName} <command> --help" for more info.`);
|
|
137
137
|
}
|
|
@@ -147,6 +147,18 @@ async function runToolsCLI(tools, scriptName, options) {
|
|
|
147
147
|
name: removePrefix(def.name, options?.stripPrefix).toLowerCase(),
|
|
148
148
|
def
|
|
149
149
|
}));
|
|
150
|
+
if (options?.extraCommands?.length) commands.push(...options.extraCommands.flatMap((cmd)=>[
|
|
151
|
+
{
|
|
152
|
+
name: cmd.name.toLowerCase(),
|
|
153
|
+
def: cmd.def,
|
|
154
|
+
hidden: cmd.hidden
|
|
155
|
+
},
|
|
156
|
+
...(cmd.aliases ?? []).map((alias)=>({
|
|
157
|
+
name: alias.toLowerCase(),
|
|
158
|
+
def: cmd.def,
|
|
159
|
+
hidden: true
|
|
160
|
+
}))
|
|
161
|
+
]));
|
|
150
162
|
const cliVersion = options?.version;
|
|
151
163
|
const [commandName, ...restArgs] = rawArgs;
|
|
152
164
|
if (!commandName || '--help' === commandName || '-h' === commandName) {
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { BaseMidsceneTools } from '../mcp/base-tools';
|
|
2
|
+
import type { ToolDefinition } from '../mcp/types';
|
|
3
|
+
export interface CLIExtraCommand {
|
|
4
|
+
name: string;
|
|
5
|
+
def: ToolDefinition;
|
|
6
|
+
aliases?: string[];
|
|
7
|
+
hidden?: boolean;
|
|
8
|
+
}
|
|
2
9
|
export interface CLIRunnerOptions {
|
|
3
10
|
stripPrefix?: string;
|
|
4
11
|
argv?: string[];
|
|
5
12
|
version?: string;
|
|
13
|
+
extraCommands?: CLIExtraCommand[];
|
|
6
14
|
}
|
|
7
15
|
export declare class CLIError extends Error {
|
|
8
16
|
exitCode: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { runToolsCLI, CLIError, parseValue, parseCliArgs, removePrefix, } from './cli-runner';
|
|
2
|
-
export type { CLIRunnerOptions } from './cli-runner';
|
|
2
|
+
export type { CLIRunnerOptions, CLIExtraCommand } from './cli-runner';
|
package/package.json
CHANGED
package/src/cli/cli-runner.ts
CHANGED
|
@@ -15,12 +15,21 @@ const debug = getDebug('cli-runner');
|
|
|
15
15
|
interface CLICommand {
|
|
16
16
|
name: string;
|
|
17
17
|
def: ToolDefinition;
|
|
18
|
+
hidden?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CLIExtraCommand {
|
|
22
|
+
name: string;
|
|
23
|
+
def: ToolDefinition;
|
|
24
|
+
aliases?: string[];
|
|
25
|
+
hidden?: boolean;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
export interface CLIRunnerOptions {
|
|
21
29
|
stripPrefix?: string;
|
|
22
30
|
argv?: string[];
|
|
23
31
|
version?: string;
|
|
32
|
+
extraCommands?: CLIExtraCommand[];
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
export class CLIError extends Error {
|
|
@@ -142,7 +151,7 @@ function printHelp(
|
|
|
142
151
|
}
|
|
143
152
|
console.log(`\nUsage: ${scriptName} <command> [options]\n`);
|
|
144
153
|
console.log('Commands:');
|
|
145
|
-
for (const { name, def } of commands) {
|
|
154
|
+
for (const { name, def } of commands.filter((command) => !command.hidden)) {
|
|
146
155
|
console.log(` ${name.padEnd(30)} ${def.description}`);
|
|
147
156
|
}
|
|
148
157
|
console.log(` ${'version'.padEnd(30)} Show CLI version`);
|
|
@@ -169,6 +178,22 @@ export async function runToolsCLI(
|
|
|
169
178
|
name: removePrefix(def.name, options?.stripPrefix).toLowerCase(),
|
|
170
179
|
def,
|
|
171
180
|
}));
|
|
181
|
+
if (options?.extraCommands?.length) {
|
|
182
|
+
commands.push(
|
|
183
|
+
...options.extraCommands.flatMap((cmd) => [
|
|
184
|
+
{
|
|
185
|
+
name: cmd.name.toLowerCase(),
|
|
186
|
+
def: cmd.def,
|
|
187
|
+
hidden: cmd.hidden,
|
|
188
|
+
},
|
|
189
|
+
...(cmd.aliases ?? []).map((alias) => ({
|
|
190
|
+
name: alias.toLowerCase(),
|
|
191
|
+
def: cmd.def,
|
|
192
|
+
hidden: true,
|
|
193
|
+
})),
|
|
194
|
+
]),
|
|
195
|
+
);
|
|
196
|
+
}
|
|
172
197
|
const cliVersion = options?.version;
|
|
173
198
|
|
|
174
199
|
const [commandName, ...restArgs] = rawArgs;
|
package/src/cli/index.ts
CHANGED