perf(init): pre-compute dir listing and send _prevPhases for cross-phase caching#307
Merged
betegon merged 6 commits intofeat/init-commandfrom Mar 3, 2026
Merged
Conversation
Scans the project directory locally and sends the listing with the initial workflow request. This lets the server's discover-context step skip its list-dir suspend, saving one full round-trip. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Api
Formatters
Other
Internal Changes 🔧Api
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
Codecov Results 📊✅ 108 passed | Total: 108 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 3093 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.23% 82.33% +1.1%
==========================================
Files 121 129 +8
Lines 16711 17502 +791
Branches 0 0 —
==========================================
+ Hits 13574 14409 +835
- Misses 3137 3093 -44
- Partials 0 0 —Generated by Codecov Action |
Combines the precomputed directory listing logic with the createRun() call that was added in the base branch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ry[] directly Extract inline entry shape into a named DirEntry type and add precomputeDirListing() that returns DirEntry[] instead of LocalOpResult, so callers get the entries array directly without type assertions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 tasks
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.
Summary
Two optimizations to reduce round-trips during the init wizard:
Pre-computed directory listing — sends a pre-computed directory listing with the first API call so the server can skip its initial
list-dirsuspend. Saves one full HTTP round-trip in thediscover-contextstep._prevPhasesfor cross-phase caching — tracks per-step result history (stepHistory) and sends_prevPhaseswith each resume payload. This lets the server reuse results from earlier phases (e.g. theread-filesphase can reuse data fromanalyze) without re-requesting them.Changes
precomputeDirListingfromlocal-ops.ts— reuses the existinglistDirfunction with the same params the server would request (recursive, maxDepth 3, maxEntries 500). The wizard runner calls it beforestartAsyncand includes the result asdirListingininputData.stepHistorymap to track accumulated local-op results per step. Each resume payload now includes_prevPhasescontaining results from prior phases of the same step.Companion server change: getsentry/cli-init-api#16
Test plan
bun test test/lib/init/)🤖 Generated with Claude Code