@boyingliu01/xp-gate 0.41.52 → 0.41.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/doctor.js CHANGED
@@ -25,7 +25,7 @@ const {
25
25
  DELPHI_ROLES,
26
26
  MIN_DISTINCT_MODELS,
27
27
  } = require('./doctor-constants.js');
28
- const { checkUpgrade, formatUpgradeMsg } = require('./check-version.js');
28
+ const { checkUpgrade, formatUpgradeMsg, getRemoteVersion, compareVersions } = require('./check-version.js');
29
29
  const { GATE_CLI_TOOLS, checkCliTool, getToolInstallCmd, checkBash, detectInstalledPlatforms, getSkillsDirs } = require('./detect-deps.js');
30
30
  // Doctor's tool section is built from the shared audit, so the validity /
31
31
  // uniqueness / currency rules live in exactly one place (2026-11-23).
@@ -47,6 +47,17 @@ const { parseQuarantine, findPolicyViolations } = require('./flaky.js');
47
47
  * and stubs are a few hundred bytes. 4 KB separates them comfortably.
48
48
  */
49
49
  const PARSE_CHECK_MIN_BYTES = 4096;
50
+
51
+ /**
52
+ * Upper bound on doctor's version probes (the CLI's own upgrade lookup and the
53
+ * OpenCode plugin's freshness comparison).
54
+ *
55
+ * Both reach the network, and a doctor that waits for a slow registry is worse
56
+ * than one that reports the comparison as incomplete: an `npm view` was measured
57
+ * at ~66 s on a loaded machine, while the answer doctor needs is advisory only.
58
+ * 3 s is the budget the upgrade probe has always used.
59
+ */
60
+ const UPGRADE_PROBE_TIMEOUT_MS = 3000;
50
61
  const {
51
62
  diagnoseTuiRegistration, diagnoseInstalledSkills,
52
63
  fixTuiRegistration, ensureTuiRegistration, readTuiJson,
@@ -3446,32 +3457,133 @@ async function diagnoseUpgrade() {
3446
3457
  } catch { /* non-blocking — don't fail doctor on network issue */ }
3447
3458
  }
3448
3459
 
3460
+ /** The OpenCode plugin package, as installed by `npm install` in ~/.config/opencode. */
3461
+ const OPENCODE_PLUGIN_PKG = '@boyingliu01/opencode-plugin';
3462
+
3449
3463
  /**
3450
- * Check 8: OpenCode plugin version check.
3451
- * @returns {number} issue count
3464
+ * Compare an installed version against the newest published one.
3465
+ *
3466
+ * Field-by-field numeric compare, NOT string ordering: `lexicographic "0.41.9"
3467
+ * > "0.41.10"` would call a current install outdated as soon as the patch level
3468
+ * grows a digit. `check-version.js::compareVersions` is the same rule and is
3469
+ * reused rather than re-implemented, so the two checks cannot disagree.
3470
+ *
3471
+ * @param {string} installed
3472
+ * @param {string} latest
3473
+ * @returns {boolean} true when a newer release exists
3474
+ */
3475
+ function isBehind(installed, latest) {
3476
+ return compareVersions(installed, latest) < 0;
3477
+ }
3478
+
3479
+ /**
3480
+ * Read the installed OpenCode plugin version, or null when it is not installed.
3481
+ *
3482
+ * A manifest that exists but cannot be parsed is reported as an empty version
3483
+ * rather than swallowed: "installed but unreadable" is a different state from
3484
+ * "not installed", and the caller must be able to say so.
3485
+ *
3486
+ * Takes `homeDir` so the lookup is reachable from a test without a real
3487
+ * `~/.config/opencode` install (vitest workers cannot chdir a HOME either).
3488
+ *
3489
+ * @param {string} [homeDir] defaults to the resolved HOME_DIR()
3490
+ * @returns {{version: string}|null}
3491
+ */
3492
+ function readOpenCodePluginVersion(homeDir = HOME_DIR()) {
3493
+ const pluginPath = path.join(homeDir, '.config', 'opencode', 'node_modules', ...OPENCODE_PLUGIN_PKG.split('/'), 'package.json');
3494
+ if (!fs.existsSync(pluginPath)) return null;
3495
+ try {
3496
+ const pluginPkg = JSON.parse(fs.readFileSync(pluginPath, 'utf8'));
3497
+ return { version: typeof pluginPkg.version === 'string' ? pluginPkg.version : '' };
3498
+ } catch {
3499
+ return { version: '' };
3500
+ }
3501
+ }
3502
+
3503
+ /**
3504
+ * Ask the registry for the plugin's newest version, bounded by the probe budget.
3505
+ *
3506
+ * Returns null — never a guessed version — when the lookup fails or runs out of
3507
+ * time. `getRemoteVersion` already resolves null on a network error, but it does
3508
+ * NOT apply the probe budget: `check-version.js` uses its own 5 s socket timeout,
3509
+ * and a socket that opens and then stalls can exceed that. The race makes the
3510
+ * bound explicit at the call site, which is also the documented contract.
3511
+ *
3512
+ * @param {(pkgName: string) => Promise<{latest?: string}|null>} [fetchRemote]
3513
+ * @returns {Promise<string|null>}
3452
3514
  */
