Commit Graph

1054 Commits

Author SHA1 Message Date
Askhz
1970c698ea feat(costrict): 根据模型列表动态设置 max_tokens 参数
从 /ai-gateway/api/v1/models 返回的模型信息中读取 maxTokensKey
和 maxTokens 字段,发送请求时动态注入对应参数名和参数值。
maxTokensKey 缺失时默认使用 max_tokens,maxTokens 无值时不传该参数。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 21:23:28 +08:00
DoSun
c147cf7578
Merge pull request #62 from Askhz/fix/server-exe-feature-args
fix(server): 修复 csc.exe server 模式下探针进程因 --feature 参数崩溃导致模型列表为空
2026-05-11 21:02:00 +08:00
Askhz
40dc2720d0 fix(server): 修复 csc.exe server 模式下探针进程因 --feature 参数崩溃导致模型列表为空
Bun 将源码编译为独立可执行文件后,process.argv[1] 变为内部虚拟路径
(B:/~BUN/root/cli.js),该路径含 / 被误判为脚本模式,导致 saveChildSpawnPrefix
为子进程生成 --feature / -d 参数。子进程(csc.exe 本身)不识别这些 Bun
运行时参数,以 exit code 1 退出,探针失败,/provider/capabilities 返回空模型。

修复:
- getScriptArgsForChild: 识别并跳过 Bun snapshot 虚拟路径前缀 (B:/~BUN/, /snapshot/)
- saveChildSpawnPrefix: 仅在 scriptArgs 非空(脚本模式)时才生成 --feature/define 参数
- build.ts: 补充 Step 7 编译独立可执行文件 csc.exe / csc

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 20:59:10 +08:00
kingboung
c431001a4a Merge remote-tracking branch 'origin/main' into feat/migrate-review-agents 2026-05-11 20:54:55 +08:00
kingboung
62efcef508 refactor: consolidate review skill registration and fix command conflicts
- Merge strict:review/strict:security-review into reviewSkills.ts (single
  file registers all four commands: /review, /security-review,
  /strict:review, /strict:security-review)
- Remove conflicting prompt commands from src/commands/ (review.ts,
  security-review.ts) so bundled skills take precedence
- Remove REVIEW_AGENTS import from builtInAgents.ts and mcp.ts
- Remove agent generation logic from generate-review-builtin.ts
- Configure allowedTools and model: 'inherit' per claudecode spec
- Switch test branch to optimize/agent-prompts

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 20:52:18 +08:00
linkai0924
d9bc165378
Merge pull request #61 from y574444354/feat/add-timestamp-to-version
Feat/add timestamp to version
2026-05-11 20:43:26 +08:00
林凯90331
f8d4feee98 feat(rawDump): disable raw dump by default
Invert the enablement logic so raw dump is disabled unless

CSC_DISABLE_RAW_DUMP or COSTRICT_DISABLE_RAW_DUMP is explicitly

set to 0 or false.

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

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-11 20:41:56 +08:00
claude-code-best
89d2c80d78 chore: 2.4.2 2026-05-11 20:37:53 +08:00
林凯90331
e8dca4d3bd feat(cli): add git commit hash and build time to --version output
Include commit short hash and formatted build timestamp in the

version string, matching the output format of cs --version.

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

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-11 20:27:22 +08:00
kingboung
a5235ab03c Merge remote-tracking branch 'origin/main' into feat/migrate-review-agents 2026-05-11 20:21:16 +08:00
kingboung
e3ba147dbe refactor: migrate review system to bundled skill files mechanism
Replace custom extension.ts initialization and agent-based routing with
csc's built-in registerBundledSkill({ files }) mechanism. Review and
security-review skills are now registered with embedded files that
get lazily extracted to disk on first invocation. Locale is resolved
at startup via getResolvedLanguage().

