Commit Graph

1174 Commits

Author SHA1 Message Date
linkai0924
e8349395ed
Merge pull request #88 from y574444354/feat/workflow
ci: add manual npm publish workflow with dry-run and auto version sync
2026-05-14 17:18:38 +08:00
林凯90331
5890d776dd ci(publish-npm): add ssh setup and review builtin generation
Add SSH agent setup before build so generate-review-builtin.ts

can clone the private costrict-review repo. Also run the

generator explicitly with continue-on-error to ensure the

bundled review skills file exists before Bun.build.

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 17:13:30 +08:00
IronRookieCoder
223b694965 fix(windows): prevent terminal startup failures
## Bug 详情
- issues.md #46:Windows MSYS2/UCRT64 下执行 csc,欢迎信息输出后在 stdin raw mode/终端输入初始化阶段崩溃,出现 native std::bad_weak_ptr 和后续 Bun mutex corrupt。
- issues.md #47:cmd.exe 可启动,但 PowerShell 运行 csc 会走 npm 生成的 csc.ps1;截图显示 node.exe 报错 "Input must be provided either through stdin or as a prompt argument when using --print",说明裸 csc 被误判成 print/non-interactive 模式。

## 根因
- MSYS2/Cygwin/mintty 等 Windows 终端对 Node/Bun stdin raw mode 和终端扩展控制序列兼容性不稳定,启动早期强行 setRawMode/查询终端能力会触发崩溃风险。
- npm 的 PowerShell shim 解析优先级高于 csc.cmd,且可能让 stdout TTY 状态不可用;原 main.tsx 只要 stdout 非 TTY 就自动进入 non-interactive/--print 路径,最终在没有 prompt/stdin 时触发 #47 的报错。

## 修复方案
- 为 Ink stdin raw mode 增加 Windows 风险终端检测,在 MSYS2/Cygwin/mintty 或显式禁用开关下跳过 raw mode,使用 cooked input fallback。
- early input 捕获在启动早期复用同类风险判断,避免 REPL 渲染前就触发 raw mode 崩溃。
- postinstall 在 Windows 上清理属于本包的 csc.ps1,让 PowerShell 回落到与 cmd.exe 一致的 csc.cmd 启动路径。
- 新增 non-interactive 判定工具,保留显式 -p/--print、--init-only、--sdk-url 的 headless 行为,但要求 stdin/stdout 都不是交互 TTY 才自动进入 non-interactive,避免 PowerShell shim 下裸 csc 被误判。

## 变更要点
- 新增 packages/@ant/ink/src/core/raw-mode-support.ts 及单元测试,覆盖普通 Windows shell、MSYS2/Cygwin/mintty 和禁用开关
- 调整 Ink App raw mode 生命周期,只在真正启用 raw mode 后写入/清理 bracketed paste、focus reporting、extended key 等终端控制序列
- 调整 component unmount/exit 清理逻辑,按 rawModeEnabledCount/rawModeActive 关闭实际启用的输入监听和 raw mode
- 调整 src/utils/earlyInput.ts,避免不安全 Windows 终端在启动阶段启用 stdin raw mode
- 调整 scripts/postinstall.cjs,立即和延迟清理 npm 生成的 csc.ps1 shim
- 调整 src/main.tsx 使用 shouldUseNonInteractiveSession,并新增对应测试覆盖 PowerShell shim 场景

## 自测
- bun test packages/@ant/ink/src/core/__tests__/raw-mode-support.test.ts src/utils/__tests__/earlyInput.test.ts src/utils/__tests__/nonInteractiveSession.test.ts
- node --check scripts/postinstall.cjs
- bun run src/entrypoints/cli.tsx --version
- bun run lint
- git diff --check

## 已知限制
- bun run typecheck 仍失败,错误来自仓库既有缺失声明/缺失模块和无关类型问题,不来自本次改动。
2026-05-14 17:07:51 +08:00
DoSun
481e6fc3c9 Merge remote-tracking branch 'origin/feat/server-refactor' into fix/serve-command-real-impl 2026-05-14 17:07:50 +08:00
林凯90331
86c68723a4 ci(publish-npm): drop v prefix from tags and skip tests
Use the exact input version for git tags without adding a v prefix.

