feat(cli): support piped prompts for exec - #5
Conversation
1. 移除了自动为对话添加上下文预算提示的逻辑,改为本地实时统计展示 2. 新增ContextUpdated事件和AppState字段跟踪上下文使用情况 3. 在状态栏添加上下文剩余占比指示器,根据剩余比例显示不同颜色 4. 公开ContextConfig::effective_limit方法用于获取有效上下文限制 5. 移除过时的上下文预算提示相关工具函数和测试代码
新增两组测试确保DeepSeek前缀缓存所需的工具列表顺序和JSON序列化结果稳定: 1. 验证MCP工具注册表严格保留工具插入顺序 2. 验证内置+外部工具的输出顺序符合预期且跨构建一致 3. 锁定serde_json序列化始终按字典序排列对象键
重构了Conversation结构体,将计划、目标、技能上下文等临时元数据从消息列表转移到volatile字段中,移除了旧的固定 pinned 系统消息实现: - 新增VolatileContext结构体管理临时上下文数据 - 替换replace_plan_state/goal_state/skill_context为volatile操作 - 添加strip_legacy_pinned_volatile清理历史遗留的pinned消息 - 修改TUI和运行时加载会话的逻辑,自动清理旧格式数据 - 更新上下文压缩逻辑,包含volatile上下文的token计算和状态继承 - 为DeepSeek API提供者添加volatile上下文叠加到最后一条消息的功能 - 重命名测试用例以匹配新的行为逻辑
1. 为Conversation结构体添加rolling_summary字段并初始化 2. 实现resume_conversation从会话历史加载最新滚动摘要 3. 优化摘要生成逻辑,支持基于已有摘要合并更新 4. 新增多项测试验证滚动摘要的处理流程
重构了对话摘要的存储和处理逻辑,将原有的单一流式滚动摘要替换为包含基线和增量更新的结构化摘要状态: 1. 新增SummaryState结构体管理对话摘要的基线和增量更新 2. 替换旧的append_summary接口为append_summary_state,持久化完整摘要状态 3. 实现摘要自动合并机制,当增量超过阈值时重建基线并清空增量 4. 完善会话恢复逻辑,优先加载持久化的结构化摘要状态 5. 清理旧格式的遗留摘要消息 6. 在API调用时正确注入结构化摘要消息到对话上下文 7. 修正上下文压缩时的token计算逻辑,正确统计摘要状态占用
新增了对话摘要缓存功能,实现基于内容寻址的本地缓存来避免重复调用摘要模型;同时添加了本地提取式压缩逻辑,对超长工具输出进行裁剪以减少token消耗,还补充了相关测试用例。
新增完整的摘要渲染指标统计与缓存隔离机制,修复大输出压缩失效问题: 1. 新增`RenderedSummaryDelta`结构体统一管理摘要渲染指标 2. 重构摘要缓存,增加purpose字段区分增量摘要和基线重建 3. 重写工具输出压缩逻辑,按大小分层处理避免主上下文压缩遮蔽规则 4. 新增示例程序验证压缩率达标情况 5. 新增调试遥测输出,方便性能监控
The Round 7 summary renderer compressed huge tool outputs ~95% relative to the raw input, but the old main-context path had already micro-compacted to a smaller size, so under the real API the renderer was more expensive (huge prompt 5644 vs old micro-masked 2252). Head/tail line/char counts alone do not bound rendered bytes (long lines blow past them). Add a hard per-tool byte budget (medium 900B, huge 700B) applied after the line/char extract via char-boundary-safe trim, tighten the tiers (medium 8+6 lines / 384+384 chars, huge 6+4 lines / 320+320 chars), and keep the size metadata (original_bytes / original_lines|chars / omitted) so the summarizer still sees this is truncated evidence. Encode the real-API target as a test: the huge renderer must be no larger than the micro_compact_tool_output baseline. Add summary_render_realapi example to verify against billed aux-model prompt_tokens. Real-API acceptance (deepseek-v4-flash): summary_huge_current_original_renderer = 235 (<= old micro-masked 235; target <=2252) summary_mid_current_renderer = 307 (target <3932) normal main cache hit = 99.2% summary cache second lookup = skips API
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (19)
📝 WalkthroughWalkthroughThis PR refactors ChangesVolatile/Summary State Refactor and Pipeline
stdin Prompt Resolution for orca exec
Sequence Diagram(s)sequenceDiagram
participant Controller/Bridge
participant context.rs
participant micro_compact
participant render_summary_delta
participant summary_cache
participant DeepSeek API
participant deepseek_http.rs
rect rgba(100, 149, 237, 0.5)
note over Controller/Bridge,deepseek_http.rs: Compaction path
Controller/Bridge->>context.rs: compact_with_summary(conversation)
context.rs->>micro_compact: micro_compact_stale_tool_outputs(conversation)
micro_compact-->>context.rs: micro_compacted (volatile/summary preserved)
context.rs->>context.rs: summarize_collapsed_messages(collapsed window)
context.rs->>render_summary_delta: original collapsed messages
render_summary_delta-->>context.rs: RenderedSummaryDelta
context.rs->>summary_cache: lookup(scope, purpose, prev, delta_text)
alt cache miss
context.rs->>DeepSeek API: request_summary(rendered_delta, prev_summary)
DeepSeek API-->>context.rs: assistant_content
context.rs->>summary_cache: store(key, summary)
end
context.rs->>context.rs: rebuild SummaryState baseline/deltas
context.rs-->>Controller/Bridge: updated Conversation (volatile + SummaryState)
Controller/Bridge->>history.rs: append_summary_state(before, after, summary, &conversation.summary)
end
rect rgba(50, 205, 50, 0.5)
note over deepseek_http.rs,DeepSeek API: Per-turn API call
deepseek_http.rs->>deepseek_http.rs: conversation_to_api_messages(conversation)
deepseek_http.rs->>deepseek_http.rs: inject_summary_messages (baseline + deltas) after system msg
deepseek_http.rs->>deepseek_http.rs: append volatile.render() to last message
deepseek_http.rs->>DeepSeek API: POST /chat (enriched messages)
end
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
orca execto read the prompt from piped stdin when no prompt argument is providedorca exec -for explicit stdin prompt mode<stdin>...</stdin>context block when a prompt argument is also presentValidation
cargo test --test exec_jsonl -- --nocapturecargo checkrustfmt --edition 2024 --check src/cli.rs tests/exec_jsonl.rsEvaluation
target/debug/orca: 12/12 passedNotes
cargo fmt --checkstill reports pre-existing formatting drift in untouched files.cargo test --workspacestill fails in unrelatedworkflow_cli_contracttests.Summary by CodeRabbit
New Features
orca execnow supports reading prompts from stdin for headless execution; examples added to documentationRefactor
Tests