Commit Graph

1209 Commits

Author SHA1 Message Date
Askhz
23711c45a8
Merge pull request #142 from Askhz/feat/memory-cloud-sync
feat: add memory cloud sync to costrict-web API
2026-05-21 20:40:36 +08:00
Askhz
efe7cfdb33 feat: add memory cloud sync to costrict-web API
Auto-memory files are now synced to the cloud via /api/memories endpoint.
On startup, a full scan uploads new/changed files. A file watcher handles
incremental changes with 10s debounce. A process lock ensures only one
watcher per project. Disabled via DISABLE_MEMORY_CLOUD_SYNC=1.

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-21 19:31:17 +08:00
Askhz
02827e97cd
Merge pull request #141 from IronRookieCoder/fix/search-extra-tools-discover-schema
fix(search-extra-tools): return input schema in discover mode results
2026-05-21 16:24:49 +08:00
IronRookieCoder
14f334b93d fix(search-extra-tools): return input schema in discover mode results
## Bug 详情
SearchExtraTools 的 discover: 查询模式计算了包含 description 和 inputSchema
的文本,但调用 buildSearchResult() 时只传入工具名数组,schema 信息被丢弃。
LLM 在 discover 后无法看到 MCP 等 deferred 工具的参数定义。

## 根因
Output 类型中缺少承载工具详情的字段,buildSearchResult() 和
mapToolResultToToolResultBlockParam() 均未处理 discover 模式的详情渲染。

## 修复方案
- Output 类型新增可选 details 字段(name、description、score、inputSchema)
- buildSearchResult() 接受并透传 details
- discover 分支将 TF-IDF 结果结构化传入输出
- mapToolResultToToolResultBlockParam() 新增 discover 模式渲染路径
- 更新 prompt 中 discover 模式描述,提及 input schema 和执行链

## 变更要点
- SearchExtraToolsTool.ts:4 处改动(Output schema、buildSearchResult、
  discover 分支、渲染逻辑)
- SearchExtraToolsTool.test.ts:更新 1 个测试 + 新增 1 个渲染测试
- prompt.ts:更新 discover 描述

## 自测
- 7 tests / 0 fail(新增 1 个渲染测试,更新 1 个 discover 测试)
- tsc --noEmit 无新增类型错误
- JSONL 日志验证 LLM 可正确解析返回的 schema

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-21 16:14:00 +08:00
github-actions[bot]
1463f5c272 chore(release): bump version to 4.1.4 2026-05-21 06:28:24 +00:00
Askhz
c3837c308d
Merge pull request #140 from Askhz/feat/new-auto-update
feat: add new standalone auto-update mechanism
2026-05-21 14:18:28 +08:00
Askhz
c63efd77a6 feat: add new standalone auto-update mechanism
Reference CS (opencode) design: startup one-shot version check,
silent patch auto-install via npm, minor/major notify only.
Does not modify any existing auto-update code.

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-21 14:16:26 +08:00
Askhz
eded375fb4
Merge pull request #137 from IronRookieCoder/fix/costrict-native-tool-bad-json
fix(costrict): recover task updates from missing tool calls
2026-05-20 17:19:51 +08:00
DoSun
69ee2ca31e
Merge pull request #139 from y574444354/fix/linux-cloud-hang
fix: prevent Linux csc cloud commands from hanging
2026-05-20 17:06:20 +08:00
DoSun
553bf671ef perf: optimize cs-cloud spawn performance and remove debug logging
Optimized the spawn call to match direct cs-cloud execution performance:
- Use process.env directly instead of spreading (avoids unnecessary copy)
- Explicitly disable shell to avoid overhead
- Removed debug timestamp logging for cleaner output

The spawn performance now matches direct cs-cloud binary execution.

Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
2026-05-20 17:03:35 +08:00
DoSun
9afae554eb refactor: change execution log from debug to info level
Changed the command execution logging from stderr debug message to stdout info message for better user experience.

- console.error -> console.log
- Removed [DEBUG] prefix
- Cleaner "Executing:" format

Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
2026-05-20 14:15:08 +08:00
DoSun
6901484dd7 feat: add command execution logging for debugging
Added debug logging to print the exact cs-cloud command being executed.
This helps verify that arguments are passed correctly when debugging cloud hang issues.

Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
2026-05-20 14:13:52 +08:00
DoSun
b6e9b1ba4e fix: prevent Linux csc cloud commands from hanging
Fixed the root cause of Linux csc cloud commands hanging by addressing spawn() call issues, not network/permission problems:

