Commit Graph

590 Commits

Author SHA1 Message Date
James Feng
9d9b60432a refactor(acp): make bridge SDK message handling type-safe
- Hide IteratorResult inside nextSdkMessageOrAbort(), return SDKMmessage | undefined
- Add local BridgeSDKMessage discriminated union covering all consumed types
- Replace 18 scattered 'as string'/'as boolean' casts with single entry-point cast
- Preserve Promise.race abort pattern (no bare for-await)
- Fix second forwardSessionUpdates variant too
- All 70 existing tests pass; add tests for abort-during-wait and unknown types

No global SDKMessage change — scope is bridge.ts only.
2026-06-08 19:25:52 +08:00
James Feng
9870abbd83 fix: resolve ~45 more unused-variable alerts across 35+ files
- @ant packages: computer-use-input, computer-use-mcp, computer-use-swift, ink, model-provider
- builtin-tools: AgentTool, BashTool, ExecuteTool, MonitorTool, PowerShellTool, SearchExtraToolsTool, WebSearchTool, bingAdapter, ScheduleCronTool
- Others: acp-link, image-processor-napi, sessionMemory, acp/agent
- UI: PromptInput, Notifications, SearchExtraToolsHint, Spinner, App

Fix ConsoleOAuthFlow.tsx regression from previous batch (doSave was accidentally removed)
2026-06-08 17:30:56 +08:00
James Feng
d20b58fc05 fix: 2 more unused-local-variable — windowMessage.ts, messages.ts
- windowMessage.ts: remove dead CLIPBOARD_THRESHOLD constant and unused pasteViaClipboard()
- messages.ts: remove unused id variable and dead isToolResultMessage()
2026-06-08 17:20:16 +08:00
James Feng
76c47956dd fix: resolve ~50 CodeQL alerts — unused, injection, type issues
unused-local-variable / useless-assignment (~30 alerts):
- mcp-client: manager.ts (11), connection.ts (3)
- acp-link: server.ts (4), rcs-upstream.ts
- remote-control-server: 10 files (SessionDetail, acp/client, transports, etc.)
- src: constants/tools.ts, attribution.ts, win32.ts, main.tsx, attachments.ts

log-injection (2):
- chromeNativeHost.ts, rcs-upstream.ts — apply sanitizeLog()

indirect-command-line-injection (4):
- imagePaste.ts: convert shell:true to explicit sh -c pattern

use-before-declaration (4):
- query.ts, claude.ts, tools.ts, attachments.ts — move feature() import up

comparison-between-incompatible-types (2):
- ExitPlanModePermissionRequest.tsx, useTerminalNotification.ts

shared: sensitive.ts — sanitizeLog() helper
2026-06-08 17:15:22 +08:00
James Feng
2b6cf08c7c fix: resolve 13 trivial-conditional alerts + remove community gemini
Trivial-conditional cleanup (13 alerts auto-closed):
- bashSecurity.ts: remove 3 redundant !inSingleQuote checks
- WebFetchTool/UI.tsx, WebSearchTool/UI.tsx: remove redundant guards
- theme.ts: simplify getStoredTheme() || defaultTheme
- EventStream.tsx: remove dead !replay check
- MCPRemoteServerMenu.tsx: remove redundant isAuthenticating
- managedEnv.ts: remove dead !env guard
- permissionSetup.ts: delete duplicate code block
- marketplaceHelpers.ts: simplify blockedValue || undefined
- toolExecution.ts: remove dead : '' ternary branch
- main.tsx: remove dead dynamicMcpConfig && guard
- attachments.ts: wire up suppressNextDiscovery (set flag before await)

Also: remove abandoned community gemini (src/services/api/gemini/)
and its routing from claude.ts. Upgrade CodeQL to security-and-quality.
2026-06-08 16:29:34 +08:00
James Feng
512144bba2 chore: upgrade CodeQL to security-and-quality suite
Re-enable quality rules (unused-local-variable, trivial-conditional, etc.)
that were previously suppressed. The codebase is no longer raw decompiled
output, so quality alerts should reflect real issues now.

