gm-qwen 2.0.984 → 2.0.986

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/bin/plugkit.js CHANGED
@@ -1,48 +1,108 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- // Minimal exec wrapper. ZERO bootstrap, ZERO version-probe, ZERO async work.
4
- // Just shell out to ~/.claude/gm-tools/plugkit{.exe} with inherited stdio.
5
- // The Rust binary handles its own self-update at startup (detached); first-time
6
- // bootstrap is done by gm-cc postinstall.js. Hot path is one spawnSync, ~150ms
7
- // of node startup overhead.
3
+ // Hot path: spawnSync to ~/.claude/gm-tools/plugkit.exe with inherited stdio.
4
+ // Cold path (session-start / prompt-submit OR missing binary): synchronously
5
+ // ensure gm-tools/plugkit{.exe} matches the pinned version, then run hook.
6
+ // Cache-aware: when local matches the pin (sha-checked), zero network calls.
8
7
 
9
8
  const { spawnSync } = require('child_process');
10
9
  const path = require('path');
11
10
  const fs = require('fs');
12
11
  const os = require('os');
13
12
 
13
+ const wrapperDir = __dirname;
14
+
14
15
  function toolsBin() {
15
16
  const home = process.env.USERPROFILE || process.env.HOME || os.homedir();
16
17
  const exe = process.platform === 'win32' ? 'plugkit.exe' : 'plugkit';
17
18
  return path.join(home, '.claude', 'gm-tools', exe);
18
19
  }
19
20
 
