Merge pull request #1018 from Raphaelowo/fix(adapters)-shorten-Windows-paths-in-tool-summaries

优化Win工具显示路径
This commit is contained in:
程序员阿江-Relakkes 2026-07-28 00:49:41 +08:00 committed by GitHub
commit e3f5e6eb1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -118,8 +118,14 @@ describe('formatToolUse', () => {
expect(result).toBe('🔧 Read …/project/src/index.ts')
})
it('shortens Windows paths in file tool summaries', () => {
const result = formatToolUse('Read', { file_path: 'C:\\Users\\test\\project\\src\\index.ts' })
expect(result).toBe('🔧 Read …/project/src/index.ts')
})
})
describe('formatPermissionRequest', () => {
it('includes tool name, input preview, and request ID', () => {
const result = formatPermissionRequest('Bash', { command: 'rm -rf /' }, 'abcde')

View File

@ -223,7 +223,7 @@ function formatToolSummary(tool: string, inp: Record<string, unknown>): string |
}
function shortPath(fp: string): string {
const parts = fp.split('/')
const parts = fp.replaceAll('\\', '/').split('/')
return parts.length > 3 ? '…/' + parts.slice(-3).join('/') : fp
}