- Remove agent generation from generate-review-builtin.ts (skill-only)
- Remove extension.ts, REVIEW_AGENTS registration, strict:* skills
- Add reviewSkills.ts with registerReviewSkills() for unified registration
- Adapt to new costrict-review index.json format (skills-only, new paths)
- Remove src/costrict/command/locales/ (no longer needed)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 20:19:05 +08:00
linkai0924
ab2195b5d1
Merge pull request #59 from y574444354/feat/package-binary
build(scripts): add bun compile scripts for linux and windows binaries
2026-05-11 17:50:46 +08:00
林凯90331
5515699125 build(scripts): add bun compile scripts for linux and windows binaries
Wrap bun build --compile to produce self-contained executables for linux-x64 (glibc/musl) and windows-x64, each in modern (AVX2) and baseline (SSE2) variants. The build:binary:* aliases run the existing build pipeline first so dist/cli.js post-processing (feature flags, import.meta.require) stays in effect.

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

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-11 17:46:44 +08:00
DoSun
ad2d4508c8
Merge pull request #58 from Askhz/fix/delete-session
fix: DELETE 历史 session 时删除磁盘 transcript 文件
2026-05-11 16:15:27 +08:00
Askhz
0a93873e3d fix: DELETE 历史 session 时删除磁盘 transcript 文件
- PATCH 接口:历史 session 不在内存时不再 404,直接返回成功
- DELETE 接口:历史 session 通过 resolveSessionFilePath 定位并删除磁盘 .jsonl 文件

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 16:11:52 +08:00
DoSun
3aab6fb889 fix: 修复 services/utils 层 strict 模式类型错误
- api/errors: formatAPIError 参数类型适配
- rawDump/logger: 导出可同时作为函数和对象调用的 log
- rawDump/worker: postJson body 类型断言、reduce 泛型标注
- sideQueryOpenAICompat: tool_calls 类型收窄为 FunctionToolCall
2026-05-11 14:33:50 +08:00
DoSun
5d6b31398a fix: strict 模式类型修复 + 恢复 allow-dangerously-skip-permissions 选项
- LogoV2: 抽取 ChannelsNoticeIfLoaded 消除重复,修复 nullability
- main.tsx: 恢复 --allow-dangerously-skip-permissions 选项
- global.d.ts: 添加 doubaoime-asr 模块类型声明
2026-05-11 14:33:44 +08:00
DoSun
c96fe77c45 fix(server): 修复 strict 模式下类型错误
- errors.ts: status 转为 ContentfulStatusCode
- server.ts: BunServer 泛型参数修正
- transcriptReader.ts: 补充 compactMetadata 类型声明
2026-05-11 14:33:37 +08:00
DoSun
799ed96b37 feat(server): prompt 支持 parts/agent 传递,import 迁移至子模块
- session route: ssePrompt 支持 parts 参数,支持 agent mentions
- session route: createSession 支持自定义 session_id
- provider/sessionManager: InitData import 从 types.js 统一导入
2026-05-11 14:33:31 +08:00
DoSun
3ebfb2c05d refactor(server): 拆分 SessionHandle 为三个子模块
- childSpawn.ts: spawn 参数构建、INIT_TIMEOUT_MS、save/loadChildSpawnPrefix
- sessionControlChannel.ts: control response pending 管理
- sessionMessageRouter.ts: stdout 消息路由 + opencode 事件发射
- sessionHandle.ts: 精简为编排层,委托给子模块
- types.ts: 统一导出 InitData/PendingPermission/PendingQuestion
2026-05-11 14:33:23 +08:00
DoSun
7c3d9da000
Merge pull request #57 from y574444354/feat/cloud-question
Feat/cloud question
2026-05-11 14:16:24 +08:00
林凯90331
1ef4182a9e fix(server): resolve merge conflicts with feat/server-refactor
- event.ts: combine /event endpoint with cwdFilter support,
  remove unused /global/event endpoint
- sessionHandle.ts: keep INIT_TIMEOUT_MS, emitOpencodeEvent,
  emitBusyStatus, toPermissionKey and extractPatterns

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-11 13:31:24 +08:00
林凯90331
009e9f0c49 feat(server): opencode-compatible question/permission with AskUserQuestion popup support
- emit opencode-compatible SSE events for questions and permissions
  (flat shape with top-level session_id for wrapEventStream routing)
- adapt question API (/question, /question/:id/reply, /question/:id/reject)
  for AskUserQuestion and elicitation workflows
- fix AskUserQuestion tool name matching and guard against double-wrapped events
- allow requiresUserInteraction tools to ask user even in bypassPermissions mode
- avoid blocking on session init to prevent cold-start timeout
- add /global/event SSE endpoint and cwdFilter support
- add question routes and session handle tests

Co-authored-by: CoStrict <zgsm@sangfor.com.cn>
2026-05-11 12:54:44 +08:00
Askhz
5d288c4290 chore: remove x-anthropic-billing-header from system prompt 2026-05-11 11:47:39 +08:00
y574444354
dbef683bb2 docs: update contributors 2026-05-11 03:45:52 +00:00
linkai0924
6651109d9c
Merge pull request #55 from y574444354/fix/batch-work-issue
fix(rawDump): prevent batch worker concurrency cascade and add fetch …
2026-05-11 11:41:18 +08:00
林凯90331
1240a1a499 fix(rawDump): prevent batch worker concurrency cascade and add fetch timeout
- Add in-process isRunning flag to block reentrant runBatch (file lock
  fails when pid === process.pid)
- Replace setInterval + double immediate trigger with self-scheduling
  setTimeout that only fires after previous batch awaits
- Move clearQueue() to right after readQueue() so any unexpected
  concurrent runBatch sees an empty queue and exits immediately
