@mrciphersmith/keryx 0.2.116 → 0.2.117

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.
Files changed (2) hide show
  1. package/dist/cli.js +71 -35
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -50252,7 +50252,7 @@ import path47 from "path";
50252
50252
  // package.json
50253
50253
  var package_default = {
50254
50254
  name: "@mrciphersmith/keryx",
50255
- version: "0.2.116",
50255
+ version: "0.2.117",
50256
50256
  description: "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
50257
50257
  private: false,
50258
50258
  publishConfig: {
@@ -82502,8 +82502,6 @@ function realSpawner() {
82502
82502
  env,
82503
82503
  detached: true
82504
82504
  });
82505
- let dataCb;
82506
- let exitCb;
82507
82505
  let netClosed = false;
82508
82506
  const closeNetOnce = async () => {
82509
82507
  if (netClosed)
@@ -82511,43 +82509,81 @@ function realSpawner() {
82511
82509
  netClosed = true;
82512
82510
  await netClose();
82513
82511
  };
82514
- const outDecoder = new TextDecoder;
82515
- const errDecoder = new TextDecoder;
82516
- const pump = async (stream, kind, decoder) => {
82517
- if (stream === undefined)
82518
- return;
82519
- const reader = stream.getReader();
82520
- try {
82521
- for (;; ) {
82522
- const chunk = await reader.read();
82523
- if (chunk.done)
82524
- break;
82525
- if (chunk.value !== undefined)
82526
- dataCb?.(decoder.decode(chunk.value, { stream: true }), kind);
82527
- }
82528
- } catch {} finally {
82529
- reader.releaseLock();
82530
- }
82531
- };
82532
- Promise.all([pump(proc.stdout, "stdout", outDecoder), pump(proc.stderr, "stderr", errDecoder)]);
82533
- proc.exited.then(async (exitCode) => {
82534
- exitCb?.({ exitCode });
82535
- await closeNetOnce();
82536
- });
82537
- return {
82538
- pid: proc.pid,
82539
- onOutput: (cb) => {
82540
- dataCb = cb;
82541
- },
82542
- onExit: (cb) => {
82543
- exitCb = cb;
82544
- },
82512
+ return superviseSpawnedProcess(proc, {
82545
82513
  kill: (signal) => {
82546
82514
  try {
82547
82515
  process.kill(-proc.pid, signal);
82548
82516
  } catch {}
82517
+ },
82518
+ afterExit: closeNetOnce
82519
+ });
82520
+ };
82521
+ }
82522
+ var EXIT_OUTPUT_DRAIN_MS = 2000;
82523
+ function superviseSpawnedProcess(proc, opts) {
82524
+ const drainMs = opts.drainMs ?? EXIT_OUTPUT_DRAIN_MS;
82525
+ let dataCb;
82526
+ let exitCb;
82527
+ const pendingChunks = [];
82528
+ let pendingExit;
82529
+ const emitData = (chunk, stream) => {
82530
+ if (dataCb === undefined)
82531
+ pendingChunks.push({ chunk, stream });
82532
+ else
82533
+ dataCb(chunk, stream);
82534
+ };
82535
+ const outDecoder = new TextDecoder;
82536
+ const errDecoder = new TextDecoder;
82537
+ const pump = async (stream, kind, decoder) => {
82538
+ if (stream === undefined)
82539
+ return;
82540
+ const reader = stream.getReader();
82541
+ try {
82542
+ for (;; ) {
82543
+ const chunk = await reader.read();
82544
+ if (chunk.done)
82545
+ break;
82546
+ if (chunk.value !== undefined)
82547
+ emitData(decoder.decode(chunk.value, { stream: true }), kind);
82549
82548
  }
82550
- };
82549
+ } catch {} finally {
82550
+ reader.releaseLock();
82551
+ }
82552
+ };
82553
+ const drained = Promise.all([
82554
+ pump(proc.stdout, "stdout", outDecoder),
82555
+ pump(proc.stderr, "stderr", errDecoder)
82556
+ ]);
82557
+ proc.exited.then(async (exitCode) => {
82558
+ let timer;
82559
+ await Promise.race([
82560
+ drained,
82561
+ new Promise((resolve) => {
82562
+ timer = setTimeout(resolve, drainMs);
82563
+ timer.unref?.();
82564
+ })
82565
+ ]);
82566
+ if (timer !== undefined)
82567
+ clearTimeout(timer);
82568
+ if (exitCb === undefined)
82569
+ pendingExit = { exitCode };
82570
+ else
82571
+ exitCb({ exitCode });
82572
+ await opts.afterExit?.();
82573
+ });
82574
+ return {
82575
+ pid: proc.pid,
82576
+ onOutput: (cb) => {
82577
+ dataCb = cb;
82578
+ for (const { chunk, stream } of pendingChunks.splice(0))
82579
+ cb(chunk, stream);
82580
+ },
82581
+ onExit: (cb) => {
82582
+ exitCb = cb;
82583
+ if (pendingExit !== undefined)
82584
+ cb(pendingExit);
82585
+ },
82586
+ kill: opts.kill
82551
82587
  };
82552
82588
  }
82553
82589
  function createJobRegistry(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrciphersmith/keryx",
3
- "version": "0.2.116",
3
+ "version": "0.2.117",
4
4
  "description": "Version-controlled project context for AI coding agents: code graph, architecture wiki, project memory, relevant tests, quality signals, and task flows.",
5
5
  "private": false,
6
6
  "publishConfig": {