@learnrudi/cli 1.1.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 +704 -267
  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 });
@@ -14961,10 +14961,26 @@ COMMANDS
14961
14961
  stats Show usage statistics
14962
14962
  search <query> Search conversation history
14963
14963
  init Initialize or migrate database
14964
+ path Show database file path
14965
+ reset Delete all data (requires --force)
14966
+ vacuum Compact database and reclaim space
14967
+ backup [file] Create database backup
14968
+ prune [days] Delete sessions older than N days (default: 90)
14969
+ tables Show table row counts
14970
+
14971
+ OPTIONS
14972
+ --force Required for destructive operations
14973
+ --dry-run Preview without making changes
14974
+ --json Output as JSON
14964
14975
 
14965
14976
  EXAMPLES
14966
14977
  rudi db stats
14967
14978
  rudi db search "authentication bug"
14979
+ rudi db reset --force
14980
+ rudi db vacuum
14981
+ rudi db backup ~/backups/rudi.db
14982
+ rudi db prune 30 --dry-run
14983
+ rudi db tables
14968
14984
  `,
14969
14985
  import: `
14970
14986
  rudi import - Import sessions from AI providers
@@ -15259,7 +15275,7 @@ async function installSinglePackage(pkg, options = {}) {
15259
15275
  onProgress?.({ phase: "downloading", package: pkg.id });
15260
15276
  if (pkg.npmPackage) {
15261
15277
  try {
15262
- const { execSync: execSync4 } = await import("child_process");
15278
+ const { execSync: execSync5 } = await import("child_process");
15263
15279
  if (!import_fs4.default.existsSync(installPath)) {
15264
15280
  import_fs4.default.mkdirSync(installPath, { recursive: true });
15265
15281
  }
@@ -15267,16 +15283,16 @@ async function installSinglePackage(pkg, options = {}) {
15267
15283
  const resourcesPath = process.env.RESOURCES_PATH;
15268
15284
  const npmCmd = resourcesPath ? import_path4.default.join(resourcesPath, "bundled-runtimes", "node", "bin", "npm") : "npm";
15269
15285
  if (!import_fs4.default.existsSync(import_path4.default.join(installPath, "package.json"))) {
15270
- execSync4(`"${npmCmd}" init -y`, { cwd: installPath, stdio: "pipe" });
15286
+ execSync5(`"${npmCmd}" init -y`, { cwd: installPath, stdio: "pipe" });
15271
15287
  }
15272
- execSync4(`"${npmCmd}" install ${pkg.npmPackage}`, { cwd: installPath, stdio: "pipe" });
15288
+ execSync5(`"${npmCmd}" install ${pkg.npmPackage}`, { cwd: installPath, stdio: "pipe" });
15273
15289
  if (pkg.postInstall) {
15274
15290
  onProgress?.({ phase: "postInstall", package: pkg.id, message: pkg.postInstall });
15275
15291
  const postInstallCmd = pkg.postInstall.replace(
15276
15292
  /^npx\s+(\S+)/,
15277
15293
  `"${import_path4.default.join(installPath, "node_modules", ".bin", "$1")}"`
15278
15294
  );
15279
- execSync4(postInstallCmd, { cwd: installPath, stdio: "pipe" });
15295
+ execSync5(postInstallCmd, { cwd: installPath, stdio: "pipe" });
15280
15296
  }
15281
15297
  import_fs4.default.writeFileSync(
15282
15298
  import_path4.default.join(installPath, "manifest.json"),
@@ -15298,15 +15314,15 @@ async function installSinglePackage(pkg, options = {}) {
15298
15314
  }
15299
15315
  if (pkg.pipPackage) {
15300
15316
  try {
15301
- const { execSync: execSync4 } = await import("child_process");
15317
+ const { execSync: execSync5 } = await import("child_process");
15302
15318
  if (!import_fs4.default.existsSync(installPath)) {
15303
15319
  import_fs4.default.mkdirSync(installPath, { recursive: true });
15304
15320
  }
15305
15321
  onProgress?.({ phase: "installing", package: pkg.id, message: `pip install ${pkg.pipPackage}` });
15306
15322
  const pythonPath = import_path4.default.join(PATHS.runtimes, "python", "bin", "python3");
15307
15323
  const pythonCmd = import_fs4.default.existsSync(pythonPath) ? pythonPath : "python3";
15308
- execSync4(`"${pythonCmd}" -m venv "${installPath}/venv"`, { stdio: "pipe" });
15309
- 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" });
15310
15326
  import_fs4.default.writeFileSync(
15311
15327
  import_path4.default.join(installPath, "manifest.json"),
15312
15328
  JSON.stringify({
@@ -15528,7 +15544,7 @@ async function listInstalled(kind) {
15528
15544
  return packages;
15529
15545
  }
15530
15546
  async function installStackDependencies(stackPath, onProgress) {
15531
- const { execSync: execSync4 } = await import("child_process");
15547
+ const { execSync: execSync5 } = await import("child_process");
15532
15548
  const nodePath = import_path4.default.join(stackPath, "node");
15533
15549
  if (import_fs4.default.existsSync(nodePath)) {
15534
15550
  const packageJsonPath = import_path4.default.join(nodePath, "package.json");
@@ -15536,7 +15552,7 @@ async function installStackDependencies(stackPath, onProgress) {
15536
15552
  onProgress?.({ phase: "installing-deps", message: "Installing Node.js dependencies..." });
15537
15553
  try {
15538
15554
  const npmCmd = await findNpmExecutable();
15539
- execSync4(`"${npmCmd}" install`, { cwd: nodePath, stdio: "pipe" });
15555
+ execSync5(`"${npmCmd}" install`, { cwd: nodePath, stdio: "pipe" });
15540
15556
  } catch (error) {
15541
15557
  console.warn(`Warning: Failed to install Node.js dependencies: ${error.message}`);
15542
15558
  }
@@ -15549,8 +15565,8 @@ async function installStackDependencies(stackPath, onProgress) {
15549
15565
  onProgress?.({ phase: "installing-deps", message: "Installing Python dependencies..." });
15550
15566
  try {
15551
15567
  const pythonCmd = await findPythonExecutable();
15552
- execSync4(`"${pythonCmd}" -m venv venv`, { cwd: pythonPath, stdio: "pipe" });
15553
- 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" });
15554
15570
  } catch (error) {
15555
15571
  console.warn(`Warning: Failed to install Python dependencies: ${error.message}`);
15556
15572
  }
@@ -15590,6 +15606,171 @@ async function findPythonExecutable() {
15590
15606
  return "python3";
15591
15607
  }
15592
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
+
15593
15774
  // src/commands/search.js
15594
15775
  function pluralizeKind(kind) {
15595
15776
  if (!kind) return "packages";
@@ -15695,31 +15876,31 @@ Total: ${totalCount} package(s) available`);
15695
15876
  }
15696
15877
 
15697
15878
  // src/commands/install.js
15698
- var fs6 = __toESM(require("fs/promises"), 1);
15699
- var path6 = __toESM(require("path"), 1);
15879
+ var fs7 = __toESM(require("fs/promises"), 1);
15880
+ var path7 = __toESM(require("path"), 1);
15700
15881
 
15701
15882
  // src/utils/mcp-registry.js
15702
- var fs5 = __toESM(require("fs/promises"), 1);
15703
- var path5 = __toESM(require("path"), 1);
15883
+ var fs6 = __toESM(require("fs/promises"), 1);
15884
+ var path6 = __toESM(require("path"), 1);
15704
15885
  var os2 = __toESM(require("os"), 1);
15705
15886
  var HOME = os2.homedir();
15706
15887
  var AGENT_CONFIGS = {
15707
- claude: path5.join(HOME, ".claude", "settings.json"),
15708
- codex: path5.join(HOME, ".codex", "config.toml"),
15709
- 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")
15710
15891
  };
15711
15892
  async function readJson(filePath) {
15712
15893
  try {
15713
- const content = await fs5.readFile(filePath, "utf-8");
15894
+ const content = await fs6.readFile(filePath, "utf-8");
15714
15895
  return JSON.parse(content);
15715
15896
  } catch {
15716
15897
  return {};
15717
15898
  }
15718
15899
  }
15719
15900
  async function writeJson(filePath, data) {
15720
- const dir = path5.dirname(filePath);
15721
- await fs5.mkdir(dir, { recursive: true });
15722
- 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");
15723
15904
  }
15724
15905
  function parseTomlValue(value) {
15725
15906
  if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
@@ -15827,16 +16008,16 @@ function stringifyToml(config, prefix = "") {
15827
16008
  }
15828
16009
  async function readToml(filePath) {
15829
16010
  try {
15830
- const content = await fs5.readFile(filePath, "utf-8");
16011
+ const content = await fs6.readFile(filePath, "utf-8");
15831
16012
  return parseToml(content);
15832
16013
  } catch {
15833
16014
  return {};
15834
16015
  }
15835
16016
  }
15836
16017
  async function writeToml(filePath, data) {
15837
- const dir = path5.dirname(filePath);
15838
- await fs5.mkdir(dir, { recursive: true });
15839
- 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");
15840
16021
  }
15841
16022
  function parseEnvFile(content) {
15842
16023
  const env = {};
@@ -15858,9 +16039,9 @@ function parseEnvFile(content) {
15858
16039
  return env;
15859
16040
  }
15860
16041
  async function readStackEnv(installPath) {
15861
- const envPath = path5.join(installPath, ".env");
16042
+ const envPath = path6.join(installPath, ".env");
15862
16043
  try {
15863
- const content = await fs5.readFile(envPath, "utf-8");
16044
+ const content = await fs6.readFile(envPath, "utf-8");
15864
16045
  return parseEnvFile(content);
15865
16046
  } catch {
15866
16047
  return {};
@@ -15871,9 +16052,9 @@ async function buildMcpConfig(stackId, installPath, manifest) {
15871
16052
  let args = [];
15872
16053
  const cwd = installPath;
15873
16054
  const resolveRelativePath2 = (value) => {
15874
- if (!value || path5.isAbsolute(value)) return value;
16055
+ if (!value || path6.isAbsolute(value)) return value;
15875
16056
  const isPathLike = value.startsWith(".") || value.includes("/") || value.includes("\\");
15876
- return isPathLike ? path5.join(installPath, value) : value;
16057
+ return isPathLike ? path6.join(installPath, value) : value;
15877
16058
  };
15878
16059
  if (manifest.command) {
15879
16060
  const cmdArray = Array.isArray(manifest.command) ? manifest.command : [manifest.command];
@@ -15884,7 +16065,7 @@ async function buildMcpConfig(stackId, installPath, manifest) {
15884
16065
  args = (manifest.mcp.args || []).map((arg) => resolveRelativePath2(arg));
15885
16066
  if (manifest.mcp.entry) {
15886
16067
  args = args.map(
15887
- (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
15888
16069
  );
15889
16070
  }
15890
16071
  } else {
@@ -15918,9 +16099,9 @@ async function optimizeEntryPoint(installPath, command, args) {
15918
16099
  }
15919
16100
  const tsFile = args[tsFileIndex];
15920
16101
  const jsFile = tsFile.replace("/src/", "/dist/").replace(".ts", ".js");
15921
- const jsPath = path5.isAbsolute(jsFile) ? jsFile : path5.join(installPath, jsFile);
16102
+ const jsPath = path6.isAbsolute(jsFile) ? jsFile : path6.join(installPath, jsFile);
15922
16103
  try {
15923
- await fs5.access(jsPath);
16104
+ await fs6.access(jsPath);
15924
16105
  return {
15925
16106
  command: "node",
15926
16107
  args: [jsPath]
@@ -16039,12 +16220,12 @@ async function unregisterMcpGemini(stackId) {
16039
16220
  }
16040
16221
  }
16041
16222
  async function getInstalledAgents() {
16042
- const agentsDir = path5.join(HOME, ".rudi", "agents");
16223
+ const agentsDir = path6.join(HOME, ".rudi", "agents");
16043
16224
  const installed = [];
16044
16225
  for (const agent of ["claude", "codex", "gemini"]) {
16045
- const agentPath = path5.join(agentsDir, agent);
16226
+ const agentPath = path6.join(agentsDir, agent);
16046
16227
  try {
16047
- await fs5.access(agentPath);
16228
+ await fs6.access(agentPath);
16048
16229
  installed.push(agent);
16049
16230
  } catch {
16050
16231
  }
@@ -16090,9 +16271,9 @@ async function unregisterMcpAll(stackId, targetAgents = null) {
16090
16271
 
16091
16272
  // src/commands/install.js
16092
16273
  async function loadManifest(installPath) {
16093
- const manifestPath = path6.join(installPath, "manifest.json");
16274
+ const manifestPath = path7.join(installPath, "manifest.json");
16094
16275
  try {
16095
- const content = await fs6.readFile(manifestPath, "utf-8");
16276
+ const content = await fs7.readFile(manifestPath, "utf-8");
16096
16277
  return JSON.parse(content);
16097
16278
  } catch {
16098
16279
  return null;
@@ -16120,9 +16301,9 @@ function getSecretLabel(secret) {
16120
16301
  async function createEnvFile(installPath, manifest) {
16121
16302
  const secrets = getManifestSecrets(manifest);
16122
16303
  if (!secrets.length) return null;
16123
- const envPath = path6.join(installPath, ".env");
16304
+ const envPath = path7.join(installPath, ".env");
16124
16305
  try {
16125
- await fs6.access(envPath);
16306
+ await fs7.access(envPath);
16126
16307
  console.log(` .env file already exists, preserving existing secrets`);
16127
16308
  return envPath;
16128
16309
  } catch {
@@ -16144,7 +16325,7 @@ async function createEnvFile(installPath, manifest) {
16144
16325
  lines.push(`${key}=`);
16145
16326
  lines.push("");
16146
16327
  }
16147
- await fs6.writeFile(envPath, lines.join("\n"), "utf-8");
16328
+ await fs7.writeFile(envPath, lines.join("\n"), "utf-8");
16148
16329
  return envPath;
16149
16330
  }
16150
16331
  async function cmdInstall(args, flags) {
@@ -16196,6 +16377,19 @@ Required secrets:`);
16196
16377
  console.log(` - ${name}`);
16197
16378
  }
16198
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
+ }
16199
16393
  console.log(`
16200
16394
  Installing...`);
16201
16395
  const result = await installPackage(pkgId, {
@@ -16258,32 +16452,32 @@ Run with: rudi run ${pkgId}`);
16258
16452
  }
16259
16453
 
16260
16454
  // ../packages/runner/src/spawn.js
16261
- var import_child_process = require("child_process");
16262
- var import_path6 = __toESM(require("path"), 1);
16263
- 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);
16264
16458
 
16265
16459
  // ../packages/runner/src/secrets.js
16266
- var import_fs5 = __toESM(require("fs"), 1);
16267
- var import_path5 = __toESM(require("path"), 1);
16460
+ var import_fs6 = __toESM(require("fs"), 1);
16461
+ var import_path6 = __toESM(require("path"), 1);
16268
16462
  var import_os2 = __toESM(require("os"), 1);
16269
- 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");
16270
16464
  function loadSecrets() {
16271
- if (!import_fs5.default.existsSync(SECRETS_PATH)) {
16465
+ if (!import_fs6.default.existsSync(SECRETS_PATH)) {
16272
16466
  return {};
16273
16467
  }
16274
16468
  try {
16275
- const content = import_fs5.default.readFileSync(SECRETS_PATH, "utf-8");
16469
+ const content = import_fs6.default.readFileSync(SECRETS_PATH, "utf-8");
16276
16470
  return JSON.parse(content);
16277
16471
  } catch {
16278
16472
  return {};
16279
16473
  }
16280
16474
  }
16281
16475
  function saveSecrets(secrets) {
16282
- const dir = import_path5.default.dirname(SECRETS_PATH);
16283
- if (!import_fs5.default.existsSync(dir)) {
16284
- 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 });
16285
16479
  }
16286
- import_fs5.default.writeFileSync(SECRETS_PATH, JSON.stringify(secrets, null, 2), {
16480
+ import_fs6.default.writeFileSync(SECRETS_PATH, JSON.stringify(secrets, null, 2), {
16287
16481
  mode: 384
16288
16482
  // Read/write only for owner
16289
16483
  });
@@ -16369,12 +16563,12 @@ async function runStack(id, options = {}) {
16369
16563
  const { inputs = {}, cwd, env = {}, onStdout, onStderr, onExit, signal } = options;
16370
16564
  const startTime = Date.now();
16371
16565
  const packagePath = getPackagePath(id);
16372
- const manifestPath = import_path6.default.join(packagePath, "manifest.json");
16373
- const { default: fs18 } = await import("fs");
16374
- 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)) {
16375
16569
  throw new Error(`Stack manifest not found: ${id}`);
16376
16570
  }
16377
- const manifest = JSON.parse(fs18.readFileSync(manifestPath, "utf-8"));
16571
+ const manifest = JSON.parse(fs19.readFileSync(manifestPath, "utf-8"));
16378
16572
  const { command, args } = resolveCommandFromManifest(manifest, packagePath);
16379
16573
  const secrets = await getSecrets(manifest.requires?.secrets || []);
16380
16574
  const runEnv = {
@@ -16385,7 +16579,7 @@ async function runStack(id, options = {}) {
16385
16579
  RUDI_PACKAGE_ID: id,
16386
16580
  RUDI_PACKAGE_PATH: packagePath
16387
16581
  };
16388
- const proc = (0, import_child_process.spawn)(command, args, {
16582
+ const proc = (0, import_child_process2.spawn)(command, args, {
16389
16583
  cwd: cwd || packagePath,
16390
16584
  env: runEnv,
16391
16585
  stdio: ["pipe", "pipe", "pipe"],
@@ -16430,15 +16624,15 @@ async function runStack(id, options = {}) {
16430
16624
  }
16431
16625
  function getCommand(runtime) {
16432
16626
  const runtimeName = runtime.replace("runtime:", "");
16433
- const runtimePath = import_path6.default.join(PATHS.runtimes, runtimeName);
16627
+ const runtimePath = import_path7.default.join(PATHS.runtimes, runtimeName);
16434
16628
  const binaryPaths = [
16435
- import_path6.default.join(runtimePath, "bin", runtimeName === "python" ? "python3" : runtimeName),
16436
- import_path6.default.join(runtimePath, "bin", runtimeName),
16437
- import_path6.default.join(runtimePath, runtimeName === "python" ? "python3" : runtimeName),
16438
- 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)
16439
16633
  ];
16440
16634
  for (const binPath of binaryPaths) {
16441
- if (import_fs6.default.existsSync(binPath)) {
16635
+ if (import_fs7.default.existsSync(binPath)) {
16442
16636
  return binPath;
16443
16637
  }
16444
16638
  }
@@ -16462,7 +16656,7 @@ function resolveCommandFromManifest(manifest, packagePath) {
16462
16656
  return { command: command2, args };
16463
16657
  }
16464
16658
  const entry = manifest.entry || "index.js";
16465
- const entryPath = import_path6.default.join(packagePath, entry);
16659
+ const entryPath = import_path7.default.join(packagePath, entry);
16466
16660
  const runtime = manifest.runtime || "runtime:node";
16467
16661
  const command = getCommand(runtime);
16468
16662
  return { command, args: [entryPath] };
@@ -16471,21 +16665,21 @@ function resolveRelativePath(value, basePath) {
16471
16665
  if (typeof value !== "string" || value.startsWith("-")) {
16472
16666
  return value;
16473
16667
  }
16474
- if (import_path6.default.isAbsolute(value)) {
16668
+ if (import_path7.default.isAbsolute(value)) {
16475
16669
  return value;
16476
16670
  }
16477
16671
  if (value.includes("/") || value.startsWith(".")) {
16478
- return import_path6.default.join(basePath, value);
16672
+ return import_path7.default.join(basePath, value);
16479
16673
  }
16480
16674
  return value;
16481
16675
  }
16482
16676
 
16483
16677
  // ../packages/manifest/src/stack.js
16484
16678
  var import_yaml2 = __toESM(require_dist(), 1);
16485
- var import_fs7 = __toESM(require("fs"), 1);
16486
- var import_path7 = __toESM(require("path"), 1);
16679
+ var import_fs8 = __toESM(require("fs"), 1);
16680
+ var import_path8 = __toESM(require("path"), 1);
16487
16681
  function parseStackManifest(filePath) {
16488
- const content = import_fs7.default.readFileSync(filePath, "utf-8");
16682
+ const content = import_fs8.default.readFileSync(filePath, "utf-8");
16489
16683
  return parseStackYaml(content, filePath);
16490
16684
  }
16491
16685
  function parseStackYaml(content, source = "stack.yaml") {
@@ -16603,8 +16797,8 @@ function validateStackManifest(manifest, source) {
16603
16797
  function findStackManifest(dir) {
16604
16798
  const candidates = ["stack.yaml", "stack.yml", "manifest.yaml", "manifest.yml"];
16605
16799
  for (const filename of candidates) {
16606
- const filePath = import_path7.default.join(dir, filename);
16607
- if (import_fs7.default.existsSync(filePath)) {
16800
+ const filePath = import_path8.default.join(dir, filename);
16801
+ if (import_fs8.default.existsSync(filePath)) {
16608
16802
  return filePath;
16609
16803
  }
16610
16804
  }
@@ -16759,8 +16953,8 @@ var validatePromptInternal = ajv.compile(promptSchema);
16759
16953
  var validateRuntimeInternal = ajv.compile(runtimeSchema);
16760
16954
 
16761
16955
  // src/commands/run.js
16762
- var import_fs8 = __toESM(require("fs"), 1);
16763
- var import_path8 = __toESM(require("path"), 1);
16956
+ var import_fs9 = __toESM(require("fs"), 1);
16957
+ var import_path9 = __toESM(require("path"), 1);
16764
16958
  async function cmdRun(args, flags) {
16765
16959
  const stackId = args[0];
16766
16960
  if (!stackId) {
@@ -16781,9 +16975,9 @@ async function cmdRun(args, flags) {
16781
16975
  if (manifestPath) {
16782
16976
  manifest = parseStackManifest(manifestPath);
16783
16977
  } else {
16784
- const jsonPath = import_path8.default.join(packagePath, "manifest.json");
16785
- if (import_fs8.default.existsSync(jsonPath)) {
16786
- 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"));
16787
16981
  }
16788
16982
  }
16789
16983
  } catch (error) {
@@ -17238,10 +17432,14 @@ function promptSecret(prompt) {
17238
17432
  });
17239
17433
  }
17240
17434
 
17435
+ // src/commands/db.js
17436
+ var import_fs11 = require("fs");
17437
+ var import_path11 = require("path");
17438
+
17241
17439
  // ../packages/db/src/index.js
17242
17440
  var import_better_sqlite3 = __toESM(require("better-sqlite3"), 1);
17243
- var import_path9 = __toESM(require("path"), 1);
17244
- var import_fs9 = __toESM(require("fs"), 1);
17441
+ var import_path10 = __toESM(require("path"), 1);
17442
+ var import_fs10 = __toESM(require("fs"), 1);
17245
17443
  init_src();
17246
17444
 
17247
17445
  // ../packages/db/src/schema.js
@@ -17978,9 +18176,9 @@ var DB_PATH = PATHS.dbFile;
17978
18176
  var db = null;
17979
18177
  function getDb(options = {}) {
17980
18178
  if (!db) {
17981
- const dbDir = import_path9.default.dirname(DB_PATH);
17982
- if (!import_fs9.default.existsSync(dbDir)) {
17983
- 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 });
17984
18182
  }
17985
18183
  db = new import_better_sqlite3.default(DB_PATH, {
17986
18184
  readonly: options.readonly || false
@@ -17993,7 +18191,7 @@ function getDb(options = {}) {
17993
18191
  return db;
17994
18192
  }
17995
18193
  function isDatabaseInitialized() {
17996
- if (!import_fs9.default.existsSync(DB_PATH)) {
18194
+ if (!import_fs10.default.existsSync(DB_PATH)) {
17997
18195
  return false;
17998
18196
  }
17999
18197
  try {
@@ -18013,7 +18211,7 @@ function getDbPath() {
18013
18211
  }
18014
18212
  function getDbSize() {
18015
18213
  try {
18016
- const stats = import_fs9.default.statSync(DB_PATH);
18214
+ const stats = import_fs10.default.statSync(DB_PATH);
18017
18215
  return stats.size;
18018
18216
  } catch {
18019
18217
  return null;
@@ -18036,6 +18234,21 @@ async function cmdDb(args, flags) {
18036
18234
  case "path":
18037
18235
  console.log(getDbPath());
18038
18236
  break;
18237
+ case "reset":
18238
+ await dbReset(flags);
18239
+ break;
18240
+ case "vacuum":
18241
+ dbVacuum(flags);
18242
+ break;
18243
+ case "backup":
18244
+ dbBackup(args.slice(1), flags);
18245
+ break;
18246
+ case "prune":
18247
+ dbPrune(args.slice(1), flags);
18248
+ break;
18249
+ case "tables":
18250
+ dbTables(flags);
18251
+ break;
18039
18252
  default:
18040
18253
  console.log(`
18041
18254
  rudi db - Database operations
@@ -18045,11 +18258,24 @@ COMMANDS
18045
18258
  search <query> Search conversation history
18046
18259
  init Initialize or migrate database
18047
18260
  path Show database file path
18261
+ reset Delete all data (requires --force)
18262
+ vacuum Compact database and reclaim space
18263
+ backup [file] Create database backup
18264
+ prune [days] Delete sessions older than N days (default: 90)
18265
+ tables Show table row counts
18266
+
18267
+ OPTIONS
18268
+ --force Required for destructive operations
18269
+ --dry-run Preview without making changes
18048
18270
 
18049
18271
  EXAMPLES
18050
18272
  rudi db stats
18051
18273
  rudi db search "authentication bug"
18052
18274
  rudi db init
18275
+ rudi db reset --force
18276
+ rudi db vacuum
18277
+ rudi db backup ~/backups/rudi-backup.db
18278
+ rudi db prune 30 --dry-run
18053
18279
  `);
18054
18280
  }
18055
18281
  }
@@ -18176,26 +18402,216 @@ function truncate(str, len) {
18176
18402
  function stripHighlight(str) {
18177
18403
  return str.replace(/>>>/g, "").replace(/<<</g, "");
18178
18404
  }
18405
+ async function dbReset(flags) {
18406
+ if (!isDatabaseInitialized()) {
18407
+ console.log("Database not initialized.");
18408
+ return;
18409
+ }
18410
+ if (!flags.force) {
18411
+ console.error("This will delete ALL data from the database.");
18412
+ console.error("Use --force to confirm.");
18413
+ process.exit(1);
18414
+ }
18415
+ const db3 = getDb();
18416
+ const dbPath = getDbPath();
18417
+ const tables = ["sessions", "turns", "tool_calls", "projects"];
18418
+ const counts = {};
18419
+ for (const table of tables) {
18420
+ try {
18421
+ const row = db3.prepare(`SELECT COUNT(*) as count FROM ${table}`).get();
18422
+ counts[table] = row.count;
18423
+ } catch (e) {
18424
+ counts[table] = 0;
18425
+ }
18426
+ }
18427
+ console.log("Deleting all data...");
18428
+ console.log("\u2500".repeat(40));
18429
+ const deleteOrder = ["tool_calls", "turns", "sessions", "projects"];
18430
+ for (const table of deleteOrder) {
18431
+ try {
18432
+ db3.prepare(`DELETE FROM ${table}`).run();
18433
+ console.log(` ${table}: ${counts[table]} rows deleted`);
18434
+ } catch (e) {
18435
+ }
18436
+ }
18437
+ try {
18438
+ db3.prepare("DELETE FROM turns_fts").run();
18439
+ console.log(" turns_fts: cleared");
18440
+ } catch (e) {
18441
+ }
18442
+ console.log("\u2500".repeat(40));
18443
+ console.log("Database reset complete.");
18444
+ console.log(`Path: ${dbPath}`);
18445
+ }
18446
+ function dbVacuum(flags) {
18447
+ if (!isDatabaseInitialized()) {
18448
+ console.log("Database not initialized.");
18449
+ return;
18450
+ }
18451
+ const dbPath = getDbPath();
18452
+ const sizeBefore = getDbSize();
18453
+ console.log("Compacting database...");
18454
+ console.log(` Before: ${formatBytes(sizeBefore)}`);
18455
+ const db3 = getDb();
18456
+ db3.exec("VACUUM");
18457
+ const sizeAfter = getDbSize();
18458
+ const saved = sizeBefore - sizeAfter;
18459
+ console.log(` After: ${formatBytes(sizeAfter)}`);
18460
+ if (saved > 0) {
18461
+ console.log(` Saved: ${formatBytes(saved)} (${(saved / sizeBefore * 100).toFixed(1)}%)`);
18462
+ } else {
18463
+ console.log(" No space reclaimed.");
18464
+ }
18465
+ }
18466
+ function dbBackup(args, flags) {
18467
+ if (!isDatabaseInitialized()) {
18468
+ console.log("Database not initialized.");
18469
+ return;
18470
+ }
18471
+ const dbPath = getDbPath();
18472
+ let backupPath = args[0];
18473
+ if (!backupPath) {
18474
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
18475
+ backupPath = (0, import_path11.join)((0, import_path11.dirname)(dbPath), `rudi-backup-${timestamp}.db`);
18476
+ }
18477
+ if (backupPath.startsWith("~")) {
18478
+ backupPath = (0, import_path11.join)(process.env.HOME || "", backupPath.slice(1));
18479
+ }
18480
+ if ((0, import_fs11.existsSync)(backupPath) && !flags.force) {
18481
+ console.error(`Backup file already exists: ${backupPath}`);
18482
+ console.error("Use --force to overwrite.");
18483
+ process.exit(1);
18484
+ }
18485
+ console.log("Creating backup...");
18486
+ console.log(` Source: ${dbPath}`);
18487
+ console.log(` Dest: ${backupPath}`);
18488
+ try {
18489
+ const db3 = getDb();
18490
+ db3.exec("VACUUM INTO ?", [backupPath]);
18491
+ } catch (e) {
18492
+ (0, import_fs11.copyFileSync)(dbPath, backupPath);
18493
+ }
18494
+ const size = getDbSize();
18495
+ console.log(` Size: ${formatBytes(size)}`);
18496
+ console.log("Backup complete.");
18497
+ }
18498
+ function dbPrune(args, flags) {
18499
+ if (!isDatabaseInitialized()) {
18500
+ console.log("Database not initialized.");
18501
+ return;
18502
+ }
18503
+ const days = parseInt(args[0]) || 90;
18504
+ const dryRun = flags["dry-run"] || flags.dryRun;
18505
+ const cutoffDate = new Date(Date.now() - days * 24 * 60 * 60 * 1e3).toISOString();
18506
+ const db3 = getDb();
18507
+ const toDelete = db3.prepare(`
18508
+ SELECT COUNT(*) as count FROM sessions
18509
+ WHERE last_active_at < ? OR (last_active_at IS NULL AND created_at < ?)
18510
+ `).get(cutoffDate, cutoffDate);
18511
+ const total = db3.prepare("SELECT COUNT(*) as count FROM sessions").get();
18512
+ console.log(`Sessions older than ${days} days: ${toDelete.count}`);
18513
+ console.log(`Total sessions: ${total.count}`);
18514
+ console.log(`Cutoff date: ${cutoffDate.slice(0, 10)}`);
18515
+ if (toDelete.count === 0) {
18516
+ console.log("\nNo sessions to prune.");
18517
+ return;
18518
+ }
18519
+ if (dryRun) {
18520
+ console.log("\n(Dry run - no changes made)");
18521
+ return;
18522
+ }
18523
+ if (!flags.force) {
18524
+ console.error(`
18525
+ This will delete ${toDelete.count} sessions and their turns.`);
18526
+ console.error("Use --force to confirm, or --dry-run to preview.");
18527
+ process.exit(1);
18528
+ }
18529
+ console.log("\nDeleting old sessions...");
18530
+ const sessionIds = db3.prepare(`
18531
+ SELECT id FROM sessions
18532
+ WHERE last_active_at < ? OR (last_active_at IS NULL AND created_at < ?)
18533
+ `).all(cutoffDate, cutoffDate).map((r) => r.id);
18534
+ let turnsDeleted = 0;
18535
+ let toolCallsDeleted = 0;
18536
+ for (const sessionId of sessionIds) {
18537
+ const turnIds = db3.prepare("SELECT id FROM turns WHERE session_id = ?").all(sessionId).map((r) => r.id);
18538
+ for (const turnId of turnIds) {
18539
+ const result = db3.prepare("DELETE FROM tool_calls WHERE turn_id = ?").run(turnId);
18540
+ toolCallsDeleted += result.changes;
18541
+ }
18542
+ const turnResult = db3.prepare("DELETE FROM turns WHERE session_id = ?").run(sessionId);
18543
+ turnsDeleted += turnResult.changes;
18544
+ }
18545
+ const sessionResult = db3.prepare(`
18546
+ DELETE FROM sessions
18547
+ WHERE last_active_at < ? OR (last_active_at IS NULL AND created_at < ?)
18548
+ `).run(cutoffDate, cutoffDate);
18549
+ console.log(` Sessions deleted: ${sessionResult.changes}`);
18550
+ console.log(` Turns deleted: ${turnsDeleted}`);
18551
+ console.log(` Tool calls deleted: ${toolCallsDeleted}`);
18552
+ console.log('\nPrune complete. Run "rudi db vacuum" to reclaim disk space.');
18553
+ }
18554
+ function dbTables(flags) {
18555
+ if (!isDatabaseInitialized()) {
18556
+ console.log("Database not initialized.");
18557
+ return;
18558
+ }
18559
+ const db3 = getDb();
18560
+ const tables = db3.prepare(`
18561
+ SELECT name FROM sqlite_master
18562
+ WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
18563
+ ORDER BY name
18564
+ `).all();
18565
+ if (flags.json) {
18566
+ const result = {};
18567
+ for (const { name } of tables) {
18568
+ try {
18569
+ const row = db3.prepare(`SELECT COUNT(*) as count FROM "${name}"`).get();
18570
+ result[name] = row.count;
18571
+ } catch (e) {
18572
+ result[name] = -1;
18573
+ }
18574
+ }
18575
+ console.log(JSON.stringify(result, null, 2));
18576
+ return;
18577
+ }
18578
+ console.log("\nDatabase Tables");
18579
+ console.log("\u2550".repeat(40));
18580
+ let totalRows = 0;
18581
+ for (const { name } of tables) {
18582
+ try {
18583
+ const row = db3.prepare(`SELECT COUNT(*) as count FROM "${name}"`).get();
18584
+ console.log(` ${name.padEnd(25)} ${row.count.toLocaleString().padStart(10)}`);
18585
+ totalRows += row.count;
18586
+ } catch (e) {
18587
+ console.log(` ${name.padEnd(25)} ${"error".padStart(10)}`);
18588
+ }
18589
+ }
18590
+ console.log("\u2500".repeat(40));
18591
+ console.log(` ${"Total".padEnd(25)} ${totalRows.toLocaleString().padStart(10)}`);
18592
+ console.log(`
18593
+ Size: ${formatBytes(getDbSize())}`);
18594
+ }
18179
18595
 
18180
18596
  // src/commands/import.js
18181
- var import_fs10 = require("fs");
18182
- var import_path10 = require("path");
18597
+ var import_fs12 = require("fs");
18598
+ var import_path12 = require("path");
18183
18599
  var import_os3 = require("os");
18184
18600
  var import_crypto2 = require("crypto");
18185
18601
  var PROVIDERS = {
18186
18602
  claude: {
18187
18603
  name: "Claude Code",
18188
- baseDir: (0, import_path10.join)((0, import_os3.homedir)(), ".claude", "projects"),
18604
+ baseDir: (0, import_path12.join)((0, import_os3.homedir)(), ".claude", "projects"),
18189
18605
  pattern: /\.jsonl$/
18190
18606
  },
18191
18607
  codex: {
18192
18608
  name: "Codex",
18193
- baseDir: (0, import_path10.join)((0, import_os3.homedir)(), ".codex", "sessions"),
18609
+ baseDir: (0, import_path12.join)((0, import_os3.homedir)(), ".codex", "sessions"),
18194
18610
  pattern: /\.jsonl$/
18195
18611
  },
18196
18612
  gemini: {
18197
18613
  name: "Gemini",
18198
- baseDir: (0, import_path10.join)((0, import_os3.homedir)(), ".gemini", "sessions"),
18614
+ baseDir: (0, import_path12.join)((0, import_os3.homedir)(), ".gemini", "sessions"),
18199
18615
  pattern: /\.jsonl$/
18200
18616
  }
18201
18617
  };
@@ -18262,7 +18678,7 @@ async function importSessions(args, flags) {
18262
18678
  console.log(`
18263
18679
  \u25B6 ${provider.name}`);
18264
18680
  console.log(` Source: ${provider.baseDir}`);
18265
- if (!(0, import_fs10.existsSync)(provider.baseDir)) {
18681
+ if (!(0, import_fs12.existsSync)(provider.baseDir)) {
18266
18682
  console.log(` \u26A0 Directory not found, skipping`);
18267
18683
  continue;
18268
18684
  }
@@ -18305,14 +18721,14 @@ async function importSessions(args, flags) {
18305
18721
  const now = Date.now();
18306
18722
  const maxAgeMs = maxAgeDays ? maxAgeDays * 24 * 60 * 60 * 1e3 : null;
18307
18723
  for (const filepath of files) {
18308
- const sessionId = (0, import_path10.basename)(filepath, ".jsonl");
18724
+ const sessionId = (0, import_path12.basename)(filepath, ".jsonl");
18309
18725
  if (existingIds.has(sessionId)) {
18310
18726
  skipped.existing++;
18311
18727
  continue;
18312
18728
  }
18313
18729
  let stat;
18314
18730
  try {
18315
- stat = (0, import_fs10.statSync)(filepath);
18731
+ stat = (0, import_fs12.statSync)(filepath);
18316
18732
  } catch (e) {
18317
18733
  skipped.error++;
18318
18734
  continue;
@@ -18410,7 +18826,7 @@ function showImportStatus(flags) {
18410
18826
  }
18411
18827
  console.log("\nProvider directories:");
18412
18828
  for (const [key, provider] of Object.entries(PROVIDERS)) {
18413
- const exists = (0, import_fs10.existsSync)(provider.baseDir);
18829
+ const exists = (0, import_fs12.existsSync)(provider.baseDir);
18414
18830
  let count = 0;
18415
18831
  if (exists) {
18416
18832
  const files = findSessionFiles(provider.baseDir, provider.pattern);
@@ -18424,10 +18840,10 @@ function showImportStatus(flags) {
18424
18840
  console.log("To import: rudi import sessions [provider]");
18425
18841
  }
18426
18842
  function findSessionFiles(dir, pattern, files = []) {
18427
- if (!(0, import_fs10.existsSync)(dir)) return files;
18843
+ if (!(0, import_fs12.existsSync)(dir)) return files;
18428
18844
  try {
18429
- for (const entry of (0, import_fs10.readdirSync)(dir, { withFileTypes: true })) {
18430
- const fullPath = (0, import_path10.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);
18431
18847
  if (entry.isDirectory()) {
18432
18848
  findSessionFiles(fullPath, pattern, files);
18433
18849
  } else if (pattern.test(entry.name)) {
@@ -18440,11 +18856,11 @@ function findSessionFiles(dir, pattern, files = []) {
18440
18856
  }
18441
18857
  function parseSessionFile(filepath, provider) {
18442
18858
  try {
18443
- const stat = (0, import_fs10.statSync)(filepath);
18444
- const content = (0, import_fs10.readFileSync)(filepath, "utf-8");
18859
+ const stat = (0, import_fs12.statSync)(filepath);
18860
+ const content = (0, import_fs12.readFileSync)(filepath, "utf-8");
18445
18861
  const lines = content.split("\n").filter((l) => l.trim());
18446
18862
  if (lines.length === 0) return null;
18447
- const sessionId = (0, import_path10.basename)(filepath, ".jsonl");
18863
+ const sessionId = (0, import_path12.basename)(filepath, ".jsonl");
18448
18864
  const isAgent = sessionId.startsWith("agent-");
18449
18865
  let title = null;
18450
18866
  let cwd = null;
@@ -18476,7 +18892,7 @@ function parseSessionFile(filepath, provider) {
18476
18892
  title = isAgent ? "Agent Session" : "Imported Session";
18477
18893
  }
18478
18894
  if (!cwd) {
18479
- const parentDir = (0, import_path10.basename)((0, import_path10.dirname)(filepath));
18895
+ const parentDir = (0, import_path12.basename)((0, import_path12.dirname)(filepath));
18480
18896
  if (parentDir.startsWith("-")) {
18481
18897
  cwd = parentDir.replace(/-/g, "/").replace(/^\//, "/");
18482
18898
  } else {
@@ -18500,7 +18916,7 @@ function parseSessionFile(filepath, provider) {
18500
18916
  }
18501
18917
 
18502
18918
  // src/commands/doctor.js
18503
- var import_fs11 = __toESM(require("fs"), 1);
18919
+ var import_fs13 = __toESM(require("fs"), 1);
18504
18920
  async function cmdDoctor(args, flags) {
18505
18921
  console.log("RUDI Health Check");
18506
18922
  console.log("\u2550".repeat(50));
@@ -18518,12 +18934,12 @@ async function cmdDoctor(args, flags) {
18518
18934
  { path: PATHS.cache, name: "Cache" }
18519
18935
  ];
18520
18936
  for (const dir of dirs) {
18521
- const exists = import_fs11.default.existsSync(dir.path);
18937
+ const exists = import_fs13.default.existsSync(dir.path);
18522
18938
  const status = exists ? "\u2713" : "\u2717";
18523
18939
  console.log(` ${status} ${dir.name}: ${dir.path}`);
18524
18940
  if (!exists) {
18525
18941
  issues.push(`Missing directory: ${dir.name}`);
18526
- fixes.push(() => import_fs11.default.mkdirSync(dir.path, { recursive: true }));
18942
+ fixes.push(() => import_fs13.default.mkdirSync(dir.path, { recursive: true }));
18527
18943
  }
18528
18944
  }
18529
18945
  console.log("\n\u{1F4BE} Database");
@@ -18560,10 +18976,31 @@ async function cmdDoctor(args, flags) {
18560
18976
  } catch (error) {
18561
18977
  console.log(` \u2717 Error reading secrets: ${error.message}`);
18562
18978
  }
18563
- 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");
18564
18999
  const nodeVersion = process.version;
18565
19000
  const nodeOk = parseInt(nodeVersion.slice(1)) >= 18;
18566
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}`);
18567
19004
  if (!nodeOk) {
18568
19005
  issues.push("Node.js version too old (requires >=18)");
18569
19006
  }
@@ -18593,9 +19030,9 @@ async function cmdDoctor(args, flags) {
18593
19030
  }
18594
19031
 
18595
19032
  // src/commands/update.js
18596
- var import_fs12 = __toESM(require("fs"), 1);
18597
- var import_path11 = __toESM(require("path"), 1);
18598
- 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");
18599
19036
  init_src();
18600
19037
  init_src2();
18601
19038
  async function cmdUpdate(args, flags) {
@@ -18620,7 +19057,7 @@ async function cmdUpdate(args, flags) {
18620
19057
  async function updatePackage(pkgId, flags) {
18621
19058
  const [kind, name] = parsePackageId(pkgId);
18622
19059
  const installPath = getPackagePath(pkgId);
18623
- if (!import_fs12.default.existsSync(installPath)) {
19060
+ if (!import_fs14.default.existsSync(installPath)) {
18624
19061
  return { success: false, error: "Package not installed" };
18625
19062
  }
18626
19063
  const pkg = await getPackage(pkgId);
@@ -18630,7 +19067,7 @@ async function updatePackage(pkgId, flags) {
18630
19067
  console.log(`Updating ${pkgId}...`);
18631
19068
  if (pkg.npmPackage) {
18632
19069
  try {
18633
- (0, import_child_process2.execSync)(`npm install ${pkg.npmPackage}@latest`, {
19070
+ (0, import_child_process3.execSync)(`npm install ${pkg.npmPackage}@latest`, {
18634
19071
  cwd: installPath,
18635
19072
  stdio: flags.verbose ? "inherit" : "pipe"
18636
19073
  });
@@ -18643,11 +19080,11 @@ async function updatePackage(pkgId, flags) {
18643
19080
  }
18644
19081
  if (pkg.pipPackage) {
18645
19082
  try {
18646
- const venvPip = import_path11.default.join(installPath, "venv", "bin", "pip");
18647
- (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}`, {
18648
19085
  stdio: flags.verbose ? "inherit" : "pipe"
18649
19086
  });
18650
- 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`, {
18651
19088
  encoding: "utf-8"
18652
19089
  });
18653
19090
  const version = versionOutput.split(":")[1]?.trim();
@@ -18660,7 +19097,7 @@ async function updatePackage(pkgId, flags) {
18660
19097
  if (kind === "runtime" && !pkg.npmPackage && !pkg.pipPackage) {
18661
19098
  try {
18662
19099
  const { downloadRuntime: downloadRuntime2 } = await Promise.resolve().then(() => (init_src2(), src_exports));
18663
- import_fs12.default.rmSync(installPath, { recursive: true, force: true });
19100
+ import_fs14.default.rmSync(installPath, { recursive: true, force: true });
18664
19101
  await downloadRuntime2(name, pkg.version || "latest", installPath, {
18665
19102
  onProgress: (p) => {
18666
19103
  if (flags.verbose) console.log(` ${p.phase}...`);
@@ -18680,8 +19117,8 @@ async function updateAll(flags) {
18680
19117
  let failed = 0;
18681
19118
  for (const kind of kinds) {
18682
19119
  const dir = kind === "runtime" ? PATHS.runtimes : kind === "stack" ? PATHS.stacks : PATHS.prompts;
18683
- if (!import_fs12.default.existsSync(dir)) continue;
18684
- const entries = import_fs12.default.readdirSync(dir, { withFileTypes: true });
19120
+ if (!import_fs14.default.existsSync(dir)) continue;
19121
+ const entries = import_fs14.default.readdirSync(dir, { withFileTypes: true });
18685
19122
  for (const entry of entries) {
18686
19123
  if (!entry.isDirectory() || entry.name.startsWith(".")) continue;
18687
19124
  const pkgId = `${kind}:${entry.name}`;
@@ -18700,14 +19137,14 @@ Updated ${updated} package(s)${failed > 0 ? `, ${failed} failed` : ""}`);
18700
19137
  }
18701
19138
  function getInstalledVersion(installPath, npmPackage) {
18702
19139
  try {
18703
- const pkgJsonPath = import_path11.default.join(installPath, "node_modules", npmPackage.replace("@", "").split("/")[0], "package.json");
18704
- if (import_fs12.default.existsSync(pkgJsonPath)) {
18705
- const pkgJson = JSON.parse(import_fs12.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"));
18706
19143
  return pkgJson.version;
18707
19144
  }
18708
- const rootPkgPath = import_path11.default.join(installPath, "package.json");
18709
- if (import_fs12.default.existsSync(rootPkgPath)) {
18710
- const rootPkg = JSON.parse(import_fs12.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"));
18711
19148
  const dep = rootPkg.dependencies?.[npmPackage];
18712
19149
  if (dep) return dep.replace(/[\^~]/, "");
18713
19150
  }
@@ -18716,30 +19153,30 @@ function getInstalledVersion(installPath, npmPackage) {
18716
19153
  return null;
18717
19154
  }
18718
19155
  function updateRuntimeMetadata(installPath, updates) {
18719
- const metaPath = import_path11.default.join(installPath, "runtime.json");
19156
+ const metaPath = import_path13.default.join(installPath, "runtime.json");
18720
19157
  try {
18721
19158
  let meta = {};
18722
- if (import_fs12.default.existsSync(metaPath)) {
18723
- meta = JSON.parse(import_fs12.default.readFileSync(metaPath, "utf-8"));
19159
+ if (import_fs14.default.existsSync(metaPath)) {
19160
+ meta = JSON.parse(import_fs14.default.readFileSync(metaPath, "utf-8"));
18724
19161
  }
18725
19162
  meta = { ...meta, ...updates };
18726
- import_fs12.default.writeFileSync(metaPath, JSON.stringify(meta, null, 2));
19163
+ import_fs14.default.writeFileSync(metaPath, JSON.stringify(meta, null, 2));
18727
19164
  } catch {
18728
19165
  }
18729
19166
  }
18730
19167
 
18731
19168
  // db/index.js
18732
19169
  var import_better_sqlite32 = __toESM(require("better-sqlite3"), 1);
18733
- var import_path12 = __toESM(require("path"), 1);
19170
+ var import_path14 = __toESM(require("path"), 1);
18734
19171
  var import_os4 = __toESM(require("os"), 1);
18735
- var import_fs13 = __toESM(require("fs"), 1);
18736
- var PROMPT_STACK_HOME = import_path12.default.join(import_os4.default.homedir(), ".prompt-stack");
18737
- var DB_PATH2 = import_path12.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");
18738
19175
  var db2 = null;
18739
19176
  function getDb2(options = {}) {
18740
19177
  if (!db2) {
18741
- if (!import_fs13.default.existsSync(PROMPT_STACK_HOME)) {
18742
- import_fs13.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 });
18743
19180
  }
18744
19181
  db2 = new import_better_sqlite32.default(DB_PATH2, {
18745
19182
  readonly: options.readonly || false
@@ -18897,7 +19334,7 @@ function getBeforeCrashLogs() {
18897
19334
  }
18898
19335
 
18899
19336
  // src/commands/logs.js
18900
- var import_fs14 = __toESM(require("fs"), 1);
19337
+ var import_fs16 = __toESM(require("fs"), 1);
18901
19338
  function parseTimeAgo(str) {
18902
19339
  const match = str.match(/^(\d+)([smhd])$/);
18903
19340
  if (!match) return null;
@@ -18997,7 +19434,7 @@ function exportLogs(logs, filepath, format) {
18997
19434
  });
18998
19435
  content = JSON.stringify(formatted, null, 2);
18999
19436
  }
19000
- import_fs14.default.writeFileSync(filepath, content, "utf-8");
19437
+ import_fs16.default.writeFileSync(filepath, content, "utf-8");
19001
19438
  return filepath;
19002
19439
  }
19003
19440
  function printStats(stats) {
@@ -19123,9 +19560,9 @@ async function handleLogsCommand(args, flags) {
19123
19560
  }
19124
19561
 
19125
19562
  // src/commands/which.js
19126
- var fs16 = __toESM(require("fs/promises"), 1);
19127
- var path14 = __toESM(require("path"), 1);
19128
- 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");
19129
19566
  init_src();
19130
19567
  async function cmdWhich(args, flags) {
19131
19568
  const stackId = args[0];
@@ -19193,7 +19630,7 @@ Installed stacks:`);
19193
19630
  if (runtimeInfo.entry) {
19194
19631
  console.log("");
19195
19632
  console.log("Run MCP server directly:");
19196
- const entryPath = path14.join(stackPath, runtimeInfo.entry);
19633
+ const entryPath = path15.join(stackPath, runtimeInfo.entry);
19197
19634
  if (runtimeInfo.runtime === "node") {
19198
19635
  console.log(` echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | node ${entryPath}`);
19199
19636
  } else if (runtimeInfo.runtime === "python") {
@@ -19212,27 +19649,27 @@ Installed stacks:`);
19212
19649
  async function detectRuntime(stackPath) {
19213
19650
  const runtimes = ["node", "python"];
19214
19651
  for (const runtime of runtimes) {
19215
- const runtimePath = path14.join(stackPath, runtime);
19652
+ const runtimePath = path15.join(stackPath, runtime);
19216
19653
  try {
19217
- await fs16.access(runtimePath);
19654
+ await fs17.access(runtimePath);
19218
19655
  if (runtime === "node") {
19219
- const distEntry = path14.join(runtimePath, "dist", "index.js");
19220
- 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");
19221
19658
  try {
19222
- await fs16.access(distEntry);
19659
+ await fs17.access(distEntry);
19223
19660
  return { runtime: "node", entry: `${runtime}/dist/index.js` };
19224
19661
  } catch {
19225
19662
  try {
19226
- await fs16.access(srcEntry);
19663
+ await fs17.access(srcEntry);
19227
19664
  return { runtime: "node", entry: `${runtime}/src/index.ts` };
19228
19665
  } catch {
19229
19666
  return { runtime: "node", entry: null };
19230
19667
  }
19231
19668
  }
19232
19669
  } else if (runtime === "python") {
19233
- const entry = path14.join(runtimePath, "src", "index.py");
19670
+ const entry = path15.join(runtimePath, "src", "index.py");
19234
19671
  try {
19235
- await fs16.access(entry);
19672
+ await fs17.access(entry);
19236
19673
  return { runtime: "python", entry: `${runtime}/src/index.py` };
19237
19674
  } catch {
19238
19675
  return { runtime: "python", entry: null };
@@ -19248,21 +19685,21 @@ async function checkAuth(stackPath, runtime) {
19248
19685
  const authFiles = [];
19249
19686
  let configured = false;
19250
19687
  if (runtime === "node" || runtime === "python") {
19251
- const runtimePath = path14.join(stackPath, runtime);
19252
- const tokenPath = path14.join(runtimePath, "token.json");
19688
+ const runtimePath = path15.join(stackPath, runtime);
19689
+ const tokenPath = path15.join(runtimePath, "token.json");
19253
19690
  try {
19254
- await fs16.access(tokenPath);
19691
+ await fs17.access(tokenPath);
19255
19692
  authFiles.push(`${runtime}/token.json`);
19256
19693
  configured = true;
19257
19694
  } catch {
19258
- const accountsPath = path14.join(runtimePath, "accounts");
19695
+ const accountsPath = path15.join(runtimePath, "accounts");
19259
19696
  try {
19260
- const accounts = await fs16.readdir(accountsPath);
19697
+ const accounts = await fs17.readdir(accountsPath);
19261
19698
  for (const account of accounts) {
19262
19699
  if (account.startsWith(".")) continue;
19263
- const accountTokenPath = path14.join(accountsPath, account, "token.json");
19700
+ const accountTokenPath = path15.join(accountsPath, account, "token.json");
19264
19701
  try {
19265
- await fs16.access(accountTokenPath);
19702
+ await fs17.access(accountTokenPath);
19266
19703
  authFiles.push(`${runtime}/accounts/${account}/token.json`);
19267
19704
  configured = true;
19268
19705
  } catch {
@@ -19272,9 +19709,9 @@ async function checkAuth(stackPath, runtime) {
19272
19709
  }
19273
19710
  }
19274
19711
  }
19275
- const envPath = path14.join(stackPath, ".env");
19712
+ const envPath = path15.join(stackPath, ".env");
19276
19713
  try {
19277
- const envContent = await fs16.readFile(envPath, "utf-8");
19714
+ const envContent = await fs17.readFile(envPath, "utf-8");
19278
19715
  const hasValues = envContent.split("\n").some((line) => {
19279
19716
  const trimmed = line.trim();
19280
19717
  if (!trimmed || trimmed.startsWith("#")) return false;
@@ -19303,7 +19740,7 @@ async function checkAuth(stackPath, runtime) {
19303
19740
  }
19304
19741
  function checkIfRunning(stackName) {
19305
19742
  try {
19306
- 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`, {
19307
19744
  encoding: "utf-8",
19308
19745
  stdio: ["pipe", "pipe", "ignore"]
19309
19746
  // Suppress stderr
@@ -19318,9 +19755,9 @@ function checkIfRunning(stackName) {
19318
19755
  }
19319
19756
 
19320
19757
  // src/commands/auth.js
19321
- var fs17 = __toESM(require("fs/promises"), 1);
19322
- var path15 = __toESM(require("path"), 1);
19323
- 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");
19324
19761
  init_src();
19325
19762
  var net = __toESM(require("net"), 1);
19326
19763
  async function findAvailablePort(basePort = 3456) {
@@ -19351,26 +19788,26 @@ function isPortAvailable(port) {
19351
19788
  async function detectRuntime2(stackPath) {
19352
19789
  const runtimes = ["node", "python"];
19353
19790
  for (const runtime of runtimes) {
19354
- const runtimePath = path15.join(stackPath, runtime);
19791
+ const runtimePath = path16.join(stackPath, runtime);
19355
19792
  try {
19356
- await fs17.access(runtimePath);
19793
+ await fs18.access(runtimePath);
19357
19794
  if (runtime === "node") {
19358
- const authTs = path15.join(runtimePath, "src", "auth.ts");
19359
- 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");
19360
19797
  try {
19361
- await fs17.access(authTs);
19798
+ await fs18.access(authTs);
19362
19799
  return { runtime: "node", authScript: authTs, useTsx: true };
19363
19800
  } catch {
19364
19801
  try {
19365
- await fs17.access(authJs);
19802
+ await fs18.access(authJs);
19366
19803
  return { runtime: "node", authScript: authJs, useTsx: false };
19367
19804
  } catch {
19368
19805
  }
19369
19806
  }
19370
19807
  } else if (runtime === "python") {
19371
- const authPy = path15.join(runtimePath, "src", "auth.py");
19808
+ const authPy = path16.join(runtimePath, "src", "auth.py");
19372
19809
  try {
19373
- await fs17.access(authPy);
19810
+ await fs18.access(authPy);
19374
19811
  return { runtime: "python", authScript: authPy, useTsx: false };
19375
19812
  } catch {
19376
19813
  }
@@ -19420,14 +19857,14 @@ Installed stacks:`);
19420
19857
  console.log(`Using port: ${port}`);
19421
19858
  console.log("");
19422
19859
  let cmd;
19423
- const cwd = path15.dirname(authInfo.authScript);
19860
+ const cwd = path16.dirname(authInfo.authScript);
19424
19861
  if (authInfo.runtime === "node") {
19425
- const distAuth = path15.join(cwd, "..", "dist", "auth.js");
19862
+ const distAuth = path16.join(cwd, "..", "dist", "auth.js");
19426
19863
  let useBuiltInPort = false;
19427
19864
  let tempAuthScript = null;
19428
19865
  try {
19429
- await fs17.access(distAuth);
19430
- const distContent = await fs17.readFile(distAuth, "utf-8");
19866
+ await fs18.access(distAuth);
19867
+ const distContent = await fs18.readFile(distAuth, "utf-8");
19431
19868
  if (distContent.includes("findAvailablePort")) {
19432
19869
  console.log("Using compiled authentication script...");
19433
19870
  cmd = `node ${distAuth}${accountEmail ? ` ${accountEmail}` : ""}`;
@@ -19436,11 +19873,11 @@ Installed stacks:`);
19436
19873
  } catch {
19437
19874
  }
19438
19875
  if (!useBuiltInPort) {
19439
- const authContent = await fs17.readFile(authInfo.authScript, "utf-8");
19876
+ const authContent = await fs18.readFile(authInfo.authScript, "utf-8");
19440
19877
  const tempExt = authInfo.useTsx ? ".ts" : ".mjs";
19441
- tempAuthScript = path15.join(cwd, "..", `auth-temp${tempExt}`);
19878
+ tempAuthScript = path16.join(cwd, "..", `auth-temp${tempExt}`);
19442
19879
  const modifiedContent = authContent.replace(/localhost:3456/g, `localhost:${port}`).replace(/server\.listen\(3456/g, `server.listen(${port}`);
19443
- await fs17.writeFile(tempAuthScript, modifiedContent);
19880
+ await fs18.writeFile(tempAuthScript, modifiedContent);
19444
19881
  if (authInfo.useTsx) {
19445
19882
  cmd = `npx tsx ${tempAuthScript}${accountEmail ? ` ${accountEmail}` : ""}`;
19446
19883
  } else {
@@ -19450,17 +19887,17 @@ Installed stacks:`);
19450
19887
  console.log("Starting OAuth flow...");
19451
19888
  console.log("");
19452
19889
  try {
19453
- (0, import_child_process4.execSync)(cmd, {
19890
+ (0, import_child_process5.execSync)(cmd, {
19454
19891
  cwd,
19455
19892
  stdio: "inherit"
19456
19893
  });
19457
19894
  if (tempAuthScript) {
19458
- await fs17.unlink(tempAuthScript);
19895
+ await fs18.unlink(tempAuthScript);
19459
19896
  }
19460
19897
  } catch (error) {
19461
19898
  if (tempAuthScript) {
19462
19899
  try {
19463
- await fs17.unlink(tempAuthScript);
19900
+ await fs18.unlink(tempAuthScript);
19464
19901
  } catch {
19465
19902
  }
19466
19903
  }
@@ -19470,7 +19907,7 @@ Installed stacks:`);
19470
19907
  cmd = `python3 ${authInfo.authScript}${accountEmail ? ` ${accountEmail}` : ""}`;
19471
19908
  console.log("Starting OAuth flow...");
19472
19909
  console.log("");
19473
- (0, import_child_process4.execSync)(cmd, {
19910
+ (0, import_child_process5.execSync)(cmd, {
19474
19911
  cwd,
19475
19912
  stdio: "inherit",
19476
19913
  env: {