Skip to content

Commit 00e8860

Browse files
committed
automatic parsing of knowledge files
1 parent ce0b552 commit 00e8860

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

sdk/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ All notable changes to the @codebuff/sdk package will be documented in this file
88

99
- `closeConnection` method in `CodebuffClient`
1010

11+
### Changed
12+
13+
- Automatic parsing of `knowledgeFiles` if not provided
14+
1115
## [0.1.8] - 2025-08-13
1216

1317
### Added

sdk/src/run-state.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,26 @@ export function initialSessionState(
2222
maxAgentSteps?: number
2323
},
2424
) {
25-
const { knowledgeFiles = {}, agentDefinitions = [] } = options
25+
const { projectFiles = {}, agentDefinitions = [] } = options
26+
let { knowledgeFiles } = options
27+
28+
if (knowledgeFiles === undefined) {
29+
knowledgeFiles = {}
30+
for (const [filePath, fileContents] of Object.entries(projectFiles)) {
31+
if (filePath in projectFiles) {
32+
continue
33+
}
34+
const lowercasePathName = filePath.toLowerCase()
35+
if (
36+
!lowercasePathName.endsWith('knowledge.md') &&
37+
!lowercasePathName.endsWith('claude.md')
38+
) {
39+
continue
40+
}
41+
42+
knowledgeFiles[filePath] = fileContents
43+
}
44+
}
2645

2746
// Process agentDefinitions array and convert handleSteps functions to strings
2847
const processedAgentTemplates: Record<string, any> = {}

0 commit comments

Comments
 (0)