refactor(cli): migrate preflight.js to TypeScript#1262
Merged
cv merged 4 commits intocv/extract-onboard-pure-fnsfrom Apr 1, 2026
Merged
refactor(cli): migrate preflight.js to TypeScript#1262cv merged 4 commits intocv/extract-onboard-pure-fnsfrom
cv merged 4 commits intocv/extract-onboard-pure-fnsfrom
Conversation
Convert bin/lib/preflight.js (357 lines) to src/lib/preflight.ts with full type definitions for all opts objects and return types. The old file becomes a thin re-export shim so existing consumers are unaffected. Changes: - Typed interfaces: PortProbeResult, MemoryInfo, SwapResult, and all opts types (CheckPortOpts, GetMemoryInfoOpts, EnsureSwapOpts) - Extract parseLsofLines helper to reduce duplication in checkPortAvailable - Incorporate #1227 fix: sudo -> sudo -n (non-interactive) for lsof retry - Co-locate tests: test/preflight.test.js -> src/lib/preflight.test.ts converted to expect-style with type narrowing - Add real net probe tests (EADDRINUSE detection on occupied ports) - Fix co-located test imports to go through dist/ for coverage attribution - Add targeted dashboard and validation branch tests for ratchet 612 CLI tests pass. Coverage ratchet passes. No user-facing behavior changes. Relates to #924 (shell consolidation). Supersedes #1227. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The discriminated union types (PortProbeOk | PortProbeConflict) caused TS2339 errors in jsconfig.json type-checking of onboard.js, which accesses .pid/.reason without narrowing. Flatten to a single interface with optional properties. Also fix co-located test imports to use dist/ paths for coverage attribution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
The tsc-js pre-push hook (jsconfig.json) type-checks bin/lib/onboard.js which requires dist/lib/ to exist. CI was not running npm run build:cli before the prek checks, causing TS2307 "Cannot find module" errors. - Add npm run build:cli step to .github/actions/basic-checks - Update tsc-js hook to run build:cli before tsc Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts: # bin/lib/preflight.js
This was referenced Apr 2, 2026
prekshivyas
pushed a commit
that referenced
this pull request
Apr 2, 2026
…eScript (#1298) Move CJS implementations in `bin/lib/` to TypeScript in `src/lib/`, compiled via `tsconfig.src.json` to `dist/lib/`. Replaces the inline CJS with thin re-export shims following the pattern from #1262, #1265. - Add `src/lib/resolve-openshell.ts` with typed DI options interface - Add `src/lib/version.ts` preserving existing getVersion() string API (git describe → .version file → package.json fallback chain) - Add `src/lib/chat-filter.ts` preserving existing array-based API - Add co-located tests importing from `../../dist/lib/` for coverage - Replace `bin/lib/` full implementations with thin shims - Use platform-neutral paths in version tests (node:path join) No API changes — all consumers (bin/nemoclaw.js, scripts/telegram-bridge.js) continue to work without modification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4 tasks
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.
Summary
bin/lib/preflight.js(357 lines) tosrc/lib/preflight.tswith full type definitionsPortProbeResult,MemoryInfo,SwapResult,CheckPortOpts,GetMemoryInfoOpts,EnsureSwapOptsparseLsofLineshelper to reduce duplication incheckPortAvailablesudo→sudo -n(non-interactive) for lsof retrybin/lib/preflight.jsbecomes a thin re-export shim — existing consumers unaffectedtest/preflight.test.js→src/lib/preflight.test.tsdist/paths for coverage attributionStacked on #1240. Not touched by any #924 blocker PR.
Test plan
tsc -p tsconfig.src.jsoncompiles cleanlytsc -p tsconfig.cli.jsontype-checks cleanlytsc -p jsconfig.jsontype-checks cleanly (the pre-push check that caught the union issue)Relates to #924 (shell consolidation). Supersedes #1227.
🤖 Generated with Claude Code