- Changed stdio from "inherit" to ["ignore", "inherit", "inherit"] to close stdin and prevent blocking
- Removed duplicate ensureCsCloud() call that was unnecessary since runCsCloud already calls it
- Added disconnect event handler for better error handling
- Added explicit detached: false option

The real issue was that stdin inheritance caused the spawn call to block on Linux, even when the cs-cloud binary already existed and worked fine when called directly.

Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
2026-05-20 14:11:30 +08:00
IronRookieCoder
4cb047ff48 fix(costrict): recover task updates from missing tool calls
## Bug 详情
CSC 在相同模型和输入下,任务流程可能先成功执行 TaskCreate,随后模型返回 stop_reason=tool_use 但没有实际 tool_use block,导致 TaskUpdate/update_todo_list 没有执行,最终任务状态更新失败。

## 根因
CoStrict/OpenAI 兼容流在工具参数不完整或模型续轮缺少工具块时,缺少稳定的结构化恢复路径;query 层原先无法基于已发生的任务工具调用链路区分普通缺失工具调用和任务状态更新流程。

## 修复方案
基于结构化 tool_use 历史识别任务流程,优先引导 CoStrict 使用 update_todo_list 恢复任务清单状态;同时为 CoStrict 工具 JSON 流增加无效参数保留和错误结果回传,避免执行 malformed tool input。

## 变更要点
- 新增 update_todo_list 兼容工具,并注册到 TaskV2 工具列表
- query 缺失 tool_use 恢复改为基于 TaskCreate/TaskUpdate/TaskList/TaskGet/update_todo_list 结构化工具历史判断
- CoStrict provider 保留 malformed tool call 的 id/name 并阻止执行无效参数
- 工具执行和 streaming executor 对 invalid tool call 返回错误 tool_result
- 补充 query 恢复、CoStrict provider、工具执行、消息规范化和 update_todo_list 单测

## 自测
- bun test src/__tests__/queryMissingToolUseRecovery.test.ts
- bun test src/costrict/provider/index.test.ts
- bun test src/utils/__tests__/messages.test.ts
- bun test src/services/tools/__tests__/StreamingToolExecutor.test.ts packages/builtin-tools/src/tools/UpdateTodoListCompatTool/__tests__/UpdateTodoListCompatTool.test.ts
- bun run typecheck 仍有当前工作区既有无关错误,未由本次修改引入
2026-05-20 13:44:12 +08:00
DoSun
d18b7a0cb8
Merge pull request #136 from y574444354/fix/linux-cloud-hang
feat: serve mode SSE event conversion and task progress rendering
2026-05-20 11:27:50 +08:00
DoSun
600170ecf3 docs: add serve event standardization and consumer capability docs 2026-05-20 11:22:26 +08:00
DoSun
c63d8c60ce perf: optimize subagent transcript lookup with cache, meta-based resolution and startup index 2026-05-20 11:22:26 +08:00
DoSun
c5a3142dfe fix: default tool_use status to completed in transcript decompose 2026-05-20 11:22:25 +08:00
DoSun
bd968b8266 feat: messages API returns parts with accurate running status for active subagents 2026-05-20 11:22:25 +08:00
DoSun
a7a00a1a26 fix: use callID matching for task progress part updates
Remove mainPartID/mainMessageID from SubagentToolState. Emit
message.part.updated with random id and callID for task progress,
so consumer can match by callID when part IDs differ after tab switch.
2026-05-20 11:22:23 +08:00
DoSun
07f6ebe004 fix: normalize tool names and remove metadata.sessionId from running/completed events
- Apply normalizeToolName consistently in all tool_result paths (wasStreamed=true and wasStreamed=false)
- Remove metadata.sessionId from running state in streamStateTracker content_block_stop
- Remove metadata.sessionId from emitTaskProgress and emitTaskCompleted
- Add streamStateTracker.ts with stream-to-opencode event conversion
- Add subagent task lifecycle events (started/progress/completed)
- Handle tombstone, attachment, progress message types
2026-05-20 11:22:22 +08:00
linkai0924
da1985708f
Merge pull request #130 from Askhz/fix/deepseek-v4-pro-reasoning-fallback
fix: add fallback for non-standard reasoning/reasoning_details fields in OpenAI stream adapter
2026-05-19 20:51:26 +08:00
linkai0924
f655c50e51
Merge pull request #132 from IronRookieCoder/fix/weixin-startup-bad-weak-ptr
fix(weixin): avoid startup initialization without account
2026-05-19 20:50:42 +08:00
linkai0924
9481d58c2b
Merge pull request #131 from Askhz/fix/ctrl-enter-newline
fix: 修复 Ctrl+Enter 在标准终端中应插入换行而非发送消息
2026-05-19 20:50:33 +08:00
linkai0924
6e8bb0f72d
Merge pull request #135 from Askhz/feat/costrict-cheapest-model-for-haiku-tasks
feat(costrict): use cheapest model by creditConsumption for haiku-tier auxiliary tasks
2026-05-19 20:46:40 +08:00
Askhz
0aa86c9f84 feat(costrict): use cheapest model by creditConsumption for haiku-tier auxiliary tasks
All auxiliary requests (session memory, extract memories, side queries,
forked agents) now resolve to the model with the lowest creditConsumption
from the /v1/models list when using the CoStrict provider, instead of
falling back to the main conversation model.

