engine7 7.0.5 → 7.0.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +49 -12
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -474,10 +474,20 @@ engine7 start \u2014 \u542F\u52A8 Engine
474
474
  configPath2 = homeCfg;
475
475
  console.log(` \u4F7F\u7528\u9ED8\u8BA4 config: ${homeCfg}`);
476
476
  } else {
477
- console.error("\u274C \u627E\u4E0D\u5230 config \u6587\u4EF6");
478
- console.error(" \u7528\u6CD5: engine7 start --config <path>");
479
- console.error(" \u6216\u5148\u8FD0\u884C: engine7 init\uFF08\u9ED8\u8BA4\u521B\u5EFA ~/.engine7\uFF09");
480
- process.exit(1);
477
+ const ptr = readHomePointer();
478
+ if (ptr?.stateDir) {
479
+ const ptrCfg = path.join(ptr.stateDir, "configs", "main7.json");
480
+ if (fs.existsSync(ptrCfg)) {
481
+ configPath2 = ptrCfg;
482
+ console.log(` \u4F7F\u7528 config: ${ptrCfg}`);
483
+ }
484
+ }
485
+ if (!configPath2) {
486
+ console.error("\u274C \u627E\u4E0D\u5230 config \u6587\u4EF6");
487
+ console.error(" \u7528\u6CD5: engine7 start --config <path>");
488
+ console.error(" \u6216\u5148\u8FD0\u884C: engine7 init");
489
+ process.exit(1);
490
+ }
481
491
  }
482
492
  }
483
493
  const { execSync, spawn } = await import("node:child_process");
@@ -550,10 +560,20 @@ engine7 service \u2014 \u5F00\u673A\u81EA\u542F\u52A8\u7BA1\u7406
550
560
  configPath2 = homeCfg;
551
561
  cwd = path.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7");
552
562
  } else {
553
- console.error("\u274C \u627E\u4E0D\u5230 config \u6587\u4EF6");
554
- console.error(" \u7528\u6CD5: engine7 service install --config <path>");
555
- console.error(" \u6216\u5148\u8FD0\u884C: engine7 init\uFF08\u9ED8\u8BA4\u521B\u5EFA ~/.engine7\uFF09");
556
- process.exit(1);
563
+ const ptr = readHomePointer();
564
+ if (ptr?.stateDir) {
565
+ const ptrCfg = path.join(ptr.stateDir, "configs", "main7.json");
566
+ if (fs.existsSync(ptrCfg)) {
567
+ configPath2 = ptrCfg;
568
+ cwd = ptr.stateDir;
569
+ }
570
+ }
571
+ if (!configPath2) {
572
+ console.error("\u274C \u627E\u4E0D\u5230 config \u6587\u4EF6");
573
+ console.error(" \u7528\u6CD5: engine7 service install --config <path>");
574
+ console.error(" \u6216\u5148\u8FD0\u884C: engine7 init");
575
+ process.exit(1);
576
+ }
557
577
  }
558
578
  }
559
579
  const { execSync } = await import("node:child_process");
@@ -561,10 +581,14 @@ engine7 service \u2014 \u5F00\u673A\u81EA\u542F\u52A8\u7BA1\u7406
561
581
  if (action === "install") {
562
582
  if (process.platform === "win32") {
563
583
  const taskName = "Engine7";
564
- const cmd = `"${engine7Bin}" start --config "${path.resolve(configPath2)}"`;
584
+ const nodeExe = process.execPath;
585
+ const cliMjs = path.resolve(engine7Bin);
586
+ const tr = `"${nodeExe}" "${cliMjs}" start --config "${path.resolve(configPath2)}"`;
565
587
  try {
566
- execSync(`schtasks /create /tn "${taskName}" /tr "${cmd}" /sc onlogon /rl highest /f`, { stdio: "inherit", shell: true });
588
+ execSync(`schtasks /create /tn "${taskName}" /tr ${tr} /sc onlogon /rl highest /f`, { stdio: "inherit", shell: true });
567
589
  console.log(`\u2705 Windows \u8BA1\u5212\u4EFB\u52A1 "${taskName}" \u5DF2\u521B\u5EFA\uFF08\u5F00\u673A\u81EA\u542F\u52A8\uFF09`);
590
+ console.log(` node: ${nodeExe}`);
591
+ console.log(` cli: ${cliMjs}`);
568
592
  } catch {
569
593
  console.error("\u274C \u521B\u5EFA\u8BA1\u5212\u4EFB\u52A1\u5931\u8D25\uFF0C\u53EF\u80FD\u9700\u8981\u7BA1\u7406\u5458\u6743\u9650");
570
594
  process.exit(1);
@@ -749,10 +773,15 @@ WantedBy=default.target`;
749
773
  console.log(`
750
774
  \u2705 \u521D\u59CB\u5316\u5B8C\u6210\uFF01
751
775
  `);
776
+ const homePointer = path.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7.json");
777
+ const pointerData = { stateDir: opts.stateDir };
778
+ fs.writeFileSync(homePointer, JSON.stringify(pointerData, null, 2) + "\n");
779
+ console.log(` \u{1F4C4} ${homePointer}\uFF08\u4ECE\u4EFB\u610F\u76EE\u5F55\u90FD\u80FD\u627E\u5230\u6B64 agent\uFF09`);
752
780
  console.log(`\u4E0B\u4E00\u6B65\uFF1A`);
753
781
  console.log(` 1. \u68C0\u67E5\u5E76\u4FEE\u6539 ${opts.stateDir}/configs/main7.json`);
754
- console.log(` 2. \u542F\u52A8 Engine: cd ${opts.stateDir} && engine7 start`);
755
- console.log(` 3. \u67E5\u770B workspace: ${path.join(opts.stateDir, "workspace")}`);
782
+ console.log(` 2. \u542F\u52A8 Engine: engine7 start\uFF08\u5728\u4EFB\u610F\u76EE\u5F55\u90FD\u884C\uFF09`);
783
+ console.log(` 3. \u5F00\u673A\u81EA\u542F: engine7 service install\uFF08\u5728\u4EFB\u610F\u76EE\u5F55\u90FD\u884C\uFF09`);
784
+ console.log(` 4. \u67E5\u770B workspace: ${path.join(opts.stateDir, "workspace")}`);
756
785
  }
757
786
  }
758
787
  function copyDirRecursive(src, dest) {
@@ -778,6 +807,14 @@ function findTemplateDir(name) {
778
807
  }
779
808
  return null;
780
809
  }
810
+ function readHomePointer() {
811
+ const ptrPath = path.join(process.env.HOME || process.env.USERPROFILE || ".", ".engine7.json");
812
+ try {
813
+ return JSON.parse(fs.readFileSync(ptrPath, "utf-8"));
814
+ } catch {
815
+ return null;
816
+ }
817
+ }
781
818
  main().catch((err) => {
782
819
  console.error(`
783
820
  \u274C \u5931\u8D25: ${err.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engine7",
3
- "version": "7.0.5",
3
+ "version": "7.0.7",
4
4
  "type": "module",
5
5
  "description": "Engine 7 — Self-hosted AI agent engine",
6
6
  "main": "dist/main.mjs",