feat(FN-1246): add app version tracking and sync infrastructure

- Add getAppVersion() utility that walks up directories to find package.json
- Add parseSemver() for semver string parsing with major/minor/patch components
- Add CentralCore version sync methods (getAppVersion, syncVersion, getLastSyncTime, getSyncStatus)
- Add CentralCore events for version sync lifecycle (version-sync-started, version-sync-completed, version-sync-failed)
- Add schema v4 migration with appVersion and lastSyncTime columns to projects table
- Export new types (CentralSyncStatus, SyncResult) and utilities via @fusion/core
- Update memory.md documentation with new types
- Fix TypeScript error in app-version.ts (return pkg.version directly instead of cached variable)
This commit is contained in:
gsxdsm
2026-04-09 15:14:19 -07:00
parent 6c69820141
commit 35a2d02529
9 changed files with 920 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ export { toJson, toJsonNullable, fromJson };
// ── Schema Definition ───────────────────────────────────────────────────
const CENTRAL_SCHEMA_VERSION = 3;
const CENTRAL_SCHEMA_VERSION = 4;
const CENTRAL_SCHEMA_SQL = `
-- Projects table (project registry)
@@ -98,6 +98,8 @@ CREATE TABLE IF NOT EXISTS nodes (
capabilities TEXT,
systemMetrics TEXT,
knownPeers TEXT,
versionInfo TEXT,
pluginVersions TEXT,
maxConcurrent INTEGER NOT NULL DEFAULT 2,
createdAt TEXT NOT NULL,
updatedAt TEXT NOT NULL
@@ -167,6 +169,11 @@ const CENTRAL_SCHEMA_V3_CREATE_PEERS_SQL = CENTRAL_SCHEMA_V3_MIGRATION_SQL
.filter((line) => !line.trim().startsWith("ALTER TABLE nodes ADD COLUMN"))
.join("\n");
const CENTRAL_SCHEMA_V4_MIGRATION_SQL = `
ALTER TABLE nodes ADD COLUMN versionInfo TEXT;
ALTER TABLE nodes ADD COLUMN pluginVersions TEXT;
`;
// ── Central Database Class ────────────────────────────────────────────────
export class CentralDatabase {
@@ -222,6 +229,16 @@ export class CentralDatabase {
migrated = true;
}
if (currentVersion < 4) {
if (!this.hasColumn("nodes", "versionInfo")) {
this.db.exec("ALTER TABLE nodes ADD COLUMN versionInfo TEXT");
}
if (!this.hasColumn("nodes", "pluginVersions")) {
this.db.exec("ALTER TABLE nodes ADD COLUMN pluginVersions TEXT");
}
migrated = true;
}
if (migrated) {
this.db
.prepare("INSERT INTO __meta (key, value) VALUES ('schemaVersion', ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value")