Skip to content

fix(cli): doctor resolves @opencodehub/sarif as installed pkg, not monorepo path#164

Merged
theagenticguy merged 2 commits into
mainfrom
fix/doctor-sarif-installed-resolution
May 29, 2026
Merged

fix(cli): doctor resolves @opencodehub/sarif as installed pkg, not monorepo path#164
theagenticguy merged 2 commits into
mainfrom
fix/doctor-sarif-installed-resolution

Conversation

@theagenticguy
Copy link
Copy Markdown
Owner

Summary

codehub doctor reported a misleading WARN to end users:

```
│ @opencodehub/sarif build │ WARN │ @opencodehub/sarif not built yet │ run `pnpm -r build` │
```

sarifSchemaCheck probed <repoRoot>/packages/sarif/dist, where repoRoot is guessRepoRoot()'s 4-dirs-up monorepo guess. On a customer npm i -g @opencodehub/cli install there is no packages/sarif/ tree — @opencodehub/sarif is a normal prebuilt node_modules dependency — so stat always threw and the check WARNed "not built yet", telling end users to run pnpm -r build. That command is nonsensical for an installed copy.

This was the last workspace-package doctor check still hard-coded to the monorepo layout. The native-binding checks (duckdb, lbug) already resolve the installed package via resolveFromRoot/createRequire; vendored wasms via resolveVendorWasmsDir/import.meta.resolve. This check was missed.

Fix

  1. Installed deployment first — resolve @opencodehub/sarif's ESM entry via import.meta.resolve and confirm it exists on disk. (sarif's exports map declares only the import condition, so createRequire().resolve() throws ERR_PACKAGE_PATH_NOT_EXPORTED — same reason resolveVendorWasmsDir uses import.meta.resolve.) A resolvable prebuilt entry → ok.
  2. Monorepo source-checkout fallback — keep the packages/sarif/dist probe; this is the only context where the pnpm -r build hint is correct.

Test plan

  • New regression test: with a bogus repoRoot (kills the source fallback), the check still reports ok against the real installed package — proving installed-package resolution.
  • node --test doctor suite: 17/17 pass (dev + compiled dist)
  • Full @opencodehub/cli suite: 263/263 pass
  • tsc --noEmit workspace: clean
  • biome check on changed files: clean

…norepo path

The sarif-build doctor check probed <repoRoot>/packages/sarif/dist, where
repoRoot is guessRepoRoot()'s 4-dirs-up monorepo guess. On a customer npm
install there is no packages/sarif/ tree — @opencodehub/sarif is a normal
prebuilt node_modules dep — so the check always WARNed 'not built yet' and
told end users to run 'pnpm -r build', which is nonsensical for an installed
copy.

Resolve the installed package first via import.meta.resolve (sarif's exports
map declares only the 'import' condition, so createRequire().resolve throws
ERR_PACKAGE_PATH_NOT_EXPORTED — same precedent as resolveVendorWasmsDir). Keep
the packages/sarif/dist probe as the monorepo source-checkout fallback, the
only context where the 'pnpm -r build' hint is correct.

Adds a regression test: with a bogus repoRoot (kills the source fallback) the
check still reports ok against the real installed package.
@theagenticguy theagenticguy enabled auto-merge (squash) May 29, 2026 16:26
@theagenticguy theagenticguy merged commit 2b2b389 into main May 29, 2026
43 of 45 checks passed
@theagenticguy theagenticguy deleted the fix/doctor-sarif-installed-resolution branch May 29, 2026 16:27
@github-actions github-actions Bot mentioned this pull request May 29, 2026
theagenticguy pushed a commit that referenced this pull request May 29, 2026
🤖 Automated release via release-please
---


<details><summary>cli: 0.5.5</summary>

##
[0.5.5](cli-v0.5.4...cli-v0.5.5)
(2026-05-29)


### Bug Fixes

* **cli:** doctor resolves @opencodehub/sarif as installed pkg, not
monorepo path
([#164](#164))
([2b2b389](2b2b389))
* **scanners:** uv-first bandit[sarif] install + pip-audit
pyproject.toml support
([#166](#166))
([5ad02d8](5ad02d8))


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @opencodehub/mcp bumped to 0.4.4
    * @opencodehub/scanners bumped to 0.2.2
</details>

<details><summary>mcp: 0.4.4</summary>

##
[0.4.4](mcp-v0.4.3...mcp-v0.4.4)
(2026-05-29)


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @opencodehub/scanners bumped to 0.2.2
</details>

<details><summary>scanners: 0.2.2</summary>

##
[0.2.2](scanners-v0.2.1...scanners-v0.2.2)
(2026-05-29)


### Bug Fixes

* **scanners:** uv-first bandit[sarif] install + pip-audit
pyproject.toml support
([#166](#166))
([5ad02d8](5ad02d8))
</details>

<details><summary>root: 0.6.6</summary>

##
[0.6.6](root-v0.6.5...root-v0.6.6)
(2026-05-29)


### Bug Fixes

* **cli:** doctor resolves @opencodehub/sarif as installed pkg, not
monorepo path
([#164](#164))
([2b2b389](2b2b389))
* **scanners:** uv-first bandit[sarif] install + pip-audit
pyproject.toml support
([#166](#166))
([5ad02d8](5ad02d8))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant