@aigne/afs-cli 1.11.0-beta.11 → 1.11.0-beta.13
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 +3 -2
- package/dist/cli.mjs +3 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/config/afs-loader.cjs +36 -315
- package/dist/config/afs-loader.d.cts.map +1 -1
- package/dist/config/afs-loader.d.mts +2 -1
- package/dist/config/afs-loader.d.mts.map +1 -1
- package/dist/config/afs-loader.mjs +28 -307
- package/dist/config/afs-loader.mjs.map +1 -1
- package/dist/config/credential-helpers.cjs +303 -0
- package/dist/config/credential-helpers.d.mts +2 -0
- package/dist/config/credential-helpers.mjs +300 -0
- package/dist/config/credential-helpers.mjs.map +1 -0
- package/dist/config/loader.cjs +3 -1
- package/dist/config/loader.mjs +3 -2
- package/dist/config/loader.mjs.map +1 -1
- package/dist/config/program-install.cjs +450 -0
- package/dist/config/program-install.d.mts +1 -0
- package/dist/config/program-install.mjs +444 -0
- package/dist/config/program-install.mjs.map +1 -0
- package/dist/core/commands/connect.cjs +53 -0
- package/dist/core/commands/connect.d.mts +2 -0
- package/dist/core/commands/connect.mjs +55 -0
- package/dist/core/commands/connect.mjs.map +1 -0
- package/dist/core/commands/daemon.cjs +211 -0
- package/dist/core/commands/daemon.d.mts +2 -0
- package/dist/core/commands/daemon.mjs +212 -0
- package/dist/core/commands/daemon.mjs.map +1 -0
- package/dist/core/commands/explain.cjs +3 -1
- package/dist/core/commands/explain.mjs +3 -1
- package/dist/core/commands/explain.mjs.map +1 -1
- package/dist/core/commands/explore.cjs +47 -12
- package/dist/core/commands/explore.mjs +47 -12
- package/dist/core/commands/explore.mjs.map +1 -1
- package/dist/core/commands/gen-agent-md.cjs +126 -0
- package/dist/core/commands/gen-agent-md.d.mts +2 -0
- package/dist/core/commands/gen-agent-md.mjs +125 -0
- package/dist/core/commands/gen-agent-md.mjs.map +1 -0
- package/dist/core/commands/index.cjs +13 -1
- package/dist/core/commands/index.d.cts.map +1 -1
- package/dist/core/commands/index.d.mts +6 -0
- package/dist/core/commands/index.d.mts.map +1 -1
- package/dist/core/commands/index.mjs +13 -1
- package/dist/core/commands/index.mjs.map +1 -1
- package/dist/core/commands/install.cjs +139 -0
- package/dist/core/commands/install.d.mts +2 -0
- package/dist/core/commands/install.mjs +140 -0
- package/dist/core/commands/install.mjs.map +1 -0
- package/dist/core/commands/ls.cjs +14 -2
- package/dist/core/commands/ls.d.cts +2 -0
- package/dist/core/commands/ls.d.cts.map +1 -1
- package/dist/core/commands/ls.d.mts +2 -0
- package/dist/core/commands/ls.d.mts.map +1 -1
- package/dist/core/commands/ls.mjs +14 -2
- package/dist/core/commands/ls.mjs.map +1 -1
- package/dist/core/commands/mcp-bridge.cjs +201 -0
- package/dist/core/commands/mcp-bridge.d.mts +2 -0
- package/dist/core/commands/mcp-bridge.mjs +201 -0
- package/dist/core/commands/mcp-bridge.mjs.map +1 -0
- package/dist/core/commands/read.cjs +20 -7
- package/dist/core/commands/read.d.cts +2 -0
- package/dist/core/commands/read.d.cts.map +1 -1
- package/dist/core/commands/read.d.mts +2 -0
- package/dist/core/commands/read.d.mts.map +1 -1
- package/dist/core/commands/read.mjs +20 -7
- package/dist/core/commands/read.mjs.map +1 -1
- package/dist/core/commands/search.cjs +5 -1
- package/dist/core/commands/search.mjs +5 -1
- package/dist/core/commands/search.mjs.map +1 -1
- package/dist/core/commands/stat.mjs.map +1 -1
- package/dist/core/commands/types.d.cts +2 -0
- package/dist/core/commands/types.d.cts.map +1 -1
- package/dist/core/commands/types.d.mts +2 -0
- package/dist/core/commands/types.d.mts.map +1 -1
- package/dist/core/commands/types.mjs.map +1 -1
- package/dist/core/commands/vault.cjs +289 -0
- package/dist/core/commands/vault.d.mts +2 -0
- package/dist/core/commands/vault.mjs +289 -0
- package/dist/core/commands/vault.mjs.map +1 -0
- package/dist/core/commands/write.cjs +19 -6
- package/dist/core/commands/write.d.cts +2 -1
- package/dist/core/commands/write.d.cts.map +1 -1
- package/dist/core/commands/write.d.mts +2 -1
- package/dist/core/commands/write.d.mts.map +1 -1
- package/dist/core/commands/write.mjs +19 -6
- package/dist/core/commands/write.mjs.map +1 -1
- package/dist/core/executor/index.cjs +95 -19
- package/dist/core/executor/index.d.cts +4 -0
- package/dist/core/executor/index.d.cts.map +1 -1
- package/dist/core/executor/index.d.mts +4 -0
- package/dist/core/executor/index.d.mts.map +1 -1
- package/dist/core/executor/index.mjs +95 -19
- package/dist/core/executor/index.mjs.map +1 -1
- package/dist/core/formatters/index.d.mts +1 -0
- package/dist/core/formatters/install.cjs +40 -0
- package/dist/core/formatters/install.d.mts +1 -0
- package/dist/core/formatters/install.mjs +36 -0
- package/dist/core/formatters/install.mjs.map +1 -0
- package/dist/core/formatters/vault.cjs +36 -0
- package/dist/core/formatters/vault.mjs +32 -0
- package/dist/core/formatters/vault.mjs.map +1 -0
- package/dist/credential/auth-server.cjs +22 -4
- package/dist/credential/auth-server.mjs +22 -4
- package/dist/credential/auth-server.mjs.map +1 -1
- package/dist/credential/index.d.mts +2 -1
- package/dist/credential/mcp-auth-context.cjs +21 -5
- package/dist/credential/mcp-auth-context.mjs +21 -5
- package/dist/credential/mcp-auth-context.mjs.map +1 -1
- package/dist/credential/resolver.cjs +11 -3
- package/dist/credential/resolver.mjs +11 -3
- package/dist/credential/resolver.mjs.map +1 -1
- package/dist/credential/vault-store.d.mts +1 -0
- package/dist/daemon/config-manager.cjs +279 -0
- package/dist/daemon/config-manager.mjs +279 -0
- package/dist/daemon/config-manager.mjs.map +1 -0
- package/dist/daemon/manager.cjs +164 -0
- package/dist/daemon/manager.mjs +157 -0
- package/dist/daemon/manager.mjs.map +1 -0
- package/dist/daemon/server.cjs +220 -0
- package/dist/daemon/server.mjs +220 -0
- package/dist/daemon/server.mjs.map +1 -0
- package/dist/mcp/http-transport.cjs +14 -1
- package/dist/mcp/http-transport.mjs +14 -1
- package/dist/mcp/http-transport.mjs.map +1 -1
- package/dist/mcp/server.cjs +4 -2
- package/dist/mcp/server.mjs +4 -2
- package/dist/mcp/server.mjs.map +1 -1
- package/dist/mcp/tools.cjs +62 -12
- package/dist/mcp/tools.mjs +62 -12
- package/dist/mcp/tools.mjs.map +1 -1
- package/dist/program/daemon-integration.cjs +46 -0
- package/dist/program/daemon-integration.mjs +45 -0
- package/dist/program/daemon-integration.mjs.map +1 -0
- package/dist/program/program-manager.cjs +166 -0
- package/dist/program/program-manager.mjs +166 -0
- package/dist/program/program-manager.mjs.map +1 -0
- package/dist/program/trigger-scanner.cjs +148 -0
- package/dist/program/trigger-scanner.mjs +148 -0
- package/dist/program/trigger-scanner.mjs.map +1 -0
- package/dist/providers/vault/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/providers/vault/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +11 -0
- package/dist/providers/vault/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs.map +1 -0
- package/dist/providers/vault/dist/encrypted-file.cjs +158 -0
- package/dist/providers/vault/dist/encrypted-file.mjs +153 -0
- package/dist/providers/vault/dist/encrypted-file.mjs.map +1 -0
- package/dist/providers/vault/dist/index.cjs +405 -0
- package/dist/providers/vault/dist/index.mjs +400 -0
- package/dist/providers/vault/dist/index.mjs.map +1 -0
- package/dist/providers/vault/dist/key-resolver.cjs +181 -0
- package/dist/providers/vault/dist/key-resolver.mjs +180 -0
- package/dist/providers/vault/dist/key-resolver.mjs.map +1 -0
- package/dist/repl.cjs +109 -14
- package/dist/repl.d.cts.map +1 -1
- package/dist/repl.d.mts.map +1 -1
- package/dist/repl.mjs +109 -14
- package/dist/repl.mjs.map +1 -1
- package/package.json +27 -20
|
@@ -8,20 +8,55 @@ import { VERSION } from "../../version.mjs";
|
|
|
8
8
|
function createExploreCommand(options) {
|
|
9
9
|
return {
|
|
10
10
|
command: "explore [path]",
|
|
11
|
-
describe: "Interactive TUI
|
|
12
|
-
builder: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
describe: "Interactive explorer (TUI or web)",
|
|
12
|
+
builder: {
|
|
13
|
+
path: {
|
|
14
|
+
type: "string",
|
|
15
|
+
default: "/",
|
|
16
|
+
description: "Starting path"
|
|
17
|
+
},
|
|
18
|
+
web: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
default: false,
|
|
21
|
+
description: "Launch web-based explorer"
|
|
22
|
+
},
|
|
23
|
+
port: {
|
|
24
|
+
type: "number",
|
|
25
|
+
default: 0,
|
|
26
|
+
description: "Port for web explorer (0 = auto)"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
17
29
|
handler: async (argv) => {
|
|
18
30
|
const afs = await resolveAFS(options);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
if (argv.web) {
|
|
32
|
+
const { startExplorer } = await import("@aigne/afs-explorer");
|
|
33
|
+
const { resolve } = await import("node:path");
|
|
34
|
+
let webRoot;
|
|
35
|
+
try {
|
|
36
|
+
const { createRequire } = await import("node:module");
|
|
37
|
+
webRoot = resolve(createRequire(import.meta.url).resolve("@aigne/afs-explorer/package.json"), "..", "web");
|
|
38
|
+
} catch {}
|
|
39
|
+
const info = await startExplorer(afs, {
|
|
40
|
+
port: argv.port,
|
|
41
|
+
host: "localhost",
|
|
42
|
+
webRoot,
|
|
43
|
+
open: true
|
|
44
|
+
});
|
|
45
|
+
console.log(`AFS Explorer running at ${info.url}`);
|
|
46
|
+
console.log("Press Ctrl+C to stop");
|
|
47
|
+
process.on("SIGINT", () => {
|
|
48
|
+
info.stop();
|
|
49
|
+
process.exit(0);
|
|
50
|
+
});
|
|
51
|
+
await new Promise(() => {});
|
|
52
|
+
} else {
|
|
53
|
+
const { createExplorerScreen } = await import("../../explorer/screen.mjs");
|
|
54
|
+
await createExplorerScreen({
|
|
55
|
+
afs,
|
|
56
|
+
startPath: argv.path,
|
|
57
|
+
version: VERSION
|
|
58
|
+
});
|
|
59
|
+
}
|
|
25
60
|
}
|
|
26
61
|
};
|
|
27
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explore.mjs","names":[],"sources":["../../../src/core/commands/explore.ts"],"sourcesContent":["/**\n * AFS Explore Command\n *\n * Interactive TUI explorer for AFS\n */\n\nimport type { CommandModule } from \"yargs\";\nimport { VERSION } from \"../../version.js\";\nimport { type CommandFactoryOptions, resolveAFS } from \"./types.js\";\n\nexport interface ExploreArgs {\n path: string;\n}\n\n/**\n * Create explore command\n */\nexport function createExploreCommand(\n options: CommandFactoryOptions,\n): CommandModule<unknown, ExploreArgs> {\n return {\n command: \"explore [path]\",\n describe: \"Interactive TUI
|
|
1
|
+
{"version":3,"file":"explore.mjs","names":[],"sources":["../../../src/core/commands/explore.ts"],"sourcesContent":["/**\n * AFS Explore Command\n *\n * Interactive TUI explorer or web-based explorer for AFS\n */\n\nimport type { CommandModule } from \"yargs\";\nimport { VERSION } from \"../../version.js\";\nimport { type CommandFactoryOptions, resolveAFS } from \"./types.js\";\n\nexport interface ExploreArgs {\n path: string;\n web: boolean;\n port: number;\n}\n\n/**\n * Create explore command\n */\nexport function createExploreCommand(\n options: CommandFactoryOptions,\n): CommandModule<unknown, ExploreArgs> {\n return {\n command: \"explore [path]\",\n describe: \"Interactive explorer (TUI or web)\",\n builder: {\n path: { type: \"string\", default: \"/\", description: \"Starting path\" },\n web: { type: \"boolean\", default: false, description: \"Launch web-based explorer\" },\n port: { type: \"number\", default: 0, description: \"Port for web explorer (0 = auto)\" },\n },\n handler: async (argv) => {\n const afs = await resolveAFS(options);\n\n if (argv.web) {\n const { startExplorer } = await import(\"@aigne/afs-explorer\");\n const { resolve } = await import(\"node:path\");\n\n // Locate web assets: try node_modules first, then relative path\n let webRoot: string | undefined;\n try {\n const { createRequire } = await import(\"node:module\");\n const req = createRequire(import.meta.url);\n const explorerPkg = req.resolve(\"@aigne/afs-explorer/package.json\");\n webRoot = resolve(explorerPkg, \"..\", \"web\");\n } catch {\n // Fallback — not critical if embedded assets are used\n }\n\n const info = await startExplorer(afs, {\n port: argv.port,\n host: \"localhost\",\n webRoot,\n open: true,\n });\n\n console.log(`AFS Explorer running at ${info.url}`);\n console.log(\"Press Ctrl+C to stop\");\n\n // Keep process alive\n process.on(\"SIGINT\", () => {\n info.stop();\n process.exit(0);\n });\n await new Promise(() => {});\n } else {\n const { createExplorerScreen } = await import(\"../../explorer/screen.js\");\n await createExplorerScreen({ afs, startPath: argv.path, version: VERSION });\n }\n },\n };\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,qBACd,SACqC;AACrC,QAAO;EACL,SAAS;EACT,UAAU;EACV,SAAS;GACP,MAAM;IAAE,MAAM;IAAU,SAAS;IAAK,aAAa;IAAiB;GACpE,KAAK;IAAE,MAAM;IAAW,SAAS;IAAO,aAAa;IAA6B;GAClF,MAAM;IAAE,MAAM;IAAU,SAAS;IAAG,aAAa;IAAoC;GACtF;EACD,SAAS,OAAO,SAAS;GACvB,MAAM,MAAM,MAAM,WAAW,QAAQ;AAErC,OAAI,KAAK,KAAK;IACZ,MAAM,EAAE,kBAAkB,MAAM,OAAO;IACvC,MAAM,EAAE,YAAY,MAAM,OAAO;IAGjC,IAAI;AACJ,QAAI;KACF,MAAM,EAAE,kBAAkB,MAAM,OAAO;AAGvC,eAAU,QAFE,cAAc,OAAO,KAAK,IAAI,CAClB,QAAQ,mCAAmC,EACpC,MAAM,MAAM;YACrC;IAIR,MAAM,OAAO,MAAM,cAAc,KAAK;KACpC,MAAM,KAAK;KACX,MAAM;KACN;KACA,MAAM;KACP,CAAC;AAEF,YAAQ,IAAI,2BAA2B,KAAK,MAAM;AAClD,YAAQ,IAAI,uBAAuB;AAGnC,YAAQ,GAAG,gBAAgB;AACzB,UAAK,MAAM;AACX,aAAQ,KAAK,EAAE;MACf;AACF,UAAM,IAAI,cAAc,GAAG;UACtB;IACL,MAAM,EAAE,yBAAyB,MAAM,OAAO;AAC9C,UAAM,qBAAqB;KAAE;KAAK,WAAW,KAAK;KAAM,SAAS;KAAS,CAAC;;;EAGhF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/commands/gen-agent-md.ts
|
|
3
|
+
/**
|
|
4
|
+
* Generate AGENT.md content from manifest and optional treeSchema.
|
|
5
|
+
*
|
|
6
|
+
* Exported for direct use in tests and other tools.
|
|
7
|
+
*/
|
|
8
|
+
function generateAgentMd(manifest, treeSchema) {
|
|
9
|
+
const lines = [];
|
|
10
|
+
lines.push("---");
|
|
11
|
+
lines.push(`name: ${manifest.name}`);
|
|
12
|
+
lines.push(`category: ${manifest.category}`);
|
|
13
|
+
lines.push(`uri: ${manifest.uriTemplate}`);
|
|
14
|
+
if (treeSchema) {
|
|
15
|
+
lines.push("operations:");
|
|
16
|
+
for (const op of treeSchema.operations) lines.push(` - ${op}`);
|
|
17
|
+
}
|
|
18
|
+
if (manifest.tags?.length) {
|
|
19
|
+
lines.push("tags:");
|
|
20
|
+
for (const tag of manifest.tags) lines.push(` - ${tag}`);
|
|
21
|
+
}
|
|
22
|
+
if (treeSchema?.auth) {
|
|
23
|
+
lines.push(`auth: ${treeSchema.auth.type}`);
|
|
24
|
+
if (treeSchema.auth.env?.length) {
|
|
25
|
+
lines.push("auth_env:");
|
|
26
|
+
for (const env of treeSchema.auth.env) lines.push(` - ${env}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
lines.push("---");
|
|
30
|
+
lines.push("");
|
|
31
|
+
lines.push(`# ${manifest.name}`);
|
|
32
|
+
lines.push("");
|
|
33
|
+
lines.push(manifest.description);
|
|
34
|
+
lines.push("");
|
|
35
|
+
if (treeSchema) {
|
|
36
|
+
lines.push("## Path Structure");
|
|
37
|
+
lines.push("");
|
|
38
|
+
for (const [path, node] of Object.entries(treeSchema.tree)) {
|
|
39
|
+
let line = `- \`${path}\` — ${node.kind}`;
|
|
40
|
+
if (node.actions?.length) line += ` (actions: ${node.actions.join(", ")})`;
|
|
41
|
+
if (node.destructive?.length) line += ` **[destructive: ${node.destructive.join(", ")}]**`;
|
|
42
|
+
lines.push(line);
|
|
43
|
+
}
|
|
44
|
+
lines.push("");
|
|
45
|
+
}
|
|
46
|
+
if (manifest.useCases?.length) {
|
|
47
|
+
lines.push("## Use Cases");
|
|
48
|
+
lines.push("");
|
|
49
|
+
for (const uc of manifest.useCases) lines.push(`- ${uc}`);
|
|
50
|
+
lines.push("");
|
|
51
|
+
}
|
|
52
|
+
if (treeSchema?.bestFor?.length) {
|
|
53
|
+
lines.push("## Best For");
|
|
54
|
+
lines.push("");
|
|
55
|
+
for (const item of treeSchema.bestFor) lines.push(`- ${item}`);
|
|
56
|
+
lines.push("");
|
|
57
|
+
}
|
|
58
|
+
if (treeSchema?.notFor?.length) {
|
|
59
|
+
lines.push("## Not Recommended For");
|
|
60
|
+
lines.push("");
|
|
61
|
+
for (const item of treeSchema.notFor) lines.push(`- ${item}`);
|
|
62
|
+
lines.push("");
|
|
63
|
+
}
|
|
64
|
+
return lines.join("\n");
|
|
65
|
+
}
|
|
66
|
+
const formatGenAgentMd = (result) => {
|
|
67
|
+
if (typeof result === "string") return result;
|
|
68
|
+
return JSON.stringify(result, null, 2);
|
|
69
|
+
};
|
|
70
|
+
function createGenAgentMdCommand(options) {
|
|
71
|
+
return {
|
|
72
|
+
command: "gen-agent-md <provider>",
|
|
73
|
+
describe: "Generate .afs/AGENT.md for a provider package",
|
|
74
|
+
builder: { provider: {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "Provider package name (e.g., @aigne/afs-sqlite) or directory path",
|
|
77
|
+
demandOption: true
|
|
78
|
+
} },
|
|
79
|
+
handler: async (argv) => {
|
|
80
|
+
try {
|
|
81
|
+
const providerPath = argv.provider;
|
|
82
|
+
const mod = await import(providerPath);
|
|
83
|
+
let manifest;
|
|
84
|
+
let treeSchema;
|
|
85
|
+
for (const key of Object.keys(mod)) {
|
|
86
|
+
const val = mod[key];
|
|
87
|
+
if (typeof val !== "function") continue;
|
|
88
|
+
if (typeof val.manifest !== "function") continue;
|
|
89
|
+
const result = val.manifest();
|
|
90
|
+
const m = Array.isArray(result) ? result[0] : result;
|
|
91
|
+
if (m?.name) {
|
|
92
|
+
manifest = m;
|
|
93
|
+
if (typeof val.treeSchema === "function") treeSchema = val.treeSchema();
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!manifest) {
|
|
98
|
+
options.onResult({
|
|
99
|
+
command: "gen-agent-md",
|
|
100
|
+
result: null,
|
|
101
|
+
format: formatGenAgentMd,
|
|
102
|
+
error: { message: `No provider class with static manifest() found in ${providerPath}` }
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const content = generateAgentMd(manifest, treeSchema);
|
|
107
|
+
options.onResult({
|
|
108
|
+
command: "gen-agent-md",
|
|
109
|
+
result: content,
|
|
110
|
+
format: formatGenAgentMd
|
|
111
|
+
});
|
|
112
|
+
} catch (err) {
|
|
113
|
+
options.onResult({
|
|
114
|
+
command: "gen-agent-md",
|
|
115
|
+
result: null,
|
|
116
|
+
format: formatGenAgentMd,
|
|
117
|
+
error: { message: `Failed to generate AGENT.md: ${err}` }
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
exports.createGenAgentMdCommand = createGenAgentMdCommand;
|
|
126
|
+
exports.generateAgentMd = generateAgentMd;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
//#region src/core/commands/gen-agent-md.ts
|
|
2
|
+
/**
|
|
3
|
+
* Generate AGENT.md content from manifest and optional treeSchema.
|
|
4
|
+
*
|
|
5
|
+
* Exported for direct use in tests and other tools.
|
|
6
|
+
*/
|
|
7
|
+
function generateAgentMd(manifest, treeSchema) {
|
|
8
|
+
const lines = [];
|
|
9
|
+
lines.push("---");
|
|
10
|
+
lines.push(`name: ${manifest.name}`);
|
|
11
|
+
lines.push(`category: ${manifest.category}`);
|
|
12
|
+
lines.push(`uri: ${manifest.uriTemplate}`);
|
|
13
|
+
if (treeSchema) {
|
|
14
|
+
lines.push("operations:");
|
|
15
|
+
for (const op of treeSchema.operations) lines.push(` - ${op}`);
|
|
16
|
+
}
|
|
17
|
+
if (manifest.tags?.length) {
|
|
18
|
+
lines.push("tags:");
|
|
19
|
+
for (const tag of manifest.tags) lines.push(` - ${tag}`);
|
|
20
|
+
}
|
|
21
|
+
if (treeSchema?.auth) {
|
|
22
|
+
lines.push(`auth: ${treeSchema.auth.type}`);
|
|
23
|
+
if (treeSchema.auth.env?.length) {
|
|
24
|
+
lines.push("auth_env:");
|
|
25
|
+
for (const env of treeSchema.auth.env) lines.push(` - ${env}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
lines.push("---");
|
|
29
|
+
lines.push("");
|
|
30
|
+
lines.push(`# ${manifest.name}`);
|
|
31
|
+
lines.push("");
|
|
32
|
+
lines.push(manifest.description);
|
|
33
|
+
lines.push("");
|
|
34
|
+
if (treeSchema) {
|
|
35
|
+
lines.push("## Path Structure");
|
|
36
|
+
lines.push("");
|
|
37
|
+
for (const [path, node] of Object.entries(treeSchema.tree)) {
|
|
38
|
+
let line = `- \`${path}\` — ${node.kind}`;
|
|
39
|
+
if (node.actions?.length) line += ` (actions: ${node.actions.join(", ")})`;
|
|
40
|
+
if (node.destructive?.length) line += ` **[destructive: ${node.destructive.join(", ")}]**`;
|
|
41
|
+
lines.push(line);
|
|
42
|
+
}
|
|
43
|
+
lines.push("");
|
|
44
|
+
}
|
|
45
|
+
if (manifest.useCases?.length) {
|
|
46
|
+
lines.push("## Use Cases");
|
|
47
|
+
lines.push("");
|
|
48
|
+
for (const uc of manifest.useCases) lines.push(`- ${uc}`);
|
|
49
|
+
lines.push("");
|
|
50
|
+
}
|
|
51
|
+
if (treeSchema?.bestFor?.length) {
|
|
52
|
+
lines.push("## Best For");
|
|
53
|
+
lines.push("");
|
|
54
|
+
for (const item of treeSchema.bestFor) lines.push(`- ${item}`);
|
|
55
|
+
lines.push("");
|
|
56
|
+
}
|
|
57
|
+
if (treeSchema?.notFor?.length) {
|
|
58
|
+
lines.push("## Not Recommended For");
|
|
59
|
+
lines.push("");
|
|
60
|
+
for (const item of treeSchema.notFor) lines.push(`- ${item}`);
|
|
61
|
+
lines.push("");
|
|
62
|
+
}
|
|
63
|
+
return lines.join("\n");
|
|
64
|
+
}
|
|
65
|
+
const formatGenAgentMd = (result) => {
|
|
66
|
+
if (typeof result === "string") return result;
|
|
67
|
+
return JSON.stringify(result, null, 2);
|
|
68
|
+
};
|
|
69
|
+
function createGenAgentMdCommand(options) {
|
|
70
|
+
return {
|
|
71
|
+
command: "gen-agent-md <provider>",
|
|
72
|
+
describe: "Generate .afs/AGENT.md for a provider package",
|
|
73
|
+
builder: { provider: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "Provider package name (e.g., @aigne/afs-sqlite) or directory path",
|
|
76
|
+
demandOption: true
|
|
77
|
+
} },
|
|
78
|
+
handler: async (argv) => {
|
|
79
|
+
try {
|
|
80
|
+
const providerPath = argv.provider;
|
|
81
|
+
const mod = await import(providerPath);
|
|
82
|
+
let manifest;
|
|
83
|
+
let treeSchema;
|
|
84
|
+
for (const key of Object.keys(mod)) {
|
|
85
|
+
const val = mod[key];
|
|
86
|
+
if (typeof val !== "function") continue;
|
|
87
|
+
if (typeof val.manifest !== "function") continue;
|
|
88
|
+
const result = val.manifest();
|
|
89
|
+
const m = Array.isArray(result) ? result[0] : result;
|
|
90
|
+
if (m?.name) {
|
|
91
|
+
manifest = m;
|
|
92
|
+
if (typeof val.treeSchema === "function") treeSchema = val.treeSchema();
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!manifest) {
|
|
97
|
+
options.onResult({
|
|
98
|
+
command: "gen-agent-md",
|
|
99
|
+
result: null,
|
|
100
|
+
format: formatGenAgentMd,
|
|
101
|
+
error: { message: `No provider class with static manifest() found in ${providerPath}` }
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const content = generateAgentMd(manifest, treeSchema);
|
|
106
|
+
options.onResult({
|
|
107
|
+
command: "gen-agent-md",
|
|
108
|
+
result: content,
|
|
109
|
+
format: formatGenAgentMd
|
|
110
|
+
});
|
|
111
|
+
} catch (err) {
|
|
112
|
+
options.onResult({
|
|
113
|
+
command: "gen-agent-md",
|
|
114
|
+
result: null,
|
|
115
|
+
format: formatGenAgentMd,
|
|
116
|
+
error: { message: `Failed to generate AGENT.md: ${err}` }
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
export { createGenAgentMdCommand, generateAgentMd };
|
|
125
|
+
//# sourceMappingURL=gen-agent-md.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gen-agent-md.mjs","names":[],"sources":["../../../src/core/commands/gen-agent-md.ts"],"sourcesContent":["/**\n * gen-agent-md Command\n *\n * Generates a .afs/AGENT.md file from a provider's manifest and treeSchema.\n * This is a developer tool for provider authors.\n */\n\nimport type { CommandModule } from \"yargs\";\nimport type { CommandFactoryOptions, FormatFunction } from \"./types.js\";\n\nexport interface GenAgentMdArgs {\n provider: string;\n}\n\ninterface ManifestInput {\n name: string;\n description: string;\n category: string;\n uriTemplate: string;\n tags?: string[];\n useCases?: string[];\n}\n\ninterface TreeSchemaInput {\n operations: string[];\n tree: Record<\n string,\n { kind: string; operations?: string[]; actions?: string[]; destructive?: string[] }\n >;\n auth?: { type: string; env?: string[] };\n bestFor?: string[];\n notFor?: string[];\n}\n\n/**\n * Generate AGENT.md content from manifest and optional treeSchema.\n *\n * Exported for direct use in tests and other tools.\n */\nexport function generateAgentMd(manifest: ManifestInput, treeSchema?: TreeSchemaInput): string {\n const lines: string[] = [];\n\n // YAML frontmatter\n lines.push(\"---\");\n lines.push(`name: ${manifest.name}`);\n lines.push(`category: ${manifest.category}`);\n lines.push(`uri: ${manifest.uriTemplate}`);\n\n if (treeSchema) {\n lines.push(\"operations:\");\n for (const op of treeSchema.operations) {\n lines.push(` - ${op}`);\n }\n }\n\n if (manifest.tags?.length) {\n lines.push(\"tags:\");\n for (const tag of manifest.tags) {\n lines.push(` - ${tag}`);\n }\n }\n\n if (treeSchema?.auth) {\n lines.push(`auth: ${treeSchema.auth.type}`);\n if (treeSchema.auth.env?.length) {\n lines.push(\"auth_env:\");\n for (const env of treeSchema.auth.env) {\n lines.push(` - ${env}`);\n }\n }\n }\n\n lines.push(\"---\");\n lines.push(\"\");\n\n // Markdown body\n lines.push(`# ${manifest.name}`);\n lines.push(\"\");\n lines.push(manifest.description);\n lines.push(\"\");\n\n // Path structure from treeSchema\n if (treeSchema) {\n lines.push(\"## Path Structure\");\n lines.push(\"\");\n for (const [path, node] of Object.entries(treeSchema.tree)) {\n let line = `- \\`${path}\\` — ${node.kind}`;\n if (node.actions?.length) {\n line += ` (actions: ${node.actions.join(\", \")})`;\n }\n if (node.destructive?.length) {\n line += ` **[destructive: ${node.destructive.join(\", \")}]**`;\n }\n lines.push(line);\n }\n lines.push(\"\");\n }\n\n // Use cases\n if (manifest.useCases?.length) {\n lines.push(\"## Use Cases\");\n lines.push(\"\");\n for (const uc of manifest.useCases) {\n lines.push(`- ${uc}`);\n }\n lines.push(\"\");\n }\n\n // Best for / Not for\n if (treeSchema?.bestFor?.length) {\n lines.push(\"## Best For\");\n lines.push(\"\");\n for (const item of treeSchema.bestFor) {\n lines.push(`- ${item}`);\n }\n lines.push(\"\");\n }\n\n if (treeSchema?.notFor?.length) {\n lines.push(\"## Not Recommended For\");\n lines.push(\"\");\n for (const item of treeSchema.notFor) {\n lines.push(`- ${item}`);\n }\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n}\n\nconst formatGenAgentMd: FormatFunction = (result) => {\n if (typeof result === \"string\") return result;\n return JSON.stringify(result, null, 2);\n};\n\nexport function createGenAgentMdCommand(\n options: CommandFactoryOptions,\n): CommandModule<unknown, GenAgentMdArgs> {\n return {\n command: \"gen-agent-md <provider>\",\n describe: \"Generate .afs/AGENT.md for a provider package\",\n builder: {\n provider: {\n type: \"string\",\n description: \"Provider package name (e.g., @aigne/afs-sqlite) or directory path\",\n demandOption: true,\n },\n },\n handler: async (argv) => {\n try {\n const providerPath = argv.provider;\n\n // Dynamic import the provider package\n const mod = (await import(providerPath)) as Record<string, unknown>;\n\n // Find the provider class with static manifest()\n let manifest: ManifestInput | undefined;\n let treeSchema: TreeSchemaInput | undefined;\n\n for (const key of Object.keys(mod)) {\n const val = mod[key];\n if (typeof val !== \"function\") continue;\n if (typeof (val as any).manifest !== \"function\") continue;\n\n const result = (val as any).manifest();\n const m = Array.isArray(result) ? result[0] : result;\n if (m?.name) {\n manifest = m;\n if (typeof (val as any).treeSchema === \"function\") {\n treeSchema = (val as any).treeSchema();\n }\n break;\n }\n }\n\n if (!manifest) {\n options.onResult({\n command: \"gen-agent-md\",\n result: null,\n format: formatGenAgentMd,\n error: { message: `No provider class with static manifest() found in ${providerPath}` },\n });\n return;\n }\n\n const content = generateAgentMd(manifest, treeSchema);\n\n options.onResult({\n command: \"gen-agent-md\",\n result: content,\n format: formatGenAgentMd,\n });\n } catch (err) {\n options.onResult({\n command: \"gen-agent-md\",\n result: null,\n format: formatGenAgentMd,\n error: { message: `Failed to generate AGENT.md: ${err}` },\n });\n }\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
const require_connect = require('./connect.cjs');
|
|
2
|
+
const require_daemon = require('./daemon.cjs');
|
|
1
3
|
const require_types = require('./types.cjs');
|
|
2
4
|
const require_delete = require('./delete.cjs');
|
|
3
5
|
const require_exec_args = require('../helpers/exec-args.cjs');
|
|
4
6
|
const require_exec = require('./exec.cjs');
|
|
5
7
|
const require_explain = require('./explain.cjs');
|
|
6
8
|
const require_explore = require('./explore.cjs');
|
|
9
|
+
const require_gen_agent_md = require('./gen-agent-md.cjs');
|
|
10
|
+
const require_install = require('./install.cjs');
|
|
7
11
|
const require_ls = require('./ls.cjs');
|
|
12
|
+
const require_mcp_bridge = require('./mcp-bridge.cjs');
|
|
8
13
|
const require_mount = require('./mount.cjs');
|
|
9
14
|
const require_read = require('./read.cjs');
|
|
10
15
|
const require_search = require('./search.cjs');
|
|
11
16
|
const require_serve = require('./serve.cjs');
|
|
12
17
|
const require_stat = require('./stat.cjs');
|
|
18
|
+
const require_vault = require('./vault.cjs');
|
|
13
19
|
const require_write = require('./write.cjs');
|
|
14
20
|
|
|
15
21
|
//#region src/core/commands/index.ts
|
|
@@ -29,7 +35,13 @@ const commandFactories = [
|
|
|
29
35
|
require_search.createSearchCommand,
|
|
30
36
|
require_mount.createMountCommand,
|
|
31
37
|
require_serve.createServeCommand,
|
|
32
|
-
require_explore.createExploreCommand
|
|
38
|
+
require_explore.createExploreCommand,
|
|
39
|
+
require_vault.createVaultCommand,
|
|
40
|
+
require_daemon.createServiceCommand,
|
|
41
|
+
require_connect.createConnectCommand,
|
|
42
|
+
require_mcp_bridge.createMcpBridgeCommand,
|
|
43
|
+
require_gen_agent_md.createGenAgentMdCommand,
|
|
44
|
+
require_install.createInstallCommand
|
|
33
45
|
];
|
|
34
46
|
|
|
35
47
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/core/commands/index.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/core/commands/index.ts"],"mappings":";;;;;;;;;;;;;;;;;cAoEa,gBAAA,EAAkB,cAAA"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { CommandFactory, CommandFactoryOptions, CommandOutput, FormatFunction } from "./types.mjs";
|
|
2
|
+
import "./connect.mjs";
|
|
3
|
+
import "./daemon.mjs";
|
|
2
4
|
import { DeleteArgs, createDeleteCommand } from "./delete.mjs";
|
|
3
5
|
import { parseExecArgs, parseValueBySchema } from "../helpers/exec-args.mjs";
|
|
4
6
|
import { ExecArgs, createExecCommand } from "./exec.mjs";
|
|
5
7
|
import { ExplainArgs, createExplainCommand } from "./explain.mjs";
|
|
6
8
|
import "./explore.mjs";
|
|
9
|
+
import "./gen-agent-md.mjs";
|
|
10
|
+
import "./install.mjs";
|
|
7
11
|
import { LsArgs, createLsCommand } from "./ls.mjs";
|
|
12
|
+
import "./mcp-bridge.mjs";
|
|
8
13
|
import { MountAddArgs, MountListArgs, MountRemoveArgs, createMountCommand } from "./mount.mjs";
|
|
9
14
|
import { ReadArgs, createReadCommand } from "./read.mjs";
|
|
10
15
|
import "./search.mjs";
|
|
11
16
|
import "./serve.mjs";
|
|
12
17
|
import { StatArgs, createStatCommand } from "./stat.mjs";
|
|
18
|
+
import "./vault.mjs";
|
|
13
19
|
import { WriteArgs, createWriteCommand } from "./write.mjs";
|
|
14
20
|
|
|
15
21
|
//#region src/core/commands/index.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/core/commands/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/core/commands/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;cAoEa,gBAAA,EAAkB,cAAA"}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { createConnectCommand } from "./connect.mjs";
|
|
2
|
+
import { createServiceCommand } from "./daemon.mjs";
|
|
1
3
|
import { resolveAFS } from "./types.mjs";
|
|
2
4
|
import { createDeleteCommand } from "./delete.mjs";
|
|
3
5
|
import { parseExecArgs, parseValueBySchema } from "../helpers/exec-args.mjs";
|
|
4
6
|
import { createExecCommand } from "./exec.mjs";
|
|
5
7
|
import { createExplainCommand } from "./explain.mjs";
|
|
6
8
|
import { createExploreCommand } from "./explore.mjs";
|
|
9
|
+
import { createGenAgentMdCommand, generateAgentMd } from "./gen-agent-md.mjs";
|
|
10
|
+
import { createInstallCommand } from "./install.mjs";
|
|
7
11
|
import { createLsCommand } from "./ls.mjs";
|
|
12
|
+
import { createMcpBridgeCommand } from "./mcp-bridge.mjs";
|
|
8
13
|
import { createMountCommand } from "./mount.mjs";
|
|
9
14
|
import { createReadCommand } from "./read.mjs";
|
|
10
15
|
import { createSearchCommand } from "./search.mjs";
|
|
11
16
|
import { createServeCommand } from "./serve.mjs";
|
|
12
17
|
import { createStatCommand } from "./stat.mjs";
|
|
18
|
+
import { createVaultCommand } from "./vault.mjs";
|
|
13
19
|
import { createWriteCommand } from "./write.mjs";
|
|
14
20
|
|
|
15
21
|
//#region src/core/commands/index.ts
|
|
@@ -29,7 +35,13 @@ const commandFactories = [
|
|
|
29
35
|
createSearchCommand,
|
|
30
36
|
createMountCommand,
|
|
31
37
|
createServeCommand,
|
|
32
|
-
createExploreCommand
|
|
38
|
+
createExploreCommand,
|
|
39
|
+
createVaultCommand,
|
|
40
|
+
createServiceCommand,
|
|
41
|
+
createConnectCommand,
|
|
42
|
+
createMcpBridgeCommand,
|
|
43
|
+
createGenAgentMdCommand,
|
|
44
|
+
createInstallCommand
|
|
33
45
|
];
|
|
34
46
|
|
|
35
47
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/commands/index.ts"],"sourcesContent":["/**\n * CLI Core Commands\n *\n * Re-exports all command implementations and factories.\n */\n\n// Command factories and types\nexport { createDeleteCommand, type DeleteArgs } from \"./delete.js\";\nexport { createExecCommand, type ExecArgs, parseExecArgs, parseValueBySchema } from \"./exec.js\";\nexport { createExplainCommand, type ExplainArgs } from \"./explain.js\";\nexport { createExploreCommand, type ExploreArgs } from \"./explore.js\";\nexport { createLsCommand, type LsArgs } from \"./ls.js\";\nexport {\n createMountCommand,\n type MountAddArgs,\n type MountListArgs,\n type MountRemoveArgs,\n} from \"./mount.js\";\nexport { createReadCommand, type ReadArgs } from \"./read.js\";\nexport { createSearchCommand, type SearchArgs } from \"./search.js\";\nexport { createServeCommand, type ServeArgs, type ServeResult } from \"./serve.js\";\nexport { createStatCommand, type StatArgs } from \"./stat.js\";\n// Types and helpers\nexport type {\n CommandFactory,\n CommandFactoryOptions,\n CommandOutput,\n FormatFunction,\n} from \"./types.js\";\nexport { resolveAFS } from \"./types.js\";\nexport { createWriteCommand, type WriteArgs } from \"./write.js\";\n\n// Import factories for array export\nimport { createDeleteCommand } from \"./delete.js\";\nimport { createExecCommand } from \"./exec.js\";\nimport { createExplainCommand } from \"./explain.js\";\nimport { createExploreCommand } from \"./explore.js\";\nimport { createLsCommand } from \"./ls.js\";\nimport { createMountCommand } from \"./mount.js\";\nimport { createReadCommand } from \"./read.js\";\nimport { createSearchCommand } from \"./search.js\";\nimport { createServeCommand } from \"./serve.js\";\nimport { createStatCommand } from \"./stat.js\";\nimport type { CommandFactory } from \"./types.js\";\nimport { createWriteCommand } from \"./write.js\";\n\n/**\n * Array of all command factories\n *\n * Used by AFSCommandExecutor to register all commands.\n */\nexport const commandFactories: CommandFactory[] = [\n createLsCommand,\n createReadCommand,\n createWriteCommand,\n createDeleteCommand,\n createStatCommand,\n createExecCommand,\n createExplainCommand,\n createSearchCommand,\n createMountCommand,\n createServeCommand,\n createExploreCommand,\n];\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/commands/index.ts"],"sourcesContent":["/**\n * CLI Core Commands\n *\n * Re-exports all command implementations and factories.\n */\n\nexport { type ConnectArgs, createConnectCommand } from \"./connect.js\";\nexport { createServiceCommand, type ServiceArgs } from \"./daemon.js\";\n// Command factories and types\nexport { createDeleteCommand, type DeleteArgs } from \"./delete.js\";\nexport { createExecCommand, type ExecArgs, parseExecArgs, parseValueBySchema } from \"./exec.js\";\nexport { createExplainCommand, type ExplainArgs } from \"./explain.js\";\nexport { createExploreCommand, type ExploreArgs } from \"./explore.js\";\nexport { createGenAgentMdCommand, type GenAgentMdArgs, generateAgentMd } from \"./gen-agent-md.js\";\nexport {\n createInstallCommand,\n type InstallAddArgs,\n type InstallConfigureArgs,\n type InstallRemoveArgs,\n} from \"./install.js\";\nexport { createLsCommand, type LsArgs } from \"./ls.js\";\nexport { createMcpBridgeCommand, type McpBridgeArgs } from \"./mcp-bridge.js\";\nexport {\n createMountCommand,\n type MountAddArgs,\n type MountListArgs,\n type MountRemoveArgs,\n} from \"./mount.js\";\nexport { createReadCommand, type ReadArgs } from \"./read.js\";\nexport { createSearchCommand, type SearchArgs } from \"./search.js\";\nexport { createServeCommand, type ServeArgs, type ServeResult } from \"./serve.js\";\nexport { createStatCommand, type StatArgs } from \"./stat.js\";\n// Types and helpers\nexport type {\n CommandFactory,\n CommandFactoryOptions,\n CommandOutput,\n FormatFunction,\n} from \"./types.js\";\nexport { resolveAFS } from \"./types.js\";\nexport { createVaultCommand } from \"./vault.js\";\nexport { createWriteCommand, type WriteArgs } from \"./write.js\";\n\n// Import factories for array export\nimport { createConnectCommand } from \"./connect.js\";\nimport { createServiceCommand } from \"./daemon.js\";\nimport { createDeleteCommand } from \"./delete.js\";\nimport { createExecCommand } from \"./exec.js\";\nimport { createExplainCommand } from \"./explain.js\";\nimport { createExploreCommand } from \"./explore.js\";\nimport { createGenAgentMdCommand } from \"./gen-agent-md.js\";\nimport { createInstallCommand } from \"./install.js\";\nimport { createLsCommand } from \"./ls.js\";\nimport { createMcpBridgeCommand } from \"./mcp-bridge.js\";\nimport { createMountCommand } from \"./mount.js\";\nimport { createReadCommand } from \"./read.js\";\nimport { createSearchCommand } from \"./search.js\";\nimport { createServeCommand } from \"./serve.js\";\nimport { createStatCommand } from \"./stat.js\";\nimport type { CommandFactory } from \"./types.js\";\nimport { createVaultCommand } from \"./vault.js\";\nimport { createWriteCommand } from \"./write.js\";\n\n/**\n * Array of all command factories\n *\n * Used by AFSCommandExecutor to register all commands.\n */\nexport const commandFactories: CommandFactory[] = [\n createLsCommand,\n createReadCommand,\n createWriteCommand,\n createDeleteCommand,\n createStatCommand,\n createExecCommand,\n createExplainCommand,\n createSearchCommand,\n createMountCommand,\n createServeCommand,\n createExploreCommand,\n createVaultCommand,\n createServiceCommand,\n createConnectCommand,\n createMcpBridgeCommand,\n createGenAgentMdCommand,\n createInstallCommand,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,MAAa,mBAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const require_install = require('../formatters/install.cjs');
|
|
2
|
+
const require_program_install = require('../../config/program-install.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/core/commands/install.ts
|
|
5
|
+
/**
|
|
6
|
+
* Create program command factory (with subcommands)
|
|
7
|
+
*/
|
|
8
|
+
function createInstallCommand(options) {
|
|
9
|
+
return {
|
|
10
|
+
command: "program",
|
|
11
|
+
describe: "Install and manage AFS programs",
|
|
12
|
+
builder: (yargs) => yargs.command(createProgramInstallSubcommand(options)).command(createProgramListSubcommand(options)).command(createProgramUninstallSubcommand(options)).command(createProgramConfigureSubcommand(options)).demandCommand(1, "Specify a subcommand: install, list, uninstall, configure").alias("help", "h"),
|
|
13
|
+
handler: () => {}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* program install <source>
|
|
18
|
+
*/
|
|
19
|
+
function createProgramInstallSubcommand(options) {
|
|
20
|
+
return {
|
|
21
|
+
command: "install <source>",
|
|
22
|
+
describe: "Install a program from local directory, GitHub URL, or zip file",
|
|
23
|
+
builder: { source: {
|
|
24
|
+
type: "string",
|
|
25
|
+
demandOption: true,
|
|
26
|
+
description: "Source: local path, GitHub URL, or .zip file"
|
|
27
|
+
} },
|
|
28
|
+
handler: async (argv) => {
|
|
29
|
+
const cwd = options.cwd ?? process.cwd();
|
|
30
|
+
const result = await require_program_install.installProgram(argv.source, { cwd });
|
|
31
|
+
options.onResult({
|
|
32
|
+
command: "program install",
|
|
33
|
+
result,
|
|
34
|
+
format: require_install.formatInstallAddOutput
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* program list
|
|
41
|
+
*/
|
|
42
|
+
function createProgramListSubcommand(options) {
|
|
43
|
+
return {
|
|
44
|
+
command: ["list", "ls"],
|
|
45
|
+
describe: "List installed programs",
|
|
46
|
+
handler: async () => {
|
|
47
|
+
const programs = await require_program_install.listInstalledPrograms();
|
|
48
|
+
options.onResult({
|
|
49
|
+
command: "program list",
|
|
50
|
+
result: programs,
|
|
51
|
+
format: require_install.formatInstallListOutput
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* program uninstall <id>
|
|
58
|
+
*/
|
|
59
|
+
function createProgramUninstallSubcommand(options) {
|
|
60
|
+
return {
|
|
61
|
+
command: "uninstall <id>",
|
|
62
|
+
describe: "Uninstall an installed program",
|
|
63
|
+
builder: {
|
|
64
|
+
id: {
|
|
65
|
+
type: "string",
|
|
66
|
+
demandOption: true,
|
|
67
|
+
description: "Program ID to uninstall"
|
|
68
|
+
},
|
|
69
|
+
purge: {
|
|
70
|
+
type: "boolean",
|
|
71
|
+
default: false,
|
|
72
|
+
description: "Also remove program data directory"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
handler: async (argv) => {
|
|
76
|
+
const cwd = options.cwd ?? process.cwd();
|
|
77
|
+
const result = await require_program_install.removeProgram(argv.id, {
|
|
78
|
+
purge: argv.purge,
|
|
79
|
+
cwd
|
|
80
|
+
});
|
|
81
|
+
options.onResult({
|
|
82
|
+
command: "program uninstall",
|
|
83
|
+
result,
|
|
84
|
+
format: require_install.formatInstallRemoveOutput
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* program configure <id>
|
|
91
|
+
*/
|
|
92
|
+
function createProgramConfigureSubcommand(options) {
|
|
93
|
+
return {
|
|
94
|
+
command: "configure <id>",
|
|
95
|
+
describe: "Configure mount credentials for an installed program",
|
|
96
|
+
builder: {
|
|
97
|
+
id: {
|
|
98
|
+
type: "string",
|
|
99
|
+
demandOption: true,
|
|
100
|
+
description: "Program ID to configure"
|
|
101
|
+
},
|
|
102
|
+
force: {
|
|
103
|
+
type: "string",
|
|
104
|
+
alias: "f",
|
|
105
|
+
description: "Force re-configure (optionally specify mount path, e.g. /telegram)"
|
|
106
|
+
},
|
|
107
|
+
list: {
|
|
108
|
+
type: "boolean",
|
|
109
|
+
alias: "l",
|
|
110
|
+
default: false,
|
|
111
|
+
description: "List configurable mounts and their status"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
handler: async (argv) => {
|
|
115
|
+
const cwd = options.cwd ?? process.cwd();
|
|
116
|
+
if (argv.list) {
|
|
117
|
+
const result$1 = await require_program_install.listProgramMountStatus(argv.id);
|
|
118
|
+
options.onResult({
|
|
119
|
+
command: "program configure --list",
|
|
120
|
+
result: result$1,
|
|
121
|
+
format: require_install.formatConfigureListOutput
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const result = await require_program_install.configureProgramMounts(argv.id, {
|
|
126
|
+
cwd,
|
|
127
|
+
force: argv.force
|
|
128
|
+
});
|
|
129
|
+
options.onResult({
|
|
130
|
+
command: "program configure",
|
|
131
|
+
result,
|
|
132
|
+
format: require_install.formatConfigureOutput
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
exports.createInstallCommand = createInstallCommand;
|