🔥 chore(sdk): 死代码大扫除第二批——插件装配链/AgentTool 嵌套引擎/死 API 面/死函数群/导出面收敛(#388) - #497
Merged
Conversation
- plugins/loader.ts 收敛为 sidecar 直连三件套:buildCommandToolDefinition + executeSandboxedCommandTool + execCommandTool(含 #317/#227 防护),删除 loadPlugins/loadPluginModule/resolveHooksConfig/normalizeManifestTools/ commandToolFromManifest/LoadedPlugin 等装配簇 - 整删 commands/ 目录:loadCommandDefinitions 恒空存根 + commandDefinitionsToSlashCommands + CommandDefinition 类型 - hooks.ts:删除 shell command 分支与 executeShellHook(shell hook 由宿主 runtime bridge 拥有);HOOK_EVENTS 收敛为 18 个有触发点事件 - agent.ts:拆除 loadedPlugins/loadedCommands/pluginSkillNames 装配字段、 getPluginAgents/getPluginTools/getPluginCommands、reloadPlugins() 方法 - 连带类型/导出/文档:ReloadPluginsResult、Query.reloadPlugins、 QueryController.reloadPlugins、index.ts 导出面、README 事件清单与 reloadPlugins 行、插件信任模型段落改述宿主持有 entry module 执行 - 测试:loader.test.ts 移除 loadPlugins 夹具组,#317 win32 屏蔽与 #201 子进程环境隔离两测试改用 buildCommandToolDefinition 构造器保留活语义 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- agent-tool.ts:删除 call 体(嵌套 QueryEngine 子代理循环)、
registerAgents/clearAgents 注册表、BUILTIN_AGENTS、
TASK_MANAGEMENT_TOOL_NAMES 及全部连带 import;外壳保留
name/description/inputSchema/validateInput/flags,call 改为宿主替换
前的显式 throw(宿主 runtime 以 {...AgentTool, call} 整体覆盖)
- tools/index.ts:删除 splitDeferredTools(唯一生产调用点随 call 体消失)
- agent.ts:删除 registerAgents 装配调用与 import
- index.ts:删除 registerAgents/clearAgents/splitDeferredTools 导出
- 测试:agent-tool.parallel.test.ts 保留外壳 concurrency-safe 钉死与
QueryEngine tool_use_id 注入两条活语义;registry.test.ts 移除
splitDeferredTools 适配器组(CORE_TOOL_NAMES 断言保留)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- query-controller.ts:删除全部 9 个控制委托方法(interrupt/ setPermissionMode/setModel/setMaxThinkingTokens/setCwd/ getInitializationResult/getContextUsage/rewindFiles/stopTask)——宿主 对 query 句柄仅 for-await 迭代,控制操作直连 agent 实例;构造器随之 去掉 methods 参数,保留 asyncIterator + streamInput 输入队列 - agent.ts:buildQueryHandle 不再转发控制方法;删除顶层一次性 query() - types.ts:Query 接口收敛为迭代 + streamInput;删 GetSessionMessagesOptions/GetSessionInfoOptions/SessionMutationOptions - session.ts:删除六个纯死导出(getSessionMessages/appendToSession/ deleteSession/getSessionInfo/renameSession/tagSession)及其私有助手; matchesDir 因 listSessions 活调用而保留 - utils/context.ts 整文件删除(systemPrompt 早退守卫致零可达路径, sidecar 恒传 systemPrompt);engine.ts 回退分支移除 git/AGENT.md context 两段 - index.ts:同步收敛导出面;agent.test.ts 以 loadSession 本地助手替代 被删的 getSessionMessages Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
冲突取舍:main 侧仅保留活语义(getInitializationCommands 简化、 close() 的 #386 lastUsageEngine 释放);死链区域 main 新增的 isInsidePath/commandToolFromManifest/reloadPlugins/getPlugin* 随 A2/A3/A5 删除一并移除;splitDeferredTools 与 LspWorkspaceEditPreview 双侧皆死,取空。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- resumeInterruptedRun/discardInterruptedRun:宿主零调用,sidecar 自建 discardInterruptedRunForThread 复用导出的 buildResumeContinuations/ detectDanglingToolUses,两者导出保留 - stopTask/rewindFiles:宿主零调用;rewind 语义由 sidecar 直用 rewindCheckpoint + agent.getLatestFileCheckpoint 承接 - CODEANY_MODEL env 回退删除(无设置方),连带孤儿 readEnv; CODEANY_HOME 活对(session-store 写 / session.ts 读)保留 - agent-resume.test.ts 随方法整体删除 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- tokens: getTokenCountFromUsage/AUTOCOMPACT_BUFFER_TOKENS/getAutoCompactThreshold - usage: getCachedTokens/calculateAutoCompactThreshold/createAgentProgressTracker (连带孤儿常量与 AgentProgressUsage 依赖) - messages: createUserMessage/createAssistantMessage/extractTextFromContent/ createCompactBoundaryMessage - retry: isAuthError/isRateLimitError/formatApiError 互锁簇整体删除 - fileCache: createFileStateCache 工厂(FileStateCache 类活,保留) - shared 协议面:progressUsage 字段全仓无生产者/消费者, 连同 AgentProgressUsage 接口一并移除 - usage.test.ts 同步删除钉死函数的两段 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 审计 apps/* + packages/shared 对 436 个命名导出的引用, 删除宿主零引用的再导出行(仅删再导出,定义本体不动) - 涵盖:已死子系统残留(registerAgents/clearAgents/splitDeferredTools、 session 六死导出、Context Utilities 块)、MCP 类型群、 skill/plugin 校验器、sandbox 探针类型等 - lumeFileUrl/downloadAndLocalizeImages 仅删再导出行,函数本体 由 web-fetch/image-pipeline 内部继续使用(#342 改判) - README 同步:顶层 query({..}) 示例改写为 createAgent().query()、 Query 控制方法表删除 streamInput/rewindFiles/stopTask 三行、 enableFileCheckpointing 描述改指 getLatestFileCheckpoint Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #388 的剩余批次(第一批 A1+A4 已随 #444 合并)。合并自中断会话的既有成果(A2/A3/A5/B1 三 commit,-2124 行)并续完 B2/B3/C,全批合计约 -3000 行。
批次明细
A2 插件装配链(4a715088e)
plugins/loader.tsloadPlugins 簇、hooks.tsshell 分支与 executeShellHook、agent.ts 装配点、commands 存根A3 AgentTool 收敛为纯外壳(224f5ed67)
A5/B1 Query 控制面 + session 死导出 + context 工具(eac101c36)
A5/B3 续:Agent 死方法 + CODEANY_MODEL 回退(1a1019bad)
B2 死函数群(a69b3aab0)
C index.ts 导出面收敛(d99372afc)
验证
缓做项(不阻塞本批)
Co-Authored-By: Claude Fable 5 noreply@anthropic.com