3453
- function diagnoseOpenCodePlugin(checks) {
3454
- const pluginPath = path.join(HOME_DIR(), '.config', 'opencode', 'node_modules', '@boyingliu01', 'opencode-plugin', 'package.json');
3455
- if (fs.existsSync(pluginPath)) {
3515
+ async function lookupPluginLatest(fetchRemote = getRemoteVersion) {
3516
+ let timer;
3517
+ const budget = new Promise((resolve) => {
3518
+ timer = setTimeout(() => resolve(null), UPGRADE_PROBE_TIMEOUT_MS);
3519
+ // Never hold the process open on account of a probe.
3520
+ if (typeof timer.unref === 'function') timer.unref();
3521
+ });
3522
+ const lookup = (async () => {
3456
3523
  try {
3457
- const pluginPkg = JSON.parse(fs.readFileSync(pluginPath, 'utf8'));
3458
- const pluginVersion = pluginPkg.version;
3459
- if (pluginVersion) {
3460
- checks.push({ name: 'OpenCode plugin version', status: 'PASS', detail: pluginVersion });
3461
- // Check if plugin is outdated vs xp-gate CLI (they should match)
3462
- const pkgVersion = getPackageVersion();
3463
- if (pkgVersion && pluginVersion !== pkgVersion) {
3464
- checks.push({
3465
- name: 'OpenCode plugin version mismatch',
3466
- status: 'WARN',
3467
- detail: `plugin: ${pluginVersion}, xp-gate CLI: ${pkgVersion} — run 'cd ~/.config/opencode && npm update @boyingliu01/opencode-plugin'`
3468
- });
3469
- return 1;
3470
- }
3471
- }
3472
- } catch { /* skip */ }
3473
- } else {
3524
+ const result = await fetchRemote(OPENCODE_PLUGIN_PKG);
3525
+ return result && typeof result.latest === 'string' ? result.latest : null;
3526
+ } catch {
3527
+ return null;
3528
+ }
3529
+ })();
3530
+ try {
3531
+ return await Promise.race([lookup, budget]);
3532
+ } finally {
3533
+ clearTimeout(timer);
3534
+ }
3535
+ }
3536
+
3537
+ /**
3538
+ * Check 8: OpenCode plugin version (#896).
3539
+ *
3540
+ * The plugin is compared against ITS OWN newest release. It used to be compared
3541
+ * against the xp-gate CLI version, on the assumption that the two "should match";
3542
+ * they are separate packages and do not release in lockstep (the plugin declares
3543
+ * no dependency on the CLI), so on a fully current install the old check warned
3544
+ * forever and prescribed an `npm update` that re-resolves to the same version.
3545
+ *
3546
+ * Three outcomes, and the third is the point: a lookup that produced no answer
3547
+ * is reported as unverified. It is neither PASS (nothing was compared) nor WARN
3548
+ * (nothing is known to be stale) — "not checked" must not be reachable as
3549
+ * "passed", and must not demand an action that may be wrong either.
3550
+ *
3551
+ * Inputs are injectable for the same reason as `diagnoseLanguageTools`: the
3552
+ * decision table is the part worth pinning, and it must be testable without a
3553
+ * real install and without the network.
3554
+ *
3555
+ * @param {Array<{name:string,status:string,detail:string}>} checks
3556
+ * @param {{homeDir?: string, fetchRemote?: Function}} [options]
3557
+ * @returns {Promise<number>} issue count (WARNs only — an unverified comparison is not an issue)
3558
+ */
3559
+ async function diagnoseOpenCodePlugin(checks, options = {}) {
3560
+ const installed = readOpenCodePluginVersion(options.homeDir);
3561
+ if (!installed) {
3474
3562
  checks.push({ name: 'OpenCode plugin', status: 'SKIP', detail: 'Not installed in OpenCode config' });
3563
+ return 0;
3564
+ }
3565
+ if (!installed.version) {
3566
+ checks.push({ name: 'OpenCode plugin version', status: 'WARN', detail: 'installed, but package.json has no readable version' });
3567
+ return 1;
3568
+ }
3569
+ checks.push({ name: 'OpenCode plugin version', status: 'PASS', detail: installed.version });
3570
+
3571
+ const remote = await lookupPluginLatest(options.fetchRemote);
3572
+ if (!remote) {
3573
+ checks.push({
3574
+ name: 'OpenCode plugin version freshness',
3575
+ status: 'SKIP',
3576
+ detail: `comparison not completed — could not reach the registry for ${OPENCODE_PLUGIN_PKG}`,
3577
+ });
3578
+ return 0;
3579
+ }
3580
+ if (isBehind(installed.version, remote)) {
3581
+ checks.push({
3582
+ name: 'OpenCode plugin version',
3583
+ status: 'WARN',
3584
+ detail: `installed ${installed.version}, latest ${remote} — run 'cd ~/.config/opencode && npm update ${OPENCODE_PLUGIN_PKG}'`,
3585
+ });
3586
+ return 1;
3475
3587
  }
3476
3588
  return 0;
3477
3589
  }
@@ -3864,7 +3976,7 @@ async function collectTrailing(checks) {
3864
3976
  } catch {
3865
3977
  // Non-blocking: the upgrade hint is a convenience, never a verdict.
3866
3978
  }
3867
- const trailing = diagnoseOpenCodePlugin(checks);
3979
+ const trailing = await diagnoseOpenCodePlugin(checks);
3868
3980
  const langIssues = diagnoseLanguageTools();
3869
3981
  return { issues: trailing + langIssues, langIssues };
3870
3982
  }
