Commit Graph

1004 Commits

Author SHA1 Message Date
DoSun
880782b1dd fix: remove debug logs, add model fallback, fix prompt_async flow
- Remove process.stderr.write debug logs from sessionHandle and prompt_async
- Add model fallback in assistant message (use this._model if msg.model missing)
- Add model field to user message emit for adapter consumption
- Wait for session ready before setModel/prompt in prompt_async
- Return 200 JSON instead of 204 No Content from prompt_async
- Set Bun.serve idleTimeout to 255s to prevent connection drops
2026-05-08 18:42:51 +08:00
DoSun
d7a65170cd
Merge pull request #48 from y574444354/feat/favorite-migrate
Feat/favorite migrate
2026-05-08 18:42:01 +08:00
林凯90331
9a2469f8a8 Merge remote-tracking branch 'origin/feat/server-refactor' into feat/favorite-migrate 2026-05-08 18:34:37 +08:00
DoSun
8261385cbb
Merge pull request #49 from Askhz/feat/server-add-session
Feat/server add session
2026-05-08 18:34:17 +08:00
林凯90331
41dbd44b4e feat(hub): migrate favorite command with auto-enable, real-time toggle and server refactor
- Migrate favorite command from opencode to csc with /hub command
- Rename /favorite → /cloud-enabled → /knowledge-hub → /hub
- Auto-enable cloud favorites on startup without manual Update button
- Toggle items immediately on check/uncheck without Update button
- Add favorite REST routes and kh alias (later removed)
- Fix UDS socket path length exceeding macOS sockaddr_un.sun_path limit
- Add AbortController timeout to CoStrict fetch to prevent startup blocking
- Fix build robustness (handle missing download-ripgrep script)
- Merge server refactor: Hono-based HTTP API, session management, transcript reader
- Add serve API docs, server module unit tests, and cloud command handler

Signed-off-by: 林凯90331 <90331@sangfor.com>
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-08 18:18:44 +08:00
Askhz
231c76df84 fix: 完善 serve 模式 session 列表接口
- GET /session/:id 支持从磁盘历史记录 fallback,修复历史 session 404
- 过滤无意义的管理命令会话(/exit、/model、/login 等)
- 保留 /crewpilot:plan 等有意义的斜杠命令触发的会话

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 18:12:22 +08:00
yhangf
ba2aad5c09 feat(permissions): auto-select AskUserQuestion answers in headless mode
- Add headless fallback in `hasPermissionsToUseToolInner` that respects
  `askUserQuestionTimeoutSeconds` from settings (default 600s) when
  `shouldAvoidPermissionPrompts` is true, instead of hanging indefinitely
- Set `shouldAvoidPermissionPrompts: true` on `toolPermissionContext` in
  `-p` (pipe/headless) mode so the new path is triggered
- Hoist `parsedInput` before the try block so the headless path can use
  Zod-transformed input (includes defaults like `multiSelect: false`)
2026-05-08 17:57:15 +08:00
Askhz
a62989e245 Merge branch 'feat/server-refactor' into feat/server-add-session 2026-05-08 17:38:11 +08:00
Askhz
084d3fa468 feat: serve 模式 GET /session 接口从磁盘读取历史会话列表
- GET /session:调用 listSessionsImpl 扫描 ~/.claude/projects/ 历史 transcript,
  合并内存中活跃 handle 的运行时状态,支持 ?dir= 过滤