Also comment out typecheck and test steps to speed up the publish flow.

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 17:07:16 +08:00
DoSun
025a4c8b34
Merge pull request #87 from Askhz/fix/serve-feature-flag-crash
fix: 编译后二进制 serve 子进程 crash 报 unknown option --feature
2026-05-14 17:05:29 +08:00
Askhz
4b7922d59b fix: 更新凭证路径注释为 ~/.costrict/share/auth.json
Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-14 17:03:12 +08:00
Askhz
195c23dbb2 fix: 编译后二进制 serve 子进程 crash 报 unknown option --feature
getScriptArgsForChild() 无法正确识别编译后的二进制:argv[1] 仍为原始入口
路径(如 src/entrypoints/cli.tsx),被误判为脚本模式,导致 saveChildSpawnPrefix()
生成 --feature Bun 专有参数传给子进程,子进程不识别直接 crash。

修复:在所有判断之前增加 execPath basename 检查,非 bun/node 的可执行文件
直接视为编译二进制,返回空数组。

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-14 17:00:43 +08:00
林凯90331
a23ebc0303 ci(publish-npm): restrict to manual trigger and auto-sync version
Remove push tag trigger so the workflow only runs on manual dispatch.

Add steps to automatically sync package.json and scripts/defines.ts

version before publishing, create the git tag, and skip typecheck.

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 16:57:09 +08:00
林凯90331
de53813db3 ci(publish-npm): auto-create missing tag on manual dispatch
When triggering the publish workflow manually with a version that does

not yet have a corresponding git tag, automatically create and push

the v-prefixed tag on the current HEAD instead of failing.

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 16:37:35 +08:00
林凯90331
5de3460884 ci(publish-npm): add dry-run support and normalize version input
Add optional dry-run flag to workflow dispatch for validating publishes

without uploading to the registry.

Support version inputs with or without the v prefix by resolving

the correct git ref automatically. Skip changelog generation and

GitHub release creation when running in dry-run mode.

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 16:33:03 +08:00
xixingde
5a306c3ea7 feat(auth): update OAuth flow message to reference Costrict branding 2026-05-14 16:28:24 +08:00
xixingde
25ea4a0cf3 feat(auth): add remote API control config to gate third-party providers 2026-05-14 16:03:04 +08:00
IronRookieCoder
a8c8c533d0 fix(builtin-tools): handle undefined message_ids in SnipTool.call()
## Bug 详情
调用 Snip 工具时,若模型通过 ExecuteExtraTool 传入空 params,
SnipTool.call() 中访问 input.message_ids.length 会抛出
`Cannot read properties of undefined (reading 'length')`。

## 根因
Snip 是延迟工具(非 CORE_TOOLS),需通过 ExecuteExtraTool 间接调用。
ExecuteExtraTool 将 params 直接透传给目标工具,不做 Zod schema 验证。
当 params 为空对象 {} 时,input.message_ids 为 undefined。

## 修复方案
在 SnipTool.call() 中使用 optional chaining 安全访问 message_ids。

## 变更要点
- packages/builtin-tools/src/tools/SnipTool/SnipTool.ts: 防御性处理空 message_ids
- src/costrict/provider/auth.ts: 删除 unreachable continue(lint 自动修复)
- src/services/rawDump/worker.ts: Math.pow → **(lint 自动修复)

## 自测
- 已人工验证

Co-Authored-By: Auto <noreply@anthropic.com>
2026-05-14 15:47:35 +08:00
DoSun
b11826c21c fix: 替换 main 分支的假 server 命令为真实 serve 实现
- 移除 DangerousBackend、lockfile、createServerLogger 等不存在的 import
- 使用 EventBus + SessionManager + startServer 真实实现
- 添加 serve 子命令作为 server 的别名
- 默认 host 改为 127.0.0.1,idle-timeout 改为 1800000ms
- 启动 probe session 并正确处理 SIGINT/SIGTERM 关闭
2026-05-14 15:36:27 +08:00
DoSun
cbc948b044 Merge branch 'feat/server-refactor'
# Conflicts:
#	build.ts
#	src/main.tsx
#	src/services/rawDump/worker.ts
2026-05-14 15:21:25 +08:00
DoSun
fd509086f3 fix: serve 模式下权限事件被 shouldAvoidPermissionPrompts 吞没导致直接拒绝
- 当 --permission-prompt-tool 指定时不设置 shouldAvoidPermissionPrompts,允许 can_use_tool 控制消息正常发出
- serve 默认权限模式从 acceptEdits 改为 default,确保权限检查链路完整
2026-05-14 15:04:17 +08:00
IronRookieCoder
28f2e3a6ac fix(agent-team): handle idle teammate coordination failures
## Bug 详情
Agent Team 在 CoStrict 环境下可能出现子代理无法执行、完成后主代理持续 Idle、shutdown 后 TeamDelete 被阻塞,以及 TeamCreate 参数错误时抛出 name.replace 深层异常。

