@aigne/afs-cli 1.11.0-beta.1 → 1.11.0-beta.2

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.
Files changed (70) hide show
  1. package/README.md +13 -9
  2. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  3. package/dist/cli.cjs +215 -0
  4. package/dist/cli.d.cts +1 -0
  5. package/dist/cli.mjs +205 -19
  6. package/dist/cli.mjs.map +1 -0
  7. package/dist/commands/exec.cjs +46 -0
  8. package/dist/commands/exec.mjs +45 -0
  9. package/dist/commands/exec.mjs.map +1 -0
  10. package/dist/commands/explain.cjs +244 -0
  11. package/dist/commands/explain.mjs +242 -0
  12. package/dist/commands/explain.mjs.map +1 -0
  13. package/dist/commands/index.cjs +7 -0
  14. package/dist/commands/index.mjs +9 -0
  15. package/dist/commands/ls.cjs +136 -0
  16. package/dist/commands/ls.mjs +135 -0
  17. package/dist/commands/ls.mjs.map +1 -0
  18. package/dist/commands/mount.cjs +157 -0
  19. package/dist/commands/mount.mjs +153 -0
  20. package/dist/commands/mount.mjs.map +1 -0
  21. package/dist/commands/read.cjs +65 -0
  22. package/dist/commands/read.mjs +64 -0
  23. package/dist/commands/read.mjs.map +1 -0
  24. package/dist/commands/stat.cjs +113 -0
  25. package/dist/commands/stat.mjs +112 -0
  26. package/dist/commands/stat.mjs.map +1 -0
  27. package/dist/commands/write.cjs +52 -0
  28. package/dist/commands/write.mjs +51 -0
  29. package/dist/commands/write.mjs.map +1 -0
  30. package/dist/config/env.cjs +46 -0
  31. package/dist/config/env.mjs +46 -0
  32. package/dist/config/env.mjs.map +1 -0
  33. package/dist/config/loader.cjs +160 -0
  34. package/dist/config/loader.mjs +158 -0
  35. package/dist/config/loader.mjs.map +1 -0
  36. package/dist/config/provider-factory.cjs +74 -0
  37. package/dist/config/provider-factory.mjs +75 -0
  38. package/dist/config/provider-factory.mjs.map +1 -0
  39. package/dist/config/schema.cjs +22 -0
  40. package/dist/config/schema.mjs +22 -0
  41. package/dist/config/schema.mjs.map +1 -0
  42. package/dist/config/uri-parser.cjs +75 -0
  43. package/dist/config/uri-parser.mjs +75 -0
  44. package/dist/config/uri-parser.mjs.map +1 -0
  45. package/dist/errors.cjs +29 -0
  46. package/dist/errors.mjs +28 -0
  47. package/dist/errors.mjs.map +1 -0
  48. package/dist/index.cjs +3 -0
  49. package/dist/index.d.cts +2 -0
  50. package/dist/index.d.mts +1 -3
  51. package/dist/index.mjs +1 -1
  52. package/dist/runtime.cjs +82 -0
  53. package/dist/runtime.mjs +82 -0
  54. package/dist/runtime.mjs.map +1 -0
  55. package/dist/version.cjs +9 -0
  56. package/dist/version.d.cts +5 -0
  57. package/dist/version.d.cts.map +1 -0
  58. package/dist/version.d.mts +5 -0
  59. package/dist/version.d.mts.map +1 -0
  60. package/dist/version.mjs +9 -0
  61. package/dist/version.mjs.map +1 -0
  62. package/package.json +51 -11
  63. package/.turbo/turbo-build.log +0 -18
  64. package/.turbo/turbo-check-types.log +0 -4
  65. package/dist/version--p6A8sKX.mjs +0 -5
  66. package/src/cli.test.ts +0 -8
  67. package/src/cli.ts +0 -29
  68. package/src/index.ts +0 -7
  69. package/src/version.ts +0 -1
  70. package/tsconfig.json +0 -16
package/README.md CHANGED
@@ -6,27 +6,31 @@ AFS 命令行工具
6
6
 
7
7
  | 命令 | 功能 |
8
8
  |------|------|
9
- | `afs ls [path]` | 列出目录内容 |
10
- | `afs cat <path>` | 读取文件内容 |
11
- | `afs write <path>` | 写入文件 |
12
- | `afs search <path> <pattern>` | 搜索内容 |
9
+ | `afs list [path]` (别名: `ls`) | 列出目录内容 |
10
+ | `afs read <path>` | 读取文件内容 |
11
+ | `afs write <path> [--content]` | 写入文件 (--content 或 stdin) |
12
+ | `afs stat <path>` | 获取文件/目录信息 |
13
13
  | `afs exec <path> <action>` | 执行操作 |
14
- | `afs explain <path>` | 语义解释 |
14
+ | `afs mount list` (别名: `ls`) | 列出挂载配置 |
15
+ | `afs mount add <path> <uri>` | 添加挂载 |
16
+ | `afs mount remove <path>` (别名: `rm`) | 移除挂载 |
17
+ | `afs mount validate` | 验证挂载配置 |
18
+ | `afs explain [topic]` | 解释概念 (mount, uri, /path) |
15
19
 
