refactor: consolidate cross-module code duplication - #33
Merged
Conversation
- Delete is-object.ts (duplicate of record-type-guard.ts) - Merge session-temperature-store, session-tools-store, session-model-state into session-state.ts - Merge model-resolution-types into model-resolution-pipeline.ts - Delete model-resolver.ts (resolveModel inlined in categories.ts, resolveModelWithFallback dead code) - Delete opencode-config-dir-types.ts (types inlined into opencode-config-dir.ts) - Update 20+ import paths across the codebase - Clean barrel index.ts (remove dead/duplicate exports) - Migrate 10 consumer files from barrel to direct imports - Update model-resolver tests to use resolveModelPipeline directly
…sAbortError, isRecord, sentinels, formatBytes, status types, getErrorMessage) - delay(): 4 private duplicates consolidated to shared, backward compat via re-export - formatDuration(): duplicate in error-helpers.ts redirected to shared - formatBytes(): extracted from message-builder.ts to shared with tests - sentinels.ts: NOT_CACHED + FALSE_PENDING_RETRY Symbols centralized - isAbortError(): 2 byte-identical implementations consolidated with 7 tests - withTimeout(): 4 implementations consolidated, fixes clearTimeout leak in session-manager - isRecord(): adopted across 11 files, local definitions removed - getErrorMessage(): added to error-formatting.ts, 2 duplicates replaced - TaskStatus type: extracted to shared, 2 consumers updated
The original extractMessage function handled objects with .message, but the shared getErrorMessage replacement didn't. This caused parseModelSuggestion to fail on plain objects with a message field.
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
Consolidated 9 categories of code duplication across the codebase into shared utilities. ~80 net lines removed, 1 bug fixed.
Changes
Verification
tsc --noEmit→ 0 errorsbun run lint→ 0 errorsbun test src/shared/→ 15/15 pass (new tests)