- Cache repoInfo and workingTreeDiff in processTask, pass into all three
  upload functions to halve git invocations per task
- Add 30s AbortController timeout on postJson fetch so the worker no
  longer hangs indefinitely on unresponsive networks

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 11:34:44 +08:00
Askhz
4dcb3a2107 feat: add agent-type request header to CoStrict provider
在 CoStrict provider 的所有 API 请求中注入 agent-type header,
反映当前会话所使用的 agent 或 skill,默认值为 "build"。

- fetch.ts: createCoStrictFetch 接受可选 agentType 参数,PascalCase
  自动转 kebab-case(StrictSpec → strict-spec),注入 agent-type header
- index.ts: queryModelCoStrict 读取 getMainThreadAgentType()(--agent 启动)
  或 getActiveSkillName()(slash skill 触发)作为 agentType
- models.ts: /v1/models 请求添加 User-Agent: csc/{VERSION} header
- state.ts: 新增 activeSkillName 状态及 getter/setter
- processSlashCommand.tsx: inline skill 和 fork skill(context:fork)
  触发时均调用 setActiveSkillName 记录当前 skill/agent 名
- caches.ts: /clear 时调用 setActiveSkillName(undefined) 重置状态,
  避免新会话继承上一会话的 agent-type

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 11:17:02 +08:00
claude-code-best
2017df72e8 chore: 2.4.1 2026-05-11 10:27:53 +08:00
claude-code-best
4e5d46ce1e docs: update contributors 2026-05-11 01:54:30 +00:00
claude-code-best
bc74d0da62 fix: 修复 CI 中 10 个测试的 Bun mock.module 跨文件污染
- thinking.test.ts: 补 envUtils.js 防御性 mock,提供 isEnvDefinedFalsy
  和 isEnvTruthy 正确实现,覆盖 6 个其他测试文件不完整 mock 导致的污染
- launchLocalVault.test.ts: 补 keychain.js 防御性 mock,强制抛
  KeychainUnavailableError 使 store 走文件回退路径,覆盖 store.test.ts
  和 keychain.test.ts 的 mock 残留

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-11 09:38:13 +08:00
DoSun
434ee9e806 feat: session status 改造为 prompt 级别 busy/idle 三态,SSE 事件和 status 接口按 cwd 过滤
- 新增 SessionBusyStatus 类型(idle/busy/retry),替代进程生命周期状态
- SessionHandle 在 prompt/result/abort/close/error 中追踪 busyStatus 并通过 EventBus 发布 session.status SSE 事件
- /session/status 接口返回扁平 Record<string, SessionBusyStatus>,支持按 cwd 过滤
- EventBus 支持客户端 cwdFilter,SSE 事件按工作空间过滤推送
- sessionManager 在 create/delete 时注册/注销 sessionCwd 映射
2026-05-11 09:26:15 +08:00
claude-code-best
3de1e2c960 fix: 修复 CI test 阶段测试失败时不退出的 bug
将 `|| true` 替换为 `set -o pipefail`,使管道中 bun test 的非零退出码能正确传播,CI 在测试失败时正确报错。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-11 09:18:09 +08:00
claude-code-best
b85cfc69b7 fix: 修复 Bun mock.module 跨文件污染导致 87 个测试失败
- 重写 setupAxiosMock 使其完全 per-file 独立,消除共享 handles 数组的竞态
- 将 launchSchedule/launchMemoryStores/launchAgentsPlatform 从直接 mock
  源 API 模块改为 mock axios 底层 HTTP 层,避免污染同目录 api.test.ts
- 删除两个 Ink waitUntilExit 超时测试文件
- 修复 hostGuard/keychain 跨文件 mock 污染
- 清理 api.test.ts 中的 require() workaround
- 在 CLAUDE.md 记录 mock 污染排查经验

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-11 08:50:03 +08:00
claude-code-best
8f512c6222 Revert "feat: 添加 GBK 编码自动检测支持,文件读写工具透明处理非 UTF-8 文件"
This reverts commit 0ce8f7a1cb.
2026-05-10 22:57:30 +08:00
claude-code-best
24e55654f6 Revert "fix: 修复非 UTF-8 编码文件读写 round-trip 字节损坏"
This reverts commit 17c06690d8.
2026-05-10 22:57:25 +08:00
claude-code-best
77092f71ab fix: 修复非 UTF-8 编码文件读写 round-trip 字节损坏
GBK 文件编辑后被错误写入为 UTF-8(Buffer.from 不支持 gbk 编码,
encodeString 静默 fallback),latin1/ANSI 文件 0x80-0x9F 范围字节因
TextDecoder('latin1') 与 Buffer.from('latin1') 编解码不对称而被篡改。

