Skip to content

fix: prefer .js over .ts when loading plugins for npm compatibility#10

Merged
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-plugin-ts-loading
Mar 24, 2026
Merged

fix: prefer .js over .ts when loading plugins for npm compatibility#10
simongdavies merged 1 commit intohyperlight-dev:mainfrom
simongdavies:fix-plugin-ts-loading

Conversation

@simongdavies
Copy link
Contributor

  • Add resolvePluginSource() helper (prefers .ts in dev, .js under node_modules)
  • Fix schema extraction to prefer .ts source for Rust parser
  • Fix fast-path plugin enable to call loadSource() before enabling
  • Root cause: schema extraction failed on compiled .js, config keys unrecognised, allowedDomains never set

Copilot AI review requested due to automatic review settings March 24, 2026 12:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves plugin loading behavior to be compatible with npm-installed layouts by centralizing “which file to read/import” decisions (.ts vs .js), and adjusts schema extraction and the approved fast-path to avoid misconfigurations (e.g., missing allowedDomains due to schema extraction failures).

Changes:

  • Add resolvePluginSource() and use it for plugin source reads/imports and approval hashing.
  • Update schema extraction to prefer .ts when available, with fallbacks for node_modules/runtime contexts.
  • Ensure approved fast-path loads plugin source before enabling; add targeted tests for resolution behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/plugin-manager.test.ts Adds unit tests covering .ts vs .js resolution rules for dev vs node_modules.
src/plugin-system/manager.ts Introduces resolvePluginSource(), updates hashing/source loading, and adjusts schema extraction + verification path usage.
src/agent/slash-commands.ts Loads plugin source before enabling in the approved fast-path to support subsequent hash verification.
src/agent/index.ts Uses resolvePluginSource() when dynamically importing enabled plugins into the sandbox.

- Add resolvePluginSource() helper (prefers .ts in dev, .js under node_modules)
- Fix schema extraction to prefer .ts source for Rust parser
- Fix fast-path plugin enable to call loadSource() before enabling
- Root cause: schema extraction failed on compiled .js, config keys
  unrecognised, allowedDomains never set

Signed-off-by: Simon Davies <simongdavies@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@simongdavies simongdavies merged commit 0920071 into hyperlight-dev:main Mar 24, 2026
13 checks passed
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