16
20
  ## 输出模式
17
21
 
18
22
  ```bash
19
23
  # 默认: Machine Truth (LLM/脚本友好)
20
- afs ls /modules/local-fs
24
+ afs list /modules/fs
21
25
 
22
26
  # JSON 结构化输出
23
- afs ls /modules/local-fs --json
27
+ afs list /modules/fs --json
24
28
 
25
29
  # LLM 优化输出
26
- afs ls /modules/local-fs --view=llm
30
+ afs list /modules/fs --view=llm
27
31
 
28
32
  # 人类友好输出
29
- afs ls /modules/local-fs --view=human
33
+ afs list /modules/fs --view=human
30
34
  ```
31
35
 
32
36
  ## 运行模式
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
package/dist/cli.cjs ADDED
@@ -0,0 +1,215 @@
1
+ #!/usr/bin/env node
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_version = require('./version.cjs');
4
+ const require_exec = require('./commands/exec.cjs');
5
+ const require_mount = require('./commands/mount.cjs');
6
+ const require_explain = require('./commands/explain.cjs');
7
+ const require_ls = require('./commands/ls.cjs');
8
+ const require_read = require('./commands/read.cjs');
9
+ const require_stat = require('./commands/stat.cjs');
10
+ const require_write = require('./commands/write.cjs');
11
+ require('./commands/index.cjs');
12
+ const require_errors = require('./errors.cjs');
13
+ const require_runtime = require('./runtime.cjs');
14
+ let yargs = require("yargs");
15
+ yargs = require_rolldown_runtime.__toESM(yargs);
16
+ let yargs_helpers = require("yargs/helpers");
17
+
18
+ //#region src/cli.ts
19
+ /**
20
+ * AFS CLI - Command Line Interface
21
+ *
22
+ * Commands:
23
+ * - afs mount list|ls List mount configurations
24
+ * - afs mount add <path> <uri> Add a mount
25
+ * - afs mount remove|rm <path> Remove a mount
26
+ * - afs mount validate Validate mount configuration
27
+ * - afs list|ls [path] List directory
28
+ * - afs stat <path> Get file/directory info
29
+ * - afs read <path> Read file content
30
+ * - afs write <path> Write file content (--content or stdin)
31
+ * - afs exec <path> <action> Execute operation
32
+ *
33
+ * Output modes:
34
+ * - Default: Machine Truth (LLM/script friendly)
35
+ * - --json: Structured JSON
36
+ * - --view=llm: LLM optimized output
37
+ * - --view=human: Human friendly format
38
+ */
39
+ function getViewType(argv) {
40
+ if (argv.json) return "json";
41
+ if (argv.view) return argv.view;
42
+ return "default";
43
+ }
44
+ async function main() {
45
+ const cli = (0, yargs.default)((0, yargs_helpers.hideBin)(process.argv)).scriptName("afs").version(require_version.VERSION).alias("version", "V").help("help").alias("help", "h").usage("$0 <command> [options]").option("json", {
46
+ type: "boolean",
47
+ description: "Output in JSON format",
48
+ global: true
49
+ }).option("view", {
50
+ type: "string",
51
+ choices: [
52
+ "default",
53
+ "llm",
54
+ "human"
55
+ ],
56
+ description: "Output view format",
57
+ global: true
58
+ }).command(["list [path]", "ls [path]"], "List directory contents", (yargs$2) => yargs$2.positional("path", {
59
+ type: "string",
60
+ default: "/",
61
+ description: "Path to list"
62
+ }).option("depth", {
63
+ type: "number",
64
+ default: 1,
65
+ description: "Maximum depth to list"
66
+ }).option("limit", {
67
+ alias: "n",
68
+ type: "number",
69
+ description: "Maximum number of entries to return"
70
+ }).option("max-children", {
71
+ type: "number",
72
+ description: "Maximum children per directory"
73
+ }).option("pattern", {
74
+ alias: "p",
75
+ type: "string",
76
+ description: "Glob pattern to filter entries (e.g., *.ts, **/*.js)"
77
+ }), async (argv) => {
78
+ const result = await require_ls.lsCommand(await require_runtime.createRuntime(), argv.path, {
79
+ maxDepth: argv.depth,
80
+ limit: argv.limit,
81
+ maxChildren: argv["max-children"],
82
+ pattern: argv.pattern
83
+ });
84
+ const view = getViewType(argv);
85
+ console.log(require_ls.formatLsOutput(result, view));
86
+ }).command("stat <path>", "Get file or directory info", (yargs$2) => yargs$2.positional("path", {
87
+ type: "string",
88
+ demandOption: true,
89
+ description: "Path to stat"
90
+ }), async (argv) => {
91
+ const result = await require_stat.statCommand(await require_runtime.createRuntime(), argv.path);
92
+ const view = getViewType(argv);
93
+ console.log(require_stat.formatStatOutput(result, view));
94
+ }).command("read <path>", "Read file content", (yargs$2) => yargs$2.positional("path", {
95
+ type: "string",
96
+ demandOption: true,
97
+ description: "Path to read"
98
+ }), async (argv) => {
99
+ const result = await require_read.readCommand(await require_runtime.createRuntime(), argv.path);
100
+ const view = getViewType(argv);
101
+ console.log(require_read.formatReadOutput(result, view));
102
+ }).command("write <path>", "Write content to file (from --content or stdin)", (yargs$2) => yargs$2.positional("path", {
103
+ type: "string",
104
+ demandOption: true,
105
+ description: "Path to write"
106
+ }).option("content", {
107
+ type: "string",
108
+ description: "Content to write (if not provided, reads from stdin)"
109
+ }).option("append", {
110
+ type: "boolean",
111
+ default: false,
112
+ description: "Append to file instead of overwrite"
113
+ }), async (argv) => {
114
+ let content;
115
+ if (argv.content !== void 0) content = argv.content;
116
+ else {
117
+ const chunks = [];
118
+ for await (const chunk of process.stdin) chunks.push(chunk);
119
+ content = Buffer.concat(chunks).toString("utf-8");
120
+ }
121
+ const result = await require_write.writeCommand(await require_runtime.createRuntime(), argv.path, content, { append: argv.append });
122
+ const view = getViewType(argv);
123
+ console.log(require_write.formatWriteOutput(result, view));
124
+ if (!result.success) process.exit(require_errors.ExitCode.RUNTIME_ERROR);
125
+ }).command("exec <path> [action]", "Execute operation on path", (yargs$2) => yargs$2.positional("path", {
126
+ type: "string",
127
+ demandOption: true,
128
+ description: "Path to execute on"
129
+ }).positional("action", {
130
+ type: "string",
131
+ default: "default",
132
+ description: "Action to execute"
133
+ }).option("params", {
134
+ type: "string",
135
+ description: "JSON parameters for the action"
136
+ }), async (argv) => {
137
+ const params = argv.params ? JSON.parse(argv.params) : {};
138
+ const result = await require_exec.execCommand(await require_runtime.createRuntime(), argv.path, argv.action, params);
139
+ const view = getViewType(argv);
140
+ console.log(require_exec.formatExecOutput(result, view));
141
+ if (!result.success) process.exit(require_errors.ExitCode.RUNTIME_ERROR);
142
+ }).command("mount", "Manage mount configurations", (yargs$2) => yargs$2.command(["list", "ls"], "List all mounts", () => {}, async (argv) => {
143
+ const result = await require_mount.mountListCommand(process.cwd());
144
+ const view = getViewType(argv);
145
+ console.log(require_mount.formatMountListOutput(result.mounts, view));
146
+ }).command("add <path> <uri>", "Add a new mount (path=virtual path, uri=data source)", (yargs$3) => yargs$3.positional("path", {
147
+ type: "string",
148
+ demandOption: true,
149
+ description: "Virtual path in AFS namespace (e.g., /src, /data)"
150
+ }).positional("uri", {
151
+ type: "string",
152
+ demandOption: true,
153
+ description: "Data source URI: fs:///local/path, git://repo, sqlite:///db.sqlite"
154
+ }).option("description", {
155
+ type: "string",
156
+ description: "Human-readable description for this mount"
157
+ }), async (argv) => {
158
+ const result = await require_mount.mountAddCommand(process.cwd(), argv.path, argv.uri, { description: argv.description });
159
+ if (getViewType(argv) === "json") console.log(JSON.stringify(result, null, 2));
160
+ else if (result.success) console.log(`Added mount ${argv.path}`);
161
+ else {
162
+ console.error(result.message);
163
+ process.exit(require_errors.ExitCode.RUNTIME_ERROR);
164
+ }
165
+ }).command(["remove <path>", "rm <path>"], "Remove a mount", (yargs$3) => yargs$3.positional("path", {
166
+ type: "string",
167
+ demandOption: true,
168
+ description: "Virtual path to remove (e.g., /src)"
169
+ }), async (argv) => {
170
+ const result = await require_mount.mountRemoveCommand(process.cwd(), argv.path);
171
+ if (getViewType(argv) === "json") console.log(JSON.stringify(result, null, 2));
172
+ else if (result.success) console.log(`Removed mount ${argv.path}`);
173
+ else {
174
+ console.error(result.message);
175
+ process.exit(require_errors.ExitCode.RUNTIME_ERROR);
176
+ }
177
+ }).command("validate", "Validate mount configuration", () => {}, async (argv) => {
178
+ const result = await require_mount.mountValidateCommand(process.cwd());
179
+ if (getViewType(argv) === "json") console.log(JSON.stringify(result, null, 2));
180
+ else if (result.valid) console.log("Configuration is valid");
181
+ else {
182
+ console.error("Configuration has errors:");
183
+ for (const error of result.errors) console.error(` - ${error}`);
184
+ process.exit(require_errors.ExitCode.RUNTIME_ERROR);
185
+ }
186
+ }).demandCommand(1, "Please specify a mount subcommand"), () => {}).command("explain [topic]", "Explain AFS concepts or AFS object", (yargs$2) => yargs$2.positional("topic", {
187
+ type: "string",
188
+ description: "Topic (mount, path, uri) or AFS path (e.g., /modules/src)"
189
+ }), async (argv) => {
190
+ const view = getViewType(argv);
191
+ const topic = argv.topic;
192
+ if (topic?.startsWith("/")) {
193
+ const result = await require_explain.explainPathCommand(await require_runtime.createRuntime(), topic);
194
+ console.log(require_explain.formatPathExplainOutput(result, view));
195
+ } else {
196
+ const result = await require_explain.explainCommand(process.cwd(), topic);
197
+ console.log(require_explain.formatExplainOutput(result, view));
198
+ }
199
+ }).demandCommand(1, "Please specify a command").strict();
200
+ try {
201
+ await cli.parse();
202
+ } catch (error) {
203
+ if (error instanceof require_errors.CLIError) {
204
+ console.error(error.message);
205
+ process.exit(error.exitCode);
206
+ }
207
+ throw error;
208
+ }
209
+ }
210
+ main().catch((error) => {
211
+ console.error("Fatal error:", error.message);
212
+ process.exit(require_errors.ExitCode.RUNTIME_ERROR);
213
+ });
214
+
215
+ //#endregion
package/dist/cli.d.cts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.mjs CHANGED
@@ -1,29 +1,215 @@
1
1
  #!/usr/bin/env node
