refactor(shared): apply ensure-directory utility to production code#1859
Open
iyoda wants to merge 8 commits intocode-yeongyu:devfrom
Open
refactor(shared): apply ensure-directory utility to production code#1859iyoda wants to merge 8 commits intocode-yeongyu:devfrom
iyoda wants to merge 8 commits intocode-yeongyu:devfrom
Conversation
There was a problem hiding this comment.
No issues found across 56 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Large changes with 56 files and 1789 lines changed; no guarantee of zero regressions despite no issues found by AI.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1e64b0a to
68af2ef
Compare
- Make model-name-matcher.ts the canonical source for fuzzyMatchModel and normalizeModelName - Export normalizeModelName from model-name-matcher.ts (was internal) - Remove duplicate implementations from model-availability.ts - Add re-exports in model-availability.ts for backward compatibility - All existing consumers continue to work via their import paths - Tests pass, typecheck clean, build succeeds
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Replace inline existsSync + readFileSync + JSON.parse + try/catch patterns with readJsonFile<T>(), and replace writeFileSync(path, JSON.stringify(data, null, 2)) with writeJsonFile(path, data, { ensureDir: true }). Consumers retain domain-specific logging and type conversions. Removes ensureCacheDir() helper from connected-providers-cache.ts as writeJsonFile handles directory creation.
Affected modules:
- src/shared/connected-providers-cache.ts (4 functions refactored)
- src/hooks/rules-injector/storage.ts (2 functions refactored)
- src/hooks/agent-usage-reminder/storage.ts (2 functions refactored)
- src/hooks/interactive-bash-session/storage.ts (2 functions refactored)
- src/shared/index.ts (added json-cache barrel export)
Net: -64 lines (removed 112, added 48)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
- Replace mkdirSync(path, { recursive: true }) with ensureDirectory(path)
- Remove redundant existsSync guards before directory creation
- Add barrel export to src/shared/index.ts
- Updated 13 production files across shared/, features/, cli/, and hooks/
- All tests, typecheck, and build pass
68af2ef to
495dc6f
Compare
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
Apply the
ensureDirectoryutility (from #1858) to 13 production files, replacing rawmkdirSync(path, { recursive: true })calls and removing redundantexistsSyncguards before directory creation.Changes
Updated 13 production files across
shared/,features/,cli/, andhooks/:src/cli/config-manager/ensure-config-directory-exists.tssrc/features/boulder-state/storage.tssrc/features/claude-tasks/storage.tssrc/features/hook-message-injector/injector.tssrc/features/mcp-oauth/storage.tssrc/hooks/claude-code-hooks/todo.tssrc/hooks/claude-code-hooks/transcript.tssrc/hooks/ralph-loop/storage.tssrc/hooks/session-recovery/storage/text-part-injector.tssrc/hooks/session-recovery/storage/thinking-prepend.tssrc/shared/binary-downloader.tssrc/shared/json-cache.tssrc/shared/session-injected-paths.tsAlso added barrel export in
src/shared/index.ts.Net: -14 lines (semantic improvement, redundant guards removed)
Verification
bun run typecheck✅bun test✅ (2693 pass, 0 fail)bun run build✅PR Stack
This is PR 8 of 9 in the code deduplication refactor series. Depends on #1858.
Summary by cubic
Standardized directory creation with ensureDirectory and centralized JSON IO, message dir lookup, and duration formatting. Removed duplicate modules and switched consumers to shared helpers with no behavior changes.
Written for commit 495dc6f. Summary will update on new commits.