修复:latin1 解码改用严格 ISO-8859-1 映射保证与 Buffer.from 对称;
GBK 编码通过 TextDecoder 反向构建查找表实现零依赖编码器。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 22:08:52 +08:00
claude-code-best
121bc61aa2 fix: 修复 issue-template 测试误删 .github/workflows 目录
afterEach 清理时 rmSync 误删了整个 .github/ 目录(含 workflows),
改为只删测试创建的 ISSUE_TEMPLATE 子目录。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 21:11:50 +08:00
claude-code-best
3d91ba033f chore: 2.4.0 2026-05-10 20:50:58 +08:00
claude-code-best
58b58e649d feat: 添加 GBK 编码自动检测支持,文件读写工具透明处理非 UTF-8 文件
新增 encoding.ts 核心模块实现三层编码检测(BOM → UTF-8 fatal → GBK 回退),
改造同步/异步读取路径和写入路径,使 FileReadTool/FileEditTool/FileWriteTool
能正确处理 GBK 编码文件。包含完整单元测试和 spec 文档。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 20:50:12 +08:00
claude-code-best
cfa7872771 fix: 修复 feature 的使用问题 2026-05-10 19:26:57 +08:00
claude-code-best
f928a11078 fix: 移除 auto mode 的 provider 和模型白名单限制
移除 firstParty provider 限制和 claude-(opus|sonnet)-4-[67] 模型白名单,
使所有模型和 provider 在 TRANSCRIPT_CLASSIFIER feature 启用时均可使用 auto mode。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 17:47:38 +08:00
claude-code-best
af0d34ebbe Merge pull request #446 from claude-code-best/feature/prompt-cut-down
feat: 大量系统提示词优化
2026-05-10 15:30:34 +08:00
claude-code-best
c490099b74 Merge pull request #445 from claude-code-best/feature/many-feature-packagee
feat: local memory + local vault wiring + autofix-pr + CI mock isolation (refactor)
2026-05-10 15:30:04 +08:00
claude-code-best
d587372fb5 fix: 进一步脱敏 probe-subscription-endpoints 日志中的 orgUUID
将 orgUUID 截断长度从 8 字符缩减到 4 字符,消除 CodeQL
js/clear-text-logging 对 oauthAccount 敏感数据的告警。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 13:14:22 +08:00
claude-code-best
40cb4b0019 fix: 修复 setupAxiosMock 多测试文件并发时 mock 丢失的问题
mock.module('axios', ...) 是 process-global last-write-wins,多个测试文件
各自注册时只有最后一个 handle 的闭包被保留,导致前面的测试 stub 不生效。
改为全局单例注册,所有 handle 共享一个 mock.module,路由器运行时扫描
活跃 handle 分派请求。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 12:12:25 +08:00
claude-code-best
6a97094464 fix: 脱敏 probe-subscription-endpoints 日志中的 API base URL
使用 URL.origin 替代完整 URL,避免明文泄露 OAuth 配置中的敏感路径信息(CodeQL js/clear-text-logging)。

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 11:40:27 +08:00
claude-code-best
97919755b1 chore: 2.3.0 2026-05-10 11:16:09 +08:00
claude-code-best
d303e1cd9a fix: 代码审查修复 — 安全、性能和正确性
- triggersApi: 添加 assertSubscriptionBaseUrl 防止 OAuth token 泄露
- claude.ts: 修复流式响应 O(n^2) 字符串拼接,改用数组累积
- claude.ts: 移除未使用的 import,动态 import 改为静态 import
- StatusLine: BuiltinStatusLine 仅在 statusLineEnabled 时显示,修复双行问题
- local-vault: 修复 --reveal 标志位置解析 bug
- share: 修复 sk-proj-* OpenAI 密钥未脱敏问题
- store.ts: 临时文件改用同目录创建,避免跨文件系统 rename 失败
- store.ts: 添加空字符串 key 校验
- permissionValidation: 端口正则限制为有效 TCP 范围 0-65535
- 测试 mock 补全: schedule/vault/skill-store 测试文件
- 移除过期的 biome-ignore 注释

Co-Authored-By: glm-5-turbo <zai-org@claude-code-best.win>
2026-05-10 09:39:34 +08:00
Askhz
636e40a991 fix: move undici to dependencies to fix Node.js startup hang when https_proxy is set
When https_proxy is configured, configureGlobalAgents() calls __require("undici")
synchronously. In the npm package, undici was listed as devDependencies and thus
absent from node_modules after installation. Node.js 22 would then attempt to load
its built-in ESM undici via CJS require(), causing an ESM/CJS interop deadlock that
hung the process indefinitely with no way to interrupt it.

Moving undici to dependencies ensures it is installed as a CJS-compatible module,
allowing __require("undici") to resolve correctly under Node.js.
2026-05-10 00:35:18 +08:00