- GET /session/status:补充磁盘历史 session(全部标为 idle),不再返回空对象
- POST /session/:id/command_async、revert、summarize:补充缺失接口
- Bun.serve 设置 idleTimeout: 0,修复 SSE 长连接被 10s 超时切断的问题

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-08 17:32:04 +08:00
DoSun
ca147a40b7 fix: 修复 serve 模式 SSE 事件流、权限响应、协议对齐
- 修复 emitEvent 无限递归(调用自身→调用 eventBus.publishSessionEvent)
- 修复 prompt() 用户消息缺失 uuid/content 字段
- session.ready 事件映射为 session.updated(非重复 session.created)
- 新增用户消息事件(message.updated role:user + message.part.updated)
- 新增 session.status busy/idle、step-start/step-finish、session.idle/diff
- 清理 heartbeat properties 为空对象
- 仅 assistant 类型消息作为 session.message 转发,过滤 system/其他杂消息
- 权限响应映射 once/always/reject → allow/deny
- 会话创建支持 permission ruleset 推导 permission mode
- prompt 路由支持 model 字段切换模型
- 初始化消息支持 hooks 配置
- 新增 HookCallback/ControlCancelRequest 处理
- 权限响应支持 updatedPermissions 和 interrupt
- 新增 --resume-session-at、--permission-prompt-tool stdio 参数
- 追踪 lastMessageUuid 用于消息级回退
- EventBus dead client 清理
2026-05-08 16:59:45 +08:00
yhangf
697ee49752 feat(query-engine): pass mainThreadAgentDefinition to support built-in agent system prompts 2026-05-08 14:43:11 +08:00
Bonerush
7a816de547 fix: 修复条件式 hook 调用导致的 "Rendered fewer hooks than expected" 错误
修复在 dev 模式下按下 Ctrl+O 切换 transcript 视图时 React 抛出
"Rendered fewer hooks than expected" 崩溃的问题。

## 根因分析

项目中有大量 hook(useState / useMemo / useRef / useSyncExternalStore 等)
被包裹在 `feature()` 三元表达式中条件调用,例如:

    const value = feature('X') ? useHook() : defaultValue;

在 build 模式下 `feature()` 是编译时常量,死代码消除会移除未使用的分支,
hooks 数量在编译后是确定的。但在 dev 模式下(scripts/dev.ts 注入
--feature 启用全部 31 个 feature),`feature()` 是运行时调用,
但始终返回 true,因此所有 hooks 都会被调用,原本不会出问题。

真正的触发器是 REPL.tsx 第 5381 行的提前返回:

    if (screen === 'transcript') { return transcriptReturn; }

当用户按下 Ctrl+O 进入 transcript 模式时,该提前返回之后的所有 hooks
(如 displayedAgentMessages 的 useMemo)都不会被调用,导致 React 在
下一次渲染时检测到 hooks 数量与上次不一致而崩溃。

此外,其他文件中也存在相同的条件式 hook 模式——虽然 dev 模式下
feature() 返回 true,所以这些路径实际上不会被触发,但它们是
潜在的隐患:若将来有人通过环境变量关闭某个 feature,
同样的崩溃会立即出现。

## 修复策略

采用统一模式:**始终无条件调用 hook,将 feature() gate 应用到值上**。

    // Before (unsafe — hook count varies by feature flag)
    const value = feature('X') ? useHook() : defaultValue;

    // After (safe — hook always called, gate on the value)
    const rawValue = useHook();
    const value = feature('X') ? rawValue : defaultValue;

## 修改清单

### 核心修复(REPL.tsx)
- 将 `displayedAgentMessages` useMemo 及依赖变量(viewedTask /
  viewedTeammateTask / viewedAgentTask / usesSyncMessages /
  rawAgentMessages / displayedMessages)从 transcript 提前返回
  之后移至之前,确保两模式下 hooks 调用顺序一致
- 修复 `disableMessageActions` / `useAssistantHistory` /
  `voiceIntegration` 的条件式 hook 调用

### 条件式 hook 修复(11 个文件)
- src/hooks/useGlobalKeybindings.tsx — isBriefOnly / toggleBrief
  keybinding 改为 isActive 门控
- src/hooks/useReplBridge.tsx — 5 个 BRIDGE_MODE 选值改为无条件调用
- src/hooks/useVoiceIntegration.tsx — 4 个 VOICE_MODE 选值修复
- src/components/PromptInput/Notifications.tsx — 4 个 feature 选值修复
- src/components/PromptInput/PromptInput.tsx — briefOwnsGap /
  companionSpeaking 修复
- src/components/PromptInput/PromptInputFooterLeftSide.tsx — 4 个
  VOICE_MODE 选值修复
