refactor(shared): apply json-cache utility to consumer modules#1857
Open
iyoda wants to merge 6 commits intocode-yeongyu:devfrom
Open
refactor(shared): apply json-cache utility to consumer modules#1857iyoda wants to merge 6 commits intocode-yeongyu:devfrom
iyoda wants to merge 6 commits intocode-yeongyu:devfrom
Conversation
There was a problem hiding this comment.
1 issue found across 42 files
Confidence score: 2/5
- Critical issue:
package.jsondeclaresoh-my-opencodeas its own dependency, which can break installs or create dependency resolution loops - High severity (9/10) with high confidence makes this a likely merge-blocking problem
- Pay close attention to
package.json- remove the self-dependency to avoid install failures
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="package.json">
<violation number="1" location="package.json:65">
P0: Critical self-dependency detected: package lists 'oh-my-opencode' as its own dependency</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
package.json
Outdated
There was a problem hiding this comment.
P0: Critical self-dependency detected: package lists 'oh-my-opencode' as its own dependency
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At package.json, line 65:
<comment>Critical self-dependency detected: package lists 'oh-my-opencode' as its own dependency</comment>
<file context>
@@ -62,6 +62,7 @@
"detect-libc": "^2.0.0",
"js-yaml": "^4.1.1",
"jsonc-parser": "^3.3.1",
+ "oh-my-opencode": "^3.5.5",
"picocolors": "^1.1.1",
"picomatch": "^4.0.2",
</file context>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
50bb0b4 to
80936b5
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)
80936b5 to
b4f34f8
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
json-cacheutility (from #1856) to 4 consumer modules, replacing inlineexistsSync + readFileSync + JSON.parse + try/catchandwriteFileSync + JSON.stringifypatterns.Changes
src/shared/connected-providers-cache.ts— 4 functions refactored, removedensureCacheDir()helpersrc/hooks/rules-injector/storage.ts— 2 functions refactoredsrc/hooks/agent-usage-reminder/storage.ts— 2 functions refactoredsrc/hooks/interactive-bash-session/storage.ts— 2 functions refactoredsrc/shared/index.ts— Addedjson-cachebarrel exportNet: -64 lines (removed 112, added 48)
Verification
bun run typecheck✅bun test✅ (2693 pass, 0 fail)bun run build✅PR Stack
This is PR 6 of 9 in the code deduplication refactor series. Depends on #1856.
Summary by cubic
Applied the shared json-cache utility and centralized helper functions across the codebase to reduce duplication and simplify imports. Unified getMessageDir, formatDuration, and model matching utilities, and removed dead background-task modules.
New Features
Refactors
Written for commit b4f34f8. Summary will update on new commits.