refactor: low-regret cleanup across core, engine, dashboard

- core: extract ai-engine-loader.ts to share @fusion/engine dynamic-import
  boilerplate between ai-summarize and memory-compaction (incl. AgentMessage
  type); collapse getInbox/getOutbox, listInsights/countInsights,
  listRuns/countRuns, and three hasProjectDb* variants behind shared helpers.
- core: drop unused pluginLoaderLog export; tighten two `any` casts
  (db.walCheckpoint row, plugin-loader error.code).
- engine: extract resolveRoleFallback helper from buildSessionSkillContext/Sync;
  remove 22 stale `eslint-disable no-explicit-any` directives across
  project-engine, self-healing, triage, worktree-pool.
- dashboard: apply ESLint autofix (let→const, empty `interface extends`→type).

All three packages: typecheck clean, full test suites pass (14,414 tests),
builds clean. Net lint: -31 warnings. No public behavior changes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-19 13:33:19 -07:00
parent 2dde0b174a
commit fc30dc48fd
18 changed files with 174 additions and 266 deletions

View File

@@ -194,31 +194,7 @@ export class MessageStore extends EventEmitter<MessageStoreEvents> {
ownerType: ParticipantType,
filter?: MessageFilter,
): Message[] {
const whereClauses: string[] = ["toId = ?", "toType = ?"];
const params: (string | number)[] = [ownerId, ownerType];
if (filter?.type) {
whereClauses.push("type = ?");
params.push(filter.type);
}
if (filter?.read !== undefined) {
whereClauses.push("read = ?");
params.push(filter.read ? 1 : 0);
}
const whereSql = whereClauses.join(" AND ");
const limit = filter?.limit ?? 100;
const offset = filter?.offset ?? 0;
const rows = this.db.prepare(`
SELECT * FROM messages
WHERE ${whereSql}
ORDER BY createdAt DESC, rowid DESC
LIMIT ? OFFSET ?
`).all(...params, limit, offset);
return (rows as any[]).map((row) => this.rowToMessage(row));
return this.queryMessagesByParticipant("to", ownerId, ownerType, filter);
}
/**
@@ -233,7 +209,18 @@ export class MessageStore extends EventEmitter<MessageStoreEvents> {
ownerType: ParticipantType,
filter?: MessageFilter,
): Message[] {
const whereClauses: string[] = ["fromId = ?", "fromType = ?"];
return this.queryMessagesByParticipant("from", ownerId, ownerType, filter);
}
private queryMessagesByParticipant(
direction: "to" | "from",
ownerId: string,
ownerType: ParticipantType,
filter?: MessageFilter,
): Message[] {
const idCol = direction === "to" ? "toId" : "fromId";
const typeCol = direction === "to" ? "toType" : "fromType";
const whereClauses: string[] = [`${idCol} = ?`, `${typeCol} = ?`];
const params: (string | number)[] = [ownerId, ownerType];
if (filter?.type) {