@@ -10,6 +10,7 @@ import type { MCPConfig } from '@codebuff/common/types/mcp'
1010import { getProjectRoot } from '../project-files'
1111import { AGENT_MODE_TO_ID , type AgentMode } from './constants'
1212import { logger } from './logger'
13+ import * as bundledAgentsModule from '../agents/bundled-agents.generated'
1314
1415import type { AgentDefinition } from '@codebuff/common/templates/initial-agents-dir/types/agent-definition'
1516
@@ -153,26 +154,12 @@ const getUserAgentDefinitions = (): AgentDefinition[] => {
153154// Bundled agents loading (generated at build time by prebuild-agents.ts)
154155// ============================================================================
155156
156- interface BundledAgentsModule {
157- bundledAgents : Record < string , AgentDefinition >
158- getBundledAgentsAsLocalInfo : ( ) => LocalAgentInfo [ ]
159- }
160-
161- // NOTE: Inline require() with try/catch is used because this file is generated at
162- // build time by prebuild-agents.ts and may not exist during development
163- let bundledAgentsModule : BundledAgentsModule | null = null
164- try {
165- bundledAgentsModule = require ( '../agents/bundled-agents.generated' )
166- } catch {
167- // File not generated yet - running in development without prebuild
168- }
169-
170157const getBundledAgents = ( ) : Record < string , AgentDefinition > => {
171- return bundledAgentsModule ? .bundledAgents ?? { }
158+ return bundledAgentsModule . bundledAgents ?? { }
172159}
173160
174161const getBundledAgentsAsLocalInfo = ( ) : LocalAgentInfo [ ] => {
175- return bundledAgentsModule ? .getBundledAgentsAsLocalInfo ?.( ) ?? [ ]
162+ return bundledAgentsModule . getBundledAgentsAsLocalInfo ?.( ) ?? [ ]
176163}
177164
178165// ============================================================================
0 commit comments