- src/components/PromptInput/PromptInputQueuedCommands.tsx — isBriefOnly
- src/components/Spinner.tsx — briefEnvEnabled 修复
- src/components/TextInput.tsx — voiceState / audioLevels /
  animationFrame 修复
- src/components/messages/AttachmentMessage.tsx — isDemoEnv 修复
- src/components/messages/UserPromptMessage.tsx — isBriefOnly /
  viewingAgentTaskId / briefEnvEnabled 修复
- src/components/messages/UserToolResultMessage/UserToolSuccessMessage.tsx
  — isBriefOnly 修复

### 其他修复
- src/components/FeedbackSurvey/useFrustrationDetection.ts — 将 3 个
  提前返回合并为 shouldSkip 变量,handleTranscriptSelect 提前 return
- src/hooks/useIssueFlagBanner.ts — useRef 移到 USER_TYPE 检查之前
- src/hooks/useUpdateNotification.ts — useState 改为 useRef,
  避免版本号变化触发不必要重渲染

### 构建/开发配置
- build.ts — 添加 `sourcemap: 'linked'`
- scripts/dev.ts — NODE_ENV 从 'production' 改为 'development'

Closes #434
2026-05-08 13:17:25 +08:00
geroge
684b81457c
Merge pull request #46 from y574444354/feat/favorite-migrate
feat: migrate favorite command from opencode to csc
2026-05-08 09:36:24 +08:00
geroge
0e01c5a02f
Merge pull request #44 from Askhz/fix/disable-fork-subagent-default
fix: 默认关闭 FORK_SUBAGENT feature flag
2026-05-08 09:35:46 +08:00
geroge
85aaeb9a7a
Merge pull request #43 from y574444354/feat/migrate-review-agents
feat: migrate review agents to unified costrict-review repo
2026-05-08 09:35:24 +08:00
林凯90331
dacbf1f7ab feat: migrate favorite command from opencode to csc
- Add /favorite REPL slash command with list/view/download/load/unload/uninstall

- Implement core favorite logic in src/costrict/favorite/ using createCoStrictFetch

- Extend GlobalConfig with agents and commands fields for config-layer storage

- Adapt skill load/unload to csc's directory-scanning mechanism (~/.claude/skills/)

- Adapt MCP load/unload to csc's mcpServers config via saveGlobalConfig()

- Decouple from opencode-specific deps: jsonc-parser, Config.invalidate, Filesystem.*

Signed-off-by: 林凯90331 <90331@sangfor.com>

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-08 08:20:57 +08:00
claude-code-best
b909af0963 chore: 2.2.1 2026-05-07 23:50:09 +08:00
claude-code-best
995bca4f27 Merge pull request #428 from xiaoFjun-eng/main
修复type
2026-05-07 22:31:12 +08:00
linkai0924
7363519887
Merge pull request #45 from y574444354/feat/report-raw-dump
feat(rawDump): add session data raw-dump reporting module
2026-05-07 22:16:02 +08:00
林凯90331
f3ece2f469 refactor(rawDump): prevent 429 with queue + batch worker
Replace per-turn detached workers with a file-backed queue consumed by
a single long-running batch worker (30s interval, 0-10s jitter).

- queue.ts, batchWorker.ts: file queue with pid-based lock for worker
  singleton; tasks deduped by sessionID:messageID before processing
- worker.ts: retry with backoff (5s, 10s) for 429 and network errors;
  update commit state per upload so partial failures resume cleanly;
  export auth, loadSessionMessages, getSessionDirectory and upload*
  helpers for batchWorker reuse
- git.ts: cap commit log at 50 entries within last 7 days; pause 500ms
  every 10 commits to spread load
- worker.ts: resolve session jsonl via ~/.claude/projects/{normalized}
  with fallbacks, scanning for the file containing the target session
- logger.ts: file + stderr logger gated by CSC_RAW_DUMP_DEBUG, default
  silent
- sessionDataUploader.ts: implement createSessionTurnUploader to pick
  the last assistant message; query.ts fires uploadSessionTurn after
  query_api_streaming_end (non-blocking)