2
- import { t as VERSION } from "./version--p6A8sKX.mjs";
2
+ import { VERSION } from "./version.mjs";
3
+ import { execCommand, formatExecOutput } from "./commands/exec.mjs";
4
+ import { formatMountListOutput, mountAddCommand, mountListCommand, mountRemoveCommand, mountValidateCommand } from "./commands/mount.mjs";
5
+ import { explainCommand, explainPathCommand, formatExplainOutput, formatPathExplainOutput } from "./commands/explain.mjs";
6
+ import { formatLsOutput, lsCommand } from "./commands/ls.mjs";
7
+ import { formatReadOutput, readCommand } from "./commands/read.mjs";
8
+ import { formatStatOutput, statCommand } from "./commands/stat.mjs";
9
+ import { formatWriteOutput, writeCommand } from "./commands/write.mjs";
10
+ import "./commands/index.mjs";
11
+ import { CLIError, ExitCode } from "./errors.mjs";
12
+ import { createRuntime } from "./runtime.mjs";
13
+ import yargs from "yargs";
14
+ import { hideBin } from "yargs/helpers";
3
15
 
4
16
  //#region src/cli.ts
5
17
  /**
6
18
  * AFS CLI - Command Line Interface
7
19
  *
8
- * 命令:
9
- * - afs ls [path] 列出目录
10
- * - afs cat <path> 读取文件
11
- * - afs write <path> 写入文件
12
- * - afs search <path> <pattern> 搜索内容
13
- * - afs exec <path> <action> 执行操作
14
- * - afs explain <path> 语义解释
20
+ * Commands:
21
+ * - afs mount list|ls List mount configurations
22
+ * - afs mount add <path> <uri> Add a mount
23
+ * - afs mount remove|rm <path> Remove a mount
24
+ * - afs mount validate Validate mount configuration
25
+ * - afs list|ls [path] List directory
26
+ * - afs stat <path> Get file/directory info
27
+ * - afs read <path> Read file content
28
+ * - afs write <path> Write file content (--content or stdin)
29
+ * - afs exec <path> <action> Execute operation
15
30
  *
16
- * 输出模式:
17
- * - 默认: Machine Truth (LLM/脚本友好)
18
- * - --json: 结构化 JSON
19
- * - --view=llm: LLM 优化输出
20
- * - --view=human: 人类友好格式
21
- *
22
- * 运行模式:
23
- * - 直接模式 (默认): 直接调用 @aigne/afs
24
- * - daemon 模式 (--daemon): 通过 afsd 代理
31
+ * Output modes:
32
+ * - Default: Machine Truth (LLM/script friendly)
33
+ * - --json: Structured JSON
34
+ * - --view=llm: LLM optimized output
35
+ * - --view=human: Human friendly format
25
36
  */
