From 272d06e2bf6e68bc13b3ca2c43a9c4b34331102a Mon Sep 17 00:00:00 2001 From: NagyVikt Date: Fri, 17 Apr 2026 15:06:33 +0200 Subject: [PATCH] Repair gx doctor parser regression and ship follow-up patch release The previous release branch left a missing parseDoctorArgs helper while the active doctor command path still referenced it, causing runtime failure for users immediately after update checks. This patch restores doctor argument parsing, adds a metadata regression assertion for parser presence, and bumps release metadata to 5.0.16 with synced release notes. Constraint: Keep doctor command behavior backward compatible for --target and --strict Rejected: Remove legacy doctor code path in this patch | broader refactor risk in hotfix window Confidence: high Scope-risk: narrow Reversibility: clean Directive: Do not remove doctor parser helpers without updating both doctor entrypoints and tests Tested: node --check bin/multiagent-safety.js; npm test; manual smoke: setup temp repo then gx doctor --target Not-tested: Global npm publish/install path on external host --- README.md | 6 ++++++ bin/multiagent-safety.js | 23 +++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- test/metadata.test.js | 7 +++++++ 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b1ce42a..ec8bee1 100644 --- a/README.md +++ b/README.md @@ -372,6 +372,12 @@ npm pack --dry-run ## Release notes +### v5.0.16 + +- Fixed `gx doctor` runtime crash (`parseDoctorArgs is not defined`) by restoring the doctor argument parser for `--target` and `--strict`. +- Added regression coverage that asserts the doctor parser function exists in `bin/multiagent-safety.js`. +- Bumped package version from `5.0.15` to `5.0.16`. + ### v5.0.15 - Added `gx setup --parent-workspace-view` to generate a parent-folder VS Code workspace (`../-branches.code-workspace`) that shows both the base repo and `.omx/agent-worktrees` in Source Control. diff --git a/bin/multiagent-safety.js b/bin/multiagent-safety.js index 59e11eb..1aa45c0 100755 --- a/bin/multiagent-safety.js +++ b/bin/multiagent-safety.js @@ -927,6 +927,29 @@ function parseSetupArgs(rawArgs, defaults) { return parseCommonArgs(forwardedArgs, setupDefaults); } +function parseDoctorArgs(rawArgs) { + const options = { + target: process.cwd(), + strict: false, + }; + + for (let index = 0; index < rawArgs.length; index += 1) { + const arg = rawArgs[index]; + if (arg === '--target' || arg === '-t') { + options.target = requireValue(rawArgs, index, '--target'); + index += 1; + continue; + } + if (arg === '--strict') { + options.strict = true; + continue; + } + throw new Error(`Unknown option: ${arg}`); + } + + return options; +} + function normalizeWorkspacePath(relativePath) { return String(relativePath || '.').replace(/\\/g, '/'); } diff --git a/package-lock.json b/package-lock.json index 7aedcc1..a3a42b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@imdeadpool/guardex", - "version": "5.0.15", + "version": "5.0.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@imdeadpool/guardex", - "version": "5.0.15", + "version": "5.0.16", "license": "MIT", "bin": { "guardex": "bin/multiagent-safety.js", diff --git a/package.json b/package.json index 8ed2944..3e587c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@imdeadpool/guardex", - "version": "5.0.15", + "version": "5.0.16", "description": "GuardeX: the Guardian T-Rex for your repo, with hardened multi-agent git guardrails.", "license": "MIT", "preferGlobal": true, diff --git a/test/metadata.test.js b/test/metadata.test.js index 1e8613a..7ca4b1e 100644 --- a/test/metadata.test.js +++ b/test/metadata.test.js @@ -75,3 +75,10 @@ test('critical runtime helper scripts stay in sync with templates', () => { ); } }); + +test('doctor CLI parser exists to prevent runtime ReferenceError regressions', () => { + const cliPath = path.join(repoRoot, 'bin', 'multiagent-safety.js'); + const cliSource = fs.readFileSync(cliPath, 'utf8'); + assert.match(cliSource, /function parseDoctorArgs\(rawArgs\)/); + assert.match(cliSource, /const options = parseDoctorArgs\(rawArgs\);/); +});