refactor(core): remove unused imports, helpers, and dead migration constant

Drops orphaned imports and the never-referenced V4 migration SQL constant
(V4 was inlined into runMigrations). Also drops the unused TypedEventEmitter
helper type and unused destructured values from stores.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-23 17:31:18 -07:00
parent 90d8dfaef2
commit b818aa2196
12 changed files with 7 additions and 31 deletions

View File

@@ -62,15 +62,6 @@ export interface AgentStoreEvents {
"rating:added": (rating: AgentRating) => void;
}
type TypedEventEmitter<Events extends Record<string, unknown[]>> = {
[K in keyof Events]: {
emit(event: K, ...args: Events[K]): boolean;
on(event: K, listener: (...args: Events[K]) => void): TypedEventEmitter<Events>;
once(event: K, listener: (...args: Events[K]) => void): TypedEventEmitter<Events>;
off(event: K, listener: (...args: Events[K]) => void): TypedEventEmitter<Events>;
};
}[keyof Events] & EventEmitter;
/** Options for AgentStore constructor */
export interface AgentStoreOptions {
/** Root directory for kb data (default: .fusion) */

View File

@@ -10,7 +10,7 @@ import type {
} from "./automation.js";
import { AUTOMATION_PRESETS, MAX_RUN_HISTORY } from "./automation.js";
import type { ScheduleType } from "./automation.js";
import { Database, toJsonNullable, fromJson } from "./db.js";
import { Database, fromJson } from "./db.js";
export interface AutomationStoreEvents {
"schedule:created": [schedule: ScheduledTask];

View File

@@ -184,10 +184,7 @@ 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;
`;
// V4 migration is applied inline via ALTER TABLE checks (see runMigrations).
const CENTRAL_SCHEMA_V5_MIGRATION_SQL = `
CREATE TABLE IF NOT EXISTS settingsSyncState (

View File

@@ -27,7 +27,6 @@ import type {
SetupCompletionResult,
DetectedProject,
RegisteredProject,
GlobalSettings,
} from "./types.js";
import type { CentralCore } from "./central-core.js";
import { MigrationOrchestrator } from "./migration-orchestrator.js";

View File

@@ -28,8 +28,7 @@
import { EventEmitter } from "node:events";
import type { Database } from "./db.js";
import { toJson, toJsonNullable, fromJson } from "./db.js";
import { randomUUID } from "node:crypto";
import { toJsonNullable, fromJson } from "./db.js";
import type {
Insight,
InsightCreateInput,

View File

@@ -29,7 +29,6 @@ import type {
MigrationOptions,
MigrationResult,
RegisteredProject,
IsolationMode,
} from "./types.js";
import type { CentralCore } from "./central-core.js";

View File

@@ -9,7 +9,7 @@
* - Error isolation (plugin crashes don't crash the loader)
*/
import { join, isAbsolute, resolve } from "node:path";
import { isAbsolute, resolve } from "node:path";
import { EventEmitter } from "node:events";
import type { TaskStore } from "./store.js";
import { PluginStore } from "./plugin-store.js";
@@ -21,7 +21,6 @@ import type {
PluginRouteDefinition,
PluginUiSlotDefinition,
PluginRuntimeRegistration,
PluginState,
PluginInstallation,
} from "./plugin-types.js";
import { validatePluginManifest } from "./plugin-types.js";

View File

@@ -420,7 +420,7 @@ export class PluginStore extends EventEmitter<PluginStoreEvents> {
id: string,
updates: PluginUpdateInput,
): Promise<PluginInstallation> {
const plugin = await this.getPlugin(id);
await this.getPlugin(id);
const now = new Date().toISOString();
const setClauses: string[] = ["updatedAt = ?"];

View File

@@ -273,7 +273,7 @@ export async function ensureMemoryFileWithBackend(
const result = await backend.write(rootDir, getDefaultMemoryScaffold());
refreshQmdIfNeeded();
return result.success;
} catch (err) {
} catch {
// Non-writable backends (readonly) don't throw during bootstrap
// This is intentional - bootstrap should not fail for non-writable backends
// The error is caught and we return false to indicate no action was taken

View File

@@ -13,7 +13,6 @@
import { EventEmitter } from "node:events";
import type { Database } from "./db.js";
import { toJsonNullable } from "./db.js";
import type {
Roadmap,
RoadmapMilestone,
@@ -35,9 +34,7 @@ import type {
RoadmapFeatureSourceRef,
} from "./roadmap-types.js";
import {
normalizeRoadmapMilestoneOrder,
applyRoadmapMilestoneReorder,
normalizeRoadmapFeatureOrder,
applyRoadmapFeatureReorder,
moveRoadmapFeature,
} from "./roadmap-ordering.js";
@@ -394,8 +391,6 @@ export class RoadmapStore extends EventEmitter<RoadmapStoreEvents> {
throw new Error(`Milestone ${id} not found`);
}
const roadmapId = milestone.roadmapId;
// SQLite FK cascade will handle features
this.db.prepare("DELETE FROM roadmap_milestones WHERE id = ?").run(id);
this.db.bumpLastModified();

View File

@@ -10,7 +10,7 @@
import { EventEmitter } from "node:events";
import { randomUUID } from "node:crypto";
import { CronExpressionParser } from "cron-parser";
import { Database, toJson, fromJson } from "./db.js";
import { Database, fromJson } from "./db.js";
import {
isCronTrigger,
type Routine,

View File

@@ -7,11 +7,8 @@
*/
import { writeFile, readFile, rename } from "node:fs/promises";
import { existsSync } from "node:fs";
import { join } from "node:path";
import type { Settings, GlobalSettings, ProjectSettings } from "./types.js";
import { TaskStore } from "./store.js";
import { GlobalSettingsStore } from "./global-settings.js";
/**
* Structure for exported settings JSON.