Skip to content

Commit a1633ac

Browse files
committed
Remove loadFileContents
1 parent fbe2f36 commit a1633ac

File tree

2 files changed

+5
-51
lines changed

2 files changed

+5
-51
lines changed

npm-app/src/agents/agent-utils.ts

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as fs from 'fs'
22
import * as path from 'path'
3-
import { PromptField } from '@codebuff/common/types/dynamic-agent-template'
43
import { getProjectRoot } from '../project-files'
54

65
const agentTemplatesSubdir = ['.agents'] as const
@@ -35,43 +34,6 @@ export function getAllTsFiles(dir: string): string[] {
3534
return files
3635
}
3736

38-
/**
39-
* Load file contents for prompt fields
40-
*/
41-
export function loadFileContents(promptField: PromptField | undefined): string {
42-
if (promptField === undefined) {
43-
return ''
44-
}
45-
46-
if (typeof promptField === 'string') {
47-
return promptField
48-
}
49-
50-
const originalPath = promptField.path
51-
const projectRoot = getProjectRoot()
52-
53-
// Try multiple path variations for better compatibility
54-
const pathVariations = [
55-
path.join(projectRoot, originalPath),
56-
path.join(projectRoot, ...agentTemplatesSubdir, originalPath),
57-
path.join(
58-
projectRoot,
59-
...agentTemplatesSubdir,
60-
path.basename(originalPath)
61-
),
62-
]
63-
64-
for (const filePath of pathVariations) {
65-
try {
66-
return fs.readFileSync(filePath, 'utf8')
67-
} catch (error) {
68-
// Ignore errors and try the next path variation
69-
}
70-
}
71-
72-
return ''
73-
}
74-
7537
/**
7638
* Get the agents directory path
7739
*/

npm-app/src/agents/load-agents.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ import {
22
DynamicAgentConfigParsed,
33
DynamicAgentConfigSchema,
44
DynamicAgentTemplate,
5-
PromptField,
65
} from '@codebuff/common/types/dynamic-agent-template'
7-
import { filterCustomAgentFiles } from '@codebuff/common/util/agent-file-utils'
86
import * as fs from 'fs'
97
import * as path from 'path'
108
import { cyan, green } from 'picocolors'
119
import { CodebuffConfig } from '@codebuff/common/json-config/constants'
12-
import {
13-
getAllTsFiles,
14-
loadFileContents,
15-
getAgentsDirectory,
16-
} from './agent-utils'
10+
import { getAllTsFiles, getAgentsDirectory } from './agent-utils'
1711

1812
export let loadedAgents: Record<string, DynamicAgentTemplate> = {}
1913

@@ -47,7 +41,7 @@ export async function loadLocalAgents({
4741
}
4842
continue
4943
}
50-
44+
5145
try {
5246
agentConfig = agentModule.default
5347
} catch (error: any) {
@@ -73,11 +67,9 @@ export async function loadLocalAgents({
7367

7468
loadedAgents[fileName] = {
7569
...typedAgentConfig,
76-
systemPrompt: loadFileContents(typedAgentConfig.systemPrompt),
77-
instructionsPrompt: loadFileContents(
78-
typedAgentConfig.instructionsPrompt
79-
),
80-
stepPrompt: loadFileContents(typedAgentConfig.stepPrompt),
70+
systemPrompt: typedAgentConfig.systemPrompt || '',
71+
instructionsPrompt: typedAgentConfig.instructionsPrompt || '',
72+
stepPrompt: typedAgentConfig.stepPrompt || '',
8173
handleSteps: handleStepsString,
8274
}
8375
}

0 commit comments

Comments
 (0)