Skip to content

fix(omp): resolve host modules and tokenizer from plugin runtime - #655

Open
randomvariable wants to merge 2 commits into
cortexkit:masterfrom
randomvariable:fix/omp-module-resolution
Open

randomvariable wants to merge 2 commits into
cortexkit:masterfrom
randomvariable:fix/omp-module-resolution

Conversation

@randomvariable

@randomvariable randomvariable commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Refs #657

Fix compiled OMP host-module imports and tokenizer runtime fallback resolution. Preserve package-local tokenizer precedence.

Independent of PR #656. Initial standalone verification: typecheck, build, 29 focused tests. Review regression improvements are in progress.

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no new actionable issues found.

Summary

The PR keeps host-package imports available for OMP to resolve at runtime and adds tokenizer lookup paths for plugin installs.

  • OMP can resolve its session API from either host package.
  • Token counts can find the plugin’s tokenizer under compiled hosts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["preloadTokenizer()"] --> B["Load relative to import.meta.url"]
  B -->|Succeeds| C["Use tokenizer"]
  B -->|Fails| D["Probe project and OpenCode cache"]
  D --> E["Probe argv and module ancestors"]
  E --> F["Probe OMP plugin tree"]
  F --> G["Import first matching package"]
  G -->|Succeeds| C
  G -->|Fails| H["Use approximate counts"]
Loading

Reviews (2) · Last reviewed commit: "fix(tokenizer): prove fallback loading a..." · Reviewed by Greptile

@cortexkit-ci

cortexkit-ci Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Design gate skipped: the trivial label is applied.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread packages/plugin/src/hooks/magic-context/read-session-formatting.ts Outdated
@magic-alfonso

magic-alfonso Bot commented Oct 10, 2026

Copy link
Copy Markdown

Thanks for this, and for splitting it from the discovery change.

Before review, please address the open bot finding. Greptile notes that the new tokenizer-roots test may not exercise the fallback: preloadTokenizer() first calls loadTokenizer(), which resolves from import.meta.url regardless of cwd or process.argv[1]. So the test can pass even if the new probe roots are never used. A test that fails without your new roots (for example with the module-relative lookup made to miss) would show the fix does what it says.

Once the finding is resolved, we'll take it through review.

@randomvariable

Copy link
Copy Markdown
Contributor Author

Addressed all three threads in 3b046f4. The runtime fixture forces the primary loader to fail under bun --no-install and proves fallback estimator identity. A second fixture proves the plugin dependency beats a conflicting host-wide copy. Three focused tests, plugin typecheck, and Pi build passed. Negative control with the old probe ordering fails the precedence regression. Refs #657 for maintainer design approval.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

@ualtinok ualtinok added the trivial Typo-class change; exempt from the design-approved gate label Oct 10, 2026
@magic-alfonso

magic-alfonso Bot commented Oct 10, 2026

Copy link
Copy Markdown

Thanks for resolving the findings. I've labelled this trivial and ran it through our merge checks against current master. Two of the new tests fail there, because of a change that landed on master after your branch point, not a problem with your fix.

read-session-formatting.ts now imports a new sibling module, ./token-count-exact (added today for issue 653). Your tokenizer-roots tests copy read-session-formatting.ts into a temporary module tree, so the copy can't resolve that import:

ResolveMessage: Cannot find module './token-count-exact' imported from …/mod/src/hooks/magic-context/read-session-formatting.ts

Affected: "the fallback loads from the plugin tree when the primary loader fails" and "the plugin's own tree outranks the host-wide ~/.omp/plugins copy". Could you rebase onto master and have the fixture copy token-count-exact.ts too, or better, every relative import of the copied file, so the next new import doesn't break it? Once that's green, we'll merge it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trivial Typo-class change; exempt from the design-approved gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants