mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-23 08:45:50 +00:00
Merge branch 'claude-code-best:main' into main
This commit is contained in:
@@ -528,19 +528,20 @@ function highlightLine(
|
|||||||
// hljs throws on unknown language despite ignoreIllegals
|
// hljs throws on unknown language despite ignoreIllegals
|
||||||
return [[defaultStyle(theme), code]]
|
return [[defaultStyle(theme), code]]
|
||||||
}
|
}
|
||||||
if (!hasRootNode(result.emitter)) {
|
const emitter = result._emitter || {};
|
||||||
|
if (!hasRootNode(emitter)) {
|
||||||
if (!loggedEmitterShapeError) {
|
if (!loggedEmitterShapeError) {
|
||||||
loggedEmitterShapeError = true
|
loggedEmitterShapeError = true
|
||||||
logError(
|
logError(
|
||||||
new Error(
|
new Error(
|
||||||
`color-diff: hljs emitter shape mismatch (keys: ${Object.keys(result.emitter).join(',')}). Syntax highlighting disabled.`,
|
`color-diff: hljs emitter shape mismatch (keys: ${Object.keys(emitter).join(',')}). Syntax highlighting disabled.`,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return [[defaultStyle(theme), code]]
|
return [[defaultStyle(theme), code]]
|
||||||
}
|
}
|
||||||
const blocks: Block[] = []
|
const blocks: Block[] = []
|
||||||
flattenHljs(result.emitter.rootNode, theme, undefined, blocks)
|
flattenHljs(emitter.rootNode, theme, undefined, blocks)
|
||||||
return blocks
|
return blocks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,18 @@ export class FileStateCache {
|
|||||||
this.cache = new LRUCache<string, FileState>({
|
this.cache = new LRUCache<string, FileState>({
|
||||||
max: maxEntries,
|
max: maxEntries,
|
||||||
maxSize: maxSizeBytes,
|
maxSize: maxSizeBytes,
|
||||||
sizeCalculation: value => Math.max(1, Buffer.byteLength(value.content)),
|
sizeCalculation: value => {
|
||||||
|
const c = value.content
|
||||||
|
const s =
|
||||||
|
typeof c === 'string'
|
||||||
|
? c
|
||||||
|
: c === null || c === undefined
|
||||||
|
? ''
|
||||||
|
: typeof c === 'object'
|
||||||
|
? JSON.stringify(c)
|
||||||
|
: String(c)
|
||||||
|
return Math.max(1, Buffer.byteLength(s, 'utf8'))
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,14 @@ export type PermissionPromptTool = Tool<
|
|||||||
// during permission prompts or limited tool operations
|
// during permission prompts or limited tool operations
|
||||||
const ASK_READ_FILE_STATE_CACHE_SIZE = 10
|
const ASK_READ_FILE_STATE_CACHE_SIZE = 10
|
||||||
|
|
||||||
|
/** Transcript JSON may deserialize Write tool `content` as a nested object — LRU needs strings. */
|
||||||
|
function coerceToolContentToString(value: unknown): string {
|
||||||
|
if (typeof value === 'string') return value
|
||||||
|
if (value === null || value === undefined) return ''
|
||||||
|
if (typeof value === 'object') return JSON.stringify(value)
|
||||||
|
return String(value)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the result should be considered successful based on the last message.
|
* Checks if the result should be considered successful based on the last message.
|
||||||
* Returns true if:
|
* Returns true if:
|
||||||
@@ -402,14 +410,18 @@ export function extractReadFilesFromMessages(
|
|||||||
) {
|
) {
|
||||||
// Extract file_path and content from the Write tool use input
|
// Extract file_path and content from the Write tool use input
|
||||||
const input = content.input as
|
const input = content.input as
|
||||||
| { file_path?: string; content?: string }
|
| { file_path?: string; content?: unknown }
|
||||||
| undefined
|
| undefined
|
||||||
if (input?.file_path && input?.content) {
|
if (
|
||||||
|
input?.file_path &&
|
||||||
|
input.content !== undefined &&
|
||||||
|
input.content !== null
|
||||||
|
) {
|
||||||
// Normalize to absolute path for consistent cache lookups
|
// Normalize to absolute path for consistent cache lookups
|
||||||
const absolutePath = expandPath(input.file_path, cwd)
|
const absolutePath = expandPath(input.file_path, cwd)
|
||||||
fileWriteToolUseIds.set(content.id, {
|
fileWriteToolUseIds.set(content.id, {
|
||||||
filePath: absolutePath,
|
filePath: absolutePath,
|
||||||
content: input.content,
|
content: coerceToolContentToString(input.content),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
|
|||||||
Reference in New Issue
Block a user