gm-skill 2.0.1347 → 2.0.1349

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.
@@ -746,9 +746,61 @@ async function resolveLatestRemoteVersion(timeoutMs) {
746
746
  return null;
747
747
  }
748
748
 
749
+ async function resolveLatestGmPlugkitNpmVersion(timeoutMs) {
750
+ try {
751
+ const buf = await httpGetBuffer('https://registry.npmjs.org/gm-plugkit/latest', timeoutMs || 3000);
752
+ const meta = JSON.parse(buf.toString('utf-8'));
753
+ if (meta && typeof meta.version === 'string') return meta.version;
754
+ } catch (_) {}
755
+ return null;
756
+ }
757
+
758
+ function getSelfVersion() {
759
+ try {
760
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8'));
761
+ return pkg.version || null;
762
+ } catch (_) { return null; }
763
+ }
764
+
765
+ async function probeSelfStaleness(timeoutMs) {
766
+ const own = getSelfVersion();
767
+ if (!own) return { stale: false, reason: 'no-self-version' };
768
+ const latest = await resolveLatestGmPlugkitNpmVersion(timeoutMs);
769
+ if (!latest) return { stale: false, reason: 'no-remote-version', own };
770
+ if (latest === own) return { stale: false, own, latest };
771
+ return { stale: true, own, latest };
772
+ }
773
+
749
774
  async function ensureReady(opts) {
750
775
  opts = opts || {};
751
776
  const offline = opts.offline === true;
777
+
778
+ if (!offline) {
779
+ try {
780
+ const selfStale = await probeSelfStaleness(2500);
781
+ if (selfStale && selfStale.stale) {
782
+ const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
783
+ const spoolDir = path.join(projectDir, '.gm', 'exec-spool');
784
+ try { fs.mkdirSync(spoolDir, { recursive: true }); } catch (_) {}
785
+ const marker = {
786
+ ts: new Date().toISOString(),
787
+ reason: 'gm-plugkit-self-stale',
788
+ running_version: selfStale.own,
789
+ latest_version: selfStale.latest,
790
+ instruction: `gm-plugkit running ${selfStale.own} but npm has ${selfStale.latest}. The npx/bun cache served a stale copy. Clear the cache so the next invocation picks up the latest wrapper fixes: bun pm cache rm; or npx clear-npx-cache; or rm -rf ~/.npm/_npx ~/AppData/Local/npm-cache/_npx`,
791
+ };
792
+ try { fs.writeFileSync(path.join(spoolDir, '.gm-plugkit-stale.json'), JSON.stringify(marker, null, 2)); } catch (_) {}
793
+ log(`gm-plugkit self-stale: running ${selfStale.own}, latest npm ${selfStale.latest} — cache served old code (marker at .gm/exec-spool/.gm-plugkit-stale.json)`);
794
+ } else if (selfStale && selfStale.own) {
795
+ try {
796
+ const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
797
+ const stalePath = path.join(projectDir, '.gm', 'exec-spool', '.gm-plugkit-stale.json');
798
+ if (fs.existsSync(stalePath)) fs.unlinkSync(stalePath);
799
+ } catch (_) {}
800
+ }
801
+ } catch (_) {}
802
+ }
803
+
752
804
  let pinnedVersion = null;
753
805
  try { pinnedVersion = readVersionFile(); } catch (_) {}
754
806
  let targetVersion = pinnedVersion;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1347",
3
+ "version": "2.0.1349",
4
4
  "description": "Bootstrap and daemon-spawn tool for gm plugkit binary. Downloads the correct platform binary, verifies SHA256, and starts the spool watcher daemon. Includes plugkit-wasm-wrapper for WASM-based spool watching.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -2061,11 +2061,27 @@ async function runSpoolWatcher(instance, spoolDir) {
2061
2061
  }, 5000);
2062
2062
 
2063
2063
  const _instanceVersionAtBoot = readInstanceVersion(instance);
2064
+ let _driftLoggedOnce = false;
2064
2065
  setInterval(() => {
2065
2066
  try {
2066
2067
  const fileV = readFileVersionOnly();
2067
2068
  const instV = _instanceVersionAtBoot;
2068
2069
  if (!fileV || !instV || fileV === instV) return;
2070
+ const bootReason = process.env.PLUGKIT_BOOT_REASON || 'unknown';
2071
+ const unsupervised = bootReason === 'direct-no-supervisor';
2072
+ if (unsupervised) {
2073
+ if (_driftLoggedOnce) return;
2074
+ _driftLoggedOnce = true;
2075
+ logEvent('plugkit', 'version.drift-detected-no-exit', {
2076
+ instance_version: instV,
2077
+ file_version: fileV,
2078
+ action: 'suppress-exit',
2079
+ reason: 'no-supervisor-to-respawn',
2080
+ boot_reason: bootReason,
2081
+ });
2082
+ console.error(`[plugkit-wasm] version drift detected: instance=${instV} file=${fileV} — exit SUPPRESSED (boot_reason=${bootReason}; no supervisor to respawn)`);
2083
+ return;
2084
+ }
2069
2085
  logEvent('plugkit', 'version.drift', {
2070
2086
  instance_version: instV,
2071
2087
  file_version: fileV,
@@ -2096,12 +2112,28 @@ async function runSpoolWatcher(instance, spoolDir) {
2096
2112
  const _crypto = require('crypto');
2097
2113
  _wrapperShaAtBoot = _crypto.createHash('sha256').update(fs.readFileSync(_wrapperPathInstalled)).digest('hex');
2098
2114
  } catch (_) {}
2115
+ let _wrapperDriftLoggedOnce = false;
2099
2116
  setInterval(() => {
2100
2117
  try {
2101
2118
  if (!_wrapperShaAtBoot) return;
2102
2119
  const _crypto = require('crypto');
2103
2120
  const cur = _crypto.createHash('sha256').update(fs.readFileSync(_wrapperPathInstalled)).digest('hex');
2104
2121
  if (cur === _wrapperShaAtBoot) return;
2122
+ const bootReason = process.env.PLUGKIT_BOOT_REASON || 'unknown';
2123
+ const unsupervised = bootReason === 'direct-no-supervisor';
2124
+ if (unsupervised) {
2125
+ if (_wrapperDriftLoggedOnce) return;
2126
+ _wrapperDriftLoggedOnce = true;
2127
+ logEvent('plugkit', 'wrapper.drift-detected-no-exit', {
2128
+ boot_sha: _wrapperShaAtBoot.slice(0, 12),
2129
+ file_sha: cur.slice(0, 12),
2130
+ action: 'suppress-exit',
2131
+ reason: 'no-supervisor-to-respawn',
2132
+ boot_reason: bootReason,
2133
+ });
2134
+ console.error(`[plugkit-wasm] wrapper.js drift detected — exit SUPPRESSED (boot_reason=${bootReason}; no supervisor to respawn)`);
2135
+ return;
2136
+ }
2105
2137
  logEvent('plugkit', 'wrapper.drift', {
2106
2138
  boot_sha: _wrapperShaAtBoot.slice(0, 12),
2107
2139
  file_sha: cur.slice(0, 12),
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.1347",
3
+ "version": "2.0.1349",
4
4
  "description": "Spool-dispatch orchestration engine with unified state machine, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-skill",
3
- "version": "2.0.1347",
3
+ "version": "2.0.1349",
4
4
  "description": "Canonical universal harness — AI-native software engineering via skill-driven orchestration; bootstraps plugkit for task execution and session isolation. Install in any AI coding agent host.",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",