kaizen-agent 1.3.4 → 1.3.5
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/cli/install.ts +32 -6
- package/package.json +1 -1
package/cli/install.ts
CHANGED
|
@@ -147,6 +147,20 @@ if (interactive && !upgrade && Bun.argv.length === 2) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
if (upgrade) await clearBunxCache();
|
|
150
|
+
|
|
151
|
+
// An install made without git is a copy, not a clone, so there is nothing to pull:
|
|
152
|
+
// upgrading itself would copy ~/kaizen over ~/kaizen and report "already up to
|
|
153
|
+
// date" forever. The new version comes from npm, and the installer inside it does
|
|
154
|
+
// the copying and relinking, so hand the job over and stop.
|
|
155
|
+
if (upgrade && !existsSync(join(dirname(import.meta.dir), ".git"))) {
|
|
156
|
+
const latest = await npmLatest();
|
|
157
|
+
const now = versionOf(dirname(import.meta.dir));
|
|
158
|
+
if (latest && latest !== now) {
|
|
159
|
+
step(`fetching kaizen ${latest} from npm`);
|
|
160
|
+
await Bun.$`${process.execPath} x kaizen-agent@${latest} --yes`.catch(() => {});
|
|
161
|
+
process.exit(0);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
150
164
|
if (!check && !upgrade) await welcome();
|
|
151
165
|
|
|
152
166
|
async function welcome() {
|
|
@@ -448,17 +462,27 @@ if (!args.has("--project")) installLauncher();
|
|
|
448
462
|
// type afterwards. A launcher pointed at the clone gives one, and keeps working
|
|
449
463
|
// after the clone updates.
|
|
450
464
|
function installLauncher() {
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
465
|
+
const entry = join(repo, "cli/install.ts");
|
|
466
|
+
// Windows cannot run a shell script and has no ~/.local/bin on PATH. Bun's own
|
|
467
|
+
// bin directory is already there — bun put it there when it installed itself —
|
|
468
|
+
// so a .cmd beside bun is the launcher that works without touching PATH.
|
|
469
|
+
const win = process.platform === "win32";
|
|
470
|
+
const binDir = win
|
|
471
|
+
? join(process.env.BUN_INSTALL ?? join(home, ".bun"), "bin")
|
|
472
|
+
: join(home, ".local", "bin");
|
|
473
|
+
const bin = join(binDir, win ? "kaizen.cmd" : "kaizen");
|
|
474
|
+
const script = win
|
|
475
|
+
? `@echo off\r\nrem kaizen launcher -- installed by kaizen-agent\r\nbun run "${entry}" %*\r\n`
|
|
476
|
+
: `#!/bin/sh\n# kaizen launcher -- installed by kaizen-agent\nexec bun run ${entry} "$@"\n`;
|
|
454
477
|
try {
|
|
455
478
|
if (existsSync(bin) && readFileSync(bin, "utf8") === script) return;
|
|
456
479
|
mkdirSync(binDir, { recursive: true });
|
|
457
480
|
writeFileSync(bin, script, { mode: 0o755 });
|
|
458
|
-
const onPath = (process.env.PATH ?? "").split(":")
|
|
481
|
+
const onPath = (process.env.PATH ?? "").split(win ? ";" : ":")
|
|
482
|
+
.some((p) => p.replace(/[\\/]+$/, "").toLowerCase() === binDir.replace(/[\\/]+$/, "").toLowerCase());
|
|
459
483
|
step(onPath
|
|
460
484
|
? `${c.cyan("kaizen upgrade")} is now on your PATH`
|
|
461
|
-
: `wrote ${tilde(bin)} ${c.dim(
|
|
485
|
+
: `wrote ${tilde(bin)} ${c.dim(`— add ${tilde(binDir)} to PATH to use it`)}`);
|
|
462
486
|
} catch {
|
|
463
487
|
/* a read-only home is not worth failing the install over */
|
|
464
488
|
}
|
|
@@ -608,7 +632,9 @@ async function runUpgrade(repoDir: string) {
|
|
|
608
632
|
.map((l) => c.dim(l.trim())),
|
|
609
633
|
];
|
|
610
634
|
if (latest && latest !== after) {
|
|
611
|
-
lines.push("", c.dim(
|
|
635
|
+
lines.push("", c.dim(existsSync(join(repoDir, ".git"))
|
|
636
|
+
? `npm publishes ${latest}; this install follows the git clone.`
|
|
637
|
+
: `npm publishes ${latest} — run: bunx kaizen-agent@${latest}`));
|
|
612
638
|
}
|
|
613
639
|
lines.push("", c.dim("Restart your agent to pick up new slash commands."));
|
|
614
640
|
return lines;
|
package/package.json
CHANGED