Skip to content

Commit 5a53d83

Browse files
deviosyanclaude
andcommitted
fix: sync outdated stub docs + integrate LSP closeAllFiles with compact
- Remove redundant fork:true and run_in_background params in /fork command - Integrate LSP closeAllFiles() into postCompactCleanup (memory leak #14) - Update 10 docs files: mark implemented features no longer as stubs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c982104 commit 5a53d83

11 files changed

Lines changed: 48 additions & 48 deletions

docs/features/autofix-pr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `/autofix-pr` 命令实现规格文档
22

3-
> **状态**规划阶段(2026-04-29),等待评审通过后进入实施
3+
> **状态**已实现(598 行代码 + 5 个测试文件)
44
> **Worktree**`E:\Source_code\Claude-code-bast-autofix-pr`,分支 `feat/autofix-pr`,基于 `origin/main` 4f1649e2。
55
> **架构**:R(Remote-via-CCR),完整版(含 stop 子命令、单例锁、subscribePR、in-process teammate、skills 探测)。
66

docs/features/bash-classifier.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# BASH_CLASSIFIER — Bash 命令分类器
22

33
> Feature Flag: `FEATURE_BASH_CLASSIFIER=1`
4-
> 实现状态:bashClassifier.ts 全部 Stub,yoloClassifier.ts 完整实现可参考
4+
> 实现状态:bashClassifier.ts 为 ANT-ONLY stub(需要 Anthropic 内部 API);开源版使用 yoloClassifier.ts (1496行) 作为完整替代方案
55
> 引用数:45
66
77
## 一、功能概述

docs/features/coordinator-mode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function isCoordinatorMode(): boolean {
9090

9191
文件:`src/coordinator/workerAgent.ts`
9292

93-
当前为 stub。Worker 实际使用通用 AgentTool 的 `worker` subagent_type。
93+
Worker 使用通用 AgentTool 的 `worker` subagent_type。工具过滤通过 `getWorkerTools()` 排除内部编排工具(TeamCreate/TeamDelete/SendMessage/SyntheticOutput)
9494

9595
### 3.6 数据流
9696

@@ -147,5 +147,5 @@ CLAUDE_CODE_SIMPLE=1 bun run dev
147147
| 文件 | 行数 | 职责 |
148148
|------|------|------|
149149
| `src/coordinator/coordinatorMode.ts` | 370 | 模式检测 + 系统提示 + 用户上下文 |
150-
| `src/coordinator/workerAgent.ts` | | Worker agent 定义(stub|
150+
| `src/coordinator/workerAgent.ts` | 68 | Worker agent 定义(完整|
151151
| `src/constants/tools.ts` || `ASYNC_AGENT_ALLOWED_TOOLS` 工具白名单 |

docs/features/fork-subagent.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Agent({ subagent_type: "general-purpose", prompt: "..." })
3131

3232
### /fork 命令
3333

34-
注册了 `/fork` 斜杠命令(当前为 stub)。当 FORK_SUBAGENT 开启时,`/branch` 命令失去 `fork` 别名,避免冲突。
34+
注册了 `/fork` 斜杠命令。当 FORK_SUBAGENT 开启时,`/branch` 命令失去 `fork` 别名,避免冲突。
3535

3636
## 三、实现架构
3737

@@ -192,4 +192,4 @@ FEATURE_FORK_SUBAGENT=1 bun run dev
192192
| `packages/builtin-tools/src/tools/AgentTool/resumeAgent.ts` || Fork agent 恢复 |
193193
| `src/constants/xml.ts` || XML 标签常量 |
194194
| `src/utils/forkedAgent.ts` || CacheSafeParams + ContentReplacementState 克隆 |
195-
| `src/commands/fork/index.ts` || /fork 命令(stub) |
195+
| `src/commands/fork/index.ts` || /fork 命令 |

docs/features/mcp-skills.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MCP_SKILLS — MCP 技能发现
22

33
> Feature Flag: `FEATURE_MCP_SKILLS=1`
4-
> 实现状态:功能性实现(config 门控筛选器完整,核心 fetcher 为 stub
4+
> 实现状态:完整实现(fetcher + 缓存 + 实时刷新 + 安全措施
55
> 引用数:9
66
77
## 一、功能概述
@@ -86,7 +86,7 @@ const fetchMcpSkillsForClient = feature('MCP_SKILLS')
8686
## 三、关键设计决策
8787

8888
1. **Feature gate 隔离**`feature('MCP_SKILLS')` 守护条件 `require()` 和所有调用点。关闭时无模块加载、无获取操作
89-
2. **资源到技能映射**:技能从 MCP 服务器的 `skill://` URI 资源中发现。`fetchMcpSkillsForClient` 负责转换(当前为 stub
89+
2. **资源到技能映射**:技能从 MCP 服务器的 `skill://` URI 资源中发现。`fetchMcpSkillsForClient` 负责转换(LRU 缓存,20 条目
9090
3. **循环依赖避免**`mcpSkillBuilders.ts` 作为依赖图叶节点,避免 `client.ts ↔ mcpSkills.ts ↔ loadSkillsDir.ts` 循环
9191
4. **服务器能力检查**:技能获取还需要 MCP 服务器支持 resources (`!!client.capabilities?.resources`)
9292

@@ -105,8 +105,8 @@ FEATURE_MCP_SKILLS=1 bun run dev
105105

106106
| 文件 | 状态 | 需要实现 |
107107
|------|------|---------|
108-
| `src/skills/mcpSkills.ts` | Stub | `fetchMcpSkillsForClient()` — 从 MCP 资源列表中筛选 `skill://` URI 并转换为 Command 对象 |
109-
| `src/skills/mcpSkillBuilders.ts` | Stub | 技能构建器注册(避免循环依赖) |
108+
| `src/skills/mcpSkills.ts` | 143 行 | `fetchMcpSkillsForClient()` — 从 MCP 资源列表中筛选 `skill://` URI 并转换为 Command 对象 |
109+
| `src/skills/mcpSkillBuilders.ts` | 45 行 | 技能构建器注册(避免循环依赖) |
110110

111111
## 六、文件索引
112112

@@ -115,4 +115,4 @@ FEATURE_MCP_SKILLS=1 bun run dev
115115
| `src/commands.ts:547-608` | 技能命令过滤 |
116116
| `src/services/mcp/client.ts:117-2358` | 技能获取 + 缓存管理 |
117117
| `src/services/mcp/useManageMCPConnections.ts` | 实时刷新 |
118-
| `src/skills/mcpSkills.ts` | 核心转换逻辑(stub|
118+
| `src/skills/mcpSkills.ts` | 核心转换逻辑(完整实现|

docs/features/web-browser-tool.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# WEB_BROWSER_TOOL — 浏览器工具
22

33
> Feature Flag: `FEATURE_WEB_BROWSER_TOOL=1`
4-
> 实现状态:核心工具已实现,面板为 Stub,布线完整
4+
> 实现状态:核心工具已实现,面板故意为 null(结果在对话中内联显示)
55
> 引用数:4
66
77
## 一、功能概述
@@ -14,7 +14,7 @@ WEB_BROWSER_TOOL 让模型可以启动浏览器实例、导航网页、与页面
1414

1515
| 模块 | 文件 | 状态 |
1616
|------|------|------|
17-
| 浏览器面板 | `packages/builtin-tools/src/tools/WebBrowserTool/WebBrowserPanel.ts` | **Stub**返回 null |
17+
| 浏览器面板 | `packages/builtin-tools/src/tools/WebBrowserTool/WebBrowserPanel.ts` | **Null by design**结果内联显示,不需面板 |
1818
| 浏览器工具 | `packages/builtin-tools/src/tools/WebBrowserTool/WebBrowserTool.ts` | **已实现** |
1919
| REPL 集成 | `src/screens/REPL.tsx` | **布线** — 渲染 WebBrowserPanel |
2020
| 工具注册 | `src/tools.ts` | **布线** — 动态加载 |

docs/features/workflow-scripts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# WORKFLOW_SCRIPTS — 工作流自动化
22

33
> Feature Flag: `FEATURE_WORKFLOW_SCRIPTS=1`
4-
> 实现状态:全部 Stub(7 个文件),布线完整
4+
> 实现状态:已实现 — WorkflowTool (432行), LocalWorkflowTask (212行), WorkflowDetailDialog (103行), 含测试
55
> 引用数:10
66
77
## 一、功能概述

docs/memory-leak-audit.md

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -581,18 +581,11 @@ if (snipResult !== undefined) {
581581

582582
### 问题详情
583583

584-
`LSPServerManager` 中的 `openedFiles: Map<string, string>` 追踪所有通过 `didOpen` 打开的文件。`closeFile()` 方法存在可以发送 `didClose` 通知并清理 Map 条目,但代码注释明确标注:
584+
`LSPServerManager` 中的 `openedFiles: Map<string, string>` 追踪所有通过 `didOpen` 打开的文件。`closeAllFiles()` 方法已实现,在 compaction 后通过 `postCompactCleanup` 自动调用,释放所有 LSP 服务器端的文件状态。
585585

586-
```
587-
NOTE: Currently available but not yet integrated with compact flow.
588-
TODO: Integrate with compact - call closeFile() when compact removes files from context
589-
```
586+
### 修复方式(已完成)
590587

591-
长时间会话中,每次读取/编辑文件都会通过 `openFile()` 添加条目,但 compaction 不会清理这些条目,导致 Map 无限增长。
592-
593-
### 修复方式
594-
595-
1. **添加 `closeAllFiles()` 方法**:遍历 `openedFiles` Map,对每个文件发送 `didClose` 通知,然后清空 Map。Best-effort 错误处理。
588+
1. **`closeAllFiles()` 方法**(LSPServerManager.ts:414):遍历 `openedFiles` Map,对每个文件发送 `didClose` 通知,然后清空 Map。Best-effort 错误处理。
596589

597590
```typescript
598591
async function closeAllFiles(): Promise<void> {
@@ -612,18 +605,16 @@ async function closeAllFiles(): Promise<void> {
612605
}
613606
```
614607

615-
2. **集成到 `postCompactCleanup`**:在 compaction 后自动调用 `closeAllFiles()`释放所有 LSP 服务器端的文件状态
608+
2. **集成到 `postCompactCleanup`**(已完成):在 compaction 后自动调用 `closeAllFiles()`使用 fire-and-forget async 模式(与 sweepFileContentCache 一致)
616609

617610
```typescript
618-
// postCompactCleanup.ts
619-
try {
620-
const lspManager = getLspServerManager()
621-
if (lspManager) {
622-
await lspManager.closeAllFiles()
623-
}
624-
} catch {
625-
// LSP module may not be available in all environments
626-
}
611+
// postCompactCleanup.ts — isMainThreadCompact guard
612+
void import('../lsp/manager.js')
613+
.then(m => {
614+
const manager = m.getLspServerManager()
615+
if (manager) return manager.closeAllFiles()
616+
})
617+
.catch(error => { logError(error) })
627618
```
628619

629620
---
@@ -632,7 +623,7 @@ try {
632623

633624
```
634625
确认已实现 (12): #1 图片 #2 /usage #3 进度消息 #4 空闲渲染 #5 虚拟滚动器 #6 管道输出 #10 MCP缓冲区
635-
已修复 (7): #7 语法加载 #8 NO_FLICKER #9 RC权限 #11 LRU缓存键 #12 snipCompact #17 LSP文件追踪 #18 Permission Polling
626+
已修复 (8): #7 语法加载 #8 NO_FLICKER #9 RC权限 #11 LRU缓存键 #12 snipCompact #14 LSP compact集成 #17 LSP文件追踪 #18 Permission Polling
636627
637628
### 测试覆盖
638629

docs/task/task-004-assistant-session-attach.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
> 来源: [stub-recovery-design-1-4.md](../features/stub-recovery-design-1-4.md) 第 4 项
44
> 优先级: P3
55
> 工作量: Phase 4A 中等,4A-4D 全做完很大
6-
> 状态: Phase 4A DONE, 4B-4D TODO
6+
> 状态: Phase 4A-4D 全部实现 (src/assistant/ 350行, src/commands/assistant/ 完整)
77
88
## 目标
99

src/commands/fork/fork.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,16 @@ export async function call(
3939
}
4040

4141
try {
42-
// Reuse AgentTool logic for fork path.
43-
// Omitting subagent_type triggers implicit fork.
42+
// Omitting subagent_type triggers the fork path in AgentTool:
43+
// isForkSubagentEnabled() && !subagent_type → fork routing → inherits
44+
// parent context + system prompt + model + tools.
45+
// run_in_background is omitted: when fork gate is on, all agents are
46+
// forced async via forceAsync flag (the param is removed from schema).
4447
const input = {
4548
prompt: directive,
46-
fork: true, // 触发 AgentTool 的 fork 路径:继承父会话上下文 + system prompt + 模型
47-
run_in_background: true, // fork always runs async
48-
// description 只显示在底部 selector / BackgroundTasksDialog,保持简短标签
49-
// 即可;用户输入的 prompt 会作为第一条用户消息呈现在主视图里,这里不要
50-
// 重复显示。
5149
description: 'forked from main',
5250
};
5351

54-
// Call AgentTool with proper parameters:
55-
// - input: the agent parameters (no subagent_type => fork path)
56-
// - toolUseContext: the current context (ToolUseContext)
57-
// - canUseTool: permission-check function from context
58-
// - assistantMessage: the last assistant message to fork from
5952
AgentTool.call(input, context, context.canUseTool!, lastAssistantMessage).catch(error => {
6053
logForDebugging(`Fork subagent async error: ${error}`, { level: 'error' });
6154
});

0 commit comments

Comments
 (0)