- Add getCheapestCoStrictModel() to select cheapest model from cached list
- Resolve haiku-family models to cheapest model in resolveCoStrictModel
- Change getSmallFastModel() for CoStrict to return haiku alias
- Fix sideQuery() to respect opts.model with known-model validation
- Override mainLoopModel in SessionMemory and extractMemories forked agents
- Use getSmallFastModel() for findRelevantMemories under CoStrict

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-19 19:13:49 +08:00
linkai0924
be10194239
Merge pull request #134 from y574444354/fix/favorite-list-all-types
fix: favorite list route should respect type query parameter
2026-05-19 17:59:42 +08:00
林凯90331
9093d20fcf fix: favorite list route should respect type query parameter
The /global/favorite/skills GET route was hardcoded to list only
skill-type favorites, causing cloud hub to show Cloud status for
non-skill favorites (agent, command, mcp) even after they were
loaded locally.

Now it reads the optional type query parameter and passes it to
listFavoriteItems, matching the opencode server behavior.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-19 17:57:38 +08:00
IronRookieCoder
31380447de fix(weixin): avoid startup initialization without account
## Bug 详情
未配置微信账号时,启动阶段的 weixin MCP 子进程可能在初始化链路中触发 `std::bad_weak_ptr`,导致 `csc --debug` 看起来无法正常启动或使用。

## 根因
`runWeixinMcpServer` 在检查账号前先执行配置和分析初始化;未登录本应快速失败,但实际会先进入额外初始化路径。

## 修复方案
将账号检查前置,未配置账号时保持原有 stderr 提示和退出码,避免进入后续初始化。

## 变更要点
- `weixin serve` 未配置账号时直接输出原有提示并退出
- 已配置账号时仍按原流程初始化配置、分析 sink 并启动 MCP server

## 自测
- `bun test packages/weixin/src/__tests__/accounts.test.ts packages/weixin/src/__tests__/pairing.test.ts`
- 空 `WEIXIN_STATE_DIR` 下执行 `bun run src/entrypoints/cli.tsx weixin serve`,确认快速退出并输出未配置账号提示
2026-05-19 17:18:07 +08:00
Askhz
728af38c52 fix: 修复 Ctrl+Enter 在标准终端中应插入换行而非发送消息
- parse-keypress.ts: \n (LF) 字节标记为 ctrl=true,因为标准终端中
  Ctrl+Enter 发送 \n,需与普通 Enter (\r) 区分
- defaultBindings.ts: 新增 ctrl+enter -> chat:newline 快捷键绑定,
  支持 Kitty 键盘协议终端(如 Windows Terminal 1.25+)

Co-Authored-By: Sonnet-4.6-CoStrict <noreply@anthropic.com>
2026-05-19 16:16:24 +08:00
Askhz
933622fbe0 fix: add fallback for non-standard reasoning/reasoning_details fields in OpenAI stream adapter
CoStrict DeepSeek-V4-Pro returns thinking content in `delta.reasoning`
(string) and `delta.reasoning_details` (array) instead of the standard
`delta.reasoning_content` field. Add extractReasoning() with priority
fallback so all three formats are mapped to Anthropic thinking blocks.

Co-Authored-By: Auto <noreply@anthropic.com>
2026-05-19 14:32:45 +08:00
github-actions[bot]
321be8a128 chore(release): bump version to 4.1.3 2026-05-19 04:00:30 +00:00
linkai0924
0574a8e00e
Merge pull request #128 from Askhz/fix/lsp-windows-spawn-shell
fix: 修复 Windows 上 LSP 服务器启动 ENOENT 错误
2026-05-19 11:59:49 +08:00
linkai0924
f39c4b3416
Merge pull request #129 from IronRookieCoder/fix/image-multimodal-model-support
fix(costrict): handle image input for model compatibility
2026-05-19 11:59:33 +08:00
IronRookieCoder
b36e8e4ff2 fix(costrict): handle image input for model compatibility
## Bug 详情
CoStrict 在读取图片后会把图片放在 tool_result.content 中,OpenAI 兼容层只保留文本,导致模型没有收到真实图片内容。