## 根因
- Team teammate 默认模型路径未复用普通 subagent 的 CoStrict 继承逻辑,未配置 teammateDefaultModel 时会回退到 CoStrict 不可用的 claude-opus-4-6。
- in-process teammate 的 AsyncLocalStorage 上下文可能影响 team lead 的 inbox polling 身份判断。
- SendMessage 收到字符串形式的 shutdown_response JSON 时按普通消息转发,未进入 shutdown approval 分支。
- ExecuteExtraTool 调用 deferred tool 前未执行目标工具 validateInput,错误参数会绕过入口校验进入目标工具内部。

## 修复方案
- 将 teammate 模型解析集中到 teammateModel,并在 CoStrict 默认场景继承 leader model。
- 抽出 inbox poller 身份判断,基于 AppState 识别 team lead polling。
- 兼容字符串 JSON 协议响应,将 shutdown_response / plan_approval_response 路由到结构化处理逻辑。
- ExecuteExtraTool 在权限检查和实际执行前调用目标工具 validateInput。

## 变更要点
- 新增 teammate 模型解析和 CoStrict 继承测试。
- 新增 inbox poller identity helper 和 in-process 上下文回归测试。
- 新增 SendMessage 字符串 shutdown_response 回归测试。
- 新增 ExecuteExtraTool 目标工具校验回归测试。

## 自测
- bun test packages/builtin-tools/src/tools/ExecuteTool/__tests__/ExecuteTool.test.ts
- bun test packages/builtin-tools/src/tools/SendMessageTool/__tests__/udsRecipientSanitization.test.ts src/utils/swarm/__tests__/teammateModel.test.ts src/hooks/__tests__/useInboxPoller.test.ts
- bunx biome check 相关变更文件
- 变更文件相关 tsc 过滤检查无输出
2026-05-14 14:50:30 +08:00
IronRookieCoder
95a4430fa2 Revert "fix(bash): wake foreground task after auto-backgrounding"
This reverts commit 1a85db7ca8.
2026-05-14 13:33:00 +08:00
IronRookieCoder
54bc918970
Merge branch 'y574444354:main' into main 2026-05-14 13:24:33 +08:00
IronRookieCoder
1a85db7ca8 fix(bash): wake foreground task after auto-backgrounding
## Bug 详情
用户升级 4.0.16 后,使用过程中 CLI 会话可能一直处于 busy 状态,表现为无法继续输入且没有响应。

## 根因
BashTool 的长命令在已经注册为 foreground task 后被自动后台化时,只设置了 backgroundShellId,但没有唤醒正在等待 progress/result 的 generator。若命令无输出或轮询没有再次触发,主 REPL 会继续等待,输入循环无法释放。

## 修复方案
在 foreground task 自动后台化成功后,立即 resolve 当前 progress 等待器,让 runShellCommand 能观察到 backgroundShellId 并返回后台任务结果。

## 变更要点
- 在 BashTool foreground auto-background 路径补齐 resolveProgress 唤醒逻辑
- 保持已有 spawnBackgroundTask 路径的唤醒行为一致

## 自测
- bun test packages/builtin-tools/src/tools/BashTool/__tests__ 通过
- bun run typecheck 当前仍有仓库既有无关错误,未涉及本次变更
2026-05-14 13:21:58 +08:00
IronRookieCoder
bec72babd8 fix(cursor): handle ANSI wrapped line offset recovery
## Bug 详情
issues.md #41 记录 ctrl+g 编辑长文本后偶现 TextInput 渲染报错,堆栈指向 MeasuredText.measureWrappedText 抛出 Failed to find wrapped line in text,导致输入组件崩溃并影响 ctrl+c 退出。

## 根因
measureWrappedText 依赖 wrapAnsi 输出的 wrapped line 通过 indexOf 反查原文偏移。wrapAnsi 在视觉换行处可能插入 ANSI reset/reopen 或 OSC 控制序列,使 wrapped line 不再是原文的字面切片,反查失败后直接抛错。

