fix: capture undeclared Office bash outputs#1037
Conversation
|
Warning Review limit reached
More reviews will be available in 44 minutes and 9 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR implements automatic discovery and visibility of Office file outputs ( ChangesOffice Output Auto-Discovery
Sequence DiagramsequenceDiagram
participant Ctx as PawWork Context
participant BashTool as Bash Tool
participant WriteHeur as Write Heuristic
participant Discover as Office Discovery
participant FileIO as File I/O
participant TurnChange as Turn-Change Recorder
Ctx->>BashTool: execute officecli command
BashTool->>WriteHeur: isLikelyWriteCommand(cmd)
WriteHeur-->>BashTool: true
BashTool->>Discover: auto-discover if messageID + write-like
Discover->>FileIO: scan workdir for .docx/.xlsx/.pptx
FileIO-->>Discover: file list (deduped, sorted)
Discover-->>BashTool: paths + overflowed flag
BashTool->>FileIO: run command
FileIO-->>BashTool: execution complete
BashTool->>FileIO: re-discover Office outputs post-command
BashTool->>FileIO: read tracked state (binary hash/large marker)
FileIO-->>BashTool: pre/post file states
BashTool->>TurnChange: record write changes (only changed artifacts)
TurnChange-->>Ctx: visible artifacts list
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Code Review
This pull request introduces auto-discovery of undeclared Microsoft Office outputs (.docx, .xlsx, .pptx) for write-like commands in the bash tool, including support for officecli commands. It also updates state preparation for non-restorable files and adds concurrency limits when reading tracked outputs. The review feedback correctly identifies that the file ignore matching in discoverOfficeOutputs uses the command's working directory instead of the project root, which can lead to incorrect ignore behavior in subdirectories, and provides suggestions to pass the project root to fix this.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/opencode/test/tool/bash-write-heuristic.test.ts (1)
60-64: ⚡ Quick winCover the
officecli.exebranch explicitly.
isOfficeCli()now has a separateofficecli.exepath, but these tables only exerciseofficecli. A Windows regression there would pass this suite unnoticed.➕ Minimal coverage addition
"officecli create report.docx", + "officecli.exe create report.docx", "officecli add report.pptx / --type slide", @@ "officecli --version", + "officecli.exe --version", "officecli help docx",Also applies to: 122-128
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/opencode/test/tool/bash-write-heuristic.test.ts` around lines 60 - 64, The test only exercises the "officecli" branch; update the bash-write-heuristic.test.ts tests that build the command lists to also include explicit "officecli.exe" variants (e.g., duplicate the commands "officecli create report.docx", "officecli add ...", etc. with "officecli.exe" instead) so the isOfficeCli() windows path is covered; make the same addition for the other command table later in the file that mirrors lines 122-128 so both branches run.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/opencode/src/tool/bash.ts`:
- Around line 1033-1045: The code currently marks every autoDiscovered run as
uncaptured; compute a boolean like hasUncapturedOutputs (e.g. const
hasUncapturedOutputs = autoDiscovered && artifacts.some(item => !item.changed)
or compare visibleArtifacts.length !== artifacts.length) and use that when
calling turnChange.recordUncaptured instead of plain autoDiscovered; keep the
early return for visibleArtifacts.length === 0 as-is but replace the later if
(autoDiscovered) { yield* turnChange.recordUncaptured(...) } with if
(hasUncapturedOutputs) { yield* turnChange.recordUncaptured({ sessionID:
ctx.sessionID, messageID: ctx.messageID }) } so only runs with genuinely
partial/uncaptured outputs are marked.
---
Nitpick comments:
In `@packages/opencode/test/tool/bash-write-heuristic.test.ts`:
- Around line 60-64: The test only exercises the "officecli" branch; update the
bash-write-heuristic.test.ts tests that build the command lists to also include
explicit "officecli.exe" variants (e.g., duplicate the commands "officecli
create report.docx", "officecli add ...", etc. with "officecli.exe" instead) so
the isOfficeCli() windows path is covered; make the same addition for the other
command table later in the file that mirrors lines 122-128 so both branches run.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b51e99a0-df49-42f8-95b4-cb3863f9063d
📒 Files selected for processing (5)
packages/opencode/src/session/turn-change.tspackages/opencode/src/tool/bash-write-heuristic.tspackages/opencode/src/tool/bash.tspackages/opencode/test/tool/bash-write-heuristic.test.tspackages/opencode/test/tool/bash.test.ts
Summary
Capture undeclared Office outputs created by Bash/OfficeCLI through the existing turn-change path.
.docx,.xlsx, and.pptxwhenexpected_outputsis omitted.expected_outputsas the highest-confidence path.officecliwrite detection to mutating subcommands and keep read-only commands quiet.Why
OfficeCLI can create or modify Office files through Bash without declaring
expected_outputs, which made those deliverables invisible to last-turn changes and session artifacts. The fix keeps Bash as the model-facing tool and registers discovered Office outputs throughturnChange.recordWrite, while preserving the existing uncaptured marker for any unbounded side effects.Related Issue
Closes #1014.
Human Review Status
Pending
Review Focus
Please focus on the Bash auto-discovery boundaries: likely-write gating, traversal budgets, ignored paths, workdir scoping, mixed uncaptured behavior, and binary/non-expandable Office display.
Risk Notes
Auto-discovery is intentionally conservative. Large directories, ignored paths, external paths reached only by command-internal
cd, or over-budget scans degrade to the existing uncaptured marker instead of guaranteeing capture.No visible UI or copy changed, so no screenshot or recording was needed.
How To Verify
Screenshots or Recordings
Not applicable; no visible UI changes.
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.Summary by CodeRabbit
New Features
Improvements