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; "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 */ /** Options for AgentStore constructor */
export interface AgentStoreOptions { export interface AgentStoreOptions {
/** Root directory for kb data (default: .fusion) */ /** Root directory for kb data (default: .fusion) */

View File

@@ -10,7 +10,7 @@ import type {
} from "./automation.js"; } from "./automation.js";
import { AUTOMATION_PRESETS, MAX_RUN_HISTORY } from "./automation.js"; import { AUTOMATION_PRESETS, MAX_RUN_HISTORY } from "./automation.js";
import type { ScheduleType } 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 { export interface AutomationStoreEvents {
"schedule:created": [schedule: ScheduledTask]; "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")) .filter((line) => !line.trim().startsWith("ALTER TABLE nodes ADD COLUMN"))
.join("\n"); .join("\n");
const CENTRAL_SCHEMA_V4_MIGRATION_SQL = ` // V4 migration is applied inline via ALTER TABLE checks (see runMigrations).
ALTER TABLE nodes ADD COLUMN versionInfo TEXT;
ALTER TABLE nodes ADD COLUMN pluginVersions TEXT;
`;
const CENTRAL_SCHEMA_V5_MIGRATION_SQL = ` const CENTRAL_SCHEMA_V5_MIGRATION_SQL = `
CREATE TABLE IF NOT EXISTS settingsSyncState ( CREATE TABLE IF NOT EXISTS settingsSyncState (

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -273,7 +273,7 @@ export async function ensureMemoryFileWithBackend(
const result = await backend.write(rootDir, getDefaultMemoryScaffold()); const result = await backend.write(rootDir, getDefaultMemoryScaffold());
refreshQmdIfNeeded(); refreshQmdIfNeeded();
return result.success; return result.success;
} catch (err) { } catch {
// Non-writable backends (readonly) don't throw during bootstrap // Non-writable backends (readonly) don't throw during bootstrap
// This is intentional - bootstrap should not fail for non-writable backends // 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 // 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 { EventEmitter } from "node:events";
import type { Database } from "./db.js"; import type { Database } from "./db.js";
import { toJsonNullable } from "./db.js";
import type { import type {
Roadmap, Roadmap,
RoadmapMilestone, RoadmapMilestone,
@@ -35,9 +34,7 @@ import type {
RoadmapFeatureSourceRef, RoadmapFeatureSourceRef,
} from "./roadmap-types.js"; } from "./roadmap-types.js";
import { import {
normalizeRoadmapMilestoneOrder,
applyRoadmapMilestoneReorder, applyRoadmapMilestoneReorder,
normalizeRoadmapFeatureOrder,
applyRoadmapFeatureReorder, applyRoadmapFeatureReorder,
moveRoadmapFeature, moveRoadmapFeature,
} from "./roadmap-ordering.js"; } from "./roadmap-ordering.js";
@@ -394,8 +391,6 @@ export class RoadmapStore extends EventEmitter<RoadmapStoreEvents> {
throw new Error(`Milestone ${id} not found`); throw new Error(`Milestone ${id} not found`);
} }
const roadmapId = milestone.roadmapId;
// SQLite FK cascade will handle features // SQLite FK cascade will handle features
this.db.prepare("DELETE FROM roadmap_milestones WHERE id = ?").run(id); this.db.prepare("DELETE FROM roadmap_milestones WHERE id = ?").run(id);
this.db.bumpLastModified(); this.db.bumpLastModified();

View File

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

View File

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