26
- console.log(`afs-cli v${VERSION}`);
37
+ function getViewType(argv) {
38
+ if (argv.json) return "json";
39
+ if (argv.view) return argv.view;
40
+ return "default";
41
+ }
42
+ async function main() {
43
+ const cli = yargs(hideBin(process.argv)).scriptName("afs").version(VERSION).alias("version", "V").help("help").alias("help", "h").usage("$0 <command> [options]").option("json", {
44
+ type: "boolean",
45
+ description: "Output in JSON format",
46
+ global: true
47
+ }).option("view", {
48
+ type: "string",
49
+ choices: [
50
+ "default",
51
+ "llm",
52
+ "human"
53
+ ],
54
+ description: "Output view format",
55
+ global: true
56
+ }).command(["list [path]", "ls [path]"], "List directory contents", (yargs$1) => yargs$1.positional("path", {
57
+ type: "string",
58
+ default: "/",
59
+ description: "Path to list"
60
+ }).option("depth", {
61
+ type: "number",
62
+ default: 1,
63
+ description: "Maximum depth to list"
64
+ }).option("limit", {
65
+ alias: "n",
66
+ type: "number",
67
+ description: "Maximum number of entries to return"
68
+ }).option("max-children", {
69
+ type: "number",
70
+ description: "Maximum children per directory"
71
+ }).option("pattern", {
72
+ alias: "p",
73
+ type: "string",
74
+ description: "Glob pattern to filter entries (e.g., *.ts, **/*.js)"
75
+ }), async (argv) => {
76
+ const result = await lsCommand(await createRuntime(), argv.path, {
77
+ maxDepth: argv.depth,
78
+ limit: argv.limit,
79
+ maxChildren: argv["max-children"],
80
+ pattern: argv.pattern
81
+ });
82
+ const view = getViewType(argv);
83
+ console.log(formatLsOutput(result, view));
84
+ }).command("stat <path>", "Get file or directory info", (yargs$1) => yargs$1.positional("path", {
85
+ type: "string",
86
+ demandOption: true,
87
+ description: "Path to stat"
88
+ }), async (argv) => {
89
+ const result = await statCommand(await createRuntime(), argv.path);
90
+ const view = getViewType(argv);
91
+ console.log(formatStatOutput(result, view));
92
+ }).command("read <path>", "Read file content", (yargs$1) => yargs$1.positional("path", {
93
+ type: "string",
94
+ demandOption: true,
95
+ description: "Path to read"
96
+ }), async (argv) => {
97
+ const result = await readCommand(await createRuntime(), argv.path);
98
+ const view = getViewType(argv);
99
+ console.log(formatReadOutput(result, view));
100
+ }).command("write <path>", "Write content to file (from --content or stdin)", (yargs$1) => yargs$1.positional("path", {
101
+ type: "string",
102
+ demandOption: true,
103
+ description: "Path to write"
104
+ }).option("content", {
105
+ type: "string",
106
+ description: "Content to write (if not provided, reads from stdin)"
107
+ }).option("append", {
108
+ type: "boolean",
109
+ default: false,
110
+ description: "Append to file instead of overwrite"
111
+ }), async (argv) => {
112
+ let content;
113
+ if (argv.content !== void 0) content = argv.content;
114
+ else {
115
+ const chunks = [];
116
+ for await (const chunk of process.stdin) chunks.push(chunk);
117
+ content = Buffer.concat(chunks).toString("utf-8");
118
+ }
119
+ const result = await writeCommand(await createRuntime(), argv.path, content, { append: argv.append });
120
+ const view = getViewType(argv);
121
+ console.log(formatWriteOutput(result, view));
122
+ if (!result.success) process.exit(ExitCode.RUNTIME_ERROR);
123
+ }).command("exec <path> [action]", "Execute operation on path", (yargs$1) => yargs$1.positional("path", {
124
+ type: "string",
125
+ demandOption: true,
126
+ description: "Path to execute on"
127
+ }).positional("action", {
128
+ type: "string",
129
+ default: "default",
130
+ description: "Action to execute"
131
+ }).option("params", {
132
+ type: "string",
133
+ description: "JSON parameters for the action"
134
+ }), async (argv) => {
135
+ const params = argv.params ? JSON.parse(argv.params) : {};
136
+ const result = await execCommand(await createRuntime(), argv.path, argv.action, params);
137
+ const view = getViewType(argv);
138
+ console.log(formatExecOutput(result, view));
139
+ if (!result.success) process.exit(ExitCode.RUNTIME_ERROR);
140
+ }).command("mount", "Manage mount configurations", (yargs$1) => yargs$1.command(["list", "ls"], "List all mounts", () => {}, async (argv) => {
141
+ const result = await mountListCommand(process.cwd());
142
+ const view = getViewType(argv);
143
+ console.log(formatMountListOutput(result.mounts, view));
144
+ }).command("add <path> <uri>", "Add a new mount (path=virtual path, uri=data source)", (yargs$2) => yargs$2.positional("path", {
145
+ type: "string",
146
+ demandOption: true,
147
+ description: "Virtual path in AFS namespace (e.g., /src, /data)"
148
+ }).positional("uri", {
149
+ type: "string",
150
+ demandOption: true,
151
+ description: "Data source URI: fs:///local/path, git://repo, sqlite:///db.sqlite"
152
+ }).option("description", {
153
+ type: "string",
154
+ description: "Human-readable description for this mount"
155
+ }), async (argv) => {
156
+ const result = await mountAddCommand(process.cwd(), argv.path, argv.uri, { description: argv.description });
157
+ if (getViewType(argv) === "json") console.log(JSON.stringify(result, null, 2));
158
+ else if (result.success) console.log(`Added mount ${argv.path}`);
159
+ else {
160
+ console.error(result.message);
161
+ process.exit(ExitCode.RUNTIME_ERROR);
162
+ }
163
+ }).command(["remove <path>", "rm <path>"], "Remove a mount", (yargs$2) => yargs$2.positional("path", {
164
+ type: "string",
165
+ demandOption: true,
166
+ description: "Virtual path to remove (e.g., /src)"
167
+ }), async (argv) => {
168
+ const result = await mountRemoveCommand(process.cwd(), argv.path);
169
+ if (getViewType(argv) === "json") console.log(JSON.stringify(result, null, 2));
170
+ else if (result.success) console.log(`Removed mount ${argv.path}`);
171
+ else {
172
+ console.error(result.message);
173
+ process.exit(ExitCode.RUNTIME_ERROR);
174
+ }
175
+ }).command("validate", "Validate mount configuration", () => {}, async (argv) => {
176
+ const result = await mountValidateCommand(process.cwd());
177
+ if (getViewType(argv) === "json") console.log(JSON.stringify(result, null, 2));
178
+ else if (result.valid) console.log("Configuration is valid");
179
+ else {
180
+ console.error("Configuration has errors:");
181
+ for (const error of result.errors) console.error(` - ${error}`);
182
+ process.exit(ExitCode.RUNTIME_ERROR);
183
+ }
184
+ }).demandCommand(1, "Please specify a mount subcommand"), () => {}).command("explain [topic]", "Explain AFS concepts or AFS object", (yargs$1) => yargs$1.positional("topic", {
185
+ type: "string",
186
+ description: "Topic (mount, path, uri) or AFS path (e.g., /modules/src)"
187
+ }), async (argv) => {
188
+ const view = getViewType(argv);
189
+ const topic = argv.topic;
190
+ if (topic?.startsWith("/")) {
191
+ const result = await explainPathCommand(await createRuntime(), topic);
192
+ console.log(formatPathExplainOutput(result, view));
193
+ } else {
194
+ const result = await explainCommand(process.cwd(), topic);
195
+ console.log(formatExplainOutput(result, view));
196
+ }
197
+ }).demandCommand(1, "Please specify a command").strict();
198
+ try {
199
+ await cli.parse();
200
+ } catch (error) {
201
+ if (error instanceof CLIError) {
202
+ console.error(error.message);
203
+ process.exit(error.exitCode);
204
+ }
205
+ throw error;
206
+ }
207
+ }
208
+ main().catch((error) => {
209
+ console.error("Fatal error:", error.message);
210
+ process.exit(ExitCode.RUNTIME_ERROR);
211
+ });
27
212
 
