@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { formatDeleteOutput } from "./formatters/delete.mjs";
|
|
2
|
+
import { formatExecOutput } from "./formatters/exec.mjs";
|
|
3
|
+
import { formatExplainOutput } from "./formatters/explain.mjs";
|
|
4
|
+
import { formatLsOutput } from "./formatters/ls.mjs";
|
|
5
|
+
import { formatMountListOutput } from "./formatters/mount.mjs";
|
|
6
|
+
import { formatReadOutput } from "./formatters/read.mjs";
|
|
7
|
+
import { formatStatOutput } from "./formatters/stat.mjs";
|
|
8
|
+
import { formatWriteOutput } from "./formatters/write.mjs";
|
|
9
|
+
import { cliPathToCanonical, parseCliPath } from "../path-utils.mjs";
|
|
10
|
+
import "./path-utils.mjs";
|
|
11
|
+
import { createDeleteCommand } from "./commands/delete.mjs";
|
|
12
|
+
import { readStdin } from "./helpers/stdin.mjs";
|
|
13
|
+
import { RESERVED_OPTIONS, parseExecArgs, parseExecArgsWithStdin, parseValueBySchema, schemaTypeToYargs } from "./helpers/exec-args.mjs";
|
|
14
|
+
import { createExecCommand } from "./commands/exec.mjs";
|
|
15
|
+
import { createExplainCommand } from "./commands/explain.mjs";
|
|
16
|
+
import { createLsCommand } from "./commands/ls.mjs";
|
|
17
|
+
import { createMountCommand } from "./commands/mount.mjs";
|
|
18
|
+
import { createReadCommand } from "./commands/read.mjs";
|
|
19
|
+
import { createStatCommand } from "./commands/stat.mjs";
|
|
20
|
+
import { createWriteCommand } from "./commands/write.mjs";
|
|
21
|
+
import { commandFactories } from "./commands/index.mjs";
|
|
22
|
+
import { AFSCommandExecutor } from "./executor/index.mjs";
|
|
23
|
+
|
|
24
|
+
export { AFSCommandExecutor, RESERVED_OPTIONS, cliPathToCanonical, commandFactories, createDeleteCommand, createExecCommand, createExplainCommand, createLsCommand, createMountCommand, createReadCommand, createStatCommand, createWriteCommand, formatDeleteOutput, formatExecOutput, formatExplainOutput, formatLsOutput, formatMountListOutput, formatReadOutput, formatStatOutput, formatWriteOutput, parseCliPath, parseExecArgs, parseExecArgsWithStdin, parseValueBySchema, readStdin, schemaTypeToYargs };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const require_path_utils = require('../path-utils.cjs');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/core/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* CLI Core Types
|
|
4
|
+
*
|
|
5
|
+
* Minimal type definitions for the core CLI layer.
|
|
6
|
+
* Uses AFS native types (AFSListResult, AFSReadResult, etc.) directly.
|
|
7
|
+
*/
|
|
8
|
+
type ViewType = "default" | "json" | "yaml" | "llm" | "human";
|
|
9
|
+
/**
|
|
10
|
+
* Simplified JSON Schema type for CLI parameter parsing
|
|
11
|
+
*/
|
|
12
|
+
interface JSONSchema {
|
|
13
|
+
type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
|
|
14
|
+
properties?: Record<string, JSONSchema>;
|
|
15
|
+
items?: JSONSchema;
|
|
16
|
+
required?: string[];
|
|
17
|
+
description?: string;
|
|
18
|
+
default?: unknown;
|
|
19
|
+
enum?: unknown[];
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { JSONSchema, ViewType };
|
|
24
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/core/types.ts"],"mappings":";;AAWA;;;;;KAAY,QAAA;;;;UASK,UAAA;EACf,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,KAAA,GAAQ,UAAA;EACR,QAAA;EACA,WAAA;EACA,OAAA;EACA,IAAA;EAAA,CACC,GAAA;AAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/core/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* CLI Core Types
|
|
4
|
+
*
|
|
5
|
+
* Minimal type definitions for the core CLI layer.
|
|
6
|
+
* Uses AFS native types (AFSListResult, AFSReadResult, etc.) directly.
|
|
7
|
+
*/
|
|
8
|
+
type ViewType = "default" | "json" | "yaml" | "llm" | "human";
|
|
9
|
+
/**
|
|
10
|
+
* Simplified JSON Schema type for CLI parameter parsing
|
|
11
|
+
*/
|
|
12
|
+
interface JSONSchema {
|
|
13
|
+
type?: "string" | "number" | "integer" | "boolean" | "array" | "object" | "null";
|
|
14
|
+
properties?: Record<string, JSONSchema>;
|
|
15
|
+
items?: JSONSchema;
|
|
16
|
+
required?: string[];
|
|
17
|
+
description?: string;
|
|
18
|
+
default?: unknown;
|
|
19
|
+
enum?: unknown[];
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { JSONSchema, ViewType };
|
|
24
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../src/core/types.ts"],"mappings":";;AAWA;;;;;KAAY,QAAA;;;;UASK,UAAA;EACf,IAAA;EACA,UAAA,GAAa,MAAA,SAAe,UAAA;EAC5B,KAAA,GAAQ,UAAA;EACR,QAAA;EACA,WAAA;EACA,OAAA;EACA,IAAA;EAAA,CACC,GAAA;AAAA"}
|
package/dist/errors.cjs
CHANGED
|
@@ -13,17 +13,6 @@ const ExitCode = {
|
|
|
13
13
|
PARTIAL: 4,
|
|
14
14
|
RUNTIME_ERROR: 5
|
|
15
15
|
};
|
|
16
|
-
/**
|
|
17
|
-
* CLI Error with exit code
|
|
18
|
-
*/
|
|
19
|
-
var CLIError = class extends Error {
|
|
20
|
-
constructor(message, exitCode = ExitCode.RUNTIME_ERROR) {
|
|
21
|
-
super(message);
|
|
22
|
-
this.exitCode = exitCode;
|
|
23
|
-
this.name = "CLIError";
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
16
|
|
|
27
17
|
//#endregion
|
|
28
|
-
exports.CLIError = CLIError;
|
|
29
18
|
exports.ExitCode = ExitCode;
|
package/dist/errors.mjs
CHANGED
|
@@ -12,17 +12,7 @@ const ExitCode = {
|
|
|
12
12
|
PARTIAL: 4,
|
|
13
13
|
RUNTIME_ERROR: 5
|
|
14
14
|
};
|
|
15
|
-
/**
|
|
16
|
-
* CLI Error with exit code
|
|
17
|
-
*/
|
|
18
|
-
var CLIError = class extends Error {
|
|
19
|
-
constructor(message, exitCode = ExitCode.RUNTIME_ERROR) {
|
|
20
|
-
super(message);
|
|
21
|
-
this.exitCode = exitCode;
|
|
22
|
-
this.name = "CLIError";
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
15
|
|
|
26
16
|
//#endregion
|
|
27
|
-
export {
|
|
17
|
+
export { ExitCode };
|
|
28
18
|
//# sourceMappingURL=errors.mjs.map
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * AFS CLI Exit Codes\n *\n * Exit codes are part of the protocol - agents and scripts depend on them.\n */\nexport const ExitCode = {\n /** Operation successful */\n OK: 0,\n /** Path or resource not found */\n NOT_FOUND: 1,\n /** Permission denied */\n PERMISSION_DENIED: 2,\n /** Conflict (e.g., concurrent modification) */\n CONFLICT: 3,\n /** Partial success (some operations succeeded, some failed) */\n PARTIAL: 4,\n /** Runtime error */\n RUNTIME_ERROR: 5,\n} as const;\n\nexport type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];\n\n/**\n * CLI Error with exit code\n */\nexport class CLIError extends Error {\n constructor(\n message: string,\n public exitCode: ExitCodeType = ExitCode.RUNTIME_ERROR,\n ) {\n super(message);\n this.name = \"CLIError\";\n }\n}\n\n/**\n * Not found error\n */\nexport class NotFoundError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.NOT_FOUND);\n this.name = \"NotFoundError\";\n }\n}\n\n/**\n * Permission denied error\n */\nexport class PermissionDeniedError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.PERMISSION_DENIED);\n this.name = \"PermissionDeniedError\";\n }\n}\n"],"mappings":";;;;;;AAKA,MAAa,WAAW;CAEtB,IAAI;CAEJ,WAAW;CAEX,mBAAmB;CAEnB,UAAU;CAEV,SAAS;CAET,eAAe;CAChB
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * AFS CLI Exit Codes\n *\n * Exit codes are part of the protocol - agents and scripts depend on them.\n */\nexport const ExitCode = {\n /** Operation successful */\n OK: 0,\n /** Path or resource not found */\n NOT_FOUND: 1,\n /** Permission denied */\n PERMISSION_DENIED: 2,\n /** Conflict (e.g., concurrent modification) */\n CONFLICT: 3,\n /** Partial success (some operations succeeded, some failed) */\n PARTIAL: 4,\n /** Runtime error */\n RUNTIME_ERROR: 5,\n} as const;\n\nexport type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];\n\n/**\n * CLI Error with exit code\n */\nexport class CLIError extends Error {\n constructor(\n message: string,\n public exitCode: ExitCodeType = ExitCode.RUNTIME_ERROR,\n ) {\n super(message);\n this.name = \"CLIError\";\n }\n}\n\n/**\n * Not found error\n */\nexport class NotFoundError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.NOT_FOUND);\n this.name = \"NotFoundError\";\n }\n}\n\n/**\n * Permission denied error\n */\nexport class PermissionDeniedError extends CLIError {\n constructor(message: string) {\n super(message, ExitCode.PERMISSION_DENIED);\n this.name = \"PermissionDeniedError\";\n }\n}\n"],"mappings":";;;;;;AAKA,MAAa,WAAW;CAEtB,IAAI;CAEJ,WAAW;CAEX,mBAAmB;CAEnB,UAAU;CAEV,SAAS;CAET,eAAe;CAChB"}
|
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/explorer/actions.ts
|
|
3
3
|
/**
|
|
4
|
+
* Check if an entry is executable based on its meta
|
|
5
|
+
*/
|
|
6
|
+
function isExecutable(meta) {
|
|
7
|
+
if (!meta) return false;
|
|
8
|
+
if (Array.isArray(meta.kinds)) return meta.kinds.includes("afs:executable");
|
|
9
|
+
return meta.kind === "afs:executable";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Check if a value is a valid directory-indicating childrenCount
|
|
13
|
+
*
|
|
14
|
+
* Per Provider Protocol spec:
|
|
15
|
+
* - childrenCount > 0: known children → directory
|
|
16
|
+
* - childrenCount = -1: unknown children count → directory
|
|
17
|
+
* - childrenCount = 0 or undefined: leaf node → file
|
|
18
|
+
*/
|
|
19
|
+
function isDirectory(childrenCount) {
|
|
20
|
+
if (typeof childrenCount !== "number" || Number.isNaN(childrenCount)) return false;
|
|
21
|
+
return childrenCount === -1 || childrenCount > 0;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
4
24
|
* Convert AFS entry to explorer entry
|
|
25
|
+
*
|
|
26
|
+
* Type determination priority:
|
|
27
|
+
* 1. afs:executable → exec
|
|
28
|
+
* 2. afs:link → link
|
|
29
|
+
* 3. childrenCount > 0 or -1 → directory
|
|
30
|
+
* 4. Otherwise (childrenCount = 0, undefined, invalid) → file
|
|
5
31
|
*/
|
|
6
32
|
function toExplorerEntry(entry, _basePath) {
|
|
7
33
|
const name = entry.path.split("/").pop() || entry.path;
|
|
8
|
-
const metadata = entry.
|
|
9
|
-
const entryType = entry.type || metadata.type;
|
|
34
|
+
const metadata = entry.meta || {};
|
|
10
35
|
let type = "file";
|
|
11
|
-
if (
|
|
12
|
-
else if (
|
|
13
|
-
else if (
|
|
14
|
-
else if (metadata.childrenCount !== void 0 || entry.path === "/modules" || entry.path.startsWith("/modules/") && !entry.path.includes(".")) type = "directory";
|
|
36
|
+
if (isExecutable(metadata)) type = "exec";
|
|
37
|
+
else if (metadata.kind === "afs:link" || metadata.kinds?.includes("afs:link")) type = "link";
|
|
38
|
+
else if (isDirectory(metadata.childrenCount)) type = "directory";
|
|
15
39
|
return {
|
|
16
40
|
name,
|
|
17
41
|
path: entry.path,
|
|
@@ -21,7 +45,13 @@ function toExplorerEntry(entry, _basePath) {
|
|
|
21
45
|
childrenCount: metadata.childrenCount,
|
|
22
46
|
hash: metadata.hash,
|
|
23
47
|
description: metadata.description,
|
|
24
|
-
provider: metadata.provider
|
|
48
|
+
provider: metadata.provider,
|
|
49
|
+
icon: metadata.icon,
|
|
50
|
+
kind: metadata.kind,
|
|
51
|
+
kinds: Array.isArray(metadata.kinds) ? metadata.kinds : void 0,
|
|
52
|
+
label: metadata.label,
|
|
53
|
+
tags: Array.isArray(metadata.tags) ? metadata.tags : void 0,
|
|
54
|
+
actions: entry.actions
|
|
25
55
|
};
|
|
26
56
|
}
|
|
27
57
|
/**
|
|
@@ -35,20 +65,43 @@ function createUpEntry(parentPath) {
|
|
|
35
65
|
};
|
|
36
66
|
}
|
|
37
67
|
/**
|
|
68
|
+
* Build immediate children from a list of deep paths
|
|
69
|
+
* For example, if path is "/" and entries contain "/github/ArcBlock/afs",
|
|
70
|
+
* this returns a virtual directory entry for "/github"
|
|
71
|
+
*/
|
|
72
|
+
function buildImmediateChildren(path, afsEntries) {
|
|
73
|
+
const normalizedPath = path === "/" ? "" : path;
|
|
74
|
+
const pathDepth = normalizedPath === "" ? 0 : normalizedPath.split("/").filter(Boolean).length;
|
|
75
|
+
const childrenMap = /* @__PURE__ */ new Map();
|
|
76
|
+
for (const entry of afsEntries) {
|
|
77
|
+
if (entry.path === path) continue;
|
|
78
|
+
const entryParts = entry.path.split("/").filter(Boolean);
|
|
79
|
+
const childName = entryParts[pathDepth];
|
|
80
|
+
if (!childName) continue;
|
|
81
|
+
const childPath = `/${entryParts.slice(0, pathDepth + 1).join("/")}`;
|
|
82
|
+
if (entryParts.length === pathDepth + 1) childrenMap.set(childName, toExplorerEntry(entry, path));
|
|
83
|
+
else if (!childrenMap.has(childName)) childrenMap.set(childName, {
|
|
84
|
+
name: childName,
|
|
85
|
+
path: childPath,
|
|
86
|
+
type: "directory",
|
|
87
|
+
childrenCount: -1
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return childrenMap;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
38
93
|
* Load directory entries from AFS
|
|
39
94
|
*/
|
|
40
|
-
async function loadDirectory(
|
|
95
|
+
async function loadDirectory(afs, path) {
|
|
41
96
|
try {
|
|
42
|
-
const result = await
|
|
97
|
+
const result = await afs.list(path, { maxDepth: 1 });
|
|
43
98
|
const entries = [];
|
|
44
99
|
if (path !== "/") {
|
|
45
100
|
const parentPath = path.split("/").slice(0, -1).join("/") || "/";
|
|
46
101
|
entries.push(createUpEntry(parentPath));
|
|
47
102
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
entries.push(toExplorerEntry(entry, path));
|
|
51
|
-
}
|
|
103
|
+
const childrenMap = buildImmediateChildren(path, result.data);
|
|
104
|
+
entries.push(...childrenMap.values());
|
|
52
105
|
entries.sort((a, b) => {
|
|
53
106
|
if (a.type === "up") return -1;
|
|
54
107
|
if (b.type === "up") return 1;
|
|
@@ -67,37 +120,35 @@ async function loadDirectory(runtime, path) {
|
|
|
67
120
|
}
|
|
68
121
|
}
|
|
69
122
|
/**
|
|
70
|
-
* Load metadata for an entry
|
|
123
|
+
* Load metadata for an entry using stat() to get enriched data (including actions)
|
|
71
124
|
*/
|
|
72
|
-
async function loadMetadata(
|
|
125
|
+
async function loadMetadata(afs, entry) {
|
|
73
126
|
if (entry.type === "up") return;
|
|
74
127
|
try {
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
128
|
+
const data = (await afs.stat(entry.path)).data;
|
|
129
|
+
if (!data) return {
|
|
77
130
|
path: entry.path,
|
|
78
|
-
type: entry.type,
|
|
79
131
|
size: entry.size,
|
|
80
132
|
modified: entry.modified
|
|
81
133
|
};
|
|
82
|
-
const
|
|
134
|
+
const meta = data.meta || {};
|
|
83
135
|
return {
|
|
84
136
|
path: entry.path,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
extra:
|
|
137
|
+
size: meta.size,
|
|
138
|
+
modified: data.updatedAt instanceof Date ? data.updatedAt : void 0,
|
|
139
|
+
childrenCount: meta.childrenCount,
|
|
140
|
+
hash: meta.hash,
|
|
141
|
+
description: meta.description,
|
|
142
|
+
provider: meta.provider,
|
|
143
|
+
mountPath: meta.mountPath,
|
|
144
|
+
uri: meta.uri,
|
|
145
|
+
permissions: meta.permissions,
|
|
146
|
+
actions: data.actions,
|
|
147
|
+
extra: meta
|
|
96
148
|
};
|
|
97
149
|
} catch {
|
|
98
150
|
return {
|
|
99
151
|
path: entry.path,
|
|
100
|
-
type: entry.type,
|
|
101
152
|
size: entry.size,
|
|
102
153
|
modified: entry.modified
|
|
103
154
|
};
|
|
@@ -106,20 +157,17 @@ async function loadMetadata(runtime, entry) {
|
|
|
106
157
|
/**
|
|
107
158
|
* Get explain output for an entry
|
|
108
159
|
*/
|
|
109
|
-
async function getExplain(
|
|
160
|
+
async function getExplain(afs, path) {
|
|
110
161
|
try {
|
|
111
|
-
const entry = (await
|
|
162
|
+
const entry = (await afs.list(path, { maxDepth: 0 })).data[0];
|
|
112
163
|
if (!entry) return {
|
|
113
164
|
content: "",
|
|
114
165
|
error: "Entry not found"
|
|
115
166
|
};
|
|
116
|
-
const metadata = entry.
|
|
167
|
+
const metadata = entry.meta || {};
|
|
117
168
|
const lines = [];
|
|
118
169
|
lines.push(`OBJECT ${path}`);
|
|
119
170
|
lines.push("");
|
|
120
|
-
lines.push("TYPE");
|
|
121
|
-
lines.push(metadata.type || "unknown");
|
|
122
|
-
lines.push("");
|
|
123
171
|
if (metadata.description) {
|
|
124
172
|
lines.push("DESCRIPTION");
|
|
125
173
|
lines.push(metadata.description);
|
|
@@ -156,31 +204,48 @@ async function getExplain(runtime, path) {
|
|
|
156
204
|
/**
|
|
157
205
|
* Execute an action on an entry
|
|
158
206
|
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
207
|
+
* For executable entries (kinds includes "afs:executable"), this calls
|
|
208
|
+
* the underlying exec command. The action parameter is currently not used
|
|
209
|
+
* but reserved for future action selection.
|
|
161
210
|
*/
|
|
162
|
-
async function executeAction(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
211
|
+
async function executeAction(afs, path, _action, params) {
|
|
212
|
+
try {
|
|
213
|
+
const result = await afs.exec(path, params || {}, {});
|
|
214
|
+
return {
|
|
215
|
+
success: result.success,
|
|
216
|
+
message: result.error?.message,
|
|
217
|
+
data: result.data
|
|
218
|
+
};
|
|
219
|
+
} catch (error) {
|
|
220
|
+
return {
|
|
221
|
+
success: false,
|
|
222
|
+
message: error instanceof Error ? error.message : String(error)
|
|
223
|
+
};
|
|
224
|
+
}
|
|
167
225
|
}
|
|
168
226
|
/**
|
|
169
227
|
* Read file content
|
|
170
228
|
*/
|
|
171
|
-
async function readFileContent(
|
|
229
|
+
async function readFileContent(afs, path) {
|
|
172
230
|
try {
|
|
173
|
-
const entry = (await
|
|
231
|
+
const entry = (await afs.read(path)).data;
|
|
174
232
|
if (!entry) return {
|
|
175
233
|
content: "",
|
|
176
234
|
error: "File not found"
|
|
177
235
|
};
|
|
178
236
|
const rawContent = entry.content;
|
|
179
|
-
if (rawContent === void 0) return {
|
|
237
|
+
if (rawContent === void 0 || rawContent === null) return {
|
|
180
238
|
content: "",
|
|
181
239
|
error: "No content available"
|
|
182
240
|
};
|
|
183
|
-
|
|
241
|
+
let content;
|
|
242
|
+
if (typeof rawContent === "string") content = rawContent;
|
|
243
|
+
else if (Buffer.isBuffer(rawContent)) content = rawContent.toString("utf-8");
|
|
244
|
+
else if (rawContent instanceof Uint8Array) content = Buffer.from(rawContent).toString("utf-8");
|
|
245
|
+
else if (rawContent instanceof ArrayBuffer) content = Buffer.from(new Uint8Array(rawContent)).toString("utf-8");
|
|
246
|
+
else if (typeof rawContent === "object") content = JSON.stringify(rawContent, null, 2);
|
|
247
|
+
else content = String(rawContent);
|
|
248
|
+
return { content };
|
|
184
249
|
} catch (error) {
|
|
185
250
|
return {
|
|
186
251
|
content: "",
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
//#region src/explorer/actions.ts
|
|
2
2
|
/**
|
|
3
|
+
* Check if an entry is executable based on its meta
|
|
4
|
+
*/
|
|
5
|
+
function isExecutable(meta) {
|
|
6
|
+
if (!meta) return false;
|
|
7
|
+
if (Array.isArray(meta.kinds)) return meta.kinds.includes("afs:executable");
|
|
8
|
+
return meta.kind === "afs:executable";
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Check if a value is a valid directory-indicating childrenCount
|
|
12
|
+
*
|
|
13
|
+
* Per Provider Protocol spec:
|
|
14
|
+
* - childrenCount > 0: known children → directory
|
|
15
|
+
* - childrenCount = -1: unknown children count → directory
|
|
16
|
+
* - childrenCount = 0 or undefined: leaf node → file
|
|
17
|
+
*/
|
|
18
|
+
function isDirectory(childrenCount) {
|
|
19
|
+
if (typeof childrenCount !== "number" || Number.isNaN(childrenCount)) return false;
|
|
20
|
+
return childrenCount === -1 || childrenCount > 0;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
3
23
|
* Convert AFS entry to explorer entry
|
|
24
|
+
*
|
|
25
|
+
* Type determination priority:
|
|
26
|
+
* 1. afs:executable → exec
|
|
27
|
+
* 2. afs:link → link
|
|
28
|
+
* 3. childrenCount > 0 or -1 → directory
|
|
29
|
+
* 4. Otherwise (childrenCount = 0, undefined, invalid) → file
|
|
4
30
|
*/
|
|
5
31
|
function toExplorerEntry(entry, _basePath) {
|
|
6
32
|
const name = entry.path.split("/").pop() || entry.path;
|
|
7
|
-
const metadata = entry.
|
|
8
|
-
const entryType = entry.type || metadata.type;
|
|
33
|
+
const metadata = entry.meta || {};
|
|
9
34
|
let type = "file";
|
|
10
|
-
if (
|
|
11
|
-
else if (
|
|
12
|
-
else if (
|
|
13
|
-
else if (metadata.childrenCount !== void 0 || entry.path === "/modules" || entry.path.startsWith("/modules/") && !entry.path.includes(".")) type = "directory";
|
|
35
|
+
if (isExecutable(metadata)) type = "exec";
|
|
36
|
+
else if (metadata.kind === "afs:link" || metadata.kinds?.includes("afs:link")) type = "link";
|
|
37
|
+
else if (isDirectory(metadata.childrenCount)) type = "directory";
|
|
14
38
|
return {
|
|
15
39
|
name,
|
|
16
40
|
path: entry.path,
|
|
@@ -20,7 +44,13 @@ function toExplorerEntry(entry, _basePath) {
|
|
|
20
44
|
childrenCount: metadata.childrenCount,
|
|
21
45
|
hash: metadata.hash,
|
|
22
46
|
description: metadata.description,
|
|
23
|
-
provider: metadata.provider
|
|
47
|
+
provider: metadata.provider,
|
|
48
|
+
icon: metadata.icon,
|
|
49
|
+
kind: metadata.kind,
|
|
50
|
+
kinds: Array.isArray(metadata.kinds) ? metadata.kinds : void 0,
|
|
51
|
+
label: metadata.label,
|
|
52
|
+
tags: Array.isArray(metadata.tags) ? metadata.tags : void 0,
|
|
53
|
+
actions: entry.actions
|
|
24
54
|
};
|
|
25
55
|
}
|
|
26
56
|
/**
|
|
@@ -34,20 +64,43 @@ function createUpEntry(parentPath) {
|
|
|
34
64
|
};
|
|
35
65
|
}
|
|
36
66
|
/**
|
|
67
|
+
* Build immediate children from a list of deep paths
|
|
68
|
+
* For example, if path is "/" and entries contain "/github/ArcBlock/afs",
|
|
69
|
+
* this returns a virtual directory entry for "/github"
|
|
70
|
+
*/
|
|
71
|
+
function buildImmediateChildren(path, afsEntries) {
|
|
72
|
+
const normalizedPath = path === "/" ? "" : path;
|
|
73
|
+
const pathDepth = normalizedPath === "" ? 0 : normalizedPath.split("/").filter(Boolean).length;
|
|
74
|
+
const childrenMap = /* @__PURE__ */ new Map();
|
|
75
|
+
for (const entry of afsEntries) {
|
|
76
|
+
if (entry.path === path) continue;
|
|
77
|
+
const entryParts = entry.path.split("/").filter(Boolean);
|
|
78
|
+
const childName = entryParts[pathDepth];
|
|
79
|
+
if (!childName) continue;
|
|
80
|
+
const childPath = `/${entryParts.slice(0, pathDepth + 1).join("/")}`;
|
|
81
|
+
if (entryParts.length === pathDepth + 1) childrenMap.set(childName, toExplorerEntry(entry, path));
|
|
82
|
+
else if (!childrenMap.has(childName)) childrenMap.set(childName, {
|
|
83
|
+
name: childName,
|
|
84
|
+
path: childPath,
|
|
85
|
+
type: "directory",
|
|
86
|
+
childrenCount: -1
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return childrenMap;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
37
92
|
* Load directory entries from AFS
|
|
38
93
|
*/
|
|
39
|
-
async function loadDirectory(
|
|
94
|
+
async function loadDirectory(afs, path) {
|
|
40
95
|
try {
|
|
41
|
-
const result = await
|
|
96
|
+
const result = await afs.list(path, { maxDepth: 1 });
|
|
42
97
|
const entries = [];
|
|
43
98
|
if (path !== "/") {
|
|
44
99
|
const parentPath = path.split("/").slice(0, -1).join("/") || "/";
|
|
45
100
|
entries.push(createUpEntry(parentPath));
|
|
46
101
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
entries.push(toExplorerEntry(entry, path));
|
|
50
|
-
}
|
|
102
|
+
const childrenMap = buildImmediateChildren(path, result.data);
|
|
103
|
+
entries.push(...childrenMap.values());
|
|
51
104
|
entries.sort((a, b) => {
|
|
52
105
|
if (a.type === "up") return -1;
|
|
53
106
|
if (b.type === "up") return 1;
|
|
@@ -66,37 +119,35 @@ async function loadDirectory(runtime, path) {
|
|
|
66
119
|
}
|
|
67
120
|
}
|
|
68
121
|
/**
|
|
69
|
-
* Load metadata for an entry
|
|
122
|
+
* Load metadata for an entry using stat() to get enriched data (including actions)
|
|
70
123
|
*/
|
|
71
|
-
async function loadMetadata(
|
|
124
|
+
async function loadMetadata(afs, entry) {
|
|
72
125
|
if (entry.type === "up") return;
|
|
73
126
|
try {
|
|
74
|
-
const
|
|
75
|
-
if (!
|
|
127
|
+
const data = (await afs.stat(entry.path)).data;
|
|
128
|
+
if (!data) return {
|
|
76
129
|
path: entry.path,
|
|
77
|
-
type: entry.type,
|
|
78
130
|
size: entry.size,
|
|
79
131
|
modified: entry.modified
|
|
80
132
|
};
|
|
81
|
-
const
|
|
133
|
+
const meta = data.meta || {};
|
|
82
134
|
return {
|
|
83
135
|
path: entry.path,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
extra:
|
|
136
|
+
size: meta.size,
|
|
137
|
+
modified: data.updatedAt instanceof Date ? data.updatedAt : void 0,
|
|
138
|
+
childrenCount: meta.childrenCount,
|
|
139
|
+
hash: meta.hash,
|
|
140
|
+
description: meta.description,
|
|
141
|
+
provider: meta.provider,
|
|
142
|
+
mountPath: meta.mountPath,
|
|
143
|
+
uri: meta.uri,
|
|
144
|
+
permissions: meta.permissions,
|
|
145
|
+
actions: data.actions,
|
|
146
|
+
extra: meta
|
|
95
147
|
};
|
|
96
148
|
} catch {
|
|
97
149
|
return {
|
|
98
150
|
path: entry.path,
|
|
99
|
-
type: entry.type,
|
|
100
151
|
size: entry.size,
|
|
101
152
|
modified: entry.modified
|
|
102
153
|
};
|
|
@@ -105,20 +156,17 @@ async function loadMetadata(runtime, entry) {
|
|
|
105
156
|
/**
|
|
106
157
|
* Get explain output for an entry
|
|
107
158
|
*/
|
|
108
|
-
async function getExplain(
|
|
159
|
+
async function getExplain(afs, path) {
|
|
109
160
|
try {
|
|
110
|
-
const entry = (await
|
|
161
|
+
const entry = (await afs.list(path, { maxDepth: 0 })).data[0];
|
|
111
162
|
if (!entry) return {
|
|
112
163
|
content: "",
|
|
113
164
|
error: "Entry not found"
|
|
114
165
|
};
|
|
115
|
-
const metadata = entry.
|
|
166
|
+
const metadata = entry.meta || {};
|
|
116
167
|
const lines = [];
|
|
117
168
|
lines.push(`OBJECT ${path}`);
|
|
118
169
|
lines.push("");
|
|
119
|
-
lines.push("TYPE");
|
|
120
|
-
lines.push(metadata.type || "unknown");
|
|
121
|
-
lines.push("");
|
|
122
170
|
if (metadata.description) {
|
|
123
171
|
lines.push("DESCRIPTION");
|
|
124
172
|
lines.push(metadata.description);
|
|
@@ -155,31 +203,48 @@ async function getExplain(runtime, path) {
|
|
|
155
203
|
/**
|
|
156
204
|
* Execute an action on an entry
|
|
157
205
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
206
|
+
* For executable entries (kinds includes "afs:executable"), this calls
|
|
207
|
+
* the underlying exec command. The action parameter is currently not used
|
|
208
|
+
* but reserved for future action selection.
|
|
160
209
|
*/
|
|
161
|
-
async function executeAction(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
210
|
+
async function executeAction(afs, path, _action, params) {
|
|
211
|
+
try {
|
|
212
|
+
const result = await afs.exec(path, params || {}, {});
|
|
213
|
+
return {
|
|
214
|
+
success: result.success,
|
|
215
|
+
message: result.error?.message,
|
|
216
|
+
data: result.data
|
|
217
|
+
};
|
|
218
|
+
} catch (error) {
|
|
219
|
+
return {
|
|
220
|
+
success: false,
|
|
221
|
+
message: error instanceof Error ? error.message : String(error)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
166
224
|
}
|
|
167
225
|
/**
|
|
168
226
|
* Read file content
|
|
169
227
|
*/
|
|
170
|
-
async function readFileContent(
|
|
228
|
+
async function readFileContent(afs, path) {
|
|
171
229
|
try {
|
|
172
|
-
const entry = (await
|
|
230
|
+
const entry = (await afs.read(path)).data;
|
|
173
231
|
if (!entry) return {
|
|
174
232
|
content: "",
|
|
175
233
|
error: "File not found"
|
|
176
234
|
};
|
|
177
235
|
const rawContent = entry.content;
|
|
178
|
-
if (rawContent === void 0) return {
|
|
236
|
+
if (rawContent === void 0 || rawContent === null) return {
|
|
179
237
|
content: "",
|
|
180
238
|
error: "No content available"
|
|
181
239
|
};
|
|
182
|
-
|
|
240
|
+
let content;
|
|
241
|
+
if (typeof rawContent === "string") content = rawContent;
|
|
242
|
+
else if (Buffer.isBuffer(rawContent)) content = rawContent.toString("utf-8");
|
|
243
|
+
else if (rawContent instanceof Uint8Array) content = Buffer.from(rawContent).toString("utf-8");
|
|
244
|
+
else if (rawContent instanceof ArrayBuffer) content = Buffer.from(new Uint8Array(rawContent)).toString("utf-8");
|
|
245
|
+
else if (typeof rawContent === "object") content = JSON.stringify(rawContent, null, 2);
|
|
246
|
+
else content = String(rawContent);
|
|
247
|
+
return { content };
|
|
183
248
|
} catch (error) {
|
|
184
249
|
return {
|
|
185
250
|
content: "",
|