非多模态模型收到图片请求时,后端会返回底层 400 错误,例如 not a multimodal model。

## 根因
OpenAI 消息转换逻辑没有处理 tool_result 中嵌套的 image block。

CoStrict 查询路径没有在发送请求前检查模型的图片输入能力,也没有归一化非多模态模型错误。

## 修复方案
将 tool_result 中的图片转换为后续 user 多模态消息,确保兼容层能传递 image_url。

在 CoStrict 模型元数据明确声明 supportsImages=false 时,提前返回英文错误提示;同时对后端非多模态错误做英文提示归一化。

## 变更要点
- Preserve image blocks nested in tool_result for OpenAI-compatible providers
- Add CoStrict image-capability gate based on supportsImages metadata
- Normalize non-multimodal backend errors to a clear English message
- Add regression tests for nested tool_result images and non-multimodal model handling

## 自测
- bun test src/costrict/provider/index.test.ts
- bun test packages/@ant/model-provider/src/shared/__tests__/openaiConvertMessages.test.ts
2026-05-19 11:38:16 +08:00
linkai0924
b7153a12a7
Merge pull request #127 from IronRookieCoder/fix/yaml-frontmatter-node-polyfill
fix(yaml): guard Bun YAML parser availability
2026-05-19 09:50:50 +08:00
Askhz
8dfd1ddc0b fix: 修复 Windows 上 LSP 服务器启动 ENOENT 错误
Windows 的 spawn() 使用 CreateProcess API,只能直接执行 PE 可执行文件
(.exe/.com),无法解析 npm 全局安装产生的 .cmd 包装脚本。启用 shell 选项
后由 cmd.exe 解析脚本路径,解决 typescript-language-server 等 LSP 服务器
在 Windows 上找不到命令的问题。

Co-Authored-By: Auto <noreply@anthropic.com>
2026-05-19 09:32:07 +08:00
IronRookieCoder
a506e933a9 fix(yaml): guard Bun YAML parser availability
## Bug 详情
Windows 下通过 npm shim 执行 csc 时,/agents 只显示 built-in agents,User agents 和 Project agents 未加载;debug 日志中 agents 和 skills 的 frontmatter 均报 Cannot read properties of undefined (reading 'parse')。

## 根因
csc.cmd 实际通过 Node 执行 dist/cli-node.js。Node 入口注入了 globalThis.Bun polyfill,但该 polyfill 不包含 Bun.YAML。parseYaml 只判断 Bun 对象存在,导致误调用 Bun.YAML.parse。

## 修复方案
将 Bun 分支改为能力检测,仅在 Bun.YAML.parse 存在时使用 Bun 内置 YAML 解析器,否则回退到 yaml npm 包。

## 变更要点
- 为 parseYaml 增加 Bun.YAML.parse 可用性判断
- 保持真实 Bun runtime 使用 Bun.YAML.parse
- 保持 Node 入口使用 require('yaml').parse 回退

## 自测
- bun 下验证 parseYaml 可解析基础 frontmatter
- Node 下验证 yaml 包可解析基础 frontmatter
- bun run typecheck 已运行,但失败于仓库既有无关类型错误
2026-05-18 20:45:56 +08:00
linkai0924
14b2030d30
Merge pull request #126 from y574444354/feat/raw-dump-parent-ids
feat(rawDump): add parent_ids to commit payload
2026-05-18 20:26:25 +08:00
林凯90331
ad90f40088 feat(rawDump): add parent_ids to commit payload
Include parent commit hashes in raw dump commit reporting.
- git log format now includes %P (parent hashes)
- parseCommitLog extracts parent_ids as string array
- CommitPayload type extended with parent_ids field
- merge commits may have multiple parents

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 20:06:15 +08:00
github-actions[bot]
a76c92ea2d chore(release): bump version to 4.1.2 2026-05-18 11:17:21 +00:00
linkai0924
70b5e285aa
Merge pull request #124 from IronRookieCoder/fix/git-bash-raw-mode
Fix/git bash raw mode
2026-05-18 19:15:14 +08:00
linkai0924
e901c66cd1
Merge pull request #122 from IronRookieCoder/fix/task-exception-status-hint
Fix/task exception status hint
2026-05-18 19:09:34 +08:00
IronRookieCoder
61610d08cd fix(openai): reject invalid streamed tool arguments
## Bug 详情
OpenAI 兼容流返回工具调用时,模型可能输出无法解析为 JSON object 的 arguments,例如 TaskUpdate 参数片段最终拼成非法 JSON。此前这类返回会被任务工具宽松修复或降级为 {},用户看不到模型返回不合法,工具也可能进入错误执行路径。

