feat(tools): 工具结果折叠为一行摘要,ctrl+o 展开全文 - #19
Merged
Merged
Conversation
db_query/db_tables/db_discover/db_tools 此前未定义 renderResult, pi 默认把 content 全文展示在页面上,表数量多或 schema 大时刷屏。 新增 tools/tool-result-summary.ts(纯函数,按 details 形状生成中文 摘要,未知形状返回 undefined)+ tools/tool-result-render.ts(薄层 渲染器工厂:isPartial 显示处理中、错误红色展示、展开态全文、折叠态 摘要 + keyHint 提示)。db_tables 的 details 补充 columnCount/ indexCount,db_discover 补充 databaseCount 供摘要使用。渲染器抛错 时 pi 自动回退默认渲染,无兜底负担。
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.
变更内容
LLM 工具(
db_query/db_tables/db_discover/db_tools)此前未定义renderResult,pi 的默认渲染把content全文展示在页面上——表数量多或 schema 大时刷屏。本 PR 给这 4 个常驻工具接入自定义渲染:ctrl+o 展开按键提示(如db_query:42 行 · 8ms(local/test_db))app.tools.expand):完整 content 全文处理中…提示实现方式
tools/tool-result-summary.ts:纯函数(无 pi 导入),按各工具details形状生成摘要,未知形状返回undefined——遵循仓库「逻辑不需要 pi API 时抽成纯函数」约定tools/tool-result-render.ts:薄层renderResult工厂,只在 pi/TUI 边界做颜色与组件封装db_tables的details补充columnCount/indexCount,db_discover补充databaseCount(供摘要使用,字段微小不影响模型上下文)tool-execution自动回退默认渲染,无需兜底注意:
renderResult只影响页面展示,LLM 上下文仍收到完整content(截断策略不变)——如需省 token 是另一个层面的调整。验证
npx tsc --noEmit通过npx vitest run256 个测试全通过(新增tool-result-summary.test.ts15 个用例)npm run lint0 errors(12 个存量 warning,无新增)npm run fmt/fmt:check通过