@silkweave/cli 1.3.1 → 1.4.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.
- package/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-check.log +3 -5
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-prepack.log +6 -6
- package/README.md +3 -3
- package/build/index.js +38 -36
- package/build/index.js.map +1 -1
- package/package.json +3 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @silkweave/cli@1.3.
|
|
3
|
+
> @silkweave/cli@1.3.2 build /Users/atomic/projects/ai/silkweave/packages/cli
|
|
4
4
|
> tsup
|
|
5
5
|
|
|
6
6
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
[34mCLI[39m Target: es2022
|
|
11
11
|
[34mCLI[39m Cleaning output folder
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mESM[39m [1mbuild/index.js [22m[32m3.
|
|
13
|
+
[32mESM[39m [1mbuild/index.js [22m[32m3.23 KB[39m
|
|
14
14
|
[32mESM[39m [1mbuild/index.js.map [22m[32m6.04 KB[39m
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 8ms
|
|
16
16
|
DTS Build start
|
|
17
|
-
DTS ⚡️ Build success in
|
|
17
|
+
DTS ⚡️ Build success in 451ms
|
|
18
18
|
DTS build/index.d.ts 103.00 B
|
package/.turbo/turbo-check.log
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
> @silkweave/cli@1.3.
|
|
2
|
+
> @silkweave/cli@1.3.2 check /Users/atomic/projects/ai/silkweave/packages/cli
|
|
3
3
|
> pnpm lint && pnpm typecheck
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @silkweave/cli@1.3.
|
|
6
|
+
> @silkweave/cli@1.3.2 lint /Users/atomic/projects/ai/silkweave/packages/cli
|
|
7
7
|
> eslint
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
> @silkweave/cli@1.3.
|
|
10
|
+
> @silkweave/cli@1.3.2 typecheck /Users/atomic/projects/ai/silkweave/packages/cli
|
|
11
11
|
> tsc --noEmit
|
|
12
12
|
|
|
13
|
-
ELIFECYCLE Command failed.
|
|
14
|
-
ELIFECYCLE Command failed.
|
package/.turbo/turbo-lint.log
CHANGED
package/.turbo/turbo-prepack.log
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> @silkweave/cli@1.
|
|
3
|
+
> @silkweave/cli@1.4.0 prepack /Users/atomic/projects/ai/silkweave/packages/cli
|
|
4
4
|
> pnpm clean && pnpm build
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
> @silkweave/cli@1.
|
|
7
|
+
> @silkweave/cli@1.4.0 clean /Users/atomic/projects/ai/silkweave/packages/cli
|
|
8
8
|
> rimraf build
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
> @silkweave/cli@1.
|
|
11
|
+
> @silkweave/cli@1.4.0 build /Users/atomic/projects/ai/silkweave/packages/cli
|
|
12
12
|
> tsup
|
|
13
13
|
|
|
14
14
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
[34mCLI[39m Target: es2022
|
|
19
19
|
[34mCLI[39m Cleaning output folder
|
|
20
20
|
[34mESM[39m Build start
|
|
21
|
-
[32mESM[39m [1mbuild/index.js [22m[32m3.
|
|
21
|
+
[32mESM[39m [1mbuild/index.js [22m[32m3.23 KB[39m
|
|
22
22
|
[32mESM[39m [1mbuild/index.js.map [22m[32m6.04 KB[39m
|
|
23
|
-
[32mESM[39m ⚡️ Build success in
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 7ms
|
|
24
24
|
DTS Build start
|
|
25
|
-
DTS ⚡️ Build success in
|
|
25
|
+
DTS ⚡️ Build success in 447ms
|
|
26
26
|
DTS build/index.d.ts 103.00 B
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @silkweave/cli
|
|
2
2
|
|
|
3
|
-
CLI adapter for [Silkweave](https://github.com/silkweave/silkweave)
|
|
3
|
+
CLI adapter for [Silkweave](https://github.com/silkweave/silkweave) - turn your actions into a complete command-line application with help text, option parsing, and styled terminal output via clack.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -63,5 +63,5 @@ $ mytool deploy production --dry-run
|
|
|
63
63
|
|
|
64
64
|
## See Also
|
|
65
65
|
|
|
66
|
-
- [Silkweave README](https://github.com/silkweave/silkweave)
|
|
67
|
-
- [`@silkweave/core`](https://www.npmjs.com/package/@silkweave/core)
|
|
66
|
+
- [Silkweave README](https://github.com/silkweave/silkweave) - Full documentation
|
|
67
|
+
- [`@silkweave/core`](https://www.npmjs.com/package/@silkweave/core) - Core library
|
package/build/index.js
CHANGED
|
@@ -8,23 +8,19 @@ import z from "zod";
|
|
|
8
8
|
function handleCLIError(error) {
|
|
9
9
|
if (error instanceof SilkweaveError) {
|
|
10
10
|
log.error(`[${error.code}] ${error.message}`);
|
|
11
|
-
process.exitCode = 1;
|
|
12
11
|
} else if (error instanceof z.ZodError) {
|
|
13
12
|
log.error("Validation Error", { withGuide: false });
|
|
14
13
|
for (const issue of error.issues) {
|
|
15
14
|
log.error(`${issue.path}: ${issue.message}`);
|
|
16
15
|
}
|
|
17
|
-
process.exitCode = 1;
|
|
18
16
|
} else if (error instanceof Error) {
|
|
19
17
|
log.error(error.message);
|
|
20
|
-
process.exitCode = 1;
|
|
21
18
|
} else if (typeof error === "string") {
|
|
22
19
|
log.error(error);
|
|
23
|
-
process.exitCode = 1;
|
|
24
20
|
} else {
|
|
25
21
|
log.error(JSON.stringify(error));
|
|
26
|
-
process.exitCode = 1;
|
|
27
22
|
}
|
|
23
|
+
process.exitCode = 1;
|
|
28
24
|
}
|
|
29
25
|
function parseCLIInput(action, args) {
|
|
30
26
|
const tmpArgs = args.slice(0, -1);
|
|
@@ -39,6 +35,42 @@ function parseCLIInput(action, args) {
|
|
|
39
35
|
}
|
|
40
36
|
return data;
|
|
41
37
|
}
|
|
38
|
+
function addCliOption(command, key, type, defaultValue, isArgument) {
|
|
39
|
+
const description = type.description;
|
|
40
|
+
if (isArgument) {
|
|
41
|
+
command.argument(`[${camelCase(key)}]`, description, defaultValue);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const flag = kebabCase(key);
|
|
45
|
+
if (type instanceof z.ZodBoolean) {
|
|
46
|
+
command.option(`--${flag}`, description, defaultValue);
|
|
47
|
+
command.option(`--no-${flag}`);
|
|
48
|
+
} else if (type instanceof z.ZodNumber) {
|
|
49
|
+
command.option(`--${flag} <number>`, description, defaultValue);
|
|
50
|
+
} else if (type instanceof z.ZodString || type instanceof z.ZodEnum) {
|
|
51
|
+
command.option(`--${flag} <string>`, description, defaultValue);
|
|
52
|
+
} else if (type instanceof z.ZodObject || type instanceof z.ZodRecord || type instanceof z.ZodArray) {
|
|
53
|
+
command.option(`--${flag} <json>`, description ?? "", JSON.parse, defaultValue);
|
|
54
|
+
} else {
|
|
55
|
+
throw new Error(`Invalid zod type: ${type.def.type}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function registerCommand(program, action, options, context) {
|
|
59
|
+
const command = program.command(kebabCase(action.name)).description(action.description);
|
|
60
|
+
const shape = action.input.shape;
|
|
61
|
+
for (const key of Object.keys(shape)) {
|
|
62
|
+
const [type, { defaultValue }] = unwrap(shape[key]);
|
|
63
|
+
addCliOption(command, key, type, defaultValue, action.args?.includes(key) ?? false);
|
|
64
|
+
}
|
|
65
|
+
command.action((...args) => {
|
|
66
|
+
const logger = createCLILogger();
|
|
67
|
+
const input = parseCLIInput(action, args);
|
|
68
|
+
intro(`${options.name} - ${action.name}`);
|
|
69
|
+
action.run(input, context.fork({ logger, command })).then((result) => {
|
|
70
|
+
logger.info(JSON.stringify(result, null, 2));
|
|
71
|
+
}).catch(handleCLIError);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
42
74
|
var cli = () => {
|
|
43
75
|
return (options, baseContext) => {
|
|
44
76
|
const context = baseContext.fork({ adapter: "cli" });
|
|
@@ -47,37 +79,7 @@ var cli = () => {
|
|
|
47
79
|
context,
|
|
48
80
|
start: async (actions) => {
|
|
49
81
|
for (const action of actions) {
|
|
50
|
-
|
|
51
|
-
const command = program.command(name).description(action.description);
|
|
52
|
-
const shape = action.input.shape;
|
|
53
|
-
const keys = Object.keys(shape);
|
|
54
|
-
for (const key of keys) {
|
|
55
|
-
const [type, { defaultValue }] = unwrap(shape[key]);
|
|
56
|
-
const description = type.description;
|
|
57
|
-
const isArgument = action.args?.includes(key);
|
|
58
|
-
if (isArgument) {
|
|
59
|
-
command.argument(`[${camelCase(key)}]`, description, defaultValue);
|
|
60
|
-
} else if (type instanceof z.ZodBoolean) {
|
|
61
|
-
command.option(`--${kebabCase(key)}`, description, defaultValue);
|
|
62
|
-
command.option(`--no-${kebabCase(key)}`);
|
|
63
|
-
} else if (type instanceof z.ZodNumber) {
|
|
64
|
-
command.option(`--${kebabCase(key)} <number>`, description, defaultValue);
|
|
65
|
-
} else if (type instanceof z.ZodString || type instanceof z.ZodEnum) {
|
|
66
|
-
command.option(`--${kebabCase(key)} <string>`, description, defaultValue);
|
|
67
|
-
} else if (type instanceof z.ZodObject || type instanceof z.ZodRecord || type instanceof z.ZodArray) {
|
|
68
|
-
command.option(`--${kebabCase(key)} <json>`, description ?? "", JSON.parse, defaultValue);
|
|
69
|
-
} else {
|
|
70
|
-
throw new Error(`Invalid zod type: ${type.def.type}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
command.action((...args) => {
|
|
74
|
-
const logger = createCLILogger();
|
|
75
|
-
const input = parseCLIInput(action, args);
|
|
76
|
-
intro(`${options.name} - ${action.name}`);
|
|
77
|
-
action.run(input, context.fork({ logger, command })).then((result) => {
|
|
78
|
-
logger.info(JSON.stringify(result, null, 2));
|
|
79
|
-
}).catch(handleCLIError);
|
|
80
|
-
});
|
|
82
|
+
registerCommand(program, action, options, context);
|
|
81
83
|
}
|
|
82
84
|
program.parse();
|
|
83
85
|
},
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapter/cli.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { intro, log } from '@clack/prompts'\nimport { Action, AdapterFactory, SilkweaveError, unwrap } from '@silkweave/core'\nimport { createCLILogger } from '@silkweave/logger'\nimport { camelCase, kebabCase } from 'change-case'\nimport { Command } from 'commander'\nimport z from 'zod'\n\nfunction handleCLIError(error: unknown) {\n if (error instanceof SilkweaveError) {\n log.error(`[${error.code}] ${error.message}`)\n
|
|
1
|
+
{"version":3,"sources":["../src/adapter/cli.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { intro, log } from '@clack/prompts'\nimport { Action, AdapterFactory, SilkweaveError, SilkweaveOptions, unwrap } from '@silkweave/core'\nimport { createCLILogger } from '@silkweave/logger'\nimport { SilkweaveContext } from '@silkweave/core'\nimport { camelCase, kebabCase } from 'change-case'\nimport { Command } from 'commander'\nimport z from 'zod'\n\nfunction handleCLIError(error: unknown) {\n if (error instanceof SilkweaveError) {\n log.error(`[${error.code}] ${error.message}`)\n } else if (error instanceof z.ZodError) {\n log.error('Validation Error', { withGuide: false })\n for (const issue of error.issues) {\n log.error(`${issue.path}: ${issue.message}`)\n }\n } else if (error instanceof Error) {\n log.error(error.message)\n } else if (typeof error === 'string') {\n log.error(error)\n } else {\n log.error(JSON.stringify(error))\n }\n process.exitCode = 1\n}\n\nfunction parseCLIInput(action: Action, args: any[]) {\n const tmpArgs = args.slice(0, -1)\n const rawInput = tmpArgs.pop()\n action.args?.forEach((k, index) => { rawInput[k] = args[index] })\n const { error, data } = action.input.safeParse(rawInput)\n if (error || !data) {\n handleCLIError(error)\n process.exit()\n }\n\n return data\n}\n\nfunction addCliOption(command: Command, key: string, type: z.ZodType, defaultValue: any, isArgument: boolean) {\n const description = type.description\n if (isArgument) {\n command.argument(`[${camelCase(key)}]`, description, defaultValue)\n return\n }\n const flag = kebabCase(key)\n if (type instanceof z.ZodBoolean) {\n command.option(`--${flag}`, description, defaultValue)\n command.option(`--no-${flag}`)\n } else if (type instanceof z.ZodNumber) {\n command.option(`--${flag} <number>`, description, defaultValue)\n } else if (type instanceof z.ZodString || type instanceof z.ZodEnum) {\n command.option(`--${flag} <string>`, description, defaultValue)\n } else if (type instanceof z.ZodObject || type instanceof z.ZodRecord || type instanceof z.ZodArray) {\n command.option(`--${flag} <json>`, description ?? '', JSON.parse, defaultValue)\n } else {\n throw new Error(`Invalid zod type: ${type.def.type}`)\n }\n}\n\nfunction registerCommand(program: Command, action: Action, options: SilkweaveOptions, context: SilkweaveContext) {\n const command = program.command(kebabCase(action.name)).description(action.description)\n const shape = action.input.shape\n for (const key of Object.keys(shape)) {\n const [type, { defaultValue }] = unwrap(shape[key])\n addCliOption(command, key, type, defaultValue, action.args?.includes(key) ?? false)\n }\n command.action((...args) => {\n const logger = createCLILogger()\n const input = parseCLIInput(action, args)\n intro(`${options.name} - ${action.name}`)\n action.run(input, context.fork({ logger, command })).then((result) => {\n logger.info(JSON.stringify(result, null, 2))\n }).catch(handleCLIError)\n })\n}\n\nexport const cli: AdapterFactory = () => {\n return (options, baseContext) => {\n const context = baseContext.fork({ adapter: 'cli' })\n const program = new Command()\n .name(options.name)\n .description(options.description)\n .version(options.version)\n\n return {\n context,\n start: async (actions) => {\n for (const action of actions) {\n registerCommand(program, action, options, context)\n }\n program.parse()\n },\n stop: async () => { }\n }\n }\n}\n"],"mappings":";AACA,SAAS,OAAO,WAAW;AAC3B,SAAiC,gBAAkC,cAAc;AACjF,SAAS,uBAAuB;AAEhC,SAAS,WAAW,iBAAiB;AACrC,SAAS,eAAe;AACxB,OAAO,OAAO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E,SAAS,MAAM,CAAC;AACnD,UAAM,UAAU,IAAI,QAAQ,EACzB,KAAK,QAAQ,IAAI,EACjB,YAAY,QAAQ,WAAW,EAC/B,QAAQ,QAAQ,OAAO;AAE1B,WAAO;AAAA,MACL;AAAA,MACA,OAAO,OAAO,YAAY;AACxB,mBAAW,UAAU,SAAS;AAC5B,0BAAgB,SAAS,QAAQ,SAAS,OAAO;AAAA,QACnD;AACA,gBAAQ,MAAM;AAAA,MAChB;AAAA,MACA,MAAM,YAAY;AAAA,MAAE;AAAA,IACtB;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silkweave/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Silkweave CLI Adapter",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"change-case": "^5.4.4",
|
|
16
16
|
"commander": "^13.1.0",
|
|
17
17
|
"zod": "^4.3.6",
|
|
18
|
-
"@silkweave/core": "1.
|
|
19
|
-
"@silkweave/logger": "1.
|
|
18
|
+
"@silkweave/core": "1.4.0",
|
|
19
|
+
"@silkweave/logger": "1.4.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@eslint/js": "^10.0.1",
|