Skip to content

Commit cbbfe73

Browse files
committed
Fix for importing bundled agents
1 parent 52523da commit cbbfe73

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

cli/src/utils/local-agent-registry.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import type { MCPConfig } from '@codebuff/common/types/mcp'
1010
import { getProjectRoot } from '../project-files'
1111
import { AGENT_MODE_TO_ID, type AgentMode } from './constants'
1212
import { logger } from './logger'
13+
import * as bundledAgentsModule from '../agents/bundled-agents.generated'
1314

1415
import 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-
170157
const getBundledAgents = (): Record<string, AgentDefinition> => {
171-
return bundledAgentsModule?.bundledAgents ?? {}
158+
return bundledAgentsModule.bundledAgents ?? {}
172159
}
173160

174161
const getBundledAgentsAsLocalInfo = (): LocalAgentInfo[] => {
175-
return bundledAgentsModule?.getBundledAgentsAsLocalInfo?.() ?? []
162+
return bundledAgentsModule.getBundledAgentsAsLocalInfo?.() ?? []
176163
}
177164

178165
// ============================================================================

0 commit comments

Comments
 (0)