@@ -5,42 +5,44 @@ import { publisher } from '../.agents/constants'
55
66import type { AgentDefinition } from '../.agents/types/agent-definition'
77
8- const agentDefinitionContent = readFileSync (
9- join ( __dirname , 'types' , 'agent-definition.ts' ) ,
10- 'utf8' ,
11- )
12- const toolsDefinitionContent = readFileSync (
13- join ( __dirname , 'types' , 'tools.ts' ) ,
14- 'utf8' ,
15- )
8+ /**
9+ * Read an agent-related file with graceful error handling.
10+ * Returns empty string and logs a warning if the file cannot be read.
11+ */
12+ function readAgentFile ( relativePath : string ) : string {
13+ try {
14+ return readFileSync ( join ( __dirname , relativePath ) , 'utf8' )
15+ } catch ( error ) {
16+ console . warn (
17+ `Failed to read agent file: ${ relativePath } ` ,
18+ error instanceof Error ? error . message : error ,
19+ )
20+ return ''
21+ }
22+ }
1623
17- const researcherDocExampleContent = readFileSync (
18- join ( __dirname , 'researcher' , 'researcher-docs.ts' ) ,
19- 'utf8' ,
20- )
21- const researcherGrok4FastExampleContent = readFileSync (
22- join ( __dirname , 'researcher' , 'researcher-grok-4-fast.ts' ) ,
23- 'utf8' ,
24- )
25- const generatePlanExampleContent = readFileSync (
26- join ( __dirname , 'planners' , 'planner-pro-with-files-input.ts' ) ,
27- 'utf8' ,
28- )
29- const reviewerExampleContent = readFileSync (
30- join ( __dirname , 'reviewer' , 'code-reviewer.ts' ) ,
31- 'utf8' ,
32- )
33- const reviewerMultiPromptExampleContent = readFileSync (
34- join ( __dirname , 'reviewer' , 'multi-prompt' , 'code-reviewer-multi-prompt.ts' ) ,
35- 'utf8' ,
24+ // Type definition files embedded in system prompt (critical - warn if missing)
25+ const agentDefinitionContent = readAgentFile ( 'types/agent-definition.ts' )
26+ const toolsDefinitionContent = readAgentFile ( 'types/tools.ts' )
27+
28+ if ( ! agentDefinitionContent || ! toolsDefinitionContent ) {
29+ console . error (
30+ 'CRITICAL: Agent builder type definitions failed to load. Agent may not function correctly.' ,
31+ )
32+ }
33+
34+ // Example agent files for inspiration
35+ const EXAMPLE_AGENT_PATHS = [
36+ 'researcher/researcher-docs.ts' ,
37+ 'researcher/researcher-grok-4-fast.ts' ,
38+ 'planners/planner-pro-with-files-input.ts' ,
39+ 'reviewer/code-reviewer.ts' ,
40+ 'reviewer/multi-prompt/code-reviewer-multi-prompt.ts' ,
41+ ] as const
42+
43+ const examplesAgentsContent = EXAMPLE_AGENT_PATHS . map ( readAgentFile ) . filter (
44+ ( content ) => content . length > 0 ,
3645)
37- const examplesAgentsContent = [
38- researcherDocExampleContent ,
39- researcherGrok4FastExampleContent ,
40- generatePlanExampleContent ,
41- reviewerExampleContent ,
42- reviewerMultiPromptExampleContent ,
43- ]
4446
4547const definition : AgentDefinition = {
4648 id : 'agent-builder' ,
0 commit comments