## 根因
normalizeContentFromAPI 在解析 tool_use.input 失败后会尝试 repairTaskToolInput,并在无法修复时回退为空对象;OpenAI 组装层没有把非法工具调用转换成用户可见提示。

## 修复方案
将工具调用参数作为模型边界输入严格校验:最终工具名必须存在,工具参数必须解析为 JSON object。非法响应抛出 InvalidToolCallResponseError,并在 OpenAI 组装层转换为普通英文 assistant 提示,工具不再执行。

## 变更要点
- 移除任务工具参数的宽松修复和 {} 降级逻辑
- 新增非法工具调用参数和缺失工具名的显式错误
- OpenAI 组装层捕获非法工具调用并显示普通英文提示
- 增加流式分片省略 name 时保留初始工具名的测试

## 自测
- bun test src/utils/__tests__/messages.test.ts
- bun test packages/@ant/model-provider/src/shared/__tests__/openaiStreamAdapter.test.ts
- git diff --check
- bun run typecheck 仍失败,失败项为仓库既有类型问题,未涉及本次改动文件
2026-05-18 17:59:13 +08:00
linkai0924
175552cc76
Merge pull request #123 from Askhz/fix/disable-context-collapse-auto-compact
fix: 禁用 CONTEXT_COLLAPSE 修复自动压缩不触发的问题
2026-05-18 17:44:29 +08:00
linkai0924
c9ce63e7d4
Merge pull request #125 from y574444354/fix/favorite-status-priority
fix: cloud favorite status priority and runtime lifecycle
2026-05-18 17:38:50 +08:00
林凯90331
02ffda9d4c fix: cloud favorite status priority and runtime lifecycle
- deriveStatus: prioritize favorite lifecycle over local config presence
- autoEnableCloudFavorites: skip unloaded items to prevent re-loading
- load/unload: sync agent/command favorites to ~/.claude/{agents,commands}/
- /hub toggle: trigger MCP reconnection and agent definition refresh
- cloud-enabled menu: trigger load for newly checked items

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 17:38:10 +08:00
Askhz
2ae463a8fe refactor: dev.ts 和 build.ts 统一从 defines.ts 导入 feature flags
之前三个文件各自维护独立的 feature 列表,导致合并时容易漏掉变更
(如 CONTEXT_COLLAPSE 在 defines.ts 已禁用但 build.ts 仍启用)。

现在 dev.ts 和 build.ts 都从 defines.ts 导入 DEFAULT_BUILD_FEATURES,
与上游保持一致的单一定义源模式。

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-18 17:28:16 +08:00
IronRookieCoder
7b3260e757 fix(ink): restore Git Bash raw input handling
## Bug 详情
Windows Git Bash 终端下,csc 4.1.x 的 REPL 输入异常:回车需要按两次,方向键无法选择历史对话,输入 / 无法正常显示或触发命令。

## 根因
Windows raw mode 风险判断将 Git for Windows 的 MINGW64/MINGW32 与 MSYS2/Cygwin/mintty 环境一并禁用 raw mode,导致 Git Bash 走 cooked input fallback,Ink 无法按预期解析 Enter、方向键和 slash 输入。

## 修复方案
将 Git for Windows 的 MINGW64/MINGW32 从 raw mode 不安全名单中排除,恢复 Git Bash 的 raw mode 输入处理,同时保留 MSYS/UCRT/CLANG/Cygwin 和显式禁用开关的保护路径。

## 变更要点
- 调整 Ink raw mode 风险检测,Git Bash 保持 raw mode
- 同步启动早期输入捕获的 Git Bash raw mode 判断
- 增加 Git Bash raw mode 回归测试,并保留 MSYS2/Cygwin 场景覆盖

## 自测
- bun test packages/@ant/ink/src/core/__tests__/raw-mode-support.test.ts src/utils/__tests__/earlyInput.test.ts
- git diff --check
- bun run typecheck(失败,失败点为仓库既有 Zod 类型、缺失声明、MACRO.COMMIT、AppState 等错误,不涉及本次修改文件)
2026-05-18 17:13:17 +08:00
Askhz
5b19f83040 fix: 禁用 build.ts 中的 CONTEXT_COLLAPSE
与 defines.ts 和 dev.ts 保持一致,构建产物中也不再启用空壳
CONTEXT_COLLAPSE,恢复 autocompact 正常工作。

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-18 16:49:59 +08:00