28
213
  //#endregion
29
- export { };
214
+ export { };
215
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","names":["yargs"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * AFS CLI - Command Line Interface\n *\n * Commands:\n * - afs mount list|ls List mount configurations\n * - afs mount add <path> <uri> Add a mount\n * - afs mount remove|rm <path> Remove a mount\n * - afs mount validate Validate mount configuration\n * - afs list|ls [path] List directory\n * - afs stat <path> Get file/directory info\n * - afs read <path> Read file content\n * - afs write <path> Write file content (--content or stdin)\n * - afs exec <path> <action> Execute operation\n *\n * Output modes:\n * - Default: Machine Truth (LLM/script friendly)\n * - --json: Structured JSON\n * - --view=llm: LLM optimized output\n * - --view=human: Human friendly format\n */\n\nimport yargs from \"yargs\";\nimport { hideBin } from \"yargs/helpers\";\nimport {\n execCommand,\n explainCommand,\n explainPathCommand,\n formatExecOutput,\n formatExplainOutput,\n formatLsOutput,\n formatMountListOutput,\n formatPathExplainOutput,\n formatReadOutput,\n formatStatOutput,\n formatWriteOutput,\n lsCommand,\n mountAddCommand,\n mountListCommand,\n mountRemoveCommand,\n mountValidateCommand,\n readCommand,\n statCommand,\n type ViewType,\n writeCommand,\n} from \"./commands/index.js\";\nimport { CLIError, ExitCode } from \"./errors.js\";\nimport { createRuntime } from \"./runtime.js\";\nimport { VERSION } from \"./version.js\";\n\n// Global view type derived from args\nfunction getViewType(argv: { json?: boolean; view?: string }): ViewType {\n if (argv.json) return \"json\";\n if (argv.view) return argv.view as ViewType;\n return \"default\";\n}\n\n// Run the CLI\nasync function main() {\n const cli = yargs(hideBin(process.argv))\n .scriptName(\"afs\")\n .version(VERSION)\n .alias(\"version\", \"V\")\n .help(\"help\")\n .alias(\"help\", \"h\")\n .usage(\"$0 <command> [options]\")\n .option(\"json\", {\n type: \"boolean\",\n description: \"Output in JSON format\",\n global: true,\n })\n .option(\"view\", {\n type: \"string\",\n choices: [\"default\", \"llm\", \"human\"],\n description: \"Output view format\",\n global: true,\n })\n .command(\n [\"list [path]\", \"ls [path]\"],\n \"List directory contents\",\n (yargs) =>\n yargs\n .positional(\"path\", {\n type: \"string\",\n default: \"/\",\n description: \"Path to list\",\n })\n .option(\"depth\", {\n type: \"number\",\n default: 1,\n description: \"Maximum depth to list\",\n })\n .option(\"limit\", {\n alias: \"n\",\n type: \"number\",\n description: \"Maximum number of entries to return\",\n })\n .option(\"max-children\", {\n type: \"number\",\n description: \"Maximum children per directory\",\n })\n .option(\"pattern\", {\n alias: \"p\",\n type: \"string\",\n description: \"Glob pattern to filter entries (e.g., *.ts, **/*.js)\",\n }),\n async (argv) => {\n const runtime = await createRuntime();\n const result = await lsCommand(runtime, argv.path!, {\n maxDepth: argv.depth,\n limit: argv.limit,\n maxChildren: argv[\"max-children\"],\n pattern: argv.pattern,\n });\n const view = getViewType(argv);\n console.log(formatLsOutput(result, view));\n },\n )\n .command(\n \"stat <path>\",\n \"Get file or directory info\",\n (yargs) =>\n yargs.positional(\"path\", {\n type: \"string\",\n demandOption: true,\n description: \"Path to stat\",\n }),\n async (argv) => {\n const runtime = await createRuntime();\n const result = await statCommand(runtime, argv.path!);\n const view = getViewType(argv);\n console.log(formatStatOutput(result, view));\n },\n )\n .command(\n \"read <path>\",\n \"Read file content\",\n (yargs) =>\n yargs.positional(\"path\", {\n type: \"string\",\n demandOption: true,\n description: \"Path to read\",\n }),\n async (argv) => {\n const runtime = await createRuntime();\n const result = await readCommand(runtime, argv.path!);\n const view = getViewType(argv);\n console.log(formatReadOutput(result, view));\n },\n )\n .command(\n \"write <path>\",\n \"Write content to file (from --content or stdin)\",\n (yargs) =>\n yargs\n .positional(\"path\", {\n type: \"string\",\n demandOption: true,\n description: \"Path to write\",\n })\n .option(\"content\", {\n type: \"string\",\n description: \"Content to write (if not provided, reads from stdin)\",\n })\n .option(\"append\", {\n type: \"boolean\",\n default: false,\n description: \"Append to file instead of overwrite\",\n }),\n async (argv) => {\n let content: string;\n\n if (argv.content !== undefined) {\n // Use --content parameter\n content = argv.content;\n } else {\n // Read content from stdin\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n content = Buffer.concat(chunks).toString(\"utf-8\");\n }\n\n const runtime = await createRuntime();\n const result = await writeCommand(runtime, argv.path!, content, {\n append: argv.append,\n });\n const view = getViewType(argv);\n console.log(formatWriteOutput(result, view));\n\n if (!result.success) {\n process.exit(ExitCode.RUNTIME_ERROR);\n }\n },\n )\n .command(\n \"exec <path> [action]\",\n \"Execute operation on path\",\n (yargs) =>\n yargs\n .positional(\"path\", {\n type: \"string\",\n demandOption: true,\n description: \"Path to execute on\",\n })\n .positional(\"action\", {\n type: \"string\",\n default: \"default\",\n description: \"Action to execute\",\n })\n .option(\"params\", {\n type: \"string\",\n description: \"JSON parameters for the action\",\n }),\n async (argv) => {\n const params = argv.params ? JSON.parse(argv.params) : {};\n\n const runtime = await createRuntime();\n const result = await execCommand(runtime, argv.path!, argv.action!, params);\n const view = getViewType(argv);\n console.log(formatExecOutput(result, view));\n\n if (!result.success) {\n process.exit(ExitCode.RUNTIME_ERROR);\n }\n },\n )\n .command(\n \"mount\",\n \"Manage mount configurations\",\n (yargs) =>\n yargs\n .command(\n [\"list\", \"ls\"],\n \"List all mounts\",\n () => {},\n async (argv) => {\n const result = await mountListCommand(process.cwd());\n const view = getViewType(argv);\n console.log(formatMountListOutput(result.mounts, view));\n },\n )\n .command(\n \"add <path> <uri>\",\n \"Add a new mount (path=virtual path, uri=data source)\",\n (yargs) =>\n yargs\n .positional(\"path\", {\n type: \"string\",\n demandOption: true,\n description: \"Virtual path in AFS namespace (e.g., /src, /data)\",\n })\n .positional(\"uri\", {\n type: \"string\",\n demandOption: true,\n description: \"Data source URI: fs:///local/path, git://repo, sqlite:///db.sqlite\",\n })\n .option(\"description\", {\n type: \"string\",\n description: \"Human-readable description for this mount\",\n }),\n async (argv) => {\n const result = await mountAddCommand(process.cwd(), argv.path!, argv.uri!, {\n description: argv.description,\n });\n const view = getViewType(argv);\n\n if (view === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n } else {\n if (result.success) {\n console.log(`Added mount ${argv.path}`);\n } else {\n console.error(result.message);\n process.exit(ExitCode.RUNTIME_ERROR);\n }\n }\n },\n )\n .command(\n [\"remove <path>\", \"rm <path>\"],\n \"Remove a mount\",\n (yargs) =>\n yargs.positional(\"path\", {\n type: \"string\",\n demandOption: true,\n description: \"Virtual path to remove (e.g., /src)\",\n }),\n async (argv) => {\n const result = await mountRemoveCommand(process.cwd(), argv.path!);\n const view = getViewType(argv);\n\n if (view === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n } else {\n if (result.success) {\n console.log(`Removed mount ${argv.path}`);\n } else {\n console.error(result.message);\n process.exit(ExitCode.RUNTIME_ERROR);\n }\n }\n },\n )\n .command(\n \"validate\",\n \"Validate mount configuration\",\n () => {},\n async (argv) => {\n const result = await mountValidateCommand(process.cwd());\n const view = getViewType(argv);\n\n if (view === \"json\") {\n console.log(JSON.stringify(result, null, 2));\n } else {\n if (result.valid) {\n console.log(\"Configuration is valid\");\n } else {\n console.error(\"Configuration has errors:\");\n for (const error of result.errors) {\n console.error(` - ${error}`);\n }\n process.exit(ExitCode.RUNTIME_ERROR);\n }\n }\n },\n )\n .demandCommand(1, \"Please specify a mount subcommand\"),\n () => {},\n )\n .command(\n \"explain [topic]\",\n \"Explain AFS concepts or AFS object\",\n (yargs) =>\n yargs.positional(\"topic\", {\n type: \"string\",\n description: \"Topic (mount, path, uri) or AFS path (e.g., /modules/src)\",\n }),\n async (argv) => {\n const view = getViewType(argv);\n const topic = argv.topic;\n\n // If topic starts with /, treat as object path\n if (topic?.startsWith(\"/\")) {\n const runtime = await createRuntime();\n const result = await explainPathCommand(runtime, topic);\n console.log(formatPathExplainOutput(result, view));\n } else {\n const result = await explainCommand(process.cwd(), topic);\n console.log(formatExplainOutput(result, view));\n }\n },\n )\n .demandCommand(1, \"Please specify a command\")\n .strict();\n\n try {\n await cli.parse();\n } catch (error) {\n if (error instanceof CLIError) {\n console.error(error.message);\n process.exit(error.exitCode);\n }\n throw error;\n }\n}\n\nmain().catch((error) => {\n console.error(\"Fatal error:\", error.message);\n process.exit(ExitCode.RUNTIME_ERROR);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAS,YAAY,MAAmD;AACtE,KAAI,KAAK,KAAM,QAAO;AACtB,KAAI,KAAK,KAAM,QAAO,KAAK;AAC3B,QAAO;;AAIT,eAAe,OAAO;CACpB,MAAM,MAAM,MAAM,QAAQ,QAAQ,KAAK,CAAC,CACrC,WAAW,MAAM,CACjB,QAAQ,QAAQ,CAChB,MAAM,WAAW,IAAI,CACrB,KAAK,OAAO,CACZ,MAAM,QAAQ,IAAI,CAClB,MAAM,yBAAyB,CAC/B,OAAO,QAAQ;EACd,MAAM;EACN,aAAa;EACb,QAAQ;EACT,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AAO,MACT,SAAQ,IAAI,yBAAyB;OAChC;AACL,WAAQ,MAAM,4BAA4B;AAC1C,QAAK,MAAM,SAAS,OAAO,OACzB,SAAQ,MAAM,OAAO,QAAQ;AAE/B,WAAQ,KAAK,SAAS,cAAc;;GAI3C,CACA,cAAc,GAAG,oCAAoC,QACpD,GACP,CACA,QACC,mBACA,uCACC,YACCA,QAAM,WAAW,SAAS;EACxB,MAAM;EACN,aAAa;EACd,CAAC,EACJ,OAAO,SAAS;EACd,MAAM,OAAO,YAAY,KAAK;EAC9B,MAAM,QAAQ,KAAK;AAGnB,MAAI,OAAO,WAAW,IAAI,EAAE;GAE1B,MAAM,SAAS,MAAM,mBADL,MAAM,eAAe,EACY,MAAM;AACvD,WAAQ,IAAI,wBAAwB,QAAQ,KAAK,CAAC;SAC7C;GACL,MAAM,SAAS,MAAM,eAAe,QAAQ,KAAK,EAAE,MAAM;AACzD,WAAQ,IAAI,oBAAoB,QAAQ,KAAK,CAAC;;GAGnD,CACA,cAAc,GAAG,2BAA2B,CAC5C,QAAQ;AAEX,KAAI;AACF,QAAM,IAAI,OAAO;UACV,OAAO;AACd,MAAI,iBAAiB,UAAU;AAC7B,WAAQ,MAAM,MAAM,QAAQ;AAC5B,WAAQ,KAAK,MAAM,SAAS;;AAE9B,QAAM;;;AAIV,MAAM,CAAC,OAAO,UAAU;AACtB,SAAQ,MAAM,gBAAgB,MAAM,QAAQ;AAC5C,SAAQ,KAAK,SAAS,cAAc;EACpC"}
@@ -0,0 +1,46 @@
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;
@@ -0,0 +1,45 @@
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
@@ -0,0 +1 @@
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"}