Skip to content

chore(mcp): convert lib/local-branch.js to TypeScript (Phase 2 of #7291) - #7423

Closed
jaytbarimbao-collab wants to merge 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:mcp-local-branch-7329
Closed

chore(mcp): convert lib/local-branch.js to TypeScript (Phase 2 of #7291)#7423
jaytbarimbao-collab wants to merge 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:mcp-local-branch-7329

Conversation

@jaytbarimbao-collab

Copy link
Copy Markdown
Contributor

Summary

Phase 2 of the packages/loopover-mcp TypeScript migration (#7291): convert lib/local-branch.js to real TypeScript, using the tsc build pipeline landed in Phase 1 (#7409).

  • lib/local-branch.jslib/local-branch.ts (592 lines). Types only — runtime behavior is byte-identical. The compiled lib/local-branch.js differs from the original only in tsc formatting, normalized trailing commas, and the elision of an already-dead node:path join import (imported but never called in the original).
  • Strict-mode compliant against the root config's noUncheckedIndexedAccess and exactOptionalPropertyTypes: provably-in-bounds index accesses use non-null assertions (erase at compile time — no new runtime branches), and optional fields that may receive undefined are declared ?: T | undefined.
  • Imports keep their .js extension (NodeNext), matching the Phase 1 files.

Test coverage

lib/local-branch.js shipped a substantial, previously-untested local scorer-preview surface (runExternalScorePreview, classifyScorerExecFailure, setupGuidanceForLocalScorer, probeLocalScorer, normalizeScorerOutput, and helpers). Now that the file is real TypeScript under the 99% patch gate, this PR adds the missing unit coverage:

  • +26 test cases across test/unit/local-scorer-adapter.test.ts (scorer exec-failure classification, JSON-shape parsing, guidance, redaction, timeouts — driven by fixture subprocesses and a selective child_process mock) and test/unit/local-branch.test.ts (git-metadata branch partials via real temp repos: base-ref resolution priorities, remote-tracking SHA, CI hints, typechange status codes, workspace-root normalization).
  • A handful of structurally-unreachable defensive fallbacks (e.g. titleFromBranch is never nullish, git diff -M never emits copy codes) are marked with /* v8 ignore -- <reason> */, matching the pattern already used across the converted packages/loopover-miner/lib TypeScript files.
  • Result: lib/local-branch.ts is at 100% line and branch coverage.

Test adjustment

Removes the now-unused // @ts-expect-error package helper is plain JS ... directives above the dynamic import("../../packages/loopover-mcp/lib/local-branch.js") calls in test/unit/local-branch.test.ts and test/unit/local-scorer-adapter.test.ts — those imports resolved to the untyped plain .js before this conversion and now resolve to the typed .ts source.

Verification

  • npm run build (mcp package): tsc compile + node --check verify both pass.
  • npx vitest run test/unit/local-branch.test.ts test/unit/local-scorer-adapter.test.ts: 99/99 pass; local-branch.ts coverage 100% lines / 100% branch.
  • Root tsc -p tsconfig.json --noEmit: clean.

Closes #7329

…Nbored#7291)

Convert packages/loopover-mcp/lib/local-branch.js to real TypeScript,
using the tsc build pipeline landed in Phase 1 (JSONbored#7409). Types only;
runtime behavior is byte-identical (the compiled lib/local-branch.js
changes only in tsc formatting and the elision of an already-dead
node:path `join` import).

Add unit coverage for the local scorer-preview machinery (previously
untested in the .js) so the newly-typed file clears codecov/patch, and
mark the handful of provably-unreachable defensive fallbacks with
`v8 ignore` directives (the pattern already used across the converted
packages/loopover-miner/lib TypeScript files).

Remove the now-unused `@ts-expect-error package helper is plain JS`
directives above the dynamic local-branch.js imports in
test/unit/local-branch.test.ts and test/unit/local-scorer-adapter.test.ts,
which now resolve to the typed .ts source.

Closes JSONbored#7329

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Issue already completed, closing.

@JSONbored JSONbored closed this Jul 20, 2026
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.34%. Comparing base (fe3a344) to head (bbab76c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7423      +/-   ##
==========================================
+ Coverage   91.27%   91.34%   +0.07%     
==========================================
  Files         716      716              
  Lines       72972    72983      +11     
  Branches    21528    21628     +100     
==========================================
+ Hits        66605    66667      +62     
+ Misses       5327     5272      -55     
- Partials     1040     1044       +4     
Flag Coverage Δ
shard-1 32.63% <53.53%> (-0.02%) ⬇️
shard-2 36.12% <68.77%> (+0.04%) ⬆️
shard-3 34.53% <0.00%> (-0.01%) ⬇️
shard-4 42.89% <0.00%> (-0.01%) ⬇️
shard-5 36.97% <0.00%> (-0.01%) ⬇️
shard-6 33.55% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-mcp/lib/local-branch.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

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.

chore(mcp): convert lib/local-branch.js to TypeScript (Phase 2 of #7291)

2 participants