## 修复方案
保留原有 indexOf 快路径;当 wrapped line 无法字面匹配时,按原文顺序和显示宽度恢复 start/end offset,并在显示宽度与字符串 offset 的双向转换中跳过 ANSI/OSC 控制序列,避免光标定位落入控制序列内部。

## 变更要点
- 为 MeasuredText 增加 wrapped line fallback offset 恢复逻辑
- 增加 ANSI/OSC 控制序列识别与跳过逻辑
- 修正包含控制序列文本的 display width 与 string offset 双向转换
- 补充 ANSI reset 和 OSC 长文本换行回归测试

## 自测
- bun test src/utils/__tests__/Cursor.test.ts
- bunx biome lint src/utils/Cursor.ts src/utils/__tests__/Cursor.test.ts
- 手动验证 ANSI/OSC 边界 smoke 通过

Refs: #41
2026-05-14 13:11:05 +08:00
geroge
a1dca02b55
Merge pull request #81 from y574444354/fix/raw-dump
feat(rawDump): add raw dump reporting module with local mode and deduplication
2026-05-14 11:34:01 +08:00
林凯90331
dc82486456 feat(rawDump): enable raw dump by default
Change isEnabled() logic so raw dump is on by default unless
explicitly disabled via CSC_DISABLE_RAW_DUMP=1 or
COSTRICT_DISABLE_RAW_DUMP=1.

Signed-off-by: 林凯90331 <90331@sangfor.com>
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 11:22:38 +08:00
林凯90331
12caa6706b perf(rawDump): reduce CPU usage and fix worker spawn reliability
Add session messages and repo info caching to avoid repeated JSONL
parsing and git subprocess spawning across tasks.

Share state across all tasks in a single batch to minimize file lock
contention and JSON parse overhead.

Convert queue operations from sync to async to prevent event loop
blocking in the main process.

Restore inline batch worker fallback when external spawn fails,
and increase worker interval from 30s to 2min to reduce CPU impact.

Add 5s debounce per session+messageID to prevent duplicate enqueues.

Improve binary mode spawn reliability by falling back to node runtime
when bun is not available.

Signed-off-by: 林凯90331 <90331@sangfor.com>
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-14 11:07:02 +08:00
林凯90331
e24ed3b63d feat(rawDump): add raw dump reporting module with local mode and deduplication
Implement the raw dump data reporting module for uploading conversation,
summary, and commit data to the CoStrict endpoint.

Key features:
- Local dump mode for debugging without network
- PID-based file locking to prevent state corruption with multiple csc instances
- 5-minute deduplication window for summary uploads
- Auto-detect sender (user/agent) and conditional user_input
- Repository fields (repo_addr, repo_branch, work_dir) in conversation
- Anonymous interface fallback when auth fails
- Filter commits to current user and limit fetch range
- Skip empty intermediate conversation turns
- Fix worker spawning for build and binary modes
- Remove git diff HEAD fallback to avoid unrelated working tree changes

Signed-off-by: 林凯90331 <90331@sangfor.com>
Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-13 23:49:20 +08:00
y574444354
60856a29bc chore: bump version to 4.0.17 2026-05-13 20:17:39 +08:00
geroge
42107f7d2f
Merge pull request #64 from y574444354/feat/migrate-review-agents
【Review】feat: 将 review skill 迁移到 extract-to-disk 架构
2026-05-13 19:38:26 +08:00
geroge
d3d0dd25d2
Merge pull request #80 from IronRookieCoder/fix/issues-31-32
fix: 修复任务列表数字ID乱序和内存轮询导致滚动跳动
2026-05-13 19:37:25 +08:00
geroge
d8a19f1473
Merge pull request #79 from IronRookieCoder/personal-ironrookiecoder-fix-issue-42-43
fix: merge sub-agent readFileState to prevent cross-agent write confl…
2026-05-13 19:37:09 +08:00
geroge
e570eee02a
Merge pull request #78 from IronRookieCoder/fix/issue-28-costrict-provider
fix: 修复 CoStrict provider 提前停止与 token override 问题
2026-05-13 19:36:34 +08:00
geroge
3cf17ad756
Merge pull request #74 from IronRookieCoder/fix/sdd-design-invalid-tool-params
Fix/sdd design invalid tool params
2026-05-13 19:33:47 +08:00
DoSun
7c2d9654f4 fix: pre-commit hook 改用 bunx 替代 npx 避免 npm arborist 兼容问题 2026-05-13 17:56:18 +08:00
DoSun
8505fce51a feat: 会话满时 LRU 驱逐空闲会话,cloud 命令透传参数 2026-05-13 17:56:18 +08:00
DoSun
40a243a94e
Merge pull request #77 from Askhz/fix/commands-dedup-and-filter
fix: 修复 /agents/commands 接口 duplicate command name 和返回多余 TUI 命令
2026-05-13 16:57:08 +08:00
IronRookieCoder
5ee2d6dcc3 fix: 修复任务列表数字ID乱序和内存轮询导致滚动跳动
两个修复:

