Commit Graph

713 Commits

Author SHA1 Message Date
claude-code-best
01f26cf42b fix: ACP loadSession 历史记录恢复失败 — 用 resolveSessionFilePath 替代 getProjectDir 定位 session 文件
- params.cwd 可能与 session 文件实际存储的项目目录不一致(子目录、
  hash 算法差异等),导致 getProjectDir 推算出的路径找不到文件
- 改用 resolveSessionFilePath(sessionId, cwd) 按 sessionId 跨项目
  搜索,先精确匹配再 fallback 全项目扫描
- 切换回已缓存的 session 时也回放历史消息给客户端
- createSession 内部 switchSession 保留 sessionProjectDir 不被覆盖为 null
2026-06-04 21:57:46 +08:00
claude-code-best
d8892f19d5 chore: 2.6.8 v2.6.8 2026-06-04 15:49:09 +08:00
claude-code-best
b62b384e36 fix: normalizeMessagesForAPI 不再跨 tool_result 边界合并同 ID assistant 消息 (CC-1215)
ACP 模式下 extended thinking + tool_use 同一 turn 时,StreamingToolExecutor
在两个同 message.id 的 AssistantMessage 之间插入 tool_result,导致向后遍历
合并跨越边界,产生重复 tool_use ID → 孤立 tool_result → 连续 user 消息 → 400。

修改向后遍历停止条件:遇到非 assistant 消息(含 tool_result)即停止,不再跳过。
v2.6.7
2026-06-04 15:41:41 +08:00
claude-code-best
d7001b870f fix: add markResourceTiming polyfill to performance shim for Node.js v22 undici compatibility
Node.js v22 undici internal calls performance.markResourceTiming() after
every fetch. The performance shim was missing this method, causing
TypeError crashes in ACP mode when running with Node.js.
2026-06-04 14:30:34 +08:00
claude-code-best
18437c20d2 fix: prevent crash when DiscoverSkills receives undefined query via ExecuteExtraTool
searchSkills() called .trim() on query without null-guard. When
DiscoverSkills is invoked through ExecuteExtraTool with missing
description, query is undefined, causing 'Cannot read properties of
undefined (reading trim)'.

Fixed with optional chaining: !query.trim() → !query?.trim()

