feat: 完成大部分操作

This commit is contained in:
claude-code-best
2026-03-31 21:40:37 +08:00
parent 3d4cb096d1
commit c4d92178b7
22 changed files with 561 additions and 98 deletions

View File

@@ -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

View File

@@ -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',
)