feat(shared): add ensure-directory utility#1858
Open
iyoda wants to merge 7 commits intocode-yeongyu:devfrom
Open
feat(shared): add ensure-directory utility#1858iyoda wants to merge 7 commits intocode-yeongyu:devfrom
iyoda wants to merge 7 commits intocode-yeongyu:devfrom
Conversation
This was referenced Feb 15, 2026
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
There was a problem hiding this comment.
No issues found across 44 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: Large refactor with 1699 lines changed; despite no issues found by AI, cannot be 100% sure no regressions occurred.
71a3179 to
c87c995
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>
c87c995 to
07d2644
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
Add an
ensureDirectoryutility that wraps the commonmkdirSync(path, { recursive: true })pattern into a semantic, single-purpose function.Changes
src/shared/ensure-directory.ts(9 lines) —ensureDirectory(dirPath: string)src/shared/ensure-directory.test.ts(86 lines) — 5 tests covering creation, idempotency, nested dirsAPI
Verification
bun run typecheck✅bun test✅ (2693 pass, 0 fail)bun run build✅PR Stack
This is PR 7 of 9 in the code deduplication refactor series. Depends on #1857. This PR adds the utility; the next PR (8) applies it to 13 production files.
Summary by cubic
Add ensureDirectory and a json-cache utility to simplify and harden file I/O. Consolidates shared helpers and removes dead modules to reduce duplication and stabilize storage code.
New Features
Refactors
Written for commit 07d2644. Summary will update on new commits.