Codemod db pass-through calls to domain modules: tasks + agents (C1 part 1/3)

Rewrite ~525 call sites from `db.<method>()` to `db.<module>.<method>()`
for tasks and agents domains (including `getAgent`/`findAgent`/`getTask`
which live on the `entityCrud` field). Delete the corresponding
pass-through methods on AppDatabaseBase. Structural types that narrowed
`db` to a bag of flat methods (CapabilityMatchDb, EscalationDeps,
SweepStaleReviewsDeps) are reshaped to match the new namespace. Internal
callback references inside database.ts/database-base.ts now invoke the
owning module directly (e.g. `this.agents.saveAgent`) rather than the
deleted pass-through.

The codemod lives at scripts/codemod/remove-appdatabase-passthrough.mjs
and filters by owning module + optional explicit method list. It is
idempotent and does not re-rewrite already-namespaced calls.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-20 13:17:01 -04:00
1 parent 411294afa6
commit 5e9b7acbc6
95 files changed
+1123 -793

No files matched your search

@@ -30,7 +30,7 @@ export interface SharedHandle {
set db(value: AppDatabase);
get companyId(): string;
get workspaceId(): string;
createAgent(overrides?: Partial<Parameters<AppDatabase["saveAgent"]>[0]>): string;
createAgent(overrides?: Partial<Parameters<AppDatabase["agents"]["saveAgent"]>[0]>): string;
buildCtx(overrides?: Record<string, unknown>): Parameters<typeof buildSystemPrompt>[0];
tempDirs: string[];
}
@@ -80,8 +80,8 @@ export function installSharedSetup(): SharedHandle {
return state.db;
}
function createAgent(overrides: Partial<Parameters<AppDatabase["saveAgent"]>[0]> = {}): string {
return currentDb().saveAgent({
function createAgent(overrides: Partial<Parameters<AppDatabase["agents"]["saveAgent"]>[0]> = {}): string {
return currentDb().agents.saveAgent({
companyId: state.companyId,
name: "TestAgent",
role: "CEO",
@@ -98,7 +98,7 @@ export function installSharedSetup(): SharedHandle {
}
function buildCtx(overrides: Record<string, unknown> = {}): Parameters<typeof buildSystemPrompt>[0] {
const agent = currentDb().getAgent(overrides.agentId as string ?? createAgent());
const agent = currentDb().entityCrud.getAgent(overrides.agentId as string ?? createAgent());
return {
agent,
apiUrl: "http://127.0.0.1:3000",