You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(app-components): import tool card helpers from their defining modules - #5548
I have linked a related issue (external PRs: issue must have a maintainer's /approve).(内部重构 PR 1.1,无关联 issue)
I have added tests that prove my feature works.(纯导入路径重构,复用 app-components 现有 1063 个单测与 app-boundaries 门禁验证;移除 bashToolCommand.test.ts 中已过时的 barrel mock)
The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
Ran gen-changesets skill, or this PR needs no changeset.(私有 app-* UI 层内部重构,无用户可感知变化,无需 changeset)
Ran gen-docs skill, or this PR needs no doc update.(不改变用户可见功能,无需更新用户文档)
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
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
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.
Requirement or Bug
packages/app-components/src/chat/tool-calls/下的 16 个工具卡片组件和toolRegistry.ts目前通过包自身的公共桶文件@moonshot-ai/app-components导入参数解析、工具名称/图标、问答解析等纯函数。这会让任意一张工具卡片在运行时静态拉入整个index.ts,与聊天面板、后台管理页共同构成 33 个文件的运行时循环依赖环。本 PR 是 Desktop 分阶段重构的 PR 1.1(紧接 #5543),把这些纯工具导入改为直连真实定义模块,使工具卡片子树彻底退出循环依赖。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路
只修改
chat/tool-calls/内的导入来源,不改动任何组件的模板、逻辑、props 与包对外导出(src/index.ts保持不变)。浏览器相关组件不在本 PR 范围内。因为工具卡片子树不再回指
index.ts,ChatPane.vue等剩余节点无法再经由index.ts → ToolCall.vue回到工具卡片,16 个工具卡片、toolRegistry.ts与ToolCall.vue共 18 个文件一次性退出运行时环。旧路径功能清单与符号映射
index.ts原本只是对这些模块做export *透传,改为直连后拿到的是完全相同的函数绑定:str@moonshot-ai/app-components./toolArgsBackgroundTaskTool、GlobTool、GrepTool、WaitForToolparseArgRecord,str@moonshot-ai/app-components./toolArgsSkillTool、TodoToolstr,urlHost@moonshot-ai/app-components./toolArgsWebFetchToolargFallbackText,parseArgRecord,str@moonshot-ai/app-components./toolArgsBashToolargFilePath,num@moonshot-ai/app-components./toolArgsReadToolargFallbackText,argFilePath,parseArgRecord,pathDirname@moonshot-ai/app-components./toolArgsEditTooltoolLabel@moonshot-ai/app-components../../lib/toolMetaAgentTool、AskUserTool、SwarmTooltoolGlyph,toolLabel@moonshot-ai/app-components../../lib/toolMetaPlanToolcomputerUseArgFields,toolChip,toolGlyph@moonshot-ai/app-components../../lib/toolMetaGenericTooltoolIconName,toolLabel,toolSummary@moonshot-ai/app-components../../lib/toolMetaCronToolnormalizeToolName@moonshot-ai/app-components(经toolMeta.ts原样 re-export)@moonshot-ai/app-core/lib(合并进CronTool已有的同路径导入)CronTool、toolRegistry.tsanswerFor,parseAskBackground,parseAskInput,parseAskOutput,resolveAnswer@moonshot-ai/app-components./askUserToolParseAskUserTool测试与基线
packages/app-components/test/bashToolCommand.test.ts:删除vi.mock('@moonshot-ai/app-components', () => import('../src/chat/tool-calls/toolArgs'))。该 mock 原本用于在单测中拦截 barrel 以避免加载全包;BashTool.vue改为直连./toolArgs后已不再需要,移除后测试直接验证组件在无 barrel mock 下的真实挂载行为。node scripts/checks/app-boundaries.mjs --update与node scripts/checks/ratchet.mjs --update,基线只降不升:chat/tool-calls/的self-package-import:19 → 0(全包剩余 12 处集中在chat/*.vue与admin/*.vue,留给 PR 1.2)。app-components的runtime-cycle成员:33 → 15。import/no-cycle与import/no-duplicates(AskUserTool、CronTool清零)同步下降。阅读指南
先看
packages/app-components/src/chat/tool-calls/CronTool.vue和AskUserTool.vue(唯一涉及多来源拆分/合并的两个文件),其余 15 个文件均为单行 import 路径替换;test/bashToolCommand.test.ts与两个基线 JSON 可略读。Behavior Changes and Affected Users
None。
证据:所有符号均指向
index.ts原本 re-export 的同一模块定义(normalizeToolName在toolMeta.ts中也是export { normalizeToolName }的同一 ESM 绑定);未改动任何分支条件、默认值、模板、样式、src/index.ts公共导出面或契约文件。packages/app-components全部组件与工具解析单测(含bashToolCommand.test.ts、toolCardState.test.ts、askUserToolParse相关用例等)。验证记录
pnpm lint:通过(0 退出)。pnpm --filter kimi-code-app run typecheck:通过(主进程tsc --noEmit与渲染端vue-tsc --noEmit -p tsconfig.renderer.json)。pnpm exec vitest run --reporter=agent packages/app-components packages/app-core/test/activitySummary.test.ts:103 个测试文件、1063 个用例全部通过。pnpm run check:duplication 88553c7d2ccc126ccafccac710d62f09f23455ff:通过,无新增重复片段(refactor(app-components): extract shared tool card and task list setup hooks #5543 抽取公共 hooks 后,本次 import 调整不再触发 jscpd 门禁)。Checklist
/approve).(内部重构 PR 1.1,无关联 issue)app-components现有 1063 个单测与app-boundaries门禁验证;移除bashToolCommand.test.ts中已过时的 barrel mock)gen-changesetsskill, or this PR needs no changeset.(私有app-*UI 层内部重构,无用户可感知变化,无需 changeset)gen-docsskill, or this PR needs no doc update.(不改变用户可见功能,无需更新用户文档)