wolverine-ai 6.2.2 → 6.2.3

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/package.json +1 -1
  2. package/src/claw/setup.js +99 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wolverine-ai",
3
- "version": "6.2.2",
3
+ "version": "6.2.3",
4
4
  "description": "Self-healing Node.js server framework powered by AI. Catches crashes, diagnoses errors, generates fixes, verifies, and restarts — automatically.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/claw/setup.js CHANGED
@@ -522,6 +522,79 @@ function ensureEnvFile(cwd, env) {
522
522
  return result;
523
523
  }
524
524
 
525
+ /**
526
+ * Ensure wolverine-ai is installed as a dependency.
527
+ * Skips if we're running from the wolverine repo itself.
528
+ */
529
+ function ensureWolverineDep(cwd) {
530
+ // If we're inside the wolverine repo, skip
531
+ const pkgPath = path.join(cwd, "package.json");
532
+ try {
533
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
534
+ if (pkg.name === "wolverine-ai") {
535
+ return { installed: true, isRepo: true, alreadyPresent: true };
536
+ }
537
+ // Already a dependency?
538
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
539
+ if (deps["wolverine-ai"]) {
540
+ return { installed: true, alreadyPresent: true };
541
+ }
542
+ } catch {}
543
+
544
+ // Install it
545
+ if (!fs.existsSync(pkgPath)) {
546
+ return { installed: false, reason: "no package.json" };
547
+ }
548
+
549
+ try {
550
+ console.log(chalk.gray(" Installing wolverine-ai..."));
551
+ execSync("npm install wolverine-ai@latest 2>&1", {
552
+ cwd,
553
+ encoding: "utf-8",
554
+ timeout: 120000,
555
+ stdio: ["pipe", "pipe", "pipe"],
556
+ });
557
+ return { installed: true, alreadyPresent: false };
558
+ } catch (err) {
559
+ return { installed: false, reason: `npm install failed: ${err.message?.split("\n")[0]}` };
560
+ }
561
+ }
562
+
563
+ /**
564
+ * Add claw-related npm scripts to the user's package.json.
565
+ */
566
+ function addClawScripts(cwd) {
567
+ const pkgPath = path.join(cwd, "package.json");
568
+ if (!fs.existsSync(pkgPath)) return { added: 0 };
569
+
570
+ try {
571
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
572
+ if (!pkg.scripts) pkg.scripts = {};
573
+
574
+ const toAdd = {
575
+ "claw": "wolverine-claw",
576
+ "claw:direct": "wolverine-claw --direct",
577
+ "claw:info": "wolverine-claw --info",
578
+ };
579
+
580
+ let added = 0;
581
+ for (const [name, cmd] of Object.entries(toAdd)) {
582
+ if (!pkg.scripts[name]) {
583
+ pkg.scripts[name] = cmd;
584
+ added++;
585
+ }
586
+ }
587
+
588
+ if (added > 0) {
589
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
590
+ }
591
+
592
+ return { added, skipped: added === 0 };
593
+ } catch {
594
+ return { added: 0 };
595
+ }
596
+ }
597
+
525
598
  /**
526
599
  * Ensure openclaw is installed as a dependency.
527
600
  */
@@ -781,9 +854,21 @@ async function setup(cwd, options = {}) {
781
854
 
782
855
  log("");
783
856
 
784
- // ── Step 6: Install OpenClaw ────────────────────────────────
857
+ // ── Step 6: Install dependencies ─────────────────────────────
858
+ log(chalk.bold(" Dependencies...\n"));
859
+
860
+ // 6a: Install wolverine-ai itself if not already a dep
861
+ const wolverineDepResult = ensureWolverineDep(cwd);
862
+ if (wolverineDepResult.installed) {
863
+ log(chalk.green(` ✅ wolverine-ai ${wolverineDepResult.alreadyPresent ? "already installed" : "installed"}`));
864
+ } else if (wolverineDepResult.isRepo) {
865
+ log(chalk.gray(" ○ wolverine-ai (running from repo)"));
866
+ } else {
867
+ log(chalk.yellow(` ⚠️ wolverine-ai: ${wolverineDepResult.reason}`));
868
+ }
869
+
870
+ // 6b: Install openclaw if not already present
785
871
  if (!env.openclaw.localInstall) {
786
- log(chalk.bold(" Dependencies...\n"));
787
872
  const depResult = ensureOpenClawDep(cwd);
788
873
  if (depResult.installed) {
789
874
  log(chalk.green(` ✅ openclaw ${depResult.alreadyPresent ? "already installed" : "installed"}`));
@@ -793,9 +878,18 @@ async function setup(cwd, options = {}) {
793
878
  log(chalk.gray(` ${depResult.fallback}`));
794
879
  }
795
880
  }
796
- log("");
797
881
  }
798
882
 
883
+ // 6c: Add claw npm scripts to user's package.json
884
+ const scriptsResult = addClawScripts(cwd);
885
+ if (scriptsResult.added > 0) {
886
+ log(chalk.green(` ✅ Added ${scriptsResult.added} npm scripts (claw, claw:info, claw:direct)`));
887
+ } else if (scriptsResult.skipped) {
888
+ log(chalk.gray(" ○ npm scripts already present"));
889
+ }
890
+
891
+ log("");
892
+
799
893
  // ── Step 7: Validate ───────────────────────────────────────
800
894
  log(chalk.bold(" Validating...\n"));
801
895
 
@@ -924,4 +1018,6 @@ module.exports = {
924
1018
  validate,
925
1019
  ensureEnvFile,
926
1020
  ensureOpenClawDep,
1021
+ ensureWolverineDep,
1022
+ addClawScripts,
927
1023
  };