@nodeskai/genehub 2026.3.4-4 → 2026.3.4-6

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/index.js CHANGED
@@ -6,6 +6,8 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // src/index.ts
9
+ import { readFileSync, realpathSync } from "fs";
10
+ import { dirname as dirname2, join as join13 } from "path";
9
11
  import { fileURLToPath } from "url";
10
12
  import { Command as Command12 } from "commander";
11
13
 
@@ -723,7 +725,9 @@ var OpenClawAdapter = class extends BaseAdapter {
723
725
  try {
724
726
  content = await readFile4(agentsPath, "utf-8");
725
727
  } catch {
726
- return;
728
+ if (action === "remove") return;
729
+ await mkdir4(this.workspaceDir, { recursive: true });
730
+ content = "# AGENTS.md\n";
727
731
  }
728
732
  const marker = `<!-- genehub:${manifest.slug} -->`;
729
733
  const endMarker = `<!-- /genehub:${manifest.slug} -->`;
@@ -1480,9 +1484,11 @@ function generateForgetTaskMarkdown(slug, name, skillContent, callbackPath) {
1480
1484
  var LearningEngine = class {
1481
1485
  workspaceDir;
1482
1486
  adapter;
1487
+ client;
1483
1488
  constructor(options) {
1484
1489
  this.workspaceDir = options.workspaceDir;
1485
1490
  this.adapter = options.adapter;
1491
+ this.client = options.client;
1486
1492
  }
1487
1493
  get tasksDir() {
1488
1494
  return join5(this.workspaceDir, "learning-tasks");
@@ -1492,10 +1498,17 @@ var LearningEngine = class {
1492
1498
  }
1493
1499
  async ensureMetaGeneInstalled() {
1494
1500
  if (!this.adapter) return false;
1501
+ await this.injectBootInstruction();
1495
1502
  const installed = await this.adapter.isInstalled("genehub-learner");
1496
1503
  if (installed) return false;
1497
- await this.adapter.install(META_LEARNER_MANIFEST, { force: true });
1498
- await this.injectBootInstruction();
1504
+ let manifest = META_LEARNER_MANIFEST;
1505
+ if (this.client) {
1506
+ try {
1507
+ manifest = await this.client.getManifest("genehub-learner");
1508
+ } catch {
1509
+ }
1510
+ }
1511
+ await this.adapter.install(manifest, { force: true });
1499
1512
  return true;
1500
1513
  }
1501
1514
  async injectBootInstruction() {
@@ -1504,7 +1517,7 @@ var LearningEngine = class {
1504
1517
  try {
1505
1518
  content = await readFile5(agentsPath, "utf-8");
1506
1519
  } catch {
1507
- return;
1520
+ content = "# AGENTS.md\n";
1508
1521
  }
1509
1522
  const BEGIN = "<!-- genehub:learning-boot -->";
1510
1523
  const END = "<!-- /genehub:learning-boot -->";
@@ -1534,6 +1547,7 @@ ${content.slice(insertPos)}`;
1534
1547
  ${instruction}
1535
1548
  `;
1536
1549
  }
1550
+ await mkdir5(join5(this.workspaceDir), { recursive: true });
1537
1551
  await writeFile5(agentsPath, content, "utf-8");
1538
1552
  }
1539
1553
  async createLearningTask(manifest) {
@@ -2032,7 +2046,7 @@ var installCommand = new Command5("install").description("\u5B89\u88C5\u57FA\u56
2032
2046
  }
2033
2047
  if (opts.learn) {
2034
2048
  const workspaceDir = adapter.product === "openclaw" ? join8(homedir4(), ".openclaw", "workspace") : adapter.product === "nanobot" ? join8(homedir4(), ".nanobot", "workspace") : join8(process.cwd(), ".genehub");
2035
- const engine = new LearningEngine({ workspaceDir, adapter });
2049
+ const engine = new LearningEngine({ workspaceDir, adapter, client });
2036
2050
  const learnSpinner = ora2("\u751F\u6210\u5B66\u4E60\u4EFB\u52A1...").start();
2037
2051
  await engine.createLearningTask(manifest);
2038
2052
  learnSpinner.succeed("\u5B66\u4E60\u4EFB\u52A1\u5DF2\u521B\u5EFA");
@@ -2075,7 +2089,7 @@ var learnCommand = new Command6("learn").description("\u89E6\u53D1\u57FA\u56E0\u
2075
2089
  const client = new GeneHubClient({ registryUrl: config.registryUrl, token: config.token });
2076
2090
  const adapter = opts.product ? getAdapter(opts.product) : await detectAdapter();
2077
2091
  const workspaceDir = getWorkspaceDir(adapter.product);
2078
- const engine = new LearningEngine({ workspaceDir, adapter });
2092
+ const engine = new LearningEngine({ workspaceDir, adapter, client });
2079
2093
  if (opts.check) {
2080
2094
  const spinner2 = ora3("\u68C0\u67E5\u5B66\u4E60\u7ED3\u679C...").start();
2081
2095
  const result = await engine.checkResult(slug);
@@ -2116,10 +2130,19 @@ var learnCommand = new Command6("learn").description("\u89E6\u53D1\u57FA\u56E0\u
2116
2130
  learnSpinner.succeed("\u5B66\u4E60\u4EFB\u52A1\u5DF2\u521B\u5EFA");
2117
2131
  ok(`\u4EFB\u52A1\u6587\u4EF6: ${join9(workspaceDir, "learning-tasks", `${slug}.md`)}`);
2118
2132
  info(`\u7ED3\u679C\u8DEF\u5F84: ${task.callback_path}`);
2133
+ if (adapter.triggerLearning) {
2134
+ const triggerSpinner = ora3("\u89E6\u53D1 bot \u5B66\u4E60...").start();
2135
+ try {
2136
+ await adapter.triggerLearning("\u68C0\u67E5 learning-tasks/ \u76EE\u5F55\u5E76\u5904\u7406\u5B66\u4E60\u4EFB\u52A1");
2137
+ triggerSpinner.succeed("\u5DF2\u89E6\u53D1 bot \u5B66\u4E60\uFF08\u540E\u53F0\u5904\u7406\u4E2D\uFF09");
2138
+ } catch {
2139
+ triggerSpinner.warn("\u81EA\u52A8\u89E6\u53D1\u5931\u8D25\uFF0CAgent \u5C06\u5728\u4E0B\u6B21\u5BF9\u8BDD\u4E2D\u5904\u7406");
2140
+ }
2141
+ } else {
2142
+ info("Agent \u5C06\u5728\u4E0B\u6B21\u5BF9\u8BDD\u4E2D\u5904\u7406\u5B66\u4E60\u4EFB\u52A1");
2143
+ }
2119
2144
  info("");
2120
- info("\u4E0B\u4E00\u6B65\uFF1A");
2121
- info(" 1. Agent \u5728\u4E0B\u6B21\u5BF9\u8BDD\u4E2D\u4F1A\u81EA\u52A8\u53D1\u73B0\u5E76\u5904\u7406\u5B66\u4E60\u4EFB\u52A1");
2122
- info(` 2. \u5B66\u4E60\u5B8C\u6210\u540E\u8FD0\u884C: genehub learn --check ${slug}`);
2145
+ info(`\u5B66\u4E60\u5B8C\u6210\u540E\u8FD0\u884C: genehub learn --check ${slug}`);
2123
2146
  } catch (err) {
2124
2147
  spinner.fail("\u5B66\u4E60\u4EFB\u52A1\u521B\u5EFA\u5931\u8D25");
2125
2148
  fail(err instanceof Error ? err.message : String(err));
@@ -7062,7 +7085,17 @@ var uninstallCommand = new Command11("uninstall").description("\u4ECE\u5F53\u524
7062
7085
 
7063
7086
  // src/index.ts
7064
7087
  var program = new Command12();
7065
- program.name("genehub").description("GeneHub CLI - AI \u5458\u5DE5\u57FA\u56E0\u7BA1\u7406\u5DE5\u5177").version("0.1.0");
7088
+ var __filename = fileURLToPath(import.meta.url);
7089
+ var __dirname = dirname2(__filename);
7090
+ function loadVersion() {
7091
+ try {
7092
+ const pkg = JSON.parse(readFileSync(join13(__dirname, "..", "package.json"), "utf-8"));
7093
+ return pkg.version ?? "0.0.0";
7094
+ } catch {
7095
+ return "0.0.0";
7096
+ }
7097
+ }
7098
+ program.name("genehub").description("GeneHub CLI - AI \u5458\u5DE5\u57FA\u56E0\u7BA1\u7406\u5DE5\u5177").version(loadVersion());
7066
7099
  program.addCommand(authCommand);
7067
7100
  program.addCommand(installCommand);
7068
7101
  program.addCommand(uninstallCommand);
@@ -7074,8 +7107,14 @@ program.addCommand(configCommand);
7074
7107
  program.addCommand(learnCommand);
7075
7108
  program.addCommand(genomeCommand);
7076
7109
  program.addCommand(templateCommand);
7077
- var __filename = fileURLToPath(import.meta.url);
7078
- if (process.argv[1] === __filename) {
7110
+ function isDirectRun() {
7111
+ try {
7112
+ return realpathSync(process.argv[1]) === realpathSync(__filename);
7113
+ } catch {
7114
+ return false;
7115
+ }
7116
+ }
7117
+ if (isDirectRun()) {
7079
7118
  program.parse();
7080
7119
  }
7081
7120
  export {