Skip to content

fix(opencode): resolve LSP dependencies from workspace root#27694

Open
samiralibabic wants to merge 1 commit into
anomalyco:devfrom
samiralibabic:fix/lsp-root-dependency-resolution
Open

fix(opencode): resolve LSP dependencies from workspace root#27694
samiralibabic wants to merge 1 commit into
anomalyco:devfrom
samiralibabic:fix/lsp-root-dependency-resolution

Conversation

@samiralibabic
Copy link
Copy Markdown

@samiralibabic samiralibabic commented May 15, 2026

Issue for this PR

Closes #18694
Addresses #7690

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

OpenCode can be launched from a monorepo root while the language project for a file lives in a child directory. Some built-in LSP servers already detect that child root, but still resolve project-local dependencies from the launch directory.

This changes built-in JS-family LSP dependency resolution to prefer the detected workspace root first, then fall back to the launch directory.

Changes:

  • TypeScript resolves typescript/lib/tsserver.js from the detected root before the launch directory.
  • ESLint resolves eslint from the detected root before the launch directory.
  • Astro resolves TypeScript from the detected root before the launch directory.
  • JS root markers now include package.json, tsconfig.json, and jsconfig.json, not only lockfiles.
  • Missing dependency logs include root, launch directory, and worktree context.

This keeps existing fallback behavior while fixing child-package monorepo layouts.

How did you verify your code works?

  • bun test test/lsp test/config/lsp.test.ts test/tool/lsp.test.ts
  • bun typecheck
  • pre-push typecheck passed: 14 successful, 14 total

Also tested locally with OpenCode launched from a repo root where the TypeScript package lives in a child directory.

Screenshots / recordings

N/A. This is not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 15, 2026
@samiralibabic
Copy link
Copy Markdown
Author

Updated the PR description to match the template.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@samiralibabic samiralibabic force-pushed the fix/lsp-root-dependency-resolution branch from e196a07 to 68c0adb Compare May 15, 2026 09: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.

TypeScript LSP server is not used if package.json is in a sub-directory

1 participant