mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 14:25:51 +00:00
feat: 完成大部分操作
This commit is contained in:
@@ -486,8 +486,87 @@ function parseHttpHookOutput(body: string): {
|
||||
}
|
||||
}
|
||||
|
||||
/** Typed representation of sync hook JSON output, matching the syncHookResponseSchema Zod schema. */
|
||||
interface TypedSyncHookOutput {
|
||||
continue?: boolean
|
||||
suppressOutput?: boolean
|
||||
stopReason?: string
|
||||
decision?: 'approve' | 'block'
|
||||
reason?: string
|
||||
systemMessage?: string
|
||||
hookSpecificOutput?:
|
||||
| {
|
||||
hookEventName: 'PreToolUse'
|
||||
permissionDecision?: 'ask' | 'deny' | 'allow' | 'passthrough'
|
||||
permissionDecisionReason?: string
|
||||
updatedInput?: Record<string, unknown>
|
||||
additionalContext?: string
|
||||
}
|
||||
| {
|
||||
hookEventName: 'UserPromptSubmit'
|
||||
additionalContext?: string
|
||||
}
|
||||
| {
|
||||
hookEventName: 'SessionStart'
|
||||
additionalContext?: string
|
||||
initialUserMessage?: string
|
||||
watchPaths?: string[]
|
||||
}
|
||||
| {
|
||||
hookEventName: 'Setup'
|
||||
additionalContext?: string
|
||||
}
|
||||
| {
|
||||
hookEventName: 'SubagentStart'
|
||||
additionalContext?: string
|
||||
}
|
||||
| {
|
||||
hookEventName: 'PostToolUse'
|
||||
additionalContext?: string
|
||||
updatedMCPToolOutput?: unknown
|
||||
}
|
||||
| {
|
||||
hookEventName: 'PostToolUseFailure'
|
||||
additionalContext?: string
|
||||
}
|
||||
| {
|
||||
hookEventName: 'PermissionDenied'
|
||||
retry?: boolean
|
||||
}
|
||||
| {
|
||||
hookEventName: 'Notification'
|
||||
additionalContext?: string
|
||||
}
|
||||
| {
|
||||
hookEventName: 'PermissionRequest'
|
||||
decision?: PermissionRequestResult
|
||||
}
|
||||
| {
|
||||
hookEventName: 'Elicitation'
|
||||
action?: 'accept' | 'decline' | 'cancel'
|
||||
content?: Record<string, unknown>
|
||||
}
|
||||
| {
|
||||
hookEventName: 'ElicitationResult'
|
||||
action?: 'accept' | 'decline' | 'cancel'
|
||||
content?: Record<string, unknown>
|
||||
}
|
||||
| {
|
||||
hookEventName: 'CwdChanged'
|
||||
watchPaths?: string[]
|
||||
}
|
||||
| {
|
||||
hookEventName: 'FileChanged'
|
||||
watchPaths?: string[]
|
||||
}
|
||||
| {
|
||||
hookEventName: 'WorktreeCreate'
|
||||
worktreePath: string
|
||||
}
|
||||
}
|
||||
|
||||
function processHookJSONOutput({
|
||||
json,
|
||||
json: rawJson,
|
||||
command,
|
||||
hookName,
|
||||
toolUseID,
|
||||
@@ -511,6 +590,9 @@ function processHookJSONOutput({
|
||||
}): Partial<HookResult> {
|
||||
const result: Partial<HookResult> = {}
|
||||
|
||||
// Cast to typed interface for type-safe property access
|
||||
const json = rawJson as TypedSyncHookOutput
|
||||
|
||||
// At this point we know it's a sync response
|
||||
const syncJson = json
|
||||
|
||||
|
||||
@@ -1033,7 +1033,7 @@ class Project {
|
||||
'sourceToolAssistantUUID' in message &&
|
||||
message.sourceToolAssistantUUID
|
||||
) {
|
||||
effectiveParentUuid = message.sourceToolAssistantUUID
|
||||
effectiveParentUuid = message.sourceToolAssistantUUID as UUID
|
||||
}
|
||||
|
||||
const transcriptMessage: TranscriptMessage = {
|
||||
@@ -2120,7 +2120,7 @@ function recoverOrphanedParallelToolResults(
|
||||
chain: TranscriptMessage[],
|
||||
seen: Set<UUID>,
|
||||
): TranscriptMessage[] {
|
||||
type ChainAssistant = Extract<TranscriptMessage, { type: 'assistant' }>
|
||||
type ChainAssistant = TranscriptMessage & { type: 'assistant' }
|
||||
const chainAssistants = chain.filter(
|
||||
(m): m is ChainAssistant => m.type === 'assistant',
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user