mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-16 13:25:51 +00:00
* 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>
79 lines
2.2 KiB
TypeScript
79 lines
2.2 KiB
TypeScript
import { feature } from 'bun:bundle'
|
|
import { isBgSession, updateSessionActivity } from './concurrentSessions.js'
|
|
import { logForDebugging } from './debug.js'
|
|
|
|
/**
|
|
* Minimum interval between task summary generations (ms).
|
|
* Prevents excessive updates during rapid tool-call loops.
|
|
*/
|
|
const SUMMARY_INTERVAL_MS = 30_000
|
|
|
|
let lastSummaryTime = 0
|
|
|
|
/**
|
|
* Whether a task summary should be generated this turn.
|
|
* Only generates in bg sessions, and rate-limits to avoid churn.
|
|
*/
|
|
export function shouldGenerateTaskSummary(): boolean {
|
|
if (!feature('BG_SESSIONS')) return false
|
|
if (!isBgSession()) return false
|
|
|
|
const now = Date.now()
|
|
return now - lastSummaryTime >= SUMMARY_INTERVAL_MS
|
|
}
|
|
|
|
/**
|
|
* Generate a task summary from the current turn's messages and push it
|
|
* to the session registry so `claude ps` can display live status.
|
|
*
|
|
* Fire-and-forget from query.ts — errors are logged, never thrown.
|
|
*/
|
|
export function maybeGenerateTaskSummary(
|
|
options: Record<string, unknown>,
|
|
): void {
|
|
lastSummaryTime = Date.now()
|
|
|
|
try {
|
|
const messages = options.forkContextMessages as
|
|
| Array<{
|
|
type: string
|
|
message?: { content?: unknown }
|
|
}>
|
|
| undefined
|
|
|
|
if (!messages || messages.length === 0) return
|
|
|
|
// Extract a short status from the most recent assistant message
|
|
const lastAssistant = [...messages]
|
|
.reverse()
|
|
.find(m => m.type === 'assistant')
|
|
|
|
let status: 'busy' | 'idle' = 'busy'
|
|
let waitingFor: string | undefined
|
|
|
|
if (lastAssistant?.message?.content) {
|
|
const content = lastAssistant.message.content
|
|
// Check if last block is tool_use
|
|
if (Array.isArray(content)) {
|
|
const lastBlock = content[content.length - 1] as
|
|
| Record<string, unknown>
|
|
| undefined
|
|
if (lastBlock?.type === 'tool_use') {
|
|
status = 'busy'
|
|
waitingFor = `tool: ${lastBlock.name || 'unknown'}`
|
|
}
|
|
}
|
|
}
|
|
|
|
// Fire-and-forget update to session registry
|
|
void updateSessionActivity({
|
|
status,
|
|
waitingFor,
|
|
}).catch(err => {
|
|
logForDebugging(`[taskSummary] updateSessionActivity failed: ${err}`)
|
|
})
|
|
} catch (err) {
|
|
logForDebugging(`[taskSummary] error: ${err}`)
|
|
}
|
|
}
|