instar 1.3.27 → 1.3.28

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 +1 @@
1
- {"version":3,"file":"PostUpdateMigrator.d.ts","sourceRoot":"","sources":["../../src/core/PostUpdateMigrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAoCH,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC3B,MAAM,yBAAyB,CAAC;AAIjC,MAAM,WAAW,eAAe;IAC9B,wBAAwB;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,kCAAkC;IAClC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAiB;IAC/B;;;;;;OAMG;IACH,OAAO,CAAC,UAAU,CAAiC;gBAEvC,MAAM,EAAE,cAAc;IAIlC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,oBAAoB;IAoB5B;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAItC;;;;;;OAMG;IACG,eAAe,CACnB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC;IAIjC,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,kBAAkB;IAO1B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IASpB;;;OAGG;IACH,OAAO,IAAI,eAAe;IAwC1B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,0B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AuB;IA4B/B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,sBAAsB;IAwC9B,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,8BAA8B;IA6HtC,OAAO,CAAC,+BAA+B;IAwKvC,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,qBAAqB;IAqO7B,OAAO,CAAC,qBAAqB;IAqI7B,OAAO,CAAC,qBAAqB;IAuL7B,OAAO,CAAC,6BAA6B;IAkLrC,OAAO,CAAC,0BAA0B;IAgClC,OAAO,CAAC,gBAAgB;IAmJxB,OAAO,CAAC,6BAA6B;CAoCtC"}
@@ -5459,56 +5459,64 @@ process.stdin.on('end', () => {
5459
5459
  // spike (gsd-executor Rule 3 exclusion: package installs are NOT
5460
5460
  // auto-fixable because a failed/typo'd install may be a slopsquat).
5461
5461
  // Signal-only — decision: approve + additionalContext. The agent decides.
5462
+ //
5463
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
5464
+ // both CJS and ESM host package types. Bare top-level \`require(...)\` throws
5465
+ // in ESM scope when the host package.json has "type":"module" — silently
5466
+ // killed this PreToolUse guard on every tool call. See hook-event-reporter.js.
5467
+
5468
+ (async () => {
5469
+ const fs = await import('node:fs');
5470
+ const path = await import('node:path');
5471
+
5472
+ // Install-command patterns → capture the args portion after the verb.
5473
+ const INSTALL_PATTERNS = [
5474
+ { re: /\\bnpm\\s+(?:i|install|add)\\s+([^&|;]+)/i, mgr: 'npm' },
5475
+ { re: /\\bpnpm\\s+(?:i|install|add)\\s+([^&|;]+)/i, mgr: 'pnpm' },
5476
+ { re: /\\byarn\\s+add\\s+([^&|;]+)/i, mgr: 'yarn' },
5477
+ { re: /\\bpip3?\\s+install\\s+([^&|;]+)/i, mgr: 'pip' },
5478
+ { re: /\\bcargo\\s+add\\s+([^&|;]+)/i, mgr: 'cargo' },
5479
+ ];
5480
+
5481
+ // Flags to strip when extracting package names.
5482
+ const FLAG_RE = /^-/;
5483
+
5484
+ function parsePackages(argStr) {
5485
+ return argStr
5486
+ .trim()
5487
+ .split(/\\s+/)
5488
+ .filter(tok => tok && !FLAG_RE.test(tok))
5489
+ // Strip version specifiers: pkg@1.2.3, pkg==1.2.3, pkg~=1.0
5490
+ .map(tok => tok.replace(/[@=~<>!].*$/, '').replace(/\\[.*$/, ''))
5491
+ .filter(Boolean);
5492
+ }
5462
5493
 
5463
- const fs = require('fs');
5464
- const path = require('path');
5465
-
5466
- // Install-command patterns → capture the args portion after the verb.
5467
- const INSTALL_PATTERNS = [
5468
- { re: /\\bnpm\\s+(?:i|install|add)\\s+([^&|;]+)/i, mgr: 'npm' },
5469
- { re: /\\bpnpm\\s+(?:i|install|add)\\s+([^&|;]+)/i, mgr: 'pnpm' },
5470
- { re: /\\byarn\\s+add\\s+([^&|;]+)/i, mgr: 'yarn' },
5471
- { re: /\\bpip3?\\s+install\\s+([^&|;]+)/i, mgr: 'pip' },
5472
- { re: /\\bcargo\\s+add\\s+([^&|;]+)/i, mgr: 'cargo' },
5473
- ];
5474
-
5475
- // Flags to strip when extracting package names.
5476
- const FLAG_RE = /^-/;
5477
-
5478
- function parsePackages(argStr) {
5479
- return argStr
5480
- .trim()
5481
- .split(/\\s+/)
5482
- .filter(tok => tok && !FLAG_RE.test(tok))
5483
- // Strip version specifiers: pkg@1.2.3, pkg==1.2.3, pkg~=1.0
5484
- .map(tok => tok.replace(/[@=~<>!].*$/, '').replace(/\\[.*$/, ''))
5485
- .filter(Boolean);
5486
- }
5487
-
5488
- // Returns the set of package names already known to the project from
5489
- // any manifest/lockfile present in the project dir.
5490
- function knownPackages(projectDir) {
5491
- const known = new Set();
5492
- const add = (name) => { if (name && typeof name === 'string') known.add(name.toLowerCase()); };
5494
+ // Returns the set of package names already known to the project from
5495
+ // any manifest/lockfile present in the project dir.
5496
+ function knownPackages(projectDir) {
5497
+ const known = new Set();
5498
+ const add = (name) => { if (name && typeof name === 'string') known.add(name.toLowerCase()); };
5493
5499
 
5494
- // package.json deps + devDeps + lock
5495
- try {
5496
- const pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf-8'));
5497
- for (const k of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
5498
- if (pkg[k]) Object.keys(pkg[k]).forEach(add);
5500
+ // package.json deps + devDeps + lock
5501
+ try {
5502
+ const pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf-8'));
5503
+ for (const k of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
5504
+ if (pkg[k]) Object.keys(pkg[k]).forEach(add);
5505
+ }
5506
+ } catch { /* no package.json */ }
5507
+ // package-lock.json — names appear as keys; cheap substring presence check via raw read
5508
+ let lockRaw = '';
5509
+ for (const lf of ['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock', 'requirements.txt', 'Cargo.toml', 'Cargo.lock', 'Pipfile', 'pyproject.toml']) {
5510
+ try { lockRaw += '\\n' + fs.readFileSync(path.join(projectDir, lf), 'utf-8'); } catch { /* absent */ }
5499
5511
  }
5500
- } catch { /* no package.json */ }
5501
- // package-lock.json — names appear as keys; cheap substring presence check via raw read
5502
- let lockRaw = '';
5503
- for (const lf of ['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock', 'requirements.txt', 'Cargo.toml', 'Cargo.lock', 'Pipfile', 'pyproject.toml']) {
5504
- try { lockRaw += '\\n' + fs.readFileSync(path.join(projectDir, lf), 'utf-8'); } catch { /* absent */ }
5512
+ return { known, lockRaw: lockRaw.toLowerCase() };
5505
5513
  }
5506
- return { known, lockRaw: lockRaw.toLowerCase() };
5507
- }
5508
5514
 
5509
- let data = '';
5510
- process.stdin.on('data', chunk => data += chunk);
5511
- process.stdin.on('end', () => {
5515
+ let data = '';
5516
+ try {
5517
+ for await (const chunk of process.stdin) data += chunk;
5518
+ } catch { process.exit(0); }
5519
+
5512
5520
  try {
5513
5521
  const input = JSON.parse(data);
5514
5522
  if (input.tool_name !== 'Bash') process.exit(0);
@@ -5559,7 +5567,7 @@ process.stdin.on('end', () => {
5559
5567
  process.stdout.write(JSON.stringify({ decision: 'approve', additionalContext: checklist.join('\\n') }));
5560
5568
  } catch { /* never block on errors */ }
5561
5569
  process.exit(0);
5562
- });
5570
+ })();
5563
5571
  `;
5564
5572
  }
5565
5573
  getPostActionReflectionHook() {
@@ -5571,13 +5579,19 @@ process.stdin.on('end', () => {
5571
5579
  //
5572
5580
  // "Every action is an opportunity to learn. Most of that learning is lost
5573
5581
  // because nobody paused to ask: what did this teach me?"
5582
+ //
5583
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
5584
+ // both CJS and ESM host package types. See hook-event-reporter.js header.
5574
5585
 
5575
- const fs = require('node:fs');
5576
- const pathMod = require('node:path');
5586
+ (async () => {
5587
+ const fs = await import('node:fs');
5588
+ const pathMod = await import('node:path');
5589
+
5590
+ let data = '';
5591
+ try {
5592
+ for await (const chunk of process.stdin) data += chunk;
5593
+ } catch { process.exit(0); }
5577
5594
 
5578
- let data = '';
5579
- process.stdin.on('data', chunk => data += chunk);
5580
- process.stdin.on('end', () => {
5581
5595
  try {
5582
5596
  const input = JSON.parse(data);
5583
5597
  if (input.tool_name !== 'Bash') process.exit(0);
@@ -5668,7 +5682,7 @@ process.stdin.on('end', () => {
5668
5682
  process.stdout.write(JSON.stringify({ decision: 'approve', additionalContext: reminder }));
5669
5683
  } catch { /* don't break on errors */ }
5670
5684
  process.exit(0);
5671
- });
5685
+ })();
5672
5686
  `;
5673
5687
  }
5674
5688
  getExternalCommunicationGuardHook() {
@@ -6187,9 +6201,15 @@ echo "[\$(date -Iseconds)] Server restart initiated"
6187
6201
  // State persists in .instar/state/scope-coherence.json via the server API.
6188
6202
 
6189
6203
  // CJS imports — this is a standalone hook script, not an ESM module
6190
- const _r = require;
6191
- const fs = _r('fs');
6192
- const path = _r('path');
6204
+ //
6205
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
6206
+ // both CJS and ESM host package types. Bare top-level \`require(...)\` throws in
6207
+ // ESM scope when the host has "type":"module" — silently killed this hook on
6208
+ // every fire. See hook-event-reporter.js header for the documented pattern.
6209
+
6210
+ (async () => {
6211
+ const fs = await import('node:fs');
6212
+ const path = await import('node:path');
6193
6213
 
6194
6214
  const STATE_FILE = path.join('.instar', 'state', 'scope-coherence.json');
6195
6215
  const SCOPE_DOC_PATTERNS = [
@@ -6237,9 +6257,11 @@ function saveState(state) {
6237
6257
  } catch {}
6238
6258
  }
6239
6259
 
6240
- let data = '';
6241
- process.stdin.on('data', chunk => data += chunk);
6242
- process.stdin.on('end', () => {
6260
+ let data = '';
6261
+ try {
6262
+ for await (const chunk of process.stdin) data += chunk;
6263
+ } catch { process.exit(0); }
6264
+
6243
6265
  try {
6244
6266
  const input = JSON.parse(data);
6245
6267
  const toolName = input.tool_name || '';
@@ -6288,7 +6310,8 @@ process.stdin.on('end', () => {
6288
6310
  } catch {}
6289
6311
  process.stdout.write(JSON.stringify({ decision: 'approve' }));
6290
6312
  process.exit(0);
6291
- });
6313
+ })();
6314
+
6292
6315
  `;
6293
6316
  }
6294
6317
  getScopeCoherenceCheckpointHook() {
@@ -6304,10 +6327,16 @@ process.stdin.on('end', () => {
6304
6327
  // Calls the Instar server for active job context to make the checkpoint actionable.
6305
6328
 
6306
6329
  // CJS imports — this is a standalone hook script, not an ESM module
6307
- const _r = require;
6308
- const fs = _r('fs');
6309
- const path = _r('path');
6310
- const http = _r('http');
6330
+ //
6331
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
6332
+ // both CJS and ESM host package types. Bare top-level \`require(...)\` throws in
6333
+ // ESM scope when the host has "type":"module" — silently killed this hook on
6334
+ // every fire. See hook-event-reporter.js header for the documented pattern.
6335
+
6336
+ (async () => {
6337
+ const fs = await import('node:fs');
6338
+ const path = await import('node:path');
6339
+ const http = await import('node:http');
6311
6340
 
6312
6341
  const STATE_FILE = path.join('.instar', 'state', 'scope-coherence.json');
6313
6342
  const DEPTH_THRESHOLD = 20;
@@ -6343,9 +6372,11 @@ function fetchActiveJob() {
6343
6372
  });
6344
6373
  }
6345
6374
 
6346
- let data = '';
6347
- process.stdin.on('data', chunk => data += chunk);
6348
- process.stdin.on('end', async () => {
6375
+ let data = '';
6376
+ try {
6377
+ for await (const chunk of process.stdin) data += chunk;
6378
+ } catch { process.exit(0); }
6379
+
6349
6380
  try {
6350
6381
  // Re-entry guard: if this Stop is a correction continuation (stop_hook_active),
6351
6382
  // approve immediately — never re-block a continuation. Without this, a block →
@@ -6446,7 +6477,8 @@ process.stdin.on('end', async () => {
6446
6477
  process.stdout.write(JSON.stringify({ decision: 'approve' }));
6447
6478
  }
6448
6479
  process.exit(0);
6449
- });
6480
+ })();
6481
+
6450
6482
  `;
6451
6483
  }
6452
6484
  getFreeTextGuardHook() {
@@ -6477,9 +6509,15 @@ process.stdin.on('end', async () => {
6477
6509
  // - Only checks topically relevant output (skip pure code, grep, cat)
6478
6510
  // - Rate-limited to prevent latency stacking
6479
6511
 
6480
- const _r = require;
6481
- const fs = _r('fs');
6482
- const path = _r('path');
6512
+ //
6513
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
6514
+ // both CJS and ESM host package types. Bare top-level \`require(...)\` throws in
6515
+ // ESM scope when the host has "type":"module" — silently killed this hook on
6516
+ // every fire. See hook-event-reporter.js header for the documented pattern.
6517
+
6518
+ (async () => {
6519
+ const fs = await import('node:fs');
6520
+ const path = await import('node:path');
6483
6521
 
6484
6522
  const STATE_DIR = path.join('.instar', 'state');
6485
6523
  const RATE_FILE = path.join(STATE_DIR, '.claim-intercept-last.tmp');
@@ -6607,9 +6645,11 @@ function findContradictions(text, state) {
6607
6645
 
6608
6646
  // ── Main ───────────────────────────────────────────────────────
6609
6647
 
6610
- let data = '';
6611
- process.stdin.on('data', chunk => data += chunk);
6612
- process.stdin.on('end', () => {
6648
+ let data = '';
6649
+ try {
6650
+ for await (const chunk of process.stdin) data += chunk;
6651
+ } catch { process.exit(0); }
6652
+
6613
6653
  try {
6614
6654
  const input = JSON.parse(data);
6615
6655
  const toolName = input.tool_name || '';
@@ -6674,7 +6714,8 @@ process.stdin.on('end', () => {
6674
6714
  process.stdout.write(JSON.stringify({ decision: 'approve', additionalContext: warning }));
6675
6715
  } catch {}
6676
6716
  process.exit(0);
6677
- });
6717
+ })();
6718
+
6678
6719
  `;
6679
6720
  }
6680
6721
  getResponseReviewHook() {
@@ -6689,10 +6730,16 @@ process.stdin.on('end', () => {
6689
6730
  // The CoherenceGate handles retry tracking and exhaustion internally.
6690
6731
  // The hook always passes the stopHookActive flag so the server can decide.
6691
6732
 
6692
- const _r = require;
6693
- const fs = _r('fs');
6694
- const path = _r('path');
6695
- const http = _r('http');
6733
+ //
6734
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
6735
+ // both CJS and ESM host package types. Bare top-level \`require(...)\` throws in
6736
+ // ESM scope when the host has "type":"module" — silently killed this hook on
6737
+ // every fire. See hook-event-reporter.js header for the documented pattern.
6738
+
6739
+ (async () => {
6740
+ const fs = await import('node:fs');
6741
+ const path = await import('node:path');
6742
+ const http = await import('node:http');
6696
6743
 
6697
6744
  // Read config for port and auth token
6698
6745
  let serverPort = ${port};
@@ -6718,9 +6765,11 @@ if (!reviewEnabled) {
6718
6765
  process.exit(0);
6719
6766
  }
6720
6767
 
6721
- let data = '';
6722
- process.stdin.on('data', chunk => data += chunk);
6723
- process.stdin.on('end', async () => {
6768
+ let data = '';
6769
+ try {
6770
+ for await (const chunk of process.stdin) data += chunk;
6771
+ } catch { process.exit(0); }
6772
+
6724
6773
  try {
6725
6774
  const input = JSON.parse(data);
6726
6775
  const message = input.last_assistant_message || '';
@@ -6797,7 +6846,8 @@ process.stdin.on('end', async () => {
6797
6846
  // JSON parse error on stdin — fail open
6798
6847
  process.exit(0);
6799
6848
  }
6800
- });
6849
+ })();
6850
+
6801
6851
  `;
6802
6852
  }
6803
6853
  getStopGateRouterHook() {
@@ -6809,122 +6859,135 @@ process.stdin.on('end', async () => {
6809
6859
  // for hot-path state, and in shadow/enforce mode submits trusted evidence
6810
6860
  // metadata to /internal/stop-gate/evaluate. Shadow mode only records telemetry;
6811
6861
  // enforce mode blocks only on a server-side "continue" decision.
6862
+ //
6863
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
6864
+ // both CJS and ESM host package types. A bare top-level \`require(...)\` throws
6865
+ // "require is not defined in ES module scope" when the host package.json has
6866
+ // "type":"module" (which silently killed this gate — the gate meant to PREVENT
6867
+ // unjustified silent stalls). A bare top-level \`import\` is a syntax error in
6868
+ // CJS scope; dynamic import works in BOTH. See hook-event-reporter.js header.
6869
+
6870
+ (async () => {
6871
+ const fs = await import('node:fs');
6872
+ const path = await import('node:path');
6873
+ const childProcess = await import('node:child_process');
6874
+
6875
+ const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
6876
+ const configPath = path.join(projectDir, '.instar', 'config.json');
6877
+ let serverPort = ${port};
6878
+ let authToken = '';
6879
+ try {
6880
+ const cfg = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
6881
+ serverPort = cfg.port || ${port};
6882
+ authToken = cfg.authToken || '';
6883
+ } catch {}
6812
6884
 
6813
- const _r = require;
6814
- const fs = _r('fs');
6815
- const path = _r('path');
6816
- const childProcess = _r('child_process');
6817
-
6818
- const projectDir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
6819
- const configPath = path.join(projectDir, '.instar', 'config.json');
6820
- let serverPort = ${port};
6821
- let authToken = '';
6822
- try {
6823
- const cfg = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
6824
- serverPort = cfg.port || ${port};
6825
- authToken = cfg.authToken || '';
6826
- } catch {}
6827
-
6828
- function postJson(urlPath, payload, timeoutMs) {
6829
- const controller = new AbortController();
6830
- const timer = setTimeout(function () { controller.abort(); }, timeoutMs);
6831
- return fetch('http://127.0.0.1:' + serverPort + urlPath, {
6832
- method: 'POST',
6833
- headers: {
6834
- 'Content-Type': 'application/json',
6835
- 'Authorization': 'Bearer ' + authToken,
6836
- },
6837
- body: JSON.stringify(payload),
6838
- signal: controller.signal,
6839
- }).then(async function (res) {
6840
- clearTimeout(timer);
6841
- if (!res.ok) throw new Error('http ' + res.status);
6842
- return res.json();
6843
- }, function (err) {
6844
- clearTimeout(timer);
6845
- throw err;
6846
- });
6847
- }
6885
+ function postJson(urlPath, payload, timeoutMs) {
6886
+ const controller = new AbortController();
6887
+ const timer = setTimeout(function () { controller.abort(); }, timeoutMs);
6888
+ return fetch('http://127.0.0.1:' + serverPort + urlPath, {
6889
+ method: 'POST',
6890
+ headers: {
6891
+ 'Content-Type': 'application/json',
6892
+ 'Authorization': 'Bearer ' + authToken,
6893
+ },
6894
+ body: JSON.stringify(payload),
6895
+ signal: controller.signal,
6896
+ }).then(async function (res) {
6897
+ clearTimeout(timer);
6898
+ if (!res.ok) throw new Error('http ' + res.status);
6899
+ return res.json();
6900
+ }, function (err) {
6901
+ clearTimeout(timer);
6902
+ throw err;
6903
+ });
6904
+ }
6848
6905
 
6849
- function getJson(urlPath, timeoutMs) {
6850
- const controller = new AbortController();
6851
- const timer = setTimeout(function () { controller.abort(); }, timeoutMs);
6852
- return fetch('http://127.0.0.1:' + serverPort + urlPath, {
6853
- headers: { 'Authorization': 'Bearer ' + authToken },
6854
- signal: controller.signal,
6855
- }).then(async function (res) {
6856
- clearTimeout(timer);
6857
- if (!res.ok) throw new Error('http ' + res.status);
6858
- return res.json();
6859
- }, function (err) {
6860
- clearTimeout(timer);
6861
- throw err;
6862
- });
6863
- }
6906
+ function getJson(urlPath, timeoutMs) {
6907
+ const controller = new AbortController();
6908
+ const timer = setTimeout(function () { controller.abort(); }, timeoutMs);
6909
+ return fetch('http://127.0.0.1:' + serverPort + urlPath, {
6910
+ headers: { 'Authorization': 'Bearer ' + authToken },
6911
+ signal: controller.signal,
6912
+ }).then(async function (res) {
6913
+ clearTimeout(timer);
6914
+ if (!res.ok) throw new Error('http ' + res.status);
6915
+ return res.json();
6916
+ }, function (err) {
6917
+ clearTimeout(timer);
6918
+ throw err;
6919
+ });
6920
+ }
6864
6921
 
6865
- function git(args) {
6866
- try {
6867
- return childProcess.execFileSync('git', ['-C', projectDir].concat(args), {
6868
- encoding: 'utf-8',
6869
- timeout: 800,
6870
- stdio: ['ignore', 'pipe', 'ignore'],
6871
- }).trim();
6872
- } catch {
6873
- return '';
6922
+ function git(args) {
6923
+ try {
6924
+ return childProcess.execFileSync('git', ['-C', projectDir].concat(args), {
6925
+ encoding: 'utf-8',
6926
+ timeout: 800,
6927
+ stdio: ['ignore', 'pipe', 'ignore'],
6928
+ }).trim();
6929
+ } catch {
6930
+ return '';
6931
+ }
6874
6932
  }
6875
- }
6876
6933
 
6877
- function firstLine(value) {
6878
- return String(value || '').split(/\\r?\\n/).filter(Boolean)[0] || null;
6879
- }
6934
+ function firstLine(value) {
6935
+ return String(value || '').split(/\\r?\\n/).filter(Boolean)[0] || null;
6936
+ }
6880
6937
 
6881
- function listEvidenceArtifacts(sessionStartTs) {
6882
- const out = git(['ls-files']);
6883
- if (!out) return [];
6884
- const files = out.split(/\\r?\\n/).filter(function (file) {
6885
- if (!file) return false;
6886
- if (!/\\.(md|markdown|json|jsonl|txt)$/i.test(file)) return false;
6887
- return /(^|\\/)(docs\\/specs|specs|plans?|tasks?|upgrades|MEMORY\\.md|AGENTS\\.md)|spec|plan|handoff|todo|next|round/i.test(file);
6888
- }).slice(0, 30);
6889
- return files.map(function (file) {
6890
- const introducingCommit = firstLine(git(['log', '--follow', '--format=%H', '--reverse', '--', file]));
6891
- const latestCommit = firstLine(git(['log', '--format=%H', '-1', '--', file]));
6892
- let createdThisSession = false;
6893
- let modifiedThisSession = false;
6894
- if (sessionStartTs && latestCommit) {
6895
- const ts = Number(firstLine(git(['show', '-s', '--format=%ct', latestCommit])) || '0') * 1000;
6896
- modifiedThisSession = ts >= sessionStartTs;
6897
- if (introducingCommit) {
6898
- const createdTs = Number(firstLine(git(['show', '-s', '--format=%ct', introducingCommit])) || '0') * 1000;
6899
- createdThisSession = createdTs >= sessionStartTs;
6938
+ function listEvidenceArtifacts(sessionStartTs) {
6939
+ const out = git(['ls-files']);
6940
+ if (!out) return [];
6941
+ const files = out.split(/\\r?\\n/).filter(function (file) {
6942
+ if (!file) return false;
6943
+ if (!/\\.(md|markdown|json|jsonl|txt)$/i.test(file)) return false;
6944
+ return /(^|\\/)(docs\\/specs|specs|plans?|tasks?|upgrades|MEMORY\\.md|AGENTS\\.md)|spec|plan|handoff|todo|next|round/i.test(file);
6945
+ }).slice(0, 30);
6946
+ return files.map(function (file) {
6947
+ const introducingCommit = firstLine(git(['log', '--follow', '--format=%H', '--reverse', '--', file]));
6948
+ const latestCommit = firstLine(git(['log', '--format=%H', '-1', '--', file]));
6949
+ let createdThisSession = false;
6950
+ let modifiedThisSession = false;
6951
+ if (sessionStartTs && latestCommit) {
6952
+ const ts = Number(firstLine(git(['show', '-s', '--format=%ct', latestCommit])) || '0') * 1000;
6953
+ modifiedThisSession = ts >= sessionStartTs;
6954
+ if (introducingCommit) {
6955
+ const createdTs = Number(firstLine(git(['show', '-s', '--format=%ct', introducingCommit])) || '0') * 1000;
6956
+ createdThisSession = createdTs >= sessionStartTs;
6957
+ }
6900
6958
  }
6901
- }
6959
+ return {
6960
+ path: file,
6961
+ introducingCommit: introducingCommit,
6962
+ latestCommit: latestCommit,
6963
+ createdThisSession: createdThisSession,
6964
+ modifiedThisSession: modifiedThisSession,
6965
+ };
6966
+ });
6967
+ }
6968
+
6969
+ function buildSignals(stopReason, message) {
6970
+ const text = String(stopReason || '') + '\\n' + String(message || '');
6902
6971
  return {
6903
- path: file,
6904
- introducingCommit: introducingCommit,
6905
- latestCommit: latestCommit,
6906
- createdThisSession: createdThisSession,
6907
- modifiedThisSession: modifiedThisSession,
6972
+ mentionsContextLimit: /context|window|token|compact/i.test(text),
6973
+ mentionsFreshSession: /fresh session|new session|restart|continue in a new/i.test(text),
6974
+ claimsShouldStopForContext: /stop|pause|wrap up|hand off/i.test(text) && /context|fresh|compact/i.test(text),
6908
6975
  };
6909
- });
6910
- }
6976
+ }
6911
6977
 
6912
- function buildSignals(stopReason, message) {
6913
- const text = String(stopReason || '') + '\\n' + String(message || '');
6914
- return {
6915
- mentionsContextLimit: /context|window|token|compact/i.test(text),
6916
- mentionsFreshSession: /fresh session|new session|restart|continue in a new/i.test(text),
6917
- claimsShouldStopForContext: /stop|pause|wrap up|hand off/i.test(text) && /context|fresh|compact/i.test(text),
6918
- };
6919
- }
6978
+ function exitOpen() {
6979
+ process.exit(0);
6980
+ }
6920
6981
 
6921
- function exitOpen() {
6922
- process.exit(0);
6923
- }
6982
+ // Read the Stop-hook JSON from stdin (works in both CJS + ESM).
6983
+ let data = '';
6984
+ try {
6985
+ for await (const chunk of process.stdin) data += chunk;
6986
+ } catch {
6987
+ exitOpen();
6988
+ return;
6989
+ }
6924
6990
 
6925
- let data = '';
6926
- process.stdin.on('data', function (chunk) { data += chunk; });
6927
- process.stdin.on('end', async function () {
6928
6991
  let input;
6929
6992
  try {
6930
6993
  input = data ? JSON.parse(data) : {};
@@ -6933,12 +6996,12 @@ process.stdin.on('end', async function () {
6933
6996
  return;
6934
6997
  }
6935
6998
 
6936
- if (input.stop_hook_active) exitOpen();
6999
+ if (input.stop_hook_active) { exitOpen(); return; }
6937
7000
  const sessionId = String(input.session_id || input.sessionId || process.env.INSTAR_SESSION_ID || 'unknown');
6938
7001
 
6939
7002
  try {
6940
7003
  const hot = await getJson('/internal/stop-gate/hot-path?session=' + encodeURIComponent(sessionId), 1500);
6941
- if (!hot || hot.killSwitch || hot.mode === 'off' || hot.compactionInFlight) exitOpen();
7004
+ if (!hot || hot.killSwitch || hot.mode === 'off' || hot.compactionInFlight) { exitOpen(); return; }
6942
7005
 
6943
7006
  const message = String(input.last_assistant_message || '');
6944
7007
  const stopReason = String(input.stop_reason || input.reason || message || '');
@@ -6966,7 +7029,7 @@ process.stdin.on('end', async function () {
6966
7029
  } catch {
6967
7030
  exitOpen();
6968
7031
  }
6969
- });
7032
+ })();
6970
7033
  `;
6971
7034
  }
6972
7035
  getClaimInterceptResponseHook() {
@@ -6986,9 +7049,15 @@ process.stdin.on('end', async function () {
6986
7049
  // Guard against infinite loops:
6987
7050
  // If stop_hook_active is true, we're in a correction continuation — skip.
6988
7051
 
6989
- const _r = require;
6990
- const fs = _r('fs');
6991
- const path = _r('path');
7052
+ //
7053
+ // ESM-SAFE: dynamic \`await import(...)\` inside an async IIFE so this runs in
7054
+ // both CJS and ESM host package types. Bare top-level \`require(...)\` throws in
7055
+ // ESM scope when the host has "type":"module" — silently killed this hook on
7056
+ // every fire. See hook-event-reporter.js header for the documented pattern.
7057
+
7058
+ (async () => {
7059
+ const fs = await import('node:fs');
7060
+ const path = await import('node:path');
6992
7061
 
6993
7062
  const STATE_DIR = path.join('.instar', 'state');
6994
7063
  const RATE_FILE = path.join(STATE_DIR, '.claim-intercept-last.tmp');
@@ -7080,9 +7149,11 @@ function findContradictions(text, state) {
7080
7149
  return contradictions;
7081
7150
  }
7082
7151
 
7083
- let data = '';
7084
- process.stdin.on('data', chunk => data += chunk);
7085
- process.stdin.on('end', () => {
7152
+ let data = '';
7153
+ try {
7154
+ for await (const chunk of process.stdin) data += chunk;
7155
+ } catch { process.exit(0); }
7156
+
7086
7157
  try {
7087
7158
  const input = JSON.parse(data);
7088
7159
 
@@ -7134,7 +7205,8 @@ process.stdin.on('end', () => {
7134
7205
  process.exit(2);
7135
7206
  } catch {}
7136
7207
  process.exit(0);
7137
- });
7208
+ })();
7209
+
7138
7210
  `;
7139
7211
  }
7140
7212
  getSkillUsageTelemetryHook() {