Co-Authored-By: deepseek-v4-pro <deepseek-ai@claude-code-best.win>
2026-06-03 21:38:23 +08:00
James F
02298cb199 security: close telemetry leak in preconnectAnthropicApi startup path (#1253)
🔒 Security Discovery: Un-gated outbound connection bypasses privacy controls

Summary
-------
preconnectAnthropicApi() unconditionally sends a TCP+TLS handshake to
api.anthropic.com on every ccb startup — even when the user has explicitly
disabled all non-essential traffic via CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
or DISABLE_TELEMETRY=1.

This is the LAST un-gated outbound connection in the entire startup path.
Every other telemetry sink (Sentry, Langfuse, OpenTelemetry, GrowthBook,
1P Event Logger, Datadog, BigQuery, etc.) already respects the
privacyLevel module's isEssentialTrafficOnly() gate. This one did not.

Impact
------
While the preconnect is a HEAD request with no payload, the connection
itself leaks the client's IP address and session timing to Anthropic's
infrastructure. For privacy-conscious users and enterprise deployments
that have disabled telemetry, this constitutes an unexpected data leak.

Fix
---
Add isEssentialTrafficOnly() check at the function entry, consistent
with every other privacy-gated code path in the codebase. The
privacyLevel module is already imported by init.ts and 12+ other
modules — no new dependencies.

Verification
------------
Reproduced and verified via strace on Linux (aarch64):

  # Before fix
  $ strace -f -e connect ccb -p <<< 'hello'
  connect(16, sin_addr=inet_addr("160.79.104.10"), sin_port=htons(443)) = 0
  # ↑ connector to api.anthropic.com despite CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1

  # After fix
  $ strace -f -e connect ccb -p <<< 'hello'
  # ↑ zero remote TCP connections — all traffic to localhost only

Changes: 1 file, +5 lines (import + gate)
2026-06-02 09:30:13 +08:00
claude-code-best
b2b1981da3 docs: update contributors 2026-06-01 00:23:43 +00:00
claude-code-best
33c52578a6 docs: 修改 README 2026-05-31 22:11:29 +08:00
claude-code-best
e33b17bde7 feat: sideQuery 支持第三方 provider 路由 (OpenAI/Grok/Gemini)
- 新增 getProviderPrimaryModel() 从环境变量解析 provider 主模型
- getDefaultOpus/Sonnet/HaikuModel 在第三方 provider 下回退到用户配置的主模型
- sideQuery 根据 provider 类型分发到对应的 API 适配器
- 新增 sideQueryViaOpenAICompatible (OpenAI + Grok) 和 sideQueryViaGemini 适配函数
- 避免 sideQuery 后台任务在配置第三方端点时仍请求 Anthropic API
2026-05-31 14:08:30 +08:00
claude-code-best
797424115d chore: 2.6.6 v2.6.6 2026-05-29 17:52:25 +08:00
claude-code-best
efc218d8a9 fix: searchSkills 使用缓存 IDF 前校验 index 引用一致性,修复测试间歇性失败 2026-05-28 22:24:29 +08:00
claude-code-best
a91653a0dd fix: 删除 edit tool 中的旧逻辑处理, 现在已经不需要这些处理了, 大模型够屌 (#1251)
* refactor: remove tab/quote normalization from FileEditTool

* fix: resolve pre-existing typecheck errors (zod v4 compat + RCS web exclude)
2026-05-28 21:52:31 +08:00
claude-code-best
c982104476 docs: update contributors 2026-05-25 00:22:36 +00:00
claude-code-best
6dd378bf15 fix: 退出启动对话框时终端残留一行内容
gracefulShutdownSync 启动异步 shutdown 后同步返回,React 立即
重新渲染组件,与 cleanupTerminalModes() 中的 Ink unmount 产生
竞态条件,导致退出后终端残留对话框内容。

修复方案:引入 pendingExitCode state,退出路径先清空画面
(渲染 null),在 useEffect 中延迟到下一个 tick 再调用
gracefulShutdownSync,确保 Ink 在终端清理前已完成空帧刷新。

影响三个启动对话框:TrustDialog、BypassPermissionsModeDialog、
DevChannelsDialog。

Co-Authored-By: glm-5.1 <zai-org@claude-code-best.win>
2026-05-22 22:25:51 +08:00
claude-code-best
ed61932748 fix: subtract cached_tokens from input_tokens in OpenAI stream adapter
OpenAI's prompt_tokens includes cached tokens, but Anthropic's
input_tokens semantic excludes them. The adapter was mapping
prompt_tokens → input_tokens verbatim, causing downstream code
(cache hit rate, cost, autocompact) to double-count.

Real-world impact: DeepSeek returns prompt_tokens=34097 with
cached_tokens=34048, displayed as 50% hit rate instead of 99.86%.

Co-Authored-By: glm-5.1 <zai-org@claude-code-best.win>
2026-05-22 21:58:33 +08:00
claude-code-best
b1c4f40f90 fix: ACP 模式下 extended thinking + tool_use 触发连续 user 消息导致 400 (CC-1215) 2026-05-22 21:58:33 +08:00
Dosion
f91060836f fix(swarm): WindowsTerminalBackend pidFile health check + 5-state lifecycle (#1237)
* fix(swarm): WindowsTerminalBackend pidFile health check + 5-state lifecycle

修 wt.exe split-pane fire-and-forget 导致 teammate 假死、TeamDelete 卡死、
kill-while-spawn race 等多个问题。

- 加 waitForPidFile() 在 wt.exe 返回后等 powershell.exe 真启动写 pidFile
  默认 8s timeout,env CLAUDE_WT_PANE_TIMEOUT_MS 覆盖,超时 throw 含完整诊断
- 加 5 态生命周期 (registered/spawning/ready/killing/dead),sendCommandToPane
  inner Promise 包装 spawnPromise,ready 态重 spawn 直接 throw
- killPane TOCTOU 修正:await spawnPromise 后重读 status;优先用缓存 pane.pid
  避免读盘,Stop-Process 失败也清缓存 + 标 dead 防 PID 复用误杀
- pid 解析严格化:/^\d+$/ + Number.isFinite + >0;移除 dead try/catch
- 构造函数 options 对象注入 pidFileDir(兼容原位置参数)
- 清启动前陈旧 pidFile,killPane fallback 3×500ms retry 兜底

* test(swarm): 12 tests covering WindowsTerminalBackend lifecycle, race, pid validation

为 WindowsTerminalBackend 加 12 个测试覆盖 v2 全部新行为,含 5 个 v1 兼容 + 7 个
v2 新场景。配套构造函数 options 对象,测试用 pidFileDir: tempDir 隔离防泄漏到
真实 OS tmpdir。

新场景覆盖:
- unlinks stale pidFile so a stale pid is not adopted
- rejects re-spawn on a ready pane
- throws on unknown paneId in sendCommandToPane
- rejects corrupted pidFile content ("123abc") and times out
- killPane awaits in-flight spawn before killing (kill-while-spawn race)
- Stop-Process failure clears cached pid and marks pane dead
- killPane uses cached pid and returns false when pane is unknown

createBackend helper 改用 options 对象 + simulatePidWrite 模拟 powershell 写
pidFile,pidFileDir 注入 tempDir,env CLAUDE_WT_PANE_TIMEOUT_MS beforeEach 设置
afterEach 清理。

---------

Co-authored-by: unraid <local@unraid.local>
2026-05-22 21:06:47 +08:00
Dosion
9d17597e58 feat(autofix-pr): 完整完成回流机制 (latent bug fix + completionChecker + 内容回流) (#1240)
* fix(autofix-pr): 修复 taskId 不一致导致 monitor lock dangling

问题:createAutofixTeammate 生成 teammate UUID 作为 monitor lock 的 key,
但 registerRemoteAgentTask 内部生成的 framework taskId 是另一个 UUID。
CCR session 自然完成时框架调 clearActiveMonitor(frameworkTaskId)
guard 失败,lock 永不释放,导致后续 /autofix-pr 报 "already monitoring"。

修复(Phase 1 of remote-agent completion loop):
- monitorState 新增 updateActiveMonitor(partial) 原子更新
- callAutofixPr 在 register 后 swap lock 的 taskId 到 framework 分配的 id
- RemoteAgentTask 引入 registerCompletionHook 注册式 API(参考已有的
  registerCompletionChecker 模式),在 5 个完成路径调 runCompletionHook
- autofix-pr 命令模块自己注册 cleanup hook,避免 framework 反向依赖
  command 模块

测试:
- monitorState 新增 4 个测试(updateActiveMonitor 行为 + bug 复现/修复)
- launchAutofixPr 新增 3 个端到端回归测试(taskId swap + hook 触发 +
  subsequent launch 不报 already monitoring)

完整分析与 Phase 2/3 改造方案见
docs/features/remote-agent-completion-analysis.md。

* feat(autofix-pr): 注册 completionChecker 用 gh CLI 探测 PR 完成

Phase 2 of remote-agent completion loop。Phase 1 修了 monitor lock
dangling,但完成信号仍然只能等 CCR session 自然 archive(timing 不可
预测,且不知道 PR 究竟有没有被修好)。Phase 2 加上主动完成探测。

实现:
- 新增 prOutcomeCheck.ts(纯决策矩阵):summariseAutofixOutcome 给定
  PR 快照 + 基线 SHA 返回 completed/summary。8 个决策分支单元测试。
- 新增 prFetch.ts(spawn 层):runGhPrView 调 gh CLI,fetchPrHeadSha
  在 launch 时捕获基线 SHA,checkPrAutofixOutcome 组合两者。
- AutofixPrRemoteTaskMetadata 加 initialHeadSha?: string 字段,survive
  --resume。
- launchAutofixPr.ts 模块顶部 registerCompletionChecker('autofix-pr',
  ...),5s throttle 防 gh CLI 调用爆。callAutofixPr 启动时调
  fetchPrHeadSha 传入 metadata。

决策矩阵:
  MERGED                  → done(merged)
  CLOSED 未 merge          → done(closed without fix)
  OPEN 无 baseline        → 继续轮询
  OPEN head 未变           → 继续轮询(agent 还没 push)
  OPEN head 变 + CI pending → 继续轮询
  OPEN head 变 + CI failure → done(surface red,user 决定 retry)
  OPEN head 变 + CI success → done(clean fix)

设计:
- gh CLI 而非 Octokit:复用用户已有 auth,不引入 token 管理
- 决策与 spawn 分文件:prOutcomeCheck 纯函数易测,prFetch 单独 mock
  避免 Bun mock.module 进程级污染(已在 launchAutofixPr.test 注释说明)
- 5s throttle:framework 每 1s 轮询,gh CLI subprocess 太重不能跟上
- 失败兜底:fetchPrHeadSha/checkPrAutofixOutcome 失败均不抛,returns
  null/false,framework 继续走原路径

测试:
- prOutcomeCheck 9 个单测覆盖决策矩阵
- launchAutofixPr 5 个新测试:checker 注册 / fetchPrHeadSha 调用 /
  initialHeadSha 传 metadata / SHA 失败仍能 launch / SHA null 处理

完整方案见 docs/features/remote-agent-completion-analysis.md。

* feat(autofix-pr): 内容回流让本地模型读到 PR 修复结果

Phase 3 of remote-agent completion loop。Phase 2 注册了 completionChecker
让框架能在 PR 合并/关闭/有 push+CI 绿时主动完成 task,但 task-notification
仍然只携带 generic 文本(""${owner}/${repo}#42 merged"")。Phase 3 让本地
模型读到远端 agent 自己产出的结构化结果(commits 列表、files 列表、CI
状态、人类可读 summary)。

实现:
- 新增 extractAutofixResultFromLog (src/commands/autofix-pr/
  extractAutofixResult.ts):从 SDKMessage[] 中扫 <autofix-result> tag,
  优先 hook stdout 后 fallback assistant text,latest-wins。10 个单测。
- RemoteAgentTask 新增 registerContentExtractor 注册式 API + 私有
  enqueueRichRemoteNotification(参考 enqueueRemoteReviewNotification),
  在 3 个 generic 完成路径(archived / completionChecker / result-driven)
  先尝试 tryExtractRichContent,有内容用 rich 变体,没有走 generic。
  isRemoteReview 路径不变(它走自己的 enqueueRemoteReviewNotification)。
- launchAutofixPr.ts 模块顶部 registerContentExtractor('autofix-pr',
  extractAutofixResultFromLog)。initialMessage 加 <autofix-result> 输出
  指令(pr-number / commits-pushed / files-changed / ci-status / summary)。

设计:
- 注册式 API(同 Phase 1 hook + Phase 2 checker):framework 不反向依赖
  命令模块,所有 PR-specific 逻辑在 autofix-pr/
- latest-wins:agent 重试时只取最新 tag,旧 tag 不会污染
- truncated tag → null:开 tag 无对应闭 tag 视为不完整,走 generic
  fallback
- 跨 message 不拼接:开 tag 和闭 tag 在不同 message 视为不完整(避免
  误拼字符串)
- 字符串 content 不解析:assistant.message.content 为 string(非 block
  array)的少见路径直接 skip,不 crash

测试:
- extractAutofixResultFromLog 10 个单测(空 log / 无 tag / hook stdout /
  assistant text / hook_response subtype / 多 tag latest-wins / 截断 /
  hook 后于 assistant 的优先级 / 跨 message 不拼接 / 字符串 content
  graceful)
- launchAutofixPr 3 个新测试(extractor 注册 / initialMessage 含 tag
  schema / extractor 真实行为)

完整方案见 docs/features/remote-agent-completion-analysis.md 第 5.3 节。

* fix(autofix-pr): extractBetween 支持 latest tag 截断时回溯到更早完整对

如果远端 agent 重试时写了完整 <autofix-result> 后又开了一个被截断的
第二个 tag, 旧实现只看 lastIndexOf(open) 然后找不到 close 就返回 null,
导致前面那个完整结果被丢弃。改为从尾向首遍历所有 open tag, 返回第一个
能配对的 open/close 对。

附带:
- docs/features/remote-agent-completion-analysis.md: 9 处裸 fenced block
  补 language tag (text/http), 修复 markdownlint MD040 警告
- 同文件: 两处"三选项" → "三个选项" 符合中文量词习惯

* test(autofix-pr): 补齐 completionChecker / 边界 CI 检查覆盖率

针对 codecov patch coverage gap, 补足三块此前未走到的代码路径:

prOutcomeCheck.ts (原 96.92%, 2 lines missing):
- statusCheckRollup === undefined 路径 (与空数组分支不同, GitHub 在无
  checks 配置的 PR 上直接省略字段)
- COMPLETED 状态但 conclusion 为 null/空 的 in-flight 检查归为 pending

launchAutofixPr.ts (原 58.33%, 15 lines missing):
- registerCompletionChecker arrow body: metadata 缺失早返回 / 节流窗口内
  返回 null / completed=false 返回 null / completed=true 返回 summary /
  initialHeadSha 透传到 checkPrAutofixOutcome
- registerCompletionHook 的 if(meta) 短路两侧: 有 metadata 时清空节流条目,
  无 metadata 时仍释放 active monitor lock

所有新测试沿用现有 mock.module 与 registerXxxMock.mock.calls 拉取注册
回调的模式, 无新增依赖。prOutcomeCheck 11/11 本地通过。

* style: biome check --fix 整形 launchAutofixPr.test 新增段

---------

Co-authored-by: unraid <local@unraid.local>
Co-authored-by: Claude <noreply@anthropic.com>
2026-05-22 21:06:26 +08:00
claude-code-best
f2b751f659 chore: 2.6.5 v2.6.5 2026-05-22 21:05:06 +08:00
claude-code-best
d4a601475f fix: 修复 BriefTool 循环依赖导致 isBriefEnabled 未定义
将模块顶层 require() 改为懒加载函数 getBriefToolModule(),
延迟到实际调用时才加载模块,避免循环依赖时模块尚未完成初始化。
2026-05-22 21:04:17 +08:00
claude-code-best
897c186f28 docs: effort 级别描述去掉模型名限制 2026-05-22 20:11:12 +08:00
claude-code-best
03598d3f84 refactor: 移除 resolveAppliedEffort 中的 max/xhigh 降级分支 2026-05-22 20:09:53 +08:00
claude-code-best
7b52054ff5 feat: 解除 max/xhigh effort 级别的模型白名单限制 2026-05-22 20:09:10 +08:00
claude-code-best
66c892521b chore: 2.6.0 v2.6.0 2026-05-21 16:38:25 +08:00
claude-code-best
dab04af7c9 perf: Vite 构建启用 code splitting,Bun RSS 从 966MB 降至 35MB
Bun/JSC 全量解析单文件大 JS 的 bytecode 和 JIT,17MB 产物导致
RSS 暴涨至 ~1GB(Node/V8 懒解析仅需 ~220MB)。启用代码分割后
Bun 按需加载 chunk,--version RSS 35MB,完整加载 ~500MB。

改动:
- vite.config.ts: 移除 codeSplitting:false,添加 chunkFileNames
- post-build.ts: 遍历 dist/ + dist/chunks/ 所有文件做 Bun patch
- 新建 distRoot.ts 共享工具函数,统一路径定位逻辑
- ripgrep.ts/computerUse/setup.ts/claudeInChrome/setup.ts/updateCCB.ts:
  用 distRoot 替换内联 import.meta.url 路径推算
2026-05-21 16:36:27 +08:00
claude-code-best
5b5fbb2f47 chore: 2.5.0 v2.5.0 2026-05-20 10:47:52 +08:00
claude-code-best
9bfa868e61 chore: 复原原始的 package.json v2.4.8 2026-05-20 10:14:40 +08:00
claude-code-best
f6dcf63902 Revert "chore: 切换到 bun publish,修复 husky 路径问题,调整 diff 折叠距离,导出 VoiceContext"
This reverts commit c80a6d062b.
2026-05-20 10:11:21 +08:00
claude-code-best
5957e26d9b Revert "chore: 修复 publish 问题"
This reverts commit 58c3feb56a.
2026-05-20 10:11:09 +08:00
claude-code-best
58c3feb56a chore: 修复 publish 问题 v2.4.7 2026-05-20 10:06:44 +08:00
claude-code-best
e2f4d558e1 Revert "fix: bun publish 通过 ~/.npmrc 配置 registry 认证"
This reverts commit 9afcb398ca.
2026-05-20 10:05:38 +08:00
claude-code-best
9afcb398ca fix: bun publish 通过 ~/.npmrc 配置 registry 认证 v2.4.6 2026-05-20 09:34:59 +08:00
claude-code-best
c80a6d062b chore: 切换到 bun publish,修复 husky 路径问题,调整 diff 折叠距离,导出 VoiceContext
- publish-npm.yml: npm publish → bun publish,移除 setup-node,使用 BUN_CONFIG_TOKEN
- package.json: prepare 脚本 husky → bunx husky,版本 2.4.4 → 2.4.5
- Messages.tsx: DIFF_COLLAPSE_DISTANCE 从 0 改为 3,避免 diff 过度折叠
- voice.tsx: 导出 VoiceContext
v2.4.5
2026-05-20 09:25:22 +08:00
claude-code-best
a05242cef0 fix: 明确告知 agent SearchExtraTools/ExecuteExtraTool 是核心工具,已在工具列表中
- prompts.ts: 核心工具列表显式加入 SearchExtraTools, ExecuteExtraTool
- claude.ts: 非 delta 路径提示强调这两个工具可直接调用
- messages.ts: delta 路径渲染强调这两个工具已在工具列表中
- SearchExtraToolsTool/prompt.ts: 加入完整两步工作流示例
- ExecuteTool/prompt.ts: 加入完整两步工作流示例
2026-05-19 23:03:46 +08:00
claude-code-best
27b334aceb fix: 防止 MCP 工具调用失败后的 SearchExtraTools/ExecuteExtraTool 死循环 2026-05-19 23:03:46 +08:00
xiaoFjun-eng
27b665ac79 Fix type (#1242)
* 完善所有用到的type对象,并添加中文注释

* 补充遗失的type

* 修复claude-for-chrome-mcp中的type和interface类型缺失

* 完善注释
2026-05-19 15:04:59 +08:00
xiaoFjun-eng
ea399f1862 Fix type (#1239)
* 完善所有用到的type对象,并添加中文注释

* 补充遗失的type
2026-05-19 09:05:04 +08:00
claude-code-best
c499bfb4ed fix: 修复 voice provider 的问题 2026-05-18 22:54:11 +08:00
18243133
b67e9f9d38 Fix/plan paste fixes (#1238)
* fix: 降低 paste 检测阈值,修复非 bracketed-paste 终端粘贴文本损坏

非 bracketed-paste 终端下,短粘贴(<800 chars)的 stdin chunk 作为独立
keystroke 走 useTextInput.onInput 路径,闭包中 cursor 未刷新导致多次插入
竞态。现将 ≥3 字符的非特殊键输入纳入 paste 累积模式,绕过逐 chunk 处理。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* @
fix: Plan模式三处缺陷修复 — ExploreAgent可用性 + 弹窗一致性 + 方案文件保护

1. areExplorePlanAgentsEnabled()移除GrowthBook A/B实验依赖(tengu_amber_stoat),
   始终返回true,确保Explore/Plan agent在BUILTIN_EXPLORE_PLAN_AGENTS开启时始终可用

2. ExitPlanMode clear-context路径补setNeedsPlanModeExitAttachment(true),
   确保清除上下文退出Plan模式后生成plan_mode_exit附件

3. Plan mode full/sparse指令强化Plan文件读取要求:
   "can read" -> "MUST use FileRead to read first before any changes",
   新增"do NOT overwrite"禁止覆盖,Phase 1指令强化并行Explore Agent引导

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@

---------

Co-authored-by: psj88520 <qq18243133@gmail.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 21:57:15 +08:00
claude-code-best
2bca31e525 docs: update contributors 2026-05-18 00:20:32 +00:00
claude-code-best
2cc9a7daef Revert "feat: 添加 /goal 命令,支持长时间运行任务的目标管理 (#1222)" (#1236)
This reverts commit d66a6f6124.
2026-05-17 10:06:09 +08:00
Fearless
d66a6f6124 feat: 添加 /goal 命令,支持长时间运行任务的目标管理 (#1222)
* feat: 添加 /goal 命令,支持长时间运行任务的目标管理

从 Codex 项目移植 /goal 命令到 Claude Code,实现:
- Goal 状态管理模块(active/paused/budget_limited/complete)
- /goal 斜杠命令(set/clear/pause/resume/complete)
- Goal 模型工具(get/set/complete)
- Continuation prompt 自动注入系统提示
- Token 用量自动追踪

Co-Authored-By: mimo-v2.5-pro <XiaomiMiMo@claude-code-best.win>

* fix: goal 状态改为 session-scoped,避免多会话泄漏

将 currentGoal 单例替换为 Map<string, GoalState>,按 sessionId 隔离,
遵循 sessionIngress.ts 的模式。所有函数支持可选 sessionId 参数。

Co-Authored-By: mimo-v2.5-pro <XiaomiMiMo@claude-code-best.win>

* fix: 对 goal 的 tokenBudget/tokensUsed 添加数值校验

setGoal 中 tokenBudget 非 finite 或负数时归零;
updateGoalTokens 中 usage 非 finite 或负数时归零。

Co-Authored-By: mimo-v2.5-pro <XiaomiMiMo@claude-code-best.win>

* fix: 暂停期间 goal 时间不再继续计数

新增 pausedAt/accumulatedActiveMs 字段,pauseGoal 累积已活跃时间,
resumeGoal 重置 startTime,计时统一使用 getActiveElapsedMs()。

Co-Authored-By: mimo-v2.5-pro <XiaomiMiMo@claude-code-best.win>

---------

Co-authored-by: mimo-v2.5-pro <XiaomiMiMo@claude-code-best.win>
2026-05-17 10:05:46 +08:00
Cepvor
48a19b8a0d fix: isUsing3PServices 检查所有非 Anthropic provider (#1235)
原实现仅检查 Bedrock/Vertex/Foundry,遗漏了 OpenAI、Gemini、Grok
三个通过 CLAUDE_CODE_USE_* 环境变量切换的第三方 provider。

这导致:
- 命令可用性判定中 OpenAI/Gemini/Grok 用户被错误识别为 console 用户
  (/fast、/install-github-app 两个 Anthropic 专有命令误显示)
- auth status 显示中这些用户被误报为"未登录"

Co-authored-by: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>
2026-05-17 07:29:14 +08:00
Cepvor
5157b09743 feat: Grok 适配完善 — 防御性 usage 合并 + thinking 自动检测 (#1234)
* feat: Grok 适配完善 — 防御性 usage 合并 + thinking 自动检测

1. 提取 updateOpenAIUsage 到共享模块 openaiShared.ts,供 OpenAI 和
   Grok 两条路径复用,消除 Grok 中重复的 spread 漏洞。

2. 在 requestBody.ts 的 isOpenAIThinkingEnabled() 中增加 Grok 模型
   自动检测(模型名含 "grok"),与 DeepSeek/MiMo 并列。

3. messaging 层的 reasoning_content 回传(openaiConvertMessages.ts)
   和流解析(openaiStreamAdapter.ts)无需修改,Grok 与 DeepSeek/MiMo
   共用相同的 reasoning_content 字段协议。

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>

* fix: 回退 Grok 从 isOpenAIThinkingEnabled 的自动检测

Grok 推理模型(如 grok-4.20-reasoning)自动进行推理,不需要
thinking/enable_thinking 请求参数。发送这些参数虽大概率被忽略
(OpenAI SDK 透传 unknown keys),但属于不正确行为。

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>

---------

Co-authored-by: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>
2026-05-17 07:28:33 +08:00
Cepvor
ecd3f9d791 fix: Gemini 适配器补全 usage 字段映射 (#1233)
* fix: Gemini 适配器补全 usage 字段映射

Gemini API 的 usageMetadata 包含 cachedContentTokenCount 字段,
但此前未映射到 Anthropic 格式的 cache_read_input_tokens,导致
cache_creation_input_tokens 和 cache_read_input_tokens 始终为 0。

同时 message_delta 事件此前只携带 output_tokens,缺失
input_tokens、cache_creation_input_tokens、cache_read_input_tokens,
导致下游从 message_delta 读取最终 token 计数时获取不完整数据。

修复:
- 新增 cachedContentTokenCount → cache_read_input_tokens 映射
- message_start 和 message_delta 携带完整四个 usage 字段
- cache_creation_input_tokens 保持为 0(Gemini API 无等价概念)

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>

* fix: 添加 cachedContentTokenCount 到 GeminiUsageMetadata 类型

streamAdapter.ts 使用 usage.cachedContentTokenCount 但该字段未
在 GeminiUsageMetadata 类型中声明。CodeRabbit 审查发现此问题。

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>

---------

Co-authored-by: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>
2026-05-17 07:28:16 +08:00
claude-code-best
5b941d4ad4 chore: 2.4.4 v2.4.4 2026-05-16 09:12:11 +08:00
claude-code-best
ae7a4e5ae5 fix: CI 中跳过 AutofixProgress 测试(Ink waitUntilExit 在无 TTY 环境下挂起)
Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-16 09:07:08 +08:00
claude-code-best
e5f31afebd fix: ExecuteExtraTool 委托执行前增加 validateInput 校验,优化工具显示样式
- 在 call() 中 checkPermissions 之前调用目标工具的 validateInput(),防止模型传入不完整参数导致崩溃(如 TeamCreate 缺少 team_name → sanitizeName(undefined).replace() TypeError)
- renderToolUseMessage 从 "Executing TeamCreate..." 简化为 "TeamCreate",与其他工具样式一致

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-16 08:47:05 +08:00
claude-code-best
fc8d531a7d fix: 将 ExecuteExtraTool 加入 ASYNC_AGENT_ALLOWED_TOOLS 允许子代理执行延迟工具 2026-05-16 08:28:43 +08:00
Cepvor
835dd2d804 fix: 为 sessionStorage existingSessionFiles Map 添加容量上限 (#1227)
* fix: 修复子代理 token 消耗在主 spinner 中始终显示为 0

Spinner.tsx 的 token 聚合循环仅统计 in_process_teammate 类型任务,
漏掉了 local_agent(后台代理/verification agent)类型。当后台代理
运行时,主界面 spinner 一直显示 "↓ 0 tokens",因为 background agent
的 token 消耗未被纳入 teammateTokens 聚合。

同时在 inProcessRunner.ts 中,进程内队友完成时计算并设置 result
(含 totalTokens/totalToolUseCount/content/usage),使详情弹窗可以
正确展示累计 token 消耗,不再仅依赖 progress.tokenCount 间歇更新。

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>

* fix: 为 cacheWarningStateBySource Map 设置上限防止内存泄漏

Map 以 querySource 为 key 存储每个来源的缓存命中率历史状态,
但 querySource 类型为 `any`,长时间会话中可能产生大量唯一值,
Map 持续增长永不清理。

新增 MAX_SOURCE_ENTRIES = 50 上限,新增条目时若达到上限则
逐出最早插入的条目(Map 按插入顺序迭代)。

同时也新增 _resetCacheWarningStateForTest() 用于测试隔离。

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>

* fix: 为 sessionStorage existingSessionFiles Map 添加容量上限

existingSessionFiles Map 缓存 sessionId → 文件路径映射以避免重复
stat 调用,但在 coordinator/swarm 模式下,每个子代理产生独立
sessionId,长时间运行的 daemon 会话可能累积数千条目。

新增 MAX_CACHED_SESSION_FILES = 200 上限,新增条目时若达到上限则
逐出最早插入的条目。同时在 _resetFlushState() 中清除此缓存以保证
测试隔离。

Co-Authored-By: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>

---------

Co-authored-by: deepseek-v4-pro[1m] <deepseek-ai@claude-code-best.win>
2026-05-16 08:09:40 +08:00