Signed-off-by: 林凯90331 <90331@sangfor.com>
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-07 21:45:20 +08:00
DoSun
33ad9cd568 fix: prompt 路由支持 parts 格式请求体
消费端发送 parts 数组格式([{type:'text', text:'...'}]),
csc 同时支持 content 字符串和 parts 数组两种格式
2026-05-07 20:29:49 +08:00
DoSun
d5cfe0aff0 fix: 修复 serve 模式模型接口返回空数据
多层问题修复:
- setup.ts: CoStrict 模型预取从 fire-and-forget 改为 await,确保缓存就绪
- sessionHandle.ts: 修复子进程 spawn 参数丢失 -d/--feature 的问题,
  修复 models 数组被当 Record 处理的类型错误,始终传 --verbose
- sessionManager.ts: 新增 probe session 预热机制和 initData 缓存,
  provider 路由不再依赖活跃 session
- provider.ts: 输出格式匹配消费端 ProviderCapabilitiesResponse 类型,
  models 从数组转为 Record<string, ModelInfo>
- session.ts: 修复 scriptArgs 计算逻辑,避免传入 serve 子命令
2026-05-07 20:08:27 +08:00
kingboung
00e37eeccd fix: use new URL() for cwd path in build.ts review generation step
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 18:41:41 +08:00
DoSun
954c218085 fix: 修复 serve 模式 GET /agent 接口,直接从内置 agent 列表加载数据 2026-05-07 18:00:52 +08:00
林凯90331
28d4f1f4e5 feat(rawDump): add session data raw-dump reporting module
Introduce a framework-decoupled raw-dump module that uploads conversation, summary, and commits data to the CoStrict server in a non-blocking detached worker process.

- Add src/services/rawDump/ with index, types, state, spawn, git, worker, and README

- Implement reportTurn and reportSession entry points with in-memory dedup and env-based disable switch (CSC_DISABLE_RAW_DUMP / COSTRICT_DISABLE_RAW_DUMP)

- Replace sessionDataUploader stub with uploadSessionTurn that delegates to reportTurn

Signed-off-by: 林凯90331 <90331@sangfor.com>

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-07 17:27:56 +08:00
Askhz
f8a4ae7083 fix: 默认关闭 FORK_SUBAGENT feature flag
开启时会强制所有 Agent 工具调用走异步路径,导致 run_in_background
参数失效,子 agent 始终在后台运行。如需启用请设置 FEATURE_FORK_SUBAGENT=1。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 17:20:59 +08:00
kingboung
083e2a7cfc chore: add gray-matter dependency for frontmatter parsing
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 17:04:08 +08:00
kingboung
49204031fb chore: remove superpowers docs directory
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 16:52:12 +08:00
DoSun
de144bc0cb fix: 修复 Windows 下 dev serve 模式 Ctrl+C 无法关闭的问题 2026-05-07 16:36:35 +08:00
claude-code-best
57c7445a15 chore: remove learn directory study notes
Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-07 14:34:39 +08:00
claude-code-best
467720f78a feat: 改为使用 ccb 的邮箱 2026-05-07 12:06:40 +08:00
kingboung
a1d3a3db2d chore: untrack generated review builtin files from git index
Files are still present on disk and generated by build:review-builtin.
.gitignore rules prevent them from being re-committed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 11:49:07 +08:00
kingboung
3beeaa545e ci: add review agent generation step to build and CI
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 11:46:05 +08:00
claude-code-best
fd7173437b fix: 修正 GLM 模型 GitHub 署名邮箱为 zai-org
Co-Authored-By: glm-5.1[1m] <zai-org@users.noreply.github.com>
2026-05-07 11:35:40 +08:00
claude-code-best
3672413d40 feat: 署名邮箱改为 GitHub noreply 格式并新增模型映射
Co-Authored-By: glm-5.1[1m] <zhipuai@users.noreply.github.com>
2026-05-07 11:32:48 +08:00
claude-code-best
f3c1ad8e98 feat: 添加自动邮箱映射功能并完善署名系统
- 新增 attributionEmail.ts 实现模型名到邮箱的自动映射
- 重构署名逻辑,统一使用 getRealModelName() 和 getAttributionEmail()
- 将产品名从 Claude Code 更新为 Claude Code Best
- 更新 PRODUCT_URL 指向 claude-code-best fork 仓库

