Repository navigation
Conversation
scripts/patch-release.js required semver at load time with no guard, so a clone without node_modules died with an unformatted MODULE_NOT_FOUND and no RESULT line. The CLI now resolves semver first and exits with a RESULT line naming `npm ci` in the repo root. CONTRIBUTING.md's release section lists the npm ci step. Dispatch-Task: harper-pro-patch-release-deps-preflight Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcQh5MH3dUbrLzfQ5swiXh
The spawned-CLI test asserted the npm ci message from a fixture under TMPDIR. Node still resolves ancestor node_modules and HOME's global folders, so a semver found there would pass the preflight and fail the test for an unrelated reason. The test now sets HOME to the fixture and fails first if semver still resolves from the fixture. The preflight comment drops the narrative and keeps the require() reason. Dispatch-Task: harper-pro-patch-release-deps-preflight Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcQh5MH3dUbrLzfQ5swiXh
The probe-based guard failed whenever a host resolved semver from an ancestor of TMPDIR or a global folder, which made the test depend on the machine's layout. A -r preload now makes require('semver') fail in the child, so the preflight branch runs everywhere. The script comment keeps only the reason for the require.main check.
Dispatch-Task: harper-pro-patch-release-deps-preflight
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JcQh5MH3dUbrLzfQ5swiXh
The test copied the script into a fixture tree, which still inherits ancestor and global module lookup. It now runs scriptPath directly with the preload, and asserts the message names the real repo root. The fixture only holds the preload and is removed only if it was created. The script comment keeps only the reason for the require.main check. Dispatch-Task: harper-pro-patch-release-deps-preflight Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcQh5MH3dUbrLzfQ5swiXh
Dispatch-Task: harper-pro-patch-release-deps-preflight Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JcQh5MH3dUbrLzfQ5swiXh
There was a problem hiding this comment.
Code Review
This pull request introduces a runtime dependency preflight check to scripts/patch-release.js to ensure that the semver package is installed before execution, providing a clear error message to run npm ci if it is missing. It also updates CONTRIBUTING.md with instructions to install dependencies first and adds a comprehensive unit test suite to verify this preflight behavior. There are no review comments, and I have no feedback to provide.
This branch has not been deployed
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.
Authored by Claude Sonnet 5 (dispatch
harper-pro-patch-release-deps-preflight).⊙ Problem
scripts/patch-release.jsloadssemverat module load with no guard. In a fresh release clone with nonode_modules, the script dies with a rawMODULE_NOT_FOUNDstack and never prints aRESULT:line, so neither a human nor a--jsoncaller learns the fix. Seen during the 5.2.0 release cut.💡 Solution
require.resolve('semver')before therequireand, on failure, exits 1 withsemver is not installed. Runnpm ciin <repo root> first.plus aRESULT: {"ok":false,...}line.CONTRIBUTING.mdaddsnpm cibeforenode scripts/patch-release.jsin the release procedure.⚖️ Alternatives
npm ciin CONTRIBUTING.md). Rejected: a run withoutnpm cistill crashes with the raw stack and noRESULT:line.prescript wrapper. Rejected: a second entry point for one script.🔧 Changes
require.resolve('semver')preflight. Look hardest at therequire.main === moduleguard: it keepsrequire()importers throwing instead of exiting their host process.runtime dependency preflighttest. Thehide-semver.cjspreload overridesModule._resolveFilenameso the child failsrequire('semver')on any host.npm cistep in CONTRIBUTING.md.✅ Verification
mocha --require unitTests/unitTestSetup.cjs unitTests/scripts/patchRelease.test.mjs unitTests/scripts/patchReleasePresence.test.mjson93ef0250: 63 passing.36efd7e4:scripts/patch-release.js, fails. The base crashes withCannot find module 'semver'and noRESULT:line.semverabsent: rawMODULE_NOT_FOUNDstack, noRESULT:line. On this branch: thenpm cimessage,RESULT: {"ok":false,...}, exit 1.prettier --checkandoxlint --deny-warningsclean on the changed files.npm run test:unitand integration tests. The change is a script and its test; no build output changes.93ef0250; receipt on the pushed head. Round 1 found one test-isolation minor and two nits, all fixed. Rounds 3–4 drove the switch to the-rpreload and comment trims. One Geminimajor(undefinedtmpdir) was dropped as factually wrong:tmpdiris imported atunitTests/scripts/patchRelease.test.mjs:16.No tracking issue: the bug was found during the 5.2.0 release cut.
🤖 Generated with Claude Code
Related PRs: none found
Review-Coverage: authored=claude; ran=cursor-composer,gemini,codex; adjudicated=domain; declined=cursor-grok,cursor-kimi,cursor-muse; rounds=6; full=2 @ 93ef025
Review-Attention: skim ~12m (decisions: result-line-without-json) @ 93ef025