1. 任务列表数字ID乱序(#32):新增 compareTaskIds 比较函数,纯数字ID按
   数值大小排序(1, 2, 3, 10 而非 1, 10, 2, 3),非纯数字回退到
   localeCompare 自然排序。listTasks 和 taskStateMessage 两处排序入口
   均已修复。

2. 终端 RSS 内存轮询引发滚动跳动(#31):useRssDisplay hook 新增 isLoading
   参数,仅在加载中启用定时轮询,闲时仅渲染一次内存占用值,避免 Ink 重渲染
   干扰用户滚动查看结果。

附:TaskCreateTool.isConcurrencySafe 改为 false,防止并发任务创建的文件
IO 竞态。

Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-13 16:44:13 +08:00
IronRookieCoder
233971c6ce fix: merge sub-agent readFileState to prevent cross-agent write conflicts
子代理完成后将其 readFileState 合并回主代理缓存,防止主代理写文件时因
缓存过期而误报 FILE_UNEXPECTEDLY_MODIFIED_ERROR。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 16:36:46 +08:00
kingboung
558d0ac9a2 fix: rename SSH secret to MY_SSH_PRIVATE_KEY
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 16:31:09 +08:00
IronRookieCoder
62f4cb9daf fix: 修复 CoStrict provider 提前停止与 token override 问题 2026-05-13 16:24:34 +08:00
kingboung
e63cc84693 chore: trigger CI
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 16:23:40 +08:00
Askhz
750400470e fix: 修复 /agents/commands 接口 duplicate command name 和返回多余 TUI 命令
1. cost/index.ts 重导出 usage/index.ts,COMMANDS() 中移除 cost 避免 BuildManifest 重复校验
2. /command 端点只返回 prompt 类型的 skills 命令,排除 TUI 命令

Co-Authored-By: DeepSeek-V4-Pro-VIP <deepseek-ai@claude-code-best.win>
2026-05-13 16:13:42 +08:00
kingboung
ed513c6292 merge: sync main into feat/migrate-review-agents
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 16:08:01 +08:00
DoSun
c2eb6bff90 fix: 清理 main 分支的 stub .js 文件,恢复有 .ts 源文件的命令模块 2026-05-13 10:36:04 +08:00
DoSun
3bfc695cb4 chore: 清理临时 rebase 脚本 2026-05-13 10:29:34 +08:00
DoSun
3abca0c053 merge: 合并 origin/main 到 feat/server-refactor,解决冲突并保留 server 完整实现 2026-05-13 10:27:14 +08:00
DoSun
f2d2083b94 feat: 添加 CSC_CLOUD_INVOKER 环境变量标识调用来源 2026-05-13 10:05:37 +08:00
DoSun
0755facc63
Merge pull request #75 from Askhz/fix/credentials-path-and-fields
fix: 移除闲置字段id/name,认证文件路径改为~/.costrict/share/auth.json
2026-05-13 09:57:09 +08:00
Askhz
902b7d4ed5 fix: 移除闲置字段id/name,认证文件路径改为~/.costrict/share/auth.json
Co-Authored-By: CoStrict-DeepSeek-V4-Pro <deepseek-ai@claude-code-best.win>
2026-05-13 09:54:40 +08:00
kingboung
167bd1f648 fix: pin CI bun version and regenerate lockfile
CI used bun latest (1.3.13) while local was 1.3.11, causing
frozen-lockfile mismatch. Pin to 1.3.11 and regenerate lockfile.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 09:18:37 +08:00
IronRookieCoder
65e55ac763 Merge remote-tracking branch 'origin' into fix/sdd-design-invalid-tool-params 2026-05-12 21:31:12 +08:00