Co-Authored-By: glm-4.7 <noreply@zhipuai.cn>
2026-05-07 11:12:40 +08:00
claude-code-best
8ca45ef63f fix: 修复模型别名未解析导致署名显示 "haiku" 而非真实模型名
去掉 getUserSpecifiedModelSetting() 分支,统一走 getMainLoopModel()(解析别名)
+ resolveProviderModel()(解析 provider 映射)的完整链路。

Co-Authored-By: opus[1m] <noreply@anthropic.com>
2026-05-07 11:10:01 +08:00
claude-code-best
970425b360 fix: 修复非 Anthropic provider 署名模型名获取错误
getRealModelName() 现在会检查 provider 特定环境变量(OPENAI_MODEL、GEMINI_MODEL、GROK_MODEL),
确保通过这些变量设置模型时署名显示真实名称而非 Anthropic 默认模型名。

Co-Authored-By: opus[1m] <noreply@anthropic.com>
2026-05-07 10:57:14 +08:00
claude-code-best
18f1112ce1 feat: 添加 prompt 缓存命中率检测与警告功能
每次 API 请求后自动计算缓存命中率,低于阈值(默认 80%)时在对话流中显示黄色警告消息。
同时更新 /context 命令输出中显示缓存命中率。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-07 10:49:06 +08:00
DoSun
9a8faf1481 feat: 添加 cloud 命令(cs-cloud 二进制下载与命令转发) 2026-05-07 10:44:43 +08:00
kingboung
4054ae9f4b feat: migrate review agents and skills to unified costrict-review repo
- Add generate-review-builtin.ts script (downloads from zgsm-ai/costrict-review)
- Add review module (index.ts, extension.ts) with locale-aware skill init
- Add CommandLocale module with zh-CN/en templates for /review and /security-review
- Integrate REVIEW_AGENTS into builtInAgents.ts
- Route /review command to CoStrictReviewer agent
- Simplify /security-review to use Skill tool with locale templates
- Remove old generate-skills.ts and inline security-review skill

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 09:40:24 +08:00
kingboung
abf67ea914 feat: add generate-review-builtin script for unified review resource generation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 09:36:47 +08:00
kingboung
e4025f5d79 chore: add review module stubs and gitignore rules
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 09:34:18 +08:00
claude-code-best
1cfcfcb62e fix: 禁用 opus[1m] 自动迁移,尊重用户手动删除 [1m] 后缀的选择
迁移逻辑过于激进,用户手动删除 [1m]] 后会被自动加回。
现在将 migrateOpusToOpus1m 改为 no-op,保留用户的手动模型选择。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-07 09:33:56 +08:00
claude-code-best
87c0973bd1 feat: 开启部分被关闭的 feature 2026-05-07 09:14:58 +08:00
kingboung
65c347a151 docs: add design spec for migrating review agents to unified costrict-review repo
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 09:00:43 +08:00
claude-code-best
a977c07900 chore: 2.2.0 2026-05-07 08:29:07 +08:00
claude-code-best
a7ce9fccac feat: 启用 COORDINATOR_MODE feature flag
AgentSummary 30s fork 循环的内存泄露已在 commit 52b61c2c 修复(闭包
引用丢弃 + 上下文重建 + 消息/字符上限),重新启用该 feature。

用户可通过 /coordinator 命令或 CLAUDE_CODE_COORDINATOR_MODE=1 环境变量
激活多 worker 编排模式。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 08:28:28 +08:00
claude-code-best
cc4a007cae fix: 恢复消息流中 diff 高亮渲染功能
还原 commit 51b8ad46 删除的 diff highlight 显示:FileEdit/FileWrite 工具
执行成功后重新展示 StructuredDiffList,拒绝时重新展示高亮代码预览或
带上下文的 diff 视图。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 08:28:28 +08:00
claude-code-best
a75cc14415 Merge pull request #423 from znygugeyx-ctrl/feat/statusline-refresh-interval
feat: 状态栏支持 refreshInterval 定时刷新
2026-05-06 23:53:36 +08:00