-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(shared): add connected-providers-cache for improved model availability checking #1121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 10 files
Confidence score: 4/5
- Safe to merge overall; the only noted issue is a medium-severity consistency concern rather than a clear breakage risk.
- In
src/shared/connected-providers-cache.ts, rawJSON.parseis used instead ofparseJsonc/readJsoncFile, which could reduce JSONC compatibility and consistent error handling. - Pay close attention to
src/shared/connected-providers-cache.ts- replace rawJSON.parsewith the shared JSONC parser utilities for consistent behavior.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/shared/connected-providers-cache.ts">
<violation number="1" location="src/shared/connected-providers-cache.ts:45">
P2: Avoid raw JSON.parse in shared utilities; use parseJsonc/readJsoncFile from src/shared/jsonc-parser.ts for consistent JSONC support and error handling.</violation>
<violation number="2" location="src/shared/connected-providers-cache.ts:96">
P2: Avoid raw JSON.parse in shared utilities; use parseJsonc/readJsoncFile from src/shared/jsonc-parser.ts for consistent JSONC support and error handling.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| try { | ||
| const content = readFileSync(cacheFile, "utf-8") | ||
| const data = JSON.parse(content) as ProviderModelsCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Avoid raw JSON.parse in shared utilities; use parseJsonc/readJsoncFile from src/shared/jsonc-parser.ts for consistent JSONC support and error handling.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/connected-providers-cache.ts, line 96:
<comment>Avoid raw JSON.parse in shared utilities; use parseJsonc/readJsoncFile from src/shared/jsonc-parser.ts for consistent JSONC support and error handling.</comment>
<file context>
@@ -0,0 +1,192 @@
+
+ try {
+ const content = readFileSync(cacheFile, "utf-8")
+ const data = JSON.parse(content) as ProviderModelsCache
+ log("[connected-providers-cache] Read provider-models cache", {
+ providerCount: Object.keys(data.models).length,
</file context>
|
|
||
| try { | ||
| const content = readFileSync(cacheFile, "utf-8") | ||
| const data = JSON.parse(content) as ConnectedProvidersCache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Avoid raw JSON.parse in shared utilities; use parseJsonc/readJsoncFile from src/shared/jsonc-parser.ts for consistent JSONC support and error handling.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/connected-providers-cache.ts, line 45:
<comment>Avoid raw JSON.parse in shared utilities; use parseJsonc/readJsoncFile from src/shared/jsonc-parser.ts for consistent JSONC support and error handling.</comment>
<file context>
@@ -0,0 +1,192 @@
+
+ try {
+ const content = readFileSync(cacheFile, "utf-8")
+ const data = JSON.parse(content) as ConnectedProvidersCache
+ log("[connected-providers-cache] Read cache", { count: data.connected.length, updatedAt: data.updatedAt })
+ return data.connected
</file context>
2970a77 to
4f14c12
Compare
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
4f14c12 to
5e2a0f4
Compare
Summary
connected-providers-cacheto cache connected provider informationChanges
connected-providers-cache.tswith cache read/write functionsdata-path.tswith cache directory utilitiesmodel-availability.tsto use provider-models cachemodel-resolver.tsto use connected providers cacheauto-update-checkerto update cache on startupSummary by cubic
Adds a connected providers cache and model whitelist to ensure we only resolve models from providers the user has actually connected. Startup now builds this cache automatically, improving fallback resolution and doctor output.
New Features
Migration
Written for commit 5e2a0f4. Summary will update on new commits.