Also reopened all 47 previously dismissed quality alerts (#267-305, #338-341,
#347, #349, #351) so the next scan will re-evaluate them.
2026-06-08 10:25:29 +08:00
James Feng
69224beb0d fix: resolve 4 dismissed CodeQL alerts — URL sanitization + crypto bias
- bingAdapter.ts: fix .hostname.includes('bing.com') → endsWith('.bing.com')
  to prevent evilbing.com bypass (#367, incomplete-url-substring-sanitization)
- Task.ts, LocalMainSessionTask.ts, words.ts: replace modulo bias
  (bytes[i] % length) with rejection sampling using crypto.randomBytes,
  eliminating biased-cryptographic-random alerts (#5, #6, #7)

Validation: bun run check:fix ✓, bunx tsc --noEmit (0 new errors) ✓,
bun run build ✓
2026-06-08 10:23:32 +08:00
James Feng
2249f184ba fix: resolve 17 CodeQL alerts — log injection, command injection, ReDoS
- acp/client.ts: add _sanitize helper with CR/LF escaping to prevent
  js/log-injection in 20 console.log/error calls (15 flagged alerts)
- execFileNoThrowPortable.ts: remove redundant env:process.env from
  execaSync (already inherited by default) — fixes js/indirect-command-line-injection
- toolCalls.ts: replace ambiguous regex [\w.-]* with non-backtracking
  [\w-]*(\.[\w-]*)+ and add 255-char length guard — fixes js/polynomial-redos

Validation: bun run check:fix ✓, bunx tsc --noEmit (0 new errors) ✓,
bun run build ✓
2026-06-08 10:10:29 +08:00
James F
c5b1db2b07
Merge pull request #7 from GhostDragon124/acp
两个问题都修改了:
问题
修复
导入路径不规范
'../modes/store.js'→'src/modes/store.js'
“泄露”措辞
→"publicly available reference document"
2026-06-07 19:50:22 +08:00
James F
b67bb31f6b
Merge branch 'main' into acp 2026-06-07 19:42:25 +08:00
James Feng
6ab6798909 docs: add usage note to CLAUDE_PERSONA — explains YAML activation (CodeRabbit review) 2026-06-07 19:36:02 +08:00
James Feng
420a9a3036 chore: gitignore AGENTS.md (agent协作手册,本地文件) 2026-06-07 19:13:35 +08:00
James Feng
aaa9bf76f2 fix: import path convention + reword persona source comment (CodeRabbit review)
- prompts.ts: use 'src/modes/store.js' alias instead of relative path
- claude.ts: reword 'leaked' to 'publicly available reference document'
2026-06-07 19:02:11 +08:00
James Feng
4aac752bb4 docs: soul-distilled — mode system & Claude persona in README
- New section: 人格模式系统 — 7 modes, /mode command, custom YAML
- Claude persona documented: 70KB Soul Document → 2,848 char distillate
- Sync table: soul-distilled entry with description
2026-06-07 18:26:25 +08:00
James Feng
8f0a6c1806 feat: wire mode persona injection — distilled Claude Soul Document into system prompt
- prompts.ts: add getModePersonaSection() → injects current mode's
  systemPrompt as 'mode_persona' dynamic section (first in order,
  before operational instructions)
- modes/personas/claude.ts: 3KB distilled Claude persona from
  Anthropic's leaked Soul Document (70KB → operational extract):
  core traits, honesty principles, helpfulness/caution balance,
  collaboration stance, identity stability
- Custom mode via ~/.claude/modes/claude.yaml loads seamlessly:
  2848 chars, 7 modes total including the new Claude persona
2026-06-07 18:26:25 +08:00
James Feng
40b75a5648 docs: soul-distilled — mode system & Claude persona in README
- New section: 人格模式系统 — 7 modes, /mode command, custom YAML
- Claude persona documented: 70KB Soul Document → 2,848 char distillate
- Sync table: soul-distilled entry with description
2026-06-07 18:25:27 +08:00
James Feng
9a4365e1f1 feat: wire mode persona injection — distilled Claude Soul Document into system prompt
- prompts.ts: add getModePersonaSection() → injects current mode's
  systemPrompt as 'mode_persona' dynamic section (first in order,
  before operational instructions)
- modes/personas/claude.ts: 3KB distilled Claude persona from
  Anthropic's leaked Soul Document (70KB → operational extract):
  core traits, honesty principles, helpfulness/caution balance,
  collaboration stance, identity stability
- Custom mode via ~/.claude/modes/claude.yaml loads seamlessly:
  2848 chars, 7 modes total including the new Claude persona
2026-06-07 18:22:03 +08:00
James F
5524f4b0dd
Merge pull request #6 from GhostDragon124/acp
CodeQL workflow 文件在 acp 分支上,但不在 main 分支。GitHub 的 Actions 标签页只看 default branch(main)。需要把 c73750bf 这个 commit cherry-pick 到 main,或者把整个 acp 合并到 main。
2026-06-07 17:55:34 +08:00
James Feng
e500d6ffe7 docs: update README for v2.6.11-ccp release
- Add v2.6.11-ccp row in sync table
- Fix tsc count: 22 → 20
- Add 'as any (core)' row: 94 → 1
- Update docs link to local docs/upstream-sync.md
2026-06-07 17:54:36 +08:00
James Feng
f33c1ef84d docs: add comprehensive project assessment report v2.6.11-ccp 2026-06-07 17:54:36 +08:00
James Feng
68064b072c fix: restore CodeQL workflow (accidentally deleted in cleanup)
Restored from commit 3013db2d (upstream cleanup batch).
Updated trigger branches: main → main, acp.
2026-06-07 17:54:36 +08:00
James Feng
4f280b43fe chore: remove spec scaffolding and community links doc
- Delete spec/feature_20260502_F001_fork-agent-redesign/ (3 files)
  Feature merged via ba74e09→e1e23787, recorded in docs/upstream-sync.md
- Delete Friends.md (community blog collection, non-code)
2026-06-07 17:54:36 +08:00
James Feng
09fd58c307 docs: merge upstream sync records and 180-commit audit into upstream-sync.md
Absorb content from:
- 上游同步记录.md (8 chapters of cherry-pick history)
- 上游commit审查清单.md (187 candidate commits reviewed)

Additions to upstream-sync.md (386→958 lines):
- Detailed merge history grouped by category (ACP, cherry-picks, auto-merge, infra)
- Commit-by-commit evaluation (P0/P1/P2/P3/REVIEW, 59 merged + 34 existing + 93 skipped)
- Skip reasons catalog (13 categories)
- Suggested merge order for future cherry-picks
- All merged commits annotated with upstream→CCP hash mapping
- Source attribution header noting absorbed documents
2026-06-07 17:54:36 +08:00
James Feng
d310b78063 docs: add upstream-sync.md, update community-code-issues.md counts
- New docs/upstream-sync.md: comprehensive upstream merge history, version
  alignment, cherry-pick strategy, CCP divergence catalog
- Update community-code-issues.md: tsc 21→20, as any 49→50, add
  client.ts googleAuth as community code
- Revert client.ts googleAuth fix — it's community-introduced
  (google-auth-library version conflict with Anthropic Vertex)
2026-06-07 17:54:36 +08:00
James Feng
a75b83492b fix: eliminate 11 of 12 remaining Anthropic-core as any
MCP schema (6): Add : () => AnyObjectSchema type annotations to
ChannelMessageNotificationSchema, ChannelPermissionNotificationSchema,
AtMentionedSchema, LogEventNotificationSchema. Remove as any at
call sites in print.ts, useManageMCPConnections.ts, useIdeAtMentioned.ts,
vscodeSdkMcp.ts.

Core API (5): Replace as any with specific type assertions in
claude.ts (supportedModels/CachedMCEditsBlock/pinCacheEdits),
filesApi.ts (error property), client.ts (vertexArgs cast).
client.ts:297 retains as any — google-auth-library version conflict
(10.x vs 9.x) with #private nominal typing makes this unavoidable.

Docs: add community-code-issues.md cataloging all 20 community tsc
errors and 49 community as any casts.
2026-06-07 17:54:36 +08:00
James Feng
a93e2bb7ba fix: eliminate all 8 NEEDS_UPSTREAM as any via type annotations and type guards
Group A (4 as any): Add : () => AnyObjectSchema type annotations to
MCP notification schema constants, removing as any at call sites.

Group B (2 as any): Add isStructuredOutputAttachmentMessage type
guard for structured output attachment payloads.

Group C (3 as any): Add isMessageDeltaStreamEvent type guard for
message_delta stream event usage extraction.

tsc: 20 errors (no regression). Build: passes.
2026-06-07 17:54:36 +08:00
James Feng
328acc2b61 docs: update README for v2.6.11-ccp release
- Add v2.6.11-ccp row in sync table
- Fix tsc count: 22 → 20
- Add 'as any (core)' row: 94 → 1
- Update docs link to local docs/upstream-sync.md
2026-06-07 17:52:35 +08:00
James Feng
a7db9df0d5 docs: add comprehensive project assessment report v2.6.11-ccp 2026-06-07 17:47:23 +08:00
James Feng
c73750bf06 fix: restore CodeQL workflow (accidentally deleted in cleanup)
Restored from commit 3013db2d (upstream cleanup batch).
Updated trigger branches: main → main, acp.
2026-06-07 17:40:35 +08:00
James Feng
dc8f68d2ca chore: remove spec scaffolding and community links doc
- Delete spec/feature_20260502_F001_fork-agent-redesign/ (3 files)
  Feature merged via ba74e09→e1e23787, recorded in docs/upstream-sync.md
- Delete Friends.md (community blog collection, non-code)
2026-06-07 17:35:56 +08:00
James Feng
61c80c6963 docs: merge upstream sync records and 180-commit audit into upstream-sync.md
Absorb content from:
- 上游同步记录.md (8 chapters of cherry-pick history)
- 上游commit审查清单.md (187 candidate commits reviewed)

Additions to upstream-sync.md (386→958 lines):
- Detailed merge history grouped by category (ACP, cherry-picks, auto-merge, infra)
- Commit-by-commit evaluation (P0/P1/P2/P3/REVIEW, 59 merged + 34 existing + 93 skipped)
- Skip reasons catalog (13 categories)
- Suggested merge order for future cherry-picks
- All merged commits annotated with upstream→CCP hash mapping
- Source attribution header noting absorbed documents
2026-06-07 17:30:47 +08:00
James Feng
ecfa69749c docs: add upstream-sync.md, update community-code-issues.md counts
- New docs/upstream-sync.md: comprehensive upstream merge history, version
  alignment, cherry-pick strategy, CCP divergence catalog
- Update community-code-issues.md: tsc 21→20, as any 49→50, add
  client.ts googleAuth as community code
- Revert client.ts googleAuth fix — it's community-introduced
  (google-auth-library version conflict with Anthropic Vertex)
2026-06-07 17:19:50 +08:00
James Feng
328ab1ee51 fix: eliminate 11 of 12 remaining Anthropic-core as any
MCP schema (6): Add : () => AnyObjectSchema type annotations to
ChannelMessageNotificationSchema, ChannelPermissionNotificationSchema,
AtMentionedSchema, LogEventNotificationSchema. Remove as any at
call sites in print.ts, useManageMCPConnections.ts, useIdeAtMentioned.ts,
vscodeSdkMcp.ts.

Core API (5): Replace as any with specific type assertions in
claude.ts (supportedModels/CachedMCEditsBlock/pinCacheEdits),
filesApi.ts (error property), client.ts (vertexArgs cast).
client.ts:297 retains as any — google-auth-library version conflict
(10.x vs 9.x) with #private nominal typing makes this unavoidable.

Docs: add community-code-issues.md cataloging all 20 community tsc
errors and 49 community as any casts.
2026-06-07 17:11:26 +08:00
James F
fefd375381
Merge pull request #5 from GhostDragon124/acp
87 个 FIXABLE as any,plus:

**FIXABLE 的典型修复模式:**

| 类型 | 修法 | 涉及 |
|:---|------|:--:|
| 判别联合收窄 | `if (!result.success)` → TS 自动 narrow | 7 个 |
| 扩展接口/类型 | 给 settings/config 类型加缺失字段 | 15 个 |
| `globalThis`/MACRO | 全局类型声明 | 5 个 |
| 组件 prop 类型 | `React.ComponentType<Props>` | 4 个 |
| 原生模块接口 | 声明 optional capability 接口 | 8 个 |
| SDKMessage 收窄 | guard 后访问子属性 | 12 个 |
| 其他(Token/block/函数签名) | 各自适配 | 36 个 |

**NEEDS_UPSTREAM 的 14 个:** MCP schema factory 返回类型(4)+ subagent stream_event 消息类型(5)+ structured_output attachment 类型(2)+ 社区 stream event(3)


| 组 | CCB 能直接用吗 | 价值 |
|---|---|---|
| **A** `: () => AnyObjectSchema` |  同文件同位置 | 消除 4 个 as any,零副作用 |
| **B** `isStructuredOutputAttachmentMessage` |  同文件同位置 | 消除 2 个 as any,附加运行时安全检查 |
| **C** `isMessageDeltaStreamEvent` |  同文件同位置 | 消除 3 个 as any,附加运行时安全检查 |
2026-06-07 16:34:15 +08:00
James Feng
a6406a9573 fix: eliminate all 8 NEEDS_UPSTREAM as any via type annotations and type guards
Group A (4 as any): Add : () => AnyObjectSchema type annotations to
MCP notification schema constants, removing as any at call sites.

Group B (2 as any): Add isStructuredOutputAttachmentMessage type
guard for structured output attachment payloads.

Group C (3 as any): Add isMessageDeltaStreamEvent type guard for
message_delta stream event usage extraction.

tsc: 20 errors (no regression). Build: passes.
2026-06-07 16:24:14 +08:00
James Feng
abde5e813a fix: remove final planned as-any casts 2026-06-07 15:48:33 +08:00
James Feng
ac807aeb08 fix: remove runtime helper as-any casts 2026-06-07 15:45:11 +08:00
James Feng
ba36ca454d fix: remove queued content as-any casts 2026-06-07 15:40:32 +08:00
James Feng
c130eaad4b fix: remove mid-plan as-any casts 2026-06-07 15:33:40 +08:00
James Feng
33a6217702 fix(type): eliminate 26 as any casts (partial batch, Codex interrupted) 2026-06-07 15:27:21 +08:00
James Feng
509b728212 chore: remove 4 dead stub files (ink-elements, ink-jsx, internal-modules, react-compiler-runtime) 2026-06-07 14:48:15 +08:00
James Feng
7019fb8c97 chore: remove dead sdk-stubs.d.ts — all types already in coreTypes.generated.ts 2026-06-07 14:44:33 +08:00
James Feng
3013b05191 fix: add resetAbortController/getAbortSignal to QueryEngine (from upstream CCB) 2026-06-07 14:24:34 +08:00
James F
498e2bcf3c
Merge pull request #4 from GhostDragon124/acp
Acp
2026-06-07 13:26:48 +08:00
James Feng
4a99c68408 docs: update README — v2.6.11, tsc 22 (community), tests 3919 2026-06-07 13:17:59 +08:00
James Feng
7763e93cf0 fix(tsc): Phase 3e (final) — all fixable errors cleared (44→22, only community code remains)
- contextCollapse stubs: fix return types and signatures
- query.ts: add type casts for Message[], Number()
- main.tsx: fix typo selectedBgAgentIndex→selectedIPAgentIndex
- betas.ts: stub getToolSearchBetaHeader
- PromptInput, Message, Messages: add @ts-expect-error / type casts
- prefetch.runner, skillSearch/prefetch, searchExtraTools: as any casts
- processUserInput, commandSuggestions, thinking.test: type narrowing
- effort.ts: xhigh_effort as any
2026-06-07 11:28:54 +08:00
James Feng
2c5010129f fix(tsc): Phase 3d — fix 40 type errors across 15 files (87→47)
- contextCollapse stub: add 5 method stubs
- which.ts: utf-8 → utf8
- convertTools.test.ts, WebSearchTool, SkillTool, AttachmentMessage
- UserTextMessage dynamic require → React.createElement
- openai: AgentId cast, fetchOverride, streaming params
- constants: remove duplicate SYNTHETIC_OUTPUT_TOOL_NAME
2026-06-07 11:19:48 +08:00
James Feng
38dde66af1 fix(tsc): Phase 3c — fix 33 type errors in contextCollapse + UI stubs (120→87) 2026-06-07 11:13:19 +08:00
James Feng
76965c5e8c fix(tsc): Phase 3b — fix 21 type errors in PowerShell/Bash/MCP UI (141→120) 2026-06-07 11:08:03 +08:00
James Feng
2c0a35d04b fix(tsc): Phase 3a — fix 34 type errors in AgentTool/UI.tsx (175→141)
- Add local type assertions (AgentProgressMessage, AgentToolProgressData)
- No as any used — all specific type narrowing
- AgentTool tests: 40 pass, 0 fail
2026-06-07 11:03:08 +08:00