@kybernesis/create 0.15.0 → 0.15.1

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/upgrade.js +33 -9
  2. package/package.json +1 -1
package/dist/upgrade.js CHANGED
@@ -721,15 +721,6 @@ function startStoppedBridge(cwd, unit) {
721
721
  }
722
722
  export async function upgrade(options = {}) {
723
723
  console.log(bold("\nkyb upgrade — checking @kybernesis/* and eve against npm\n"));
724
- const selfVersion = checkSelfVersion();
725
- if (selfVersion.kind === "stale") {
726
- console.log(` ${yellow("!")} ${selfVersion.message}`);
727
- console.log(` ${dim(selfVersion.fix)}\n`);
728
- if (!options.allowStale) {
729
- process.exitCode = 1;
730
- return;
731
- }
732
- }
733
724
  const cwd = process.cwd();
734
725
  const packagePath = join(cwd, "package.json");
735
726
  const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
@@ -737,6 +728,39 @@ export async function upgrade(options = {}) {
737
728
  ...(pkg.dependencies ?? {}),
738
729
  ...(pkg.devDependencies ?? {}),
739
730
  };
731
+ const selfVersion = checkSelfVersion();
732
+ if (selfVersion.kind === "stale" && !options.allowStale) {
733
+ /**
734
+ * A stale kyb that is the PROJECT's own dependency renews itself.
735
+ *
736
+ * On every self-hosted agent, kyb is in package.json and `npx kyb` runs
737
+ * that copy; a global install — the printed fix until now — changes
738
+ * nothing there, and the person who followed it was back at the same
739
+ * message. So when the project owns kyb, install the latest into the
740
+ * project and run the upgrade again from that copy. The re-run is marked
741
+ * so that a registry that has not caught up cannot make this loop.
742
+ */
743
+ if (deps["@kybernesis/create"] && process.env.KYB_UPGRADE_RENEWED !== "1") {
744
+ console.log(` ${yellow("↑")} kyb ${selfVersion.installed} → ${selfVersion.latest} ${dim("(this project's own copy; renewing it first)")}`);
745
+ const renewed = run("npm", ["install", `@kybernesis/create@${selfVersion.latest}`, "--no-audit", "--no-fund"], { cwd, allowFail: true, quiet: true });
746
+ const cli = join(cwd, "node_modules/@kybernesis/create/dist/cli.js");
747
+ if (renewed && existsSync(cli)) {
748
+ const again = spawnSync(process.execPath, [cli, "upgrade", ...process.argv.slice(3)], {
749
+ cwd, stdio: "inherit", env: { ...process.env, KYB_UPGRADE_RENEWED: "1" },
750
+ });
751
+ process.exitCode = again.status ?? 1;
752
+ return;
753
+ }
754
+ }
755
+ console.log(` ${yellow("!")} ${selfVersion.message}`);
756
+ console.log(` ${dim(deps["@kybernesis/create"] ? `npm install @kybernesis/create@latest && npx kyb upgrade` : selfVersion.fix)}\n`);
757
+ process.exitCode = 1;
758
+ return;
759
+ }
760
+ if (selfVersion.kind === "stale") {
761
+ console.log(` ${yellow("!")} ${selfVersion.message}`);
762
+ console.log(` ${dim(selfVersion.fix)} ${dim("(continuing: --allow-stale)")}\n`);
763
+ }
740
764
  reportAgentInputLimit(cwd);
741
765
  const entries = dependencyEntries(pkg);
742
766
  const installedVersions = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kybernesis/create",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "The Kybernesis agent scaffolder and FDE toolkit: one command to a governed, remembering, multiplayer, self-testing eve agent \u2014 plus doctor and upgrade.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",