feat(departments): construct DepartmentManager in the shared kernel

This commit is contained in:
newbie 2026-11-24 20:56:21 +08:00
parent 1004511d25
commit cde027d330
3 changed files with 11 additions and 2 deletions

View File

@ -20,7 +20,7 @@
*/
import { join, resolve } from 'node:path';
import { CloudClient } from "./api.js";
import { LocalMemoryManager, LocalMemoryRemote } from "./local-memory/index.js";
import { DepartmentManager, LocalMemoryManager, LocalMemoryRemote } from "./local-memory/index.js";
import { VERSION } from "./version.js";
import { createCloudMemoryRemoteFactory } from "./cloudsync.js";
import { ClientRegistry } from "./clients.js";
@ -59,6 +59,7 @@ export class BrainKernel {
memoryRemoteFactory;
localMemory;
localMemoryRemote;
departments;
reporter;
skillAdmin;
skillRepository;
@ -99,6 +100,7 @@ export class BrainKernel {
}),
});
this.localMemoryRemote = new LocalMemoryRemote(this.localMemory);
this.departments = new DepartmentManager({ memory: this.localMemory });
// The global space is part of first boot; project space stays lazy until
// the first memory use in that project.
if (settings().localMemoryEnabled !== false && settings().autoMemorySpaces !== false)
@ -273,6 +275,7 @@ export class BrainKernel {
clients: skills ? this.clients : undefined,
mcp: this.isActive('mcp'),
localMemory: this.localMemory,
departments: this.departments,
};
}
}

View File

@ -20,7 +20,7 @@
*/
import { join, resolve } from 'node:path'
import { CloudClient } from './api.ts'
import { LocalMemoryManager, LocalMemoryRemote } from './local-memory/index.ts'
import { DepartmentManager, LocalMemoryManager, LocalMemoryRemote } from './local-memory/index.ts'
import { VERSION } from './version.ts'
import { createCloudMemoryRemoteFactory } from './cloudsync.ts'
import { ClientRegistry } from './clients.ts'
@ -72,6 +72,7 @@ export class BrainKernel {
readonly memoryRemoteFactory: ReturnType<typeof createCloudMemoryRemoteFactory>
readonly localMemory: LocalMemoryManager
readonly localMemoryRemote: LocalMemoryRemote
readonly departments: DepartmentManager
readonly reporter: Reporter
readonly skillAdmin: SkillAdmin
readonly skillRepository: AdminSkillRepository
@ -116,6 +117,7 @@ export class BrainKernel {
}),
})
this.localMemoryRemote = new LocalMemoryRemote(this.localMemory)
this.departments = new DepartmentManager({ memory: this.localMemory })
// The global space is part of first boot; project space stays lazy until
// the first memory use in that project.
if (settings().localMemoryEnabled !== false && settings().autoMemorySpaces !== false) void this.localMemory.ensureGlobal().catch((error: unknown) => { logger.warn('dsh-brain local memory initialization failed: ' + (error instanceof Error ? error.message : String(error))) })
@ -301,6 +303,7 @@ export class BrainKernel {
clients: skills ? this.clients : undefined,
mcp: this.isActive('mcp'),
localMemory: this.localMemory,
departments: this.departments,
}
}
}

View File

@ -26,6 +26,7 @@ import type { Reporter } from './reporter.ts'
import { createSettingsUiRoutes } from './settings-ui/routes.ts'
import type { CloudMemoryWebRoute } from './context-types.ts'
import type { LocalMemoryManager } from './local-memory/manager.ts'
import type { DepartmentManager } from './local-memory/departments/index.ts'
import type { SkillSync, SkillSyncStats } from './skill-sync.ts'
import type { SkillAdmin } from './skill-admin.ts'
import type { SkillGroupManager } from './skill-groups.ts'
@ -79,6 +80,8 @@ export interface RouteDeps {
mcp?: boolean
/** Local memory manager, when the memory bundle is available. */
localMemory?: LocalMemoryManager
/** Department registry (P1.5), when wired in. */
departments?: DepartmentManager
}
/** One feature flag the card reads before it renders a control. */