@aigne/afs-cli 1.11.0-beta.10 → 1.11.0-beta.12
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 +64 -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 +59 -310
- package/dist/config/afs-loader.mjs.map +1 -1
- package/dist/config/credential-helpers.cjs +291 -0
- package/dist/config/credential-helpers.d.mts +2 -0
- package/dist/config/credential-helpers.mjs +288 -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 +276 -0
- package/dist/config/program-install.d.mts +1 -0
- package/dist/config/program-install.mjs +273 -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 +207 -0
- package/dist/core/commands/daemon.d.mts +2 -0
- package/dist/core/commands/daemon.mjs +208 -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 +91 -0
- package/dist/core/commands/install.d.mts +2 -0
- package/dist/core/commands/install.mjs +92 -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 +21 -0
- package/dist/core/formatters/install.d.mts +1 -0
- package/dist/core/formatters/install.mjs +19 -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/index.d.mts +2 -1
- package/dist/credential/mcp-auth-context.cjs +27 -5
- package/dist/credential/mcp-auth-context.mjs +27 -5
- package/dist/credential/mcp-auth-context.mjs.map +1 -1
- package/dist/credential/resolver.cjs +7 -2
- package/dist/credential/resolver.mjs +7 -2
- 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 +162 -0
- package/dist/program/program-manager.mjs +162 -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 +105 -14
- package/dist/repl.d.cts.map +1 -1
- package/dist/repl.d.mts.map +1 -1
- package/dist/repl.mjs +105 -14
- package/dist/repl.mjs.map +1 -1
- package/package.json +29 -22
|
@@ -0,0 +1,91 @@
|
|
|
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)).demandCommand(1, "Specify a subcommand: install, list, uninstall").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
|
+
//#endregion
|
|
91
|
+
exports.createInstallCommand = createInstallCommand;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { formatInstallAddOutput, formatInstallListOutput, formatInstallRemoveOutput } from "../formatters/install.mjs";
|
|
2
|
+
import { installProgram, listInstalledPrograms, removeProgram } from "../../config/program-install.mjs";
|
|
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)).demandCommand(1, "Specify a subcommand: install, list, uninstall").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 installProgram(argv.source, { cwd });
|
|
31
|
+
options.onResult({
|
|
32
|
+
command: "program install",
|
|
33
|
+
result,
|
|
34
|
+
format: 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 listInstalledPrograms();
|
|
48
|
+
options.onResult({
|
|
49
|
+
command: "program list",
|
|
50
|
+
result: programs,
|
|
51
|
+
format: 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 removeProgram(argv.id, {
|
|
78
|
+
purge: argv.purge,
|
|
79
|
+
cwd
|
|
80
|
+
});
|
|
81
|
+
options.onResult({
|
|
82
|
+
command: "program uninstall",
|
|
83
|
+
result,
|
|
84
|
+
format: formatInstallRemoveOutput
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
export { createInstallCommand };
|
|
92
|
+
//# sourceMappingURL=install.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.mjs","names":[],"sources":["../../../src/core/commands/install.ts"],"sourcesContent":["/**\n * program Command — Install, list, and uninstall AFS programs.\n *\n * Programs are installed to ~/.afs-config/programs/<id>/\n * and mounted at /programs/<id> in user-level config.\n */\n\nimport type { Argv, CommandModule } from \"yargs\";\nimport {\n installProgram,\n listInstalledPrograms,\n removeProgram,\n} from \"../../config/program-install.js\";\nimport {\n formatInstallAddOutput,\n formatInstallListOutput,\n formatInstallRemoveOutput,\n} from \"../formatters/install.js\";\nimport type { CommandFactoryOptions } from \"./types.js\";\n\nexport interface InstallAddArgs {\n source: string;\n}\n\nexport interface InstallRemoveArgs {\n id: string;\n purge?: boolean;\n}\n\n/**\n * Create program command factory (with subcommands)\n */\nexport function createInstallCommand(options: CommandFactoryOptions): CommandModule {\n return {\n command: \"program\",\n describe: \"Install and manage AFS programs\",\n builder: (yargs: Argv) =>\n yargs\n .command(createProgramInstallSubcommand(options))\n .command(createProgramListSubcommand(options))\n .command(createProgramUninstallSubcommand(options))\n .demandCommand(1, \"Specify a subcommand: install, list, uninstall\")\n .alias(\"help\", \"h\"),\n handler: () => {},\n };\n}\n\n/**\n * program install <source>\n */\nfunction createProgramInstallSubcommand(\n options: CommandFactoryOptions,\n): CommandModule<unknown, InstallAddArgs> {\n return {\n command: \"install <source>\",\n describe: \"Install a program from local directory, GitHub URL, or zip file\",\n builder: {\n source: {\n type: \"string\",\n demandOption: true,\n description: \"Source: local path, GitHub URL, or .zip file\",\n },\n },\n handler: async (argv) => {\n const cwd = options.cwd ?? process.cwd();\n const result = await installProgram(argv.source, { cwd });\n\n options.onResult({\n command: \"program install\",\n result,\n format: formatInstallAddOutput,\n });\n },\n };\n}\n\n/**\n * program list\n */\nfunction createProgramListSubcommand(options: CommandFactoryOptions): CommandModule {\n return {\n command: [\"list\", \"ls\"],\n describe: \"List installed programs\",\n handler: async () => {\n const programs = await listInstalledPrograms();\n\n options.onResult({\n command: \"program list\",\n result: programs,\n format: formatInstallListOutput,\n });\n },\n };\n}\n\n/**\n * program uninstall <id>\n */\nfunction createProgramUninstallSubcommand(\n options: CommandFactoryOptions,\n): CommandModule<unknown, InstallRemoveArgs> {\n return {\n command: \"uninstall <id>\",\n describe: \"Uninstall an installed program\",\n builder: {\n id: {\n type: \"string\",\n demandOption: true,\n description: \"Program ID to uninstall\",\n },\n purge: {\n type: \"boolean\",\n default: false,\n description: \"Also remove program data directory\",\n },\n },\n handler: async (argv) => {\n const cwd = options.cwd ?? process.cwd();\n const result = await removeProgram(argv.id, { purge: argv.purge, cwd });\n\n options.onResult({\n command: \"program uninstall\",\n result,\n format: formatInstallRemoveOutput,\n });\n },\n };\n}\n"],"mappings":";;;;;;;AAgCA,SAAgB,qBAAqB,SAA+C;AAClF,QAAO;EACL,SAAS;EACT,UAAU;EACV,UAAU,UACR,MACG,QAAQ,+BAA+B,QAAQ,CAAC,CAChD,QAAQ,4BAA4B,QAAQ,CAAC,CAC7C,QAAQ,iCAAiC,QAAQ,CAAC,CAClD,cAAc,GAAG,iDAAiD,CAClE,MAAM,QAAQ,IAAI;EACvB,eAAe;EAChB;;;;;AAMH,SAAS,+BACP,SACwC;AACxC,QAAO;EACL,SAAS;EACT,UAAU;EACV,SAAS,EACP,QAAQ;GACN,MAAM;GACN,cAAc;GACd,aAAa;GACd,EACF;EACD,SAAS,OAAO,SAAS;GACvB,MAAM,MAAM,QAAQ,OAAO,QAAQ,KAAK;GACxC,MAAM,SAAS,MAAM,eAAe,KAAK,QAAQ,EAAE,KAAK,CAAC;AAEzD,WAAQ,SAAS;IACf,SAAS;IACT;IACA,QAAQ;IACT,CAAC;;EAEL;;;;;AAMH,SAAS,4BAA4B,SAA+C;AAClF,QAAO;EACL,SAAS,CAAC,QAAQ,KAAK;EACvB,UAAU;EACV,SAAS,YAAY;GACnB,MAAM,WAAW,MAAM,uBAAuB;AAE9C,WAAQ,SAAS;IACf,SAAS;IACT,QAAQ;IACR,QAAQ;IACT,CAAC;;EAEL;;;;;AAMH,SAAS,iCACP,SAC2C;AAC3C,QAAO;EACL,SAAS;EACT,UAAU;EACV,SAAS;GACP,IAAI;IACF,MAAM;IACN,cAAc;IACd,aAAa;IACd;GACD,OAAO;IACL,MAAM;IACN,SAAS;IACT,aAAa;IACd;GACF;EACD,SAAS,OAAO,SAAS;GACvB,MAAM,MAAM,QAAQ,OAAO,QAAQ,KAAK;GACxC,MAAM,SAAS,MAAM,cAAc,KAAK,IAAI;IAAE,OAAO,KAAK;IAAO;IAAK,CAAC;AAEvE,WAAQ,SAAS;IACf,SAAS;IACT;IACA,QAAQ;IACT,CAAC;;EAEL"}
|
|
@@ -22,6 +22,16 @@ function createLsCommand(options) {
|
|
|
22
22
|
default: 1,
|
|
23
23
|
description: "Maximum depth to list"
|
|
24
24
|
},
|
|
25
|
+
l: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
default: false,
|
|
28
|
+
description: "Long listing format (detailed view)"
|
|
29
|
+
},
|
|
30
|
+
R: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
default: false,
|
|
33
|
+
description: "List recursively"
|
|
34
|
+
},
|
|
25
35
|
limit: {
|
|
26
36
|
type: "number",
|
|
27
37
|
description: "Maximum number of entries to return"
|
|
@@ -38,8 +48,9 @@ function createLsCommand(options) {
|
|
|
38
48
|
handler: async (argv) => {
|
|
39
49
|
const afs = await require_types.resolveAFS(options);
|
|
40
50
|
const canonicalPath = require_path_utils.cliPathToCanonical(argv.path || "/");
|
|
51
|
+
const depth = argv.R ? 10 : argv.depth ?? 1;
|
|
41
52
|
const result = await afs.list(canonicalPath, {
|
|
42
|
-
maxDepth:
|
|
53
|
+
maxDepth: depth,
|
|
43
54
|
limit: argv.limit,
|
|
44
55
|
maxChildren: argv.maxChildren,
|
|
45
56
|
pattern: argv.pattern
|
|
@@ -47,7 +58,8 @@ function createLsCommand(options) {
|
|
|
47
58
|
options.onResult({
|
|
48
59
|
command: "ls",
|
|
49
60
|
result,
|
|
50
|
-
format: require_ls.formatLsOutput
|
|
61
|
+
format: require_ls.formatLsOutput,
|
|
62
|
+
...argv.l && { viewOverride: "human" }
|
|
51
63
|
});
|
|
52
64
|
}
|
|
53
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.d.cts","names":[],"sources":["../../../src/core/commands/ls.ts"],"mappings":";;;;;;;UAeiB,MAAA;EACf,IAAA;EACA,KAAA;EACA,KAAA;EACA,WAAA;EACA,OAAA;AAAA;;;;iBAMc,eAAA,CAAgB,OAAA,EAAS,qBAAA,GAAwB,aAAA,UAAuB,MAAA"}
|
|
1
|
+
{"version":3,"file":"ls.d.cts","names":[],"sources":["../../../src/core/commands/ls.ts"],"mappings":";;;;;;;UAeiB,MAAA;EACf,IAAA;EACA,KAAA;EACA,CAAA;EACA,CAAA;EACA,KAAA;EACA,WAAA;EACA,OAAA;AAAA;;;;iBAMc,eAAA,CAAgB,OAAA,EAAS,qBAAA,GAAwB,aAAA,UAAuB,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.d.mts","names":[],"sources":["../../../src/core/commands/ls.ts"],"mappings":";;;;;;;UAeiB,MAAA;EACf,IAAA;EACA,KAAA;EACA,KAAA;EACA,WAAA;EACA,OAAA;AAAA;;;;iBAMc,eAAA,CAAgB,OAAA,EAAS,qBAAA,GAAwB,aAAA,UAAuB,MAAA"}
|
|
1
|
+
{"version":3,"file":"ls.d.mts","names":[],"sources":["../../../src/core/commands/ls.ts"],"mappings":";;;;;;;UAeiB,MAAA;EACf,IAAA;EACA,KAAA;EACA,CAAA;EACA,CAAA;EACA,KAAA;EACA,WAAA;EACA,OAAA;AAAA;;;;iBAMc,eAAA,CAAgB,OAAA,EAAS,qBAAA,GAAwB,aAAA,UAAuB,MAAA"}
|
|
@@ -22,6 +22,16 @@ function createLsCommand(options) {
|
|
|
22
22
|
default: 1,
|
|
23
23
|
description: "Maximum depth to list"
|
|
24
24
|
},
|
|
25
|
+
l: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
default: false,
|
|
28
|
+
description: "Long listing format (detailed view)"
|
|
29
|
+
},
|
|
30
|
+
R: {
|
|
31
|
+
type: "boolean",
|
|
32
|
+
default: false,
|
|
33
|
+
description: "List recursively"
|
|
34
|
+
},
|
|
25
35
|
limit: {
|
|
26
36
|
type: "number",
|
|
27
37
|
description: "Maximum number of entries to return"
|
|
@@ -38,8 +48,9 @@ function createLsCommand(options) {
|
|
|
38
48
|
handler: async (argv) => {
|
|
39
49
|
const afs = await resolveAFS(options);
|
|
40
50
|
const canonicalPath = cliPathToCanonical(argv.path || "/");
|
|
51
|
+
const depth = argv.R ? 10 : argv.depth ?? 1;
|
|
41
52
|
const result = await afs.list(canonicalPath, {
|
|
42
|
-
maxDepth:
|
|
53
|
+
maxDepth: depth,
|
|
43
54
|
limit: argv.limit,
|
|
44
55
|
maxChildren: argv.maxChildren,
|
|
45
56
|
pattern: argv.pattern
|
|
@@ -47,7 +58,8 @@ function createLsCommand(options) {
|
|
|
47
58
|
options.onResult({
|
|
48
59
|
command: "ls",
|
|
49
60
|
result,
|
|
50
|
-
format: formatLsOutput
|
|
61
|
+
format: formatLsOutput,
|
|
62
|
+
...argv.l && { viewOverride: "human" }
|
|
51
63
|
});
|
|
52
64
|
}
|
|
53
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ls.mjs","names":[],"sources":["../../../src/core/commands/ls.ts"],"sourcesContent":["/**\n * ls Command - Core Implementation\n *\n * Lists directory contents. Accepts AFS instance directly.\n * Returns AFSListResult directly (no custom type).\n */\n\nimport type { CommandModule } from \"yargs\";\nimport { formatLsOutput } from \"../formatters/index.js\";\nimport { cliPathToCanonical } from \"../path-utils.js\";\nimport { type CommandFactoryOptions, resolveAFS } from \"./types.js\";\n\n/**\n * Ls command arguments\n */\nexport interface LsArgs {\n path: string;\n depth: number;\n limit?: number;\n maxChildren?: number;\n pattern?: string;\n}\n\n/**\n * Create ls command factory\n */\nexport function createLsCommand(options: CommandFactoryOptions): CommandModule<unknown, LsArgs> {\n return {\n command: [\"ls [path]\", \"list [path]\"],\n describe: \"List directory contents\",\n builder: {\n path: {\n type: \"string\",\n default: \"/\",\n description: \"Path to list\",\n },\n depth: {\n type: \"number\",\n default: 1,\n description: \"Maximum depth to list\",\n },\n limit: {\n type: \"number\",\n description: \"Maximum number of entries to return\",\n },\n \"max-children\": {\n type: \"number\",\n description: \"Maximum children per directory\",\n },\n pattern: {\n type: \"string\",\n description: \"Glob pattern to filter entries\",\n },\n },\n handler: async (argv) => {\n const afs = await resolveAFS(options);\n const canonicalPath = cliPathToCanonical(argv.path || \"/\");\n const result = await afs.list(canonicalPath, {\n maxDepth:
|
|
1
|
+
{"version":3,"file":"ls.mjs","names":[],"sources":["../../../src/core/commands/ls.ts"],"sourcesContent":["/**\n * ls Command - Core Implementation\n *\n * Lists directory contents. Accepts AFS instance directly.\n * Returns AFSListResult directly (no custom type).\n */\n\nimport type { CommandModule } from \"yargs\";\nimport { formatLsOutput } from \"../formatters/index.js\";\nimport { cliPathToCanonical } from \"../path-utils.js\";\nimport { type CommandFactoryOptions, resolveAFS } from \"./types.js\";\n\n/**\n * Ls command arguments\n */\nexport interface LsArgs {\n path: string;\n depth: number;\n l: boolean;\n R: boolean;\n limit?: number;\n maxChildren?: number;\n pattern?: string;\n}\n\n/**\n * Create ls command factory\n */\nexport function createLsCommand(options: CommandFactoryOptions): CommandModule<unknown, LsArgs> {\n return {\n command: [\"ls [path]\", \"list [path]\"],\n describe: \"List directory contents\",\n builder: {\n path: {\n type: \"string\",\n default: \"/\",\n description: \"Path to list\",\n },\n depth: {\n type: \"number\",\n default: 1,\n description: \"Maximum depth to list\",\n },\n l: {\n type: \"boolean\",\n default: false,\n description: \"Long listing format (detailed view)\",\n },\n R: {\n type: \"boolean\",\n default: false,\n description: \"List recursively\",\n },\n limit: {\n type: \"number\",\n description: \"Maximum number of entries to return\",\n },\n \"max-children\": {\n type: \"number\",\n description: \"Maximum children per directory\",\n },\n pattern: {\n type: \"string\",\n description: \"Glob pattern to filter entries\",\n },\n },\n handler: async (argv) => {\n const afs = await resolveAFS(options);\n const canonicalPath = cliPathToCanonical(argv.path || \"/\");\n const depth = argv.R ? 10 : (argv.depth ?? 1);\n const result = await afs.list(canonicalPath, {\n maxDepth: depth,\n limit: argv.limit,\n maxChildren: argv.maxChildren,\n pattern: argv.pattern,\n });\n options.onResult({\n command: \"ls\",\n result,\n format: formatLsOutput,\n ...(argv.l && { viewOverride: \"human\" as const }),\n });\n },\n };\n}\n"],"mappings":";;;;;;;;;AA4BA,SAAgB,gBAAgB,SAAgE;AAC9F,QAAO;EACL,SAAS,CAAC,aAAa,cAAc;EACrC,UAAU;EACV,SAAS;GACP,MAAM;IACJ,MAAM;IACN,SAAS;IACT,aAAa;IACd;GACD,OAAO;IACL,MAAM;IACN,SAAS;IACT,aAAa;IACd;GACD,GAAG;IACD,MAAM;IACN,SAAS;IACT,aAAa;IACd;GACD,GAAG;IACD,MAAM;IACN,SAAS;IACT,aAAa;IACd;GACD,OAAO;IACL,MAAM;IACN,aAAa;IACd;GACD,gBAAgB;IACd,MAAM;IACN,aAAa;IACd;GACD,SAAS;IACP,MAAM;IACN,aAAa;IACd;GACF;EACD,SAAS,OAAO,SAAS;GACvB,MAAM,MAAM,MAAM,WAAW,QAAQ;GACrC,MAAM,gBAAgB,mBAAmB,KAAK,QAAQ,IAAI;GAC1D,MAAM,QAAQ,KAAK,IAAI,KAAM,KAAK,SAAS;GAC3C,MAAM,SAAS,MAAM,IAAI,KAAK,eAAe;IAC3C,UAAU;IACV,OAAO,KAAK;IACZ,aAAa,KAAK;IAClB,SAAS,KAAK;IACf,CAAC;AACF,WAAQ,SAAS;IACf,SAAS;IACT;IACA,QAAQ;IACR,GAAI,KAAK,KAAK,EAAE,cAAc,SAAkB;IACjD,CAAC;;EAEL"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/core/commands/mcp-bridge.ts
|
|
3
|
+
const noopFormat = () => "";
|
|
4
|
+
/** Backoff config for reconnection */
|
|
5
|
+
const RECONNECT = {
|
|
6
|
+
initialDelay: 500,
|
|
7
|
+
maxDelay: 1e4,
|
|
8
|
+
factor: 1.5
|
|
9
|
+
};
|
|
10
|
+
function createMcpBridgeCommand(options) {
|
|
11
|
+
return {
|
|
12
|
+
command: "mcp",
|
|
13
|
+
describe: "Connect Claude Desktop (or any stdio MCP client) to AFS",
|
|
14
|
+
builder: (yargs) => yargs.option("port", {
|
|
15
|
+
type: "number",
|
|
16
|
+
default: 4900,
|
|
17
|
+
description: "Daemon port"
|
|
18
|
+
}).epilog([
|
|
19
|
+
"Bridges stdio ↔ the running AFS daemon's MCP endpoint.",
|
|
20
|
+
"Auto-starts the daemon if not running.",
|
|
21
|
+
"",
|
|
22
|
+
"Claude Desktop config example:",
|
|
23
|
+
" { \"mcpServers\": { \"AFS\": { \"command\": \"afs\", \"args\": [\"mcp\"] } } }",
|
|
24
|
+
"",
|
|
25
|
+
"This is NOT a standalone MCP server. For that, use:",
|
|
26
|
+
" afs serve --transport mcp-stdio (standalone, loads AFS directly)",
|
|
27
|
+
" afs serve --transport mcp-http (standalone, HTTP transport)"
|
|
28
|
+
].join("\n")),
|
|
29
|
+
handler: async (argv) => {
|
|
30
|
+
const { getDaemonStatus, spawnDaemon } = await Promise.resolve().then(() => require("../../daemon/manager.cjs"));
|
|
31
|
+
const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
|
|
32
|
+
const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
33
|
+
let info = await getDaemonStatus();
|
|
34
|
+
if (!info) {
|
|
35
|
+
console.error("Starting AFS service...");
|
|
36
|
+
try {
|
|
37
|
+
info = await spawnDaemon(argv.port);
|
|
38
|
+
console.error(`AFS service started on port ${info.port}`);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.error(`Failed to start service: ${err.message}`);
|
|
41
|
+
options.onResult({
|
|
42
|
+
command: "mcp",
|
|
43
|
+
result: null,
|
|
44
|
+
format: noopFormat
|
|
45
|
+
});
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const mcpUrl = new URL(info.mcpUrl);
|
|
51
|
+
let http = null;
|
|
52
|
+
let connected = false;
|
|
53
|
+
let reconnecting = false;
|
|
54
|
+
let connectingPromise = null;
|
|
55
|
+
let cachedInitialize = null;
|
|
56
|
+
/**
|
|
57
|
+
* Try to connect to the daemon's MCP endpoint.
|
|
58
|
+
* Does NOT spawn a new daemon — only connects to an existing one.
|
|
59
|
+
* Spawning is done once at startup; reconnect just waits for it to come back.
|
|
60
|
+
*
|
|
61
|
+
* On reconnect (when cachedInitialize is set), transparently replays the
|
|
62
|
+
* initialize handshake so the new daemon session is established before
|
|
63
|
+
* any client requests are forwarded.
|
|
64
|
+
*/
|
|
65
|
+
async function connectHttp() {
|
|
66
|
+
try {
|
|
67
|
+
const transport = new StreamableHTTPClientTransport(mcpUrl);
|
|
68
|
+
let swallowNextResponse = false;
|
|
69
|
+
transport.onmessage = async (message) => {
|
|
70
|
+
if (swallowNextResponse) {
|
|
71
|
+
swallowNextResponse = false;
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
await stdio.send(message);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error(`Bridge receive error: ${err.message}`);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
transport.onclose = () => {
|
|
81
|
+
if (http !== transport) return;
|
|
82
|
+
connected = false;
|
|
83
|
+
http = null;
|
|
84
|
+
console.error("Backend disconnected, will reconnect...");
|
|
85
|
+
scheduleReconnect();
|
|
86
|
+
};
|
|
87
|
+
await transport.start();
|
|
88
|
+
if (cachedInitialize) {
|
|
89
|
+
swallowNextResponse = true;
|
|
90
|
+
await transport.send(cachedInitialize);
|
|
91
|
+
await transport.send({
|
|
92
|
+
jsonrpc: "2.0",
|
|
93
|
+
method: "notifications/initialized"
|
|
94
|
+
});
|
|
95
|
+
console.error("Session re-initialized on new daemon");
|
|
96
|
+
}
|
|
97
|
+
http = transport;
|
|
98
|
+
connected = true;
|
|
99
|
+
return true;
|
|
100
|
+
} catch {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** Reconnect loop with exponential backoff */
|
|
105
|
+
function scheduleReconnect() {
|
|
106
|
+
if (reconnecting) return;
|
|
107
|
+
reconnecting = true;
|
|
108
|
+
let resolveGate;
|
|
109
|
+
connectingPromise = new Promise((r) => {
|
|
110
|
+
resolveGate = r;
|
|
111
|
+
});
|
|
112
|
+
let delay = RECONNECT.initialDelay;
|
|
113
|
+
const attempt = async () => {
|
|
114
|
+
if (connected) {
|
|
115
|
+
reconnecting = false;
|
|
116
|
+
resolveGate(true);
|
|
117
|
+
connectingPromise = null;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (await connectHttp()) {
|
|
121
|
+
reconnecting = false;
|
|
122
|
+
resolveGate(true);
|
|
123
|
+
connectingPromise = null;
|
|
124
|
+
console.error(`MCP bridge reconnected to ${mcpUrl}`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
delay = Math.min(delay * RECONNECT.factor, RECONNECT.maxDelay);
|
|
128
|
+
setTimeout(attempt, delay);
|
|
129
|
+
};
|
|
130
|
+
attempt();
|
|
131
|
+
}
|
|
132
|
+
const stdio = new StdioServerTransport();
|
|
133
|
+
/** Send a JSON-RPC error back to the client */
|
|
134
|
+
async function sendError(id, message) {
|
|
135
|
+
try {
|
|
136
|
+
await stdio.send({
|
|
137
|
+
jsonrpc: "2.0",
|
|
138
|
+
id,
|
|
139
|
+
error: {
|
|
140
|
+
code: -32e3,
|
|
141
|
+
message
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
} catch {}
|
|
145
|
+
}
|
|
146
|
+
stdio.onmessage = async (message) => {
|
|
147
|
+
const msg = message;
|
|
148
|
+
if (msg.method === "initialize") cachedInitialize = msg;
|
|
149
|
+
if (!connected && connectingPromise) await connectingPromise;
|
|
150
|
+
if (!connected || !http) {
|
|
151
|
+
if (msg.id != null) await sendError(msg.id, "AFS service unavailable, reconnecting...");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
await http.send(message);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
console.error(`Bridge send error: ${err.message}`);
|
|
158
|
+
if (connected) {
|
|
159
|
+
connected = false;
|
|
160
|
+
http = null;
|
|
161
|
+
scheduleReconnect();
|
|
162
|
+
}
|
|
163
|
+
if (connectingPromise) await connectingPromise;
|
|
164
|
+
if (connected && http) try {
|
|
165
|
+
await http.send(message);
|
|
166
|
+
return;
|
|
167
|
+
} catch {}
|
|
168
|
+
if (msg.id != null) await sendError(msg.id, "AFS service unavailable, reconnecting...");
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
let shuttingDown = false;
|
|
172
|
+
const shutdown = () => {
|
|
173
|
+
if (shuttingDown) return;
|
|
174
|
+
shuttingDown = true;
|
|
175
|
+
stdio.onclose = void 0;
|
|
176
|
+
if (http) {
|
|
177
|
+
http.onclose = void 0;
|
|
178
|
+
http.close().catch(() => {});
|
|
179
|
+
}
|
|
180
|
+
stdio.close().catch(() => {});
|
|
181
|
+
setTimeout(() => process.exit(0), 50);
|
|
182
|
+
};
|
|
183
|
+
stdio.onclose = () => shutdown();
|
|
184
|
+
process.on("SIGINT", () => shutdown());
|
|
185
|
+
process.on("SIGTERM", () => shutdown());
|
|
186
|
+
connectingPromise = connectHttp();
|
|
187
|
+
const ok = await connectingPromise;
|
|
188
|
+
connectingPromise = null;
|
|
189
|
+
if (ok) console.error(`MCP bridge connected to ${info.mcpUrl}`);
|
|
190
|
+
else {
|
|
191
|
+
console.error(`MCP bridge started, waiting for daemon at ${info.mcpUrl}...`);
|
|
192
|
+
scheduleReconnect();
|
|
193
|
+
}
|
|
194
|
+
await stdio.start();
|
|
195
|
+
await new Promise(() => {});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
exports.createMcpBridgeCommand = createMcpBridgeCommand;
|