@aigne/cli 1.60.0-beta → 1.74.0-beta
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/README.md +12 -12
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/bunwrapper.cjs +22 -0
- package/dist/bunwrapper.d.cts +1 -0
- package/dist/bunwrapper.d.mts +1 -0
- package/dist/bunwrapper.mjs +23 -0
- package/dist/bunwrapper.mjs.map +1 -0
- package/dist/cli.cjs +42 -0
- package/dist/cli.d.cts +9 -0
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +10 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +41 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/commands/aigne.cjs +23 -0
- package/dist/commands/aigne.mjs +22 -0
- package/dist/commands/aigne.mjs.map +1 -0
- package/dist/commands/app/agent.cjs +117 -0
- package/dist/commands/app/agent.mjs +113 -0
- package/dist/commands/app/agent.mjs.map +1 -0
- package/dist/commands/app/app.cjs +92 -0
- package/dist/commands/app/app.mjs +90 -0
- package/dist/commands/app/app.mjs.map +1 -0
- package/dist/commands/app/cli.cjs +6 -0
- package/dist/commands/app/cli.d.cts +1 -0
- package/dist/commands/app/cli.d.mts +1 -0
- package/dist/commands/app/cli.mjs +8 -0
- package/dist/commands/app/cli.mjs.map +1 -0
- package/dist/commands/app/upgrade.cjs +243 -0
- package/dist/commands/app/upgrade.mjs +240 -0
- package/dist/commands/app/upgrade.mjs.map +1 -0
- package/dist/commands/app.cjs +53 -0
- package/dist/commands/app.mjs +53 -0
- package/dist/commands/app.mjs.map +1 -0
- package/dist/commands/create.cjs +66 -0
- package/dist/commands/create.mjs +65 -0
- package/dist/commands/create.mjs.map +1 -0
- package/dist/commands/deploy.cjs +237 -0
- package/dist/commands/deploy.mjs +237 -0
- package/dist/commands/deploy.mjs.map +1 -0
- package/dist/commands/eval.cjs +88 -0
- package/dist/commands/eval.mjs +88 -0
- package/dist/commands/eval.mjs.map +1 -0
- package/dist/commands/hub.cjs +297 -0
- package/dist/commands/hub.mjs +294 -0
- package/dist/commands/hub.mjs.map +1 -0
- package/dist/commands/observe.cjs +49 -0
- package/dist/commands/observe.mjs +46 -0
- package/dist/commands/observe.mjs.map +1 -0
- package/dist/commands/run-skill.cjs +84 -0
- package/dist/commands/run-skill.mjs +81 -0
- package/dist/commands/run-skill.mjs.map +1 -0
- package/dist/commands/run.cjs +172 -0
- package/dist/commands/run.mjs +171 -0
- package/dist/commands/run.mjs.map +1 -0
- package/dist/commands/serve-mcp.cjs +68 -0
- package/dist/commands/serve-mcp.mjs +67 -0
- package/dist/commands/serve-mcp.mjs.map +1 -0
- package/dist/commands/test.cjs +40 -0
- package/dist/commands/test.mjs +39 -0
- package/dist/commands/test.mjs.map +1 -0
- package/dist/constants.cjs +28 -0
- package/dist/constants.d.cts +9 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +9 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +24 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/global.d.cjs +0 -0
- package/dist/global.d.cts +6 -0
- package/dist/global.d.cts.map +1 -0
- package/dist/global.d.mts +6 -0
- package/dist/global.d.mts.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/tracer/terminal.cjs +336 -0
- package/dist/tracer/terminal.mjs +332 -0
- package/dist/tracer/terminal.mjs.map +1 -0
- package/dist/type.cjs +0 -0
- package/dist/type.d.cts +10 -0
- package/dist/type.d.cts.map +1 -0
- package/dist/type.d.mts +10 -0
- package/dist/type.d.mts.map +1 -0
- package/dist/type.mjs +1 -0
- package/dist/ui/utils/terminal-input.cjs +145 -0
- package/dist/ui/utils/terminal-input.mjs +144 -0
- package/dist/ui/utils/terminal-input.mjs.map +1 -0
- package/dist/ui/utils/text-buffer.cjs +865 -0
- package/dist/ui/utils/text-buffer.mjs +865 -0
- package/dist/ui/utils/text-buffer.mjs.map +1 -0
- package/dist/ui/utils/text-utils.cjs +85 -0
- package/dist/ui/utils/text-utils.mjs +78 -0
- package/dist/ui/utils/text-utils.mjs.map +1 -0
- package/dist/utils/agent-v1.cjs +180 -0
- package/dist/utils/agent-v1.d.cts +138 -0
- package/dist/utils/agent-v1.d.cts.map +1 -0
- package/dist/utils/agent-v1.d.mts +138 -0
- package/dist/utils/agent-v1.d.mts.map +1 -0
- package/dist/utils/agent-v1.mjs +179 -0
- package/dist/utils/agent-v1.mjs.map +1 -0
- package/dist/utils/aigne-hub/constants.cjs +22 -0
- package/dist/utils/aigne-hub/constants.mjs +18 -0
- package/dist/utils/aigne-hub/constants.mjs.map +1 -0
- package/dist/utils/aigne-hub/credential.cjs +179 -0
- package/dist/utils/aigne-hub/credential.mjs +175 -0
- package/dist/utils/aigne-hub/credential.mjs.map +1 -0
- package/dist/utils/aigne-hub/crypto.cjs +41 -0
- package/dist/utils/aigne-hub/crypto.mjs +33 -0
- package/dist/utils/aigne-hub/crypto.mjs.map +1 -0
- package/dist/utils/aigne-hub/model.cjs +112 -0
- package/dist/utils/aigne-hub/model.d.cts +19 -0
- package/dist/utils/aigne-hub/model.d.cts.map +1 -0
- package/dist/utils/aigne-hub/model.d.mts +19 -0
- package/dist/utils/aigne-hub/model.d.mts.map +1 -0
- package/dist/utils/aigne-hub/model.mjs +106 -0
- package/dist/utils/aigne-hub/model.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/file.cjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/index.cjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/keytar.cjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/migrate.cjs +46 -0
- package/dist/utils/aigne-hub/store/migrate.mjs +45 -0
- package/dist/utils/aigne-hub/store/migrate.mjs.map +1 -0
- package/dist/utils/aigne-hub/type.d.cts +18 -0
- package/dist/utils/aigne-hub/type.d.cts.map +1 -0
- package/dist/utils/aigne-hub/type.d.mts +18 -0
- package/dist/utils/aigne-hub/type.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.cjs +11 -0
- package/dist/utils/aigne-hub-user.d.cts +23 -0
- package/dist/utils/aigne-hub-user.d.cts.map +1 -0
- package/dist/utils/aigne-hub-user.d.mts +23 -0
- package/dist/utils/aigne-hub-user.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.mjs +11 -0
- package/dist/utils/aigne-hub-user.mjs.map +1 -0
- package/dist/utils/ascii-logo.cjs +30 -0
- package/dist/utils/ascii-logo.d.cts +5 -0
- package/dist/utils/ascii-logo.d.cts.map +1 -0
- package/dist/utils/ascii-logo.d.mts +5 -0
- package/dist/utils/ascii-logo.d.mts.map +1 -0
- package/dist/utils/{ascii-logo.js → ascii-logo.mjs} +13 -3
- package/dist/utils/ascii-logo.mjs.map +1 -0
- package/dist/utils/download.cjs +25 -0
- package/dist/utils/download.d.cts +7 -0
- package/dist/utils/download.d.cts.map +1 -0
- package/dist/utils/download.d.mts +7 -0
- package/dist/utils/download.d.mts.map +1 -0
- package/dist/utils/download.mjs +25 -0
- package/dist/utils/download.mjs.map +1 -0
- package/dist/utils/evaluation/core.cjs +84 -0
- package/dist/utils/evaluation/core.mjs +84 -0
- package/dist/utils/evaluation/core.mjs.map +1 -0
- package/dist/utils/evaluation/dataset.cjs +47 -0
- package/dist/utils/evaluation/dataset.mjs +46 -0
- package/dist/utils/evaluation/dataset.mjs.map +1 -0
- package/dist/utils/evaluation/evaluator.cjs +109 -0
- package/dist/utils/evaluation/{evaluator.js → evaluator.mjs} +48 -45
- package/dist/utils/evaluation/evaluator.mjs.map +1 -0
- package/dist/utils/evaluation/reporter.cjs +225 -0
- package/dist/utils/evaluation/reporter.mjs +220 -0
- package/dist/utils/evaluation/reporter.mjs.map +1 -0
- package/dist/utils/evaluation/runner.cjs +85 -0
- package/dist/utils/evaluation/runner.mjs +85 -0
- package/dist/utils/evaluation/runner.mjs.map +1 -0
- package/dist/utils/get-url-origin.cjs +12 -0
- package/dist/utils/get-url-origin.d.cts +5 -0
- package/dist/utils/get-url-origin.d.cts.map +1 -0
- package/dist/utils/get-url-origin.d.mts +5 -0
- package/dist/utils/get-url-origin.d.mts.map +1 -0
- package/dist/utils/get-url-origin.mjs +12 -0
- package/dist/utils/get-url-origin.mjs.map +1 -0
- package/dist/utils/inquirer/checkbox.cjs +265 -0
- package/dist/utils/inquirer/checkbox.mjs +262 -0
- package/dist/utils/inquirer/checkbox.mjs.map +1 -0
- package/dist/utils/listr.cjs +226 -0
- package/dist/utils/listr.d.cts +71 -0
- package/dist/utils/listr.d.cts.map +1 -0
- package/dist/utils/listr.d.mts +71 -0
- package/dist/utils/listr.d.mts.map +1 -0
- package/dist/utils/listr.mjs +222 -0
- package/dist/utils/listr.mjs.map +1 -0
- package/dist/utils/load-aigne.cjs +77 -0
- package/dist/utils/load-aigne.d.cts +29 -0
- package/dist/utils/load-aigne.d.cts.map +1 -0
- package/dist/utils/load-aigne.d.mts +29 -0
- package/dist/utils/load-aigne.d.mts.map +1 -0
- package/dist/utils/load-aigne.mjs +74 -0
- package/dist/utils/load-aigne.mjs.map +1 -0
- package/dist/utils/run-chat-loop.cjs +90 -0
- package/dist/utils/run-chat-loop.d.cts +20 -0
- package/dist/utils/run-chat-loop.d.cts.map +1 -0
- package/dist/utils/run-chat-loop.d.mts +20 -0
- package/dist/utils/run-chat-loop.d.mts.map +1 -0
- package/dist/utils/run-chat-loop.mjs +89 -0
- package/dist/utils/run-chat-loop.mjs.map +1 -0
- package/dist/utils/run-with-aigne.cjs +131 -0
- package/dist/utils/run-with-aigne.d.cts +46 -0
- package/dist/utils/run-with-aigne.d.cts.map +1 -0
- package/dist/utils/run-with-aigne.d.mts +46 -0
- package/dist/utils/run-with-aigne.d.mts.map +1 -0
- package/dist/utils/run-with-aigne.mjs +126 -0
- package/dist/utils/run-with-aigne.mjs.map +1 -0
- package/dist/utils/serve-mcp.cjs +91 -0
- package/dist/utils/serve-mcp.d.cts +20 -0
- package/dist/utils/serve-mcp.d.cts.map +1 -0
- package/dist/utils/serve-mcp.d.mts +20 -0
- package/dist/utils/serve-mcp.d.mts.map +1 -0
- package/dist/utils/serve-mcp.mjs +89 -0
- package/dist/utils/serve-mcp.mjs.map +1 -0
- package/dist/utils/spinner.cjs +19 -0
- package/dist/utils/spinner.d.cts +5 -0
- package/dist/utils/spinner.d.cts.map +1 -0
- package/dist/utils/spinner.d.mts +5 -0
- package/dist/utils/spinner.d.mts.map +1 -0
- package/dist/utils/spinner.mjs +19 -0
- package/dist/utils/spinner.mjs.map +1 -0
- package/dist/utils/string-utils.cjs +11 -0
- package/dist/utils/string-utils.d.cts +5 -0
- package/dist/utils/string-utils.d.cts.map +1 -0
- package/dist/utils/string-utils.d.mts +5 -0
- package/dist/utils/string-utils.d.mts.map +1 -0
- package/dist/utils/string-utils.mjs +10 -0
- package/dist/utils/string-utils.mjs.map +1 -0
- package/dist/utils/time.cjs +14 -0
- package/dist/utils/time.d.cts +5 -0
- package/dist/utils/time.d.cts.map +1 -0
- package/dist/utils/time.d.mts +5 -0
- package/dist/utils/time.d.mts.map +1 -0
- package/dist/utils/time.mjs +14 -0
- package/dist/utils/time.mjs.map +1 -0
- package/dist/utils/url.cjs +8 -0
- package/dist/utils/url.d.cts +5 -0
- package/dist/utils/url.d.cts.map +1 -0
- package/dist/utils/url.d.mts +5 -0
- package/dist/utils/url.d.mts.map +1 -0
- package/dist/utils/url.mjs +8 -0
- package/dist/utils/url.mjs.map +1 -0
- package/dist/utils/yargs.cjs +191 -0
- package/dist/utils/yargs.d.cts +96 -0
- package/dist/utils/yargs.d.cts.map +1 -0
- package/dist/utils/yargs.d.mts +96 -0
- package/dist/utils/yargs.d.mts.map +1 -0
- package/dist/utils/yargs.mjs +186 -0
- package/dist/utils/yargs.mjs.map +1 -0
- package/package.json +122 -45
- package/CHANGELOG.md +0 -5019
- package/dist/bunwrapper.d.ts +0 -2
- package/dist/bunwrapper.js +0 -18
- package/dist/cli.d.ts +0 -7
- package/dist/cli.js +0 -42
- package/dist/commands/aigne.d.ts +0 -4
- package/dist/commands/aigne.js +0 -35
- package/dist/commands/app/agent.d.ts +0 -26
- package/dist/commands/app/agent.js +0 -122
- package/dist/commands/app/app.d.ts +0 -7
- package/dist/commands/app/app.js +0 -92
- package/dist/commands/app/cli.d.ts +0 -1
- package/dist/commands/app/cli.js +0 -2
- package/dist/commands/app/upgrade.d.ts +0 -54
- package/dist/commands/app/upgrade.js +0 -236
- package/dist/commands/app.d.ts +0 -4
- package/dist/commands/app.js +0 -54
- package/dist/commands/create.d.ts +0 -6
- package/dist/commands/create.js +0 -74
- package/dist/commands/deploy.d.ts +0 -11
- package/dist/commands/deploy.js +0 -255
- package/dist/commands/eval.d.ts +0 -11
- package/dist/commands/eval.js +0 -110
- package/dist/commands/hub.d.ts +0 -3
- package/dist/commands/hub.js +0 -323
- package/dist/commands/observe.d.ts +0 -7
- package/dist/commands/observe.js +0 -41
- package/dist/commands/run-skill.d.ts +0 -6
- package/dist/commands/run-skill.js +0 -102
- package/dist/commands/run.d.ts +0 -9
- package/dist/commands/run.js +0 -187
- package/dist/commands/serve-mcp.d.ts +0 -20
- package/dist/commands/serve-mcp.js +0 -67
- package/dist/commands/test.d.ts +0 -9
- package/dist/commands/test.js +0 -33
- package/dist/constants.d.ts +0 -7
- package/dist/constants.js +0 -21
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tracer/terminal.d.ts +0 -62
- package/dist/tracer/terminal.js +0 -404
- package/dist/type.d.ts +0 -5
- package/dist/type.js +0 -1
- package/dist/ui/utils/terminal-input.d.ts +0 -19
- package/dist/ui/utils/terminal-input.js +0 -123
- package/dist/ui/utils/text-buffer.d.ts +0 -87
- package/dist/ui/utils/text-buffer.js +0 -1059
- package/dist/ui/utils/text-utils.d.ts +0 -37
- package/dist/ui/utils/text-utils.js +0 -185
- package/dist/utils/agent-v1.d.ts +0 -134
- package/dist/utils/agent-v1.js +0 -213
- package/dist/utils/aigne-hub/constants.d.ts +0 -6
- package/dist/utils/aigne-hub/constants.js +0 -12
- package/dist/utils/aigne-hub/credential.d.ts +0 -20
- package/dist/utils/aigne-hub/credential.js +0 -182
- package/dist/utils/aigne-hub/crypto.d.ts +0 -4
- package/dist/utils/aigne-hub/crypto.js +0 -30
- package/dist/utils/aigne-hub/model.d.ts +0 -13
- package/dist/utils/aigne-hub/model.js +0 -122
- package/dist/utils/aigne-hub/store/file.d.ts +0 -15
- package/dist/utils/aigne-hub/store/file.js +0 -69
- package/dist/utils/aigne-hub/store/index.d.ts +0 -5
- package/dist/utils/aigne-hub/store/index.js +0 -43
- package/dist/utils/aigne-hub/store/keytar.d.ts +0 -15
- package/dist/utils/aigne-hub/store/keytar.js +0 -67
- package/dist/utils/aigne-hub/store/migrate.d.ts +0 -2
- package/dist/utils/aigne-hub/store/migrate.js +0 -57
- package/dist/utils/aigne-hub/type.d.ts +0 -38
- package/dist/utils/aigne-hub/type.js +0 -1
- package/dist/utils/aigne-hub-user.d.ts +0 -16
- package/dist/utils/aigne-hub-user.js +0 -10
- package/dist/utils/ascii-logo.d.ts +0 -1
- package/dist/utils/download.d.ts +0 -3
- package/dist/utils/download.js +0 -19
- package/dist/utils/evaluation/core.d.ts +0 -8
- package/dist/utils/evaluation/core.js +0 -83
- package/dist/utils/evaluation/dataset.d.ts +0 -15
- package/dist/utils/evaluation/dataset.js +0 -61
- package/dist/utils/evaluation/evaluator.d.ts +0 -9
- package/dist/utils/evaluation/reporter.d.ts +0 -28
- package/dist/utils/evaluation/reporter.js +0 -221
- package/dist/utils/evaluation/runner.d.ts +0 -16
- package/dist/utils/evaluation/runner.js +0 -129
- package/dist/utils/evaluation/type.d.ts +0 -69
- package/dist/utils/evaluation/type.js +0 -1
- package/dist/utils/get-url-origin.d.ts +0 -1
- package/dist/utils/get-url-origin.js +0 -8
- package/dist/utils/inquirer/checkbox.d.ts +0 -55
- package/dist/utils/inquirer/checkbox.js +0 -319
- package/dist/utils/listr.d.ts +0 -64
- package/dist/utils/listr.js +0 -265
- package/dist/utils/load-aigne.d.ts +0 -18
- package/dist/utils/load-aigne.js +0 -80
- package/dist/utils/run-chat-loop.d.ts +0 -15
- package/dist/utils/run-chat-loop.js +0 -87
- package/dist/utils/run-with-aigne.d.ts +0 -27
- package/dist/utils/run-with-aigne.js +0 -157
- package/dist/utils/serve-mcp.d.ts +0 -9
- package/dist/utils/serve-mcp.js +0 -93
- package/dist/utils/spinner.d.ts +0 -1
- package/dist/utils/spinner.js +0 -14
- package/dist/utils/string-utils.d.ts +0 -1
- package/dist/utils/string-utils.js +0 -4
- package/dist/utils/time.d.ts +0 -1
- package/dist/utils/time.js +0 -12
- package/dist/utils/url.d.ts +0 -1
- package/dist/utils/url.js +0 -3
- package/dist/utils/yargs.d.ts +0 -94
- package/dist/utils/yargs.js +0 -210
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_upgrade = require('./app/upgrade.cjs');
|
|
3
|
+
let node_child_process = require("node:child_process");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
let node_url = require("node:url");
|
|
6
|
+
|
|
7
|
+
//#region src/commands/app.ts
|
|
8
|
+
const builtinApps = [{
|
|
9
|
+
name: "doc-smith",
|
|
10
|
+
packageName: "@aigne/doc-smith",
|
|
11
|
+
describe: "Generate and maintain project docs — powered by agents.",
|
|
12
|
+
aliases: ["docsmith", "doc"]
|
|
13
|
+
}, {
|
|
14
|
+
name: "web-smith",
|
|
15
|
+
packageName: "@aigne/web-smith",
|
|
16
|
+
describe: "Generate and maintain project website pages — powered by agents.",
|
|
17
|
+
aliases: ["websmith", "web"]
|
|
18
|
+
}];
|
|
19
|
+
function createAppCommands({ argv } = {}) {
|
|
20
|
+
return builtinApps.map((app) => ({
|
|
21
|
+
command: app.name,
|
|
22
|
+
describe: app.describe,
|
|
23
|
+
aliases: app.aliases,
|
|
24
|
+
builder: async (y) => y.help(false).version(false).strict(false),
|
|
25
|
+
handler: async () => {
|
|
26
|
+
let retried = false;
|
|
27
|
+
let retryWithBeta = false;
|
|
28
|
+
while (true) {
|
|
29
|
+
const child = (0, node_child_process.fork)((0, node_path.join)((0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)), "./app/cli.mjs"), argv, {
|
|
30
|
+
stdio: "inherit",
|
|
31
|
+
env: {
|
|
32
|
+
...process.env,
|
|
33
|
+
AIGNE_APP_NAME: app.name,
|
|
34
|
+
AIGNE_APP_PACKAGE_NAME: app.packageName,
|
|
35
|
+
AIGNE_APP_DESCRIPTION: app.describe,
|
|
36
|
+
AIGNE_APP_USE_BETA_APPS: retryWithBeta ? "1" : "0"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const code = await new Promise((resolve) => {
|
|
40
|
+
child.on("exit", (code$1) => resolve(code$1));
|
|
41
|
+
});
|
|
42
|
+
if (code === require_upgrade.NeedReinstallError.code || code === require_upgrade.NeedReinstallBetaError.code) {
|
|
43
|
+
if (retried) process.exit(1);
|
|
44
|
+
retryWithBeta = code === require_upgrade.NeedReinstallBetaError.code;
|
|
45
|
+
retried = true;
|
|
46
|
+
} else process.exit(code);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
exports.createAppCommands = createAppCommands;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { NeedReinstallBetaError, NeedReinstallError } from "./app/upgrade.mjs";
|
|
2
|
+
import { fork } from "node:child_process";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
//#region src/commands/app.ts
|
|
7
|
+
const builtinApps = [{
|
|
8
|
+
name: "doc-smith",
|
|
9
|
+
packageName: "@aigne/doc-smith",
|
|
10
|
+
describe: "Generate and maintain project docs — powered by agents.",
|
|
11
|
+
aliases: ["docsmith", "doc"]
|
|
12
|
+
}, {
|
|
13
|
+
name: "web-smith",
|
|
14
|
+
packageName: "@aigne/web-smith",
|
|
15
|
+
describe: "Generate and maintain project website pages — powered by agents.",
|
|
16
|
+
aliases: ["websmith", "web"]
|
|
17
|
+
}];
|
|
18
|
+
function createAppCommands({ argv } = {}) {
|
|
19
|
+
return builtinApps.map((app) => ({
|
|
20
|
+
command: app.name,
|
|
21
|
+
describe: app.describe,
|
|
22
|
+
aliases: app.aliases,
|
|
23
|
+
builder: async (y) => y.help(false).version(false).strict(false),
|
|
24
|
+
handler: async () => {
|
|
25
|
+
let retried = false;
|
|
26
|
+
let retryWithBeta = false;
|
|
27
|
+
while (true) {
|
|
28
|
+
const child = fork(join(dirname(fileURLToPath(import.meta.url)), "./app/cli.mjs"), argv, {
|
|
29
|
+
stdio: "inherit",
|
|
30
|
+
env: {
|
|
31
|
+
...process.env,
|
|
32
|
+
AIGNE_APP_NAME: app.name,
|
|
33
|
+
AIGNE_APP_PACKAGE_NAME: app.packageName,
|
|
34
|
+
AIGNE_APP_DESCRIPTION: app.describe,
|
|
35
|
+
AIGNE_APP_USE_BETA_APPS: retryWithBeta ? "1" : "0"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const code = await new Promise((resolve$1) => {
|
|
39
|
+
child.on("exit", (code$1) => resolve$1(code$1));
|
|
40
|
+
});
|
|
41
|
+
if (code === NeedReinstallError.code || code === NeedReinstallBetaError.code) {
|
|
42
|
+
if (retried) process.exit(1);
|
|
43
|
+
retryWithBeta = code === NeedReinstallBetaError.code;
|
|
44
|
+
retried = true;
|
|
45
|
+
} else process.exit(code);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { createAppCommands };
|
|
53
|
+
//# sourceMappingURL=app.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.mjs","names":["resolve","code"],"sources":["../../src/commands/app.ts"],"sourcesContent":["import { fork } from \"node:child_process\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { CommandModule } from \"yargs\";\nimport { NeedReinstallBetaError, NeedReinstallError } from \"./app/upgrade.js\";\n\nconst builtinApps = [\n {\n name: \"doc-smith\",\n packageName: \"@aigne/doc-smith\",\n describe: \"Generate and maintain project docs — powered by agents.\",\n aliases: [\"docsmith\", \"doc\"],\n },\n {\n name: \"web-smith\",\n packageName: \"@aigne/web-smith\",\n describe: \"Generate and maintain project website pages — powered by agents.\",\n aliases: [\"websmith\", \"web\"],\n },\n];\n\nexport function createAppCommands({ argv }: { argv?: string[] } = {}): CommandModule[] {\n return builtinApps.map((app) => ({\n command: app.name,\n describe: app.describe,\n aliases: app.aliases,\n builder: async (y) => y.help(false).version(false).strict(false),\n handler: async () => {\n let retried = false;\n\n let retryWithBeta = false;\n\n while (true) {\n const child = fork(join(dirname(fileURLToPath(import.meta.url)), \"./app/cli.mjs\"), argv, {\n stdio: \"inherit\",\n env: {\n ...process.env,\n AIGNE_APP_NAME: app.name,\n AIGNE_APP_PACKAGE_NAME: app.packageName,\n AIGNE_APP_DESCRIPTION: app.describe,\n AIGNE_APP_USE_BETA_APPS: retryWithBeta ? \"1\" : \"0\",\n },\n });\n\n const code = await new Promise<number | null>((resolve) => {\n child.on(\"exit\", (code) => resolve(code));\n });\n\n if (code === NeedReinstallError.code || code === NeedReinstallBetaError.code) {\n if (retried) process.exit(1);\n retryWithBeta = code === NeedReinstallBetaError.code;\n retried = true;\n } else {\n process.exit(code);\n }\n }\n },\n }));\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc,CAClB;CACE,MAAM;CACN,aAAa;CACb,UAAU;CACV,SAAS,CAAC,YAAY,MAAM;CAC7B,EACD;CACE,MAAM;CACN,aAAa;CACb,UAAU;CACV,SAAS,CAAC,YAAY,MAAM;CAC7B,CACF;AAED,SAAgB,kBAAkB,EAAE,SAA8B,EAAE,EAAmB;AACrF,QAAO,YAAY,KAAK,SAAS;EAC/B,SAAS,IAAI;EACb,UAAU,IAAI;EACd,SAAS,IAAI;EACb,SAAS,OAAO,MAAM,EAAE,KAAK,MAAM,CAAC,QAAQ,MAAM,CAAC,OAAO,MAAM;EAChE,SAAS,YAAY;GACnB,IAAI,UAAU;GAEd,IAAI,gBAAgB;AAEpB,UAAO,MAAM;IACX,MAAM,QAAQ,KAAK,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EAAE,gBAAgB,EAAE,MAAM;KACvF,OAAO;KACP,KAAK;MACH,GAAG,QAAQ;MACX,gBAAgB,IAAI;MACpB,wBAAwB,IAAI;MAC5B,uBAAuB,IAAI;MAC3B,yBAAyB,gBAAgB,MAAM;MAChD;KACF,CAAC;IAEF,MAAM,OAAO,MAAM,IAAI,SAAwB,cAAY;AACzD,WAAM,GAAG,SAAS,WAASA,UAAQC,OAAK,CAAC;MACzC;AAEF,QAAI,SAAS,mBAAmB,QAAQ,SAAS,uBAAuB,MAAM;AAC5E,SAAI,QAAS,SAAQ,KAAK,EAAE;AAC5B,qBAAgB,SAAS,uBAAuB;AAChD,eAAU;UAEV,SAAQ,KAAK,KAAK;;;EAIzB,EAAE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let node_url = require("node:url");
|
|
5
|
+
let node_fs_promises = require("node:fs/promises");
|
|
6
|
+
let inquirer = require("inquirer");
|
|
7
|
+
inquirer = require_rolldown_runtime.__toESM(inquirer);
|
|
8
|
+
|
|
9
|
+
//#region src/commands/create.ts
|
|
10
|
+
function createCreateCommand() {
|
|
11
|
+
return {
|
|
12
|
+
command: "create [path]",
|
|
13
|
+
describe: "Create a new aigne project with agent config files",
|
|
14
|
+
builder: (yargs) => {
|
|
15
|
+
return yargs.positional("path", {
|
|
16
|
+
describe: "Path to create the project directory",
|
|
17
|
+
type: "string",
|
|
18
|
+
default: "."
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
handler: async ({ path }) => {
|
|
22
|
+
if (path === ".") path = (await inquirer.default.prompt([{
|
|
23
|
+
type: "input",
|
|
24
|
+
name: "projectName",
|
|
25
|
+
message: "Project name:",
|
|
26
|
+
default: path !== "." ? path : "my-aigne-project",
|
|
27
|
+
validate: (input) => {
|
|
28
|
+
if (input.trim() === "") return "Project name cannot be empty.";
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}])).projectName;
|
|
32
|
+
path = (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(process.cwd(), path);
|
|
33
|
+
if ((0, node_fs.existsSync)(path) && (0, node_fs.readdirSync)(path).length > 0) {
|
|
34
|
+
if (!(await inquirer.default.prompt([{
|
|
35
|
+
type: "confirm",
|
|
36
|
+
name: "overwrite",
|
|
37
|
+
message: `The directory "${path}" is not empty. Do you want to remove its contents?`,
|
|
38
|
+
default: false
|
|
39
|
+
}])).overwrite) {
|
|
40
|
+
console.log("Operation cancelled.");
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const { template } = await inquirer.default.prompt([{
|
|
45
|
+
type: "list",
|
|
46
|
+
name: "template",
|
|
47
|
+
message: "Select a template:",
|
|
48
|
+
choices: [{ name: "default" }].map((t) => t.name),
|
|
49
|
+
default: "default"
|
|
50
|
+
}]);
|
|
51
|
+
(0, node_fs.mkdirSync)(path, { recursive: true });
|
|
52
|
+
const templatePath = (0, node_path.join)((0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)), "../../templates", template);
|
|
53
|
+
if (!(0, node_fs.existsSync)(templatePath)) throw new Error(`Template "${template}" not found.`);
|
|
54
|
+
const files = (0, node_fs.readdirSync)(templatePath);
|
|
55
|
+
for (const file of files) await (0, node_fs_promises.cp)((0, node_path.join)(templatePath, file), (0, node_path.join)(path, file), {
|
|
56
|
+
recursive: true,
|
|
57
|
+
force: true
|
|
58
|
+
});
|
|
59
|
+
console.log("\n✅ AIGNE project created successfully!");
|
|
60
|
+
console.log(`\nTo use your new agent, run:\n cd ${(0, node_path.relative)(process.cwd(), path)} && aigne run`);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.createCreateCommand = createCreateCommand;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync } from "node:fs";
|
|
2
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { cp } from "node:fs/promises";
|
|
5
|
+
import inquirer from "inquirer";
|
|
6
|
+
|
|
7
|
+
//#region src/commands/create.ts
|
|
8
|
+
function createCreateCommand() {
|
|
9
|
+
return {
|
|
10
|
+
command: "create [path]",
|
|
11
|
+
describe: "Create a new aigne project with agent config files",
|
|
12
|
+
builder: (yargs) => {
|
|
13
|
+
return yargs.positional("path", {
|
|
14
|
+
describe: "Path to create the project directory",
|
|
15
|
+
type: "string",
|
|
16
|
+
default: "."
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
handler: async ({ path: path$1 }) => {
|
|
20
|
+
if (path$1 === ".") path$1 = (await inquirer.prompt([{
|
|
21
|
+
type: "input",
|
|
22
|
+
name: "projectName",
|
|
23
|
+
message: "Project name:",
|
|
24
|
+
default: path$1 !== "." ? path$1 : "my-aigne-project",
|
|
25
|
+
validate: (input) => {
|
|
26
|
+
if (input.trim() === "") return "Project name cannot be empty.";
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}])).projectName;
|
|
30
|
+
path$1 = isAbsolute(path$1) ? path$1 : resolve(process.cwd(), path$1);
|
|
31
|
+
if (existsSync(path$1) && readdirSync(path$1).length > 0) {
|
|
32
|
+
if (!(await inquirer.prompt([{
|
|
33
|
+
type: "confirm",
|
|
34
|
+
name: "overwrite",
|
|
35
|
+
message: `The directory "${path$1}" is not empty. Do you want to remove its contents?`,
|
|
36
|
+
default: false
|
|
37
|
+
}])).overwrite) {
|
|
38
|
+
console.log("Operation cancelled.");
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const { template } = await inquirer.prompt([{
|
|
43
|
+
type: "list",
|
|
44
|
+
name: "template",
|
|
45
|
+
message: "Select a template:",
|
|
46
|
+
choices: [{ name: "default" }].map((t) => t.name),
|
|
47
|
+
default: "default"
|
|
48
|
+
}]);
|
|
49
|
+
mkdirSync(path$1, { recursive: true });
|
|
50
|
+
const templatePath = join(dirname(fileURLToPath(import.meta.url)), "../../templates", template);
|
|
51
|
+
if (!existsSync(templatePath)) throw new Error(`Template "${template}" not found.`);
|
|
52
|
+
const files = readdirSync(templatePath);
|
|
53
|
+
for (const file of files) await cp(join(templatePath, file), join(path$1, file), {
|
|
54
|
+
recursive: true,
|
|
55
|
+
force: true
|
|
56
|
+
});
|
|
57
|
+
console.log("\n✅ AIGNE project created successfully!");
|
|
58
|
+
console.log(`\nTo use your new agent, run:\n cd ${relative(process.cwd(), path$1)} && aigne run`);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//#endregion
|
|
64
|
+
export { createCreateCommand };
|
|
65
|
+
//# sourceMappingURL=create.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.mjs","names":["path"],"sources":["../../src/commands/create.ts"],"sourcesContent":["import { existsSync, mkdirSync, readdirSync } from \"node:fs\";\nimport { cp } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport inquirer from \"inquirer\";\nimport type { CommandModule } from \"yargs\";\n\ninterface CreateOptions {\n path: string;\n}\n\nexport function createCreateCommand(): CommandModule<unknown, CreateOptions> {\n return {\n command: \"create [path]\",\n describe: \"Create a new aigne project with agent config files\",\n builder: (yargs) => {\n return yargs.positional(\"path\", {\n describe: \"Path to create the project directory\",\n type: \"string\",\n default: \".\",\n });\n },\n handler: async ({ path }) => {\n if (path === \".\") {\n const answers = await inquirer.prompt([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"Project name:\",\n default: path !== \".\" ? path : \"my-aigne-project\",\n validate: (input) => {\n if (input.trim() === \"\") return \"Project name cannot be empty.\";\n\n return true;\n },\n },\n ]);\n path = answers.projectName;\n }\n\n path = isAbsolute(path) ? path : resolve(process.cwd(), path);\n\n const isPathNotEmpty = existsSync(path) && readdirSync(path).length > 0;\n if (isPathNotEmpty) {\n const answers = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"overwrite\",\n message: `The directory \"${path}\" is not empty. Do you want to remove its contents?`,\n default: false,\n },\n ]);\n\n if (!answers.overwrite) {\n console.log(\"Operation cancelled.\");\n process.exit(0);\n }\n }\n\n const templates = [{ name: \"default\" }];\n\n const { template } = await inquirer.prompt([\n {\n type: \"list\",\n name: \"template\",\n message: \"Select a template:\",\n choices: templates.map((t) => t.name),\n default: \"default\",\n },\n ]);\n\n mkdirSync(path, { recursive: true });\n\n const templatePath = join(\n dirname(fileURLToPath(import.meta.url)),\n \"../../templates\",\n template,\n );\n\n if (!existsSync(templatePath)) throw new Error(`Template \"${template}\" not found.`);\n\n const files = readdirSync(templatePath);\n for (const file of files) {\n const source = join(templatePath, file);\n const destination = join(path, file);\n await cp(source, destination, { recursive: true, force: true });\n }\n\n console.log(\"\\n✅ AIGNE project created successfully!\");\n console.log(\n `\\nTo use your new agent, run:\\n cd ${relative(process.cwd(), path)} && aigne run`,\n );\n },\n };\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,sBAA6D;AAC3E,QAAO;EACL,SAAS;EACT,UAAU;EACV,UAAU,UAAU;AAClB,UAAO,MAAM,WAAW,QAAQ;IAC9B,UAAU;IACV,MAAM;IACN,SAAS;IACV,CAAC;;EAEJ,SAAS,OAAO,EAAE,mBAAW;AAC3B,OAAIA,WAAS,IAcX,WAbgB,MAAM,SAAS,OAAO,CACpC;IACE,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAASA,WAAS,MAAMA,SAAO;IAC/B,WAAW,UAAU;AACnB,SAAI,MAAM,MAAM,KAAK,GAAI,QAAO;AAEhC,YAAO;;IAEV,CACF,CAAC,EACa;AAGjB,YAAO,WAAWA,OAAK,GAAGA,SAAO,QAAQ,QAAQ,KAAK,EAAEA,OAAK;AAG7D,OADuB,WAAWA,OAAK,IAAI,YAAYA,OAAK,CAAC,SAAS,GAWpE;QAAI,EATY,MAAM,SAAS,OAAO,CACpC;KACE,MAAM;KACN,MAAM;KACN,SAAS,kBAAkBA,OAAK;KAChC,SAAS;KACV,CACF,CAAC,EAEW,WAAW;AACtB,aAAQ,IAAI,uBAAuB;AACnC,aAAQ,KAAK,EAAE;;;GAMnB,MAAM,EAAE,aAAa,MAAM,SAAS,OAAO,CACzC;IACE,MAAM;IACN,MAAM;IACN,SAAS;IACT,SAPc,CAAC,EAAE,MAAM,WAAW,CAAC,CAOhB,KAAK,MAAM,EAAE,KAAK;IACrC,SAAS;IACV,CACF,CAAC;AAEF,aAAUA,QAAM,EAAE,WAAW,MAAM,CAAC;GAEpC,MAAM,eAAe,KACnB,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,EACvC,mBACA,SACD;AAED,OAAI,CAAC,WAAW,aAAa,CAAE,OAAM,IAAI,MAAM,aAAa,SAAS,cAAc;GAEnF,MAAM,QAAQ,YAAY,aAAa;AACvC,QAAK,MAAM,QAAQ,MAGjB,OAAM,GAFS,KAAK,cAAc,KAAK,EACnB,KAAKA,QAAM,KAAK,EACN;IAAE,WAAW;IAAM,OAAO;IAAM,CAAC;AAGjE,WAAQ,IAAI,0CAA0C;AACtD,WAAQ,IACN,uCAAuC,SAAS,QAAQ,KAAK,EAAEA,OAAK,CAAC,eACtE;;EAEJ"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_constants = require('../utils/aigne-hub/constants.cjs');
|
|
3
|
+
let node_child_process = require("node:child_process");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
let node_url = require("node:url");
|
|
7
|
+
let node_fs_promises = require("node:fs/promises");
|
|
8
|
+
let _aigne_listr2 = require("@aigne/listr2");
|
|
9
|
+
let node_os = require("node:os");
|
|
10
|
+
let _inquirer_prompts = require("@inquirer/prompts");
|
|
11
|
+
let _listr2_prompt_adapter_inquirer = require("@listr2/prompt-adapter-inquirer");
|
|
12
|
+
let yaml = require("yaml");
|
|
13
|
+
|
|
14
|
+
//#region src/commands/deploy.ts
|
|
15
|
+
async function fileExists(p) {
|
|
16
|
+
try {
|
|
17
|
+
await (0, node_fs_promises.access)(p, node_fs.constants.F_OK);
|
|
18
|
+
return true;
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const DEPLOYED_FILE = require_constants.isTest ? "deployed.test.yaml" : "deployed.yaml";
|
|
24
|
+
async function run(cmd, args = [], opts = {}) {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
const { catchOutput = true, ...rest } = opts;
|
|
27
|
+
const child = (0, node_child_process.spawn)(cmd, args, {
|
|
28
|
+
shell: true,
|
|
29
|
+
...rest,
|
|
30
|
+
stdio: catchOutput ? "pipe" : "inherit"
|
|
31
|
+
});
|
|
32
|
+
if (catchOutput) {
|
|
33
|
+
let stdout = "";
|
|
34
|
+
let stderr = "";
|
|
35
|
+
child.stdout?.on("data", (data) => {
|
|
36
|
+
stdout += data.toString();
|
|
37
|
+
});
|
|
38
|
+
child.stderr?.on("data", (data) => {
|
|
39
|
+
stderr += data.toString();
|
|
40
|
+
});
|
|
41
|
+
child.on("close", (code) => {
|
|
42
|
+
if (code === 0) resolve(stdout.trim());
|
|
43
|
+
else reject(new Error(stderr.trim() || `Process failed with code ${code}`));
|
|
44
|
+
});
|
|
45
|
+
} else child.on("close", (code) => {
|
|
46
|
+
if (code === 0) resolve("");
|
|
47
|
+
else reject(/* @__PURE__ */ new Error(`${cmd} ${args.join(" ")} failed with code ${code}`));
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function createDeployCommands() {
|
|
52
|
+
return {
|
|
53
|
+
command: "deploy",
|
|
54
|
+
describe: "Deploy an aigne application",
|
|
55
|
+
builder: (yargs) => {
|
|
56
|
+
return yargs.option("path", { type: "string" }).option("endpoint", {
|
|
57
|
+
type: "string",
|
|
58
|
+
describe: "Deploy an aigne application to a specified endpoint."
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
handler: async (argv) => {
|
|
62
|
+
const path = argv.path;
|
|
63
|
+
const endpoint = argv.endpoint;
|
|
64
|
+
if (!path) {
|
|
65
|
+
console.error("path is required");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
if (!endpoint) {
|
|
69
|
+
console.error("endpoint is required");
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
await deploy((0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(process.cwd(), path), endpoint);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function copyDir(src, dest) {
|
|
77
|
+
await (0, node_fs_promises.mkdir)(dest, { recursive: true });
|
|
78
|
+
const entries = await (0, node_fs_promises.readdir)(src, { withFileTypes: true });
|
|
79
|
+
const skip = [".deploy", "node_modules"];
|
|
80
|
+
for (const entry of entries) {
|
|
81
|
+
const srcPath = (0, node_path.join)(src, entry.name);
|
|
82
|
+
const destPath = (0, node_path.join)(dest, entry.name);
|
|
83
|
+
if (skip.includes(entry.name)) continue;
|
|
84
|
+
if (entry.isDirectory()) await copyDir(srcPath, destPath);
|
|
85
|
+
else await (0, node_fs_promises.copyFile)(srcPath, destPath);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const deploy = async (path, endpoint) => {
|
|
89
|
+
const aigneHomeDir = (0, node_path.join)((0, node_os.homedir)(), ".aigne");
|
|
90
|
+
if (!await fileExists(aigneHomeDir)) await (0, node_fs_promises.mkdir)(aigneHomeDir, { recursive: true });
|
|
91
|
+
const deployRoot = (0, node_path.join)(path, ".deploy");
|
|
92
|
+
const agentDest = (0, node_path.join)(deployRoot, "agent");
|
|
93
|
+
const tasks = new _aigne_listr2.Listr([
|
|
94
|
+
{
|
|
95
|
+
title: "Prepare deploy environment",
|
|
96
|
+
task: async (ctx, task) => {
|
|
97
|
+
ctx.logs = [];
|
|
98
|
+
task.output = "Preparing deploy environment...";
|
|
99
|
+
const entryFile = (0, node_path.join)(path, "aigne.yaml");
|
|
100
|
+
if (!await fileExists(entryFile)) throw new Error(`Entry file not found: ${entryFile}`);
|
|
101
|
+
await (0, node_fs_promises.rm)(deployRoot, {
|
|
102
|
+
recursive: true,
|
|
103
|
+
force: true
|
|
104
|
+
});
|
|
105
|
+
task.output = "Copying template files...";
|
|
106
|
+
await copyDir((0, node_path.join)((0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href)), "../../templates/blocklet"), deployRoot);
|
|
107
|
+
await copyDir(path, agentDest);
|
|
108
|
+
for (const file of [
|
|
109
|
+
"package.json",
|
|
110
|
+
"package-lock.json",
|
|
111
|
+
"README.md",
|
|
112
|
+
"CHANGELOG.md",
|
|
113
|
+
"biome.json"
|
|
114
|
+
]) {
|
|
115
|
+
const srcFile = (0, node_path.join)(path, file);
|
|
116
|
+
if (await fileExists(srcFile)) {
|
|
117
|
+
await (0, node_fs_promises.copyFile)(srcFile, (0, node_path.join)(deployRoot, file));
|
|
118
|
+
await (0, node_fs_promises.rm)((0, node_path.join)(deployRoot, file), { force: true });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (await fileExists((0, node_path.join)(deployRoot, "package.json"))) {
|
|
122
|
+
task.output = "Running npm install...";
|
|
123
|
+
await run("npm", ["install"], { cwd: deployRoot });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
title: "Check Blocklet CLI",
|
|
129
|
+
task: async (_, task) => {
|
|
130
|
+
try {
|
|
131
|
+
task.output = "Checking Blocklet CLI Version...";
|
|
132
|
+
await run("blocklet", ["--version"], { cwd: deployRoot });
|
|
133
|
+
} catch {
|
|
134
|
+
task.output = "Blocklet CLI not installed, asking to install...";
|
|
135
|
+
const { install } = await task.prompt(_listr2_prompt_adapter_inquirer.ListrInquirerPromptAdapter).run(_inquirer_prompts.select, {
|
|
136
|
+
type: "list",
|
|
137
|
+
name: "install",
|
|
138
|
+
message: "Install Blocklet CLI?",
|
|
139
|
+
choices: ["yes", "no"],
|
|
140
|
+
default: "yes"
|
|
141
|
+
});
|
|
142
|
+
if (install === "yes") {
|
|
143
|
+
task.output = "Installing Blocklet CLI...";
|
|
144
|
+
await run("npm", [
|
|
145
|
+
"install",
|
|
146
|
+
"-g",
|
|
147
|
+
"@blocklet/cli"
|
|
148
|
+
], { cwd: deployRoot });
|
|
149
|
+
} else throw new Error("Blocklet CLI not found, please install manually: npm install -g @blocklet/cli");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
title: "Configure Blocklet",
|
|
155
|
+
task: async (ctx, task) => {
|
|
156
|
+
task.output = "Configuring Blocklet...";
|
|
157
|
+
if (await fileExists((0, node_path.join)(deployRoot, "blocklet.yml"))) {
|
|
158
|
+
const agentName = (0, yaml.parse)(await (0, node_fs_promises.readFile)((0, node_path.join)(path, "aigne.yaml"), "utf-8")).name;
|
|
159
|
+
const deployed = (0, yaml.parse)(await (0, node_fs_promises.readFile)((0, node_path.join)(aigneHomeDir, DEPLOYED_FILE), "utf-8").catch(() => (0, yaml.stringify)({})));
|
|
160
|
+
let blockletName = deployed[path]?.name;
|
|
161
|
+
if (!blockletName) {
|
|
162
|
+
task.output = "Asking for Blocklet name...";
|
|
163
|
+
blockletName = await task.prompt(_listr2_prompt_adapter_inquirer.ListrInquirerPromptAdapter).run(_inquirer_prompts.input, {
|
|
164
|
+
type: "input",
|
|
165
|
+
name: "blockletName",
|
|
166
|
+
message: "Please input agent blocklet name:",
|
|
167
|
+
default: deployed[path]?.name || agentName || (0, node_path.basename)(path),
|
|
168
|
+
validate: (input) => {
|
|
169
|
+
if (input.trim() === "") return "Blocklet name cannot be empty.";
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
let did = deployed[path]?.did;
|
|
175
|
+
if (!did) {
|
|
176
|
+
task.output = "Creating DID...";
|
|
177
|
+
const info = await run("blocklet", ["create", "--did-only"], {
|
|
178
|
+
cwd: deployRoot,
|
|
179
|
+
catchOutput: true
|
|
180
|
+
});
|
|
181
|
+
const match = info.match(/Created Blocklet DID:\s+(\S+)/);
|
|
182
|
+
if (match?.[1]) did = match[1];
|
|
183
|
+
else throw new Error(`DID not found. Output content: ${info}`);
|
|
184
|
+
}
|
|
185
|
+
task.output = `Blocklet name: ${blockletName}, DID: ${did}`;
|
|
186
|
+
ctx.logs.push(task.output);
|
|
187
|
+
const data = (0, yaml.parse)(await (0, node_fs_promises.readFile)((0, node_path.join)(deployRoot, "blocklet.yml"), "utf-8"));
|
|
188
|
+
data.name = blockletName;
|
|
189
|
+
data.title = blockletName;
|
|
190
|
+
data.did = did;
|
|
191
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(deployRoot, "blocklet.yml"), (0, yaml.stringify)(data));
|
|
192
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(aigneHomeDir, DEPLOYED_FILE), (0, yaml.stringify)({
|
|
193
|
+
...deployed,
|
|
194
|
+
[path]: {
|
|
195
|
+
name: blockletName,
|
|
196
|
+
did
|
|
197
|
+
}
|
|
198
|
+
}));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
title: "Bundle Blocklet",
|
|
204
|
+
task: async (_, task) => {
|
|
205
|
+
task.output = "Running blocklet bundle...";
|
|
206
|
+
await run("blocklet", ["bundle", "--create-release"], { cwd: deployRoot });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
], {
|
|
210
|
+
concurrent: false,
|
|
211
|
+
exitOnError: true,
|
|
212
|
+
rendererOptions: { collapseSubtasks: false }
|
|
213
|
+
});
|
|
214
|
+
try {
|
|
215
|
+
await tasks.run();
|
|
216
|
+
await run("blocklet", [
|
|
217
|
+
"deploy",
|
|
218
|
+
"--endpoint",
|
|
219
|
+
endpoint,
|
|
220
|
+
".blocklet/bundle"
|
|
221
|
+
], {
|
|
222
|
+
cwd: deployRoot,
|
|
223
|
+
catchOutput: false
|
|
224
|
+
});
|
|
225
|
+
await (0, node_fs_promises.rm)(deployRoot, {
|
|
226
|
+
recursive: true,
|
|
227
|
+
force: true
|
|
228
|
+
});
|
|
229
|
+
console.log(`✅ Deploy completed: ${path} -> ${endpoint}`);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.error(`❌ Deploy failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
exports.createDeployCommands = createDeployCommands;
|