Skip to content

fix(gemini): resolve companion from nested node_modules in cache#93

Merged
slkiser merged 2 commits into
slkiser:mainfrom
anthonyhaussman:tone/fix/nested_node_modules
May 17, 2026
Merged

fix(gemini): resolve companion from nested node_modules in cache#93
slkiser merged 2 commits into
slkiser:mainfrom
anthonyhaussman:tone/fix/nested_node_modules

Conversation

@anthonyhaussman
Copy link
Copy Markdown
Contributor

Summary

Fix companion plugin resolution issue affecting both opencode-gemini-auth and opencode-antigravity-auth.

When OpenCode caches companion plugins internally, it extracts them into a nested node_modules structure (e.g., ~/.cache/opencode/packages/opencode-gemini-auth@latest/node_modules/opencode-gemini-auth/dist/index.js).
Previously, the opencode-quota companion resolution logic only probed the package root without traversing into this nested node_modules directory.

This caused the resolution to fail and cache an invalid presence state when fallback resolutions were exhausted (which happens after a cache wipe).

This fix updates getRuntimePackageRoots to also yield the nested node_modules/[COMPANION_PACKAGE_NAME] path within the runtime cache directory structure, allowing the resolution logic to correctly locate and load the plugin's credentials.

Linked Issue

This resolves the bug where executing opencode-quota outside the context of a fully initialized OpenCode session (or after
wiping the .cache folder) would fail to resolve locally cached companion plugins.

OpenCode Validation

  • Current production released OpenCode version tested: 1.15.3
  • Why this version is relevant to the fix: The cache structure tested matches the current OpenCode caching mechanism for remote packages.

Quality Checklist

  • I ran pnpm run typecheck
  • I ran pnpm test
  • I ran pnpm run build
  • This is the smallest safe root-cause fix (no unnecessary hook/output mutation logic)
  • I preserved behavioral invariants and updated/added boundary tests as needed
  • I updated docs for user-facing workflow/command/config changes (README.md and CONTRIBUTING.md when applicable)
  • For new API-key/token providers, I started from contributing/provider-template/ or explained why the template does not apply
  • For provider setup/auth wording changes, I checked the relevant dummy .ts template in contributing/provider-template/ and verified README.md against src/lib/provider-metadata.ts (authentication/authFallbacks) and provider auth resolver/diagnostics behavior

@anthonyhaussman anthonyhaussman changed the title fix(gemini): resolve companion from nested node_modules in cache fix(gemini): resolve companion from nested node_modules in cache May 17, 2026
@anthonyhaussman anthonyhaussman marked this pull request as ready for review May 17, 2026 15:13
@slkiser
Copy link
Copy Markdown
Owner

slkiser commented May 17, 2026

@anthonyhaussman Thanks for fix! Could I ask what model(s) you use form Gemini?

@slkiser slkiser merged commit 2ee9f77 into slkiser:main May 17, 2026
4 checks passed
@anthonyhaussman
Copy link
Copy Markdown
Contributor Author

@anthonyhaussman Thanks for fix! Could I ask what model(s) you use form Gemini?

@slkiser, I use the google/gemini-3.1-pro-preview model on my side. ☺️

@anthonyhaussman anthonyhaussman deleted the tone/fix/nested_node_modules branch May 17, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants