## 背景 enhance-0819.md §P1.1 Spill 策略 (DSH #8) 要 head/tail 预览 + disk locator。 ## 审计结论 Spill 机制**已存在** (名 `persist` 非 `spill`): `src/utils/toolResultStorage.ts` — `persistToolResult` / `maybePersistLargeToolResult` / `enforceToolResultBudget`。spec 大部分项已落地: - ✅ spillStore+policy, maxInlineBytes+MLX 分档 (`getPersistenceThreshold` + `MLX_DEFAULT_MAX_RESULT_SIZE_CHARS=15_000`) - ✅ locator 可读回 (`~/.fusion-code/projects/<cwd>/<sessionId>/tool-results/<id>.{txt,json}` + Read offset/limit) - ✅ 跳读/非文本/已替换, Bash dispatch-log arm (`BashTool.tsx:728-753`), best-effort 永不 isError - ❌ **head/tail 预览** — `generatePreview` (`toolResultStorage.ts:431-447`) head-only。spec 要 head+tail。**真 gap** - ⏳ B 参数分档 (≤3B→4KB 等) — 运行时无 B-param resolver (代码按 context window 分档), 需跨仓 fusion-mlx, 延后单 issue ## 真 gap = tail 预览 MLX 日志工作流实益大 (错误在尾部, 当前 head-only 看不到)。 ## 方案 (surgical) `generatePreview` 截断时同时产 head (60% 预算) + tail (40%), 按行边界切, 非 truncating 时 tailPreview=undefined (向后兼容)。改: - `generatePreview` 返回类型 + tail 逻辑 (`toolResultStorage.ts:431-447`) - `PersistedToolResult` 类型加可选 `tailPreview?: string` (`:94-100`) - `buildLargeToolResultMessage` 有 tail 时插 head + 省略标记 + tail (`:202-212`) - 3 调用点同步: `toolResultStorage.ts:188`, `BashTool.tsx:592`, `PowerShellTool.tsx:401` - 新单测 `src/__tests__/services/tools/toolResultStoragePreview.test.ts` ## 验收 typecheck 0, 全测无回归, build + build:dev:full pass, 大输出含 head+tail 两段预览 + locator, locator 可 Read 回全文。B 参数分档延后单 issue。
Activity