toolcraft 0.0.55 → 0.0.57
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/dist/cli.d.ts +1 -0
- package/dist/cli.js +103 -66
- package/package.json +2 -2
package/dist/cli.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface CLIControls {
|
|
|
13
13
|
export interface RunCLIOptions<TServices extends object = Record<string, unknown>> {
|
|
14
14
|
apiVersion?: string;
|
|
15
15
|
approvals?: boolean;
|
|
16
|
+
argv?: readonly string[];
|
|
16
17
|
casing?: Casing;
|
|
17
18
|
controls?: CLIControls;
|
|
18
19
|
fetch?: typeof globalThis.fetch;
|
package/dist/cli.js
CHANGED
|
@@ -1527,6 +1527,37 @@ function resolveOutput(resolvedFlags) {
|
|
|
1527
1527
|
}
|
|
1528
1528
|
return "rich";
|
|
1529
1529
|
}
|
|
1530
|
+
function resolveOutputFromArgv(argv) {
|
|
1531
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
1532
|
+
const token = argv[index] ?? "";
|
|
1533
|
+
if (token === "--json") {
|
|
1534
|
+
return "json";
|
|
1535
|
+
}
|
|
1536
|
+
if (token === "--md" || token === "--markdown") {
|
|
1537
|
+
return "md";
|
|
1538
|
+
}
|
|
1539
|
+
if (token === "--output") {
|
|
1540
|
+
const value = argv[index + 1];
|
|
1541
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
1542
|
+
return value;
|
|
1543
|
+
}
|
|
1544
|
+
if (value === "markdown") {
|
|
1545
|
+
return "md";
|
|
1546
|
+
}
|
|
1547
|
+
continue;
|
|
1548
|
+
}
|
|
1549
|
+
if (token.startsWith("--output=")) {
|
|
1550
|
+
const value = token.slice("--output=".length);
|
|
1551
|
+
if (value === "rich" || value === "md" || value === "json") {
|
|
1552
|
+
return value;
|
|
1553
|
+
}
|
|
1554
|
+
if (value === "markdown") {
|
|
1555
|
+
return "md";
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
return "rich";
|
|
1560
|
+
}
|
|
1530
1561
|
const DESIGN_SYSTEM_OUTPUT_BY_MODE = {
|
|
1531
1562
|
rich: "terminal",
|
|
1532
1563
|
md: "markdown",
|
|
@@ -2893,71 +2924,73 @@ function renderHttpError(error, options) {
|
|
|
2893
2924
|
process.stderr.write(`${formatDebugStack(stack, options.debugStackMode)}\n`);
|
|
2894
2925
|
}
|
|
2895
2926
|
}
|
|
2896
|
-
function handleRunError(error, options) {
|
|
2927
|
+
async function handleRunError(error, options) {
|
|
2897
2928
|
const logger = createLogger();
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
}
|
|
2912
|
-
if (error instanceof Error && error.name === "ToolcraftBugError") {
|
|
2913
|
-
renderCliErrorPattern({
|
|
2914
|
-
kind: "toolcraft-bug",
|
|
2915
|
-
error,
|
|
2916
|
-
debugStackMode: options.debugStackMode
|
|
2917
|
-
});
|
|
2918
|
-
return;
|
|
2919
|
-
}
|
|
2920
|
-
if (error instanceof CommanderError) {
|
|
2921
|
-
process.exitCode = error.exitCode;
|
|
2922
|
-
if (error.code === "commander.helpDisplayed" || error.code === "commander.version") {
|
|
2929
|
+
await withOutputFormat(options.output, async () => {
|
|
2930
|
+
if (error instanceof UserError) {
|
|
2931
|
+
renderCliErrorPattern(options.userErrorPattern === "usage"
|
|
2932
|
+
? {
|
|
2933
|
+
kind: "usage",
|
|
2934
|
+
message: error.message,
|
|
2935
|
+
rootUsageName: options.rootUsageName,
|
|
2936
|
+
commandPath: options.commandPath
|
|
2937
|
+
}
|
|
2938
|
+
: {
|
|
2939
|
+
kind: "runtime-user",
|
|
2940
|
+
message: error.message
|
|
2941
|
+
});
|
|
2923
2942
|
return;
|
|
2924
2943
|
}
|
|
2925
|
-
if (error.
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2944
|
+
if (error instanceof Error && error.name === "ToolcraftBugError") {
|
|
2945
|
+
renderCliErrorPattern({
|
|
2946
|
+
kind: "toolcraft-bug",
|
|
2947
|
+
error,
|
|
2948
|
+
debugStackMode: options.debugStackMode
|
|
2949
|
+
});
|
|
2930
2950
|
return;
|
|
2931
2951
|
}
|
|
2932
|
-
if (error
|
|
2933
|
-
|
|
2934
|
-
|
|
2952
|
+
if (error instanceof CommanderError) {
|
|
2953
|
+
process.exitCode = error.exitCode;
|
|
2954
|
+
if (error.code === "commander.helpDisplayed" || error.code === "commander.version") {
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2957
|
+
if (error.code === "commander.unknownCommand") {
|
|
2958
|
+
logger.error(appendUsagePointer(formatUnknownCommandError(error, options.program, options.argv ?? process.argv), {
|
|
2959
|
+
rootUsageName: options.rootUsageName,
|
|
2960
|
+
commandPath: options.commandPath
|
|
2961
|
+
}));
|
|
2962
|
+
return;
|
|
2963
|
+
}
|
|
2964
|
+
if (error.code === "commander.unknownOption") {
|
|
2965
|
+
const argv = options.argv ?? process.argv;
|
|
2966
|
+
logger.error(appendUsagePointer(formatUnknownOptionError(error, options.program, argv), {
|
|
2967
|
+
rootUsageName: options.rootUsageName,
|
|
2968
|
+
commandPath: options.commandPath.length > 0
|
|
2969
|
+
? options.commandPath
|
|
2970
|
+
: findCurrentCommanderCommandPath(options.program, argv)
|
|
2971
|
+
}));
|
|
2972
|
+
return;
|
|
2973
|
+
}
|
|
2974
|
+
logger.error(appendUsagePointer(formatCommanderErrorMessage(error), {
|
|
2935
2975
|
rootUsageName: options.rootUsageName,
|
|
2936
2976
|
commandPath: options.commandPath.length > 0
|
|
2937
2977
|
? options.commandPath
|
|
2938
|
-
: findCurrentCommanderCommandPath(options.program, argv)
|
|
2978
|
+
: findCurrentCommanderCommandPath(options.program, options.argv ?? process.argv)
|
|
2939
2979
|
}));
|
|
2940
2980
|
return;
|
|
2941
2981
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
}
|
|
2955
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
2956
|
-
renderCliErrorPattern({
|
|
2957
|
-
kind: "unexpected",
|
|
2958
|
-
message,
|
|
2959
|
-
stack: error instanceof Error ? error.stack : undefined,
|
|
2960
|
-
debugStackMode: options.debugStackMode
|
|
2982
|
+
if (isHttpErrorLike(error)) {
|
|
2983
|
+
renderHttpError(error, options);
|
|
2984
|
+
process.exitCode = 1;
|
|
2985
|
+
return;
|
|
2986
|
+
}
|
|
2987
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2988
|
+
renderCliErrorPattern({
|
|
2989
|
+
kind: "unexpected",
|
|
2990
|
+
message,
|
|
2991
|
+
stack: error instanceof Error ? error.stack : undefined,
|
|
2992
|
+
debugStackMode: options.debugStackMode
|
|
2993
|
+
});
|
|
2961
2994
|
});
|
|
2962
2995
|
}
|
|
2963
2996
|
function formatCommanderErrorMessage(error) {
|
|
@@ -3156,15 +3189,16 @@ function configureCommanderSuggestionOutput(command) {
|
|
|
3156
3189
|
}
|
|
3157
3190
|
export async function runCLI(roots, options = {}) {
|
|
3158
3191
|
enableSourceMaps();
|
|
3159
|
-
const
|
|
3192
|
+
const argv = [...(options.argv ?? process.argv)];
|
|
3193
|
+
const normalizedRoot = normalizeRoots(roots, argv);
|
|
3160
3194
|
const root = options.approvals === true ? mergeApprovalsGroup(normalizedRoot) : normalizedRoot;
|
|
3161
3195
|
await resolveMcpProxies(root, { projectRoot: options.projectRoot });
|
|
3162
3196
|
const casing = options.casing ?? "kebab";
|
|
3163
3197
|
const services = (options.services ?? {});
|
|
3164
3198
|
const runtimeOptions = options.humanInLoop ?? {};
|
|
3165
3199
|
const runtimeFetch = options.fetch ?? globalThis.fetch;
|
|
3166
|
-
const version = options.version ?? findEntrypointPackageMetadata(
|
|
3167
|
-
const rootUsageName = options.rootUsageName ?? inferProgramName(
|
|
3200
|
+
const version = options.version ?? findEntrypointPackageMetadata(argv[1])?.version;
|
|
3201
|
+
const rootUsageName = options.rootUsageName ?? inferProgramName(argv);
|
|
3168
3202
|
const controls = resolveCLIControls(options.controls);
|
|
3169
3203
|
const servicesWithBuiltIns = {
|
|
3170
3204
|
...services,
|
|
@@ -3175,8 +3209,8 @@ export async function runCLI(roots, options = {}) {
|
|
|
3175
3209
|
apiVersion: options.apiVersion
|
|
3176
3210
|
};
|
|
3177
3211
|
validateServices(services);
|
|
3178
|
-
if (hasHelpFlag(
|
|
3179
|
-
await renderGeneratedHelp(root,
|
|
3212
|
+
if (hasHelpFlag(argv)) {
|
|
3213
|
+
await renderGeneratedHelp(root, argv, { ...options, version });
|
|
3180
3214
|
return;
|
|
3181
3215
|
}
|
|
3182
3216
|
const program = new CommanderCommand();
|
|
@@ -3217,7 +3251,7 @@ export async function runCLI(roots, options = {}) {
|
|
|
3217
3251
|
addCommanderChild(program, command, isDefaultChild, rootChildNames);
|
|
3218
3252
|
}
|
|
3219
3253
|
configureCommanderSuggestionOutput(program);
|
|
3220
|
-
const unknownCommand = findUnknownCommanderCommand(program,
|
|
3254
|
+
const unknownCommand = findUnknownCommanderCommand(program, argv);
|
|
3221
3255
|
if (unknownCommand !== undefined) {
|
|
3222
3256
|
createLogger().error(appendUsagePointer(formatUnknownCommandMessage(unknownCommand.input, unknownCommand.currentCommand), {
|
|
3223
3257
|
rootUsageName,
|
|
@@ -3227,7 +3261,7 @@ export async function runCLI(roots, options = {}) {
|
|
|
3227
3261
|
return;
|
|
3228
3262
|
}
|
|
3229
3263
|
try {
|
|
3230
|
-
await program.parseAsync(
|
|
3264
|
+
await program.parseAsync(argv);
|
|
3231
3265
|
}
|
|
3232
3266
|
catch (error) {
|
|
3233
3267
|
if (error instanceof ApprovalDeclinedError) {
|
|
@@ -3236,7 +3270,7 @@ export async function runCLI(roots, options = {}) {
|
|
|
3236
3270
|
}
|
|
3237
3271
|
const resolvedFlags = lastActionCommand ? getResolvedFlags(lastActionCommand) : undefined;
|
|
3238
3272
|
const report = await writeErrorReport({
|
|
3239
|
-
argv
|
|
3273
|
+
argv,
|
|
3240
3274
|
command: errorReportContext?.command,
|
|
3241
3275
|
commandPath: errorReportContext?.commandPath ?? resolvedCommandPath,
|
|
3242
3276
|
env: process.env,
|
|
@@ -3250,13 +3284,16 @@ export async function runCLI(roots, options = {}) {
|
|
|
3250
3284
|
if (report !== undefined) {
|
|
3251
3285
|
process.stderr.write(`Saved error report to ${report.displayPath}\n`);
|
|
3252
3286
|
}
|
|
3253
|
-
handleRunError(error, {
|
|
3287
|
+
await handleRunError(error, {
|
|
3254
3288
|
debugStackMode: resolvedFlags !== undefined
|
|
3255
3289
|
? resolveDebugStackMode(resolvedFlags.debug)
|
|
3256
|
-
: getDebugStackModeFromArgv(
|
|
3257
|
-
|
|
3290
|
+
: getDebugStackModeFromArgv(argv),
|
|
3291
|
+
output: resolvedFlags !== undefined
|
|
3292
|
+
? resolveOutput(resolvedFlags)
|
|
3293
|
+
: resolveOutputFromArgv(argv),
|
|
3294
|
+
verbose: resolvedFlags ? Boolean(resolvedFlags.verbose) : argv.includes("--verbose"),
|
|
3258
3295
|
program,
|
|
3259
|
-
argv
|
|
3296
|
+
argv,
|
|
3260
3297
|
rootUsageName,
|
|
3261
3298
|
commandPath: resolvedCommandPath,
|
|
3262
3299
|
userErrorPattern: errorReportContext?.params === undefined ? "usage" : "runtime-user"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"postpack": "node ../../scripts/manage-bundled-workspace-deps.mjs cleanup . toolcraft-design @poe-code/frontmatter @poe-code/agent-mcp-config @poe-code/agent-human-in-loop @poe-code/task-list @poe-code/agent-defs @poe-code/config-mutations @poe-code/process-runner tiny-mcp-client mcp-oauth auth-store"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"toolcraft-schema": "0.0.
|
|
50
|
+
"toolcraft-schema": "0.0.57",
|
|
51
51
|
"commander": "^14.0.3",
|
|
52
52
|
"fast-string-width": "^3.0.2",
|
|
53
53
|
"fast-wrap-ansi": "^0.2.0",
|