kaizen-agent 1.3.8 → 1.3.10
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/dashboard.ts +10 -3
- package/cli/install.ts +27 -5
- package/package.json +1 -1
package/cli/dashboard.ts
CHANGED
|
@@ -437,7 +437,12 @@ export async function dashboard(
|
|
|
437
437
|
async function sync() {
|
|
438
438
|
const before = knownProjects().length;
|
|
439
439
|
const started = Date.now();
|
|
440
|
-
|
|
440
|
+
// Only searching under $HOME misses every project on another drive or mount,
|
|
441
|
+
// which on Windows is most of them. The folder the dashboard was opened in is
|
|
442
|
+
// searched too, and it is where the projects being worked on actually are.
|
|
443
|
+
const roots = [home, dirname(state ?? process.cwd()), process.cwd()]
|
|
444
|
+
.filter((d, i, all) => all.indexOf(d) === i);
|
|
445
|
+
const found = [...new Set(roots.flatMap((r) => findProjects(r)))];
|
|
441
446
|
for (const dir of found) remember(dir);
|
|
442
447
|
const added = knownProjects().length - before;
|
|
443
448
|
await report([
|
|
@@ -445,7 +450,7 @@ export async function dashboard(
|
|
|
445
450
|
"",
|
|
446
451
|
...found.map((d) => " " + c.dim(tilde(d))),
|
|
447
452
|
"",
|
|
448
|
-
c.dim(`${found.length} found in ${((Date.now() - started) / 1000).toFixed(1)}s under ${tilde(
|
|
453
|
+
c.dim(`${found.length} found in ${((Date.now() - started) / 1000).toFixed(1)}s under ${roots.map(tilde).join(", ")}`),
|
|
449
454
|
c.dim(`the list lives in ${tilde(join(home, ".kaizen", "projects"))} and can be edited`),
|
|
450
455
|
]);
|
|
451
456
|
}
|
|
@@ -1311,7 +1316,9 @@ function findProjects(root: string, depth = 4): string[] {
|
|
|
1311
1316
|
try { entries = readdirSync(dir); } catch { return; }
|
|
1312
1317
|
// $HOME holds ~/.kaizen, the global state, which is not a project and must not
|
|
1313
1318
|
// stop the walk before it has looked at anything.
|
|
1314
|
-
|
|
1319
|
+
// A project can hold projects of its own -- a monorepo, or a folder of them --
|
|
1320
|
+
// so finding one is not a reason to stop looking underneath it.
|
|
1321
|
+
if (dir !== root && entries.includes(".kaizen")) found.push(dir);
|
|
1315
1322
|
if (left === 0) return;
|
|
1316
1323
|
for (const name of entries) {
|
|
1317
1324
|
if (name.startsWith(".") || name === "node_modules") continue;
|
package/cli/install.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import {
|
|
3
3
|
symlinkSync, mkdirSync, readdirSync, lstatSync, readlinkSync, unlinkSync,
|
|
4
|
-
existsSync, copyFileSync, readFileSync, appendFileSync, rmSync, writeFileSync,
|
|
4
|
+
existsSync, copyFileSync, readFileSync, appendFileSync, rmSync, writeFileSync, renameSync,
|
|
5
5
|
statSync, cpSync,
|
|
6
6
|
} from "node:fs";
|
|
7
7
|
import { join, dirname, basename } from "node:path";
|
|
@@ -355,14 +355,36 @@ async function resolveRepo() {
|
|
|
355
355
|
}
|
|
356
356
|
return dest;
|
|
357
357
|
}
|
|
358
|
-
|
|
358
|
+
// A copy made before git was installed can never be pulled, so it keeps upgrading
|
|
359
|
+
// through npm and its caches. Once git is here, replace it with a real clone --
|
|
360
|
+
// into a sibling first, so a clone that fails leaves the working copy alone.
|
|
361
|
+
if (Bun.which("git") && existsSync(join(dest, "cli", "install.ts"))) {
|
|
362
|
+
const fresh = `${dest}.new`;
|
|
363
|
+
try {
|
|
364
|
+
rmSync(fresh, { recursive: true, force: true });
|
|
365
|
+
await Bun.$`git clone --quiet ${REPO_URL} ${fresh}`;
|
|
366
|
+
rmSync(dest, { recursive: true, force: true });
|
|
367
|
+
renameSync(fresh, dest);
|
|
368
|
+
step(`re-cloned ${tilde(dest)} ${c.dim("(git is available now)")}`);
|
|
369
|
+
return dest;
|
|
370
|
+
} catch {
|
|
371
|
+
rmSync(fresh, { recursive: true, force: true });
|
|
372
|
+
// Fall through to the copy below: an unreachable network is not a reason to
|
|
373
|
+
// leave the install untouched.
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Cloning needs an empty directory, and a copy made on a machine that had no git
|
|
378
|
+
// is anything but: installing git later must not turn every run into a fatal.
|
|
379
|
+
// An existing directory is updated in place whichever way it was made.
|
|
380
|
+
if (Bun.which("git") && !existsSync(dest)) {
|
|
359
381
|
step(`cloning into ${tilde(dest)}`);
|
|
360
382
|
await Bun.$`git clone --quiet ${REPO_URL} ${dest}`;
|
|
361
383
|
return dest;
|
|
362
384
|
}
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
step(`copying into ${tilde(dest)} ${c.dim("(no git)")}`);
|
|
385
|
+
// The bunx download already holds everything a clone would, so copy it in place.
|
|
386
|
+
// Upgrades then come from re-running bunx rather than a pull.
|
|
387
|
+
step(`copying into ${tilde(dest)} ${c.dim(existsSync(dest) ? "(over the copy already there)" : "(no git)")}`);
|
|
366
388
|
cpSync(here, dest, {
|
|
367
389
|
recursive: true, dereference: true,
|
|
368
390
|
filter: (src) => basename(src) !== "node_modules",
|
package/package.json
CHANGED