fix: restore packaged CLI startup#190
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (10)
📝 WalkthroughWalkthroughThis PR marks Changesjsonc-parser externalization and CLI runtime validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| scripts/check-package-runtime.mjs | New smoke-check script that spawns the built CLI with --version and validates the output. Path calculation and version regex are correct; spawn errors are not surfaced in the error message. |
| packages/core/rolldown.config.ts | Adds jsonc-parser to the external list for the Node bundle; the browser bundle entry correctly omits it since browser consumers bundle dependencies themselves. |
| packages/opencode/rolldown.config.ts | Externalizes jsonc-parser consistently with the core and pi packages, preventing re-embedding of the UMD wrapper in the opencode bundle. |
| packages/pi/rolldown.config.ts | Externalizes jsonc-parser consistently with the core and opencode packages. |
| package.json | Wires the smoke-check script into both build and release pipelines so startup regressions fail CI before publishing. |
| packages/core/package.json | Adds jsonc-parser as a runtime dependency, required now that the Node bundle emits it as an external import. |
| packages/core/test/telemetry-source-maps.test.ts | Splits the release-script assertion into two toContain checks to accommodate the new smoke-check step inserted between turbo build and changeset publish; the test's actual guard (sentry scripts absent) is unchanged. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["pnpm build / pnpm release"] --> B["turbo build"]
B --> C["core Node bundle\nexternal: jsonc-parser"]
B --> D["opencode bundle\nexternal: jsonc-parser"]
B --> E["pi bundle\nexternal: jsonc-parser"]
B --> F["cli bundle\nexternal: @caplets/core"]
C & D & E & F --> G["node scripts/check-package-runtime.mjs"]
G --> H{"node packages/cli/dist/index.js --version"}
H -- "exit 0 + semver output" --> I["✅ Smoke check passed"]
H -- "exit ≠ 0 or bad output" --> J["❌ Pipeline fails"]
I --> K["changeset publish\n(release only)"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A["pnpm build / pnpm release"] --> B["turbo build"]
B --> C["core Node bundle\nexternal: jsonc-parser"]
B --> D["opencode bundle\nexternal: jsonc-parser"]
B --> E["pi bundle\nexternal: jsonc-parser"]
B --> F["cli bundle\nexternal: @caplets/core"]
C & D & E & F --> G["node scripts/check-package-runtime.mjs"]
G --> H{"node packages/cli/dist/index.js --version"}
H -- "exit 0 + semver output" --> I["✅ Smoke check passed"]
H -- "exit ≠ 0 or bad output" --> J["❌ Pipeline fails"]
I --> K["changeset publish\n(release only)"]
Reviews (1): Last reviewed commit: "fix: restore packaged CLI startup" | Re-trigger Greptile
| if (result.status !== 0) { | ||
| process.stderr.write("Built Caplets CLI failed to start with --version.\n"); | ||
| if (result.stdout) process.stderr.write(result.stdout); | ||
| if (result.stderr) process.stderr.write(result.stderr); | ||
| process.exit(result.status ?? 1); | ||
| } |
There was a problem hiding this comment.
Spawn errors (e.g.,
ENOENT when packages/cli/dist/index.js doesn't exist because the CLI build step was skipped) are silently absorbed. result.error carries the OS-level message but is never written to stderr, so a "file not found" failure is indistinguishable from a CLI crash in CI logs.
| if (result.status !== 0) { | |
| process.stderr.write("Built Caplets CLI failed to start with --version.\n"); | |
| if (result.stdout) process.stderr.write(result.stdout); | |
| if (result.stderr) process.stderr.write(result.stderr); | |
| process.exit(result.status ?? 1); | |
| } | |
| if (result.error || result.status !== 0) { | |
| process.stderr.write("Built Caplets CLI failed to start with --version.\n"); | |
| if (result.error) process.stderr.write(`${result.error.message}\n`); | |
| if (result.stdout) process.stderr.write(result.stdout); | |
| if (result.stderr) process.stderr.write(result.stderr); | |
| process.exit(result.status ?? 1); | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
The published Caplets CLI can start again after install. The Node bundles now leave
jsonc-parseras a package dependency instead of embedding its UMD wrapper, which was looking for private./impl/*files that are not present in the published dist.This also covers the native OpenCode and Pi packages, which re-bundle core artifacts and could otherwise reintroduce the same startup failure. Build and release now run a packaged CLI smoke check so
caplets --versionfails the pipeline if startup regresses.Validation
pnpm verifypassed from the pre-push hook.node packages/cli/dist/index.js --versionprinted0.25.5locally after the fix.jsonc-parseras a package import instead of containing the failing./impl/formatrequire.Summary by CodeRabbit
caplets --versionworks correctly in the built package.