gm-skill 2.0.1334 → 2.0.1336

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1334",
3
+ "version": "2.0.1336",
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": {
@@ -1752,17 +1752,8 @@ function resolveVersion(instance) {
1752
1752
  try {
1753
1753
  return fs.readFileSync(path.join(GM_TOOLS_ROOT, 'plugkit.version'), 'utf8').trim();
1754
1754
  } catch (_) {}
1755
- try {
1756
- const fn = instance && instance.exports && instance.exports.plugkit_version;
1757
- if (typeof fn === 'function') {
1758
- const result = fn();
1759
- const ptr = Number(result & 0xffffffffn);
1760
- const len = Number(result >> 32n);
1761
- const bytes = new Uint8Array(instance.exports.memory.buffer, ptr, len);
1762
- return new TextDecoder().decode(bytes).trim();
1763
- }
1764
- } catch (_) {}
1765
- return 'unknown';
1755
+ const fromInstance = readInstanceVersion(instance);
1756
+ return fromInstance || 'unknown';
1766
1757
  }
1767
1758
 
1768
1759
  function readFileVersionOnly() {
@@ -1774,10 +1765,22 @@ function readInstanceVersion(instance) {
1774
1765
  const fn = instance && instance.exports && instance.exports.plugkit_version;
1775
1766
  if (typeof fn !== 'function') return null;
1776
1767
  const result = fn();
1777
- const ptr = Number(result & 0xffffffffn);
1778
- const len = Number(result >> 32n);
1779
- const bytes = new Uint8Array(instance.exports.memory.buffer, ptr, len);
1780
- return new TextDecoder().decode(bytes).trim();
1768
+ let ptr, len;
1769
+ if (typeof result === 'bigint') {
1770
+ ptr = Number(result & 0xffffffffn);
1771
+ len = Number(result >> 32n);
1772
+ } else {
1773
+ ptr = Number(result) & 0xffffffff;
1774
+ len = 0;
1775
+ }
1776
+ const buf = new Uint8Array(instance.exports.memory.buffer, ptr, 64);
1777
+ if (len === 0) {
1778
+ let end = 0;
1779
+ while (end < buf.length && buf[end] !== 0) end++;
1780
+ len = end;
1781
+ }
1782
+ if (len === 0) return null;
1783
+ return new TextDecoder().decode(buf.subarray(0, len)).trim() || null;
1781
1784
  } catch (_) { return null; }
1782
1785
  }
1783
1786
 
@@ -2515,9 +2518,60 @@ async function runSpoolWatcher(instance, spoolDir) {
2515
2518
 
2516
2519
  const UPDATE_AVAILABLE_PATH = path.join(spoolDir, '.update-available.json');
2517
2520
  const UPDATE_CHECK_INTERVAL_MS = 5 * 60 * 1000;
2521
+ const UPDATE_CHECK_SHARED_CACHE = path.join(GM_TOOLS_ROOT, '.update-check-cache.json');
2522
+ const UPDATE_CHECK_CACHE_TTL_MS = 4 * 60 * 1000;
2518
2523
  let _lastKnownDrift = null;
2524
+ function readSharedUpdateCache() {
2525
+ try {
2526
+ const content = fs.readFileSync(UPDATE_CHECK_SHARED_CACHE, 'utf-8');
2527
+ const parsed = JSON.parse(content);
2528
+ if (parsed && parsed.ts && parsed.latest && (Date.now() - parsed.ts) < UPDATE_CHECK_CACHE_TTL_MS) {
2529
+ return parsed;
2530
+ }
2531
+ } catch (_) {}
2532
+ return null;
2533
+ }
2534
+ function writeSharedUpdateCache(latest, status) {
2535
+ try {
2536
+ fs.mkdirSync(path.dirname(UPDATE_CHECK_SHARED_CACHE), { recursive: true });
2537
+ const tmp = UPDATE_CHECK_SHARED_CACHE + '.tmp.' + process.pid;
2538
+ fs.writeFileSync(tmp, JSON.stringify({ ts: Date.now(), latest, status, by_pid: process.pid }));
2539
+ fs.renameSync(tmp, UPDATE_CHECK_SHARED_CACHE);
2540
+ } catch (_) {}
2541
+ }
2542
+ function applyUpdateCheckResult(installed, latest, statusCode) {
2543
+ if (statusCode !== 200) {
2544
+ logEvent('plugkit', 'update.check.error', { installed, status: statusCode });
2545
+ return;
2546
+ }
2547
+ if (!latest) return;
2548
+ if (latest === installed) {
2549
+ try { fs.unlinkSync(UPDATE_AVAILABLE_PATH); } catch (_) {}
2550
+ if (_lastKnownDrift) {
2551
+ logEvent('plugkit', 'update.cleared', { installed, was: _lastKnownDrift });
2552
+ _lastKnownDrift = null;
2553
+ }
2554
+ return;
2555
+ }
2556
+ const isDrift = latest !== installed;
2557
+ if (isDrift && _lastKnownDrift !== latest) {
2558
+ try {
2559
+ fs.writeFileSync(UPDATE_AVAILABLE_PATH, JSON.stringify({
2560
+ installed, latest, ts: Date.now(),
2561
+ update_url: `https://github.com/AnEntrypoint/plugkit-bin/releases/tag/v${latest}`,
2562
+ }));
2563
+ } catch (_) {}
2564
+ logEvent('plugkit', 'update.available', { installed, latest });
2565
+ _lastKnownDrift = latest;
2566
+ }
2567
+ }
2519
2568
  function checkForUpdate() {
2520
2569
  const installed = resolveVersion(instance);
2570
+ const cached = readSharedUpdateCache();
2571
+ if (cached) {
2572
+ applyUpdateCheckResult(installed, cached.latest, cached.status || 200);
2573
+ return;
2574
+ }
2521
2575
  const req = https.get({
2522
2576
  host: 'api.github.com',
2523
2577
  path: '/repos/AnEntrypoint/plugkit-bin/releases/latest',
@@ -2526,7 +2580,8 @@ async function runSpoolWatcher(instance, spoolDir) {
2526
2580
  }, (res) => {
2527
2581
  if (res.statusCode !== 200) {
2528
2582
  res.resume();
2529
- logEvent('plugkit', 'update.check.error', { installed, status: res.statusCode });
2583
+ writeSharedUpdateCache(null, res.statusCode);
2584
+ applyUpdateCheckResult(installed, null, res.statusCode);
2530
2585
  return;
2531
2586
  }
2532
2587
  const chunks = [];
@@ -2537,6 +2592,7 @@ async function runSpoolWatcher(instance, spoolDir) {
2537
2592
  const tag = rel && rel.tag_name;
2538
2593
  if (!tag) return;
2539
2594
  const latest = tag.replace(/^v/, '');
2595
+ writeSharedUpdateCache(latest, 200);
2540
2596
  if (latest === installed) {
2541
2597
  try { fs.unlinkSync(UPDATE_AVAILABLE_PATH); } catch (_) {}
2542
2598
  if (_lastKnownDrift) {
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.1334",
3
+ "version": "2.0.1336",
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.1334",
3
+ "version": "2.0.1336",
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",