gm-plugkit 2.0.1867 → 2.0.1869

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.
@@ -71,7 +71,7 @@ Write `in/<lang>/<N>.<ext>` for language stems, `in/<verb>/<N>.txt` for orchestr
71
71
 
72
72
  ## SESSION_ID
73
73
 
74
- Thread SESSION_ID through every spool body + rs-exec RPC; plugkit rejects empty.
74
+ Thread SESSION_ID through every spool body; plugkit rejects empty.
75
75
 
76
76
  ## Daemonize
77
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-plugkit",
3
- "version": "2.0.1867",
3
+ "version": "2.0.1869",
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": {
@@ -12,7 +12,6 @@
12
12
  "index.js",
13
13
  "bootstrap.js",
14
14
  "supervisor.js",
15
- "lang-host-runner.js",
16
15
  "plugkit-wasm-wrapper.js",
17
16
  "plugkit.version",
18
17
  "plugkit.sha256",
@@ -1049,18 +1049,6 @@ function resolveWindowsExeLocal(cmd) {
1049
1049
  }
1050
1050
  }
1051
1051
 
1052
- function isPortReachableSync(host, port, timeoutMs) {
1053
- const r = spawnSync(process.execPath, ['-e', `
1054
- const net = require('net');
1055
- const s = net.connect({ port: ${port}, host: ${JSON.stringify(host)} });
1056
- let done = false;
1057
- s.on('connect', () => { done = true; s.destroy(); process.exit(0); });
1058
- s.on('error', () => { if (!done) process.exit(1); });
1059
- setTimeout(() => { if (!done) { s.destroy(); process.exit(1); } }, ${timeoutMs || 800});
1060
- `], { timeout: (timeoutMs || 800) + 2000, windowsHide: true });
1061
- return r.status === 0;
1062
- }
1063
-
1064
1052
  function findFreePortSync() {
1065
1053
  const r = spawnSync(process.execPath, ['-e', `
1066
1054
  const net = require('net');
@@ -1072,17 +1060,6 @@ function findFreePortSync() {
1072
1060
  return parseInt(r.stdout.trim(), 10);
1073
1061
  }
1074
1062
 
1075
- function isPortAliveSync(port) {
1076
- const r = spawnSync(process.execPath, ['-e', `
1077
- const net = require('net');
1078
- const s = net.connect({ port: ${port}, host: '127.0.0.1' });
1079
- s.on('connect', () => { s.destroy(); process.exit(0); });
1080
- s.on('error', () => process.exit(1));
1081
- setTimeout(() => process.exit(1), 800);
1082
- `], { timeout: 2000 });
1083
- return r.status === 0;
1084
- }
1085
-
1086
1063
  function sleepSync(ms) {
1087
1064
  Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, Math.max(0, ms | 0));
1088
1065
  }
@@ -4390,16 +4367,42 @@ async function runSpoolWatcher(instance, spoolDir) {
4390
4367
  // The window must therefore comfortably exceed the worst-case cold embed;
4391
4368
  // it is a one-time cost (the digest persists after a single completion,
4392
4369
  // so subsequent boots' warmup is near-instant).
4393
- _writeStatusBusy(1200000);
4394
- const vb = new TextEncoder().encode('codesearch');
4395
- const bb = new TextEncoder().encode(JSON.stringify({ query: 'index warmup', k: 1 }));
4396
- const vp = writeWasmInput(instance, vb, 'boot-warmup:codesearch.verb');
4397
- const bp = writeWasmInput(instance, bb, 'boot-warmup:codesearch.body');
4370
+ // A single warmup dispatch only advances the index by one wall-budget
4371
+ // slice, so a large repo needs many passes before the digest converges
4372
+ // (deferred_files == 0). A single-shot warmup left the digest permanently
4373
+ // withheld: every later verb and every respawn re-triggered a fresh
4374
+ // partial pass, and the stale-digest boot path re-embedded from scratch
4375
+ // forever. Loop the warmup, refreshing busy_until each pass so the
4376
+ // supervisor's stale-heartbeat check never kills a converging rebuild,
4377
+ // until deferred_files reaches 0 or a bounded pass count is hit.
4398
4378
  const t0 = Date.now();
4399
- const r = dispatch(vp, vb.length, bp, bb.length);
4400
- decodeWasmResult(instance, r, 'boot-warmup:codesearch');
4379
+ let passes = 0;
4380
+ let lastDeferred = -1;
4381
+ let stagnant = 0;
4382
+ const MAX_WARMUP_PASSES = 80;
4383
+ while (passes < MAX_WARMUP_PASSES) {
4384
+ _writeStatusBusy(1200000);
4385
+ const vb = new TextEncoder().encode('codeinsight_index');
4386
+ const bb = new TextEncoder().encode(JSON.stringify({ root: '.', max_files: 500 }));
4387
+ const vp = writeWasmInput(instance, vb, 'boot-warmup:codeinsight_index.verb');
4388
+ const bp = writeWasmInput(instance, bb, 'boot-warmup:codeinsight_index.body');
4389
+ const r = dispatch(vp, vb.length, bp, bb.length);
4390
+ const decoded = decodeWasmResult(instance, r, 'boot-warmup:codeinsight_index');
4391
+ passes++;
4392
+ let deferred = null;
4393
+ try {
4394
+ const parsed = typeof decoded === 'string' ? JSON.parse(decoded) : decoded;
4395
+ const d = parsed && (parsed.data || parsed);
4396
+ if (d && typeof d.deferred_files === 'number') deferred = d.deferred_files;
4397
+ else if (parsed && typeof parsed.deferred_files === 'number') deferred = parsed.deferred_files;
4398
+ } catch (_) {}
4399
+ if (deferred === null) break;
4400
+ if (deferred === 0) break;
4401
+ if (deferred === lastDeferred) { stagnant++; if (stagnant >= 4) break; } else { stagnant = 0; }
4402
+ lastDeferred = deferred;
4403
+ }
4401
4404
  writeStatus();
4402
- logEvent('plugkit', 'boot.index-warmup', { ms: Date.now() - t0 });
4405
+ logEvent('plugkit', 'boot.index-warmup', { ms: Date.now() - t0, passes, converged: lastDeferred === -1 || lastDeferred === 0 });
4403
4406
  } catch (e) {
4404
4407
  try { logEvent('plugkit', 'boot.index-warmup-failed', { error: String(e && e.message || e) }); } catch (_) {}
4405
4408
  }
package/plugkit.version CHANGED
@@ -1 +1 @@
1
- 0.1.851
1
+ 0.1.852
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- const fs = require('fs');
4
- const path = require('path');
5
-
6
- async function main() {
7
- const [, , projectDir, command, codeB64] = process.argv;
8
- if (!projectDir || !command || codeB64 === undefined) {
9
- console.log(JSON.stringify({ ok: false, error: 'usage: lang-host-runner <projectDir> <command> <code-base64>' }));
10
- process.exit(2);
11
- }
12
- const code = Buffer.from(codeB64, 'base64').toString('utf8');
13
- const langDir = path.join(projectDir, 'lang');
14
- if (!fs.existsSync(langDir)) {
15
- console.log(JSON.stringify({ ok: false, error: 'no-lang-dir', langDir }));
16
- return;
17
- }
18
- const files = fs.readdirSync(langDir).filter(f => f.endsWith('.js') && f !== 'loader.js');
19
- const plugins = files.reduce((acc, f) => {
20
- try {
21
- const p = require(path.join(langDir, f));
22
- if (p && typeof p.id === 'string' && p.exec && p.exec.match instanceof RegExp && typeof p.exec.run === 'function') {
23
- acc.push(p);
24
- }
25
- } catch (_) {}
26
- return acc;
27
- }, []);
28
- const plugin = plugins.find(p => p.exec.match.test(command));
29
- if (!plugin) {
30
- console.log(JSON.stringify({ ok: false, error: 'no-plugin-matched', command, available: plugins.map(p => p.id) }));
31
- return;
32
- }
33
- const t0 = Date.now();
34
- const timer = setTimeout(() => {
35
- console.log(JSON.stringify({ ok: false, error: 'timeout', plugin_id: plugin.id, ms: Date.now() - t0 }));
36
- process.exit(0);
37
- }, 30000);
38
- try {
39
- const out = await plugin.exec.run(code, projectDir);
40
- clearTimeout(timer);
41
- console.log(JSON.stringify({ ok: true, plugin_id: plugin.id, output: String(out), ms: Date.now() - t0 }));
42
- } catch (e) {
43
- clearTimeout(timer);
44
- console.log(JSON.stringify({ ok: false, error: String(e && e.message || e), plugin_id: plugin.id, ms: Date.now() - t0 }));
45
- }
46
- }
47
-
48
- main();