Skip to content

Commit 28b9daa

Browse files
committed
Fix create result handling
1 parent e7f1c59 commit 28b9daa

4 files changed

Lines changed: 26 additions & 10 deletions

File tree

.agents/types/tools.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ export interface ProposeStrReplaceParams {
181181
/** Array of replacements to make. */
182182
replacements: {
183183
/** The string to replace. This must be an *exact match* of the string you want to replace, including whitespace and punctuation. */
184-
old: string
185-
/** The string to replace the corresponding old string with. Can be empty to delete. */
186-
new: string
187-
/** Whether to allow multiple replacements of old string. */
184+
oldString: string
185+
/** The string to replace the corresponding oldString with. Can be empty to delete. */
186+
newString: string
187+
/** Whether to allow multiple replacements of oldString. */
188188
allowMultiple?: boolean
189189
}[]
190190
}
@@ -305,10 +305,10 @@ export interface StrReplaceParams {
305305
/** Array of replacements to make. */
306306
replacements: {
307307
/** The string to replace. This must be an *exact match* of the string you want to replace, including whitespace and punctuation. */
308-
old: string
309-
/** The string to replace the corresponding old string with. Can be empty to delete. */
310-
new: string
311-
/** Whether to allow multiple replacements of old string. */
308+
oldString: string
309+
/** The string to replace the corresponding oldString with. Can be empty to delete. */
310+
newString: string
311+
/** Whether to allow multiple replacements of oldString. */
312312
allowMultiple?: boolean
313313
}[]
314314
}

cli/src/components/tools/str-replace.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ function extractValueForKey(output: string, key: string): string | null {
4040
return null
4141
}
4242

43+
function isCreatedFileMessage(message: string | null): boolean {
44+
return message === 'Created file successfully.' || message === 'Created new file'
45+
}
46+
4347
interface EditHeaderProps {
4448
name: string
4549
filePath: string | null
@@ -97,7 +101,7 @@ export const StrReplaceComponent = defineToolComponent({
97101
? (toolBlock.input as any).path
98102
: null)
99103
const message = extractValueForKey(outputStr, 'message')
100-
const isCreate = message === 'Created new file'
104+
const isCreate = isCreatedFileMessage(message)
101105

102106
return {
103107
content: (

cli/src/utils/__tests__/implementor-helpers.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ describe('getFileChangeType', () => {
215215
expect(getFileChangeType(block)).toBe('A')
216216
})
217217

218+
test('returns A for successful file creation', () => {
219+
const block: ToolContentBlock = {
220+
type: 'tool',
221+
toolCallId: 'test-1',
222+
toolName: 'write_file',
223+
input: {},
224+
output: 'message: Created file successfully.',
225+
}
226+
expect(getFileChangeType(block)).toBe('A')
227+
})
228+
218229
test('returns M for write_file modification', () => {
219230
const block: ToolContentBlock = {
220231
type: 'tool',

cli/src/utils/implementor-helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ export function isCreateFile(toolBlock: ToolContentBlock): boolean {
325325
const message = extractValueForKey(outputStr, 'message')
326326
return (
327327
typeof message === 'string' &&
328-
(message.startsWith('Created new file') ||
328+
(message.startsWith('Created file successfully') ||
329+
message.startsWith('Created new file') ||
329330
message.startsWith('Proposed new file'))
330331
)
331332
}

0 commit comments

Comments
 (0)