20
- function legacyBesideWrapper() {
21
- const dir = __dirname;
22
- const p = os.platform();
23
- const a = os.arch();
24
- let candidates = [];
25
- if (p === 'win32') candidates = [path.join(dir, a === 'arm64' ? 'plugkit-win32-arm64.exe' : 'plugkit-win32-x64.exe')];
26
- else if (p === 'darwin') candidates = [path.join(dir, a === 'arm64' ? 'plugkit-darwin-arm64' : 'plugkit-darwin-x64')];
27
- else candidates = [path.join(dir, (a === 'arm64' || a === 'aarch64') ? 'plugkit-linux-arm64' : 'plugkit-linux-x64')];
28
- for (const c of candidates) if (fs.existsSync(c)) return c;
21
+ function sha256OfFileSync(filePath) {
22
+ try {
23
+ const crypto = require('crypto');
24
+ const h = crypto.createHash('sha256');
25
+ const fd = fs.openSync(filePath, 'r');
26
+ try {
27
+ const buf = Buffer.alloc(1 << 20);
28
+ let n;
29
+ while ((n = fs.readSync(fd, buf, 0, buf.length, null)) > 0) h.update(buf.subarray(0, n));
30
+ } finally { fs.closeSync(fd); }
31
+ return h.digest('hex');
32
+ } catch (_) { return null; }
33
+ }
34
+
35
+ function platformAsset() {
36
+ const p = process.platform;
37
+ const a = process.arch;
38
+ if (p === 'win32') return a === 'arm64' ? 'plugkit-win32-arm64.exe' : 'plugkit-win32-x64.exe';
39
+ if (p === 'darwin') return a === 'arm64' ? 'plugkit-darwin-arm64' : 'plugkit-darwin-x64';
40
+ return (a === 'arm64' || a === 'aarch64') ? 'plugkit-linux-arm64' : 'plugkit-linux-x64';
41
+ }
42
+
43
+ function readPinnedVersion() {
44
+ try { return fs.readFileSync(path.join(wrapperDir, 'plugkit.version'), 'utf8').trim(); } catch (_) { return null; }
45
+ }
46
+
47
+ function readExpectedSha() {
48
+ try {
49
+ const manifest = fs.readFileSync(path.join(wrapperDir, 'plugkit.sha256'), 'utf8');
50
+ const asset = platformAsset();
51
+ for (const line of manifest.split(/\r?\n/)) {
52
+ const parts = line.trim().split(/\s+/);
53
+ if (parts.length >= 2 && parts[parts.length - 1].replace(/^\*/, '') === asset) {
54
+ return parts[0].toLowerCase();
55
+ }
56
+ }
57
+ } catch (_) {}
29
58
  return null;
30
59
  }
31
60
 
61
+ // Returns true if gm-tools binary matches pinned version by sha. Fast: no network.
62
+ function isReady() {
63
+ const bin = toolsBin();
64
+ if (!fs.existsSync(bin)) return false;
65
+ const expected = readExpectedSha();
66
+ if (!expected) return true; // no manifest to compare against — trust existence
67
+ const actual = sha256OfFileSync(bin);
68
+ return actual && actual.toLowerCase() === expected;
69
+ }
70
+
71
+ // Synchronously run bootstrap.js in a child node. Blocks until install finishes
72
+ // (or fails). Bootstrap itself is cache-aware: re-download only when sha differs
73
+ // from manifest. Wraps stdio:inherit so the user sees progress.
74
+ function ensureReady(silent) {
75
+ if (isReady()) return true;
76
+ const bootstrap = path.join(wrapperDir, 'bootstrap.js');
77
+ const r = spawnSync(process.execPath, [bootstrap], {
78
+ stdio: silent ? ['ignore', 'pipe', 'pipe'] : ['ignore', 'inherit', 'inherit'],
79
+ windowsHide: true,
80
+ });
81
+ return r.status === 0 && isReady();
82
+ }
83
+
32
84
  function main() {
33
85
  const args = process.argv.slice(2);
34
86
  const isHook = args[0] === 'hook';
35
- let bin = toolsBin();
36
- if (!fs.existsSync(bin)) {
37
- bin = legacyBesideWrapper();
38
- if (!bin) {
39
- // Binary not yet installed. If this is a hook, exit cleanly so CC doesn't
40
- // see an error; postinstall will populate gm-tools on /plugin install.
41
- if (isHook) process.exit(0);
42
- process.stderr.write('[plugkit] binary not found at ~/.claude/gm-tools/plugkit — run postinstall\n');
87
+ const hookSubcmd = isHook ? (args[1] || '') : '';
88
+
89
+ // Synchronous readiness check on these hooks. Hot path: isReady() is sha-match
90
+ // against pinned manifest, returns true in <50ms with no network.
91
+ const blocksUntilReady = hookSubcmd === 'session-start' || hookSubcmd === 'prompt-submit';
92
+
93
+ if (blocksUntilReady) {
94
+ if (!ensureReady(false)) {
95
+ process.stderr.write('[plugkit] bootstrap failed; aborting hook\n');
43
96
  process.exit(1);
44
97
  }
98
+ } else if (!fs.existsSync(toolsBin())) {
99
+ // For non-blocking hooks (pre-tool-use, post-tool-use, stop, etc.): if the
100
+ // binary doesn't exist yet, exit cleanly — session-start will populate it.
101
+ if (isHook) process.exit(0);
102
+ process.exit(1);
45
103
  }
104
+
105
+ const bin = toolsBin();
46
106
  const r = spawnSync(bin, args, { stdio: 'inherit', windowsHide: true });
47
107
  process.exit(r.status ?? 1);
48
108
  }
@@ -1,6 +1,6 @@
1
- c938ab1d5651cb586a67652b2249c006b31a7fd39c68df39ad9f8ff762b53dbd plugkit-win32-x64.exe
2
- 91094a9948594e0b6ad232037ae1ed5e958ea54d060b023fb76e4c3e47c47ba0 plugkit-win32-arm64.exe
3
- ece14d52bdca7fc3652e82942caeae5dfc14467b01e8c503ff84aa3bc9b36f78 plugkit-darwin-x64
4
- 149ebb637564f45881a7f050043499cf95b3c0b92ce4848936b36d6ddd43d3a8 plugkit-darwin-arm64
5
- 2bd0d5bac2b13d118e0b4f0fa0164dba1580e045801d56bb1f976eacc0025d37 plugkit-linux-x64
6
- 05a4a3f804029a3fc6ba3eb6622d2cea5dbaa32ef9b360a20f460c5a8e95b02f plugkit-linux-arm64
1
+ af4b0d3ab31f104ac744f12502377f98c40daa15ecc432d3e457e4cfd38bc975 plugkit-win32-x64.exe
2
+ 7d8635c11f0e61d496e5961109f2df21a00b1478176ae90b779c437dbbd9efb0 plugkit-win32-arm64.exe
3
+ 965f657007282bd22bc712d095939c0d45b16aee153832b49d15562f20567b54 plugkit-darwin-x64
4
+ aadc456903ec71af39e3519af6638021d2159534601304959ddc36456f53aaf7 plugkit-darwin-arm64
5
+ 90dd164ccd31e0f97710b9eb92b2e8127617c3f03522a205c7b0ff8df7b9c257 plugkit-linux-x64
6
+ 4e10f4c4af5516de6c1b8b46d11c9a904eaa9e251f1c6018020baa4c189c07f2 plugkit-linux-arm64
@@ -1 +1 @@
1
- 0.1.340
1
+ 0.1.341
package/bin/rtk.sha256 CHANGED
@@ -1,5 +1,5 @@
1
- 3e4417d0380ca1171e9c67e2bba1d42a2ee9ed3c8df814b8816d483e778b99bb rtk-win32-x64.exe
2
- 2e757fd4bb4d7a3797f788b4e8933908b6ee4debc86098d3dece4356c1657c94 rtk-win32-arm64.exe
1
+ 3de194e9d628eb5b1b2113d35312442c403bc3caee92f5cb70ee9715200453ef rtk-win32-x64.exe
2
+ 6d60d3b7ff499e194c69c86b7d18bc93e394a5f9c4ae7a751338675634ea9311 rtk-win32-arm64.exe
3
3
  1b1e792767ed0e1e6ca0e2f0a8de02e77b06dea2f5ae667278b94baf239fcdc3 rtk-darwin-x64
4
4
  9717978d9d6216ea50c94444e00e359479b6315a17bd48c16064b267c8b0b60d rtk-darwin-arm64
5
5
  a100d3defac54194144e5723aec57e6f286b42298c67145c8428815246c9ee56 rtk-linux-x64
package/gm.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.984",
3
+ "version": "2.0.986",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -23,5 +23,5 @@
23
23
  "publishConfig": {
24
24
  "access": "public"
25
25
  },
26
- "plugkitVersion": "0.1.340"
26
+ "plugkitVersion": "0.1.341"
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-qwen",
3
- "version": "2.0.984",
3
+ "version": "2.0.986",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",