mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-18 06:15:51 +00:00
Feat/integrate lint preview (#285)
* feat: 适配 zed acp 协议 * docs: 完善 acp 文档 * feat: integrate feature branches + daemon/job 命令层级化 + 跨平台后台引擎 Cherry-picked from origin/lint/preview (637c908), excluding lint-only changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: correct detectMimeFromBase64 to decode raw bytes from base64 Cherry-picked from origin/lint/preview (ee36954). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: daemon 子进程 spawn 跨平台修复 + CliLaunchSpec 集中化重构 Cherry-picked from origin/lint/preview (c5f52cd), excluding lint-only formatting changes. - 新建 src/utils/cliLaunch.ts: 集中化 CLI 子进程启动层 - 修复 --daemon-worker=kind 等号格式解析 - 修复 daemon/bg fast path 缺少 setShellIfWindows() - 修复 checkPathExists 用 existsSync 替代 execSync('dir') - 7 个 spawn 站点迁移到 CliLaunchSpec Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: merge tsconfig.base.json into tsconfig.json with full compiler options The cherry-pick from637c908dropped jsx/strict/etc settings when removing tsconfig.base.json. This commit restores them in a single tsconfig.json. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: merge tsconfig.base.json into tsconfig.json with full compiler options The cherry-pick from637c908dropped jsx/strict/etc settings when removing tsconfig.base.json. This commit restores them in a single tsconfig.json. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,11 @@ import { evictTerminalTask } from '../../utils/task/framework.js'
|
||||
import { tokenCountWithEstimation } from '../../utils/tokens.js'
|
||||
import { createAbortController } from '../abortController.js'
|
||||
import { type AgentContext, runWithAgentContext } from '../agentContext.js'
|
||||
import {
|
||||
markAutonomyRunCompleted,
|
||||
markAutonomyRunFailed,
|
||||
markAutonomyRunRunning,
|
||||
} from '../autonomyRuns.js'
|
||||
import { count } from '../array.js'
|
||||
import { logForDebugging } from '../debug.js'
|
||||
import { cloneFileStateCache } from '../fileStateCache.js'
|
||||
@@ -668,6 +673,7 @@ type WaitResult =
|
||||
| {
|
||||
type: 'new_message'
|
||||
message: string
|
||||
autonomyRunId?: string
|
||||
from: string
|
||||
color?: string
|
||||
summary?: string
|
||||
@@ -710,7 +716,7 @@ async function waitForNextPromptOrShutdown(
|
||||
task.type === 'in_process_teammate' &&
|
||||
task.pendingUserMessages.length > 0
|
||||
) {
|
||||
const message = task.pendingUserMessages[0]! // Safe: checked length > 0
|
||||
const pending = task.pendingUserMessages[0]! // Safe: checked length > 0
|
||||
// Pop the message from the queue
|
||||
setAppState(prev => {
|
||||
const prevTask = prev.tasks[taskId]
|
||||
@@ -731,9 +737,13 @@ async function waitForNextPromptOrShutdown(
|
||||
logForDebugging(
|
||||
`[inProcessRunner] ${identity.agentName} found pending user message (poll #${pollCount})`,
|
||||
)
|
||||
if (pending.autonomyRunId) {
|
||||
await markAutonomyRunRunning(pending.autonomyRunId)
|
||||
}
|
||||
return {
|
||||
type: 'new_message',
|
||||
message,
|
||||
message: pending.message,
|
||||
autonomyRunId: pending.autonomyRunId,
|
||||
from: 'user',
|
||||
}
|
||||
}
|
||||
@@ -1010,6 +1020,7 @@ export async function runInProcessTeammate(
|
||||
description,
|
||||
)
|
||||
let currentPrompt = wrappedInitialPrompt
|
||||
let currentAutonomyRunId: string | undefined
|
||||
let shouldExit = false
|
||||
|
||||
// Try to claim an available task immediately so the UI can show activity
|
||||
@@ -1306,6 +1317,13 @@ export async function runInProcessTeammate(
|
||||
}),
|
||||
setAppState,
|
||||
)
|
||||
if (currentAutonomyRunId) {
|
||||
await markAutonomyRunFailed(currentAutonomyRunId, ERROR_MESSAGE_USER_ABORT)
|
||||
currentAutonomyRunId = undefined
|
||||
}
|
||||
} else if (currentAutonomyRunId) {
|
||||
await markAutonomyRunCompleted(currentAutonomyRunId)
|
||||
currentAutonomyRunId = undefined
|
||||
}
|
||||
|
||||
// Check if already idle before updating (to skip duplicate notification)
|
||||
@@ -1378,6 +1396,7 @@ export async function runInProcessTeammate(
|
||||
createUserMessage({ content: currentPrompt }),
|
||||
setAppState,
|
||||
)
|
||||
currentAutonomyRunId = undefined
|
||||
break
|
||||
|
||||
case 'new_message':
|
||||
@@ -1389,6 +1408,7 @@ export async function runInProcessTeammate(
|
||||
// Messages from other teammates get XML wrapper for identification
|
||||
if (waitResult.from === 'user') {
|
||||
currentPrompt = waitResult.message
|
||||
currentAutonomyRunId = waitResult.autonomyRunId
|
||||
} else {
|
||||
currentPrompt = formatAsTeammateMessage(
|
||||
waitResult.from,
|
||||
@@ -1404,6 +1424,7 @@ export async function runInProcessTeammate(
|
||||
createUserMessage({ content: currentPrompt }),
|
||||
setAppState,
|
||||
)
|
||||
currentAutonomyRunId = undefined
|
||||
}
|
||||
break
|
||||
|
||||
@@ -1459,7 +1480,6 @@ export async function runInProcessTeammate(
|
||||
summary: identity.agentId,
|
||||
})
|
||||
}
|
||||
|
||||
unregisterPerfettoAgent(identity.agentId)
|
||||
return { success: true, messages: allMessages }
|
||||
} catch (error) {
|
||||
@@ -1511,6 +1531,9 @@ export async function runInProcessTeammate(
|
||||
summary: identity.agentId,
|
||||
})
|
||||
}
|
||||
if (currentAutonomyRunId) {
|
||||
await markAutonomyRunFailed(currentAutonomyRunId, errorMessage)
|
||||
}
|
||||
|
||||
// Send idle notification with failure via file-based mailbox
|
||||
await sendIdleNotification(
|
||||
|
||||
@@ -24,6 +24,7 @@ import type {
|
||||
TeammateIdentity,
|
||||
} from '../../tasks/InProcessTeammateTask/types.js'
|
||||
import { createAbortController } from '../abortController.js'
|
||||
import { markAutonomyRunFailed } from '../autonomyRuns.js'
|
||||
import { formatAgentId } from '../agentId.js'
|
||||
import { registerCleanup } from '../cleanupRegistry.js'
|
||||
import { logForDebugging } from '../debug.js'
|
||||
@@ -233,6 +234,7 @@ export function killInProcessTeammate(
|
||||
let agentId: string | null = null
|
||||
let toolUseId: string | undefined
|
||||
let description: string | undefined
|
||||
let pendingAutonomyRunIds: string[] = []
|
||||
|
||||
setAppState((prev: AppState) => {
|
||||
const task = prev.tasks[taskId]
|
||||
@@ -252,6 +254,11 @@ export function killInProcessTeammate(
|
||||
toolUseId = teammateTask.toolUseId
|
||||
description = teammateTask.description
|
||||
|
||||
// Capture pending autonomy run IDs before clearing them
|
||||
pendingAutonomyRunIds = teammateTask.pendingUserMessages
|
||||
.map(message => message.autonomyRunId)
|
||||
.filter((runId): runId is string => runId !== undefined)
|
||||
|
||||
// Abort the controller to stop execution
|
||||
teammateTask.abortController?.abort()
|
||||
|
||||
@@ -304,6 +311,12 @@ export function killInProcessTeammate(
|
||||
}
|
||||
|
||||
if (killed) {
|
||||
for (const runId of pendingAutonomyRunIds) {
|
||||
void markAutonomyRunFailed(
|
||||
runId,
|
||||
`Teammate ${agentId ?? taskId} was stopped before it could consume the queued autonomy prompt.`,
|
||||
)
|
||||
}
|
||||
void evictTaskOutput(taskId)
|
||||
// notified:true was pre-set so no XML notification fires; close the SDK
|
||||
// task_started bookend directly. The in-process runner's own
|
||||
|
||||
Reference in New Issue
Block a user