aico-cli 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ import { join as join$1 } from 'node:path';
13
13
  import { join, dirname, basename } from 'pathe';
14
14
  import { fileURLToPath } from 'node:url';
15
15
 
16
- const version = "0.3.5";
16
+ const version = "0.3.7";
17
17
 
18
18
  function displayBanner(subtitle) {
19
19
  const defaultSubtitle = "\u4E00\u952E\u914D\u7F6E\u4F60\u7684\u5F00\u53D1\u73AF\u5883";
package/dist/cli.mjs CHANGED
@@ -127,6 +127,25 @@ promisify$1(exec$1);
127
127
 
128
128
  promisify$1(exec$1);
129
129
 
130
+ const execAsync = promisify(exec);
131
+ async function run(command) {
132
+ try {
133
+ const result = await execAsync(command);
134
+ return result;
135
+ } catch (error) {
136
+ if (error instanceof Error) {
137
+ throw new Error(`Command failed: ${command}
138
+ Error: ${error.message}`);
139
+ }
140
+ throw error;
141
+ }
142
+ }
143
+
144
+ const runCommand = {
145
+ __proto__: null,
146
+ run: run
147
+ };
148
+
130
149
  async function tryStartClaude(command, args, options) {
131
150
  return new Promise((resolve, reject) => {
132
151
  const child = spawn(command, args, options);
@@ -202,6 +221,30 @@ function createDefaultContext() {
202
221
  async function launchCodeEditor() {
203
222
  return startClaudeCodeEditor();
204
223
  }
224
+ async function launchCUI() {
225
+ const { spawn } = await import('child_process');
226
+ const { promisify } = await import('util');
227
+ const exec = promisify(require("child_process").exec);
228
+ try {
229
+ console.log("\u6B63\u5728\u5B89\u88C5 pm2...");
230
+ await exec("npm install -g pm2");
231
+ console.log("pm2 \u5B89\u88C5\u6210\u529F");
232
+ console.log("\u6B63\u5728\u5B89\u88C5 aico-cui...");
233
+ await exec("npm install -g aico-cui");
234
+ console.log("aico-cui \u5B89\u88C5\u6210\u529F");
235
+ console.log("\u542F\u52A8 AICO CUI \u53EF\u89C6\u5316\u754C\u9762...");
236
+ const cuiProcess = spawn("aico-cui", [], { stdio: "inherit" });
237
+ cuiProcess.on("close", (code) => {
238
+ console.log(`AICO CUI \u5DF2\u9000\u51FA\uFF0C\u9000\u51FA\u7801: ${code}`);
239
+ });
240
+ cuiProcess.on("error", (err) => {
241
+ console.error("\u542F\u52A8 AICO CUI \u5931\u8D25:", err);
242
+ });
243
+ } catch (error) {
244
+ console.error("\u542F\u52A8\u53EF\u89C6\u5316\u754C\u9762\u5931\u8D25:", error);
245
+ throw error;
246
+ }
247
+ }
205
248
 
206
249
  async function showMainMenu() {
207
250
  try {
@@ -235,6 +278,13 @@ async function showMainMenu() {
235
278
  description: "\u66F4\u65B0 \u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382 \u5230\u6700\u65B0\u7248\u672C",
236
279
  processor: () => updateAicoCli(),
237
280
  section: "\u57FA\u7840\u914D\u7F6E"
281
+ },
282
+ "5": {
283
+ key: "5",
284
+ label: "\u542F\u52A8\u53EF\u89C6\u5316\u754C\u9762",
285
+ description: "\u542F\u52A8AICO CUI\u53EF\u89C6\u5316\u754C\u9762",
286
+ processor: () => launchCUI(),
287
+ section: "\u9AD8\u7EA7\u529F\u80FD"
238
288
  }
239
289
  };
240
290
  let exitMenu = false;
@@ -367,7 +417,7 @@ async function update(options = {}) {
367
417
  }
368
418
 
369
419
  function setupCommands(cli) {
370
- cli.command("", "\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\uFF08\u9ED8\u8BA4\uFF09").option("--menu", "\u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355").option("--init", "\u521D\u59CB\u5316\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382AI\u914D\u7F6E").option("--update", "\u66F4\u65B0\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\u5230\u6700\u65B0\u7248\u672C").option("--company", "\u914D\u7F6E\u516C\u53F8\u914D\u7F6E").option("--personal", "\u914D\u7F6E\u4E2A\u4EBA\u914D\u7F6E").option("--help", "\u663E\u793A\u5E2E\u52A9\u4FE1\u606F").action(async (options) => {
420
+ cli.command("", "\u542F\u52A8\u4EE3\u7801\u7F16\u8F91\u5668\uFF08\u9ED8\u8BA4\uFF09").option("--menu", "\u663E\u793A\u4EA4\u4E92\u5F0F\u83DC\u5355").option("--init", "\u521D\u59CB\u5316\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382AI\u914D\u7F6E").option("--update", "\u66F4\u65B0\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\u5230\u6700\u65B0\u7248\u672C").option("--company", "\u914D\u7F6E\u516C\u53F8\u914D\u7F6E").option("--personal", "\u914D\u7F6E\u4E2A\u4EBA\u914D\u7F6E").option("--ui", "\u542F\u52A8\u53EF\u89C6\u5316\u9875\u9762").option("--help", "\u663E\u793A\u5E2E\u52A9\u4FE1\u606F").action(async (options) => {
371
421
  if (options.menu) {
372
422
  await showMainMenu();
373
423
  } else if (options.init) {
@@ -392,6 +442,8 @@ function setupCommands(cli) {
392
442
  });
393
443
  } else if (options.help) {
394
444
  cli.outputHelp();
445
+ } else if (options.ui) {
446
+ await startUI();
395
447
  } else {
396
448
  await startCodeEditor();
397
449
  }
@@ -423,6 +475,9 @@ function setupCommands(cli) {
423
475
  cli.command("h", "\u663E\u793A\u5E2E\u52A9\u4FE1\u606F").action(() => {
424
476
  cli.outputHelp();
425
477
  });
478
+ cli.command("ui", "\u542F\u52A8\u53EF\u89C6\u5316\u754C\u9762").action(async () => {
479
+ await startUI();
480
+ });
426
481
  cli.help((sections) => customizeHelp(sections));
427
482
  cli.version(version);
428
483
  return cli;
@@ -482,6 +537,7 @@ function customizeHelp(sections) {
482
537
  ` ${ansis.cyan("--update")} \u66F4\u65B0\u667A\u80FD\u8F6F\u4EF6\u661F\u5DE5\u5382\u5230\u6700\u65B0\u7248\u672C`,
483
538
  ` ${ansis.cyan("--company")} \u914D\u7F6E\u516C\u53F8\u914D\u7F6E`,
484
539
  ` ${ansis.cyan("--personal")} \u914D\u7F6E\u4E2A\u4EBA\u914D\u7F6E`,
540
+ ` ${ansis.cyan("--ui")} \u542F\u52A8\u53EF\u89C6\u5316\u9875\u9762`,
485
541
  ` ${ansis.cyan("--help")} \u663E\u793A\u5E2E\u52A9\u4FE1\u606F`,
486
542
  "",
487
543
  ansis.gray(" \u5FEB\u6377\u65B9\u5F0F:"),
@@ -489,11 +545,26 @@ function customizeHelp(sections) {
489
545
  ` ${ansis.cyan("aico u")} (--update) \u5FEB\u901F\u66F4\u65B0`,
490
546
  ` ${ansis.cyan("aico c")} (--company) \u516C\u53F8\u914D\u7F6E`,
491
547
  ` ${ansis.cyan("aico p")} (--personal) \u4E2A\u4EBA\u914D\u7F6E`,
548
+ ` ${ansis.cyan("aico ui")} (--ui) \u542F\u52A8\u53EF\u89C6\u5316\u754C\u9762`,
492
549
  ` ${ansis.cyan("aico h")} (--help) \u663E\u793A\u5E2E\u52A9`
493
550
  ].join("\n")
494
551
  });
495
552
  return sections;
496
553
  }
554
+ async function startUI() {
555
+ try {
556
+ const { run } = await Promise.resolve().then(function () { return runCommand; });
557
+ console.log("\x1B[36m\u6B63\u5728\u5B89\u88C5PM2...\x1B[0m");
558
+ await run("npm install -g pm2");
559
+ console.log("\x1B[36m\u6B63\u5728\u5B89\u88C5AICO\u53EF\u89C6\u5316\u754C\u9762...\x1B[0m");
560
+ await run("npm install -g aico-cui");
561
+ console.log("\x1B[36m\u542F\u52A8AICO\u53EF\u89C6\u5316\u754C\u9762...\x1B[0m");
562
+ await run("aico-cui");
563
+ } catch (error) {
564
+ console.error("\x1B[31m\u542F\u52A8\u53EF\u89C6\u5316\u754C\u9762\u5931\u8D25:\x1B[0m", error);
565
+ process.exit(1);
566
+ }
567
+ }
497
568
 
498
569
  if (!Array.prototype.findLastIndex) {
499
570
  Array.prototype.findLastIndex = function(predicate, thisArg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aico-cli",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "packageManager": "pnpm@9.15.9",
5
5
  "description": "AI CLI",
6
6
  "repository": {