mirror of
https://github.com/sdwolf4103/opencode-working-memory.git
synced 2026-07-17 12:56:42 +02:00
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
/**
|
|
* Local helper to trigger migration on workspace roots.
|
|
*
|
|
* Usage:
|
|
* MIGRATION_DRY_RUN_ROOTS=/path/a:/path/b bun run scripts/dev/dry-run-migration.ts
|
|
*
|
|
* Or create a local file (gitignored):
|
|
* echo "/path/to/workspace1" > scripts/dev/dry-run-roots.local.txt
|
|
* echo "/path/to/workspace2" >> scripts/dev/dry-run-roots.local.txt
|
|
* bun run scripts/dev/dry-run-migration.ts
|
|
*/
|
|
|
|
import { existsSync } from "node:fs";
|
|
import { readFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { loadWorkspaceMemory } from "../../src/workspace-memory.ts";
|
|
|
|
async function getRoots(): Promise<string[]> {
|
|
// Priority 1: environment variable
|
|
const envRoots = process.env.MIGRATION_DRY_RUN_ROOTS;
|
|
if (envRoots) {
|
|
return envRoots.split(":").filter(root => root.length > 0);
|
|
}
|
|
|
|
// Priority 2: local file
|
|
const localFile = join(import.meta.dirname, "dry-run-roots.local.txt");
|
|
if (existsSync(localFile)) {
|
|
const content = await readFile(localFile, "utf8");
|
|
return content.trim().split("\n").filter(root => root.length > 0);
|
|
}
|
|
|
|
// No roots configured
|
|
console.log("No workspace roots configured.");
|
|
console.log("Set MIGRATION_DRY_RUN_ROOTS=/path/a:/path/b or create dry-run-roots.local.txt");
|
|
return [];
|
|
}
|
|
|
|
const roots = await getRoots();
|
|
|
|
if (roots.length === 0) {
|
|
process.exit(0);
|
|
}
|
|
|
|
for (const root of roots) {
|
|
console.log(`Loading workspace memory: ${root}`);
|
|
const store = await loadWorkspaceMemory(root);
|
|
const active = store.entries.filter(entry => entry.status !== "superseded").length;
|
|
const superseded = store.entries.filter(entry => entry.status === "superseded").length;
|
|
console.log(` active=${active} superseded=${superseded} migrations=${(store.migrations ?? []).join(",")}`);
|
|
}
|