@aigne/afs-cli 1.11.0-beta.6 → 1.11.0-beta.8
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/_virtual/rolldown_runtime.mjs +7 -0
- package/dist/cli.cjs +27 -353
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.mts +2 -1
- package/dist/cli.mjs +28 -353
- package/dist/cli.mjs.map +1 -1
- package/dist/config/afs-loader.cjs +567 -0
- package/dist/config/afs-loader.d.cts +19 -0
- package/dist/config/afs-loader.d.cts.map +1 -0
- package/dist/config/afs-loader.d.mts +19 -0
- package/dist/config/afs-loader.d.mts.map +1 -0
- package/dist/config/afs-loader.mjs +565 -0
- package/dist/config/afs-loader.mjs.map +1 -0
- package/dist/config/loader.cjs +28 -11
- package/dist/config/loader.mjs +28 -11
- package/dist/config/loader.mjs.map +1 -1
- package/dist/config/mount-commands.cjs +208 -0
- package/dist/config/mount-commands.d.cts +14 -0
- package/dist/config/mount-commands.d.cts.map +1 -0
- package/dist/config/mount-commands.d.mts +14 -0
- package/dist/config/mount-commands.d.mts.map +1 -0
- package/dist/config/mount-commands.mjs +203 -0
- package/dist/config/mount-commands.mjs.map +1 -0
- package/dist/config/schema.cjs +10 -2
- package/dist/config/schema.mjs +10 -2
- package/dist/config/schema.mjs.map +1 -1
- package/dist/core/commands/delete.cjs +41 -0
- package/dist/core/commands/delete.d.cts +18 -0
- package/dist/core/commands/delete.d.cts.map +1 -0
- package/dist/core/commands/delete.d.mts +18 -0
- package/dist/core/commands/delete.d.mts.map +1 -0
- package/dist/core/commands/delete.mjs +42 -0
- package/dist/core/commands/delete.mjs.map +1 -0
- package/dist/core/commands/exec.cjs +98 -0
- package/dist/core/commands/exec.d.cts +26 -0
- package/dist/core/commands/exec.d.cts.map +1 -0
- package/dist/core/commands/exec.d.mts +26 -0
- package/dist/core/commands/exec.d.mts.map +1 -0
- package/dist/core/commands/exec.mjs +99 -0
- package/dist/core/commands/exec.mjs.map +1 -0
- package/dist/core/commands/explain.cjs +254 -0
- package/dist/core/commands/explain.d.cts +25 -0
- package/dist/core/commands/explain.d.cts.map +1 -0
- package/dist/core/commands/explain.d.mts +25 -0
- package/dist/core/commands/explain.d.mts.map +1 -0
- package/dist/core/commands/explain.mjs +255 -0
- package/dist/core/commands/explain.mjs.map +1 -0
- package/dist/core/commands/explore.cjs +30 -0
- package/dist/core/commands/explore.d.mts +2 -0
- package/dist/core/commands/explore.mjs +31 -0
- package/dist/core/commands/explore.mjs.map +1 -0
- package/dist/core/commands/index.cjs +36 -0
- package/dist/core/commands/index.d.cts +21 -0
- package/dist/core/commands/index.d.cts.map +1 -0
- package/dist/core/commands/index.d.mts +24 -0
- package/dist/core/commands/index.d.mts.map +1 -0
- package/dist/core/commands/index.mjs +37 -0
- package/dist/core/commands/index.mjs.map +1 -0
- package/dist/core/commands/ls.cjs +57 -0
- package/dist/core/commands/ls.d.cts +21 -0
- package/dist/core/commands/ls.d.cts.map +1 -0
- package/dist/core/commands/ls.d.mts +21 -0
- package/dist/core/commands/ls.d.mts.map +1 -0
- package/dist/core/commands/ls.mjs +58 -0
- package/dist/core/commands/ls.mjs.map +1 -0
- package/dist/core/commands/mount.cjs +222 -0
- package/dist/core/commands/mount.d.cts +35 -0
- package/dist/core/commands/mount.d.cts.map +1 -0
- package/dist/core/commands/mount.d.mts +35 -0
- package/dist/core/commands/mount.d.mts.map +1 -0
- package/dist/core/commands/mount.mjs +223 -0
- package/dist/core/commands/mount.mjs.map +1 -0
- package/dist/core/commands/read.cjs +48 -0
- package/dist/core/commands/read.d.cts +17 -0
- package/dist/core/commands/read.d.cts.map +1 -0
- package/dist/core/commands/read.d.mts +17 -0
- package/dist/core/commands/read.d.mts.map +1 -0
- package/dist/core/commands/read.mjs +49 -0
- package/dist/core/commands/read.mjs.map +1 -0
- package/dist/core/commands/search.cjs +40 -0
- package/dist/core/commands/search.d.mts +2 -0
- package/dist/core/commands/search.mjs +41 -0
- package/dist/core/commands/search.mjs.map +1 -0
- package/dist/core/commands/serve.cjs +267 -0
- package/dist/core/commands/serve.d.mts +2 -0
- package/dist/core/commands/serve.mjs +267 -0
- package/dist/core/commands/serve.mjs.map +1 -0
- package/dist/core/commands/stat.cjs +53 -0
- package/dist/core/commands/stat.d.cts +17 -0
- package/dist/core/commands/stat.d.cts.map +1 -0
- package/dist/core/commands/stat.d.mts +17 -0
- package/dist/core/commands/stat.d.mts.map +1 -0
- package/dist/core/commands/stat.mjs +54 -0
- package/dist/core/commands/stat.mjs.map +1 -0
- package/dist/core/commands/types.cjs +18 -0
- package/dist/core/commands/types.d.cts +54 -0
- package/dist/core/commands/types.d.cts.map +1 -0
- package/dist/core/commands/types.d.mts +54 -0
- package/dist/core/commands/types.d.mts.map +1 -0
- package/dist/core/commands/types.mjs +19 -0
- package/dist/core/commands/types.mjs.map +1 -0
- package/dist/core/commands/write.cjs +70 -0
- package/dist/core/commands/write.d.cts +20 -0
- package/dist/core/commands/write.d.cts.map +1 -0
- package/dist/core/commands/write.d.mts +20 -0
- package/dist/core/commands/write.d.mts.map +1 -0
- package/dist/core/commands/write.mjs +71 -0
- package/dist/core/commands/write.mjs.map +1 -0
- package/dist/core/executor/index.cjs +196 -0
- package/dist/core/executor/index.d.cts +77 -0
- package/dist/core/executor/index.d.cts.map +1 -0
- package/dist/core/executor/index.d.mts +77 -0
- package/dist/core/executor/index.d.mts.map +1 -0
- package/dist/core/executor/index.mjs +195 -0
- package/dist/core/executor/index.mjs.map +1 -0
- package/dist/core/formatters/delete.cjs +37 -0
- package/dist/core/formatters/delete.d.cts +18 -0
- package/dist/core/formatters/delete.d.cts.map +1 -0
- package/dist/core/formatters/delete.d.mts +18 -0
- package/dist/core/formatters/delete.d.mts.map +1 -0
- package/dist/core/formatters/delete.mjs +37 -0
- package/dist/core/formatters/delete.mjs.map +1 -0
- package/dist/core/formatters/exec.cjs +60 -0
- package/dist/core/formatters/exec.d.cts +18 -0
- package/dist/core/formatters/exec.d.cts.map +1 -0
- package/dist/core/formatters/exec.d.mts +18 -0
- package/dist/core/formatters/exec.d.mts.map +1 -0
- package/dist/core/formatters/exec.mjs +60 -0
- package/dist/core/formatters/exec.mjs.map +1 -0
- package/dist/core/formatters/explain.cjs +97 -0
- package/dist/core/formatters/explain.d.cts +11 -0
- package/dist/core/formatters/explain.d.cts.map +1 -0
- package/dist/core/formatters/explain.d.mts +11 -0
- package/dist/core/formatters/explain.d.mts.map +1 -0
- package/dist/core/formatters/explain.mjs +96 -0
- package/dist/core/formatters/explain.mjs.map +1 -0
- package/dist/core/formatters/index.d.mts +9 -0
- package/dist/core/formatters/ls.cjs +179 -0
- package/dist/core/formatters/ls.d.cts +20 -0
- package/dist/core/formatters/ls.d.cts.map +1 -0
- package/dist/core/formatters/ls.d.mts +20 -0
- package/dist/core/formatters/ls.d.mts.map +1 -0
- package/dist/core/formatters/ls.mjs +179 -0
- package/dist/core/formatters/ls.mjs.map +1 -0
- package/dist/core/formatters/mount.cjs +55 -0
- package/dist/core/formatters/mount.d.cts +15 -0
- package/dist/core/formatters/mount.d.cts.map +1 -0
- package/dist/core/formatters/mount.d.mts +15 -0
- package/dist/core/formatters/mount.d.mts.map +1 -0
- package/dist/core/formatters/mount.mjs +55 -0
- package/dist/core/formatters/mount.mjs.map +1 -0
- package/dist/core/formatters/read.cjs +100 -0
- package/dist/core/formatters/read.d.cts +22 -0
- package/dist/core/formatters/read.d.cts.map +1 -0
- package/dist/core/formatters/read.d.mts +22 -0
- package/dist/core/formatters/read.d.mts.map +1 -0
- package/dist/core/formatters/read.mjs +100 -0
- package/dist/core/formatters/read.mjs.map +1 -0
- package/dist/core/formatters/search.cjs +44 -0
- package/dist/core/formatters/search.d.mts +1 -0
- package/dist/core/formatters/search.mjs +44 -0
- package/dist/core/formatters/search.mjs.map +1 -0
- package/dist/core/formatters/stat.cjs +155 -0
- package/dist/core/formatters/stat.d.cts +15 -0
- package/dist/core/formatters/stat.d.cts.map +1 -0
- package/dist/core/formatters/stat.d.mts +15 -0
- package/dist/core/formatters/stat.d.mts.map +1 -0
- package/dist/core/formatters/stat.mjs +155 -0
- package/dist/core/formatters/stat.mjs.map +1 -0
- package/dist/core/formatters/write.cjs +51 -0
- package/dist/core/formatters/write.d.cts +22 -0
- package/dist/core/formatters/write.d.cts.map +1 -0
- package/dist/core/formatters/write.d.mts +22 -0
- package/dist/core/formatters/write.d.mts.map +1 -0
- package/dist/core/formatters/write.mjs +51 -0
- package/dist/core/formatters/write.mjs.map +1 -0
- package/dist/core/helpers/exec-args.cjs +142 -0
- package/dist/core/helpers/exec-args.d.cts +46 -0
- package/dist/core/helpers/exec-args.d.cts.map +1 -0
- package/dist/core/helpers/exec-args.d.mts +46 -0
- package/dist/core/helpers/exec-args.d.mts.map +1 -0
- package/dist/core/helpers/exec-args.mjs +139 -0
- package/dist/core/helpers/exec-args.mjs.map +1 -0
- package/dist/core/helpers/stdin.cjs +41 -0
- package/dist/core/helpers/stdin.d.cts +15 -0
- package/dist/core/helpers/stdin.d.cts.map +1 -0
- package/dist/core/helpers/stdin.d.mts +15 -0
- package/dist/core/helpers/stdin.d.mts.map +1 -0
- package/dist/core/helpers/stdin.mjs +41 -0
- package/dist/core/helpers/stdin.mjs.map +1 -0
- package/dist/core/index.cjs +49 -0
- package/dist/core/index.d.cts +24 -0
- package/dist/core/index.d.mts +25 -0
- package/dist/core/index.mjs +24 -0
- package/dist/core/path-utils.cjs +1 -0
- package/dist/core/path-utils.mjs +3 -0
- package/dist/core/types.d.cts +24 -0
- package/dist/core/types.d.cts.map +1 -0
- package/dist/core/types.d.mts +24 -0
- package/dist/core/types.d.mts.map +1 -0
- package/dist/credential/auth-server.cjs +247 -0
- package/dist/credential/auth-server.mjs +247 -0
- package/dist/credential/auth-server.mjs.map +1 -0
- package/dist/credential/cli-auth-context.cjs +86 -0
- package/dist/credential/cli-auth-context.d.mts +1 -0
- package/dist/credential/cli-auth-context.mjs +86 -0
- package/dist/credential/cli-auth-context.mjs.map +1 -0
- package/dist/credential/index.cjs +5 -0
- package/dist/credential/index.d.mts +4 -0
- package/dist/credential/index.mjs +7 -0
- package/dist/credential/mcp-auth-context.cjs +186 -0
- package/dist/credential/mcp-auth-context.d.mts +1 -0
- package/dist/credential/mcp-auth-context.mjs +186 -0
- package/dist/credential/mcp-auth-context.mjs.map +1 -0
- package/dist/credential/resolver.cjs +125 -0
- package/dist/credential/resolver.d.mts +1 -0
- package/dist/credential/resolver.mjs +125 -0
- package/dist/credential/resolver.mjs.map +1 -0
- package/dist/credential/store.cjs +106 -0
- package/dist/credential/store.d.cts +30 -0
- package/dist/credential/store.d.cts.map +1 -0
- package/dist/credential/store.d.mts +30 -0
- package/dist/credential/store.d.mts.map +1 -0
- package/dist/credential/store.mjs +106 -0
- package/dist/credential/store.mjs.map +1 -0
- package/dist/errors.cjs +0 -11
- package/dist/errors.mjs +1 -11
- package/dist/errors.mjs.map +1 -1
- package/dist/explorer/actions.cjs +67 -32
- package/dist/explorer/actions.mjs +66 -32
- package/dist/explorer/actions.mjs.map +1 -1
- package/dist/explorer/components/dialog.cjs +170 -46
- package/dist/explorer/components/dialog.mjs +170 -46
- package/dist/explorer/components/dialog.mjs.map +1 -1
- package/dist/explorer/components/metadata-panel.cjs +86 -3
- package/dist/explorer/components/metadata-panel.mjs +86 -3
- package/dist/explorer/components/metadata-panel.mjs.map +1 -1
- package/dist/explorer/screen.cjs +63 -27
- package/dist/explorer/screen.d.cts +23 -0
- package/dist/explorer/screen.d.cts.map +1 -0
- package/dist/explorer/screen.d.mts +23 -0
- package/dist/explorer/screen.d.mts.map +1 -0
- package/dist/explorer/screen.mjs +63 -27
- package/dist/explorer/screen.mjs.map +1 -1
- package/dist/explorer/theme.cjs +1 -1
- package/dist/explorer/theme.mjs +1 -1
- package/dist/explorer/theme.mjs.map +1 -1
- package/dist/index.cjs +10 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.mjs +6 -1
- package/dist/mcp/http-transport.cjs +87 -0
- package/dist/mcp/http-transport.mjs +87 -0
- package/dist/mcp/http-transport.mjs.map +1 -0
- package/dist/mcp/prompts.cjs +48 -0
- package/dist/mcp/prompts.mjs +48 -0
- package/dist/mcp/prompts.mjs.map +1 -0
- package/dist/mcp/resources.cjs +25 -0
- package/dist/mcp/resources.mjs +25 -0
- package/dist/mcp/resources.mjs.map +1 -0
- package/dist/mcp/server.cjs +40 -0
- package/dist/mcp/server.mjs +39 -0
- package/dist/mcp/server.mjs.map +1 -0
- package/dist/mcp/tools.cjs +152 -0
- package/dist/mcp/tools.mjs +152 -0
- package/dist/mcp/tools.mjs.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts +10 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts +10 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/index.d.mts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts +46 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts +46 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/types.d.mts.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +902 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs +902 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/dist/urlpattern.mjs.map +1 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.cjs +6 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs +8 -0
- package/dist/node_modules/.pnpm/urlpattern-polyfill@10.1.0/node_modules/urlpattern-polyfill/index.mjs.map +1 -0
- package/dist/path-utils.d.cts +50 -0
- package/dist/path-utils.d.cts.map +1 -0
- package/dist/path-utils.d.mts +50 -0
- package/dist/path-utils.d.mts.map +1 -0
- package/dist/repl.cjs +491 -0
- package/dist/repl.d.cts +15 -0
- package/dist/repl.d.cts.map +1 -0
- package/dist/repl.d.mts +16 -0
- package/dist/repl.d.mts.map +1 -0
- package/dist/repl.mjs +491 -0
- package/dist/repl.mjs.map +1 -0
- package/dist/serve.cjs +146 -0
- package/dist/serve.d.cts +41 -0
- package/dist/serve.d.cts.map +1 -0
- package/dist/serve.d.mts +41 -0
- package/dist/serve.d.mts.map +1 -0
- package/dist/serve.mjs +146 -0
- package/dist/serve.mjs.map +1 -0
- package/dist/ui/header.cjs +1 -40
- package/dist/ui/header.mjs +1 -39
- package/dist/ui/header.mjs.map +1 -1
- package/dist/ui/index.cjs +2 -9
- package/dist/ui/index.mjs +2 -7
- package/dist/ui/index.mjs.map +1 -1
- package/dist/ui/terminal.cjs +1 -10
- package/dist/ui/terminal.mjs +1 -8
- package/dist/ui/terminal.mjs.map +1 -1
- package/package.json +30 -17
- package/dist/commands/exec.cjs +0 -164
- package/dist/commands/exec.mjs +0 -160
- package/dist/commands/exec.mjs.map +0 -1
- package/dist/commands/explain.cjs +0 -244
- package/dist/commands/explain.mjs +0 -242
- package/dist/commands/explain.mjs.map +0 -1
- package/dist/commands/index.cjs +0 -8
- package/dist/commands/index.mjs +0 -10
- package/dist/commands/ls.cjs +0 -242
- package/dist/commands/ls.mjs +0 -242
- package/dist/commands/ls.mjs.map +0 -1
- package/dist/commands/mount.cjs +0 -194
- package/dist/commands/mount.mjs +0 -190
- package/dist/commands/mount.mjs.map +0 -1
- package/dist/commands/read.cjs +0 -264
- package/dist/commands/read.mjs +0 -263
- package/dist/commands/read.mjs.map +0 -1
- package/dist/commands/serve.cjs +0 -144
- package/dist/commands/serve.mjs +0 -143
- package/dist/commands/serve.mjs.map +0 -1
- package/dist/commands/stat.cjs +0 -195
- package/dist/commands/stat.mjs +0 -195
- package/dist/commands/stat.mjs.map +0 -1
- package/dist/commands/write.cjs +0 -85
- package/dist/commands/write.mjs +0 -85
- package/dist/commands/write.mjs.map +0 -1
- package/dist/config/provider-factory.cjs +0 -400
- package/dist/config/provider-factory.mjs +0 -401
- package/dist/config/provider-factory.mjs.map +0 -1
- package/dist/config/uri-parser.cjs +0 -285
- package/dist/config/uri-parser.mjs +0 -285
- package/dist/config/uri-parser.mjs.map +0 -1
- package/dist/runtime.cjs +0 -120
- package/dist/runtime.mjs +0 -120
- package/dist/runtime.mjs.map +0 -1
- package/dist/utils/meta.cjs +0 -51
- package/dist/utils/meta.mjs +0 -49
- package/dist/utils/meta.mjs.map +0 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AFS } from "@aigne/afs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/executor/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Result from executing a command
|
|
6
|
+
*/
|
|
7
|
+
interface ExecuteResult {
|
|
8
|
+
/** Whether the command executed successfully */
|
|
9
|
+
success: boolean;
|
|
10
|
+
/** The command that was executed (ls, read, write, etc.) */
|
|
11
|
+
command: string;
|
|
12
|
+
/** The raw result data from AFS */
|
|
13
|
+
result?: unknown;
|
|
14
|
+
/** Formatted output string */
|
|
15
|
+
formatted: string;
|
|
16
|
+
/** Error info if the command failed */
|
|
17
|
+
error?: {
|
|
18
|
+
/** Exit code (from ExitCode enum) */code?: number; /** Error message */
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for the executor
|
|
24
|
+
*/
|
|
25
|
+
interface ExecutorOptions {
|
|
26
|
+
/** Whether the output is for a TTY (enables colors) */
|
|
27
|
+
tty?: boolean;
|
|
28
|
+
/** Current working directory (for explore command) */
|
|
29
|
+
cwd?: string;
|
|
30
|
+
/** Version of the AFS CLI */
|
|
31
|
+
version?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* AFS Command Executor
|
|
35
|
+
*
|
|
36
|
+
* Provides a unified interface for executing AFS commands using yargs.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const executor = new AFSCommandExecutor(afs, { tty: false });
|
|
41
|
+
* const result = await executor.execute("afs ls /path --depth=2");
|
|
42
|
+
* console.log(result.formatted);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare class AFSCommandExecutor {
|
|
46
|
+
private afs?;
|
|
47
|
+
private options;
|
|
48
|
+
constructor(afs?: AFS, options?: ExecutorOptions);
|
|
49
|
+
/**
|
|
50
|
+
* Execute an AFS command
|
|
51
|
+
*
|
|
52
|
+
* @param argv - Command string or array of arguments
|
|
53
|
+
* - String: "afs ls /path --depth=2" or "ls /path --depth=2"
|
|
54
|
+
* - Array: ["ls", "/path", "--depth=2"]
|
|
55
|
+
* @returns Execution result with formatted output
|
|
56
|
+
*/
|
|
57
|
+
execute(argv: string | string[]): Promise<ExecuteResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Normalize argv to an array of strings
|
|
60
|
+
*/
|
|
61
|
+
private normalizeArgv;
|
|
62
|
+
/**
|
|
63
|
+
* Tokenize a command string, respecting quotes
|
|
64
|
+
*/
|
|
65
|
+
private tokenize;
|
|
66
|
+
/**
|
|
67
|
+
* Extract output options from args
|
|
68
|
+
*/
|
|
69
|
+
private extractOutputOptions;
|
|
70
|
+
/**
|
|
71
|
+
* Extract path from args (first non-option argument after command)
|
|
72
|
+
*/
|
|
73
|
+
private extractPath;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { AFSCommandExecutor, ExecuteResult, ExecutorOptions };
|
|
77
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/core/executor/index.ts"],"mappings":";;;;;;UAkBiB,aAAA;EAQf;EANA,OAAA;EAUE;EARF,OAAA;EAUS;EART,MAAA;EAee;EAbf,SAAA;;EAEA,KAAA;IAaA,qCAXE,IAAA,WAeF;IAbE,OAAA;EAAA;AAAA;;;;UAOa,eAAA;EAsCiC;EApChD,GAAA;EAoC+C;EAlC/C,GAAA;EAkBQ;EAhBR,OAAA;AAAA;;;;;;;;;;;;;cAeW,kBAAA;EAAA,QACH,GAAA;EAAA,QACA,OAAA;cAEI,GAAA,GAAM,GAAA,EAAK,OAAA,GAAU,eAAA;;;;;;;;;EAa3B,OAAA,CAAQ,IAAA,sBAA0B,OAAA,CAAQ,aAAA;;;;UA6IxC,aAAA;;;;UAoCA,QAAA;;;;UA2CA,oBAAA;;;;UA+BA,WAAA;AAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AFS } from "@aigne/afs";
|
|
2
|
+
|
|
3
|
+
//#region src/core/executor/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Result from executing a command
|
|
6
|
+
*/
|
|
7
|
+
interface ExecuteResult {
|
|
8
|
+
/** Whether the command executed successfully */
|
|
9
|
+
success: boolean;
|
|
10
|
+
/** The command that was executed (ls, read, write, etc.) */
|
|
11
|
+
command: string;
|
|
12
|
+
/** The raw result data from AFS */
|
|
13
|
+
result?: unknown;
|
|
14
|
+
/** Formatted output string */
|
|
15
|
+
formatted: string;
|
|
16
|
+
/** Error info if the command failed */
|
|
17
|
+
error?: {
|
|
18
|
+
/** Exit code (from ExitCode enum) */code?: number; /** Error message */
|
|
19
|
+
message: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options for the executor
|
|
24
|
+
*/
|
|
25
|
+
interface ExecutorOptions {
|
|
26
|
+
/** Whether the output is for a TTY (enables colors) */
|
|
27
|
+
tty?: boolean;
|
|
28
|
+
/** Current working directory (for explore command) */
|
|
29
|
+
cwd?: string;
|
|
30
|
+
/** Version of the AFS CLI */
|
|
31
|
+
version?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* AFS Command Executor
|
|
35
|
+
*
|
|
36
|
+
* Provides a unified interface for executing AFS commands using yargs.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const executor = new AFSCommandExecutor(afs, { tty: false });
|
|
41
|
+
* const result = await executor.execute("afs ls /path --depth=2");
|
|
42
|
+
* console.log(result.formatted);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
declare class AFSCommandExecutor {
|
|
46
|
+
private afs?;
|
|
47
|
+
private options;
|
|
48
|
+
constructor(afs?: AFS, options?: ExecutorOptions);
|
|
49
|
+
/**
|
|
50
|
+
* Execute an AFS command
|
|
51
|
+
*
|
|
52
|
+
* @param argv - Command string or array of arguments
|
|
53
|
+
* - String: "afs ls /path --depth=2" or "ls /path --depth=2"
|
|
54
|
+
* - Array: ["ls", "/path", "--depth=2"]
|
|
55
|
+
* @returns Execution result with formatted output
|
|
56
|
+
*/
|
|
57
|
+
execute(argv: string | string[]): Promise<ExecuteResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Normalize argv to an array of strings
|
|
60
|
+
*/
|
|
61
|
+
private normalizeArgv;
|
|
62
|
+
/**
|
|
63
|
+
* Tokenize a command string, respecting quotes
|
|
64
|
+
*/
|
|
65
|
+
private tokenize;
|
|
66
|
+
/**
|
|
67
|
+
* Extract output options from args
|
|
68
|
+
*/
|
|
69
|
+
private extractOutputOptions;
|
|
70
|
+
/**
|
|
71
|
+
* Extract path from args (first non-option argument after command)
|
|
72
|
+
*/
|
|
73
|
+
private extractPath;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { AFSCommandExecutor, ExecuteResult, ExecutorOptions };
|
|
77
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/core/executor/index.ts"],"mappings":";;;;;;UAkBiB,aAAA;EAQf;EANA,OAAA;EAUE;EARF,OAAA;EAUS;EART,MAAA;EAee;EAbf,SAAA;;EAEA,KAAA;IAaA,qCAXE,IAAA,WAeF;IAbE,OAAA;EAAA;AAAA;;;;UAOa,eAAA;EAsCiC;EApChD,GAAA;EAoC+C;EAlC/C,GAAA;EAkBQ;EAhBR,OAAA;AAAA;;;;;;;;;;;;;cAeW,kBAAA;EAAA,QACH,GAAA;EAAA,QACA,OAAA;cAEI,GAAA,GAAM,GAAA,EAAK,OAAA,GAAU,eAAA;;;;;;;;;EAa3B,OAAA,CAAQ,IAAA,sBAA0B,OAAA,CAAQ,aAAA;;;;UA6IxC,aAAA;;;;UAoCA,QAAA;;;;UA2CA,oBAAA;;;;UA+BA,WAAA;AAAA"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { commandFactories } from "../commands/index.mjs";
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/executor/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* AFS Command Executor
|
|
7
|
+
*
|
|
8
|
+
* Provides a unified interface for executing AFS commands using yargs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const executor = new AFSCommandExecutor(afs, { tty: false });
|
|
13
|
+
* const result = await executor.execute("afs ls /path --depth=2");
|
|
14
|
+
* console.log(result.formatted);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
var AFSCommandExecutor = class {
|
|
18
|
+
afs;
|
|
19
|
+
options;
|
|
20
|
+
constructor(afs, options) {
|
|
21
|
+
this.afs = afs;
|
|
22
|
+
this.options = options ?? {};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Execute an AFS command
|
|
26
|
+
*
|
|
27
|
+
* @param argv - Command string or array of arguments
|
|
28
|
+
* - String: "afs ls /path --depth=2" or "ls /path --depth=2"
|
|
29
|
+
* - Array: ["ls", "/path", "--depth=2"]
|
|
30
|
+
* @returns Execution result with formatted output
|
|
31
|
+
*/
|
|
32
|
+
async execute(argv) {
|
|
33
|
+
const normalizedArgs = this.normalizeArgv(argv);
|
|
34
|
+
let commandResult;
|
|
35
|
+
const outputOptions = this.extractOutputOptions(normalizedArgs);
|
|
36
|
+
const factoryOptions = {
|
|
37
|
+
afs: this.afs,
|
|
38
|
+
argv: normalizedArgs,
|
|
39
|
+
cwd: this.options.cwd,
|
|
40
|
+
onResult: (result) => {
|
|
41
|
+
commandResult = result;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let parser = yargs(normalizedArgs).scriptName("afs").usage("$0 <command> [options]").option("json", {
|
|
45
|
+
type: "boolean",
|
|
46
|
+
description: "Output in JSON format",
|
|
47
|
+
global: true
|
|
48
|
+
}).option("yaml", {
|
|
49
|
+
type: "boolean",
|
|
50
|
+
description: "Output in YAML format",
|
|
51
|
+
global: true
|
|
52
|
+
}).option("view", {
|
|
53
|
+
type: "string",
|
|
54
|
+
choices: [
|
|
55
|
+
"default",
|
|
56
|
+
"llm",
|
|
57
|
+
"human"
|
|
58
|
+
],
|
|
59
|
+
default: "default",
|
|
60
|
+
description: "Output view format",
|
|
61
|
+
global: true
|
|
62
|
+
}).option("interactive", {
|
|
63
|
+
alias: "i",
|
|
64
|
+
type: "boolean",
|
|
65
|
+
description: "Start interactive REPL mode",
|
|
66
|
+
global: false
|
|
67
|
+
}).help(true).alias("h", "help").version(this.options.version || "unknown").alias("v", "version").demandCommand().showHelpOnFail(true).exitProcess(false);
|
|
68
|
+
for (const factory of commandFactories) parser = parser.command(factory(factoryOptions));
|
|
69
|
+
try {
|
|
70
|
+
let output;
|
|
71
|
+
let error;
|
|
72
|
+
const parsed = await parser.parseAsync(normalizedArgs, {}, (e, _, o) => {
|
|
73
|
+
if (e) error = e;
|
|
74
|
+
output = o;
|
|
75
|
+
});
|
|
76
|
+
if (error) return {
|
|
77
|
+
success: false,
|
|
78
|
+
command: normalizedArgs[0] || "unknown",
|
|
79
|
+
result: void 0,
|
|
80
|
+
formatted: output,
|
|
81
|
+
error: { message: error.message }
|
|
82
|
+
};
|
|
83
|
+
if (parsed.help) return {
|
|
84
|
+
success: true,
|
|
85
|
+
command: "help",
|
|
86
|
+
formatted: output
|
|
87
|
+
};
|
|
88
|
+
if (parsed.version) return {
|
|
89
|
+
success: true,
|
|
90
|
+
command: "version",
|
|
91
|
+
formatted: output
|
|
92
|
+
};
|
|
93
|
+
if (!commandResult) throw new Error("Command not found");
|
|
94
|
+
const view = outputOptions.json ? "json" : outputOptions.yaml ? "yaml" : outputOptions.view;
|
|
95
|
+
const formatted = commandResult.format(commandResult.result, view, { path: this.extractPath(normalizedArgs) });
|
|
96
|
+
if (commandResult.error) return {
|
|
97
|
+
success: false,
|
|
98
|
+
command: commandResult.command,
|
|
99
|
+
result: commandResult.result,
|
|
100
|
+
formatted,
|
|
101
|
+
error: commandResult.error
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
success: true,
|
|
105
|
+
command: commandResult.command,
|
|
106
|
+
result: commandResult.result,
|
|
107
|
+
formatted
|
|
108
|
+
};
|
|
109
|
+
} catch (error) {
|
|
110
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
111
|
+
return {
|
|
112
|
+
success: false,
|
|
113
|
+
command: normalizedArgs[0] || "unknown",
|
|
114
|
+
result: void 0,
|
|
115
|
+
formatted: `ERROR: ${errorMessage}`,
|
|
116
|
+
error: { message: errorMessage }
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Normalize argv to an array of strings
|
|
122
|
+
*/
|
|
123
|
+
normalizeArgv(argv) {
|
|
124
|
+
if (typeof argv === "string") return this.tokenize(argv);
|
|
125
|
+
const filtered = [];
|
|
126
|
+
let foundCommand = false;
|
|
127
|
+
for (const arg of argv) {
|
|
128
|
+
if (!foundCommand && (arg.includes("node") || arg.includes("bun") || arg.endsWith(".js") || arg.endsWith(".ts"))) continue;
|
|
129
|
+
if (!foundCommand && arg === "afs") continue;
|
|
130
|
+
filtered.push(arg);
|
|
131
|
+
if (!arg.startsWith("-")) foundCommand = true;
|
|
132
|
+
}
|
|
133
|
+
return filtered;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Tokenize a command string, respecting quotes
|
|
137
|
+
*/
|
|
138
|
+
tokenize(input) {
|
|
139
|
+
const tokens = [];
|
|
140
|
+
let current = "";
|
|
141
|
+
let inQuote = false;
|
|
142
|
+
let quoteChar = "";
|
|
143
|
+
for (let i = 0; i < input.length; i++) {
|
|
144
|
+
const char = input[i];
|
|
145
|
+
if (inQuote) if (char === quoteChar) inQuote = false;
|
|
146
|
+
else current += char;
|
|
147
|
+
else if (char === "\"" || char === "'") {
|
|
148
|
+
inQuote = true;
|
|
149
|
+
quoteChar = char;
|
|
150
|
+
} else if (char === " " || char === " ") {
|
|
151
|
+
if (current) {
|
|
152
|
+
tokens.push(current);
|
|
153
|
+
current = "";
|
|
154
|
+
}
|
|
155
|
+
} else current += char;
|
|
156
|
+
}
|
|
157
|
+
if (current) tokens.push(current);
|
|
158
|
+
if (tokens[0] === "afs") tokens.shift();
|
|
159
|
+
return tokens;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Extract output options from args
|
|
163
|
+
*/
|
|
164
|
+
extractOutputOptions(args) {
|
|
165
|
+
let json = false;
|
|
166
|
+
let yaml = false;
|
|
167
|
+
let view;
|
|
168
|
+
for (let i = 0; i < args.length; i++) {
|
|
169
|
+
const arg = args[i];
|
|
170
|
+
if (arg === "--json") json = true;
|
|
171
|
+
if (arg === "--yaml") yaml = true;
|
|
172
|
+
if (arg.startsWith("--view=")) view = arg.slice(7);
|
|
173
|
+
else if (arg === "--view" && args[i + 1] && !args[i + 1].startsWith("-")) view = args[i + 1];
|
|
174
|
+
}
|
|
175
|
+
if (!view) view = this.options.tty ? "human" : "default";
|
|
176
|
+
return {
|
|
177
|
+
json,
|
|
178
|
+
yaml,
|
|
179
|
+
view
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Extract path from args (first non-option argument after command)
|
|
184
|
+
*/
|
|
185
|
+
extractPath(args) {
|
|
186
|
+
for (let i = 1; i < args.length; i++) {
|
|
187
|
+
const arg = args[i];
|
|
188
|
+
if (!arg.startsWith("-")) return arg;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
//#endregion
|
|
194
|
+
export { AFSCommandExecutor };
|
|
195
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/executor/index.ts"],"sourcesContent":["/**\n * AFS Command Executor\n *\n * Unified command execution interface using yargs and CommandFactory pattern.\n */\n\nimport type { AFS } from \"@aigne/afs\";\nimport yargs from \"yargs\";\nimport {\n type CommandFactoryOptions,\n type CommandOutput,\n commandFactories,\n} from \"../commands/index.js\";\nimport type { ViewType } from \"../types.js\";\n\n/**\n * Result from executing a command\n */\nexport interface ExecuteResult {\n /** Whether the command executed successfully */\n success: boolean;\n /** The command that was executed (ls, read, write, etc.) */\n command: string;\n /** The raw result data from AFS */\n result?: unknown;\n /** Formatted output string */\n formatted: string;\n /** Error info if the command failed */\n error?: {\n /** Exit code (from ExitCode enum) */\n code?: number;\n /** Error message */\n message: string;\n };\n}\n\n/**\n * Options for the executor\n */\nexport interface ExecutorOptions {\n /** Whether the output is for a TTY (enables colors) */\n tty?: boolean;\n /** Current working directory (for explore command) */\n cwd?: string;\n /** Version of the AFS CLI */\n version?: string;\n}\n\n/**\n * AFS Command Executor\n *\n * Provides a unified interface for executing AFS commands using yargs.\n *\n * @example\n * ```typescript\n * const executor = new AFSCommandExecutor(afs, { tty: false });\n * const result = await executor.execute(\"afs ls /path --depth=2\");\n * console.log(result.formatted);\n * ```\n */\nexport class AFSCommandExecutor {\n private afs?: AFS;\n private options: ExecutorOptions;\n\n constructor(afs?: AFS, options?: ExecutorOptions) {\n this.afs = afs;\n this.options = options ?? {};\n }\n\n /**\n * Execute an AFS command\n *\n * @param argv - Command string or array of arguments\n * - String: \"afs ls /path --depth=2\" or \"ls /path --depth=2\"\n * - Array: [\"ls\", \"/path\", \"--depth=2\"]\n * @returns Execution result with formatted output\n */\n async execute(argv: string | string[]): Promise<ExecuteResult> {\n const normalizedArgs = this.normalizeArgv(argv);\n\n // Capture command result\n let commandResult: CommandOutput | undefined;\n\n // Determine output format from args\n const outputOptions = this.extractOutputOptions(normalizedArgs);\n\n // Create factory options\n const factoryOptions: CommandFactoryOptions = {\n afs: this.afs,\n argv: normalizedArgs,\n cwd: this.options.cwd,\n onResult: (result) => {\n commandResult = result;\n },\n };\n\n // Build yargs parser with all commands\n let parser = yargs(normalizedArgs)\n .scriptName(\"afs\")\n .usage(\"$0 <command> [options]\")\n .option(\"json\", {\n type: \"boolean\",\n description: \"Output in JSON format\",\n global: true,\n })\n .option(\"yaml\", {\n type: \"boolean\",\n description: \"Output in YAML format\",\n global: true,\n })\n .option(\"view\", {\n type: \"string\",\n choices: [\"default\", \"llm\", \"human\"],\n default: \"default\",\n description: \"Output view format\",\n global: true,\n })\n .option(\"interactive\", {\n alias: \"i\",\n type: \"boolean\",\n description: \"Start interactive REPL mode\",\n global: false,\n })\n .help(true)\n .alias(\"h\", \"help\")\n .version(this.options.version || \"unknown\")\n .alias(\"v\", \"version\")\n .demandCommand()\n .showHelpOnFail(true)\n .exitProcess(false);\n\n // Register all commands from factories\n for (const factory of commandFactories) {\n parser = parser.command(factory(factoryOptions));\n }\n\n // Parse and execute\n try {\n let output: string | undefined;\n let error: Error | undefined;\n\n const parsed = await parser.parseAsync(normalizedArgs, {}, (e, _, o) => {\n if (e) error = e;\n output = o;\n });\n\n if (error) {\n return {\n success: false,\n command: normalizedArgs[0] || \"unknown\",\n result: undefined,\n formatted: output!,\n error: { message: error.message },\n };\n }\n\n if (parsed.help) {\n return {\n success: true,\n command: \"help\",\n formatted: output!,\n };\n }\n if (parsed.version) {\n return {\n success: true,\n command: \"version\",\n formatted: output!,\n };\n }\n\n if (!commandResult) {\n throw new Error(\"Command not found\");\n }\n\n // Always use the formatter - it handles json/llm/human views\n const view: ViewType = outputOptions.json\n ? \"json\"\n : outputOptions.yaml\n ? \"yaml\"\n : outputOptions.view;\n const formatted = commandResult.format(commandResult.result, view, {\n path: this.extractPath(normalizedArgs),\n });\n\n // Check if command indicated failure\n if (commandResult.error) {\n return {\n success: false,\n command: commandResult.command,\n result: commandResult.result,\n formatted,\n error: commandResult.error,\n };\n }\n\n return {\n success: true,\n command: commandResult.command,\n result: commandResult.result,\n formatted,\n };\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n return {\n success: false,\n command: normalizedArgs[0] || \"unknown\",\n result: undefined,\n formatted: `ERROR: ${errorMessage}`,\n error: { message: errorMessage },\n };\n }\n }\n\n /**\n * Normalize argv to an array of strings\n */\n private normalizeArgv(argv: string | string[]): string[] {\n if (typeof argv === \"string\") {\n // Parse quoted strings properly\n return this.tokenize(argv);\n }\n\n // Filter array input\n const filtered: string[] = [];\n let foundCommand = false;\n\n for (const arg of argv) {\n // Skip node and script paths (for process.argv format)\n if (\n !foundCommand &&\n (arg.includes(\"node\") || arg.includes(\"bun\") || arg.endsWith(\".js\") || arg.endsWith(\".ts\"))\n ) {\n continue;\n }\n\n // Skip \"afs\" prefix\n if (!foundCommand && arg === \"afs\") {\n continue;\n }\n\n filtered.push(arg);\n if (!arg.startsWith(\"-\")) {\n foundCommand = true;\n }\n }\n\n return filtered;\n }\n\n /**\n * Tokenize a command string, respecting quotes\n */\n private tokenize(input: string): string[] {\n const tokens: string[] = [];\n let current = \"\";\n let inQuote = false;\n let quoteChar = \"\";\n\n for (let i = 0; i < input.length; i++) {\n const char = input[i]!;\n\n if (inQuote) {\n if (char === quoteChar) {\n inQuote = false;\n } else {\n current += char;\n }\n } else if (char === '\"' || char === \"'\") {\n inQuote = true;\n quoteChar = char;\n } else if (char === \" \" || char === \"\\t\") {\n if (current) {\n tokens.push(current);\n current = \"\";\n }\n } else {\n current += char;\n }\n }\n\n if (current) {\n tokens.push(current);\n }\n\n // Filter out \"afs\" prefix if present\n if (tokens[0] === \"afs\") {\n tokens.shift();\n }\n\n return tokens;\n }\n\n /**\n * Extract output options from args\n */\n private extractOutputOptions(args: string[]): {\n json: boolean;\n yaml: boolean;\n view: ViewType;\n } {\n let json = false;\n let yaml = false;\n let view: ViewType | undefined;\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]!;\n if (arg === \"--json\") json = true;\n if (arg === \"--yaml\") yaml = true;\n if (arg.startsWith(\"--view=\")) {\n view = arg.slice(7) as ViewType;\n } else if (arg === \"--view\" && args[i + 1] && !args[i + 1]!.startsWith(\"-\")) {\n view = args[i + 1] as ViewType;\n }\n }\n\n // Default to human view in TTY, default otherwise\n if (!view) {\n view = this.options.tty ? \"human\" : \"default\";\n }\n\n return { json, yaml, view };\n }\n\n /**\n * Extract path from args (first non-option argument after command)\n */\n private extractPath(args: string[]): string | undefined {\n for (let i = 1; i < args.length; i++) {\n const arg = args[i]!;\n if (!arg.startsWith(\"-\")) {\n return arg;\n }\n }\n return undefined;\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/formatters/delete.ts
|
|
3
|
+
/**
|
|
4
|
+
* Format delete output for different views
|
|
5
|
+
*
|
|
6
|
+
* @param result - AFS delete result (native type)
|
|
7
|
+
* @param view - View type (default, json, llm, human)
|
|
8
|
+
* @param options - Format options (path for display)
|
|
9
|
+
* @returns Formatted string (no ANSI colors)
|
|
10
|
+
*/
|
|
11
|
+
function formatDeleteOutput(result, view, options) {
|
|
12
|
+
const path = options?.path;
|
|
13
|
+
switch (view) {
|
|
14
|
+
case "json": return JSON.stringify(result, null, 2);
|
|
15
|
+
case "llm": return formatLlm(result, path);
|
|
16
|
+
case "human": return formatHuman(result, path);
|
|
17
|
+
default: return formatDefault(result, path);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function formatDefault(result, path) {
|
|
21
|
+
if (path) return path;
|
|
22
|
+
return result.message || "Deleted";
|
|
23
|
+
}
|
|
24
|
+
function formatLlm(result, path) {
|
|
25
|
+
const lines = [];
|
|
26
|
+
lines.push(`DELETE ${path || "path"}`);
|
|
27
|
+
lines.push("STATUS SUCCESS");
|
|
28
|
+
if (result.message) lines.push(`MESSAGE ${result.message}`);
|
|
29
|
+
return lines.join("\n");
|
|
30
|
+
}
|
|
31
|
+
function formatHuman(result, path) {
|
|
32
|
+
if (path) return `Deleted: ${path}`;
|
|
33
|
+
return result.message || "Deleted successfully";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.formatDeleteOutput = formatDeleteOutput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ViewType } from "../types.cjs";
|
|
2
|
+
import { AFSDeleteResult } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/formatters/delete.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Format delete output for different views
|
|
7
|
+
*
|
|
8
|
+
* @param result - AFS delete result (native type)
|
|
9
|
+
* @param view - View type (default, json, llm, human)
|
|
10
|
+
* @param options - Format options (path for display)
|
|
11
|
+
* @returns Formatted string (no ANSI colors)
|
|
12
|
+
*/
|
|
13
|
+
declare function formatDeleteOutput(result: AFSDeleteResult, view: ViewType, options?: {
|
|
14
|
+
path?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { formatDeleteOutput };
|
|
18
|
+
//# sourceMappingURL=delete.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.cts","names":[],"sources":["../../../src/core/formatters/delete.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,kBAAA,CACd,MAAA,EAAQ,eAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ViewType } from "../types.mjs";
|
|
2
|
+
import { AFSDeleteResult } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/formatters/delete.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Format delete output for different views
|
|
7
|
+
*
|
|
8
|
+
* @param result - AFS delete result (native type)
|
|
9
|
+
* @param view - View type (default, json, llm, human)
|
|
10
|
+
* @param options - Format options (path for display)
|
|
11
|
+
* @returns Formatted string (no ANSI colors)
|
|
12
|
+
*/
|
|
13
|
+
declare function formatDeleteOutput(result: AFSDeleteResult, view: ViewType, options?: {
|
|
14
|
+
path?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { formatDeleteOutput };
|
|
18
|
+
//# sourceMappingURL=delete.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.mts","names":[],"sources":["../../../src/core/formatters/delete.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,kBAAA,CACd,MAAA,EAAQ,eAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/core/formatters/delete.ts
|
|
2
|
+
/**
|
|
3
|
+
* Format delete output for different views
|
|
4
|
+
*
|
|
5
|
+
* @param result - AFS delete result (native type)
|
|
6
|
+
* @param view - View type (default, json, llm, human)
|
|
7
|
+
* @param options - Format options (path for display)
|
|
8
|
+
* @returns Formatted string (no ANSI colors)
|
|
9
|
+
*/
|
|
10
|
+
function formatDeleteOutput(result, view, options) {
|
|
11
|
+
const path = options?.path;
|
|
12
|
+
switch (view) {
|
|
13
|
+
case "json": return JSON.stringify(result, null, 2);
|
|
14
|
+
case "llm": return formatLlm(result, path);
|
|
15
|
+
case "human": return formatHuman(result, path);
|
|
16
|
+
default: return formatDefault(result, path);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function formatDefault(result, path) {
|
|
20
|
+
if (path) return path;
|
|
21
|
+
return result.message || "Deleted";
|
|
22
|
+
}
|
|
23
|
+
function formatLlm(result, path) {
|
|
24
|
+
const lines = [];
|
|
25
|
+
lines.push(`DELETE ${path || "path"}`);
|
|
26
|
+
lines.push("STATUS SUCCESS");
|
|
27
|
+
if (result.message) lines.push(`MESSAGE ${result.message}`);
|
|
28
|
+
return lines.join("\n");
|
|
29
|
+
}
|
|
30
|
+
function formatHuman(result, path) {
|
|
31
|
+
if (path) return `Deleted: ${path}`;
|
|
32
|
+
return result.message || "Deleted successfully";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { formatDeleteOutput };
|
|
37
|
+
//# sourceMappingURL=delete.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.mjs","names":[],"sources":["../../../src/core/formatters/delete.ts"],"sourcesContent":["/**\n * delete Formatter - Core Implementation\n *\n * Formats delete output without colors.\n * Accepts AFS native AFSDeleteResult directly.\n */\n\nimport type { AFSDeleteResult } from \"@aigne/afs\";\nimport type { ViewType } from \"../types.js\";\n\n/**\n * Format delete output for different views\n *\n * @param result - AFS delete result (native type)\n * @param view - View type (default, json, llm, human)\n * @param options - Format options (path for display)\n * @returns Formatted string (no ANSI colors)\n */\nexport function formatDeleteOutput(\n result: AFSDeleteResult,\n view: ViewType,\n options?: { path?: string },\n): string {\n const path = options?.path;\n switch (view) {\n case \"json\":\n return JSON.stringify(result, null, 2);\n case \"llm\":\n return formatLlm(result, path);\n case \"human\":\n return formatHuman(result, path);\n default:\n return formatDefault(result, path);\n }\n}\n\nfunction formatDefault(result: AFSDeleteResult, path?: string): string {\n if (path) {\n return path;\n }\n return result.message || \"Deleted\";\n}\n\nfunction formatLlm(result: AFSDeleteResult, path?: string): string {\n const lines: string[] = [];\n\n lines.push(`DELETE ${path || \"path\"}`);\n lines.push(\"STATUS SUCCESS\");\n\n if (result.message) {\n lines.push(`MESSAGE ${result.message}`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatHuman(result: AFSDeleteResult, path?: string): string {\n if (path) {\n return `Deleted: ${path}`;\n }\n return result.message || \"Deleted successfully\";\n}\n"],"mappings":";;;;;;;;;AAkBA,SAAgB,mBACd,QACA,MACA,SACQ;CACR,MAAM,OAAO,SAAS;AACtB,SAAQ,MAAR;EACE,KAAK,OACH,QAAO,KAAK,UAAU,QAAQ,MAAM,EAAE;EACxC,KAAK,MACH,QAAO,UAAU,QAAQ,KAAK;EAChC,KAAK,QACH,QAAO,YAAY,QAAQ,KAAK;EAClC,QACE,QAAO,cAAc,QAAQ,KAAK;;;AAIxC,SAAS,cAAc,QAAyB,MAAuB;AACrE,KAAI,KACF,QAAO;AAET,QAAO,OAAO,WAAW;;AAG3B,SAAS,UAAU,QAAyB,MAAuB;CACjE,MAAM,QAAkB,EAAE;AAE1B,OAAM,KAAK,UAAU,QAAQ,SAAS;AACtC,OAAM,KAAK,iBAAiB;AAE5B,KAAI,OAAO,QACT,OAAM,KAAK,WAAW,OAAO,UAAU;AAGzC,QAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,YAAY,QAAyB,MAAuB;AACnE,KAAI,KACF,QAAO,YAAY;AAErB,QAAO,OAAO,WAAW"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/formatters/exec.ts
|
|
3
|
+
/**
|
|
4
|
+
* Format exec output for different views
|
|
5
|
+
*
|
|
6
|
+
* @param result - AFS exec result (native type)
|
|
7
|
+
* @param view - View type (default, json, llm, human)
|
|
8
|
+
* @param options - Format options (path for display)
|
|
9
|
+
* @returns Formatted string (no ANSI colors)
|
|
10
|
+
*/
|
|
11
|
+
function formatExecOutput(result, view, options) {
|
|
12
|
+
const path = options?.path;
|
|
13
|
+
switch (view) {
|
|
14
|
+
case "json": return JSON.stringify(result, null, 2);
|
|
15
|
+
case "llm": return formatLlm(result, path);
|
|
16
|
+
case "human": return formatHuman(result, path);
|
|
17
|
+
default: return formatDefault(result, path);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function formatDefault(result, path) {
|
|
21
|
+
if (result.success) {
|
|
22
|
+
if (result.data) return JSON.stringify(result.data);
|
|
23
|
+
return path ? `OK ${path}` : "OK";
|
|
24
|
+
}
|
|
25
|
+
return `${result.error?.code || "ERROR"} ${path || ""} ${result.error?.message || ""}`.trim();
|
|
26
|
+
}
|
|
27
|
+
function formatLlm(result, path) {
|
|
28
|
+
const lines = [];
|
|
29
|
+
if (path) lines.push(`EXEC ${path}`);
|
|
30
|
+
lines.push(`STATUS ${result.success ? "SUCCESS" : "FAILED"}`);
|
|
31
|
+
if (result.data) lines.push(`DATA ${JSON.stringify(result.data)}`);
|
|
32
|
+
if (!result.success && result.error) {
|
|
33
|
+
if (result.error.code) lines.push(`ERROR ${result.error.code}`);
|
|
34
|
+
if (result.error.message) lines.push(`MESSAGE ${result.error.message}`);
|
|
35
|
+
if (result.error.details) lines.push(`DETAILS ${JSON.stringify(result.error.details)}`);
|
|
36
|
+
}
|
|
37
|
+
return lines.join("\n");
|
|
38
|
+
}
|
|
39
|
+
function formatHuman(result, path) {
|
|
40
|
+
if (result.success) {
|
|
41
|
+
const lines$1 = path ? [`Executed: ${path}`] : ["Executed successfully"];
|
|
42
|
+
if (result.data) {
|
|
43
|
+
lines$1.push("");
|
|
44
|
+
lines$1.push(JSON.stringify(result.data, null, 2));
|
|
45
|
+
}
|
|
46
|
+
return lines$1.join("\n");
|
|
47
|
+
}
|
|
48
|
+
const lines = path ? [`Failed: ${path}`] : ["Execution failed"];
|
|
49
|
+
lines.push("");
|
|
50
|
+
if (result.error?.code) lines.push(`Error: ${result.error.code}`);
|
|
51
|
+
if (result.error?.message) lines.push(`Message: ${result.error.message}`);
|
|
52
|
+
if (result.error?.details) {
|
|
53
|
+
lines.push("Details:");
|
|
54
|
+
for (const [key, value] of Object.entries(result.error.details)) lines.push(` ${key}: ${JSON.stringify(value)}`);
|
|
55
|
+
}
|
|
56
|
+
return lines.join("\n");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
exports.formatExecOutput = formatExecOutput;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ViewType } from "../types.cjs";
|
|
2
|
+
import { AFSExecResult } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/formatters/exec.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Format exec output for different views
|
|
7
|
+
*
|
|
8
|
+
* @param result - AFS exec result (native type)
|
|
9
|
+
* @param view - View type (default, json, llm, human)
|
|
10
|
+
* @param options - Format options (path for display)
|
|
11
|
+
* @returns Formatted string (no ANSI colors)
|
|
12
|
+
*/
|
|
13
|
+
declare function formatExecOutput(result: AFSExecResult, view: ViewType, options?: {
|
|
14
|
+
path?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { formatExecOutput };
|
|
18
|
+
//# sourceMappingURL=exec.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.cts","names":[],"sources":["../../../src/core/formatters/exec.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,gBAAA,CACd,MAAA,EAAQ,aAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ViewType } from "../types.mjs";
|
|
2
|
+
import { AFSExecResult } from "@aigne/afs";
|
|
3
|
+
|
|
4
|
+
//#region src/core/formatters/exec.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Format exec output for different views
|
|
7
|
+
*
|
|
8
|
+
* @param result - AFS exec result (native type)
|
|
9
|
+
* @param view - View type (default, json, llm, human)
|
|
10
|
+
* @param options - Format options (path for display)
|
|
11
|
+
* @returns Formatted string (no ANSI colors)
|
|
12
|
+
*/
|
|
13
|
+
declare function formatExecOutput(result: AFSExecResult, view: ViewType, options?: {
|
|
14
|
+
path?: string;
|
|
15
|
+
}): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { formatExecOutput };
|
|
18
|
+
//# sourceMappingURL=exec.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.mts","names":[],"sources":["../../../src/core/formatters/exec.ts"],"mappings":";;;;;;;;;;;;iBAkBgB,gBAAA,CACd,MAAA,EAAQ,aAAA,EACR,IAAA,EAAM,QAAA,EACN,OAAA;EAAY,IAAA;AAAA"}
|