@learnrudi/cli 1.2.0 → 1.3.0

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/index.cjs +472 -273
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -415,8 +415,8 @@ async function downloadRuntime(runtime, version, destPath, options = {}) {
415
415
  import_fs2.default.rmSync(destPath, { recursive: true });
416
416
  }
417
417
  import_fs2.default.mkdirSync(destPath, { recursive: true });
418
- const { execSync: execSync4 } = await import("child_process");
419
- execSync4(`tar -xzf "${tempFile}" -C "${destPath}" --strip-components=1`, {
418
+ const { execSync: execSync5 } = await import("child_process");
419
+ execSync5(`tar -xzf "${tempFile}" -C "${destPath}" --strip-components=1`, {
420
420
  stdio: "pipe"
421
421
  });
422
422
  import_fs2.default.unlinkSync(tempFile);
@@ -454,7 +454,7 @@ async function downloadTool(toolName, destPath, options = {}) {
454
454
  import_fs2.default.rmSync(destPath, { recursive: true });
455
455
  }
456
456
  import_fs2.default.mkdirSync(destPath, { recursive: true });
457
- const { execSync: execSync4 } = await import("child_process");
457
+ const { execSync: execSync5 } = await import("child_process");
458
458
  const downloads = toolManifest.downloads?.[platformArch];
459
459
  if (downloads && Array.isArray(downloads)) {
460
460
  const downloadedUrls = /* @__PURE__ */ new Set();
@@ -483,11 +483,11 @@ async function downloadTool(toolName, destPath, options = {}) {
483
483
  onProgress?.({ phase: "extracting", tool: toolName, binary: import_path2.default.basename(binary) });
484
484
  const archiveType = type || guessArchiveType(urlFilename);
485
485
  if (archiveType === "zip") {
486
- execSync4(`unzip -o "${tempFile}" -d "${destPath}"`, { stdio: "pipe" });
486
+ execSync5(`unzip -o "${tempFile}" -d "${destPath}"`, { stdio: "pipe" });
487
487
  } else if (archiveType === "tar.xz") {
488
- execSync4(`tar -xJf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
488
+ execSync5(`tar -xJf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
489
489
  } else if (archiveType === "tar.gz" || archiveType === "tgz") {
490
- execSync4(`tar -xzf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
490
+ execSync5(`tar -xzf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
491
491
  } else {
492
492
  throw new Error(`Unsupported archive type: ${archiveType}`);
493
493
  }
@@ -534,11 +534,11 @@ async function downloadTool(toolName, destPath, options = {}) {
534
534
  onProgress?.({ phase: "extracting", tool: toolName });
535
535
  const archiveType = extractConfig.type || guessArchiveType(urlFilename);
536
536
  if (archiveType === "zip") {
537
- execSync4(`unzip -o "${tempFile}" -d "${destPath}"`, { stdio: "pipe" });
537
+ execSync5(`unzip -o "${tempFile}" -d "${destPath}"`, { stdio: "pipe" });
538
538
  } else if (archiveType === "tar.xz") {
539
- execSync4(`tar -xJf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
539
+ execSync5(`tar -xJf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
540
540
  } else if (archiveType === "tar.gz" || archiveType === "tgz") {
541
- execSync4(`tar -xzf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
541
+ execSync5(`tar -xzf "${tempFile}" -C "${destPath}"`, { stdio: "pipe" });
542
542
  } else {
543
543
  throw new Error(`Unsupported archive type: ${archiveType}`);
544
544
  }
@@ -776,17 +776,17 @@ var require_visit = __commonJS({
776
776
  visit.BREAK = BREAK;
777
777
  visit.SKIP = SKIP;
778
778
  visit.REMOVE = REMOVE;
779
- function visit_(key, node, visitor, path16) {
780
- const ctrl = callVisitor(key, node, visitor, path16);
779
+ function visit_(key, node, visitor, path17) {
780
+ const ctrl = callVisitor(key, node, visitor, path17);
781
781
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
782
- replaceNode(key, path16, ctrl);
783
- return visit_(key, ctrl, visitor, path16);
782
+ replaceNode(key, path17, ctrl);
783
+ return visit_(key, ctrl, visitor, path17);
784
784
  }
785
785
  if (typeof ctrl !== "symbol") {
786
786
  if (identity.isCollection(node)) {
787
- path16 = Object.freeze(path16.concat(node));
787
+ path17 = Object.freeze(path17.concat(node));
788
788
  for (let i = 0; i < node.items.length; ++i) {
789
- const ci = visit_(i, node.items[i], visitor, path16);
789
+ const ci = visit_(i, node.items[i], visitor, path17);
790
790
  if (typeof ci === "number")
791
791
  i = ci - 1;
792
792
  else if (ci === BREAK)
@@ -797,13 +797,13 @@ var require_visit = __commonJS({
797
797
  }
798
798
  }
799
799
  } else if (identity.isPair(node)) {
800
- path16 = Object.freeze(path16.concat(node));
801
- const ck = visit_("key", node.key, visitor, path16);
800
+ path17 = Object.freeze(path17.concat(node));
801
+ const ck = visit_("key", node.key, visitor, path17);
802
802
  if (ck === BREAK)
803
803
  return BREAK;
804
804
  else if (ck === REMOVE)
805
805
  node.key = null;
806
- const cv = visit_("value", node.value, visitor, path16);
806
+ const cv = visit_("value", node.value, visitor, path17);
807
807
  if (cv === BREAK)
808
808
  return BREAK;
809
809
  else if (cv === REMOVE)
@@ -824,17 +824,17 @@ var require_visit = __commonJS({
824
824
  visitAsync.BREAK = BREAK;
825
825
  visitAsync.SKIP = SKIP;
826
826
  visitAsync.REMOVE = REMOVE;
827
- async function visitAsync_(key, node, visitor, path16) {
828
- const ctrl = await callVisitor(key, node, visitor, path16);
827
+ async function visitAsync_(key, node, visitor, path17) {
828
+ const ctrl = await callVisitor(key, node, visitor, path17);
829
829
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
830
- replaceNode(key, path16, ctrl);
831
- return visitAsync_(key, ctrl, visitor, path16);
830
+ replaceNode(key, path17, ctrl);
831
+ return visitAsync_(key, ctrl, visitor, path17);
832
832
  }
833
833
  if (typeof ctrl !== "symbol") {
834
834
  if (identity.isCollection(node)) {
835
- path16 = Object.freeze(path16.concat(node));
835
+ path17 = Object.freeze(path17.concat(node));
836
836
  for (let i = 0; i < node.items.length; ++i) {
837
- const ci = await visitAsync_(i, node.items[i], visitor, path16);
837
+ const ci = await visitAsync_(i, node.items[i], visitor, path17);
838
838
  if (typeof ci === "number")
839
839
  i = ci - 1;
840
840
  else if (ci === BREAK)
@@ -845,13 +845,13 @@ var require_visit = __commonJS({
845
845
  }
846
846
  }
847
847
  } else if (identity.isPair(node)) {
848
- path16 = Object.freeze(path16.concat(node));
849
- const ck = await visitAsync_("key", node.key, visitor, path16);
848
+ path17 = Object.freeze(path17.concat(node));
849
+ const ck = await visitAsync_("key", node.key, visitor, path17);
850
850
  if (ck === BREAK)
851
851
  return BREAK;
852
852
  else if (ck === REMOVE)
853
853
  node.key = null;
854
- const cv = await visitAsync_("value", node.value, visitor, path16);
854
+ const cv = await visitAsync_("value", node.value, visitor, path17);
855
855
  if (cv === BREAK)
856
856
  return BREAK;
857
857
  else if (cv === REMOVE)
@@ -878,23 +878,23 @@ var require_visit = __commonJS({
878
878
  }
879
879
  return visitor;
880
880
  }
881
- function callVisitor(key, node, visitor, path16) {
881
+ function callVisitor(key, node, visitor, path17) {
882
882
  if (typeof visitor === "function")
883
- return visitor(key, node, path16);
883
+ return visitor(key, node, path17);
884
884
  if (identity.isMap(node))
885
- return visitor.Map?.(key, node, path16);
885
+ return visitor.Map?.(key, node, path17);
886
886
  if (identity.isSeq(node))
887
- return visitor.Seq?.(key, node, path16);
887
+ return visitor.Seq?.(key, node, path17);
888
888
  if (identity.isPair(node))
889
- return visitor.Pair?.(key, node, path16);
889
+ return visitor.Pair?.(key, node, path17);
890
890
  if (identity.isScalar(node))
891
- return visitor.Scalar?.(key, node, path16);
891
+ return visitor.Scalar?.(key, node, path17);
892
892
  if (identity.isAlias(node))
893
- return visitor.Alias?.(key, node, path16);
893
+ return visitor.Alias?.(key, node, path17);
894
894
  return void 0;
895
895
  }
896
- function replaceNode(key, path16, node) {
897
- const parent = path16[path16.length - 1];
896
+ function replaceNode(key, path17, node) {
897
+ const parent = path17[path17.length - 1];
898
898
  if (identity.isCollection(parent)) {
899
899
  parent.items[key] = node;
900
900
  } else if (identity.isPair(parent)) {
@@ -1502,10 +1502,10 @@ var require_Collection = __commonJS({
1502
1502
  var createNode = require_createNode();
1503
1503
  var identity = require_identity();
1504
1504
  var Node = require_Node();
1505
- function collectionFromPath(schema, path16, value) {
1505
+ function collectionFromPath(schema, path17, value) {
1506
1506
  let v = value;
1507
- for (let i = path16.length - 1; i >= 0; --i) {
1508
- const k = path16[i];
1507
+ for (let i = path17.length - 1; i >= 0; --i) {
1508
+ const k = path17[i];
1509
1509
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
1510
1510
  const a = [];
1511
1511
  a[k] = v;
@@ -1524,7 +1524,7 @@ var require_Collection = __commonJS({
1524
1524
  sourceObjects: /* @__PURE__ */ new Map()
1525
1525
  });
1526
1526
  }
1527
- var isEmptyPath = (path16) => path16 == null || typeof path16 === "object" && !!path16[Symbol.iterator]().next().done;
1527
+ var isEmptyPath = (path17) => path17 == null || typeof path17 === "object" && !!path17[Symbol.iterator]().next().done;
1528
1528
  var Collection = class extends Node.NodeBase {
1529
1529
  constructor(type, schema) {
1530
1530
  super(type);
@@ -1554,11 +1554,11 @@ var require_Collection = __commonJS({
1554
1554
  * be a Pair instance or a `{ key, value }` object, which may not have a key
1555
1555
  * that already exists in the map.
1556
1556
  */
1557
- addIn(path16, value) {
1558
- if (isEmptyPath(path16))
1557
+ addIn(path17, value) {
1558
+ if (isEmptyPath(path17))
1559
1559
  this.add(value);
1560
1560
  else {
1561
- const [key, ...rest] = path16;
1561
+ const [key, ...rest] = path17;
1562
1562
  const node = this.get(key, true);
1563
1563
  if (identity.isCollection(node))
1564
1564
  node.addIn(rest, value);
@@ -1572,8 +1572,8 @@ var require_Collection = __commonJS({
1572
1572
  * Removes a value from the collection.
1573
1573
  * @returns `true` if the item was found and removed.
1574
1574
  */
1575
- deleteIn(path16) {
1576
- const [key, ...rest] = path16;
1575
+ deleteIn(path17) {
1576
+ const [key, ...rest] = path17;
1577
1577
  if (rest.length === 0)
1578
1578
  return this.delete(key);
1579
1579
  const node = this.get(key, true);
@@ -1587,8 +1587,8 @@ var require_Collection = __commonJS({
1587
1587
  * scalar values from their surrounding node; to disable set `keepScalar` to
1588
1588
  * `true` (collections are always returned intact).
1589
1589
  */
1590
- getIn(path16, keepScalar) {
1591
- const [key, ...rest] = path16;
1590
+ getIn(path17, keepScalar) {
1591
+ const [key, ...rest] = path17;
1592
1592
  const node = this.get(key, true);
1593
1593
  if (rest.length === 0)
1594
1594
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -1606,8 +1606,8 @@ var require_Collection = __commonJS({
1606
1606
  /**
1607
1607
  * Checks if the collection includes a value with the key `key`.
1608
1608
  */
1609
- hasIn(path16) {
1610
- const [key, ...rest] = path16;
1609
+ hasIn(path17) {
1610
+ const [key, ...rest] = path17;
1611
1611
  if (rest.length === 0)
1612
1612
  return this.has(key);
1613
1613
  const node = this.get(key, true);
@@ -1617,8 +1617,8 @@ var require_Collection = __commonJS({
1617
1617
  * Sets a value in this collection. For `!!set`, `value` needs to be a
1618
1618
  * boolean to add/remove the item from the set.
1619
1619
  */
1620
- setIn(path16, value) {
1621
- const [key, ...rest] = path16;
1620
+ setIn(path17, value) {
1621
+ const [key, ...rest] = path17;
1622
1622
  if (rest.length === 0) {
1623
1623
  this.set(key, value);
1624
1624
  } else {
@@ -4122,9 +4122,9 @@ var require_Document = __commonJS({
4122
4122
  this.contents.add(value);
4123
4123
  }
4124
4124
  /** Adds a value to the document. */
4125
- addIn(path16, value) {
4125
+ addIn(path17, value) {
4126
4126
  if (assertCollection(this.contents))
4127
- this.contents.addIn(path16, value);
4127
+ this.contents.addIn(path17, value);
4128
4128
  }
4129
4129
  /**
4130
4130
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -4199,14 +4199,14 @@ var require_Document = __commonJS({
4199
4199
  * Removes a value from the document.
4200
4200
  * @returns `true` if the item was found and removed.
4201
4201
  */
4202
- deleteIn(path16) {
4203
- if (Collection.isEmptyPath(path16)) {
4202
+ deleteIn(path17) {
4203
+ if (Collection.isEmptyPath(path17)) {
4204
4204
  if (this.contents == null)
4205
4205
  return false;
4206
4206
  this.contents = null;
4207
4207
  return true;
4208
4208
  }
4209
- return assertCollection(this.contents) ? this.contents.deleteIn(path16) : false;
4209
+ return assertCollection(this.contents) ? this.contents.deleteIn(path17) : false;
4210
4210
  }
4211
4211
  /**
4212
4212
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -4221,10 +4221,10 @@ var require_Document = __commonJS({
4221
4221
  * scalar values from their surrounding node; to disable set `keepScalar` to
4222
4222
  * `true` (collections are always returned intact).
4223
4223
  */
4224
- getIn(path16, keepScalar) {
4225
- if (Collection.isEmptyPath(path16))
4224
+ getIn(path17, keepScalar) {
4225
+ if (Collection.isEmptyPath(path17))
4226
4226
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
4227
- return identity.isCollection(this.contents) ? this.contents.getIn(path16, keepScalar) : void 0;
4227
+ return identity.isCollection(this.contents) ? this.contents.getIn(path17, keepScalar) : void 0;
4228
4228
  }
4229
4229
  /**
4230
4230
  * Checks if the document includes a value with the key `key`.
@@ -4235,10 +4235,10 @@ var require_Document = __commonJS({
4235
4235
  /**
4236
4236
  * Checks if the document includes a value at `path`.
4237
4237
  */
4238
- hasIn(path16) {
4239
- if (Collection.isEmptyPath(path16))
4238
+ hasIn(path17) {
4239
+ if (Collection.isEmptyPath(path17))
4240
4240
  return this.contents !== void 0;
4241
- return identity.isCollection(this.contents) ? this.contents.hasIn(path16) : false;
4241
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path17) : false;
4242
4242
  }
4243
4243
  /**
4244
4244
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -4255,13 +4255,13 @@ var require_Document = __commonJS({
4255
4255
  * Sets a value in this document. For `!!set`, `value` needs to be a
4256
4256
  * boolean to add/remove the item from the set.
4257
4257
  */
4258
- setIn(path16, value) {
4259
- if (Collection.isEmptyPath(path16)) {
4258
+ setIn(path17, value) {
4259
+ if (Collection.isEmptyPath(path17)) {
4260
4260
  this.contents = value;
4261
4261
  } else if (this.contents == null) {
4262
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path16), value);
4262
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path17), value);
4263
4263
  } else if (assertCollection(this.contents)) {
4264
- this.contents.setIn(path16, value);
4264
+ this.contents.setIn(path17, value);
4265
4265
  }
4266
4266
  }
4267
4267
  /**
@@ -6213,9 +6213,9 @@ var require_cst_visit = __commonJS({
6213
6213
  visit.BREAK = BREAK;
6214
6214
  visit.SKIP = SKIP;
6215
6215
  visit.REMOVE = REMOVE;
6216
- visit.itemAtPath = (cst, path16) => {
6216
+ visit.itemAtPath = (cst, path17) => {
6217
6217
  let item = cst;
6218
- for (const [field, index] of path16) {
6218
+ for (const [field, index] of path17) {
6219
6219
  const tok = item?.[field];
6220
6220
  if (tok && "items" in tok) {
6221
6221
  item = tok.items[index];
@@ -6224,23 +6224,23 @@ var require_cst_visit = __commonJS({
6224
6224
  }
6225
6225
  return item;
6226
6226
  };
6227
- visit.parentCollection = (cst, path16) => {
6228
- const parent = visit.itemAtPath(cst, path16.slice(0, -1));
6229
- const field = path16[path16.length - 1][0];
6227
+ visit.parentCollection = (cst, path17) => {
6228
+ const parent = visit.itemAtPath(cst, path17.slice(0, -1));
6229
+ const field = path17[path17.length - 1][0];
6230
6230
  const coll = parent?.[field];
6231
6231
  if (coll && "items" in coll)
6232
6232
  return coll;
6233
6233
  throw new Error("Parent collection not found");
6234
6234
  };
6235
- function _visit(path16, item, visitor) {
6236
- let ctrl = visitor(item, path16);
6235
+ function _visit(path17, item, visitor) {
6236
+ let ctrl = visitor(item, path17);
6237
6237
  if (typeof ctrl === "symbol")
6238
6238
  return ctrl;
6239
6239
  for (const field of ["key", "value"]) {
6240
6240
  const token = item[field];
6241
6241
  if (token && "items" in token) {
6242
6242
  for (let i = 0; i < token.items.length; ++i) {
6243
- const ci = _visit(Object.freeze(path16.concat([[field, i]])), token.items[i], visitor);
6243
+ const ci = _visit(Object.freeze(path17.concat([[field, i]])), token.items[i], visitor);
6244
6244
  if (typeof ci === "number")
6245
6245
  i = ci - 1;
6246
6246
  else if (ci === BREAK)
@@ -6251,10 +6251,10 @@ var require_cst_visit = __commonJS({
6251
6251
  }
6252
6252
  }
6253
6253
  if (typeof ctrl === "function" && field === "key")
6254
- ctrl = ctrl(item, path16);
6254
+ ctrl = ctrl(item, path17);
6255
6255
  }
6256
6256
  }
6257
- return typeof ctrl === "function" ? ctrl(item, path16) : ctrl;
6257
+ return typeof ctrl === "function" ? ctrl(item, path17) : ctrl;
6258
6258
  }
6259
6259
  exports2.visit = visit;
6260
6260
  }
@@ -7539,14 +7539,14 @@ var require_parser = __commonJS({
7539
7539
  case "scalar":
7540
7540
  case "single-quoted-scalar":
7541
7541
  case "double-quoted-scalar": {
7542
- const fs18 = this.flowScalar(this.type);
7542
+ const fs19 = this.flowScalar(this.type);
7543
7543
  if (atNextItem || it.value) {
7544
- map.items.push({ start, key: fs18, sep: [] });
7544
+ map.items.push({ start, key: fs19, sep: [] });
7545
7545
  this.onKeyLine = true;
7546
7546
  } else if (it.sep) {
7547
- this.stack.push(fs18);
7547
+ this.stack.push(fs19);
7548
7548
  } else {
7549
- Object.assign(it, { key: fs18, sep: [] });
7549
+ Object.assign(it, { key: fs19, sep: [] });
7550
7550
  this.onKeyLine = true;
7551
7551
  }
7552
7552
  return;
@@ -7674,13 +7674,13 @@ var require_parser = __commonJS({
7674
7674
  case "scalar":
7675
7675
  case "single-quoted-scalar":
7676
7676
  case "double-quoted-scalar": {
7677
- const fs18 = this.flowScalar(this.type);
7677
+ const fs19 = this.flowScalar(this.type);
7678
7678
  if (!it || it.value)
7679
- fc.items.push({ start: [], key: fs18, sep: [] });
7679
+ fc.items.push({ start: [], key: fs19, sep: [] });
7680
7680
  else if (it.sep)
7681
- this.stack.push(fs18);
7681
+ this.stack.push(fs19);
7682
7682
  else
7683
- Object.assign(it, { key: fs18, sep: [] });
7683
+ Object.assign(it, { key: fs19, sep: [] });
7684
7684
  return;
7685
7685
  }
7686
7686
  case "flow-map-end":
@@ -11181,8 +11181,8 @@ var require_utils = __commonJS({
11181
11181
  }
11182
11182
  return ind;
11183
11183
  }
11184
- function removeDotSegments(path16) {
11185
- let input = path16;
11184
+ function removeDotSegments(path17) {
11185
+ let input = path17;
11186
11186
  const output = [];
11187
11187
  let nextSlash = -1;
11188
11188
  let len = 0;
@@ -11381,8 +11381,8 @@ var require_schemes = __commonJS({
11381
11381
  wsComponent.secure = void 0;
11382
11382
  }
11383
11383
  if (wsComponent.resourceName) {
11384
- const [path16, query] = wsComponent.resourceName.split("?");
11385
- wsComponent.path = path16 && path16 !== "/" ? path16 : void 0;
11384
+ const [path17, query] = wsComponent.resourceName.split("?");
11385
+ wsComponent.path = path17 && path17 !== "/" ? path17 : void 0;
11386
11386
  wsComponent.query = query;
11387
11387
  wsComponent.resourceName = void 0;
11388
11388
  }
@@ -14735,12 +14735,12 @@ var require_dist2 = __commonJS({
14735
14735
  throw new Error(`Unknown format "${name}"`);
14736
14736
  return f;
14737
14737
  };
14738
- function addFormats2(ajv2, list, fs18, exportName) {
14738
+ function addFormats2(ajv2, list, fs19, exportName) {
14739
14739
  var _a;
14740
14740
  var _b;
14741
14741
  (_a = (_b = ajv2.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
14742
14742
  for (const f of list)
14743
- ajv2.addFormat(f, fs18[f]);
14743
+ ajv2.addFormat(f, fs19[f]);
14744
14744
  }
14745
14745
  module2.exports = exports2 = formatsPlugin;
14746
14746
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -15275,7 +15275,7 @@ async function installSinglePackage(pkg, options = {}) {
15275
15275
  onProgress?.({ phase: "downloading", package: pkg.id });
15276
15276
  if (pkg.npmPackage) {
15277
15277
  try {
15278
- const { execSync: execSync4 } = await import("child_process");
15278
+ const { execSync: execSync5 } = await import("child_process");
15279
15279
  if (!import_fs4.default.existsSync(installPath)) {
15280
15280
  import_fs4.default.mkdirSync(installPath, { recursive: true });
15281
15281
  }
@@ -15283,16 +15283,16 @@ async function installSinglePackage(pkg, options = {}) {
15283
15283
  const resourcesPath = process.env.RESOURCES_PATH;
15284
15284
  const npmCmd = resourcesPath ? import_path4.default.join(resourcesPath, "bundled-runtimes", "node", "bin", "npm") : "npm";
15285
15285
  if (!import_fs4.default.existsSync(import_path4.default.join(installPath, "package.json"))) {
15286
- execSync4(`"${npmCmd}" init -y`, { cwd: installPath, stdio: "pipe" });
15286
+ execSync5(`"${npmCmd}" init -y`, { cwd: installPath, stdio: "pipe" });
15287
15287
  }
15288
- execSync4(`"${npmCmd}" install ${pkg.npmPackage}`, { cwd: installPath, stdio: "pipe" });
15288
+ execSync5(`"${npmCmd}" install ${pkg.npmPackage}`, { cwd: installPath, stdio: "pipe" });
15289
15289
  if (pkg.postInstall) {
15290
15290
  onProgress?.({ phase: "postInstall", package: pkg.id, message: pkg.postInstall });
15291
15291
  const postInstallCmd = pkg.postInstall.replace(
15292
15292
  /^npx\s+(\S+)/,
15293
15293
  `"${import_path4.default.join(installPath, "node_modules", ".bin", "$1")}"`
15294
15294
  );
15295
- execSync4(postInstallCmd, { cwd: installPath, stdio: "pipe" });
15295
+ execSync5(postInstallCmd, { cwd: installPath, stdio: "pipe" });
15296
15296
  }
15297
15297
  import_fs4.default.writeFileSync(
15298
15298
  import_path4.default.join(installPath, "manifest.json"),
@@ -15314,15 +15314,15 @@ async function installSinglePackage(pkg, options = {}) {
15314
15314
  }
15315
15315
  if (pkg.pipPackage) {
15316
15316
  try {
15317
- const { execSync: execSync4 } = await import("child_process");
15317
+ const { execSync: execSync5 } = await import("child_process");
15318
15318
  if (!import_fs4.default.existsSync(installPath)) {
15319
15319
  import_fs4.default.mkdirSync(installPath, { recursive: true });
15320
15320
  }
15321
15321
  onProgress?.({ phase: "installing", package: pkg.id, message: `pip install ${pkg.pipPackage}` });
15322
15322
  const pythonPath = import_path4.default.join(PATHS.runtimes, "python", "bin", "python3");
15323
15323
  const pythonCmd = import_fs4.default.existsSync(pythonPath) ? pythonPath : "python3";
15324
- execSync4(`"${pythonCmd}" -m venv "${installPath}/venv"`, { stdio: "pipe" });
15325
- execSync4(`"${installPath}/venv/bin/pip" install ${pkg.pipPackage}`, { stdio: "pipe" });
15324
+ execSync5(`"${pythonCmd}" -m venv "${installPath}/venv"`, { stdio: "pipe" });
15325
+ execSync5(`"${installPath}/venv/bin/pip" install ${pkg.pipPackage}`, { stdio: "pipe" });
15326
15326
  import_fs4.default.writeFileSync(
15327
15327
  import_path4.default.join(installPath, "manifest.json"),
15328
15328
  JSON.stringify({
@@ -15544,7 +15544,7 @@ async function listInstalled(kind) {
15544
15544
  return packages;
15545
15545
  }
15546
15546
  async function installStackDependencies(stackPath, onProgress) {
15547
- const { execSync: execSync4 } = await import("child_process");
15547
+ const { execSync: execSync5 } = await import("child_process");
15548
15548
  const nodePath = import_path4.default.join(stackPath, "node");
15549
15549
  if (import_fs4.default.existsSync(nodePath)) {
15550
15550
  const packageJsonPath = import_path4.default.join(nodePath, "package.json");
@@ -15552,7 +15552,7 @@ async function installStackDependencies(stackPath, onProgress) {
15552
15552
  onProgress?.({ phase: "installing-deps", message: "Installing Node.js dependencies..." });
15553
15553
  try {
15554
15554
  const npmCmd = await findNpmExecutable();
15555
- execSync4(`"${npmCmd}" install`, { cwd: nodePath, stdio: "pipe" });
15555
+ execSync5(`"${npmCmd}" install`, { cwd: nodePath, stdio: "pipe" });
15556
15556
  } catch (error) {
15557
15557
  console.warn(`Warning: Failed to install Node.js dependencies: ${error.message}`);
15558
15558
  }
@@ -15565,8 +15565,8 @@ async function installStackDependencies(stackPath, onProgress) {
15565
15565
  onProgress?.({ phase: "installing-deps", message: "Installing Python dependencies..." });
15566
15566
  try {
15567
15567
  const pythonCmd = await findPythonExecutable();
15568
- execSync4(`"${pythonCmd}" -m venv venv`, { cwd: pythonPath, stdio: "pipe" });
15569
- execSync4("./venv/bin/pip install -r requirements.txt", { cwd: pythonPath, stdio: "pipe" });
15568
+ execSync5(`"${pythonCmd}" -m venv venv`, { cwd: pythonPath, stdio: "pipe" });
15569
+ execSync5("./venv/bin/pip install -r requirements.txt", { cwd: pythonPath, stdio: "pipe" });
15570
15570
  } catch (error) {
15571
15571
  console.warn(`Warning: Failed to install Python dependencies: ${error.message}`);
15572
15572
  }
@@ -15606,6 +15606,171 @@ async function findPythonExecutable() {
15606
15606
  return "python3";
15607
15607
  }
15608
15608
 
15609
+ // ../packages/core/src/deps.js
15610
+ var import_fs5 = __toESM(require("fs"), 1);
15611
+ var import_path5 = __toESM(require("path"), 1);
15612
+ var import_child_process = require("child_process");
15613
+ init_src();
15614
+ function checkRuntime(runtime) {
15615
+ const name = runtime.replace(/^runtime:/, "");
15616
+ const rudiPath = import_path5.default.join(PATHS.runtimes, name);
15617
+ if (import_fs5.default.existsSync(rudiPath)) {
15618
+ const binPath = getBinPath(rudiPath, name);
15619
+ if (binPath && import_fs5.default.existsSync(binPath)) {
15620
+ const version = getVersion(binPath, name);
15621
+ return { available: true, path: binPath, version, source: "rudi" };
15622
+ }
15623
+ }
15624
+ const systemCmd = getSystemCommand(name);
15625
+ const systemPath = which(systemCmd);
15626
+ if (systemPath) {
15627
+ const version = getVersion(systemPath, name);
15628
+ return { available: true, path: systemPath, version, source: "system" };
15629
+ }
15630
+ return { available: false, path: null, version: null, source: null };
15631
+ }
15632
+ function checkBinary(binary) {
15633
+ const name = binary.replace(/^binary:/, "");
15634
+ const rudiPath = import_path5.default.join(PATHS.binaries, name);
15635
+ if (import_fs5.default.existsSync(rudiPath)) {
15636
+ const binPath = getBinPath(rudiPath, name);
15637
+ if (binPath && import_fs5.default.existsSync(binPath)) {
15638
+ const version = getVersion(binPath, name);
15639
+ return { available: true, path: binPath, version, source: "rudi" };
15640
+ }
15641
+ }
15642
+ const systemPath = which(name);
15643
+ if (systemPath) {
15644
+ const version = getVersion(systemPath, name);
15645
+ return { available: true, path: systemPath, version, source: "system" };
15646
+ }
15647
+ return { available: false, path: null, version: null, source: null };
15648
+ }
15649
+ function checkAllDependencies(resolved) {
15650
+ const results = [];
15651
+ let satisfied = true;
15652
+ if (resolved.runtime) {
15653
+ const runtime = resolved.runtime.replace(/^runtime:/, "");
15654
+ const check = checkRuntime(runtime);
15655
+ results.push({
15656
+ type: "runtime",
15657
+ name: runtime,
15658
+ required: true,
15659
+ ...check
15660
+ });
15661
+ if (!check.available) satisfied = false;
15662
+ }
15663
+ for (const rt of resolved.requires?.runtimes || []) {
15664
+ const name = rt.replace(/^runtime:/, "");
15665
+ const check = checkRuntime(name);
15666
+ results.push({
15667
+ type: "runtime",
15668
+ name,
15669
+ required: true,
15670
+ ...check
15671
+ });
15672
+ if (!check.available) satisfied = false;
15673
+ }
15674
+ for (const bin of resolved.requires?.binaries || []) {
15675
+ const name = bin.replace(/^binary:/, "");
15676
+ const check = checkBinary(name);
15677
+ results.push({
15678
+ type: "binary",
15679
+ name,
15680
+ required: true,
15681
+ ...check
15682
+ });
15683
+ if (!check.available) satisfied = false;
15684
+ }
15685
+ return { satisfied, results };
15686
+ }
15687
+ function formatDependencyResults(results) {
15688
+ const lines = [];
15689
+ for (const r of results) {
15690
+ const icon = r.available ? "\u2713" : "\u2717";
15691
+ const version = r.version ? ` v${r.version}` : "";
15692
+ const source = r.source ? ` (${r.source})` : "";
15693
+ const status = r.available ? `${icon} ${r.name}${version}${source}` : `${icon} ${r.name} - not found`;
15694
+ lines.push(` ${status}`);
15695
+ }
15696
+ return lines;
15697
+ }
15698
+ function getBinPath(baseDir, name) {
15699
+ const arch = process.arch === "arm64" ? "arm64" : "x64";
15700
+ const isWindows = process.platform === "win32";
15701
+ const ext = isWindows ? ".exe" : "";
15702
+ const exeMap = {
15703
+ node: "node",
15704
+ python: "python3",
15705
+ deno: "deno",
15706
+ bun: "bun",
15707
+ ffmpeg: "ffmpeg",
15708
+ ripgrep: "rg",
15709
+ sqlite: "sqlite3",
15710
+ jq: "jq",
15711
+ yq: "yq"
15712
+ };
15713
+ const exe = exeMap[name] || name;
15714
+ const archPath = import_path5.default.join(baseDir, arch, "bin", exe + ext);
15715
+ if (import_fs5.default.existsSync(archPath)) return archPath;
15716
+ const flatPath = import_path5.default.join(baseDir, "bin", exe + ext);
15717
+ if (import_fs5.default.existsSync(flatPath)) return flatPath;
15718
+ const directPath = import_path5.default.join(baseDir, exe + ext);
15719
+ if (import_fs5.default.existsSync(directPath)) return directPath;
15720
+ return null;
15721
+ }
15722
+ function getSystemCommand(name) {
15723
+ const cmdMap = {
15724
+ python: "python3",
15725
+ node: "node",
15726
+ deno: "deno",
15727
+ bun: "bun"
15728
+ };
15729
+ return cmdMap[name] || name;
15730
+ }
15731
+ function which(cmd) {
15732
+ try {
15733
+ const result = (0, import_child_process.execSync)(`which ${cmd} 2>/dev/null`, { encoding: "utf-8" });
15734
+ return result.trim();
15735
+ } catch {
15736
+ return null;
15737
+ }
15738
+ }
15739
+ function getVersion(binPath, name) {
15740
+ const versionFlags = {
15741
+ node: "--version",
15742
+ python: "--version",
15743
+ python3: "--version",
15744
+ deno: "--version",
15745
+ bun: "--version",
15746
+ ffmpeg: "-version",
15747
+ rg: "--version",
15748
+ ripgrep: "--version",
15749
+ sqlite3: "--version",
15750
+ jq: "--version",
15751
+ yq: "--version"
15752
+ };
15753
+ const flag = versionFlags[name] || "--version";
15754
+ try {
15755
+ const output = (0, import_child_process.execSync)(`"${binPath}" ${flag} 2>&1`, { encoding: "utf-8" });
15756
+ const match = output.match(/(\d+\.\d+(?:\.\d+)?)/);
15757
+ return match ? match[1] : output.split("\n")[0].trim();
15758
+ } catch {
15759
+ return null;
15760
+ }
15761
+ }
15762
+ function getAvailableDeps() {
15763
+ const runtimes = ["node", "python", "deno", "bun"].map((name) => ({
15764
+ name,
15765
+ ...checkRuntime(name)
15766
+ }));
15767
+ const binaries = ["ffmpeg", "ripgrep", "sqlite3", "jq", "yq", "git", "docker"].map((name) => ({
15768
+ name,
15769
+ ...checkBinary(name)
15770
+ }));
15771
+ return { runtimes, binaries };
15772
+ }
15773
+
15609
15774
  // src/commands/search.js
15610
15775
  function pluralizeKind(kind) {
15611
15776
  if (!kind) return "packages";
@@ -15711,31 +15876,31 @@ Total: ${totalCount} package(s) available`);
15711
15876
  }
15712
15877
 
15713
15878
  // src/commands/install.js
15714
- var fs6 = __toESM(require("fs/promises"), 1);
15715
- var path6 = __toESM(require("path"), 1);
15879
+ var fs7 = __toESM(require("fs/promises"), 1);
15880
+ var path7 = __toESM(require("path"), 1);
15716
15881
 
15717
15882
  // src/utils/mcp-registry.js
15718
- var fs5 = __toESM(require("fs/promises"), 1);
15719
- var path5 = __toESM(require("path"), 1);
15883
+ var fs6 = __toESM(require("fs/promises"), 1);
15884
+ var path6 = __toESM(require("path"), 1);
15720
15885
  var os2 = __toESM(require("os"), 1);
15721
15886
  var HOME = os2.homedir();
15722
15887
  var AGENT_CONFIGS = {
15723
- claude: path5.join(HOME, ".claude", "settings.json"),
15724
- codex: path5.join(HOME, ".codex", "config.toml"),
15725
- gemini: path5.join(HOME, ".gemini", "settings.json")
15888
+ claude: path6.join(HOME, ".claude", "settings.json"),
15889
+ codex: path6.join(HOME, ".codex", "config.toml"),
15890
+ gemini: path6.join(HOME, ".gemini", "settings.json")
15726
15891
  };
15727
15892
  async function readJson(filePath) {
15728
15893
  try {
15729
- const content = await fs5.readFile(filePath, "utf-8");
15894
+ const content = await fs6.readFile(filePath, "utf-8");
15730
15895
  return JSON.parse(content);
15731
15896
  } catch {
15732
15897
  return {};
15733
15898
  }
15734
15899
  }
15735
15900
  async function writeJson(filePath, data) {
15736
- const dir = path5.dirname(filePath);
15737
- await fs5.mkdir(dir, { recursive: true });
15738
- await fs5.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
15901
+ const dir = path6.dirname(filePath);
15902
+ await fs6.mkdir(dir, { recursive: true });
15903
+ await fs6.writeFile(filePath, JSON.stringify(data, null, 2), "utf-8");
15739
15904
  }
15740
15905
  function parseTomlValue(value) {
15741
15906
  if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
@@ -15843,16 +16008,16 @@ function stringifyToml(config, prefix = "") {
15843
16008
  }
15844
16009
  async function readToml(filePath) {
15845
16010
  try {
15846
- const content = await fs5.readFile(filePath, "utf-8");
16011
+ const content = await fs6.readFile(filePath, "utf-8");
15847
16012
  return parseToml(content);
15848
16013
  } catch {
15849
16014
  return {};
15850
16015
  }
15851
16016
  }
15852
16017
  async function writeToml(filePath, data) {
15853
- const dir = path5.dirname(filePath);
15854
- await fs5.mkdir(dir, { recursive: true });
15855
- await fs5.writeFile(filePath, stringifyToml(data), "utf-8");
16018
+ const dir = path6.dirname(filePath);
16019
+ await fs6.mkdir(dir, { recursive: true });
16020
+ await fs6.writeFile(filePath, stringifyToml(data), "utf-8");
15856
16021
  }
15857
16022
  function parseEnvFile(content) {
15858
16023
  const env = {};
@@ -15874,9 +16039,9 @@ function parseEnvFile(content) {
15874
16039
  return env;
15875
16040
  }
15876
16041
  async function readStackEnv(installPath) {
15877
- const envPath = path5.join(installPath, ".env");
16042
+ const envPath = path6.join(installPath, ".env");
15878
16043
  try {
15879
- const content = await fs5.readFile(envPath, "utf-8");
16044
+ const content = await fs6.readFile(envPath, "utf-8");
15880
16045
  return parseEnvFile(content);
15881
16046
  } catch {
15882
16047
  return {};
@@ -15887,9 +16052,9 @@ async function buildMcpConfig(stackId, installPath, manifest) {
15887
16052
  let args = [];
15888
16053
  const cwd = installPath;
15889
16054
  const resolveRelativePath2 = (value) => {
15890
- if (!value || path5.isAbsolute(value)) return value;
16055
+ if (!value || path6.isAbsolute(value)) return value;
15891
16056
  const isPathLike = value.startsWith(".") || value.includes("/") || value.includes("\\");
15892
- return isPathLike ? path5.join(installPath, value) : value;
16057
+ return isPathLike ? path6.join(installPath, value) : value;
15893
16058
  };
15894
16059
  if (manifest.command) {
15895
16060
  const cmdArray = Array.isArray(manifest.command) ? manifest.command : [manifest.command];
@@ -15900,7 +16065,7 @@ async function buildMcpConfig(stackId, installPath, manifest) {
15900
16065
  args = (manifest.mcp.args || []).map((arg) => resolveRelativePath2(arg));
15901
16066
  if (manifest.mcp.entry) {
15902
16067
  args = args.map(
15903
- (arg) => arg === manifest.mcp.entry ? path5.join(installPath, manifest.mcp.entry) : arg
16068
+ (arg) => arg === manifest.mcp.entry ? path6.join(installPath, manifest.mcp.entry) : arg
15904
16069
  );
15905
16070
  }
15906
16071
  } else {
@@ -15934,9 +16099,9 @@ async function optimizeEntryPoint(installPath, command, args) {
15934
16099
  }
15935
16100
  const tsFile = args[tsFileIndex];
15936
16101
  const jsFile = tsFile.replace("/src/", "/dist/").replace(".ts", ".js");
15937
- const jsPath = path5.isAbsolute(jsFile) ? jsFile : path5.join(installPath, jsFile);
16102
+ const jsPath = path6.isAbsolute(jsFile) ? jsFile : path6.join(installPath, jsFile);
15938
16103
  try {
15939
- await fs5.access(jsPath);
16104
+ await fs6.access(jsPath);
15940
16105
  return {
15941
16106
  command: "node",
15942
16107
  args: [jsPath]
@@ -16055,12 +16220,12 @@ async function unregisterMcpGemini(stackId) {
16055
16220
  }
16056
16221
  }
16057
16222
  async function getInstalledAgents() {
16058
- const agentsDir = path5.join(HOME, ".rudi", "agents");
16223
+ const agentsDir = path6.join(HOME, ".rudi", "agents");
16059
16224
  const installed = [];
16060
16225
  for (const agent of ["claude", "codex", "gemini"]) {
16061
- const agentPath = path5.join(agentsDir, agent);
16226
+ const agentPath = path6.join(agentsDir, agent);
16062
16227
  try {
16063
- await fs5.access(agentPath);
16228
+ await fs6.access(agentPath);
16064
16229
  installed.push(agent);
16065
16230
  } catch {
16066
16231
  }
@@ -16106,9 +16271,9 @@ async function unregisterMcpAll(stackId, targetAgents = null) {
16106
16271
 
16107
16272
  // src/commands/install.js
16108
16273
  async function loadManifest(installPath) {
16109
- const manifestPath = path6.join(installPath, "manifest.json");
16274
+ const manifestPath = path7.join(installPath, "manifest.json");
16110
16275
  try {
16111
- const content = await fs6.readFile(manifestPath, "utf-8");
16276
+ const content = await fs7.readFile(manifestPath, "utf-8");
16112
16277
  return JSON.parse(content);
16113
16278
  } catch {
16114
16279
  return null;
@@ -16136,9 +16301,9 @@ function getSecretLabel(secret) {
16136
16301
  async function createEnvFile(installPath, manifest) {
16137
16302
  const secrets = getManifestSecrets(manifest);
16138
16303
  if (!secrets.length) return null;
16139
- const envPath = path6.join(installPath, ".env");
16304
+ const envPath = path7.join(installPath, ".env");
16140
16305
  try {
16141
- await fs6.access(envPath);
16306
+ await fs7.access(envPath);
16142
16307
  console.log(` .env file already exists, preserving existing secrets`);
16143
16308
  return envPath;
16144
16309
  } catch {
@@ -16160,7 +16325,7 @@ async function createEnvFile(installPath, manifest) {
16160
16325
  lines.push(`${key}=`);
16161
16326
  lines.push("");
16162
16327
  }
16163
- await fs6.writeFile(envPath, lines.join("\n"), "utf-8");
16328
+ await fs7.writeFile(envPath, lines.join("\n"), "utf-8");
16164
16329
  return envPath;
16165
16330
  }
16166
16331
  async function cmdInstall(args, flags) {
@@ -16212,6 +16377,19 @@ Required secrets:`);
16212
16377
  console.log(` - ${name}`);
16213
16378
  }
16214
16379
  }
16380
+ const depCheck = checkAllDependencies(resolved);
16381
+ if (depCheck.results.length > 0) {
16382
+ console.log(`
16383
+ System dependencies:`);
16384
+ for (const line of formatDependencyResults(depCheck.results)) {
16385
+ console.log(line);
16386
+ }
16387
+ if (!depCheck.satisfied && !force) {
16388
+ console.error(`
16389
+ \u2717 Missing required dependencies. Install them first or use --force to skip.`);
16390
+ process.exit(1);
16391
+ }
16392
+ }
16215
16393
  console.log(`
16216
16394
  Installing...`);
16217
16395
  const result = await installPackage(pkgId, {
@@ -16274,32 +16452,32 @@ Run with: rudi run ${pkgId}`);
16274
16452
  }
16275
16453
 
16276
16454
  // ../packages/runner/src/spawn.js
16277
- var import_child_process = require("child_process");
16278
- var import_path6 = __toESM(require("path"), 1);
16279
- var import_fs6 = __toESM(require("fs"), 1);
16455
+ var import_child_process2 = require("child_process");
16456
+ var import_path7 = __toESM(require("path"), 1);
16457
+ var import_fs7 = __toESM(require("fs"), 1);
16280
16458
 
16281
16459
  // ../packages/runner/src/secrets.js
16282
- var import_fs5 = __toESM(require("fs"), 1);
16283
- var import_path5 = __toESM(require("path"), 1);
16460
+ var import_fs6 = __toESM(require("fs"), 1);
16461
+ var import_path6 = __toESM(require("path"), 1);
16284
16462
  var import_os2 = __toESM(require("os"), 1);
16285
- var SECRETS_PATH = import_path5.default.join(import_os2.default.homedir(), ".rudi", "secrets.json");
16463
+ var SECRETS_PATH = import_path6.default.join(import_os2.default.homedir(), ".rudi", "secrets.json");
16286
16464
  function loadSecrets() {
16287
- if (!import_fs5.default.existsSync(SECRETS_PATH)) {
16465
+ if (!import_fs6.default.existsSync(SECRETS_PATH)) {
16288
16466
  return {};
16289
16467
  }
16290
16468
  try {
16291
- const content = import_fs5.default.readFileSync(SECRETS_PATH, "utf-8");
16469
+ const content = import_fs6.default.readFileSync(SECRETS_PATH, "utf-8");
16292
16470
  return JSON.parse(content);
16293
16471
  } catch {
16294
16472
  return {};
16295
16473
  }
16296
16474
  }
16297
16475
  function saveSecrets(secrets) {
16298
- const dir = import_path5.default.dirname(SECRETS_PATH);
16299
- if (!import_fs5.default.existsSync(dir)) {
16300
- import_fs5.default.mkdirSync(dir, { recursive: true });
16476
+ const dir = import_path6.default.dirname(SECRETS_PATH);
16477
+ if (!import_fs6.default.existsSync(dir)) {
16478
+ import_fs6.default.mkdirSync(dir, { recursive: true });
16301
16479
  }
16302
- import_fs5.default.writeFileSync(SECRETS_PATH, JSON.stringify(secrets, null, 2), {
16480
+ import_fs6.default.writeFileSync(SECRETS_PATH, JSON.stringify(secrets, null, 2), {
16303
16481
  mode: 384
16304
16482
  // Read/write only for owner
16305
16483
  });
@@ -16385,12 +16563,12 @@ async function runStack(id, options = {}) {
16385
16563
  const { inputs = {}, cwd, env = {}, onStdout, onStderr, onExit, signal } = options;
16386
16564
  const startTime = Date.now();
16387
16565
  const packagePath = getPackagePath(id);
16388
- const manifestPath = import_path6.default.join(packagePath, "manifest.json");
16389
- const { default: fs18 } = await import("fs");
16390
- if (!fs18.existsSync(manifestPath)) {
16566
+ const manifestPath = import_path7.default.join(packagePath, "manifest.json");
16567
+ const { default: fs19 } = await import("fs");
16568
+ if (!fs19.existsSync(manifestPath)) {
16391
16569
  throw new Error(`Stack manifest not found: ${id}`);
16392
16570
  }
16393
- const manifest = JSON.parse(fs18.readFileSync(manifestPath, "utf-8"));
16571
+ const manifest = JSON.parse(fs19.readFileSync(manifestPath, "utf-8"));
16394
16572
  const { command, args } = resolveCommandFromManifest(manifest, packagePath);
16395
16573
  const secrets = await getSecrets(manifest.requires?.secrets || []);
16396
16574
  const runEnv = {
@@ -16401,7 +16579,7 @@ async function runStack(id, options = {}) {
16401
16579
  RUDI_PACKAGE_ID: id,
16402
16580
  RUDI_PACKAGE_PATH: packagePath
16403
16581
  };
16404
- const proc = (0, import_child_process.spawn)(command, args, {
16582
+ const proc = (0, import_child_process2.spawn)(command, args, {
16405
16583
  cwd: cwd || packagePath,
16406
16584
  env: runEnv,
16407
16585
  stdio: ["pipe", "pipe", "pipe"],
@@ -16446,15 +16624,15 @@ async function runStack(id, options = {}) {
16446
16624
  }
16447
16625
  function getCommand(runtime) {
16448
16626
  const runtimeName = runtime.replace("runtime:", "");
16449
- const runtimePath = import_path6.default.join(PATHS.runtimes, runtimeName);
16627
+ const runtimePath = import_path7.default.join(PATHS.runtimes, runtimeName);
16450
16628
  const binaryPaths = [
16451
- import_path6.default.join(runtimePath, "bin", runtimeName === "python" ? "python3" : runtimeName),
16452
- import_path6.default.join(runtimePath, "bin", runtimeName),
16453
- import_path6.default.join(runtimePath, runtimeName === "python" ? "python3" : runtimeName),
16454
- import_path6.default.join(runtimePath, runtimeName)
16629
+ import_path7.default.join(runtimePath, "bin", runtimeName === "python" ? "python3" : runtimeName),
16630
+ import_path7.default.join(runtimePath, "bin", runtimeName),
16631
+ import_path7.default.join(runtimePath, runtimeName === "python" ? "python3" : runtimeName),
16632
+ import_path7.default.join(runtimePath, runtimeName)
16455
16633
  ];
16456
16634
  for (const binPath of binaryPaths) {
16457
- if (import_fs6.default.existsSync(binPath)) {
16635
+ if (import_fs7.default.existsSync(binPath)) {
16458
16636
  return binPath;
16459
16637
  }
16460
16638
  }
@@ -16478,7 +16656,7 @@ function resolveCommandFromManifest(manifest, packagePath) {
16478
16656
  return { command: command2, args };
16479
16657
  }
16480
16658
  const entry = manifest.entry || "index.js";
16481
- const entryPath = import_path6.default.join(packagePath, entry);
16659
+ const entryPath = import_path7.default.join(packagePath, entry);
16482
16660
  const runtime = manifest.runtime || "runtime:node";
16483
16661
  const command = getCommand(runtime);
16484
16662
  return { command, args: [entryPath] };
@@ -16487,21 +16665,21 @@ function resolveRelativePath(value, basePath) {
16487
16665
  if (typeof value !== "string" || value.startsWith("-")) {
16488
16666
  return value;
16489
16667
  }
16490
- if (import_path6.default.isAbsolute(value)) {
16668
+ if (import_path7.default.isAbsolute(value)) {
16491
16669
  return value;
16492
16670
  }
16493
16671
  if (value.includes("/") || value.startsWith(".")) {
16494
- return import_path6.default.join(basePath, value);
16672
+ return import_path7.default.join(basePath, value);
16495
16673
  }
16496
16674
  return value;
16497
16675
  }
16498
16676
 
16499
16677
  // ../packages/manifest/src/stack.js
16500
16678
  var import_yaml2 = __toESM(require_dist(), 1);
16501
- var import_fs7 = __toESM(require("fs"), 1);
16502
- var import_path7 = __toESM(require("path"), 1);
16679
+ var import_fs8 = __toESM(require("fs"), 1);
16680
+ var import_path8 = __toESM(require("path"), 1);
16503
16681
  function parseStackManifest(filePath) {
16504
- const content = import_fs7.default.readFileSync(filePath, "utf-8");
16682
+ const content = import_fs8.default.readFileSync(filePath, "utf-8");
16505
16683
  return parseStackYaml(content, filePath);
16506
16684
  }
16507
16685
  function parseStackYaml(content, source = "stack.yaml") {
@@ -16619,8 +16797,8 @@ function validateStackManifest(manifest, source) {
16619
16797
  function findStackManifest(dir) {
16620
16798
  const candidates = ["stack.yaml", "stack.yml", "manifest.yaml", "manifest.yml"];
16621
16799
  for (const filename of candidates) {
16622
- const filePath = import_path7.default.join(dir, filename);
16623
- if (import_fs7.default.existsSync(filePath)) {
16800
+ const filePath = import_path8.default.join(dir, filename);
16801
+ if (import_fs8.default.existsSync(filePath)) {
16624
16802
  return filePath;
16625
16803
  }
16626
16804
  }
@@ -16775,8 +16953,8 @@ var validatePromptInternal = ajv.compile(promptSchema);
16775
16953
  var validateRuntimeInternal = ajv.compile(runtimeSchema);
16776
16954
 
16777
16955
  // src/commands/run.js
16778
- var import_fs8 = __toESM(require("fs"), 1);
16779
- var import_path8 = __toESM(require("path"), 1);
16956
+ var import_fs9 = __toESM(require("fs"), 1);
16957
+ var import_path9 = __toESM(require("path"), 1);
16780
16958
  async function cmdRun(args, flags) {
16781
16959
  const stackId = args[0];
16782
16960
  if (!stackId) {
@@ -16797,9 +16975,9 @@ async function cmdRun(args, flags) {
16797
16975
  if (manifestPath) {
16798
16976
  manifest = parseStackManifest(manifestPath);
16799
16977
  } else {
16800
- const jsonPath = import_path8.default.join(packagePath, "manifest.json");
16801
- if (import_fs8.default.existsSync(jsonPath)) {
16802
- manifest = JSON.parse(import_fs8.default.readFileSync(jsonPath, "utf-8"));
16978
+ const jsonPath = import_path9.default.join(packagePath, "manifest.json");
16979
+ if (import_fs9.default.existsSync(jsonPath)) {
16980
+ manifest = JSON.parse(import_fs9.default.readFileSync(jsonPath, "utf-8"));
16803
16981
  }
16804
16982
  }
16805
16983
  } catch (error) {
@@ -17255,13 +17433,13 @@ function promptSecret(prompt) {
17255
17433
  }
17256
17434
 
17257
17435
  // src/commands/db.js
17258
- var import_fs10 = require("fs");
17259
- var import_path10 = require("path");
17436
+ var import_fs11 = require("fs");
17437
+ var import_path11 = require("path");
17260
17438
 
17261
17439
  // ../packages/db/src/index.js
17262
17440
  var import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
17263
- var import_path9 = __toESM(require("path"), 1);
17264
- var import_fs9 = __toESM(require("fs"), 1);
17441
+ var import_path10 = __toESM(require("path"), 1);
17442
+ var import_fs10 = __toESM(require("fs"), 1);
17265
17443
  init_src();
17266
17444
 
17267
17445
  // ../packages/db/src/schema.js
@@ -17998,9 +18176,9 @@ var DB_PATH = PATHS.dbFile;
17998
18176
  var db = null;
17999
18177
  function getDb(options = {}) {
18000
18178
  if (!db) {
18001
- const dbDir = import_path9.default.dirname(DB_PATH);
18002
- if (!import_fs9.default.existsSync(dbDir)) {
18003
- import_fs9.default.mkdirSync(dbDir, { recursive: true });
18179
+ const dbDir = import_path10.default.dirname(DB_PATH);
18180
+ if (!import_fs10.default.existsSync(dbDir)) {
18181
+ import_fs10.default.mkdirSync(dbDir, { recursive: true });
18004
18182
  }
18005
18183
  db = new import_better_sqlite3.default(DB_PATH, {
18006
18184
  readonly: options.readonly || false
@@ -18013,7 +18191,7 @@ function getDb(options = {}) {
18013
18191
  return db;
18014
18192
  }
18015
18193
  function isDatabaseInitialized() {
18016
- if (!import_fs9.default.existsSync(DB_PATH)) {
18194
+ if (!import_fs10.default.existsSync(DB_PATH)) {
18017
18195
  return false;
18018
18196
  }
18019
18197
  try {
@@ -18033,7 +18211,7 @@ function getDbPath() {
18033
18211
  }
18034
18212
  function getDbSize() {
18035
18213
  try {
18036
- const stats = import_fs9.default.statSync(DB_PATH);
18214
+ const stats = import_fs10.default.statSync(DB_PATH);
18037
18215
  return stats.size;
18038
18216
  } catch {
18039
18217
  return null;
@@ -18294,12 +18472,12 @@ function dbBackup(args, flags) {
18294
18472
  let backupPath = args[0];
18295
18473
  if (!backupPath) {
18296
18474
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
18297
- backupPath = (0, import_path10.join)((0, import_path10.dirname)(dbPath), `rudi-backup-${timestamp}.db`);
18475
+ backupPath = (0, import_path11.join)((0, import_path11.dirname)(dbPath), `rudi-backup-${timestamp}.db`);
18298
18476
  }
18299
18477
  if (backupPath.startsWith("~")) {
18300
- backupPath = (0, import_path10.join)(process.env.HOME || "", backupPath.slice(1));
18478
+ backupPath = (0, import_path11.join)(process.env.HOME || "", backupPath.slice(1));
18301
18479
  }
18302
- if ((0, import_fs10.existsSync)(backupPath) && !flags.force) {
18480
+ if ((0, import_fs11.existsSync)(backupPath) && !flags.force) {
18303
18481
  console.error(`Backup file already exists: ${backupPath}`);
18304
18482
  console.error("Use --force to overwrite.");
18305
18483
  process.exit(1);
@@ -18311,7 +18489,7 @@ function dbBackup(args, flags) {
18311
18489
  const db3 = getDb();
18312
18490
  db3.exec("VACUUM INTO ?", [backupPath]);
18313
18491
  } catch (e) {
18314
- (0, import_fs10.copyFileSync)(dbPath, backupPath);
18492
+ (0, import_fs11.copyFileSync)(dbPath, backupPath);
18315
18493
  }
18316
18494
  const size = getDbSize();
18317
18495
  console.log(` Size: ${formatBytes(size)}`);
@@ -18416,24 +18594,24 @@ function dbTables(flags) {
18416
18594
  }
18417
18595
 
18418
18596
  // src/commands/import.js
18419
- var import_fs11 = require("fs");
18420
- var import_path11 = require("path");
18597
+ var import_fs12 = require("fs");
18598
+ var import_path12 = require("path");
18421
18599
  var import_os3 = require("os");
18422
18600
  var import_crypto2 = require("crypto");
18423
18601
  var PROVIDERS = {
18424
18602
  claude: {
18425
18603
  name: "Claude Code",
18426
- baseDir: (0, import_path11.join)((0, import_os3.homedir)(), ".claude", "projects"),
18604
+ baseDir: (0, import_path12.join)((0, import_os3.homedir)(), ".claude", "projects"),
18427
18605
  pattern: /\.jsonl$/
18428
18606
  },
18429
18607
  codex: {
18430
18608
  name: "Codex",
18431
- baseDir: (0, import_path11.join)((0, import_os3.homedir)(), ".codex", "sessions"),
18609
+ baseDir: (0, import_path12.join)((0, import_os3.homedir)(), ".codex", "sessions"),
18432
18610
  pattern: /\.jsonl$/
18433
18611
  },
18434
18612
  gemini: {
18435
18613
  name: "Gemini",
18436
- baseDir: (0, import_path11.join)((0, import_os3.homedir)(), ".gemini", "sessions"),
18614
+ baseDir: (0, import_path12.join)((0, import_os3.homedir)(), ".gemini", "sessions"),
18437
18615
  pattern: /\.jsonl$/
18438
18616
  }
18439
18617
  };
@@ -18500,7 +18678,7 @@ async function importSessions(args, flags) {
18500
18678
  console.log(`
18501
18679
  \u25B6 ${provider.name}`);
18502
18680
  console.log(` Source: ${provider.baseDir}`);
18503
- if (!(0, import_fs11.existsSync)(provider.baseDir)) {
18681
+ if (!(0, import_fs12.existsSync)(provider.baseDir)) {
18504
18682
  console.log(` \u26A0 Directory not found, skipping`);
18505
18683
  continue;
18506
18684
  }
@@ -18543,14 +18721,14 @@ async function importSessions(args, flags) {
18543
18721
  const now = Date.now();
18544
18722
  const maxAgeMs = maxAgeDays ? maxAgeDays * 24 * 60 * 60 * 1e3 : null;
18545
18723
  for (const filepath of files) {
18546
- const sessionId = (0, import_path11.basename)(filepath, ".jsonl");
18724
+ const sessionId = (0, import_path12.basename)(filepath, ".jsonl");
18547
18725
  if (existingIds.has(sessionId)) {
18548
18726
  skipped.existing++;
18549
18727
  continue;
18550
18728
  }
18551
18729
  let stat;
18552
18730
  try {
18553
- stat = (0, import_fs11.statSync)(filepath);
18731
+ stat = (0, import_fs12.statSync)(filepath);
18554
18732
  } catch (e) {
18555
18733
  skipped.error++;
18556
18734
  continue;
@@ -18648,7 +18826,7 @@ function showImportStatus(flags) {
18648
18826
  }
18649
18827
  console.log("\nProvider directories:");
18650
18828
  for (const [key, provider] of Object.entries(PROVIDERS)) {
18651
- const exists = (0, import_fs11.existsSync)(provider.baseDir);
18829
+ const exists = (0, import_fs12.existsSync)(provider.baseDir);
18652
18830
  let count = 0;
18653
18831
  if (exists) {
18654
18832
  const files = findSessionFiles(provider.baseDir, provider.pattern);
@@ -18662,10 +18840,10 @@ function showImportStatus(flags) {
18662
18840
  console.log("To import: rudi import sessions [provider]");
18663
18841
  }
18664
18842
  function findSessionFiles(dir, pattern, files = []) {
18665
- if (!(0, import_fs11.existsSync)(dir)) return files;
18843
+ if (!(0, import_fs12.existsSync)(dir)) return files;
18666
18844
  try {
18667
- for (const entry of (0, import_fs11.readdirSync)(dir, { withFileTypes: true })) {
18668
- const fullPath = (0, import_path11.join)(dir, entry.name);
18845
+ for (const entry of (0, import_fs12.readdirSync)(dir, { withFileTypes: true })) {
18846
+ const fullPath = (0, import_path12.join)(dir, entry.name);
18669
18847
  if (entry.isDirectory()) {
18670
18848
  findSessionFiles(fullPath, pattern, files);
18671
18849
  } else if (pattern.test(entry.name)) {
@@ -18678,11 +18856,11 @@ function findSessionFiles(dir, pattern, files = []) {
18678
18856
  }
18679
18857
  function parseSessionFile(filepath, provider) {
18680
18858
  try {
18681
- const stat = (0, import_fs11.statSync)(filepath);
18682
- const content = (0, import_fs11.readFileSync)(filepath, "utf-8");
18859
+ const stat = (0, import_fs12.statSync)(filepath);
18860
+ const content = (0, import_fs12.readFileSync)(filepath, "utf-8");
18683
18861
  const lines = content.split("\n").filter((l) => l.trim());
18684
18862
  if (lines.length === 0) return null;
18685
- const sessionId = (0, import_path11.basename)(filepath, ".jsonl");
18863
+ const sessionId = (0, import_path12.basename)(filepath, ".jsonl");
18686
18864
  const isAgent = sessionId.startsWith("agent-");
18687
18865
  let title = null;
18688
18866
  let cwd = null;
@@ -18714,7 +18892,7 @@ function parseSessionFile(filepath, provider) {
18714
18892
  title = isAgent ? "Agent Session" : "Imported Session";
18715
18893
  }
18716
18894
  if (!cwd) {
18717
- const parentDir = (0, import_path11.basename)((0, import_path11.dirname)(filepath));
18895
+ const parentDir = (0, import_path12.basename)((0, import_path12.dirname)(filepath));
18718
18896
  if (parentDir.startsWith("-")) {
18719
18897
  cwd = parentDir.replace(/-/g, "/").replace(/^\//, "/");
18720
18898
  } else {
@@ -18738,7 +18916,7 @@ function parseSessionFile(filepath, provider) {
18738
18916
  }
18739
18917
 
18740
18918
  // src/commands/doctor.js
18741
- var import_fs12 = __toESM(require("fs"), 1);
18919
+ var import_fs13 = __toESM(require("fs"), 1);
18742
18920
  async function cmdDoctor(args, flags) {
18743
18921
  console.log("RUDI Health Check");
18744
18922
  console.log("\u2550".repeat(50));
@@ -18756,12 +18934,12 @@ async function cmdDoctor(args, flags) {
18756
18934
  { path: PATHS.cache, name: "Cache" }
18757
18935
  ];
18758
18936
  for (const dir of dirs) {
18759
- const exists = import_fs12.default.existsSync(dir.path);
18937
+ const exists = import_fs13.default.existsSync(dir.path);
18760
18938
  const status = exists ? "\u2713" : "\u2717";
18761
18939
  console.log(` ${status} ${dir.name}: ${dir.path}`);
18762
18940
  if (!exists) {
18763
18941
  issues.push(`Missing directory: ${dir.name}`);
18764
- fixes.push(() => import_fs12.default.mkdirSync(dir.path, { recursive: true }));
18942
+ fixes.push(() => import_fs13.default.mkdirSync(dir.path, { recursive: true }));
18765
18943
  }
18766
18944
  }
18767
18945
  console.log("\n\u{1F4BE} Database");
@@ -18798,10 +18976,31 @@ async function cmdDoctor(args, flags) {
18798
18976
  } catch (error) {
18799
18977
  console.log(` \u2717 Error reading secrets: ${error.message}`);
18800
18978
  }
18801
- console.log("\n\u2699\uFE0F Environment");
18979
+ console.log("\n\u2699\uFE0F Runtimes");
18980
+ try {
18981
+ const { runtimes, binaries } = getAvailableDeps();
18982
+ for (const rt of runtimes) {
18983
+ const icon = rt.available ? "\u2713" : "\u25CB";
18984
+ const version = rt.version ? `v${rt.version}` : "";
18985
+ const source = rt.source ? `(${rt.source})` : "not found";
18986
+ console.log(` ${icon} ${rt.name}: ${version} ${source}`);
18987
+ }
18988
+ console.log("\n\u{1F527} Binaries");
18989
+ for (const bin of binaries) {
18990
+ const icon = bin.available ? "\u2713" : "\u25CB";
18991
+ const version = bin.version ? `v${bin.version}` : "";
18992
+ const source = bin.source ? `(${bin.source})` : "not found";
18993
+ console.log(` ${icon} ${bin.name}: ${version} ${source}`);
18994
+ }
18995
+ } catch (error) {
18996
+ console.log(` \u2717 Error checking dependencies: ${error.message}`);
18997
+ }
18998
+ console.log("\n\u{1F4CD} Environment");
18802
18999
  const nodeVersion = process.version;
18803
19000
  const nodeOk = parseInt(nodeVersion.slice(1)) >= 18;
18804
19001
  console.log(` ${nodeOk ? "\u2713" : "\u2717"} Node.js: ${nodeVersion} ${nodeOk ? "" : "(requires >=18)"}`);
19002
+ console.log(` \u2713 Platform: ${process.platform}-${process.arch}`);
19003
+ console.log(` \u2713 RUDI Home: ${PATHS.home}`);
18805
19004
  if (!nodeOk) {
18806
19005
  issues.push("Node.js version too old (requires >=18)");
18807
19006
  }
@@ -18831,9 +19030,9 @@ async function cmdDoctor(args, flags) {
18831
19030
  }
18832
19031
 
18833
19032
  // src/commands/update.js
18834
- var import_fs13 = __toESM(require("fs"), 1);
18835
- var import_path12 = __toESM(require("path"), 1);
18836
- var import_child_process2 = require("child_process");
19033
+ var import_fs14 = __toESM(require("fs"), 1);
19034
+ var import_path13 = __toESM(require("path"), 1);
19035
+ var import_child_process3 = require("child_process");
18837
19036
  init_src();
18838
19037
  init_src2();
18839
19038
  async function cmdUpdate(args, flags) {
@@ -18858,7 +19057,7 @@ async function cmdUpdate(args, flags) {
18858
19057
  async function updatePackage(pkgId, flags) {
18859
19058
  const [kind, name] = parsePackageId(pkgId);
18860
19059
  const installPath = getPackagePath(pkgId);
18861
- if (!import_fs13.default.existsSync(installPath)) {
19060
+ if (!import_fs14.default.existsSync(installPath)) {
18862
19061
  return { success: false, error: "Package not installed" };
18863
19062
  }
18864
19063
  const pkg = await getPackage(pkgId);
@@ -18868,7 +19067,7 @@ async function updatePackage(pkgId, flags) {
18868
19067
  console.log(`Updating ${pkgId}...`);
18869
19068
  if (pkg.npmPackage) {
18870
19069
  try {
18871
- (0, import_child_process2.execSync)(`npm install ${pkg.npmPackage}@latest`, {
19070
+ (0, import_child_process3.execSync)(`npm install ${pkg.npmPackage}@latest`, {
18872
19071
  cwd: installPath,
18873
19072
  stdio: flags.verbose ? "inherit" : "pipe"
18874
19073
  });
@@ -18881,11 +19080,11 @@ async function updatePackage(pkgId, flags) {
18881
19080
  }
18882
19081
  if (pkg.pipPackage) {
18883
19082
  try {
18884
- const venvPip = import_path12.default.join(installPath, "venv", "bin", "pip");
18885
- (0, import_child_process2.execSync)(`"${venvPip}" install --upgrade ${pkg.pipPackage}`, {
19083
+ const venvPip = import_path13.default.join(installPath, "venv", "bin", "pip");
19084
+ (0, import_child_process3.execSync)(`"${venvPip}" install --upgrade ${pkg.pipPackage}`, {
18886
19085
  stdio: flags.verbose ? "inherit" : "pipe"
18887
19086
  });
18888
- const versionOutput = (0, import_child_process2.execSync)(`"${venvPip}" show ${pkg.pipPackage} | grep Version`, {
19087
+ const versionOutput = (0, import_child_process3.execSync)(`"${venvPip}" show ${pkg.pipPackage} | grep Version`, {
18889
19088
  encoding: "utf-8"
18890
19089
  });
18891
19090
  const version = versionOutput.split(":")[1]?.trim();
@@ -18898,7 +19097,7 @@ async function updatePackage(pkgId, flags) {
18898
19097
  if (kind === "runtime" && !pkg.npmPackage && !pkg.pipPackage) {
18899
19098
  try {
18900
19099
  const { downloadRuntime: downloadRuntime2 } = await Promise.resolve().then(() => (init_src2(), src_exports));
18901
- import_fs13.default.rmSync(installPath, { recursive: true, force: true });
19100
+ import_fs14.default.rmSync(installPath, { recursive: true, force: true });
18902
19101
  await downloadRuntime2(name, pkg.version || "latest", installPath, {
18903
19102
  onProgress: (p) => {
18904
19103
  if (flags.verbose) console.log(` ${p.phase}...`);
@@ -18918,8 +19117,8 @@ async function updateAll(flags) {
18918
19117
  let failed = 0;
18919
19118
  for (const kind of kinds) {
18920
19119
  const dir = kind === "runtime" ? PATHS.runtimes : kind === "stack" ? PATHS.stacks : PATHS.prompts;
18921
- if (!import_fs13.default.existsSync(dir)) continue;
18922
- const entries = import_fs13.default.readdirSync(dir, { withFileTypes: true });
19120
+ if (!import_fs14.default.existsSync(dir)) continue;
19121
+ const entries = import_fs14.default.readdirSync(dir, { withFileTypes: true });
18923
19122
  for (const entry of entries) {
18924
19123
  if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
18925
19124
  const pkgId = `${kind}:${entry.name}`;
@@ -18938,14 +19137,14 @@ Updated ${updated} package(s)${failed > 0 ? `, ${failed} failed` : ""}`);
18938
19137
  }
18939
19138
  function getInstalledVersion(installPath, npmPackage) {
18940
19139
  try {
18941
- const pkgJsonPath = import_path12.default.join(installPath, "node_modules", npmPackage.replace("@", "").split("/")[0], "package.json");
18942
- if (import_fs13.default.existsSync(pkgJsonPath)) {
18943
- const pkgJson = JSON.parse(import_fs13.default.readFileSync(pkgJsonPath, "utf-8"));
19140
+ const pkgJsonPath = import_path13.default.join(installPath, "node_modules", npmPackage.replace("@", "").split("/")[0], "package.json");
19141
+ if (import_fs14.default.existsSync(pkgJsonPath)) {
19142
+ const pkgJson = JSON.parse(import_fs14.default.readFileSync(pkgJsonPath, "utf-8"));
18944
19143
  return pkgJson.version;
18945
19144
  }
18946
- const rootPkgPath = import_path12.default.join(installPath, "package.json");
18947
- if (import_fs13.default.existsSync(rootPkgPath)) {
18948
- const rootPkg = JSON.parse(import_fs13.default.readFileSync(rootPkgPath, "utf-8"));
19145
+ const rootPkgPath = import_path13.default.join(installPath, "package.json");
19146
+ if (import_fs14.default.existsSync(rootPkgPath)) {
19147
+ const rootPkg = JSON.parse(import_fs14.default.readFileSync(rootPkgPath, "utf-8"));
18949
19148
  const dep = rootPkg.dependencies?.[npmPackage];
18950
19149
  if (dep) return dep.replace(/[\^~]/, "");
18951
19150
  }
@@ -18954,30 +19153,30 @@ function getInstalledVersion(installPath, npmPackage) {
18954
19153
  return null;
18955
19154
  }
18956
19155
  function updateRuntimeMetadata(installPath, updates) {
18957
- const metaPath = import_path12.default.join(installPath, "runtime.json");
19156
+ const metaPath = import_path13.default.join(installPath, "runtime.json");
18958
19157
  try {
18959
19158
  let meta = {};
18960
- if (import_fs13.default.existsSync(metaPath)) {
18961
- meta = JSON.parse(import_fs13.default.readFileSync(metaPath, "utf-8"));
19159
+ if (import_fs14.default.existsSync(metaPath)) {
19160
+ meta = JSON.parse(import_fs14.default.readFileSync(metaPath, "utf-8"));
18962
19161
  }
18963
19162
  meta = { ...meta, ...updates };
18964
- import_fs13.default.writeFileSync(metaPath, JSON.stringify(meta, null, 2));
19163
+ import_fs14.default.writeFileSync(metaPath, JSON.stringify(meta, null, 2));
18965
19164
  } catch {
18966
19165
  }
18967
19166
  }
18968
19167
 
18969
19168
  // db/index.js
18970
19169
  var import_better_sqlite32 = __toESM(require("better-sqlite3"), 1);
18971
- var import_path13 = __toESM(require("path"), 1);
19170
+ var import_path14 = __toESM(require("path"), 1);
18972
19171
  var import_os4 = __toESM(require("os"), 1);
18973
- var import_fs14 = __toESM(require("fs"), 1);
18974
- var PROMPT_STACK_HOME = import_path13.default.join(import_os4.default.homedir(), ".prompt-stack");
18975
- var DB_PATH2 = import_path13.default.join(PROMPT_STACK_HOME, "prompt-stack.db");
19172
+ var import_fs15 = __toESM(require("fs"), 1);
19173
+ var PROMPT_STACK_HOME = import_path14.default.join(import_os4.default.homedir(), ".prompt-stack");
19174
+ var DB_PATH2 = import_path14.default.join(PROMPT_STACK_HOME, "prompt-stack.db");
18976
19175
  var db2 = null;
18977
19176
  function getDb2(options = {}) {
18978
19177
  if (!db2) {
18979
- if (!import_fs14.default.existsSync(PROMPT_STACK_HOME)) {
18980
- import_fs14.default.mkdirSync(PROMPT_STACK_HOME, { recursive: true });
19178
+ if (!import_fs15.default.existsSync(PROMPT_STACK_HOME)) {
19179
+ import_fs15.default.mkdirSync(PROMPT_STACK_HOME, { recursive: true });
18981
19180
  }
18982
19181
  db2 = new import_better_sqlite32.default(DB_PATH2, {
18983
19182
  readonly: options.readonly || false
@@ -19135,7 +19334,7 @@ function getBeforeCrashLogs() {
19135
19334
  }
19136
19335
 
19137
19336
  // src/commands/logs.js
19138
- var import_fs15 = __toESM(require("fs"), 1);
19337
+ var import_fs16 = __toESM(require("fs"), 1);
19139
19338
  function parseTimeAgo(str) {
19140
19339
  const match = str.match(/^(\d+)([smhd])$/);
19141
19340
  if (!match) return null;
@@ -19235,7 +19434,7 @@ function exportLogs(logs, filepath, format) {
19235
19434
  });
19236
19435
  content = JSON.stringify(formatted, null, 2);
19237
19436
  }
19238
- import_fs15.default.writeFileSync(filepath, content, "utf-8");
19437
+ import_fs16.default.writeFileSync(filepath, content, "utf-8");
19239
19438
  return filepath;
19240
19439
  }
19241
19440
  function printStats(stats) {
@@ -19361,9 +19560,9 @@ async function handleLogsCommand(args, flags) {
19361
19560
  }
19362
19561
 
19363
19562
  // src/commands/which.js
19364
- var fs16 = __toESM(require("fs/promises"), 1);
19365
- var path14 = __toESM(require("path"), 1);
19366
- var import_child_process3 = require("child_process");
19563
+ var fs17 = __toESM(require("fs/promises"), 1);
19564
+ var path15 = __toESM(require("path"), 1);
19565
+ var import_child_process4 = require("child_process");
19367
19566
  init_src();
19368
19567
  async function cmdWhich(args, flags) {
19369
19568
  const stackId = args[0];
@@ -19431,7 +19630,7 @@ Installed stacks:`);
19431
19630
  if (runtimeInfo.entry) {
19432
19631
  console.log("");
19433
19632
  console.log("Run MCP server directly:");
19434
- const entryPath = path14.join(stackPath, runtimeInfo.entry);
19633
+ const entryPath = path15.join(stackPath, runtimeInfo.entry);
19435
19634
  if (runtimeInfo.runtime === "node") {
19436
19635
  console.log(` echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | node ${entryPath}`);
19437
19636
  } else if (runtimeInfo.runtime === "python") {
@@ -19450,27 +19649,27 @@ Installed stacks:`);
19450
19649
  async function detectRuntime(stackPath) {
19451
19650
  const runtimes = ["node", "python"];
19452
19651
  for (const runtime of runtimes) {
19453
- const runtimePath = path14.join(stackPath, runtime);
19652
+ const runtimePath = path15.join(stackPath, runtime);
19454
19653
  try {
19455
- await fs16.access(runtimePath);
19654
+ await fs17.access(runtimePath);
19456
19655
  if (runtime === "node") {
19457
- const distEntry = path14.join(runtimePath, "dist", "index.js");
19458
- const srcEntry = path14.join(runtimePath, "src", "index.ts");
19656
+ const distEntry = path15.join(runtimePath, "dist", "index.js");
19657
+ const srcEntry = path15.join(runtimePath, "src", "index.ts");
19459
19658
  try {
19460
- await fs16.access(distEntry);
19659
+ await fs17.access(distEntry);
19461
19660
  return { runtime: "node", entry: `${runtime}/dist/index.js` };
19462
19661
  } catch {
19463
19662
  try {
19464
- await fs16.access(srcEntry);
19663
+ await fs17.access(srcEntry);
19465
19664
  return { runtime: "node", entry: `${runtime}/src/index.ts` };
19466
19665
  } catch {
19467
19666
  return { runtime: "node", entry: null };
19468
19667
  }
19469
19668
  }
19470
19669
  } else if (runtime === "python") {
19471
- const entry = path14.join(runtimePath, "src", "index.py");
19670
+ const entry = path15.join(runtimePath, "src", "index.py");
19472
19671
  try {
19473
- await fs16.access(entry);
19672
+ await fs17.access(entry);
19474
19673
  return { runtime: "python", entry: `${runtime}/src/index.py` };
19475
19674
  } catch {
19476
19675
  return { runtime: "python", entry: null };
@@ -19486,21 +19685,21 @@ async function checkAuth(stackPath, runtime) {
19486
19685
  const authFiles = [];
19487
19686
  let configured = false;
19488
19687
  if (runtime === "node" || runtime === "python") {
19489
- const runtimePath = path14.join(stackPath, runtime);
19490
- const tokenPath = path14.join(runtimePath, "token.json");
19688
+ const runtimePath = path15.join(stackPath, runtime);
19689
+ const tokenPath = path15.join(runtimePath, "token.json");
19491
19690
  try {
19492
- await fs16.access(tokenPath);
19691
+ await fs17.access(tokenPath);
19493
19692
  authFiles.push(`${runtime}/token.json`);
19494
19693
  configured = true;
19495
19694
  } catch {
19496
- const accountsPath = path14.join(runtimePath, "accounts");
19695
+ const accountsPath = path15.join(runtimePath, "accounts");
19497
19696
  try {
19498
- const accounts = await fs16.readdir(accountsPath);
19697
+ const accounts = await fs17.readdir(accountsPath);
19499
19698
  for (const account of accounts) {
19500
19699
  if (account.startsWith(".")) continue;
19501
- const accountTokenPath = path14.join(accountsPath, account, "token.json");
19700
+ const accountTokenPath = path15.join(accountsPath, account, "token.json");
19502
19701
  try {
19503
- await fs16.access(accountTokenPath);
19702
+ await fs17.access(accountTokenPath);
19504
19703
  authFiles.push(`${runtime}/accounts/${account}/token.json`);
19505
19704
  configured = true;
19506
19705
  } catch {
@@ -19510,9 +19709,9 @@ async function checkAuth(stackPath, runtime) {
19510
19709
  }
19511
19710
  }
19512
19711
  }
19513
- const envPath = path14.join(stackPath, ".env");
19712
+ const envPath = path15.join(stackPath, ".env");
19514
19713
  try {
19515
- const envContent = await fs16.readFile(envPath, "utf-8");
19714
+ const envContent = await fs17.readFile(envPath, "utf-8");
19516
19715
  const hasValues = envContent.split("\n").some((line) => {
19517
19716
  const trimmed = line.trim();
19518
19717
  if (!trimmed || trimmed.startsWith("#")) return false;
@@ -19541,7 +19740,7 @@ async function checkAuth(stackPath, runtime) {
19541
19740
  }
19542
19741
  function checkIfRunning(stackName) {
19543
19742
  try {
19544
- const result = (0, import_child_process3.execSync)(`ps aux | grep "${stackName}" | grep -v grep || true`, {
19743
+ const result = (0, import_child_process4.execSync)(`ps aux | grep "${stackName}" | grep -v grep || true`, {
19545
19744
  encoding: "utf-8",
19546
19745
  stdio: ["pipe", "pipe", "ignore"]
19547
19746
  // Suppress stderr
@@ -19556,9 +19755,9 @@ function checkIfRunning(stackName) {
19556
19755
  }
19557
19756
 
19558
19757
  // src/commands/auth.js
19559
- var fs17 = __toESM(require("fs/promises"), 1);
19560
- var path15 = __toESM(require("path"), 1);
19561
- var import_child_process4 = require("child_process");
19758
+ var fs18 = __toESM(require("fs/promises"), 1);
19759
+ var path16 = __toESM(require("path"), 1);
19760
+ var import_child_process5 = require("child_process");
19562
19761
  init_src();
19563
19762
  var net = __toESM(require("net"), 1);
19564
19763
  async function findAvailablePort(basePort = 3456) {
@@ -19589,26 +19788,26 @@ function isPortAvailable(port) {
19589
19788
  async function detectRuntime2(stackPath) {
19590
19789
  const runtimes = ["node", "python"];
19591
19790
  for (const runtime of runtimes) {
19592
- const runtimePath = path15.join(stackPath, runtime);
19791
+ const runtimePath = path16.join(stackPath, runtime);
19593
19792
  try {
19594
- await fs17.access(runtimePath);
19793
+ await fs18.access(runtimePath);
19595
19794
  if (runtime === "node") {
19596
- const authTs = path15.join(runtimePath, "src", "auth.ts");
19597
- const authJs = path15.join(runtimePath, "dist", "auth.js");
19795
+ const authTs = path16.join(runtimePath, "src", "auth.ts");
19796
+ const authJs = path16.join(runtimePath, "dist", "auth.js");
19598
19797
  try {
19599
- await fs17.access(authTs);
19798
+ await fs18.access(authTs);
19600
19799
  return { runtime: "node", authScript: authTs, useTsx: true };
19601
19800
  } catch {
19602
19801
  try {
19603
- await fs17.access(authJs);
19802
+ await fs18.access(authJs);
19604
19803
  return { runtime: "node", authScript: authJs, useTsx: false };
19605
19804
  } catch {
19606
19805
  }
19607
19806
  }
19608
19807
  } else if (runtime === "python") {
19609
- const authPy = path15.join(runtimePath, "src", "auth.py");
19808
+ const authPy = path16.join(runtimePath, "src", "auth.py");
19610
19809
  try {
19611
- await fs17.access(authPy);
19810
+ await fs18.access(authPy);
19612
19811
  return { runtime: "python", authScript: authPy, useTsx: false };
19613
19812
  } catch {
19614
19813
  }
@@ -19658,14 +19857,14 @@ Installed stacks:`);
19658
19857
  console.log(`Using port: ${port}`);
19659
19858
  console.log("");
19660
19859
  let cmd;
19661
- const cwd = path15.dirname(authInfo.authScript);
19860
+ const cwd = path16.dirname(authInfo.authScript);
19662
19861
  if (authInfo.runtime === "node") {
19663
- const distAuth = path15.join(cwd, "..", "dist", "auth.js");
19862
+ const distAuth = path16.join(cwd, "..", "dist", "auth.js");
19664
19863
  let useBuiltInPort = false;
19665
19864
  let tempAuthScript = null;
19666
19865
  try {
19667
- await fs17.access(distAuth);
19668
- const distContent = await fs17.readFile(distAuth, "utf-8");
19866
+ await fs18.access(distAuth);
19867
+ const distContent = await fs18.readFile(distAuth, "utf-8");
19669
19868
  if (distContent.includes("findAvailablePort")) {
19670
19869
  console.log("Using compiled authentication script...");
19671
19870
  cmd = `node ${distAuth}${accountEmail ? ` ${accountEmail}` : ""}`;
@@ -19674,11 +19873,11 @@ Installed stacks:`);
19674
19873
  } catch {
19675
19874
  }
19676
19875
  if (!useBuiltInPort) {
19677
- const authContent = await fs17.readFile(authInfo.authScript, "utf-8");
19876
+ const authContent = await fs18.readFile(authInfo.authScript, "utf-8");
19678
19877
  const tempExt = authInfo.useTsx ? ".ts" : ".mjs";
19679
- tempAuthScript = path15.join(cwd, "..", `auth-temp${tempExt}`);
19878
+ tempAuthScript = path16.join(cwd, "..", `auth-temp${tempExt}`);
19680
19879
  const modifiedContent = authContent.replace(/localhost:3456/g, `localhost:${port}`).replace(/server\.listen\(3456/g, `server.listen(${port}`);
19681
- await fs17.writeFile(tempAuthScript, modifiedContent);
19880
+ await fs18.writeFile(tempAuthScript, modifiedContent);
19682
19881
  if (authInfo.useTsx) {
19683
19882
  cmd = `npx tsx ${tempAuthScript}${accountEmail ? ` ${accountEmail}` : ""}`;
19684
19883
  } else {
@@ -19688,17 +19887,17 @@ Installed stacks:`);
19688
19887
  console.log("Starting OAuth flow...");
19689
19888
  console.log("");
19690
19889
  try {
19691
- (0, import_child_process4.execSync)(cmd, {
19890
+ (0, import_child_process5.execSync)(cmd, {
19692
19891
  cwd,
19693
19892
  stdio: "inherit"
19694
19893
  });
19695
19894
  if (tempAuthScript) {
19696
- await fs17.unlink(tempAuthScript);
19895
+ await fs18.unlink(tempAuthScript);
19697
19896
  }
19698
19897
  } catch (error) {
19699
19898
  if (tempAuthScript) {
19700
19899
  try {
19701
- await fs17.unlink(tempAuthScript);
19900
+ await fs18.unlink(tempAuthScript);
19702
19901
  } catch {
19703
19902
  }
19704
19903
  }
@@ -19708,7 +19907,7 @@ Installed stacks:`);
19708
19907
  cmd = `python3 ${authInfo.authScript}${accountEmail ? ` ${accountEmail}` : ""}`;
19709
19908
  console.log("Starting OAuth flow...");
19710
19909
  console.log("");
19711
- (0, import_child_process4.execSync)(cmd, {
19910
+ (0, import_child_process5.execSync)(cmd, {
19712
19911
  cwd,
19713
19912
  stdio: "inherit",
19714
19913
  env: {