fix(memory): address quality cleanup audit findings

This commit is contained in:
Ralph Chang
2026-04-28 14:29:28 +08:00
parent e8c95a62ec
commit 8da39c7a9d
9 changed files with 267 additions and 63 deletions
+40 -7
View File
@@ -1,12 +1,45 @@
/**
* 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";
const roots = [
"/Users/sd_wo/work/opencode-working-memory",
"/Users/sd_wo/Documents/projects/Pre-cancer-atlas",
"/Users/sd_wo/work/opencode-record",
"/Users/sd_wo/work/pathology-agent-reports",
"/Users/sd_wo/work/pathology-extraction",
];
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}`);