refactor: remove legacy kb compatibility

Drops the .kb/kb.db migration path, legacy backup filename handling, and
backward-compat test suites. Renames internal kbDir identifiers to
fusionDir and hasKbProject/isValidKbProject to their fusion equivalents.

- Remove needsCentralMigration, autoMigrateToCentral, and the
  "needs-migration" FirstRunState; checkAndMigrate and KB_SKIP_MIGRATION
  env var are gone
- Remove LEGACY_BACKUP_DIR and canonicalizeBackupDir; listBackups no
  longer matches kb-* filenames
- Delete backward-compat.test.ts and store-backward-compat.test.ts;
  update remaining tests to new 3-state first-run model

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-23 16:55:46 -07:00
parent 32da0aedac
commit a269f4829f
36 changed files with 365 additions and 1194 deletions

View File

@@ -220,12 +220,12 @@ export async function resolveProject(options: ResolveOptions = {}): Promise<Reso
// 2. Walk up from cwd to find .fusion/
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
const kbDir = findKbDir(cwd);
const fusionDir = findKbDir(cwd);
if (kbDir) {
if (fusionDir) {
// 3. Match path against registered projects
const allProjects = await central.listProjects();
const normalizedKbDir = normalize(kbDir);
const normalizedKbDir = normalize(fusionDir);
const match = allProjects.find((p) => normalize(p.path) === normalizedKbDir);
@@ -245,12 +245,12 @@ export async function resolveProject(options: ResolveOptions = {}): Promise<Reso
// 4. Has .fusion/ but not registered
if (interactive) {
console.log(`\n Found fn project at ${kbDir} but it's not registered.`);
console.log(`\n Found fn project at ${fusionDir} but it's not registered.`);
const shouldRegister = await promptConfirm("Register this project now?", true);
if (shouldRegister) {
const rl = createInterface({ input: process.stdin, output: process.stdout });
const defaultName = kbDir.split("/").pop() || "unnamed";
const defaultName = fusionDir.split("/").pop() || "unnamed";
const name = await rl.question(` Project name [${defaultName}]: `);
rl.close();
@@ -259,7 +259,7 @@ export async function resolveProject(options: ResolveOptions = {}): Promise<Reso
try {
const newProject = await central.registerProject({
name: finalName,
path: kbDir,
path: fusionDir,
isolationMode: "in-process",
});
@@ -272,22 +272,22 @@ export async function resolveProject(options: ResolveOptions = {}): Promise<Reso
throw new ProjectResolutionError(
`Failed to register project: ${err.message}`,
"NOT_REGISTERED",
{ directory: kbDir, error: err.message }
{ directory: fusionDir, error: err.message }
);
}
} else {
throw new ProjectResolutionError(
"Project not registered. Run `fn project add <path>` to register.",
"NOT_REGISTERED",
{ directory: kbDir }
{ directory: fusionDir }
);
}
} else {
throw new ProjectResolutionError(
`Found fn project at ${kbDir} but it's not registered.\n\n` +
"Run `fn project add " + kbDir + "` to register it, or use --project <name>.",
`Found fn project at ${fusionDir} but it's not registered.\n\n` +
"Run `fn project add " + fusionDir + "` to register it, or use --project <name>.",
"NOT_REGISTERED",
{ directory: kbDir }
{ directory: fusionDir }
);
}
}