@@ -4979,6 +5091,7 @@ module.exports = {
4979
5091
  runHookAndModuleSync, staleSyncEntries,
4980
5092
  planStaleHookSync, reportBlockedHookSync, refreshSafeHooks,
4981
5093
  doctor, doctorDelphi, isXpGateFile, diagnoseLanguageTools, diagnoseCliTools, SIGNATURES, getHookSignatures, isXpGateHookContent,
5094
+ diagnoseOpenCodePlugin,
4982
5095
  fixVersionMismatch,
4983
5096
  fixTemplateDirMismatch,
4984
5097
  fixMissingHooks,
@@ -2,6 +2,6 @@
2
2
  "verdict": "PASS",
3
3
  "license_type": "MIT",
4
4
  "sha256": "0e7ac423bf2c6e223b7c5b156f8cf72da49d748e56a1641402c31f22ad07dbb5",
5
- "checked_at": "2026-12-01T11:40:32.746Z",
5
+ "checked_at": "2026-12-01T15:20:55.655Z",
6
6
  "source": "network"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/xp-gate",
3
- "version": "0.41.52",
3
+ "version": "0.41.56",
4
4
  "description": "Deterministic quality gates for AI-generated code: 15 gates, Delphi review, sprint flow. Works with Claude Code, OpenCode, Qoder.",
5
5
  "bin": {
6
6
  "xp-gate": "bin/xp-gate.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.41.52",
3
+ "version": "0.41.56",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Claude Code. Includes 12 pre-commit gates (Gate 0-11), 8 pre-push gates, Sprint Flow (6 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/dsh-plugin-xp-gate",
3
- "version": "0.41.52",
3
+ "version": "0.41.56",
4
4
  "description": "XP-Gate deterministic quality gates + AI workflow skills as a DeepSeek Harness (DSH) native plugin: gate-check / gate-principles / gate-arch tools + 12 SKILL.md skills",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyingliu01/opencode-plugin",
3
- "version": "0.41.52",
3
+ "version": "0.41.56",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "description": "XP-Gate quality gates + AI workflow skills for OpenCode",
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xp-gate",
3
- "version": "0.41.52",
3
+ "version": "0.41.56",
4
4
  "displayName": "XP-Gate",
5
5
  "description": "Extreme Programming quality gates + AI workflow skills for Qoder. Includes 12 pre-commit gates (Gate 0-11), 8 pre-push gates, Sprint Flow (6 phases), and Delphi multi-expert review (>=90% consensus).",
6
6
  "author": {
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  **6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration; each REQ starts from a clean context instead of accumulating one across REQs). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
@@ -3,7 +3,7 @@
3
3
  **Generated:** 2026-11-04
4
4
  **Commit:** eb2097b0
5
5
  **Branch:** sprint/2026-11-03-02
6
- **Version:** 0.41.52.0
6
+ **Version:** 0.41.56.0
7
7
 
8
8
  ## OVERVIEW
9
9
  Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.