fix: resolve version 0.0.0 and user CLI load failures (#788)#789
Merged
jackwener merged 1 commit intojackwener:mainfrom Apr 5, 2026
Merged
Conversation
Bug 1: version.ts used a single-level parent lookup for package.json, which broke after jackwener#784 changed rootDir from "src" to "." (version.js now lives in dist/src/ instead of dist/). Walk up until package.json is found — works in both dev (src/) and prod (dist/src/). Bug 2: adapters copied to ~/.opencli/clis/ import ../../src/registry.js etc., which resolves to ~/.opencli/src/. Derive src/ compat shims from the existing rootShims list so these imports resolve correctly.
jackwener
approved these changes
Apr 5, 2026
Owner
jackwener
left a comment
There was a problem hiding this comment.
LGTM. Both fixes are correct and minimal:
- version.ts: Walk up one more level to find package.json — handles both dev (src/) and prod (dist/src/) layouts correctly.
- discovery.ts: Add src/ compat shims — adapters compiled with rootDir '.' produce
../../src/registry.jsimports, which resolve to~/.opencli/src/registry.js. Creating shims there fixes the load failures.
Verified by rebuilding: dist/clis/36kr/hot.js indeed imports from ../../src/registry.js, confirming the root cause.
Closes #788, also fixes #791 (same underlying issue on Windows).
This was referenced Apr 5, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #788. Two regressions introduced by #784 (
rootDirchange from"src"to"."):package.jsonbroke becauseversion.jsnow lives indist/src/instead ofdist/. Added fallback to walk up one more level whenpackage.jsonisn't found at the first parent.~/.opencli/clis/import../../src/registry.jsetc., which resolves to~/.opencli/src/. Addedsrc/compat shims derived from the existingrootShimslist (single source of truth, no duplicate mapping).Related issue: #788
Type of Change
Checklist
Screenshots / Output
version.ts fix (prod mode):
```
$ node dist/src/version.js
version: 1.6.3
```
src/ shims generated:
```
~/.opencli/src/
errors.js
launcher.js
logger.js
registry.js
types.js
utils.js
```
Unit tests: 42 files, 496 passed, 1 skipped.