@aigne/afs-cli 1.11.0-beta.5 → 1.11.0-beta.7
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.cjs +25 -328
- package/dist/cli.d.cts +2 -1
- package/dist/cli.d.mts +2 -1
- package/dist/cli.mjs +26 -328
- package/dist/cli.mjs.map +1 -1
- package/dist/config/afs-loader.cjs +123 -0
- package/dist/config/afs-loader.d.cts +14 -0
- package/dist/config/afs-loader.d.cts.map +1 -0
- package/dist/config/afs-loader.d.mts +14 -0
- package/dist/config/afs-loader.d.mts.map +1 -0
- package/dist/config/afs-loader.mjs +122 -0
- package/dist/config/afs-loader.mjs.map +1 -0
- package/dist/config/loader.cjs +14 -3
- package/dist/config/loader.mjs +14 -3
- package/dist/config/loader.mjs.map +1 -1
- package/dist/{commands/mount.cjs → config/mount-commands.cjs} +13 -49
- package/dist/config/mount-commands.d.cts +20 -0
- package/dist/config/mount-commands.d.cts.map +1 -0
- package/dist/config/mount-commands.d.mts +20 -0
- package/dist/config/mount-commands.d.mts.map +1 -0
- package/dist/{commands/mount.mjs → config/mount-commands.mjs} +14 -49
- package/dist/config/mount-commands.mjs.map +1 -0
- package/dist/config/schema.cjs +9 -1
- package/dist/config/schema.mjs +9 -1
- 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 +95 -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 +96 -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 +139 -0
- package/dist/core/commands/mount.d.cts +33 -0
- package/dist/core/commands/mount.d.cts.map +1 -0
- package/dist/core/commands/mount.d.mts +33 -0
- package/dist/core/commands/mount.d.mts.map +1 -0
- package/dist/core/commands/mount.mjs +140 -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 +242 -0
- package/dist/core/commands/serve.d.mts +2 -0
- package/dist/core/commands/serve.mjs +242 -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 +13 -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 +14 -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/errors.cjs +0 -11
- package/dist/errors.mjs +1 -11
- package/dist/errors.mjs.map +1 -1
- package/dist/explorer/actions.cjs +113 -48
- package/dist/explorer/actions.mjs +113 -48
- package/dist/explorer/actions.mjs.map +1 -1
- package/dist/explorer/components/dialog.cjs +287 -10
- package/dist/explorer/components/dialog.mjs +287 -10
- package/dist/explorer/components/dialog.mjs.map +1 -1
- package/dist/explorer/components/file-list.mjs.map +1 -1
- package/dist/explorer/components/metadata-panel.cjs +121 -24
- package/dist/explorer/components/metadata-panel.mjs +121 -24
- package/dist/explorer/components/metadata-panel.mjs.map +1 -1
- package/dist/explorer/screen.cjs +72 -21
- 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 +73 -22
- package/dist/explorer/screen.mjs.map +1 -1
- package/dist/explorer/theme.cjs +4 -2
- package/dist/explorer/theme.mjs +4 -2
- package/dist/explorer/theme.mjs.map +1 -1
- package/dist/index.cjs +7 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +4 -1
- package/dist/mcp/http-transport.cjs +68 -0
- package/dist/mcp/http-transport.mjs +68 -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 +30 -0
- package/dist/mcp/server.mjs +30 -0
- package/dist/mcp/server.mjs.map +1 -0
- package/dist/mcp/tools.cjs +196 -0
- package/dist/mcp/tools.mjs +196 -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.cjs +2 -1
- 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/path-utils.mjs +1 -1
- package/dist/repl.cjs +485 -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 +485 -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 -49
- package/dist/ui/header.mjs +1 -47
- package/dist/ui/header.mjs.map +1 -1
- package/dist/ui/index.cjs +2 -11
- package/dist/ui/index.mjs +2 -8
- 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 +32 -9
- package/dist/commands/exec.cjs +0 -46
- package/dist/commands/exec.mjs +0 -45
- 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 -143
- package/dist/commands/ls.mjs +0 -143
- package/dist/commands/ls.mjs.map +0 -1
- package/dist/commands/mount.mjs.map +0 -1
- package/dist/commands/read.cjs +0 -65
- package/dist/commands/read.mjs +0 -64
- 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 -113
- package/dist/commands/stat.mjs +0 -112
- package/dist/commands/stat.mjs.map +0 -1
- package/dist/commands/write.cjs +0 -52
- package/dist/commands/write.mjs +0 -51
- package/dist/commands/write.mjs.map +0 -1
- package/dist/config/provider-factory.cjs +0 -93
- package/dist/config/provider-factory.mjs +0 -94
- package/dist/config/provider-factory.mjs.map +0 -1
- package/dist/config/uri-parser.cjs +0 -92
- package/dist/config/uri-parser.mjs +0 -92
- package/dist/config/uri-parser.mjs.map +0 -1
- package/dist/runtime.cjs +0 -96
- package/dist/runtime.mjs +0 -96
- package/dist/runtime.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/afs-cli",
|
|
3
|
-
"version": "1.11.0-beta.
|
|
3
|
+
"version": "1.11.0-beta.7",
|
|
4
4
|
"description": "AFS Command Line Interface",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"require": "./dist/cli.cjs",
|
|
32
32
|
"import": "./dist/cli.mjs"
|
|
33
33
|
},
|
|
34
|
+
"./core": {
|
|
35
|
+
"require": "./dist/core/index.cjs",
|
|
36
|
+
"import": "./dist/core/index.mjs"
|
|
37
|
+
},
|
|
34
38
|
"./*": "./*"
|
|
35
39
|
},
|
|
36
40
|
"files": [
|
|
@@ -40,27 +44,46 @@
|
|
|
40
44
|
"CHANGELOG.md"
|
|
41
45
|
],
|
|
42
46
|
"dependencies": {
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
43
48
|
"blessed": "^0.1.81",
|
|
44
49
|
"smol-toml": "^1.3.1",
|
|
50
|
+
"ufo": "^1.6.3",
|
|
51
|
+
"urlpattern-polyfill": "^10.1.0",
|
|
52
|
+
"yaml": "^2.8.2",
|
|
45
53
|
"yargs": "^17.7.2",
|
|
54
|
+
"yargs-parser": "^22.0.0",
|
|
46
55
|
"zod": "^3.24.1",
|
|
47
|
-
"@aigne/afs": "1.11.0-beta.
|
|
48
|
-
"@aigne/afs-
|
|
49
|
-
"@aigne/afs
|
|
50
|
-
"@aigne/afs-fs": "1.11.0-beta.
|
|
51
|
-
"@aigne/afs-
|
|
52
|
-
"@aigne/afs-
|
|
56
|
+
"@aigne/afs-dns": "1.11.0-beta.7",
|
|
57
|
+
"@aigne/afs-ec2": "1.11.0-beta.7",
|
|
58
|
+
"@aigne/afs": "1.11.0-beta.7",
|
|
59
|
+
"@aigne/afs-fs": "1.11.0-beta.7",
|
|
60
|
+
"@aigne/afs-gce": "1.11.0-beta.7",
|
|
61
|
+
"@aigne/afs-gcs": "1.11.0-beta.7",
|
|
62
|
+
"@aigne/afs-git": "1.11.0-beta.7",
|
|
63
|
+
"@aigne/afs-github": "1.11.0-beta.7",
|
|
64
|
+
"@aigne/afs-http": "1.11.0-beta.7",
|
|
65
|
+
"@aigne/afs-json": "1.11.0-beta.7",
|
|
66
|
+
"@aigne/afs-mcp": "1.11.0-beta.7",
|
|
67
|
+
"@aigne/afs-provider-registry": "1.11.0-beta.7",
|
|
68
|
+
"@aigne/afs-registry": "1.11.0-beta.7",
|
|
69
|
+
"@aigne/afs-s3": "1.11.0-beta.7",
|
|
70
|
+
"@aigne/afs-sandbox": "1.11.0-beta.7",
|
|
71
|
+
"@aigne/afs-sqlite": "1.11.0-beta.7",
|
|
72
|
+
"@aigne/afs-toml": "1.11.0-beta.7",
|
|
73
|
+
"@aigne/afs-workspace": "1.11.0-beta.7"
|
|
53
74
|
},
|
|
54
75
|
"devDependencies": {
|
|
76
|
+
"@modelcontextprotocol/server-everything": "^2026.1.26",
|
|
55
77
|
"@types/blessed": "^0.1.25",
|
|
56
78
|
"@types/bun": "^1.3.6",
|
|
57
79
|
"@types/yargs": "^17.0.33",
|
|
80
|
+
"@types/yargs-parser": "^21.0.3",
|
|
58
81
|
"npm-run-all": "^4.1.5",
|
|
59
82
|
"rimraf": "^6.1.2",
|
|
60
83
|
"tsdown": "0.20.0-beta.3",
|
|
61
84
|
"typescript": "5.9.2",
|
|
62
|
-
"@aigne/
|
|
63
|
-
"@aigne/
|
|
85
|
+
"@aigne/typescript-config": "0.0.0",
|
|
86
|
+
"@aigne/scripts": "0.0.0"
|
|
64
87
|
},
|
|
65
88
|
"scripts": {
|
|
66
89
|
"build": "tsdown",
|
package/dist/commands/exec.cjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/commands/exec.ts
|
|
3
|
-
/**
|
|
4
|
-
* Execute an action on an AFS path
|
|
5
|
-
*
|
|
6
|
-
* Note: exec is not widely implemented by providers yet.
|
|
7
|
-
* This is a placeholder for future functionality.
|
|
8
|
-
*/
|
|
9
|
-
async function execCommand(_runtime, path, _action, _params = {}) {
|
|
10
|
-
return {
|
|
11
|
-
path,
|
|
12
|
-
success: false,
|
|
13
|
-
message: "exec operation is not yet implemented"
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Format exec output for different views
|
|
18
|
-
*/
|
|
19
|
-
function formatExecOutput(result, view) {
|
|
20
|
-
switch (view) {
|
|
21
|
-
case "json": return JSON.stringify(result, null, 2);
|
|
22
|
-
case "llm": return formatLlm(result);
|
|
23
|
-
case "human": return formatHuman(result);
|
|
24
|
-
default: return formatDefault(result);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function formatDefault(result) {
|
|
28
|
-
if (result.success) return `OK ${result.path}`;
|
|
29
|
-
return `ERROR ${result.path} ${result.message}`;
|
|
30
|
-
}
|
|
31
|
-
function formatLlm(result) {
|
|
32
|
-
const lines = [];
|
|
33
|
-
lines.push(`EXEC ${result.path}`);
|
|
34
|
-
lines.push(`STATUS ${result.success ? "SUCCESS" : "FAILED"}`);
|
|
35
|
-
if (result.data) lines.push(`DATA ${JSON.stringify(result.data)}`);
|
|
36
|
-
if (result.message) lines.push(`MESSAGE ${result.message}`);
|
|
37
|
-
return lines.join("\n");
|
|
38
|
-
}
|
|
39
|
-
function formatHuman(result) {
|
|
40
|
-
if (result.success) return `Executed on ${result.path}\n${result.data ? JSON.stringify(result.data, null, 2) : ""}`;
|
|
41
|
-
return `Failed to execute on ${result.path}: ${result.message}`;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
//#endregion
|
|
45
|
-
exports.execCommand = execCommand;
|
|
46
|
-
exports.formatExecOutput = formatExecOutput;
|
package/dist/commands/exec.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
//#region src/commands/exec.ts
|
|
2
|
-
/**
|
|
3
|
-
* Execute an action on an AFS path
|
|
4
|
-
*
|
|
5
|
-
* Note: exec is not widely implemented by providers yet.
|
|
6
|
-
* This is a placeholder for future functionality.
|
|
7
|
-
*/
|
|
8
|
-
async function execCommand(_runtime, path, _action, _params = {}) {
|
|
9
|
-
return {
|
|
10
|
-
path,
|
|
11
|
-
success: false,
|
|
12
|
-
message: "exec operation is not yet implemented"
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Format exec output for different views
|
|
17
|
-
*/
|
|
18
|
-
function formatExecOutput(result, view) {
|
|
19
|
-
switch (view) {
|
|
20
|
-
case "json": return JSON.stringify(result, null, 2);
|
|
21
|
-
case "llm": return formatLlm(result);
|
|
22
|
-
case "human": return formatHuman(result);
|
|
23
|
-
default: return formatDefault(result);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function formatDefault(result) {
|
|
27
|
-
if (result.success) return `OK ${result.path}`;
|
|
28
|
-
return `ERROR ${result.path} ${result.message}`;
|
|
29
|
-
}
|
|
30
|
-
function formatLlm(result) {
|
|
31
|
-
const lines = [];
|
|
32
|
-
lines.push(`EXEC ${result.path}`);
|
|
33
|
-
lines.push(`STATUS ${result.success ? "SUCCESS" : "FAILED"}`);
|
|
34
|
-
if (result.data) lines.push(`DATA ${JSON.stringify(result.data)}`);
|
|
35
|
-
if (result.message) lines.push(`MESSAGE ${result.message}`);
|
|
36
|
-
return lines.join("\n");
|
|
37
|
-
}
|
|
38
|
-
function formatHuman(result) {
|
|
39
|
-
if (result.success) return `Executed on ${result.path}\n${result.data ? JSON.stringify(result.data, null, 2) : ""}`;
|
|
40
|
-
return `Failed to execute on ${result.path}: ${result.message}`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
export { execCommand, formatExecOutput };
|
|
45
|
-
//# sourceMappingURL=exec.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec.mjs","names":[],"sources":["../../src/commands/exec.ts"],"sourcesContent":["import type { AFSRuntime } from \"../runtime.js\";\nimport type { ViewType } from \"./ls.js\";\n\nexport interface ExecResult {\n path: string;\n success: boolean;\n data?: Record<string, unknown>;\n message?: string;\n}\n\n/**\n * Execute an action on an AFS path\n *\n * Note: exec is not widely implemented by providers yet.\n * This is a placeholder for future functionality.\n */\nexport async function execCommand(\n _runtime: AFSRuntime,\n path: string,\n _action: string,\n _params: Record<string, unknown> = {},\n): Promise<ExecResult> {\n // exec is not yet implemented in the runtime\n // This is a placeholder that returns an error\n\n return {\n path,\n success: false,\n message: \"exec operation is not yet implemented\",\n };\n}\n\n/**\n * Format exec output for different views\n */\nexport function formatExecOutput(result: ExecResult, view: ViewType): string {\n switch (view) {\n case \"json\":\n return JSON.stringify(result, null, 2);\n case \"llm\":\n return formatLlm(result);\n case \"human\":\n return formatHuman(result);\n default:\n return formatDefault(result);\n }\n}\n\nfunction formatDefault(result: ExecResult): string {\n if (result.success) {\n return `OK ${result.path}`;\n }\n return `ERROR ${result.path} ${result.message}`;\n}\n\nfunction formatLlm(result: ExecResult): string {\n const lines: string[] = [];\n\n lines.push(`EXEC ${result.path}`);\n lines.push(`STATUS ${result.success ? \"SUCCESS\" : \"FAILED\"}`);\n\n if (result.data) {\n lines.push(`DATA ${JSON.stringify(result.data)}`);\n }\n\n if (result.message) {\n lines.push(`MESSAGE ${result.message}`);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatHuman(result: ExecResult): string {\n if (result.success) {\n return `Executed on ${result.path}\\n${result.data ? JSON.stringify(result.data, null, 2) : \"\"}`;\n }\n return `Failed to execute on ${result.path}: ${result.message}`;\n}\n"],"mappings":";;;;;;;AAgBA,eAAsB,YACpB,UACA,MACA,SACA,UAAmC,EAAE,EAChB;AAIrB,QAAO;EACL;EACA,SAAS;EACT,SAAS;EACV;;;;;AAMH,SAAgB,iBAAiB,QAAoB,MAAwB;AAC3E,SAAQ,MAAR;EACE,KAAK,OACH,QAAO,KAAK,UAAU,QAAQ,MAAM,EAAE;EACxC,KAAK,MACH,QAAO,UAAU,OAAO;EAC1B,KAAK,QACH,QAAO,YAAY,OAAO;EAC5B,QACE,QAAO,cAAc,OAAO;;;AAIlC,SAAS,cAAc,QAA4B;AACjD,KAAI,OAAO,QACT,QAAO,MAAM,OAAO;AAEtB,QAAO,SAAS,OAAO,KAAK,GAAG,OAAO;;AAGxC,SAAS,UAAU,QAA4B;CAC7C,MAAM,QAAkB,EAAE;AAE1B,OAAM,KAAK,QAAQ,OAAO,OAAO;AACjC,OAAM,KAAK,UAAU,OAAO,UAAU,YAAY,WAAW;AAE7D,KAAI,OAAO,KACT,OAAM,KAAK,QAAQ,KAAK,UAAU,OAAO,KAAK,GAAG;AAGnD,KAAI,OAAO,QACT,OAAM,KAAK,WAAW,OAAO,UAAU;AAGzC,QAAO,MAAM,KAAK,KAAK;;AAGzB,SAAS,YAAY,QAA4B;AAC/C,KAAI,OAAO,QACT,QAAO,eAAe,OAAO,KAAK,IAAI,OAAO,OAAO,KAAK,UAAU,OAAO,MAAM,MAAM,EAAE,GAAG;AAE7F,QAAO,wBAAwB,OAAO,KAAK,IAAI,OAAO"}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
const require_mount = require('./mount.cjs');
|
|
2
|
-
|
|
3
|
-
//#region src/commands/explain.ts
|
|
4
|
-
/**
|
|
5
|
-
* Explain AFS concepts or current configuration
|
|
6
|
-
*/
|
|
7
|
-
async function explainCommand(cwd, topic) {
|
|
8
|
-
switch (topic) {
|
|
9
|
-
case "mount":
|
|
10
|
-
case "mounts": return explainMounts(cwd);
|
|
11
|
-
case "path":
|
|
12
|
-
case "paths": return explainPaths();
|
|
13
|
-
case "uri": return explainUri();
|
|
14
|
-
default: return explainOverview();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Explain an AFS object at a given path
|
|
19
|
-
*/
|
|
20
|
-
async function explainPathCommand(runtime, path) {
|
|
21
|
-
const entry = (await runtime.read(path)).data;
|
|
22
|
-
if (!entry) return {
|
|
23
|
-
path,
|
|
24
|
-
type: "unknown"
|
|
25
|
-
};
|
|
26
|
-
const metadata = entry.metadata || {};
|
|
27
|
-
const entryType = metadata.type || "file";
|
|
28
|
-
const result = {
|
|
29
|
-
path: entry.path,
|
|
30
|
-
type: entryType,
|
|
31
|
-
description: metadata.description,
|
|
32
|
-
metadata: {}
|
|
33
|
-
};
|
|
34
|
-
if (metadata.provider) result.metadata.provider = String(metadata.provider);
|
|
35
|
-
if (metadata.permissions) {
|
|
36
|
-
const perms = metadata.permissions;
|
|
37
|
-
result.metadata.permissions = Array.isArray(perms) ? perms.join(", ") : String(perms);
|
|
38
|
-
}
|
|
39
|
-
if (entryType === "exec") {
|
|
40
|
-
if (metadata.inputs) result.inputs = Array.isArray(metadata.inputs) ? metadata.inputs : [String(metadata.inputs)];
|
|
41
|
-
if (metadata.outputs) result.outputs = Array.isArray(metadata.outputs) ? metadata.outputs : [String(metadata.outputs)];
|
|
42
|
-
if (metadata.errors) result.errors = Array.isArray(metadata.errors) ? metadata.errors : [String(metadata.errors)];
|
|
43
|
-
if (metadata.sideEffects) result.sideEffects = Array.isArray(metadata.sideEffects) ? metadata.sideEffects : [String(metadata.sideEffects)];
|
|
44
|
-
}
|
|
45
|
-
if (Object.keys(result.metadata).length === 0) delete result.metadata;
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
function explainOverview() {
|
|
49
|
-
return {
|
|
50
|
-
topic: "AFS Overview",
|
|
51
|
-
explanation: `AFS (Abstract File System) is a virtual filesystem that unifies different data sources into a single namespace.
|
|
52
|
-
|
|
53
|
-
Core Concepts:
|
|
54
|
-
- mount: Mount a data source to a virtual path
|
|
55
|
-
- path: Virtual path, e.g., /src, /data
|
|
56
|
-
- uri: Data source address, e.g., fs://, git://, sqlite://
|
|
57
|
-
|
|
58
|
-
Data Flow:
|
|
59
|
-
User Path -> AFS -> /modules/{name} -> Provider -> Actual Data`,
|
|
60
|
-
examples: [
|
|
61
|
-
"afs mount add /src fs:///path/to/source",
|
|
62
|
-
"afs ls /modules/src",
|
|
63
|
-
"afs read /modules/src/file.txt"
|
|
64
|
-
]
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
async function explainMounts(cwd) {
|
|
68
|
-
const result = await require_mount.mountListCommand(cwd);
|
|
69
|
-
if (result.mounts.length === 0) return {
|
|
70
|
-
topic: "Mounts",
|
|
71
|
-
explanation: `No mounts configured.
|
|
72
|
-
|
|
73
|
-
Use mount add to add a mount:
|
|
74
|
-
afs mount add <path> <uri>
|
|
75
|
-
|
|
76
|
-
path: Virtual path for accessing data in AFS
|
|
77
|
-
uri: Data source URI specifying the data origin`,
|
|
78
|
-
examples: ["afs mount add /src fs:///Users/me/project", "afs mount add /data sqlite:///data.db"]
|
|
79
|
-
};
|
|
80
|
-
return {
|
|
81
|
-
topic: "Mounts",
|
|
82
|
-
explanation: `Current mount configuration:
|
|
83
|
-
|
|
84
|
-
${result.mounts.map((m) => ` ${m.path} → ${m.uri}${m.description ? ` (${m.description})` : ""}`).join("\n")}
|
|
85
|
-
|
|
86
|
-
After mounting, data is accessed via /modules/{name}:
|
|
87
|
-
path="/src" -> /modules/src`,
|
|
88
|
-
examples: result.mounts.map((m) => {
|
|
89
|
-
return `afs ls /modules/${m.path.slice(1).replace(/\//g, "-") || "root"}`;
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function explainPaths() {
|
|
94
|
-
return {
|
|
95
|
-
topic: "Paths",
|
|
96
|
-
explanation: `AFS Path Structure:
|
|
97
|
-
|
|
98
|
-
/ Root directory
|
|
99
|
-
/modules All mounted modules
|
|
100
|
-
/modules/{name} Specific module, name derived from mount path
|
|
101
|
-
|
|
102
|
-
Path Mapping:
|
|
103
|
-
config: path="/src" -> access: /modules/src
|
|
104
|
-
config: path="/data" -> access: /modules/data
|
|
105
|
-
|
|
106
|
-
Note: The path configured by user is transformed to /modules/{name}`
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function explainUri() {
|
|
110
|
-
return {
|
|
111
|
-
topic: "URI",
|
|
112
|
-
explanation: `AFS URI Schemes and Objects:
|
|
113
|
-
|
|
114
|
-
fs:// Local Filesystem Provider
|
|
115
|
-
Format: fs:///absolute/path or fs://./relative/path
|
|
116
|
-
Objects:
|
|
117
|
-
- directory: folder entries, supports list
|
|
118
|
-
- file: file entries, supports read/write
|
|
119
|
-
Operations: list, read, write, delete
|
|
120
|
-
|
|
121
|
-
git:// Git Repository Provider
|
|
122
|
-
Format: git:///local/repo or git://github.com/user/repo?branch=main
|
|
123
|
-
Objects:
|
|
124
|
-
- directory: tree entries
|
|
125
|
-
- file: blob entries, read-only
|
|
126
|
-
Operations: list, read
|
|
127
|
-
|
|
128
|
-
sqlite:// SQLite Database Provider
|
|
129
|
-
Format: sqlite:///path/to/db.sqlite
|
|
130
|
-
Objects:
|
|
131
|
-
- directory: database root, tables list
|
|
132
|
-
- exec: table entries, supports query operations
|
|
133
|
-
Operations: list, read, exec (SQL queries)
|
|
134
|
-
|
|
135
|
-
json:// JSON Data Provider
|
|
136
|
-
Format: json:///path/to/data.json
|
|
137
|
-
Objects:
|
|
138
|
-
- directory: object/array entries
|
|
139
|
-
- file: primitive values
|
|
140
|
-
Operations: list, read, write`,
|
|
141
|
-
examples: [
|
|
142
|
-
"afs mount add /src fs:///Users/me/project",
|
|
143
|
-
"afs mount add /repo git://github.com/user/repo",
|
|
144
|
-
"afs mount add /db sqlite:///data.sqlite"
|
|
145
|
-
]
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Format explain output for different views
|
|
150
|
-
*/
|
|
151
|
-
function formatExplainOutput(result, view) {
|
|
152
|
-
switch (view) {
|
|
153
|
-
case "json": return JSON.stringify(result, null, 2);
|
|
154
|
-
case "llm": return formatLlm(result);
|
|
155
|
-
default: return formatDefault(result);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function formatDefault(result) {
|
|
159
|
-
let output = `${result.topic}\n${"=".repeat(result.topic.length)}\n\n${result.explanation}`;
|
|
160
|
-
if (result.examples && result.examples.length > 0) output += `\n\nExamples:\n${result.examples.map((e) => ` $ ${e}`).join("\n")}`;
|
|
161
|
-
return output;
|
|
162
|
-
}
|
|
163
|
-
function formatLlm(result) {
|
|
164
|
-
const lines = [
|
|
165
|
-
`TOPIC ${result.topic}`,
|
|
166
|
-
"",
|
|
167
|
-
result.explanation
|
|
168
|
-
];
|
|
169
|
-
if (result.examples && result.examples.length > 0) {
|
|
170
|
-
lines.push("", "EXAMPLES");
|
|
171
|
-
for (const example of result.examples) lines.push(`CMD ${example}`);
|
|
172
|
-
}
|
|
173
|
-
return lines.join("\n");
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Format object explain output for different views
|
|
177
|
-
*/
|
|
178
|
-
function formatPathExplainOutput(result, view) {
|
|
179
|
-
switch (view) {
|
|
180
|
-
case "json": return JSON.stringify(result, null, 2);
|
|
181
|
-
case "llm": return formatPathLlm(result);
|
|
182
|
-
default: return formatPathDefault(result);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function formatPathDefault(result) {
|
|
186
|
-
const lines = [];
|
|
187
|
-
lines.push(`PATH ${result.path}`);
|
|
188
|
-
lines.push("");
|
|
189
|
-
lines.push("TYPE");
|
|
190
|
-
lines.push(result.type);
|
|
191
|
-
if (result.description) {
|
|
192
|
-
lines.push("");
|
|
193
|
-
lines.push("DESCRIPTION");
|
|
194
|
-
lines.push(result.description);
|
|
195
|
-
}
|
|
196
|
-
if (result.inputs && result.inputs.length > 0) {
|
|
197
|
-
lines.push("");
|
|
198
|
-
lines.push("INPUTS");
|
|
199
|
-
for (const input of result.inputs) lines.push(`- ${input}`);
|
|
200
|
-
}
|
|
201
|
-
if (result.outputs && result.outputs.length > 0) {
|
|
202
|
-
lines.push("");
|
|
203
|
-
lines.push("OUTPUTS");
|
|
204
|
-
for (const output of result.outputs) lines.push(`- ${output}`);
|
|
205
|
-
}
|
|
206
|
-
if (result.errors && result.errors.length > 0) {
|
|
207
|
-
lines.push("");
|
|
208
|
-
lines.push("ERRORS");
|
|
209
|
-
for (const error of result.errors) lines.push(`- ${error}`);
|
|
210
|
-
}
|
|
211
|
-
if (result.sideEffects && result.sideEffects.length > 0) {
|
|
212
|
-
lines.push("");
|
|
213
|
-
lines.push("SIDE EFFECTS");
|
|
214
|
-
for (const effect of result.sideEffects) lines.push(`- ${effect}`);
|
|
215
|
-
} else {
|
|
216
|
-
lines.push("");
|
|
217
|
-
lines.push("SIDE EFFECTS");
|
|
218
|
-
lines.push("- none");
|
|
219
|
-
}
|
|
220
|
-
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
221
|
-
lines.push("");
|
|
222
|
-
lines.push("METADATA");
|
|
223
|
-
for (const [key, value] of Object.entries(result.metadata)) lines.push(`- ${key}: ${value}`);
|
|
224
|
-
}
|
|
225
|
-
return lines.join("\n");
|
|
226
|
-
}
|
|
227
|
-
function formatPathLlm(result) {
|
|
228
|
-
const lines = [];
|
|
229
|
-
lines.push(`PATH ${result.path}`);
|
|
230
|
-
lines.push(`TYPE ${result.type.toUpperCase()}`);
|
|
231
|
-
if (result.description) lines.push(`DESC ${result.description}`);
|
|
232
|
-
if (result.inputs && result.inputs.length > 0) lines.push(`INPUTS ${result.inputs.join(", ")}`);
|
|
233
|
-
if (result.outputs && result.outputs.length > 0) lines.push(`OUTPUTS ${result.outputs.join(", ")}`);
|
|
234
|
-
if (result.errors && result.errors.length > 0) lines.push(`ERRORS ${result.errors.join(", ")}`);
|
|
235
|
-
lines.push(`SIDE_EFFECTS ${result.sideEffects?.join(", ") || "none"}`);
|
|
236
|
-
if (result.metadata) for (const [key, value] of Object.entries(result.metadata)) lines.push(`${key.toUpperCase()} ${value}`);
|
|
237
|
-
return lines.join("\n");
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
exports.explainCommand = explainCommand;
|
|
242
|
-
exports.explainPathCommand = explainPathCommand;
|
|
243
|
-
exports.formatExplainOutput = formatExplainOutput;
|
|
244
|
-
exports.formatPathExplainOutput = formatPathExplainOutput;
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { mountListCommand } from "./mount.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/commands/explain.ts
|
|
4
|
-
/**
|
|
5
|
-
* Explain AFS concepts or current configuration
|
|
6
|
-
*/
|
|
7
|
-
async function explainCommand(cwd, topic) {
|
|
8
|
-
switch (topic) {
|
|
9
|
-
case "mount":
|
|
10
|
-
case "mounts": return explainMounts(cwd);
|
|
11
|
-
case "path":
|
|
12
|
-
case "paths": return explainPaths();
|
|
13
|
-
case "uri": return explainUri();
|
|
14
|
-
default: return explainOverview();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Explain an AFS object at a given path
|
|
19
|
-
*/
|
|
20
|
-
async function explainPathCommand(runtime, path) {
|
|
21
|
-
const entry = (await runtime.read(path)).data;
|
|
22
|
-
if (!entry) return {
|
|
23
|
-
path,
|
|
24
|
-
type: "unknown"
|
|
25
|
-
};
|
|
26
|
-
const metadata = entry.metadata || {};
|
|
27
|
-
const entryType = metadata.type || "file";
|
|
28
|
-
const result = {
|
|
29
|
-
path: entry.path,
|
|
30
|
-
type: entryType,
|
|
31
|
-
description: metadata.description,
|
|
32
|
-
metadata: {}
|
|
33
|
-
};
|
|
34
|
-
if (metadata.provider) result.metadata.provider = String(metadata.provider);
|
|
35
|
-
if (metadata.permissions) {
|
|
36
|
-
const perms = metadata.permissions;
|
|
37
|
-
result.metadata.permissions = Array.isArray(perms) ? perms.join(", ") : String(perms);
|
|
38
|
-
}
|
|
39
|
-
if (entryType === "exec") {
|
|
40
|
-
if (metadata.inputs) result.inputs = Array.isArray(metadata.inputs) ? metadata.inputs : [String(metadata.inputs)];
|
|
41
|
-
if (metadata.outputs) result.outputs = Array.isArray(metadata.outputs) ? metadata.outputs : [String(metadata.outputs)];
|
|
42
|
-
if (metadata.errors) result.errors = Array.isArray(metadata.errors) ? metadata.errors : [String(metadata.errors)];
|
|
43
|
-
if (metadata.sideEffects) result.sideEffects = Array.isArray(metadata.sideEffects) ? metadata.sideEffects : [String(metadata.sideEffects)];
|
|
44
|
-
}
|
|
45
|
-
if (Object.keys(result.metadata).length === 0) delete result.metadata;
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
function explainOverview() {
|
|
49
|
-
return {
|
|
50
|
-
topic: "AFS Overview",
|
|
51
|
-
explanation: `AFS (Abstract File System) is a virtual filesystem that unifies different data sources into a single namespace.
|
|
52
|
-
|
|
53
|
-
Core Concepts:
|
|
54
|
-
- mount: Mount a data source to a virtual path
|
|
55
|
-
- path: Virtual path, e.g., /src, /data
|
|
56
|
-
- uri: Data source address, e.g., fs://, git://, sqlite://
|
|
57
|
-
|
|
58
|
-
Data Flow:
|
|
59
|
-
User Path -> AFS -> /modules/{name} -> Provider -> Actual Data`,
|
|
60
|
-
examples: [
|
|
61
|
-
"afs mount add /src fs:///path/to/source",
|
|
62
|
-
"afs ls /modules/src",
|
|
63
|
-
"afs read /modules/src/file.txt"
|
|
64
|
-
]
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
async function explainMounts(cwd) {
|
|
68
|
-
const result = await mountListCommand(cwd);
|
|
69
|
-
if (result.mounts.length === 0) return {
|
|
70
|
-
topic: "Mounts",
|
|
71
|
-
explanation: `No mounts configured.
|
|
72
|
-
|
|
73
|
-
Use mount add to add a mount:
|
|
74
|
-
afs mount add <path> <uri>
|
|
75
|
-
|
|
76
|
-
path: Virtual path for accessing data in AFS
|
|
77
|
-
uri: Data source URI specifying the data origin`,
|
|
78
|
-
examples: ["afs mount add /src fs:///Users/me/project", "afs mount add /data sqlite:///data.db"]
|
|
79
|
-
};
|
|
80
|
-
return {
|
|
81
|
-
topic: "Mounts",
|
|
82
|
-
explanation: `Current mount configuration:
|
|
83
|
-
|
|
84
|
-
${result.mounts.map((m) => ` ${m.path} → ${m.uri}${m.description ? ` (${m.description})` : ""}`).join("\n")}
|
|
85
|
-
|
|
86
|
-
After mounting, data is accessed via /modules/{name}:
|
|
87
|
-
path="/src" -> /modules/src`,
|
|
88
|
-
examples: result.mounts.map((m) => {
|
|
89
|
-
return `afs ls /modules/${m.path.slice(1).replace(/\//g, "-") || "root"}`;
|
|
90
|
-
})
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function explainPaths() {
|
|
94
|
-
return {
|
|
95
|
-
topic: "Paths",
|
|
96
|
-
explanation: `AFS Path Structure:
|
|
97
|
-
|
|
98
|
-
/ Root directory
|
|
99
|
-
/modules All mounted modules
|
|
100
|
-
/modules/{name} Specific module, name derived from mount path
|
|
101
|
-
|
|
102
|
-
Path Mapping:
|
|
103
|
-
config: path="/src" -> access: /modules/src
|
|
104
|
-
config: path="/data" -> access: /modules/data
|
|
105
|
-
|
|
106
|
-
Note: The path configured by user is transformed to /modules/{name}`
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function explainUri() {
|
|
110
|
-
return {
|
|
111
|
-
topic: "URI",
|
|
112
|
-
explanation: `AFS URI Schemes and Objects:
|
|
113
|
-
|
|
114
|
-
fs:// Local Filesystem Provider
|
|
115
|
-
Format: fs:///absolute/path or fs://./relative/path
|
|
116
|
-
Objects:
|
|
117
|
-
- directory: folder entries, supports list
|
|
118
|
-
- file: file entries, supports read/write
|
|
119
|
-
Operations: list, read, write, delete
|
|
120
|
-
|
|
121
|
-
git:// Git Repository Provider
|
|
122
|
-
Format: git:///local/repo or git://github.com/user/repo?branch=main
|
|
123
|
-
Objects:
|
|
124
|
-
- directory: tree entries
|
|
125
|
-
- file: blob entries, read-only
|
|
126
|
-
Operations: list, read
|
|
127
|
-
|
|
128
|
-
sqlite:// SQLite Database Provider
|
|
129
|
-
Format: sqlite:///path/to/db.sqlite
|
|
130
|
-
Objects:
|
|
131
|
-
- directory: database root, tables list
|
|
132
|
-
- exec: table entries, supports query operations
|
|
133
|
-
Operations: list, read, exec (SQL queries)
|
|
134
|
-
|
|
135
|
-
json:// JSON Data Provider
|
|
136
|
-
Format: json:///path/to/data.json
|
|
137
|
-
Objects:
|
|
138
|
-
- directory: object/array entries
|
|
139
|
-
- file: primitive values
|
|
140
|
-
Operations: list, read, write`,
|
|
141
|
-
examples: [
|
|
142
|
-
"afs mount add /src fs:///Users/me/project",
|
|
143
|
-
"afs mount add /repo git://github.com/user/repo",
|
|
144
|
-
"afs mount add /db sqlite:///data.sqlite"
|
|
145
|
-
]
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Format explain output for different views
|
|
150
|
-
*/
|
|
151
|
-
function formatExplainOutput(result, view) {
|
|
152
|
-
switch (view) {
|
|
153
|
-
case "json": return JSON.stringify(result, null, 2);
|
|
154
|
-
case "llm": return formatLlm(result);
|
|
155
|
-
default: return formatDefault(result);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function formatDefault(result) {
|
|
159
|
-
let output = `${result.topic}\n${"=".repeat(result.topic.length)}\n\n${result.explanation}`;
|
|
160
|
-
if (result.examples && result.examples.length > 0) output += `\n\nExamples:\n${result.examples.map((e) => ` $ ${e}`).join("\n")}`;
|
|
161
|
-
return output;
|
|
162
|
-
}
|
|
163
|
-
function formatLlm(result) {
|
|
164
|
-
const lines = [
|
|
165
|
-
`TOPIC ${result.topic}`,
|
|
166
|
-
"",
|
|
167
|
-
result.explanation
|
|
168
|
-
];
|
|
169
|
-
if (result.examples && result.examples.length > 0) {
|
|
170
|
-
lines.push("", "EXAMPLES");
|
|
171
|
-
for (const example of result.examples) lines.push(`CMD ${example}`);
|
|
172
|
-
}
|
|
173
|
-
return lines.join("\n");
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Format object explain output for different views
|
|
177
|
-
*/
|
|
178
|
-
function formatPathExplainOutput(result, view) {
|
|
179
|
-
switch (view) {
|
|
180
|
-
case "json": return JSON.stringify(result, null, 2);
|
|
181
|
-
case "llm": return formatPathLlm(result);
|
|
182
|
-
default: return formatPathDefault(result);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function formatPathDefault(result) {
|
|
186
|
-
const lines = [];
|
|
187
|
-
lines.push(`PATH ${result.path}`);
|
|
188
|
-
lines.push("");
|
|
189
|
-
lines.push("TYPE");
|
|
190
|
-
lines.push(result.type);
|
|
191
|
-
if (result.description) {
|
|
192
|
-
lines.push("");
|
|
193
|
-
lines.push("DESCRIPTION");
|
|
194
|
-
lines.push(result.description);
|
|
195
|
-
}
|
|
196
|
-
if (result.inputs && result.inputs.length > 0) {
|
|
197
|
-
lines.push("");
|
|
198
|
-
lines.push("INPUTS");
|
|
199
|
-
for (const input of result.inputs) lines.push(`- ${input}`);
|
|
200
|
-
}
|
|
201
|
-
if (result.outputs && result.outputs.length > 0) {
|
|
202
|
-
lines.push("");
|
|
203
|
-
lines.push("OUTPUTS");
|
|
204
|
-
for (const output of result.outputs) lines.push(`- ${output}`);
|
|
205
|
-
}
|
|
206
|
-
if (result.errors && result.errors.length > 0) {
|
|
207
|
-
lines.push("");
|
|
208
|
-
lines.push("ERRORS");
|
|
209
|
-
for (const error of result.errors) lines.push(`- ${error}`);
|
|
210
|
-
}
|
|
211
|
-
if (result.sideEffects && result.sideEffects.length > 0) {
|
|
212
|
-
lines.push("");
|
|
213
|
-
lines.push("SIDE EFFECTS");
|
|
214
|
-
for (const effect of result.sideEffects) lines.push(`- ${effect}`);
|
|
215
|
-
} else {
|
|
216
|
-
lines.push("");
|
|
217
|
-
lines.push("SIDE EFFECTS");
|
|
218
|
-
lines.push("- none");
|
|
219
|
-
}
|
|
220
|
-
if (result.metadata && Object.keys(result.metadata).length > 0) {
|
|
221
|
-
lines.push("");
|
|
222
|
-
lines.push("METADATA");
|
|
223
|
-
for (const [key, value] of Object.entries(result.metadata)) lines.push(`- ${key}: ${value}`);
|
|
224
|
-
}
|
|
225
|
-
return lines.join("\n");
|
|
226
|
-
}
|
|
227
|
-
function formatPathLlm(result) {
|
|
228
|
-
const lines = [];
|
|
229
|
-
lines.push(`PATH ${result.path}`);
|
|
230
|
-
lines.push(`TYPE ${result.type.toUpperCase()}`);
|
|
231
|
-
if (result.description) lines.push(`DESC ${result.description}`);
|
|
232
|
-
if (result.inputs && result.inputs.length > 0) lines.push(`INPUTS ${result.inputs.join(", ")}`);
|
|
233
|
-
if (result.outputs && result.outputs.length > 0) lines.push(`OUTPUTS ${result.outputs.join(", ")}`);
|
|
234
|
-
if (result.errors && result.errors.length > 0) lines.push(`ERRORS ${result.errors.join(", ")}`);
|
|
235
|
-
lines.push(`SIDE_EFFECTS ${result.sideEffects?.join(", ") || "none"}`);
|
|
236
|
-
if (result.metadata) for (const [key, value] of Object.entries(result.metadata)) lines.push(`${key.toUpperCase()} ${value}`);
|
|
237
|
-
return lines.join("\n");
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
export { explainCommand, explainPathCommand, formatExplainOutput, formatPathExplainOutput };
|
|
242
|
-
//# sourceMappingURL=explain.mjs.map
|