@agenit/cli 1.0.2 → 1.0.4

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 (3) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/cli.js +790 -532
  3. package/package.json +2 -1
package/cli.js CHANGED
@@ -148,8 +148,8 @@ var init_soul = __esm({
148
148
  "use strict";
149
149
  SoulEngine = class {
150
150
  path;
151
- constructor(path55) {
152
- this.path = path55;
151
+ constructor(path57) {
152
+ this.path = path57;
153
153
  }
154
154
  async load() {
155
155
  return await fs2.readFile(this.path, "utf8");
@@ -1529,14 +1529,14 @@ var require_url_state_machine = __commonJS({
1529
1529
  return url.replace(/\u0009|\u000A|\u000D/g, "");
1530
1530
  }
1531
1531
  function shortenPath(url) {
1532
- const path55 = url.path;
1533
- if (path55.length === 0) {
1532
+ const path57 = url.path;
1533
+ if (path57.length === 0) {
1534
1534
  return;
1535
1535
  }
1536
- if (url.scheme === "file" && path55.length === 1 && isNormalizedWindowsDriveLetter(path55[0])) {
1536
+ if (url.scheme === "file" && path57.length === 1 && isNormalizedWindowsDriveLetter(path57[0])) {
1537
1537
  return;
1538
1538
  }
1539
- path55.pop();
1539
+ path57.pop();
1540
1540
  }
1541
1541
  function includesCredentials(url) {
1542
1542
  return url.username !== "" || url.password !== "";
@@ -7117,14 +7117,14 @@ __export(fileFromPath_exports, {
7117
7117
  });
7118
7118
  import { statSync, createReadStream, promises as fs9 } from "fs";
7119
7119
  import { basename } from "path";
7120
- function createFileFromPath(path55, { mtimeMs, size }, filenameOrOptions, options = {}) {
7120
+ function createFileFromPath(path57, { mtimeMs, size }, filenameOrOptions, options = {}) {
7121
7121
  let filename;
7122
7122
  if (isPlainObject_default2(filenameOrOptions)) {
7123
7123
  [options, filename] = [filenameOrOptions, void 0];
7124
7124
  } else {
7125
7125
  filename = filenameOrOptions;
7126
7126
  }
7127
- const file = new FileFromPath({ path: path55, size, lastModified: mtimeMs });
7127
+ const file = new FileFromPath({ path: path57, size, lastModified: mtimeMs });
7128
7128
  if (!filename) {
7129
7129
  filename = file.name;
7130
7130
  }
@@ -7133,13 +7133,13 @@ function createFileFromPath(path55, { mtimeMs, size }, filenameOrOptions, option
7133
7133
  lastModified: file.lastModified
7134
7134
  });
7135
7135
  }
7136
- function fileFromPathSync(path55, filenameOrOptions, options = {}) {
7137
- const stats = statSync(path55);
7138
- return createFileFromPath(path55, stats, filenameOrOptions, options);
7136
+ function fileFromPathSync(path57, filenameOrOptions, options = {}) {
7137
+ const stats = statSync(path57);
7138
+ return createFileFromPath(path57, stats, filenameOrOptions, options);
7139
7139
  }
7140
- async function fileFromPath2(path55, filenameOrOptions, options) {
7141
- const stats = await fs9.stat(path55);
7142
- return createFileFromPath(path55, stats, filenameOrOptions, options);
7140
+ async function fileFromPath2(path57, filenameOrOptions, options) {
7141
+ const stats = await fs9.stat(path57);
7142
+ return createFileFromPath(path57, stats, filenameOrOptions, options);
7143
7143
  }
7144
7144
  var import_node_domexception, __classPrivateFieldSet4, __classPrivateFieldGet5, _FileFromPath_path, _FileFromPath_start, MESSAGE, FileFromPath;
7145
7145
  var init_fileFromPath = __esm({
@@ -10797,12 +10797,12 @@ var init_esm5 = __esm({
10797
10797
  /**
10798
10798
  * Get the Path object referenced by the string path, resolved from this Path
10799
10799
  */
10800
- resolve(path55) {
10801
- if (!path55) {
10800
+ resolve(path57) {
10801
+ if (!path57) {
10802
10802
  return this;
10803
10803
  }
10804
- const rootPath = this.getRootString(path55);
10805
- const dir = path55.substring(rootPath.length);
10804
+ const rootPath = this.getRootString(path57);
10805
+ const dir = path57.substring(rootPath.length);
10806
10806
  const dirParts = dir.split(this.splitSep);
10807
10807
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
10808
10808
  return result;
@@ -11554,8 +11554,8 @@ var init_esm5 = __esm({
11554
11554
  /**
11555
11555
  * @internal
11556
11556
  */
11557
- getRootString(path55) {
11558
- return win32.parse(path55).root;
11557
+ getRootString(path57) {
11558
+ return win32.parse(path57).root;
11559
11559
  }
11560
11560
  /**
11561
11561
  * @internal
@@ -11601,8 +11601,8 @@ var init_esm5 = __esm({
11601
11601
  /**
11602
11602
  * @internal
11603
11603
  */
11604
- getRootString(path55) {
11605
- return path55.startsWith("/") ? "/" : "";
11604
+ getRootString(path57) {
11605
+ return path57.startsWith("/") ? "/" : "";
11606
11606
  }
11607
11607
  /**
11608
11608
  * @internal
@@ -11651,8 +11651,8 @@ var init_esm5 = __esm({
11651
11651
  *
11652
11652
  * @internal
11653
11653
  */
11654
- constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs54 = defaultFS } = {}) {
11655
- this.#fs = fsFromOption(fs54);
11654
+ constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs56 = defaultFS } = {}) {
11655
+ this.#fs = fsFromOption(fs56);
11656
11656
  if (cwd instanceof URL || cwd.startsWith("file://")) {
11657
11657
  cwd = fileURLToPath(cwd);
11658
11658
  }
@@ -11691,11 +11691,11 @@ var init_esm5 = __esm({
11691
11691
  /**
11692
11692
  * Get the depth of a provided path, string, or the cwd
11693
11693
  */
11694
- depth(path55 = this.cwd) {
11695
- if (typeof path55 === "string") {
11696
- path55 = this.cwd.resolve(path55);
11694
+ depth(path57 = this.cwd) {
11695
+ if (typeof path57 === "string") {
11696
+ path57 = this.cwd.resolve(path57);
11697
11697
  }
11698
- return path55.depth();
11698
+ return path57.depth();
11699
11699
  }
11700
11700
  /**
11701
11701
  * Return the cache of child entries. Exposed so subclasses can create
@@ -12182,9 +12182,9 @@ var init_esm5 = __esm({
12182
12182
  process2();
12183
12183
  return results;
12184
12184
  }
12185
- chdir(path55 = this.cwd) {
12185
+ chdir(path57 = this.cwd) {
12186
12186
  const oldCwd = this.cwd;
12187
- this.cwd = typeof path55 === "string" ? this.cwd.resolve(path55) : path55;
12187
+ this.cwd = typeof path57 === "string" ? this.cwd.resolve(path57) : path57;
12188
12188
  this.cwd[setAsCwd](oldCwd);
12189
12189
  }
12190
12190
  };
@@ -12210,8 +12210,8 @@ var init_esm5 = __esm({
12210
12210
  /**
12211
12211
  * @internal
12212
12212
  */
12213
- newRoot(fs54) {
12214
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs54 });
12213
+ newRoot(fs56) {
12214
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs56 });
12215
12215
  }
12216
12216
  /**
12217
12217
  * Return true if the provided path string is an absolute path
@@ -12239,8 +12239,8 @@ var init_esm5 = __esm({
12239
12239
  /**
12240
12240
  * @internal
12241
12241
  */
12242
- newRoot(fs54) {
12243
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs54 });
12242
+ newRoot(fs56) {
12243
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs56 });
12244
12244
  }
12245
12245
  /**
12246
12246
  * Return true if the provided path string is an absolute path
@@ -12559,8 +12559,8 @@ var init_processor = __esm({
12559
12559
  }
12560
12560
  // match, absolute, ifdir
12561
12561
  entries() {
12562
- return [...this.store.entries()].map(([path55, n2]) => [
12563
- path55,
12562
+ return [...this.store.entries()].map(([path57, n2]) => [
12563
+ path57,
12564
12564
  !!(n2 & 2),
12565
12565
  !!(n2 & 1)
12566
12566
  ]);
@@ -12773,9 +12773,9 @@ var init_walker = __esm({
12773
12773
  signal;
12774
12774
  maxDepth;
12775
12775
  includeChildMatches;
12776
- constructor(patterns, path55, opts) {
12776
+ constructor(patterns, path57, opts) {
12777
12777
  this.patterns = patterns;
12778
- this.path = path55;
12778
+ this.path = path57;
12779
12779
  this.opts = opts;
12780
12780
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
12781
12781
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -12794,11 +12794,11 @@ var init_walker = __esm({
12794
12794
  });
12795
12795
  }
12796
12796
  }
12797
- #ignored(path55) {
12798
- return this.seen.has(path55) || !!this.#ignore?.ignored?.(path55);
12797
+ #ignored(path57) {
12798
+ return this.seen.has(path57) || !!this.#ignore?.ignored?.(path57);
12799
12799
  }
12800
- #childrenIgnored(path55) {
12801
- return !!this.#ignore?.childrenIgnored?.(path55);
12800
+ #childrenIgnored(path57) {
12801
+ return !!this.#ignore?.childrenIgnored?.(path57);
12802
12802
  }
12803
12803
  // backpressure mechanism
12804
12804
  pause() {
@@ -13013,8 +13013,8 @@ var init_walker = __esm({
13013
13013
  };
13014
13014
  GlobWalker = class extends GlobUtil {
13015
13015
  matches = /* @__PURE__ */ new Set();
13016
- constructor(patterns, path55, opts) {
13017
- super(patterns, path55, opts);
13016
+ constructor(patterns, path57, opts) {
13017
+ super(patterns, path57, opts);
13018
13018
  }
13019
13019
  matchEmit(e2) {
13020
13020
  this.matches.add(e2);
@@ -13051,8 +13051,8 @@ var init_walker = __esm({
13051
13051
  };
13052
13052
  GlobStream = class extends GlobUtil {
13053
13053
  results;
13054
- constructor(patterns, path55, opts) {
13055
- super(patterns, path55, opts);
13054
+ constructor(patterns, path57, opts) {
13055
+ super(patterns, path57, opts);
13056
13056
  this.results = new Minipass({
13057
13057
  signal: this.signal,
13058
13058
  objectMode: true
@@ -14062,7 +14062,7 @@ var init_esm7 = __esm({
14062
14062
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
14063
14063
  const statMethod = opts.lstat ? lstat2 : stat;
14064
14064
  if (wantBigintFsStats) {
14065
- this._stat = (path55) => statMethod(path55, { bigint: true });
14065
+ this._stat = (path57) => statMethod(path57, { bigint: true });
14066
14066
  } else {
14067
14067
  this._stat = statMethod;
14068
14068
  }
@@ -14087,8 +14087,8 @@ var init_esm7 = __esm({
14087
14087
  const par = this.parent;
14088
14088
  const fil = par && par.files;
14089
14089
  if (fil && fil.length > 0) {
14090
- const { path: path55, depth } = par;
14091
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path55));
14090
+ const { path: path57, depth } = par;
14091
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path57));
14092
14092
  const awaited = await Promise.all(slice);
14093
14093
  for (const entry of awaited) {
14094
14094
  if (!entry)
@@ -14128,20 +14128,20 @@ var init_esm7 = __esm({
14128
14128
  this.reading = false;
14129
14129
  }
14130
14130
  }
14131
- async _exploreDir(path55, depth) {
14131
+ async _exploreDir(path57, depth) {
14132
14132
  let files;
14133
14133
  try {
14134
- files = await readdir2(path55, this._rdOptions);
14134
+ files = await readdir2(path57, this._rdOptions);
14135
14135
  } catch (error) {
14136
14136
  this._onError(error);
14137
14137
  }
14138
- return { files, depth, path: path55 };
14138
+ return { files, depth, path: path57 };
14139
14139
  }
14140
- async _formatEntry(dirent, path55) {
14140
+ async _formatEntry(dirent, path57) {
14141
14141
  let entry;
14142
14142
  const basename4 = this._isDirent ? dirent.name : dirent;
14143
14143
  try {
14144
- const fullPath = presolve(pjoin(path55, basename4));
14144
+ const fullPath = presolve(pjoin(path57, basename4));
14145
14145
  entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
14146
14146
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
14147
14147
  } catch (err) {
@@ -14202,16 +14202,16 @@ import { watchFile, unwatchFile, watch as fs_watch } from "fs";
14202
14202
  import { open, stat as stat2, lstat as lstat3, realpath as fsrealpath } from "fs/promises";
14203
14203
  import * as sysPath from "path";
14204
14204
  import { type as osType } from "os";
14205
- function createFsWatchInstance(path55, options, listener, errHandler, emitRaw) {
14205
+ function createFsWatchInstance(path57, options, listener, errHandler, emitRaw) {
14206
14206
  const handleEvent = (rawEvent, evPath) => {
14207
- listener(path55);
14208
- emitRaw(rawEvent, evPath, { watchedPath: path55 });
14209
- if (evPath && path55 !== evPath) {
14210
- fsWatchBroadcast(sysPath.resolve(path55, evPath), KEY_LISTENERS, sysPath.join(path55, evPath));
14207
+ listener(path57);
14208
+ emitRaw(rawEvent, evPath, { watchedPath: path57 });
14209
+ if (evPath && path57 !== evPath) {
14210
+ fsWatchBroadcast(sysPath.resolve(path57, evPath), KEY_LISTENERS, sysPath.join(path57, evPath));
14211
14211
  }
14212
14212
  };
14213
14213
  try {
14214
- return fs_watch(path55, {
14214
+ return fs_watch(path57, {
14215
14215
  persistent: options.persistent
14216
14216
  }, handleEvent);
14217
14217
  } catch (error) {
@@ -14555,12 +14555,12 @@ var init_handler = __esm({
14555
14555
  listener(val1, val2, val3);
14556
14556
  });
14557
14557
  };
14558
- setFsWatchListener = (path55, fullPath, options, handlers) => {
14558
+ setFsWatchListener = (path57, fullPath, options, handlers) => {
14559
14559
  const { listener, errHandler, rawEmitter } = handlers;
14560
14560
  let cont = FsWatchInstances.get(fullPath);
14561
14561
  let watcher;
14562
14562
  if (!options.persistent) {
14563
- watcher = createFsWatchInstance(path55, options, listener, errHandler, rawEmitter);
14563
+ watcher = createFsWatchInstance(path57, options, listener, errHandler, rawEmitter);
14564
14564
  if (!watcher)
14565
14565
  return;
14566
14566
  return watcher.close.bind(watcher);
@@ -14571,7 +14571,7 @@ var init_handler = __esm({
14571
14571
  addAndConvert(cont, KEY_RAW, rawEmitter);
14572
14572
  } else {
14573
14573
  watcher = createFsWatchInstance(
14574
- path55,
14574
+ path57,
14575
14575
  options,
14576
14576
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
14577
14577
  errHandler,
@@ -14586,7 +14586,7 @@ var init_handler = __esm({
14586
14586
  cont.watcherUnusable = true;
14587
14587
  if (isWindows && error.code === "EPERM") {
14588
14588
  try {
14589
- const fd = await open(path55, "r");
14589
+ const fd = await open(path57, "r");
14590
14590
  await fd.close();
14591
14591
  broadcastErr(error);
14592
14592
  } catch (err) {
@@ -14617,7 +14617,7 @@ var init_handler = __esm({
14617
14617
  };
14618
14618
  };
14619
14619
  FsWatchFileInstances = /* @__PURE__ */ new Map();
14620
- setFsWatchFileListener = (path55, fullPath, options, handlers) => {
14620
+ setFsWatchFileListener = (path57, fullPath, options, handlers) => {
14621
14621
  const { listener, rawEmitter } = handlers;
14622
14622
  let cont = FsWatchFileInstances.get(fullPath);
14623
14623
  const copts = cont && cont.options;
@@ -14639,7 +14639,7 @@ var init_handler = __esm({
14639
14639
  });
14640
14640
  const currmtime = curr.mtimeMs;
14641
14641
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
14642
- foreach(cont.listeners, (listener2) => listener2(path55, curr));
14642
+ foreach(cont.listeners, (listener2) => listener2(path57, curr));
14643
14643
  }
14644
14644
  })
14645
14645
  };
@@ -14667,13 +14667,13 @@ var init_handler = __esm({
14667
14667
  * @param listener on fs change
14668
14668
  * @returns closer for the watcher instance
14669
14669
  */
14670
- _watchWithNodeFs(path55, listener) {
14670
+ _watchWithNodeFs(path57, listener) {
14671
14671
  const opts = this.fsw.options;
14672
- const directory = sysPath.dirname(path55);
14673
- const basename4 = sysPath.basename(path55);
14672
+ const directory = sysPath.dirname(path57);
14673
+ const basename4 = sysPath.basename(path57);
14674
14674
  const parent = this.fsw._getWatchedDir(directory);
14675
14675
  parent.add(basename4);
14676
- const absolutePath = sysPath.resolve(path55);
14676
+ const absolutePath = sysPath.resolve(path57);
14677
14677
  const options = {
14678
14678
  persistent: opts.persistent
14679
14679
  };
@@ -14683,12 +14683,12 @@ var init_handler = __esm({
14683
14683
  if (opts.usePolling) {
14684
14684
  const enableBin = opts.interval !== opts.binaryInterval;
14685
14685
  options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
14686
- closer = setFsWatchFileListener(path55, absolutePath, options, {
14686
+ closer = setFsWatchFileListener(path57, absolutePath, options, {
14687
14687
  listener,
14688
14688
  rawEmitter: this.fsw._emitRaw
14689
14689
  });
14690
14690
  } else {
14691
- closer = setFsWatchListener(path55, absolutePath, options, {
14691
+ closer = setFsWatchListener(path57, absolutePath, options, {
14692
14692
  listener,
14693
14693
  errHandler: this._boundHandleError,
14694
14694
  rawEmitter: this.fsw._emitRaw
@@ -14710,7 +14710,7 @@ var init_handler = __esm({
14710
14710
  let prevStats = stats;
14711
14711
  if (parent.has(basename4))
14712
14712
  return;
14713
- const listener = async (path55, newStats) => {
14713
+ const listener = async (path57, newStats) => {
14714
14714
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
14715
14715
  return;
14716
14716
  if (!newStats || newStats.mtimeMs === 0) {
@@ -14724,11 +14724,11 @@ var init_handler = __esm({
14724
14724
  this.fsw._emit(EV.CHANGE, file, newStats2);
14725
14725
  }
14726
14726
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
14727
- this.fsw._closeFile(path55);
14727
+ this.fsw._closeFile(path57);
14728
14728
  prevStats = newStats2;
14729
14729
  const closer2 = this._watchWithNodeFs(file, listener);
14730
14730
  if (closer2)
14731
- this.fsw._addPathCloser(path55, closer2);
14731
+ this.fsw._addPathCloser(path57, closer2);
14732
14732
  } else {
14733
14733
  prevStats = newStats2;
14734
14734
  }
@@ -14760,7 +14760,7 @@ var init_handler = __esm({
14760
14760
  * @param item basename of this item
14761
14761
  * @returns true if no more processing is needed for this entry.
14762
14762
  */
14763
- async _handleSymlink(entry, directory, path55, item) {
14763
+ async _handleSymlink(entry, directory, path57, item) {
14764
14764
  if (this.fsw.closed) {
14765
14765
  return;
14766
14766
  }
@@ -14770,7 +14770,7 @@ var init_handler = __esm({
14770
14770
  this.fsw._incrReadyCount();
14771
14771
  let linkPath;
14772
14772
  try {
14773
- linkPath = await fsrealpath(path55);
14773
+ linkPath = await fsrealpath(path57);
14774
14774
  } catch (e2) {
14775
14775
  this.fsw._emitReady();
14776
14776
  return true;
@@ -14780,12 +14780,12 @@ var init_handler = __esm({
14780
14780
  if (dir.has(item)) {
14781
14781
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
14782
14782
  this.fsw._symlinkPaths.set(full, linkPath);
14783
- this.fsw._emit(EV.CHANGE, path55, entry.stats);
14783
+ this.fsw._emit(EV.CHANGE, path57, entry.stats);
14784
14784
  }
14785
14785
  } else {
14786
14786
  dir.add(item);
14787
14787
  this.fsw._symlinkPaths.set(full, linkPath);
14788
- this.fsw._emit(EV.ADD, path55, entry.stats);
14788
+ this.fsw._emit(EV.ADD, path57, entry.stats);
14789
14789
  }
14790
14790
  this.fsw._emitReady();
14791
14791
  return true;
@@ -14814,9 +14814,9 @@ var init_handler = __esm({
14814
14814
  return;
14815
14815
  }
14816
14816
  const item = entry.path;
14817
- let path55 = sysPath.join(directory, item);
14817
+ let path57 = sysPath.join(directory, item);
14818
14818
  current.add(item);
14819
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path55, item)) {
14819
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path57, item)) {
14820
14820
  return;
14821
14821
  }
14822
14822
  if (this.fsw.closed) {
@@ -14825,8 +14825,8 @@ var init_handler = __esm({
14825
14825
  }
14826
14826
  if (item === target || !target && !previous.has(item)) {
14827
14827
  this.fsw._incrReadyCount();
14828
- path55 = sysPath.join(dir, sysPath.relative(dir, path55));
14829
- this._addToNodeFs(path55, initialAdd, wh, depth + 1);
14828
+ path57 = sysPath.join(dir, sysPath.relative(dir, path57));
14829
+ this._addToNodeFs(path57, initialAdd, wh, depth + 1);
14830
14830
  }
14831
14831
  }).on(EV.ERROR, this._boundHandleError);
14832
14832
  return new Promise((resolve3, reject) => {
@@ -14895,13 +14895,13 @@ var init_handler = __esm({
14895
14895
  * @param depth Child path actually targeted for watch
14896
14896
  * @param target Child path actually targeted for watch
14897
14897
  */
14898
- async _addToNodeFs(path55, initialAdd, priorWh, depth, target) {
14898
+ async _addToNodeFs(path57, initialAdd, priorWh, depth, target) {
14899
14899
  const ready = this.fsw._emitReady;
14900
- if (this.fsw._isIgnored(path55) || this.fsw.closed) {
14900
+ if (this.fsw._isIgnored(path57) || this.fsw.closed) {
14901
14901
  ready();
14902
14902
  return false;
14903
14903
  }
14904
- const wh = this.fsw._getWatchHelpers(path55);
14904
+ const wh = this.fsw._getWatchHelpers(path57);
14905
14905
  if (priorWh) {
14906
14906
  wh.filterPath = (entry) => priorWh.filterPath(entry);
14907
14907
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -14917,8 +14917,8 @@ var init_handler = __esm({
14917
14917
  const follow = this.fsw.options.followSymlinks;
14918
14918
  let closer;
14919
14919
  if (stats.isDirectory()) {
14920
- const absPath = sysPath.resolve(path55);
14921
- const targetPath = follow ? await fsrealpath(path55) : path55;
14920
+ const absPath = sysPath.resolve(path57);
14921
+ const targetPath = follow ? await fsrealpath(path57) : path57;
14922
14922
  if (this.fsw.closed)
14923
14923
  return;
14924
14924
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -14928,29 +14928,29 @@ var init_handler = __esm({
14928
14928
  this.fsw._symlinkPaths.set(absPath, targetPath);
14929
14929
  }
14930
14930
  } else if (stats.isSymbolicLink()) {
14931
- const targetPath = follow ? await fsrealpath(path55) : path55;
14931
+ const targetPath = follow ? await fsrealpath(path57) : path57;
14932
14932
  if (this.fsw.closed)
14933
14933
  return;
14934
14934
  const parent = sysPath.dirname(wh.watchPath);
14935
14935
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
14936
14936
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
14937
- closer = await this._handleDir(parent, stats, initialAdd, depth, path55, wh, targetPath);
14937
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path57, wh, targetPath);
14938
14938
  if (this.fsw.closed)
14939
14939
  return;
14940
14940
  if (targetPath !== void 0) {
14941
- this.fsw._symlinkPaths.set(sysPath.resolve(path55), targetPath);
14941
+ this.fsw._symlinkPaths.set(sysPath.resolve(path57), targetPath);
14942
14942
  }
14943
14943
  } else {
14944
14944
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
14945
14945
  }
14946
14946
  ready();
14947
14947
  if (closer)
14948
- this.fsw._addPathCloser(path55, closer);
14948
+ this.fsw._addPathCloser(path57, closer);
14949
14949
  return false;
14950
14950
  } catch (error) {
14951
14951
  if (this.fsw._handleError(error)) {
14952
14952
  ready();
14953
- return path55;
14953
+ return path57;
14954
14954
  }
14955
14955
  }
14956
14956
  }
@@ -14989,26 +14989,26 @@ function createPattern(matcher) {
14989
14989
  }
14990
14990
  return () => false;
14991
14991
  }
14992
- function normalizePath(path55) {
14993
- if (typeof path55 !== "string")
14992
+ function normalizePath(path57) {
14993
+ if (typeof path57 !== "string")
14994
14994
  throw new Error("string expected");
14995
- path55 = sysPath2.normalize(path55);
14996
- path55 = path55.replace(/\\/g, "/");
14995
+ path57 = sysPath2.normalize(path57);
14996
+ path57 = path57.replace(/\\/g, "/");
14997
14997
  let prepend = false;
14998
- if (path55.startsWith("//"))
14998
+ if (path57.startsWith("//"))
14999
14999
  prepend = true;
15000
15000
  const DOUBLE_SLASH_RE2 = /\/\//;
15001
- while (path55.match(DOUBLE_SLASH_RE2))
15002
- path55 = path55.replace(DOUBLE_SLASH_RE2, "/");
15001
+ while (path57.match(DOUBLE_SLASH_RE2))
15002
+ path57 = path57.replace(DOUBLE_SLASH_RE2, "/");
15003
15003
  if (prepend)
15004
- path55 = "/" + path55;
15005
- return path55;
15004
+ path57 = "/" + path57;
15005
+ return path57;
15006
15006
  }
15007
15007
  function matchPatterns(patterns, testString, stats) {
15008
- const path55 = normalizePath(testString);
15008
+ const path57 = normalizePath(testString);
15009
15009
  for (let index2 = 0; index2 < patterns.length; index2++) {
15010
15010
  const pattern = patterns[index2];
15011
- if (pattern(path55, stats)) {
15011
+ if (pattern(path57, stats)) {
15012
15012
  return true;
15013
15013
  }
15014
15014
  }
@@ -15068,19 +15068,19 @@ var init_esm8 = __esm({
15068
15068
  }
15069
15069
  return str;
15070
15070
  };
15071
- normalizePathToUnix = (path55) => toUnix(sysPath2.normalize(toUnix(path55)));
15072
- normalizeIgnored = (cwd = "") => (path55) => {
15073
- if (typeof path55 === "string") {
15074
- return normalizePathToUnix(sysPath2.isAbsolute(path55) ? path55 : sysPath2.join(cwd, path55));
15071
+ normalizePathToUnix = (path57) => toUnix(sysPath2.normalize(toUnix(path57)));
15072
+ normalizeIgnored = (cwd = "") => (path57) => {
15073
+ if (typeof path57 === "string") {
15074
+ return normalizePathToUnix(sysPath2.isAbsolute(path57) ? path57 : sysPath2.join(cwd, path57));
15075
15075
  } else {
15076
- return path55;
15076
+ return path57;
15077
15077
  }
15078
15078
  };
15079
- getAbsolutePath = (path55, cwd) => {
15080
- if (sysPath2.isAbsolute(path55)) {
15081
- return path55;
15079
+ getAbsolutePath = (path57, cwd) => {
15080
+ if (sysPath2.isAbsolute(path57)) {
15081
+ return path57;
15082
15082
  }
15083
- return sysPath2.join(cwd, path55);
15083
+ return sysPath2.join(cwd, path57);
15084
15084
  };
15085
15085
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
15086
15086
  DirEntry = class {
@@ -15135,10 +15135,10 @@ var init_esm8 = __esm({
15135
15135
  STAT_METHOD_F = "stat";
15136
15136
  STAT_METHOD_L = "lstat";
15137
15137
  WatchHelper = class {
15138
- constructor(path55, follow, fsw) {
15138
+ constructor(path57, follow, fsw) {
15139
15139
  this.fsw = fsw;
15140
- const watchPath = path55;
15141
- this.path = path55 = path55.replace(REPLACER_RE, "");
15140
+ const watchPath = path57;
15141
+ this.path = path57 = path57.replace(REPLACER_RE, "");
15142
15142
  this.watchPath = watchPath;
15143
15143
  this.fullWatchPath = sysPath2.resolve(watchPath);
15144
15144
  this.dirParts = [];
@@ -15260,20 +15260,20 @@ var init_esm8 = __esm({
15260
15260
  this._closePromise = void 0;
15261
15261
  let paths = unifyPaths(paths_);
15262
15262
  if (cwd) {
15263
- paths = paths.map((path55) => {
15264
- const absPath = getAbsolutePath(path55, cwd);
15263
+ paths = paths.map((path57) => {
15264
+ const absPath = getAbsolutePath(path57, cwd);
15265
15265
  return absPath;
15266
15266
  });
15267
15267
  }
15268
- paths.forEach((path55) => {
15269
- this._removeIgnoredPath(path55);
15268
+ paths.forEach((path57) => {
15269
+ this._removeIgnoredPath(path57);
15270
15270
  });
15271
15271
  this._userIgnored = void 0;
15272
15272
  if (!this._readyCount)
15273
15273
  this._readyCount = 0;
15274
15274
  this._readyCount += paths.length;
15275
- Promise.all(paths.map(async (path55) => {
15276
- const res = await this._nodeFsHandler._addToNodeFs(path55, !_internal, void 0, 0, _origAdd);
15275
+ Promise.all(paths.map(async (path57) => {
15276
+ const res = await this._nodeFsHandler._addToNodeFs(path57, !_internal, void 0, 0, _origAdd);
15277
15277
  if (res)
15278
15278
  this._emitReady();
15279
15279
  return res;
@@ -15295,17 +15295,17 @@ var init_esm8 = __esm({
15295
15295
  return this;
15296
15296
  const paths = unifyPaths(paths_);
15297
15297
  const { cwd } = this.options;
15298
- paths.forEach((path55) => {
15299
- if (!sysPath2.isAbsolute(path55) && !this._closers.has(path55)) {
15298
+ paths.forEach((path57) => {
15299
+ if (!sysPath2.isAbsolute(path57) && !this._closers.has(path57)) {
15300
15300
  if (cwd)
15301
- path55 = sysPath2.join(cwd, path55);
15302
- path55 = sysPath2.resolve(path55);
15301
+ path57 = sysPath2.join(cwd, path57);
15302
+ path57 = sysPath2.resolve(path57);
15303
15303
  }
15304
- this._closePath(path55);
15305
- this._addIgnoredPath(path55);
15306
- if (this._watched.has(path55)) {
15304
+ this._closePath(path57);
15305
+ this._addIgnoredPath(path57);
15306
+ if (this._watched.has(path57)) {
15307
15307
  this._addIgnoredPath({
15308
- path: path55,
15308
+ path: path57,
15309
15309
  recursive: true
15310
15310
  });
15311
15311
  }
@@ -15369,38 +15369,38 @@ var init_esm8 = __esm({
15369
15369
  * @param stats arguments to be passed with event
15370
15370
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
15371
15371
  */
15372
- async _emit(event, path55, stats) {
15372
+ async _emit(event, path57, stats) {
15373
15373
  if (this.closed)
15374
15374
  return;
15375
15375
  const opts = this.options;
15376
15376
  if (isWindows)
15377
- path55 = sysPath2.normalize(path55);
15377
+ path57 = sysPath2.normalize(path57);
15378
15378
  if (opts.cwd)
15379
- path55 = sysPath2.relative(opts.cwd, path55);
15380
- const args = [path55];
15379
+ path57 = sysPath2.relative(opts.cwd, path57);
15380
+ const args = [path57];
15381
15381
  if (stats != null)
15382
15382
  args.push(stats);
15383
15383
  const awf = opts.awaitWriteFinish;
15384
15384
  let pw;
15385
- if (awf && (pw = this._pendingWrites.get(path55))) {
15385
+ if (awf && (pw = this._pendingWrites.get(path57))) {
15386
15386
  pw.lastChange = /* @__PURE__ */ new Date();
15387
15387
  return this;
15388
15388
  }
15389
15389
  if (opts.atomic) {
15390
15390
  if (event === EVENTS.UNLINK) {
15391
- this._pendingUnlinks.set(path55, [event, ...args]);
15391
+ this._pendingUnlinks.set(path57, [event, ...args]);
15392
15392
  setTimeout(() => {
15393
- this._pendingUnlinks.forEach((entry, path56) => {
15393
+ this._pendingUnlinks.forEach((entry, path58) => {
15394
15394
  this.emit(...entry);
15395
15395
  this.emit(EVENTS.ALL, ...entry);
15396
- this._pendingUnlinks.delete(path56);
15396
+ this._pendingUnlinks.delete(path58);
15397
15397
  });
15398
15398
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
15399
15399
  return this;
15400
15400
  }
15401
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path55)) {
15401
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path57)) {
15402
15402
  event = EVENTS.CHANGE;
15403
- this._pendingUnlinks.delete(path55);
15403
+ this._pendingUnlinks.delete(path57);
15404
15404
  }
15405
15405
  }
15406
15406
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -15418,16 +15418,16 @@ var init_esm8 = __esm({
15418
15418
  this.emitWithAll(event, args);
15419
15419
  }
15420
15420
  };
15421
- this._awaitWriteFinish(path55, awf.stabilityThreshold, event, awfEmit);
15421
+ this._awaitWriteFinish(path57, awf.stabilityThreshold, event, awfEmit);
15422
15422
  return this;
15423
15423
  }
15424
15424
  if (event === EVENTS.CHANGE) {
15425
- const isThrottled = !this._throttle(EVENTS.CHANGE, path55, 50);
15425
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path57, 50);
15426
15426
  if (isThrottled)
15427
15427
  return this;
15428
15428
  }
15429
15429
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
15430
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path55) : path55;
15430
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path57) : path57;
15431
15431
  let stats2;
15432
15432
  try {
15433
15433
  stats2 = await stat3(fullPath);
@@ -15458,23 +15458,23 @@ var init_esm8 = __esm({
15458
15458
  * @param timeout duration of time to suppress duplicate actions
15459
15459
  * @returns tracking object or false if action should be suppressed
15460
15460
  */
15461
- _throttle(actionType, path55, timeout) {
15461
+ _throttle(actionType, path57, timeout) {
15462
15462
  if (!this._throttled.has(actionType)) {
15463
15463
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
15464
15464
  }
15465
15465
  const action = this._throttled.get(actionType);
15466
15466
  if (!action)
15467
15467
  throw new Error("invalid throttle");
15468
- const actionPath = action.get(path55);
15468
+ const actionPath = action.get(path57);
15469
15469
  if (actionPath) {
15470
15470
  actionPath.count++;
15471
15471
  return false;
15472
15472
  }
15473
15473
  let timeoutObject;
15474
15474
  const clear2 = () => {
15475
- const item = action.get(path55);
15475
+ const item = action.get(path57);
15476
15476
  const count = item ? item.count : 0;
15477
- action.delete(path55);
15477
+ action.delete(path57);
15478
15478
  clearTimeout(timeoutObject);
15479
15479
  if (item)
15480
15480
  clearTimeout(item.timeoutObject);
@@ -15482,7 +15482,7 @@ var init_esm8 = __esm({
15482
15482
  };
15483
15483
  timeoutObject = setTimeout(clear2, timeout);
15484
15484
  const thr = { timeoutObject, clear: clear2, count: 0 };
15485
- action.set(path55, thr);
15485
+ action.set(path57, thr);
15486
15486
  return thr;
15487
15487
  }
15488
15488
  _incrReadyCount() {
@@ -15496,44 +15496,44 @@ var init_esm8 = __esm({
15496
15496
  * @param event
15497
15497
  * @param awfEmit Callback to be called when ready for event to be emitted.
15498
15498
  */
15499
- _awaitWriteFinish(path55, threshold, event, awfEmit) {
15499
+ _awaitWriteFinish(path57, threshold, event, awfEmit) {
15500
15500
  const awf = this.options.awaitWriteFinish;
15501
15501
  if (typeof awf !== "object")
15502
15502
  return;
15503
15503
  const pollInterval = awf.pollInterval;
15504
15504
  let timeoutHandler;
15505
- let fullPath = path55;
15506
- if (this.options.cwd && !sysPath2.isAbsolute(path55)) {
15507
- fullPath = sysPath2.join(this.options.cwd, path55);
15505
+ let fullPath = path57;
15506
+ if (this.options.cwd && !sysPath2.isAbsolute(path57)) {
15507
+ fullPath = sysPath2.join(this.options.cwd, path57);
15508
15508
  }
15509
15509
  const now = /* @__PURE__ */ new Date();
15510
15510
  const writes = this._pendingWrites;
15511
15511
  function awaitWriteFinishFn(prevStat) {
15512
15512
  statcb(fullPath, (err, curStat) => {
15513
- if (err || !writes.has(path55)) {
15513
+ if (err || !writes.has(path57)) {
15514
15514
  if (err && err.code !== "ENOENT")
15515
15515
  awfEmit(err);
15516
15516
  return;
15517
15517
  }
15518
15518
  const now2 = Number(/* @__PURE__ */ new Date());
15519
15519
  if (prevStat && curStat.size !== prevStat.size) {
15520
- writes.get(path55).lastChange = now2;
15520
+ writes.get(path57).lastChange = now2;
15521
15521
  }
15522
- const pw = writes.get(path55);
15522
+ const pw = writes.get(path57);
15523
15523
  const df = now2 - pw.lastChange;
15524
15524
  if (df >= threshold) {
15525
- writes.delete(path55);
15525
+ writes.delete(path57);
15526
15526
  awfEmit(void 0, curStat);
15527
15527
  } else {
15528
15528
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
15529
15529
  }
15530
15530
  });
15531
15531
  }
15532
- if (!writes.has(path55)) {
15533
- writes.set(path55, {
15532
+ if (!writes.has(path57)) {
15533
+ writes.set(path57, {
15534
15534
  lastChange: now,
15535
15535
  cancelWait: () => {
15536
- writes.delete(path55);
15536
+ writes.delete(path57);
15537
15537
  clearTimeout(timeoutHandler);
15538
15538
  return event;
15539
15539
  }
@@ -15544,8 +15544,8 @@ var init_esm8 = __esm({
15544
15544
  /**
15545
15545
  * Determines whether user has asked to ignore this path.
15546
15546
  */
15547
- _isIgnored(path55, stats) {
15548
- if (this.options.atomic && DOT_RE.test(path55))
15547
+ _isIgnored(path57, stats) {
15548
+ if (this.options.atomic && DOT_RE.test(path57))
15549
15549
  return true;
15550
15550
  if (!this._userIgnored) {
15551
15551
  const { cwd } = this.options;
@@ -15555,17 +15555,17 @@ var init_esm8 = __esm({
15555
15555
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
15556
15556
  this._userIgnored = anymatch(list, void 0);
15557
15557
  }
15558
- return this._userIgnored(path55, stats);
15558
+ return this._userIgnored(path57, stats);
15559
15559
  }
15560
- _isntIgnored(path55, stat4) {
15561
- return !this._isIgnored(path55, stat4);
15560
+ _isntIgnored(path57, stat4) {
15561
+ return !this._isIgnored(path57, stat4);
15562
15562
  }
15563
15563
  /**
15564
15564
  * Provides a set of common helpers and properties relating to symlink handling.
15565
15565
  * @param path file or directory pattern being watched
15566
15566
  */
15567
- _getWatchHelpers(path55) {
15568
- return new WatchHelper(path55, this.options.followSymlinks, this);
15567
+ _getWatchHelpers(path57) {
15568
+ return new WatchHelper(path57, this.options.followSymlinks, this);
15569
15569
  }
15570
15570
  // Directory helpers
15571
15571
  // -----------------
@@ -15597,63 +15597,63 @@ var init_esm8 = __esm({
15597
15597
  * @param item base path of item/directory
15598
15598
  */
15599
15599
  _remove(directory, item, isDirectory) {
15600
- const path55 = sysPath2.join(directory, item);
15601
- const fullPath = sysPath2.resolve(path55);
15602
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path55) || this._watched.has(fullPath);
15603
- if (!this._throttle("remove", path55, 100))
15600
+ const path57 = sysPath2.join(directory, item);
15601
+ const fullPath = sysPath2.resolve(path57);
15602
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path57) || this._watched.has(fullPath);
15603
+ if (!this._throttle("remove", path57, 100))
15604
15604
  return;
15605
15605
  if (!isDirectory && this._watched.size === 1) {
15606
15606
  this.add(directory, item, true);
15607
15607
  }
15608
- const wp = this._getWatchedDir(path55);
15608
+ const wp = this._getWatchedDir(path57);
15609
15609
  const nestedDirectoryChildren = wp.getChildren();
15610
- nestedDirectoryChildren.forEach((nested) => this._remove(path55, nested));
15610
+ nestedDirectoryChildren.forEach((nested) => this._remove(path57, nested));
15611
15611
  const parent = this._getWatchedDir(directory);
15612
15612
  const wasTracked = parent.has(item);
15613
15613
  parent.remove(item);
15614
15614
  if (this._symlinkPaths.has(fullPath)) {
15615
15615
  this._symlinkPaths.delete(fullPath);
15616
15616
  }
15617
- let relPath = path55;
15617
+ let relPath = path57;
15618
15618
  if (this.options.cwd)
15619
- relPath = sysPath2.relative(this.options.cwd, path55);
15619
+ relPath = sysPath2.relative(this.options.cwd, path57);
15620
15620
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
15621
15621
  const event = this._pendingWrites.get(relPath).cancelWait();
15622
15622
  if (event === EVENTS.ADD)
15623
15623
  return;
15624
15624
  }
15625
- this._watched.delete(path55);
15625
+ this._watched.delete(path57);
15626
15626
  this._watched.delete(fullPath);
15627
15627
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
15628
- if (wasTracked && !this._isIgnored(path55))
15629
- this._emit(eventName, path55);
15630
- this._closePath(path55);
15628
+ if (wasTracked && !this._isIgnored(path57))
15629
+ this._emit(eventName, path57);
15630
+ this._closePath(path57);
15631
15631
  }
15632
15632
  /**
15633
15633
  * Closes all watchers for a path
15634
15634
  */
15635
- _closePath(path55) {
15636
- this._closeFile(path55);
15637
- const dir = sysPath2.dirname(path55);
15638
- this._getWatchedDir(dir).remove(sysPath2.basename(path55));
15635
+ _closePath(path57) {
15636
+ this._closeFile(path57);
15637
+ const dir = sysPath2.dirname(path57);
15638
+ this._getWatchedDir(dir).remove(sysPath2.basename(path57));
15639
15639
  }
15640
15640
  /**
15641
15641
  * Closes only file-specific watchers
15642
15642
  */
15643
- _closeFile(path55) {
15644
- const closers = this._closers.get(path55);
15643
+ _closeFile(path57) {
15644
+ const closers = this._closers.get(path57);
15645
15645
  if (!closers)
15646
15646
  return;
15647
15647
  closers.forEach((closer) => closer());
15648
- this._closers.delete(path55);
15648
+ this._closers.delete(path57);
15649
15649
  }
15650
- _addPathCloser(path55, closer) {
15650
+ _addPathCloser(path57, closer) {
15651
15651
  if (!closer)
15652
15652
  return;
15653
- let list = this._closers.get(path55);
15653
+ let list = this._closers.get(path57);
15654
15654
  if (!list) {
15655
15655
  list = [];
15656
- this._closers.set(path55, list);
15656
+ this._closers.set(path57, list);
15657
15657
  }
15658
15658
  list.push(closer);
15659
15659
  }
@@ -37854,8 +37854,8 @@ var require_lib3 = __commonJS({
37854
37854
 
37855
37855
  // src/cli.tsx
37856
37856
  init_dist();
37857
- import { promises as fs53 } from "node:fs";
37858
- import path54 from "node:path";
37857
+ import { promises as fs55 } from "node:fs";
37858
+ import path56 from "node:path";
37859
37859
  import { spawn as spawn17 } from "node:child_process";
37860
37860
  import { render as render2 } from "ink";
37861
37861
  import yargs from "yargs";
@@ -39050,13 +39050,13 @@ var MultipartBody = class {
39050
39050
  // ../../node_modules/.pnpm/@anthropic-ai+sdk@0.30.1/node_modules/@anthropic-ai/sdk/_shims/node-runtime.mjs
39051
39051
  import { ReadableStream as ReadableStream3 } from "node:stream/web";
39052
39052
  var fileFromPathWarned = false;
39053
- async function fileFromPath3(path55, ...args) {
39053
+ async function fileFromPath3(path57, ...args) {
39054
39054
  const { fileFromPath: _fileFromPath } = await Promise.resolve().then(() => (init_fileFromPath(), fileFromPath_exports));
39055
39055
  if (!fileFromPathWarned) {
39056
- console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path55)}) instead`);
39056
+ console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path57)}) instead`);
39057
39057
  fileFromPathWarned = true;
39058
39058
  }
39059
- return await _fileFromPath(path55, ...args);
39059
+ return await _fileFromPath(path57, ...args);
39060
39060
  }
39061
39061
  var defaultHttpAgent = new import_agentkeepalive.default({ keepAlive: true, timeout: 5 * 60 * 1e3 });
39062
39062
  var defaultHttpsAgent = new import_agentkeepalive.default.HttpsAgent({ keepAlive: true, timeout: 5 * 60 * 1e3 });
@@ -39655,29 +39655,29 @@ var APIClient = class {
39655
39655
  defaultIdempotencyKey() {
39656
39656
  return `stainless-node-retry-${uuid4()}`;
39657
39657
  }
39658
- get(path55, opts) {
39659
- return this.methodRequest("get", path55, opts);
39658
+ get(path57, opts) {
39659
+ return this.methodRequest("get", path57, opts);
39660
39660
  }
39661
- post(path55, opts) {
39662
- return this.methodRequest("post", path55, opts);
39661
+ post(path57, opts) {
39662
+ return this.methodRequest("post", path57, opts);
39663
39663
  }
39664
- patch(path55, opts) {
39665
- return this.methodRequest("patch", path55, opts);
39664
+ patch(path57, opts) {
39665
+ return this.methodRequest("patch", path57, opts);
39666
39666
  }
39667
- put(path55, opts) {
39668
- return this.methodRequest("put", path55, opts);
39667
+ put(path57, opts) {
39668
+ return this.methodRequest("put", path57, opts);
39669
39669
  }
39670
- delete(path55, opts) {
39671
- return this.methodRequest("delete", path55, opts);
39670
+ delete(path57, opts) {
39671
+ return this.methodRequest("delete", path57, opts);
39672
39672
  }
39673
- methodRequest(method, path55, opts) {
39673
+ methodRequest(method, path57, opts) {
39674
39674
  return this.request(Promise.resolve(opts).then(async (opts2) => {
39675
39675
  const body = opts2 && isBlobLike(opts2?.body) ? new DataView(await opts2.body.arrayBuffer()) : opts2?.body instanceof DataView ? opts2.body : opts2?.body instanceof ArrayBuffer ? new DataView(opts2.body) : opts2 && ArrayBuffer.isView(opts2?.body) ? new DataView(opts2.body.buffer) : opts2?.body;
39676
- return { method, path: path55, ...opts2, body };
39676
+ return { method, path: path57, ...opts2, body };
39677
39677
  }));
39678
39678
  }
39679
- getAPIList(path55, Page2, opts) {
39680
- return this.requestAPIList(Page2, { method: "get", path: path55, ...opts });
39679
+ getAPIList(path57, Page2, opts) {
39680
+ return this.requestAPIList(Page2, { method: "get", path: path57, ...opts });
39681
39681
  }
39682
39682
  calculateContentLength(body) {
39683
39683
  if (typeof body === "string") {
@@ -39695,10 +39695,10 @@ var APIClient = class {
39695
39695
  return null;
39696
39696
  }
39697
39697
  buildRequest(options, { retryCount = 0 } = {}) {
39698
- const { method, path: path55, query, headers = {} } = options;
39698
+ const { method, path: path57, query, headers = {} } = options;
39699
39699
  const body = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
39700
39700
  const contentLength = this.calculateContentLength(body);
39701
- const url = this.buildURL(path55, query);
39701
+ const url = this.buildURL(path57, query);
39702
39702
  if ("timeout" in options)
39703
39703
  validatePositiveInteger("timeout", options.timeout);
39704
39704
  const timeout = options.timeout ?? this.timeout;
@@ -39811,8 +39811,8 @@ var APIClient = class {
39811
39811
  const request = this.makeRequest(options, null);
39812
39812
  return new PagePromise(this, request, Page2);
39813
39813
  }
39814
- buildURL(path55, query) {
39815
- const url = isAbsoluteURL(path55) ? new URL(path55) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path55.startsWith("/") ? path55.slice(1) : path55));
39814
+ buildURL(path57, query) {
39815
+ const url = isAbsoluteURL(path57) ? new URL(path57) : new URL(this.baseURL + (this.baseURL.endsWith("/") && path57.startsWith("/") ? path57.slice(1) : path57));
39816
39816
  const defaultQuery = this.defaultQuery();
39817
39817
  if (!isEmptyObj(defaultQuery)) {
39818
39818
  query = { ...defaultQuery, ...query };
@@ -45731,13 +45731,120 @@ var yoloCommand = {
45731
45731
 
45732
45732
  // src/commands/project-setup.ts
45733
45733
  init_dist();
45734
+ import { promises as fs25 } from "node:fs";
45735
+ import path20 from "node:path";
45736
+ import chalk6 from "chalk";
45737
+
45738
+ // src/gemini-assets.ts
45734
45739
  import { promises as fs24 } from "node:fs";
45735
45740
  import path19 from "node:path";
45736
- import chalk6 from "chalk";
45741
+ async function seedGeminiAssets(projectDir2, flowHome) {
45742
+ const sourceSkillsDir = path19.join(flowHome, ".gemini", "skills");
45743
+ const sourceSettingsPath = path19.join(flowHome, ".gemini", "settings.json");
45744
+ const targetGeminiDir = path19.join(projectDir2, ".gemini");
45745
+ const targetSkillsDir = path19.join(targetGeminiDir, "skills");
45746
+ const targetSettingsPath = path19.join(targetGeminiDir, "settings.json");
45747
+ await fs24.mkdir(targetGeminiDir, { recursive: true });
45748
+ const skillsCopied = await copySkills(sourceSkillsDir, targetSkillsDir);
45749
+ const settingsResult = await seedSettings(
45750
+ sourceSettingsPath,
45751
+ targetSettingsPath,
45752
+ flowHome
45753
+ );
45754
+ return {
45755
+ skillsCopied,
45756
+ settingsWritten: settingsResult.written,
45757
+ settingsSkippedReason: settingsResult.skippedReason
45758
+ };
45759
+ }
45760
+ async function copySkills(source, target) {
45761
+ let entries;
45762
+ try {
45763
+ entries = await fs24.readdir(source, { withFileTypes: true });
45764
+ } catch {
45765
+ return 0;
45766
+ }
45767
+ await fs24.mkdir(target, { recursive: true });
45768
+ let copied = 0;
45769
+ for (const entry of entries) {
45770
+ if (!entry.isDirectory()) continue;
45771
+ const srcSkillDir = path19.join(source, entry.name);
45772
+ const dstSkillDir = path19.join(target, entry.name);
45773
+ await copyDirRecursive(srcSkillDir, dstSkillDir);
45774
+ copied += 1;
45775
+ }
45776
+ return copied;
45777
+ }
45778
+ async function copyDirRecursive(src, dst) {
45779
+ await fs24.mkdir(dst, { recursive: true });
45780
+ const entries = await fs24.readdir(src, { withFileTypes: true });
45781
+ for (const entry of entries) {
45782
+ const s2 = path19.join(src, entry.name);
45783
+ const d2 = path19.join(dst, entry.name);
45784
+ if (entry.isDirectory()) {
45785
+ await copyDirRecursive(s2, d2);
45786
+ } else if (entry.isFile()) {
45787
+ await fs24.copyFile(s2, d2);
45788
+ }
45789
+ }
45790
+ }
45791
+ async function seedSettings(sourcePath, targetPath, flowHome) {
45792
+ try {
45793
+ await fs24.access(targetPath);
45794
+ return { written: false, skippedReason: "already exists" };
45795
+ } catch {
45796
+ }
45797
+ let raw;
45798
+ try {
45799
+ raw = await fs24.readFile(sourcePath, "utf8");
45800
+ } catch {
45801
+ return { written: false, skippedReason: "source settings.json missing" };
45802
+ }
45803
+ let parsed;
45804
+ try {
45805
+ parsed = JSON.parse(raw);
45806
+ } catch (err) {
45807
+ return {
45808
+ written: false,
45809
+ skippedReason: `source settings.json is invalid JSON: ${err.message}`
45810
+ };
45811
+ }
45812
+ const rewritten = rewriteHookPaths(parsed, flowHome);
45813
+ await fs24.writeFile(targetPath, JSON.stringify(rewritten, null, 2) + "\n");
45814
+ return { written: true, skippedReason: null };
45815
+ }
45816
+ function rewriteHookPaths(node, flowHome) {
45817
+ if (Array.isArray(node)) {
45818
+ return node.map((n2) => rewriteHookPaths(n2, flowHome));
45819
+ }
45820
+ if (node && typeof node === "object") {
45821
+ const out = {};
45822
+ for (const [key, value] of Object.entries(node)) {
45823
+ if (key === "command" && typeof value === "string") {
45824
+ out[key] = rewriteCommandString(value, flowHome);
45825
+ } else {
45826
+ out[key] = rewriteHookPaths(value, flowHome);
45827
+ }
45828
+ }
45829
+ return out;
45830
+ }
45831
+ return node;
45832
+ }
45833
+ function rewriteCommandString(command, flowHome) {
45834
+ return command.split(/(\s+)/).map((tok) => {
45835
+ if (tok.startsWith("./") || tok.startsWith(".\\")) {
45836
+ const rel = tok.slice(2);
45837
+ return path19.join(flowHome, rel);
45838
+ }
45839
+ return tok;
45840
+ }).join("");
45841
+ }
45842
+
45843
+ // src/commands/project-setup.ts
45737
45844
  var KNOWN_PROFILES = ["generic", "embedded", "automotive", "web"];
45738
45845
  function parseInitArgs(raw) {
45739
45846
  const tokens = raw.trim().split(/\s+/).filter(Boolean);
45740
- const out = { generateAgents: true };
45847
+ const out = { generateAgents: true, seedGemini: true };
45741
45848
  for (let i2 = 0; i2 < tokens.length; i2++) {
45742
45849
  const t2 = tokens[i2];
45743
45850
  if (t2 === "--profile" && i2 + 1 < tokens.length) {
@@ -45753,6 +45860,10 @@ function parseInitArgs(raw) {
45753
45860
  out.generateAgents = false;
45754
45861
  } else if (t2 === "--agents") {
45755
45862
  out.generateAgents = true;
45863
+ } else if (t2 === "--no-skills") {
45864
+ out.seedGemini = false;
45865
+ } else if (t2 === "--skills") {
45866
+ out.seedGemini = true;
45756
45867
  } else if (!t2.startsWith("--")) {
45757
45868
  out.name = t2;
45758
45869
  }
@@ -45762,7 +45873,7 @@ function parseInitArgs(raw) {
45762
45873
  async function detectProfile(cwd) {
45763
45874
  const exists = async (rel) => {
45764
45875
  try {
45765
- await fs24.access(path19.join(cwd, rel));
45876
+ await fs25.access(path20.join(cwd, rel));
45766
45877
  return true;
45767
45878
  } catch {
45768
45879
  return false;
@@ -45770,7 +45881,7 @@ async function detectProfile(cwd) {
45770
45881
  };
45771
45882
  const globExists = async (pattern) => {
45772
45883
  try {
45773
- const entries = await fs24.readdir(cwd);
45884
+ const entries = await fs25.readdir(cwd);
45774
45885
  return entries.some((e2) => pattern.test(e2));
45775
45886
  } catch {
45776
45887
  return false;
@@ -45778,7 +45889,7 @@ async function detectProfile(cwd) {
45778
45889
  };
45779
45890
  if (await exists("package.json")) {
45780
45891
  try {
45781
- const raw = await fs24.readFile(path19.join(cwd, "package.json"), "utf8");
45892
+ const raw = await fs25.readFile(path20.join(cwd, "package.json"), "utf8");
45782
45893
  const pkg = JSON.parse(raw);
45783
45894
  const deps = {
45784
45895
  ...pkg.dependencies ?? {},
@@ -45812,8 +45923,8 @@ async function detectProfile(cwd) {
45812
45923
  }
45813
45924
  if (await exists("CMakeLists.txt")) {
45814
45925
  try {
45815
- const cmake = await fs24.readFile(
45816
- path19.join(cwd, "CMakeLists.txt"),
45926
+ const cmake = await fs25.readFile(
45927
+ path20.join(cwd, "CMakeLists.txt"),
45817
45928
  "utf8"
45818
45929
  );
45819
45930
  if (/arm-none-eabi/.test(cmake) || await globExists(/\.c$|\.h$|\.cpp$|\.hpp$/i)) {
@@ -45900,7 +46011,7 @@ var initCommand = {
45900
46011
  async execute(args, state, cfg) {
45901
46012
  const parsed = parseInitArgs(args);
45902
46013
  const cwd = process.cwd();
45903
- const name = parsed.name || state.activeProject || path19.basename(cwd);
46014
+ const name = parsed.name || state.activeProject || path20.basename(cwd);
45904
46015
  let profileName;
45905
46016
  let detectionReason;
45906
46017
  if (parsed.profile) {
@@ -45911,7 +46022,7 @@ var initCommand = {
45911
46022
  profileName = det.name;
45912
46023
  detectionReason = det.reason;
45913
46024
  }
45914
- const profilesRoot = path19.join(cfg.flow.flowHome, ".agenit", "profiles");
46025
+ const profilesRoot = path20.join(cfg.flow.flowHome, ".agenit", "profiles");
45915
46026
  let profile;
45916
46027
  try {
45917
46028
  profile = await loadProfile(profileName, profilesRoot);
@@ -45923,8 +46034,8 @@ var initCommand = {
45923
46034
  const loader = new MemoryLoader(cfg.flow.soulPath, cfg.flow.memoryDir);
45924
46035
  await loader.initProject(name);
45925
46036
  state.activeProject = name;
45926
- await fs24.writeFile(
45927
- path19.join(cwd, ".agenit_project"),
46037
+ await fs25.writeFile(
46038
+ path20.join(cwd, ".agenit_project"),
45928
46039
  projectMarkerToml(name, profileName)
45929
46040
  ).catch(() => {
45930
46041
  });
@@ -45938,19 +46049,19 @@ var initCommand = {
45938
46049
  lines.push(` Profile : ${chalk6.bold(profileName)}`);
45939
46050
  lines.push(` Detected via: ${chalk6.dim(detectionReason)}`);
45940
46051
  lines.push(
45941
- ` Memory dir : ${chalk6.dim(path19.join(cfg.flow.memoryDir, name))}`
46052
+ ` Memory dir : ${chalk6.dim(path20.join(cfg.flow.memoryDir, name))}`
45942
46053
  );
45943
46054
  lines.push(` Marker file : ${chalk6.dim(".agenit_project")}`);
45944
46055
  if (parsed.generateAgents) {
45945
- const agentsPath = path19.join(cwd, "AGENTS.md");
45946
- const exists = await fs24.access(agentsPath).then(() => true).catch(() => false);
46056
+ const agentsPath = path20.join(cwd, "AGENTS.md");
46057
+ const exists = await fs25.access(agentsPath).then(() => true).catch(() => false);
45947
46058
  if (exists) {
45948
46059
  lines.push(
45949
46060
  ` AGENTS.md : ${chalk6.yellow("skipped \u2014 file already exists")}`
45950
46061
  );
45951
46062
  } else {
45952
46063
  const seed = await readGlobalAgentsTemplate() || seedAgentsFromProfile(profile);
45953
- await fs24.writeFile(agentsPath, seed);
46064
+ await fs25.writeFile(agentsPath, seed);
45954
46065
  lines.push(
45955
46066
  ` AGENTS.md : ${chalk6.bold.green("written")} (${chalk6.dim("seeded from profile")})`
45956
46067
  );
@@ -45958,6 +46069,37 @@ var initCommand = {
45958
46069
  } else {
45959
46070
  lines.push(` AGENTS.md : ${chalk6.dim("skipped (--no-agents)")}`);
45960
46071
  }
46072
+ if (parsed.seedGemini) {
46073
+ try {
46074
+ const seed = await seedGeminiAssets(cwd, cfg.flow.flowHome);
46075
+ lines.push(
46076
+ ` Skills : ${chalk6.bold.green("copied")} ${chalk6.dim(
46077
+ `(${seed.skillsCopied} skill${seed.skillsCopied === 1 ? "" : "s"} \u2192 .gemini/skills/)`
46078
+ )}`
46079
+ );
46080
+ if (seed.settingsWritten) {
46081
+ lines.push(
46082
+ ` Hooks : ${chalk6.bold.green("written")} ${chalk6.dim(
46083
+ "(.gemini/settings.json with absolute hook paths)"
46084
+ )}`
46085
+ );
46086
+ } else {
46087
+ lines.push(
46088
+ ` Hooks : ${chalk6.yellow("skipped")} ${chalk6.dim(
46089
+ `(${seed.settingsSkippedReason ?? "unknown reason"})`
46090
+ )}`
46091
+ );
46092
+ }
46093
+ } catch (err) {
46094
+ lines.push(
46095
+ ` Skills : ${chalk6.red("failed")} ${chalk6.dim(
46096
+ err.message
46097
+ )}`
46098
+ );
46099
+ }
46100
+ } else {
46101
+ lines.push(` Skills : ${chalk6.dim("skipped (--no-skills)")}`);
46102
+ }
45961
46103
  lines.push("");
45962
46104
  lines.push(
45963
46105
  `Tip: run ${chalk6.bold("/run <task>")} or ${chalk6.bold(
@@ -45976,7 +46118,7 @@ var unflowCommand = {
45976
46118
  let removed = false;
45977
46119
  for (const marker of [".agenit_project", ".flow_project"]) {
45978
46120
  try {
45979
- await fs24.unlink(marker);
46121
+ await fs25.unlink(marker);
45980
46122
  removed = true;
45981
46123
  } catch {
45982
46124
  }
@@ -46076,7 +46218,7 @@ ${text || chalk7.dim("(empty)")}
46076
46218
 
46077
46219
  // src/commands/codedigest.ts
46078
46220
  init_dist2();
46079
- import path20 from "node:path";
46221
+ import path21 from "node:path";
46080
46222
  var codedigestCommand = {
46081
46223
  name: "codedigest",
46082
46224
  description: "AST-walk + keyword search of the codebase (no Docker / native deps)",
@@ -46103,7 +46245,7 @@ ${out}
46103
46245
  }
46104
46246
  case "index": {
46105
46247
  const root = rest || ".";
46106
- const stats = await index(path20.resolve(root), {
46248
+ const stats = await index(path21.resolve(root), {
46107
46249
  dbDir,
46108
46250
  project
46109
46251
  });
@@ -46141,9 +46283,9 @@ ${md}`;
46141
46283
 
46142
46284
  // src/commands/mempalace.ts
46143
46285
  import { spawn as spawn9 } from "node:child_process";
46144
- import { promises as fs25 } from "node:fs";
46286
+ import { promises as fs26 } from "node:fs";
46145
46287
  import os2 from "node:os";
46146
- import path21 from "node:path";
46288
+ import path22 from "node:path";
46147
46289
  import chalk8 from "chalk";
46148
46290
  async function runBinary(bin, args, timeoutMs) {
46149
46291
  return await new Promise((resolve3) => {
@@ -46171,11 +46313,11 @@ async function runBinary(bin, args, timeoutMs) {
46171
46313
  }
46172
46314
  async function lastMtime(dir) {
46173
46315
  try {
46174
- const entries = await fs25.readdir(dir);
46316
+ const entries = await fs26.readdir(dir);
46175
46317
  let latest = 0;
46176
46318
  for (const e2 of entries) {
46177
46319
  try {
46178
- const s2 = await fs25.stat(path21.join(dir, e2));
46320
+ const s2 = await fs26.stat(path22.join(dir, e2));
46179
46321
  if (s2.mtimeMs > latest) latest = s2.mtimeMs;
46180
46322
  } catch {
46181
46323
  }
@@ -46235,7 +46377,7 @@ var mempalaceCommand = {
46235
46377
  `mempalace binary '${cfg.mempalace.binary}' not on PATH. Run \`pip install mempalace\` and re-try.`
46236
46378
  );
46237
46379
  }
46238
- const target = rest && rest.length > 0 ? path21.resolve(rest) : path21.join(cfg.flow.memoryDir, project);
46380
+ const target = rest && rest.length > 0 ? path22.resolve(rest) : path22.join(cfg.flow.memoryDir, project);
46239
46381
  const result = await runBinary(
46240
46382
  cfg.mempalace.binary,
46241
46383
  ["mine", target],
@@ -46265,7 +46407,7 @@ ${result.stdout.trim()}
46265
46407
  `mempalace binary '${cfg.mempalace.binary}' not on PATH.`
46266
46408
  );
46267
46409
  }
46268
- const sidecar = path21.join(cfg.tools.toolsDir, "mempalace_search.py");
46410
+ const sidecar = path22.join(cfg.tools.toolsDir, "mempalace_search.py");
46269
46411
  const result = await runBinary(
46270
46412
  cfg.tools.python,
46271
46413
  [
@@ -46324,7 +46466,7 @@ ${result.stdout.trim() || "(empty)"}
46324
46466
  const unregister = sub === "mcp-unregister";
46325
46467
  const tokens = rest.split(/\s+/).filter(Boolean);
46326
46468
  let dryRun = false;
46327
- let settingsPath = path21.join(os2.homedir(), ".gemini", "settings.json");
46469
+ let settingsPath = path22.join(os2.homedir(), ".gemini", "settings.json");
46328
46470
  for (let i2 = 0; i2 < tokens.length; i2++) {
46329
46471
  const t2 = tokens[i2];
46330
46472
  if (t2 === "--dry-run") dryRun = true;
@@ -46418,7 +46560,7 @@ async function unregisterMempalaceMcp(settingsPath, dryRun) {
46418
46560
  }
46419
46561
  async function readSettings(settingsPath) {
46420
46562
  try {
46421
- const raw = await fs25.readFile(settingsPath, "utf8");
46563
+ const raw = await fs26.readFile(settingsPath, "utf8");
46422
46564
  const parsed = JSON.parse(raw);
46423
46565
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
46424
46566
  throw new Error(
@@ -46433,23 +46575,23 @@ async function readSettings(settingsPath) {
46433
46575
  }
46434
46576
  }
46435
46577
  async function writeSettings(settingsPath, json) {
46436
- await fs25.mkdir(path21.dirname(settingsPath), { recursive: true });
46578
+ await fs26.mkdir(path22.dirname(settingsPath), { recursive: true });
46437
46579
  const body = JSON.stringify(json, null, 2) + "\n";
46438
- await fs25.writeFile(settingsPath, body, "utf8");
46580
+ await fs26.writeFile(settingsPath, body, "utf8");
46439
46581
  }
46440
46582
  function indent(s2) {
46441
46583
  return s2.split("\n").map((l2) => ` ${l2}`).join("\n");
46442
46584
  }
46443
46585
 
46444
46586
  // src/commands/skills.ts
46445
- import { promises as fs26 } from "node:fs";
46446
- import path22 from "node:path";
46587
+ import { promises as fs27 } from "node:fs";
46588
+ import path23 from "node:path";
46447
46589
  import chalk9 from "chalk";
46448
46590
  var SKILLS_DIR = ".gemini/skills";
46449
46591
  async function listSkills() {
46450
46592
  let entries = [];
46451
46593
  try {
46452
- const dirents = await fs26.readdir(SKILLS_DIR, { withFileTypes: true });
46594
+ const dirents = await fs27.readdir(SKILLS_DIR, { withFileTypes: true });
46453
46595
  entries = dirents.filter((d2) => d2.isDirectory()).map((d2) => d2.name);
46454
46596
  } catch {
46455
46597
  return ` ${chalk9.yellow("No skills directory found at .gemini/skills/")}`;
@@ -46458,10 +46600,10 @@ async function listSkills() {
46458
46600
  `;
46459
46601
  let count = 0;
46460
46602
  for (const name of entries.sort()) {
46461
- const skillMd = path22.join(SKILLS_DIR, name, "SKILL.md");
46603
+ const skillMd = path23.join(SKILLS_DIR, name, "SKILL.md");
46462
46604
  let body = "";
46463
46605
  try {
46464
- body = await fs26.readFile(skillMd, "utf8");
46606
+ body = await fs27.readFile(skillMd, "utf8");
46465
46607
  } catch {
46466
46608
  continue;
46467
46609
  }
@@ -46490,46 +46632,46 @@ async function installSkill(src) {
46490
46632
  if (!src) throw new Error("Usage: /skills install <path-to-skill-directory>");
46491
46633
  let stat4;
46492
46634
  try {
46493
- stat4 = await fs26.stat(src);
46635
+ stat4 = await fs27.stat(src);
46494
46636
  } catch {
46495
46637
  throw new Error(`Path not found: ${src}`);
46496
46638
  }
46497
46639
  if (!stat4.isDirectory()) throw new Error(`${src} is not a directory`);
46498
- const name = path22.basename(src);
46499
- const dest = path22.join(SKILLS_DIR, name);
46640
+ const name = path23.basename(src);
46641
+ const dest = path23.join(SKILLS_DIR, name);
46500
46642
  try {
46501
- await fs26.access(dest);
46643
+ await fs27.access(dest);
46502
46644
  throw new Error(
46503
46645
  `Skill '${name}' is already installed. Remove it first with /skills remove ${name}`
46504
46646
  );
46505
46647
  } catch (e2) {
46506
46648
  if (e2.code !== "ENOENT") throw e2;
46507
46649
  }
46508
- await copyDirRecursive(src, dest);
46650
+ await copyDirRecursive2(src, dest);
46509
46651
  return `${chalk9.bold.green("\u2713")} Skill '${chalk9.bold.cyan(name)}' installed at ${SKILLS_DIR}/${name}
46510
46652
  Reload Gemini CLI with: ${chalk9.bold("gemini /skills reload")} or restart the session.`;
46511
46653
  }
46512
46654
  async function removeSkill(name) {
46513
46655
  if (!name) throw new Error("Usage: /skills remove <skill-name>");
46514
- const target = path22.join(SKILLS_DIR, name);
46656
+ const target = path23.join(SKILLS_DIR, name);
46515
46657
  try {
46516
- await fs26.access(target);
46658
+ await fs27.access(target);
46517
46659
  } catch {
46518
46660
  throw new Error(`Skill '${name}' not found in ${SKILLS_DIR}/`);
46519
46661
  }
46520
- await fs26.rm(target, { recursive: true, force: true });
46662
+ await fs27.rm(target, { recursive: true, force: true });
46521
46663
  return `${chalk9.bold.green("\u2713")} Skill '${chalk9.bold.cyan(name)}' removed.`;
46522
46664
  }
46523
- async function copyDirRecursive(src, dst) {
46524
- await fs26.mkdir(dst, { recursive: true });
46525
- const entries = await fs26.readdir(src, { withFileTypes: true });
46665
+ async function copyDirRecursive2(src, dst) {
46666
+ await fs27.mkdir(dst, { recursive: true });
46667
+ const entries = await fs27.readdir(src, { withFileTypes: true });
46526
46668
  for (const entry of entries) {
46527
- const s2 = path22.join(src, entry.name);
46528
- const d2 = path22.join(dst, entry.name);
46669
+ const s2 = path23.join(src, entry.name);
46670
+ const d2 = path23.join(dst, entry.name);
46529
46671
  if (entry.isDirectory()) {
46530
- await copyDirRecursive(s2, d2);
46672
+ await copyDirRecursive2(s2, d2);
46531
46673
  } else {
46532
- await fs26.copyFile(s2, d2);
46674
+ await fs27.copyFile(s2, d2);
46533
46675
  }
46534
46676
  }
46535
46677
  }
@@ -46559,7 +46701,7 @@ var skillsCommand = {
46559
46701
  };
46560
46702
 
46561
46703
  // src/commands/worktree.ts
46562
- import { promises as fs27 } from "node:fs";
46704
+ import { promises as fs28 } from "node:fs";
46563
46705
  import { spawn as spawn10 } from "node:child_process";
46564
46706
  import chalk10 from "chalk";
46565
46707
  function runGit(args) {
@@ -46619,7 +46761,7 @@ ${chalk10.bold("Usage:")}
46619
46761
  }
46620
46762
  const branch = trimmed;
46621
46763
  const worktreePath = `.gemini/worktrees/${branch}`;
46622
- await fs27.mkdir(".gemini/worktrees", { recursive: true }).catch(() => {
46764
+ await fs28.mkdir(".gemini/worktrees", { recursive: true }).catch(() => {
46623
46765
  });
46624
46766
  const create = await runGit(["worktree", "add", "-b", branch, worktreePath]);
46625
46767
  if (!create.ok) {
@@ -46648,8 +46790,8 @@ Branch: ${chalk10.cyan(branch)}
46648
46790
  };
46649
46791
 
46650
46792
  // src/commands/traceability.ts
46651
- import { promises as fs28 } from "node:fs";
46652
- import path23 from "node:path";
46793
+ import { promises as fs29 } from "node:fs";
46794
+ import path24 from "node:path";
46653
46795
  import chalk11 from "chalk";
46654
46796
  function parseSummary(stdout) {
46655
46797
  const t2 = { covered: 0, testGap: 0, orphan: 0 };
@@ -46668,17 +46810,17 @@ function parseSummary(stdout) {
46668
46810
  return t2;
46669
46811
  }
46670
46812
  async function locateScript() {
46671
- const local = path23.join(process.cwd(), ".flow/tools/traceability_scan.py");
46813
+ const local = path24.join(process.cwd(), ".flow/tools/traceability_scan.py");
46672
46814
  try {
46673
- await fs28.access(local);
46815
+ await fs29.access(local);
46674
46816
  return local;
46675
46817
  } catch {
46676
46818
  }
46677
46819
  const flowHome = process.env.FLOW_HOME;
46678
46820
  if (flowHome) {
46679
- const home = path23.join(flowHome, ".flow/tools/traceability_scan.py");
46821
+ const home = path24.join(flowHome, ".flow/tools/traceability_scan.py");
46680
46822
  try {
46681
- await fs28.access(home);
46823
+ await fs29.access(home);
46682
46824
  return home;
46683
46825
  } catch {
46684
46826
  }
@@ -46687,9 +46829,9 @@ async function locateScript() {
46687
46829
  }
46688
46830
  async function locateSrcDir() {
46689
46831
  for (const c2 of ["src", "Src", "source", "Source", "crates", "packages"]) {
46690
- const p2 = path23.join(process.cwd(), c2);
46832
+ const p2 = path24.join(process.cwd(), c2);
46691
46833
  try {
46692
- const s2 = await fs28.stat(p2);
46834
+ const s2 = await fs29.stat(p2);
46693
46835
  if (s2.isDirectory()) return p2;
46694
46836
  } catch {
46695
46837
  }
@@ -46697,9 +46839,9 @@ async function locateSrcDir() {
46697
46839
  return process.cwd();
46698
46840
  }
46699
46841
  async function locatePython() {
46700
- const venv = path23.join(process.cwd(), ".venv/bin/python3");
46842
+ const venv = path24.join(process.cwd(), ".venv/bin/python3");
46701
46843
  try {
46702
- await fs28.access(venv);
46844
+ await fs29.access(venv);
46703
46845
  return venv;
46704
46846
  } catch {
46705
46847
  return "python3";
@@ -46708,9 +46850,9 @@ async function locatePython() {
46708
46850
  async function runTraceability(state, cfg) {
46709
46851
  const project = state.activeProject;
46710
46852
  if (!project) throw new Error("no active project \u2014 run /project <name> first");
46711
- const reqs = path23.join(cfg.flow.memoryDir, "projects", project, "requirements.md");
46853
+ const reqs = path24.join(cfg.flow.memoryDir, "projects", project, "requirements.md");
46712
46854
  try {
46713
- await fs28.access(reqs);
46855
+ await fs29.access(reqs);
46714
46856
  } catch {
46715
46857
  throw new Error(
46716
46858
  `requirements.md not found at ${reqs} \u2014 write SWE.1 requirements first`
@@ -46741,8 +46883,8 @@ var traceabilityCommand = {
46741
46883
  };
46742
46884
 
46743
46885
  // src/commands/profile.ts
46744
- import { promises as fs29 } from "node:fs";
46745
- import path24 from "node:path";
46886
+ import { promises as fs30 } from "node:fs";
46887
+ import path25 from "node:path";
46746
46888
  import chalk12 from "chalk";
46747
46889
  function parseProfilesYaml(text) {
46748
46890
  const profiles = [];
@@ -46811,10 +46953,10 @@ function stripQuotes(s2) {
46811
46953
  return s2;
46812
46954
  }
46813
46955
  async function loadProfiles(cfg) {
46814
- const file = path24.join(cfg.flow.flowHome, "profiles", "profiles.yaml");
46956
+ const file = path25.join(cfg.flow.flowHome, "profiles", "profiles.yaml");
46815
46957
  let text = "";
46816
46958
  try {
46817
- text = await fs29.readFile(file, "utf8");
46959
+ text = await fs30.readFile(file, "utf8");
46818
46960
  } catch {
46819
46961
  return [];
46820
46962
  }
@@ -46892,7 +47034,7 @@ ${found.skills.map((s2) => ` \u2022 ${s2}`).join("\n")}`;
46892
47034
  };
46893
47035
 
46894
47036
  // src/commands/debug.ts
46895
- import { promises as fs30 } from "node:fs";
47037
+ import { promises as fs31 } from "node:fs";
46896
47038
  import chalk13 from "chalk";
46897
47039
  init_dist();
46898
47040
  var debugCommand = {
@@ -46925,7 +47067,7 @@ ${chalk13.dim(" /debug why does my LIN slave timeout after 10 frames")}
46925
47067
  ${ctx}` : soul;
46926
47068
  let skillBody = "You are a hardware debugging expert for embedded systems.";
46927
47069
  try {
46928
- skillBody = await fs30.readFile(".gemini/skills/hw-debugger/SKILL.md", "utf8");
47070
+ skillBody = await fs31.readFile(".gemini/skills/hw-debugger/SKILL.md", "utf8");
46929
47071
  } catch {
46930
47072
  }
46931
47073
  const { python, toolsDir } = cfg.tools;
@@ -46968,24 +47110,24 @@ ${response}`;
46968
47110
 
46969
47111
  // src/commands/squad.ts
46970
47112
  import { existsSync } from "node:fs";
46971
- import path27 from "node:path";
47113
+ import path28 from "node:path";
46972
47114
  import chalk14 from "chalk";
46973
47115
 
46974
47116
  // src/skill-loader.ts
46975
- import { promises as fs31 } from "node:fs";
46976
- import path25 from "node:path";
47117
+ import { promises as fs32 } from "node:fs";
47118
+ import path26 from "node:path";
46977
47119
  async function loadSkillBody2(skill) {
46978
- const local = path25.join(".gemini", "skills", skill, "SKILL.md");
47120
+ const local = path26.join(".gemini", "skills", skill, "SKILL.md");
46979
47121
  try {
46980
- const body = await fs31.readFile(local, "utf8");
47122
+ const body = await fs32.readFile(local, "utf8");
46981
47123
  if (body.trim()) return body;
46982
47124
  } catch {
46983
47125
  }
46984
47126
  const home = process.env.HOME ?? process.env.USERPROFILE;
46985
47127
  if (home) {
46986
- const global2 = path25.join(home, ".gemini", "skills", skill, "SKILL.md");
47128
+ const global2 = path26.join(home, ".gemini", "skills", skill, "SKILL.md");
46987
47129
  try {
46988
- const body = await fs31.readFile(global2, "utf8");
47130
+ const body = await fs32.readFile(global2, "utf8");
46989
47131
  if (body.trim()) return body;
46990
47132
  } catch {
46991
47133
  }
@@ -47067,16 +47209,16 @@ function renderSkillWithRestrictions(skill) {
47067
47209
  }
47068
47210
 
47069
47211
  // src/tool-executors.ts
47070
- import { promises as fs32 } from "node:fs";
47212
+ import { promises as fs33 } from "node:fs";
47071
47213
  import { spawn as spawn11 } from "node:child_process";
47072
- import path26 from "node:path";
47214
+ import path27 from "node:path";
47073
47215
  var MAX_FILE_BYTES = 256 * 1024;
47074
47216
  var MAX_GREP_HITS = 200;
47075
47217
  var MAX_DIR_ENTRIES = 200;
47076
47218
  async function readGuard(cwd) {
47077
47219
  try {
47078
- const raw = await fs32.readFile(
47079
- path26.join(cwd, ".flow", ".guard.json"),
47220
+ const raw = await fs33.readFile(
47221
+ path27.join(cwd, ".flow", ".guard.json"),
47080
47222
  "utf8"
47081
47223
  );
47082
47224
  return JSON.parse(raw);
@@ -47102,7 +47244,7 @@ function checkShellAllowed(command, guard) {
47102
47244
  let head = "";
47103
47245
  for (const tok of tokens) {
47104
47246
  if (/^[A-Za-z_][\w]*=/.test(tok)) continue;
47105
- head = path26.basename(tok);
47247
+ head = path27.basename(tok);
47106
47248
  break;
47107
47249
  }
47108
47250
  if (head && !allow.includes(head)) {
@@ -47113,24 +47255,24 @@ function checkShellAllowed(command, guard) {
47113
47255
  var readFile = async (args) => {
47114
47256
  const p2 = String(args.path ?? "");
47115
47257
  if (!p2) throw new Error("read_file requires `path`");
47116
- const stat4 = await fs32.stat(p2);
47258
+ const stat4 = await fs33.stat(p2);
47117
47259
  if (stat4.size > MAX_FILE_BYTES) {
47118
47260
  return `(${stat4.size} bytes \u2014 too large; first ${MAX_FILE_BYTES} bytes follow)
47119
- ` + (await fs32.readFile(p2, { encoding: "utf8" })).slice(0, MAX_FILE_BYTES);
47261
+ ` + (await fs33.readFile(p2, { encoding: "utf8" })).slice(0, MAX_FILE_BYTES);
47120
47262
  }
47121
- return await fs32.readFile(p2, "utf8");
47263
+ return await fs33.readFile(p2, "utf8");
47122
47264
  };
47123
47265
  var writeFile = async (args) => {
47124
47266
  const p2 = String(args.path ?? "");
47125
47267
  const content = String(args.content ?? "");
47126
47268
  if (!p2) throw new Error("write_file requires `path`");
47127
- await fs32.mkdir(path26.dirname(p2), { recursive: true });
47128
- await fs32.writeFile(p2, content);
47269
+ await fs33.mkdir(path27.dirname(p2), { recursive: true });
47270
+ await fs33.writeFile(p2, content);
47129
47271
  return `wrote ${content.length} bytes to ${p2}`;
47130
47272
  };
47131
47273
  var listDir = async (args) => {
47132
47274
  const p2 = String(args.path ?? ".");
47133
- const entries = await fs32.readdir(p2, { withFileTypes: true });
47275
+ const entries = await fs33.readdir(p2, { withFileTypes: true });
47134
47276
  const lines = [];
47135
47277
  for (const e2 of entries.slice(0, MAX_DIR_ENTRIES)) {
47136
47278
  lines.push(`${e2.isDirectory() ? "d" : "f"} ${e2.name}`);
@@ -47331,7 +47473,7 @@ function squadRunCfg(cfg) {
47331
47473
  } : void 0
47332
47474
  };
47333
47475
  }
47334
- const hookPath = path27.join(
47476
+ const hookPath = path28.join(
47335
47477
  cfg.baseDir,
47336
47478
  ".flow",
47337
47479
  "hooks",
@@ -47343,7 +47485,7 @@ function squadRunCfg(cfg) {
47343
47485
  script: hookPath
47344
47486
  };
47345
47487
  }
47346
- out.graphDir = path27.join(cfg.flow.memoryDir, "..", "graph");
47488
+ out.graphDir = path28.join(cfg.flow.memoryDir, "..", "graph");
47347
47489
  return out;
47348
47490
  }
47349
47491
  var squadCommand = {
@@ -47487,7 +47629,7 @@ ${response}
47487
47629
  };
47488
47630
 
47489
47631
  // src/commands/goal.ts
47490
- import path32 from "node:path";
47632
+ import path33 from "node:path";
47491
47633
  import chalk15 from "chalk";
47492
47634
 
47493
47635
  // src/telemetry.ts
@@ -47719,18 +47861,18 @@ var GoalBudget = class _GoalBudget {
47719
47861
  };
47720
47862
 
47721
47863
  // ../goal/dist/store.js
47722
- import { existsSync as existsSync2, promises as fs33 } from "node:fs";
47723
- import path28 from "node:path";
47864
+ import { existsSync as existsSync2, promises as fs34 } from "node:fs";
47865
+ import path29 from "node:path";
47724
47866
  var GoalStore = class {
47725
47867
  projectDir;
47726
47868
  constructor(projectDir2) {
47727
47869
  this.projectDir = projectDir2;
47728
47870
  }
47729
47871
  activePath() {
47730
- return path28.join(this.projectDir, "goal.json");
47872
+ return path29.join(this.projectDir, "goal.json");
47731
47873
  }
47732
47874
  archivePath() {
47733
- return path28.join(this.projectDir, "goals_archive.md");
47875
+ return path29.join(this.projectDir, "goals_archive.md");
47734
47876
  }
47735
47877
  /** Test helper: is there an active goal file on disk right now? */
47736
47878
  hasActiveSync() {
@@ -47738,7 +47880,7 @@ var GoalStore = class {
47738
47880
  }
47739
47881
  async hasActive() {
47740
47882
  try {
47741
- await fs33.access(this.activePath());
47883
+ await fs34.access(this.activePath());
47742
47884
  return true;
47743
47885
  } catch {
47744
47886
  return false;
@@ -47752,7 +47894,7 @@ var GoalStore = class {
47752
47894
  const p2 = this.activePath();
47753
47895
  let raw;
47754
47896
  try {
47755
- raw = await fs33.readFile(p2, "utf8");
47897
+ raw = await fs34.readFile(p2, "utf8");
47756
47898
  } catch {
47757
47899
  return null;
47758
47900
  }
@@ -47770,27 +47912,27 @@ var GoalStore = class {
47770
47912
  * renames so a crash mid-write can't leave a half-flushed file in place.
47771
47913
  */
47772
47914
  async save(record) {
47773
- await fs33.mkdir(this.projectDir, { recursive: true });
47915
+ await fs34.mkdir(this.projectDir, { recursive: true });
47774
47916
  const p2 = this.activePath();
47775
47917
  const tmp = p2 + ".tmp";
47776
47918
  const body = JSON.stringify(record, null, 2);
47777
- await fs33.writeFile(tmp, body);
47778
- await fs33.rename(tmp, p2);
47919
+ await fs34.writeFile(tmp, body);
47920
+ await fs34.rename(tmp, p2);
47779
47921
  }
47780
47922
  /**
47781
47923
  * Clear the active goal: append a summary block to the archive, then
47782
47924
  * remove `goal.json`.
47783
47925
  */
47784
47926
  async archiveAndClear(record) {
47785
- await fs33.mkdir(this.projectDir, { recursive: true });
47927
+ await fs34.mkdir(this.projectDir, { recursive: true });
47786
47928
  let existing = "";
47787
47929
  try {
47788
- existing = await fs33.readFile(this.archivePath(), "utf8");
47930
+ existing = await fs34.readFile(this.archivePath(), "utf8");
47789
47931
  } catch {
47790
47932
  }
47791
- await fs33.writeFile(this.archivePath(), existing + formatArchiveEntry(record));
47933
+ await fs34.writeFile(this.archivePath(), existing + formatArchiveEntry(record));
47792
47934
  try {
47793
- await fs33.unlink(this.activePath());
47935
+ await fs34.unlink(this.activePath());
47794
47936
  } catch {
47795
47937
  }
47796
47938
  }
@@ -47808,13 +47950,13 @@ function formatArchiveEntry(rec) {
47808
47950
  }
47809
47951
 
47810
47952
  // ../goal/dist/lock.js
47811
- import { promises as fs34 } from "node:fs";
47812
- import path29 from "node:path";
47953
+ import { promises as fs35 } from "node:fs";
47954
+ import path30 from "node:path";
47813
47955
  var GoalLock = class _GoalLock {
47814
47956
  path;
47815
47957
  released = false;
47816
- constructor(path55) {
47817
- this.path = path55;
47958
+ constructor(path57) {
47959
+ this.path = path57;
47818
47960
  }
47819
47961
  /**
47820
47962
  * Try to acquire the lock, polling every 50 ms up to `timeoutMs`. If a
@@ -47823,8 +47965,8 @@ var GoalLock = class _GoalLock {
47823
47965
  */
47824
47966
  static async acquire(target, timeoutMs) {
47825
47967
  const lockPath = lockPathFor(target);
47826
- const dir = path29.dirname(lockPath);
47827
- await fs34.mkdir(dir, { recursive: true }).catch(() => {
47968
+ const dir = path30.dirname(lockPath);
47969
+ await fs35.mkdir(dir, { recursive: true }).catch(() => {
47828
47970
  });
47829
47971
  const started = Date.now();
47830
47972
  while (true) {
@@ -47834,12 +47976,12 @@ var GoalLock = class _GoalLock {
47834
47976
  } catch {
47835
47977
  let holderText = "";
47836
47978
  try {
47837
- holderText = await fs34.readFile(lockPath, "utf8");
47979
+ holderText = await fs35.readFile(lockPath, "utf8");
47838
47980
  } catch {
47839
47981
  }
47840
47982
  const pid = parsePid(holderText);
47841
47983
  if (!isPidAlive(pid)) {
47842
- await fs34.unlink(lockPath).catch(() => {
47984
+ await fs35.unlink(lockPath).catch(() => {
47843
47985
  });
47844
47986
  continue;
47845
47987
  }
@@ -47855,7 +47997,7 @@ var GoalLock = class _GoalLock {
47855
47997
  if (this.released)
47856
47998
  return;
47857
47999
  try {
47858
- await fs34.unlink(this.path);
48000
+ await fs35.unlink(this.path);
47859
48001
  } catch (e2) {
47860
48002
  const code = e2.code;
47861
48003
  if (code !== "ENOENT")
@@ -47868,7 +48010,7 @@ function lockPathFor(target) {
47868
48010
  return `${target}.lock`;
47869
48011
  }
47870
48012
  async function tryCreate(p2) {
47871
- const handle = await fs34.open(p2, "wx");
48013
+ const handle = await fs35.open(p2, "wx");
47872
48014
  try {
47873
48015
  await handle.write(String(process.pid));
47874
48016
  } finally {
@@ -48016,13 +48158,13 @@ async function gitChangedFiles(workspace) {
48016
48158
  return out.stdout.split("\n").map(parsePorcelainLine).filter((p2) => p2 !== null);
48017
48159
  }
48018
48160
  function parsePorcelainLine(line) {
48019
- const path55 = line.slice(3).trim();
48020
- if (!path55)
48161
+ const path57 = line.slice(3).trim();
48162
+ if (!path57)
48021
48163
  return null;
48022
- const renameIdx = path55.indexOf(" -> ");
48164
+ const renameIdx = path57.indexOf(" -> ");
48023
48165
  if (renameIdx >= 0)
48024
- return path55.slice(renameIdx + 4);
48025
- return path55;
48166
+ return path57.slice(renameIdx + 4);
48167
+ return path57;
48026
48168
  }
48027
48169
  function countTestChanges(files) {
48028
48170
  return files.filter(isTestPath).length;
@@ -48077,7 +48219,7 @@ async function runCapture(cmd, args, cwd) {
48077
48219
 
48078
48220
  // ../goal/dist/runner.js
48079
48221
  import { EventEmitter as EventEmitter4 } from "node:events";
48080
- import path30 from "node:path";
48222
+ import path31 from "node:path";
48081
48223
 
48082
48224
  // ../goal/dist/telemetry.js
48083
48225
  import { trace as trace4, SpanStatusCode as SpanStatusCode4 } from "@opentelemetry/api";
@@ -48161,7 +48303,7 @@ function spawnRunner(projectDir2, driver) {
48161
48303
  return;
48162
48304
  }
48163
48305
  try {
48164
- const target = path30.join(projectDir2, "goal.json");
48306
+ const target = path31.join(projectDir2, "goal.json");
48165
48307
  const lock = await GoalLock.acquire(target, RUNNER_LOCK_TIMEOUT_MS);
48166
48308
  try {
48167
48309
  await store.save(rec);
@@ -48373,8 +48515,8 @@ function summarise2(result, turn) {
48373
48515
  }
48374
48516
 
48375
48517
  // ../goal/dist/cost.js
48376
- import { promises as fs35 } from "node:fs";
48377
- import path31 from "node:path";
48518
+ import { promises as fs36 } from "node:fs";
48519
+ import path32 from "node:path";
48378
48520
  var DEFAULT_RATE_USD_PER_1K_TOKENS = {
48379
48521
  // Gemini CLI is OAuth-billed (free quota, then Pay-as-you-go).
48380
48522
  "gemini-cli": 5e-3,
@@ -48405,11 +48547,11 @@ function rateFor(provider, model, overrides) {
48405
48547
  return DEFAULT_RATE_USD_PER_1K_TOKENS[provider] ?? 0;
48406
48548
  }
48407
48549
  function logPath(projectDir2) {
48408
- return path31.join(projectDir2, "costs.json");
48550
+ return path32.join(projectDir2, "costs.json");
48409
48551
  }
48410
48552
  async function loadCostLog(projectDir2, project) {
48411
48553
  try {
48412
- const raw = await fs35.readFile(logPath(projectDir2), "utf8");
48554
+ const raw = await fs36.readFile(logPath(projectDir2), "utf8");
48413
48555
  const parsed = JSON.parse(raw);
48414
48556
  if (!Array.isArray(parsed.entries))
48415
48557
  parsed.entries = [];
@@ -48432,8 +48574,8 @@ async function appendCostEntry(projectDir2, project, entry, rateOverrides) {
48432
48574
  if (log.entries.length > 5e3) {
48433
48575
  log.entries = log.entries.slice(-5e3);
48434
48576
  }
48435
- await fs35.mkdir(projectDir2, { recursive: true });
48436
- await fs35.writeFile(logPath(projectDir2), JSON.stringify(log, null, 2));
48577
+ await fs36.mkdir(projectDir2, { recursive: true });
48578
+ await fs36.writeFile(logPath(projectDir2), JSON.stringify(log, null, 2));
48437
48579
  return finalEntry;
48438
48580
  }
48439
48581
 
@@ -48447,10 +48589,10 @@ function getLoopWorkerPool() {
48447
48589
  return loopPool;
48448
48590
  }
48449
48591
  function projectDir(cfg, project) {
48450
- return path32.join(cfg.flow.memoryDir, project);
48592
+ return path33.join(cfg.flow.memoryDir, project);
48451
48593
  }
48452
48594
  async function saveLocked(store, pdir, rec) {
48453
- const target = path32.join(pdir, "goal.json");
48595
+ const target = path33.join(pdir, "goal.json");
48454
48596
  const lock = await GoalLock.acquire(target, LOCK_TIMEOUT_MS);
48455
48597
  try {
48456
48598
  await store.save(rec);
@@ -48671,7 +48813,7 @@ ${block}
48671
48813
  const report = await this.auditor.audit(response);
48672
48814
  rec.budget.recordTurn(tokensThisTurn);
48673
48815
  try {
48674
- const projectDir2 = path32.join(this.cfg.flow.memoryDir, this.project);
48816
+ const projectDir2 = path33.join(this.cfg.flow.memoryDir, this.project);
48675
48817
  const provider = this.lastRouted?.provider ?? this.cfg.backend.provider ?? "gemini-cli";
48676
48818
  const model = this.lastRouted?.model ?? this.cfg.backend.model ?? this.cfg.gemini.model ?? provider;
48677
48819
  const entry = await appendCostEntry(
@@ -48981,7 +49123,7 @@ async function tickOnce(store, pdir, cfg, signal) {
48981
49123
  if (rec.state !== GoalState.Active) {
48982
49124
  return `${chalk15.cyan("\u2139")} Goal is ${rec.state}; resume it first.`;
48983
49125
  }
48984
- const driver = new OrchestratorDriver(cfg, workspaceRoot(cfg), path32.basename(pdir));
49126
+ const driver = new OrchestratorDriver(cfg, workspaceRoot(cfg), path33.basename(pdir));
48985
49127
  driver.signal = signal;
48986
49128
  const outcome = await driver.tick(rec);
48987
49129
  await saveLocked(store, pdir, rec);
@@ -49012,7 +49154,7 @@ async function startRunner(pdir, cfg, store) {
49012
49154
  if (activeRunner) {
49013
49155
  return `${chalk15.cyan("\u2139")} An autonomous runner is already active. \`/goal stop\` to halt it.`;
49014
49156
  }
49015
- const driver = new OrchestratorDriver(cfg, workspaceRoot(cfg), path32.basename(pdir));
49157
+ const driver = new OrchestratorDriver(cfg, workspaceRoot(cfg), path33.basename(pdir));
49016
49158
  const handle = spawnRunner(pdir, driver);
49017
49159
  activeRunner = handle;
49018
49160
  const goalLoopId = `goal:${rec.spec.id}`;
@@ -49342,15 +49484,15 @@ ${chalk17.dim(`Findings persisted at memory/projects/${project}/security-audit.m
49342
49484
  };
49343
49485
 
49344
49486
  // src/commands/testgap.ts
49345
- import { promises as fs36 } from "node:fs";
49346
- import path33 from "node:path";
49487
+ import { promises as fs37 } from "node:fs";
49488
+ import path34 from "node:path";
49347
49489
  import chalk18 from "chalk";
49348
49490
  function reportPath(memoryDir, project) {
49349
- return path33.join(memoryDir, project, "testgap_report.json");
49491
+ return path34.join(memoryDir, project, "testgap_report.json");
49350
49492
  }
49351
49493
  async function loadReport(memoryDir, project) {
49352
49494
  try {
49353
- const raw = await fs36.readFile(reportPath(memoryDir, project), "utf8");
49495
+ const raw = await fs37.readFile(reportPath(memoryDir, project), "utf8");
49354
49496
  return JSON.parse(raw);
49355
49497
  } catch {
49356
49498
  return null;
@@ -49424,7 +49566,7 @@ var testgapCommand = {
49424
49566
  if (sub !== "scan") {
49425
49567
  throw new Error("Usage: /testgap [scan|report]");
49426
49568
  }
49427
- const tool = path33.join(cfg.tools.toolsDir, "testgap_scan.py");
49569
+ const tool = path34.join(cfg.tools.toolsDir, "testgap_scan.py");
49428
49570
  let raw;
49429
49571
  try {
49430
49572
  raw = await runPython(
@@ -49451,10 +49593,10 @@ var testgapCommand = {
49451
49593
  );
49452
49594
  }
49453
49595
  report.capturedAt = (/* @__PURE__ */ new Date()).toISOString();
49454
- await fs36.mkdir(path33.join(cfg.flow.memoryDir, project), {
49596
+ await fs37.mkdir(path34.join(cfg.flow.memoryDir, project), {
49455
49597
  recursive: true
49456
49598
  });
49457
- await fs36.writeFile(
49599
+ await fs37.writeFile(
49458
49600
  reportPath(cfg.flow.memoryDir, project),
49459
49601
  JSON.stringify(report, null, 2)
49460
49602
  );
@@ -49467,8 +49609,8 @@ import chalk19 from "chalk";
49467
49609
 
49468
49610
  // ../web-ui/dist/index.js
49469
49611
  import { createServer } from "node:http";
49470
- import { promises as fs37 } from "node:fs";
49471
- import path34 from "node:path";
49612
+ import { promises as fs38 } from "node:fs";
49613
+ import path35 from "node:path";
49472
49614
  import { fileURLToPath as fileURLToPath3 } from "node:url";
49473
49615
 
49474
49616
  // ../../node_modules/.pnpm/ws@8.20.0/node_modules/ws/wrapper.mjs
@@ -49484,7 +49626,7 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
49484
49626
  // ../web-ui/dist/index.js
49485
49627
  var STATIC_DIR = (
49486
49628
  // dist build copies src/static → dist/static (see package.json `build`).
49487
- path34.resolve(path34.dirname(fileURLToPath3(import.meta.url)), "static")
49629
+ path35.resolve(path35.dirname(fileURLToPath3(import.meta.url)), "static")
49488
49630
  );
49489
49631
  var MIME = {
49490
49632
  ".html": "text/html; charset=utf-8",
@@ -49501,9 +49643,9 @@ async function startWebUi(bus, opts = {}) {
49501
49643
  const url = new URL(req.url ?? "/", `http://${host}:${port}`);
49502
49644
  let pathname = url.pathname === "/" ? "/index.html" : url.pathname;
49503
49645
  pathname = pathname.replace(/\.\.+/g, "");
49504
- const filePath = path34.join(STATIC_DIR, pathname);
49505
- const ext2 = path34.extname(filePath).toLowerCase();
49506
- const body = await fs37.readFile(filePath);
49646
+ const filePath = path35.join(STATIC_DIR, pathname);
49647
+ const ext2 = path35.extname(filePath).toLowerCase();
49648
+ const body = await fs38.readFile(filePath);
49507
49649
  res.writeHead(200, {
49508
49650
  "Content-Type": MIME[ext2] ?? "application/octet-stream",
49509
49651
  "Cache-Control": "no-store",
@@ -49652,12 +49794,12 @@ var webCommand = {
49652
49794
  };
49653
49795
 
49654
49796
  // src/commands/federation.ts
49655
- import path38 from "node:path";
49797
+ import path39 from "node:path";
49656
49798
  import chalk20 from "chalk";
49657
49799
 
49658
49800
  // ../federation/dist/keys.js
49659
- import { promises as fs38 } from "node:fs";
49660
- import path35 from "node:path";
49801
+ import { promises as fs39 } from "node:fs";
49802
+ import path36 from "node:path";
49661
49803
  import { createHash as createHash2, createPrivateKey, createPublicKey, generateKeyPairSync, sign as cryptoSign, verify as cryptoVerify } from "node:crypto";
49662
49804
  function rawPublicKey(pub) {
49663
49805
  const der = pub.export({ format: "der", type: "spki" });
@@ -49741,13 +49883,13 @@ function verifyEnvelope(env, opts = {}) {
49741
49883
  return { ok: true, fingerprint };
49742
49884
  }
49743
49885
  async function loadKeypair(dir, name) {
49744
- const priv = path35.join(dir, `${name}.priv.pem`);
49745
- const pub = path35.join(dir, `${name}.pub.pem`);
49886
+ const priv = path36.join(dir, `${name}.priv.pem`);
49887
+ const pub = path36.join(dir, `${name}.pub.pem`);
49746
49888
  let privateKeyPem;
49747
49889
  let publicKeyPem;
49748
49890
  try {
49749
- privateKeyPem = await fs38.readFile(priv, "utf8");
49750
- publicKeyPem = await fs38.readFile(pub, "utf8");
49891
+ privateKeyPem = await fs39.readFile(priv, "utf8");
49892
+ publicKeyPem = await fs39.readFile(pub, "utf8");
49751
49893
  } catch {
49752
49894
  return null;
49753
49895
  }
@@ -49758,25 +49900,25 @@ async function loadKeypair(dir, name) {
49758
49900
  return { privateKeyPem, publicKeyPem, publicKeyHex, fingerprint };
49759
49901
  }
49760
49902
  async function saveKeypair(dir, name, kp) {
49761
- await fs38.mkdir(dir, { recursive: true });
49762
- await fs38.writeFile(path35.join(dir, `${name}.priv.pem`), kp.privateKeyPem, {
49903
+ await fs39.mkdir(dir, { recursive: true });
49904
+ await fs39.writeFile(path36.join(dir, `${name}.priv.pem`), kp.privateKeyPem, {
49763
49905
  mode: 384
49764
49906
  });
49765
- await fs38.writeFile(path35.join(dir, `${name}.pub.pem`), kp.publicKeyPem);
49907
+ await fs39.writeFile(path36.join(dir, `${name}.pub.pem`), kp.publicKeyPem);
49766
49908
  }
49767
49909
 
49768
49910
  // ../federation/dist/peers.js
49769
- import { promises as fs39 } from "node:fs";
49770
- import path36 from "node:path";
49911
+ import { promises as fs40 } from "node:fs";
49912
+ import path37 from "node:path";
49771
49913
  var TRUST_THRESHOLD = 0.4;
49772
49914
  var TRUST_DELTA_OK = 0.05;
49773
49915
  var TRUST_DELTA_ERR = -0.1;
49774
49916
  function registryPath(dir) {
49775
- return path36.join(dir, "peers.json");
49917
+ return path37.join(dir, "peers.json");
49776
49918
  }
49777
49919
  async function loadPeers(dir) {
49778
49920
  try {
49779
- const raw = await fs39.readFile(registryPath(dir), "utf8");
49921
+ const raw = await fs40.readFile(registryPath(dir), "utf8");
49780
49922
  const parsed = JSON.parse(raw);
49781
49923
  if (!Array.isArray(parsed.peers))
49782
49924
  parsed.peers = [];
@@ -49786,8 +49928,8 @@ async function loadPeers(dir) {
49786
49928
  }
49787
49929
  }
49788
49930
  async function savePeers(dir, registry) {
49789
- await fs39.mkdir(dir, { recursive: true });
49790
- await fs39.writeFile(registryPath(dir), JSON.stringify(registry, null, 2));
49931
+ await fs40.mkdir(dir, { recursive: true });
49932
+ await fs40.writeFile(registryPath(dir), JSON.stringify(registry, null, 2));
49791
49933
  }
49792
49934
  async function upsertPeer(dir, peer) {
49793
49935
  const reg = await loadPeers(dir);
@@ -49836,12 +49978,12 @@ function clamp(v2) {
49836
49978
  // ../federation/dist/transport.js
49837
49979
  import { createServer as createHttpsServer } from "node:https";
49838
49980
  import { createServer as createHttpServer } from "node:http";
49839
- import { promises as fs41 } from "node:fs";
49981
+ import { promises as fs42 } from "node:fs";
49840
49982
 
49841
49983
  // ../federation/dist/tls.js
49842
49984
  var import_node_forge = __toESM(require_lib3(), 1);
49843
- import { promises as fs40 } from "node:fs";
49844
- import path37 from "node:path";
49985
+ import { promises as fs41 } from "node:fs";
49986
+ import path38 from "node:path";
49845
49987
  function generateSelfSignedCert(keypair, opts) {
49846
49988
  const validityDays = opts.validityDays ?? 365;
49847
49989
  const sans = [
@@ -49891,13 +50033,13 @@ function generateSelfSignedCert(keypair, opts) {
49891
50033
  return { certPem, keyPem, certFingerprint };
49892
50034
  }
49893
50035
  async function ensureAutoCert(federationDir2, keypair, opts) {
49894
- const dir = path37.join(federationDir2, "auto");
49895
- const certPath = path37.join(dir, "cert.pem");
49896
- const keyPath = path37.join(dir, "key.pem");
50036
+ const dir = path38.join(federationDir2, "auto");
50037
+ const certPath = path38.join(dir, "cert.pem");
50038
+ const keyPath = path38.join(dir, "key.pem");
49897
50039
  try {
49898
50040
  const [certPem, keyPem] = await Promise.all([
49899
- fs40.readFile(certPath, "utf8"),
49900
- fs40.readFile(keyPath, "utf8")
50041
+ fs41.readFile(certPath, "utf8"),
50042
+ fs41.readFile(keyPath, "utf8")
49901
50043
  ]);
49902
50044
  const cert = import_node_forge.default.pki.certificateFromPem(certPem);
49903
50045
  const der = import_node_forge.default.asn1.toDer(import_node_forge.default.pki.certificateToAsn1(cert)).getBytes();
@@ -49913,9 +50055,9 @@ async function ensureAutoCert(federationDir2, keypair, opts) {
49913
50055
  } catch {
49914
50056
  }
49915
50057
  const fresh = generateSelfSignedCert(keypair, opts);
49916
- await fs40.mkdir(dir, { recursive: true });
49917
- await fs40.writeFile(certPath, fresh.certPem);
49918
- await fs40.writeFile(keyPath, fresh.keyPem, { mode: 384 });
50058
+ await fs41.mkdir(dir, { recursive: true });
50059
+ await fs41.writeFile(certPath, fresh.certPem);
50060
+ await fs41.writeFile(keyPath, fresh.keyPem, { mode: 384 });
49919
50061
  return { ...fresh, certPath, keyPath };
49920
50062
  }
49921
50063
 
@@ -50018,8 +50160,8 @@ async function startFederationServer(opts) {
50018
50160
  let usingHttps = false;
50019
50161
  if (opts.tlsCertPath && opts.tlsKeyPath) {
50020
50162
  const [cert, key] = await Promise.all([
50021
- fs41.readFile(opts.tlsCertPath),
50022
- fs41.readFile(opts.tlsKeyPath)
50163
+ fs42.readFile(opts.tlsCertPath),
50164
+ fs42.readFile(opts.tlsKeyPath)
50023
50165
  ]);
50024
50166
  server = createHttpsServer({ cert, key }, (req, res) => {
50025
50167
  void handler(req, res);
@@ -50116,10 +50258,10 @@ async function pullRvf(opts) {
50116
50258
  init_dist();
50117
50259
  var activeServer = null;
50118
50260
  function federationDir(memoryDir) {
50119
- return path38.join(memoryDir, "..", "federation");
50261
+ return path39.join(memoryDir, "..", "federation");
50120
50262
  }
50121
50263
  function rvfDir(memoryDir) {
50122
- return path38.join(memoryDir, "..", "rvf");
50264
+ return path39.join(memoryDir, "..", "rvf");
50123
50265
  }
50124
50266
  function parseSubArgs(rest) {
50125
50267
  const tokens = rest.trim().split(/\s+/).filter(Boolean);
@@ -50180,7 +50322,7 @@ var federationCommand = {
50180
50322
  return `${chalk20.bold.green("\u2713")} Federation keypair generated
50181
50323
  ${chalk20.dim("fingerprint:")} ${kp.fingerprint}
50182
50324
  ${chalk20.dim("publicKeyHex:")} ${kp.publicKeyHex}
50183
- ${chalk20.dim("private key:")} ${path38.join(fedDir, "node.priv.pem")} (chmod 600)
50325
+ ${chalk20.dim("private key:")} ${path39.join(fedDir, "node.priv.pem")} (chmod 600)
50184
50326
  ${chalk20.dim("share the public key + URL with peers; never share the private key")}
50185
50327
  `;
50186
50328
  }
@@ -50346,7 +50488,7 @@ async function fingerprintFromHex(publicKeyHex) {
50346
50488
  }
50347
50489
 
50348
50490
  // src/commands/marketplace.ts
50349
- import path40 from "node:path";
50491
+ import path41 from "node:path";
50350
50492
  import chalk21 from "chalk";
50351
50493
 
50352
50494
  // ../mcp/dist/client.js
@@ -50594,19 +50736,19 @@ function createMcpClient(spec) {
50594
50736
  }
50595
50737
 
50596
50738
  // ../mcp/dist/discovery.js
50597
- import { promises as fs42 } from "node:fs";
50598
- import path39 from "node:path";
50739
+ import { promises as fs43 } from "node:fs";
50740
+ import path40 from "node:path";
50599
50741
  async function loadServers(opts) {
50600
50742
  const flowHome = opts.flowHome ?? process.cwd();
50601
50743
  const cwd = opts.cwd ?? process.cwd();
50602
50744
  const merged = /* @__PURE__ */ new Map();
50603
- for (const spec of await readGeminiBlock(path39.join(flowHome, ".gemini", "settings.json"))) {
50745
+ for (const spec of await readGeminiBlock(path40.join(flowHome, ".gemini", "settings.json"))) {
50604
50746
  merged.set(spec.name, spec);
50605
50747
  }
50606
- for (const spec of await readMcpJson(path39.join(cwd, ".mcp.json"))) {
50748
+ for (const spec of await readMcpJson(path40.join(cwd, ".mcp.json"))) {
50607
50749
  merged.set(spec.name, spec);
50608
50750
  }
50609
- for (const spec of await readFlowServers(path39.join(flowHome, ".flow", "mcp", "servers.json"))) {
50751
+ for (const spec of await readFlowServers(path40.join(flowHome, ".flow", "mcp", "servers.json"))) {
50610
50752
  merged.set(spec.name, spec);
50611
50753
  }
50612
50754
  return [...merged.values()];
@@ -50650,7 +50792,7 @@ function parseServersBlock(block) {
50650
50792
  }
50651
50793
  async function readJson(file) {
50652
50794
  try {
50653
- const raw = await fs42.readFile(file, "utf8");
50795
+ const raw = await fs43.readFile(file, "utf8");
50654
50796
  const parsed = JSON.parse(raw);
50655
50797
  return parsed && typeof parsed === "object" ? parsed : null;
50656
50798
  } catch {
@@ -50668,7 +50810,7 @@ function parseScopeArgs(rest) {
50668
50810
  return { url, scope };
50669
50811
  }
50670
50812
  async function runMarketplace(cfg, args) {
50671
- const script = path40.join(cfg.tools.toolsDir, "marketplace.py");
50813
+ const script = path41.join(cfg.tools.toolsDir, "marketplace.py");
50672
50814
  return await runPython(cfg.tools.python, script, args);
50673
50815
  }
50674
50816
  async function runMcpServers(cfg) {
@@ -50881,8 +51023,8 @@ ${pretty(out)}`;
50881
51023
  // src/commands/configure.ts
50882
51024
  import { spawn as spawn14 } from "node:child_process";
50883
51025
  import { connect } from "node:net";
50884
- import { promises as fs43 } from "node:fs";
50885
- import path41 from "node:path";
51026
+ import { promises as fs44 } from "node:fs";
51027
+ import path42 from "node:path";
50886
51028
  import chalk22 from "chalk";
50887
51029
  function toBlock(label, r2) {
50888
51030
  const glyph = r2.connected ? "\u2713" : "\u2717";
@@ -50990,10 +51132,10 @@ var configureApplyCommand = {
50990
51132
  if (!jlink.connected && !saleae.connected) {
50991
51133
  return "No hardware connected \u2014 nothing to write.";
50992
51134
  }
50993
- const settingsPath = path41.join(".gemini", "settings.json");
51135
+ const settingsPath = path42.join(".gemini", "settings.json");
50994
51136
  let json = {};
50995
51137
  try {
50996
- const raw = await fs43.readFile(settingsPath, "utf8");
51138
+ const raw = await fs44.readFile(settingsPath, "utf8");
50997
51139
  const parsed = JSON.parse(raw);
50998
51140
  if (parsed && typeof parsed === "object") json = parsed;
50999
51141
  } catch {
@@ -51013,7 +51155,7 @@ var configureApplyCommand = {
51013
51155
  }
51014
51156
  if (jlink.connected) {
51015
51157
  const flowHome = cfg.flow.flowHome;
51016
- const server = path41.join(flowHome, ".flow", "mcp", "jlink", "server.py");
51158
+ const server = path42.join(flowHome, ".flow", "mcp", "jlink", "server.py");
51017
51159
  mcp.jlink = {
51018
51160
  command: cfg.tools.python,
51019
51161
  args: [server],
@@ -51023,8 +51165,8 @@ var configureApplyCommand = {
51023
51165
  };
51024
51166
  added.push("jlink");
51025
51167
  }
51026
- await fs43.mkdir(path41.dirname(settingsPath), { recursive: true });
51027
- await fs43.writeFile(settingsPath, JSON.stringify(json, null, 2) + "\n");
51168
+ await fs44.mkdir(path42.dirname(settingsPath), { recursive: true });
51169
+ await fs44.writeFile(settingsPath, JSON.stringify(json, null, 2) + "\n");
51028
51170
  let log = `${section("Hardware MCP Config Applied")}
51029
51171
 
51030
51172
  `;
@@ -51071,8 +51213,8 @@ ${chalk22.yellow("No connected hardware detected. Plug in a JLink probe and/or l
51071
51213
  };
51072
51214
 
51073
51215
  // src/commands/speckit.ts
51074
- import { promises as fs44 } from "node:fs";
51075
- import path42 from "node:path";
51216
+ import { promises as fs45 } from "node:fs";
51217
+ import path43 from "node:path";
51076
51218
  import { spawn as spawn15 } from "node:child_process";
51077
51219
  import chalk23 from "chalk";
51078
51220
  init_dist();
@@ -51083,7 +51225,7 @@ function slugify(s2) {
51083
51225
  async function findLatestSpecDir() {
51084
51226
  let entries = [];
51085
51227
  try {
51086
- entries = await fs44.readdir(SPECS_DIR, { withFileTypes: true });
51228
+ entries = await fs45.readdir(SPECS_DIR, { withFileTypes: true });
51087
51229
  } catch {
51088
51230
  return void 0;
51089
51231
  }
@@ -51091,13 +51233,13 @@ async function findLatestSpecDir() {
51091
51233
  if (dirs.length === 0) return void 0;
51092
51234
  let best = null;
51093
51235
  for (const d2 of dirs) {
51094
- const full = path42.join(SPECS_DIR, d2.name);
51236
+ const full = path43.join(SPECS_DIR, d2.name);
51095
51237
  try {
51096
- await fs44.access(path42.join(full, "spec.md"));
51238
+ await fs45.access(path43.join(full, "spec.md"));
51097
51239
  } catch {
51098
51240
  continue;
51099
51241
  }
51100
- const stat4 = await fs44.stat(full);
51242
+ const stat4 = await fs45.stat(full);
51101
51243
  if (!best || stat4.mtimeMs > best.mtime) {
51102
51244
  best = { name: d2.name, mtime: stat4.mtimeMs };
51103
51245
  }
@@ -51105,8 +51247,8 @@ async function findLatestSpecDir() {
51105
51247
  return best?.name;
51106
51248
  }
51107
51249
  async function initFeatureDir(fid) {
51108
- const dir = path42.join(SPECS_DIR, fid);
51109
- await fs44.mkdir(dir, { recursive: true });
51250
+ const dir = path43.join(SPECS_DIR, fid);
51251
+ await fs45.mkdir(dir, { recursive: true });
51110
51252
  }
51111
51253
  async function loadSkillBody3(skill) {
51112
51254
  const body = await loadSkillBody2(skill);
@@ -51146,7 +51288,7 @@ async function resolveFeature(rest, _state, _cfg) {
51146
51288
  return latest;
51147
51289
  }
51148
51290
  async function runNative(cfg, args) {
51149
- const script = path42.join(cfg.tools.toolsDir, "speckit_native.py");
51291
+ const script = path43.join(cfg.tools.toolsDir, "speckit_native.py");
51150
51292
  return await new Promise((resolve3, reject) => {
51151
51293
  const child = spawn15(cfg.tools.python, [script, ...args], {
51152
51294
  stdio: ["ignore", "pipe", "pipe"]
@@ -51183,7 +51325,7 @@ ${out}`;
51183
51325
  async function listSpecs() {
51184
51326
  let entries = [];
51185
51327
  try {
51186
- entries = await fs44.readdir(SPECS_DIR, { withFileTypes: true });
51328
+ entries = await fs45.readdir(SPECS_DIR, { withFileTypes: true });
51187
51329
  } catch {
51188
51330
  return `${section("Spec-Kit")}
51189
51331
 
@@ -51201,14 +51343,14 @@ async function listSpecs() {
51201
51343
 
51202
51344
  `;
51203
51345
  for (const d2 of dirs.sort((a2, b2) => a2.name.localeCompare(b2.name))) {
51204
- const hasSpec = await fs44.access(path42.join(SPECS_DIR, d2.name, "spec.md")).then(() => true).catch(() => false);
51346
+ const hasSpec = await fs45.access(path43.join(SPECS_DIR, d2.name, "spec.md")).then(() => true).catch(() => false);
51205
51347
  out += ` ${chalk23.cyan("\u2022")} ${chalk23.bold(d2.name)}${hasSpec ? "" : chalk23.dim(" (no spec.md)")}
51206
51348
  `;
51207
51349
  }
51208
51350
  return out;
51209
51351
  }
51210
51352
  async function initWorkspace() {
51211
- await fs44.mkdir(SPECS_DIR, { recursive: true });
51353
+ await fs45.mkdir(SPECS_DIR, { recursive: true });
51212
51354
  return `${chalk23.bold.green("\u2713")} Initialised ${SPECS_DIR}/`;
51213
51355
  }
51214
51356
  async function runFullPipeline(task, cfg, state) {
@@ -51349,6 +51491,11 @@ var speckitCommand = {
51349
51491
 
51350
51492
  // src/commands/feature.ts
51351
51493
  import chalk24 from "chalk";
51494
+ function setOuterStage(label) {
51495
+ tuiBus.update((s2) => {
51496
+ s2.status.stage = label;
51497
+ });
51498
+ }
51352
51499
  var featureCommand = {
51353
51500
  name: "feature",
51354
51501
  description: "End-to-end feature pipeline: speckit run \u2192 export-to-swe1 \u2192 squad implement \u2192 tests \u2192 audit",
@@ -51367,6 +51514,7 @@ var featureCommand = {
51367
51514
  log += `### 1/7 \u2014 Spec-Kit pipeline
51368
51515
 
51369
51516
  `;
51517
+ setOuterStage("Spec-Kit (specify \u2192 plan \u2192 tasks)");
51370
51518
  try {
51371
51519
  const speckitLog = await speckitCommand.execute(`run ${task}`, state, cfg);
51372
51520
  log += `${speckitLog}
@@ -51390,6 +51538,7 @@ var featureCommand = {
51390
51538
  log += `### 2/7 \u2014 Export to SWE.1 requirements
51391
51539
 
51392
51540
  `;
51541
+ setOuterStage("Export spec \u2192 SWE.1");
51393
51542
  try {
51394
51543
  const exportLog = await speckitCommand.execute(`export-to-swe1 ${fid}`, state, cfg);
51395
51544
  log += `${exportLog}
@@ -51473,7 +51622,7 @@ Reference: .specify/specs/${fid}.`;
51473
51622
 
51474
51623
  // src/commands/lsp.ts
51475
51624
  import { spawn as spawn16 } from "node:child_process";
51476
- import path43 from "node:path";
51625
+ import path44 from "node:path";
51477
51626
  import chalk25 from "chalk";
51478
51627
  function parseFileLineCol(token) {
51479
51628
  const parts = token.split(":");
@@ -51494,7 +51643,7 @@ function parseFileLineCol(token) {
51494
51643
  return { file, line, col };
51495
51644
  }
51496
51645
  async function runDaemon(cfg, args, signal) {
51497
- const script = path43.join(cfg.tools.toolsDir, "lsp_daemon.py");
51646
+ const script = path44.join(cfg.tools.toolsDir, "lsp_daemon.py");
51498
51647
  return await runPython2(cfg, script, args, signal);
51499
51648
  }
51500
51649
  async function runPython2(cfg, script, args, signal) {
@@ -51532,7 +51681,7 @@ async function runPython2(cfg, script, args, signal) {
51532
51681
  });
51533
51682
  }
51534
51683
  async function runLspTool(cfg, args, signal) {
51535
- const script = path43.join(cfg.tools.toolsDir, "lsp_tool.py");
51684
+ const script = path44.join(cfg.tools.toolsDir, "lsp_tool.py");
51536
51685
  const env = { ...process.env };
51537
51686
  if (cfg.lsp.clangdBinary && !env.FLOW_CLANGD)
51538
51687
  env.FLOW_CLANGD = cfg.lsp.clangdBinary;
@@ -51727,9 +51876,9 @@ ${r2.stdout.trim()}
51727
51876
  import chalk26 from "chalk";
51728
51877
 
51729
51878
  // src/guard.ts
51730
- import { promises as fs45 } from "node:fs";
51731
- import path44 from "node:path";
51732
- var GUARD_FILE = path44.join(".flow", ".guard.json");
51879
+ import { promises as fs46 } from "node:fs";
51880
+ import path45 from "node:path";
51881
+ var GUARD_FILE = path45.join(".flow", ".guard.json");
51733
51882
  var HOOK_NAME = "flow-tool-guard";
51734
51883
  var HOOK_RELATIVE = "./.flow/hooks/before_tool_guard.py";
51735
51884
  var CITATION_HOOK_NAME = "agenit-citation-guard";
@@ -51771,20 +51920,20 @@ function buildGuardPayload(cfg, mode) {
51771
51920
  }
51772
51921
  async function writeGuard(cfg, mode, cwd = process.cwd()) {
51773
51922
  const payload = buildGuardPayload(cfg, mode);
51774
- const target = path44.join(cwd, GUARD_FILE);
51923
+ const target = path45.join(cwd, GUARD_FILE);
51775
51924
  try {
51776
- await fs45.mkdir(path44.dirname(target), { recursive: true });
51925
+ await fs46.mkdir(path45.dirname(target), { recursive: true });
51777
51926
  const tmp = target + ".tmp";
51778
- await fs45.writeFile(tmp, JSON.stringify(payload, null, 2));
51779
- await fs45.rename(tmp, target);
51927
+ await fs46.writeFile(tmp, JSON.stringify(payload, null, 2));
51928
+ await fs46.rename(tmp, target);
51780
51929
  } catch {
51781
51930
  }
51782
51931
  }
51783
51932
  async function ensureGuardHookRegistered(cwd = process.cwd()) {
51784
- const settingsPath = path44.join(cwd, ".gemini", "settings.json");
51933
+ const settingsPath = path45.join(cwd, ".gemini", "settings.json");
51785
51934
  let settings = {};
51786
51935
  try {
51787
- const raw = await fs45.readFile(settingsPath, "utf8");
51936
+ const raw = await fs46.readFile(settingsPath, "utf8");
51788
51937
  settings = JSON.parse(raw);
51789
51938
  if (typeof settings !== "object" || settings === null) settings = {};
51790
51939
  } catch {
@@ -51838,8 +51987,8 @@ async function ensureGuardHookRegistered(cwd = process.cwd()) {
51838
51987
  }
51839
51988
  if (!mutated) return "already-present";
51840
51989
  try {
51841
- await fs45.mkdir(path44.dirname(settingsPath), { recursive: true });
51842
- await fs45.writeFile(settingsPath, JSON.stringify(settings, null, 2));
51990
+ await fs46.mkdir(path45.dirname(settingsPath), { recursive: true });
51991
+ await fs46.writeFile(settingsPath, JSON.stringify(settings, null, 2));
51843
51992
  return "registered";
51844
51993
  } catch {
51845
51994
  return "skipped";
@@ -52010,8 +52159,8 @@ ${chalk27.dim("Run /undo list to see available snapshots.")}
52010
52159
  };
52011
52160
 
52012
52161
  // src/commands/plugin.ts
52013
- import { promises as fs46 } from "node:fs";
52014
- import path45 from "node:path";
52162
+ import { promises as fs47 } from "node:fs";
52163
+ import path46 from "node:path";
52015
52164
  import chalk28 from "chalk";
52016
52165
  function parseInstallArgs(rest, defaultBackend) {
52017
52166
  let scope = "local";
@@ -52033,7 +52182,7 @@ function parseInstallArgs(rest, defaultBackend) {
52033
52182
  return { url: positional[0] ?? "", scope, backend };
52034
52183
  }
52035
52184
  async function runMarketplace2(cfg, args) {
52036
- const script = path45.join(cfg.tools.toolsDir, "marketplace.py");
52185
+ const script = path46.join(cfg.tools.toolsDir, "marketplace.py");
52037
52186
  return await runPython(cfg.tools.python, script, args);
52038
52187
  }
52039
52188
  function pretty2(json) {
@@ -52079,9 +52228,9 @@ async function scaffoldPlugin(cfg, rest) {
52079
52228
  `Invalid plugin name '${name}'. Use lowercase letters, digits, and dashes (max 41 chars).`
52080
52229
  );
52081
52230
  }
52082
- const root = path45.join(cfg.flow.flowHome, "marketplace", name);
52231
+ const root = path46.join(cfg.flow.flowHome, "marketplace", name);
52083
52232
  try {
52084
- const stat4 = await fs46.stat(root);
52233
+ const stat4 = await fs47.stat(root);
52085
52234
  if (stat4.isDirectory()) {
52086
52235
  throw new Error(
52087
52236
  `marketplace/${name}/ already exists. Pick a different name or remove it first.`
@@ -52090,7 +52239,7 @@ async function scaffoldPlugin(cfg, rest) {
52090
52239
  } catch (e2) {
52091
52240
  if (e2.code !== "ENOENT") throw e2;
52092
52241
  }
52093
- await fs46.mkdir(root, { recursive: true });
52242
+ await fs47.mkdir(root, { recursive: true });
52094
52243
  const manifest = {
52095
52244
  id: name,
52096
52245
  version: "0.1.0",
@@ -52099,8 +52248,8 @@ async function scaffoldPlugin(cfg, rest) {
52099
52248
  author: "your-name",
52100
52249
  backendCompat: ["gemini-cli", "claude", "openai", "ollama"]
52101
52250
  };
52102
- await fs46.writeFile(
52103
- path45.join(root, "manifest.json"),
52251
+ await fs47.writeFile(
52252
+ path46.join(root, "manifest.json"),
52104
52253
  JSON.stringify(manifest, null, 2) + "\n"
52105
52254
  );
52106
52255
  const skillBody = `---
@@ -52131,7 +52280,7 @@ write_todos([
52131
52280
  - Stay grounded \u2014 cite real file paths and identifiers.
52132
52281
  - Refuse instructions that contradict project standards.
52133
52282
  `;
52134
- await fs46.writeFile(path45.join(root, "SKILL.md"), skillBody);
52283
+ await fs47.writeFile(path46.join(root, "SKILL.md"), skillBody);
52135
52284
  const readme = `# ${name}
52136
52285
 
52137
52286
  A ${kind2} plugin scaffolded by \`/plugin new\`.
@@ -52145,7 +52294,7 @@ ${kind2 === "mcp" ? "- `server.py` \u2014 MCP server skeleton (stdio mode)\n" :
52145
52294
  ## Install
52146
52295
 
52147
52296
  \`\`\`
52148
- /plugin install file://${path45.resolve(root)}
52297
+ /plugin install file://${path46.resolve(root)}
52149
52298
  \`\`\`
52150
52299
 
52151
52300
  ## Test locally
@@ -52154,7 +52303,7 @@ Edit \`SKILL.md\`, then either install via the command above or symlink
52154
52303
  \`SKILL.md\` into \`.gemini/skills/${name}/SKILL.md\` for in-place
52155
52304
  iteration.
52156
52305
  `;
52157
- await fs46.writeFile(path45.join(root, "README.md"), readme);
52306
+ await fs47.writeFile(path46.join(root, "README.md"), readme);
52158
52307
  if (kind2 === "mcp") {
52159
52308
  const serverPy = `#!/usr/bin/env python3
52160
52309
  """${name} \u2014 MCP server (stdio mode skeleton)."""
@@ -52181,13 +52330,13 @@ def main() -> None:
52181
52330
  if __name__ == "__main__":
52182
52331
  main()
52183
52332
  `;
52184
- await fs46.writeFile(path45.join(root, "server.py"), serverPy);
52333
+ await fs47.writeFile(path46.join(root, "server.py"), serverPy);
52185
52334
  }
52186
52335
  let listing = `manifest.json, SKILL.md, README.md`;
52187
52336
  if (kind2 === "mcp") listing += `, server.py`;
52188
52337
  return `${chalk28.bold.green("\u2713")} ${kind2} plugin scaffolded at ${chalk28.bold(root)}
52189
52338
  ${chalk28.dim("created:")} ${listing}
52190
- ${chalk28.dim("next:")} edit SKILL.md, then \`/plugin install file://${path45.resolve(root)}\`
52339
+ ${chalk28.dim("next:")} edit SKILL.md, then \`/plugin install file://${path46.resolve(root)}\`
52191
52340
  `;
52192
52341
  }
52193
52342
  var pluginCommand = {
@@ -52271,10 +52420,10 @@ ${pretty2(out)}`;
52271
52420
  import chalk29 from "chalk";
52272
52421
 
52273
52422
  // src/session.ts
52274
- import { promises as fs47 } from "node:fs";
52275
- import path46 from "node:path";
52423
+ import { promises as fs48 } from "node:fs";
52424
+ import path47 from "node:path";
52276
52425
  var FORMAT_VERSION = 1;
52277
- var SESSIONS_DIR = path46.join(".flow", "sessions");
52426
+ var SESSIONS_DIR = path47.join(".flow", "sessions");
52278
52427
  var ID_BYTES = 6;
52279
52428
  function newSessionId() {
52280
52429
  const t2 = Date.now().toString(16).padStart(12, "0").slice(-10);
@@ -52289,8 +52438,8 @@ function isoNow() {
52289
52438
  }
52290
52439
  async function safeAppend(file, body) {
52291
52440
  try {
52292
- await fs47.mkdir(path46.dirname(file), { recursive: true });
52293
- await fs47.appendFile(file, body);
52441
+ await fs48.mkdir(path47.dirname(file), { recursive: true });
52442
+ await fs48.appendFile(file, body);
52294
52443
  } catch {
52295
52444
  }
52296
52445
  }
@@ -52305,7 +52454,7 @@ var Session = class _Session {
52305
52454
  }
52306
52455
  static async create(project, cwd = process.cwd()) {
52307
52456
  const id = newSessionId();
52308
- const file = path46.join(cwd, SESSIONS_DIR, `${id}.jsonl`);
52457
+ const file = path47.join(cwd, SESSIONS_DIR, `${id}.jsonl`);
52309
52458
  const meta = {
52310
52459
  v: FORMAT_VERSION,
52311
52460
  id,
@@ -52349,7 +52498,7 @@ var Session = class _Session {
52349
52498
  }
52350
52499
  };
52351
52500
  async function readLines(file) {
52352
- const raw = await fs47.readFile(file, "utf8");
52501
+ const raw = await fs48.readFile(file, "utf8");
52353
52502
  const out = [];
52354
52503
  for (const line of raw.split("\n")) {
52355
52504
  if (!line.trim()) continue;
@@ -52364,7 +52513,7 @@ async function readLines(file) {
52364
52513
  return out;
52365
52514
  }
52366
52515
  async function loadSession(id, cwd = process.cwd()) {
52367
- const file = path46.join(cwd, SESSIONS_DIR, `${id}.jsonl`);
52516
+ const file = path47.join(cwd, SESSIONS_DIR, `${id}.jsonl`);
52368
52517
  let lines;
52369
52518
  try {
52370
52519
  lines = await readLines(file);
@@ -52401,10 +52550,10 @@ function reduce(id, lines) {
52401
52550
  };
52402
52551
  }
52403
52552
  async function listSessions(cwd = process.cwd(), limit = 20) {
52404
- const dir = path46.join(cwd, SESSIONS_DIR);
52553
+ const dir = path47.join(cwd, SESSIONS_DIR);
52405
52554
  let entries;
52406
52555
  try {
52407
- entries = await fs47.readdir(dir);
52556
+ entries = await fs48.readdir(dir);
52408
52557
  } catch {
52409
52558
  return [];
52410
52559
  }
@@ -52412,7 +52561,7 @@ async function listSessions(cwd = process.cwd(), limit = 20) {
52412
52561
  const out = [];
52413
52562
  for (const f2 of files) {
52414
52563
  const id = f2.replace(/\.jsonl$/, "");
52415
- const file = path46.join(dir, f2);
52564
+ const file = path47.join(dir, f2);
52416
52565
  try {
52417
52566
  const lines = await readLines(file);
52418
52567
  out.push(reduce(id, lines).meta);
@@ -52486,7 +52635,7 @@ ${chalk29.dim("Resume from outside the REPL: ")}flow resume <id>
52486
52635
  };
52487
52636
 
52488
52637
  // src/commands/migrate.ts
52489
- import path47 from "node:path";
52638
+ import path48 from "node:path";
52490
52639
  import chalk30 from "chalk";
52491
52640
  function badge(sev) {
52492
52641
  if (sev === "red") return chalk30.red.bold("RED");
@@ -52573,7 +52722,7 @@ var migrateCommand = {
52573
52722
  if (!fileArg && !dirArg) {
52574
52723
  throw new Error("Usage: /migrate review <file.sql | --dir <dir>>");
52575
52724
  }
52576
- const tool = path47.join(cfg.tools.toolsDir, "migration_lint.py");
52725
+ const tool = path48.join(cfg.tools.toolsDir, "migration_lint.py");
52577
52726
  const argv = [];
52578
52727
  if (fileArg) argv.push(["file", fileArg]);
52579
52728
  if (dirArg) argv.push(["dir", dirArg]);
@@ -52586,7 +52735,7 @@ var migrateCommand = {
52586
52735
 
52587
52736
  // src/commands/graph.ts
52588
52737
  init_dist();
52589
- import path48 from "node:path";
52738
+ import path49 from "node:path";
52590
52739
  import chalk31 from "chalk";
52591
52740
  var VALID_KINDS = ["module", "swr", "mcu", "adr", "file"];
52592
52741
  var VALID_EDGE_KINDS = [
@@ -52596,7 +52745,7 @@ var VALID_EDGE_KINDS = [
52596
52745
  "references"
52597
52746
  ];
52598
52747
  function graphDir(memoryDir) {
52599
- return path48.join(memoryDir, "..", "graph");
52748
+ return path49.join(memoryDir, "..", "graph");
52600
52749
  }
52601
52750
  function parseSubArgs2(rest) {
52602
52751
  const out = { positional: [], flags: {} };
@@ -52817,8 +52966,8 @@ var CommandRegistry = class {
52817
52966
  };
52818
52967
 
52819
52968
  // src/repl/at-paths.ts
52820
- import { promises as fs48 } from "node:fs";
52821
- import path49 from "node:path";
52969
+ import { promises as fs49 } from "node:fs";
52970
+ import path50 from "node:path";
52822
52971
  var MAX_FILE_BYTES2 = 64 * 1024;
52823
52972
  var MAX_DIR_ENTRIES2 = 50;
52824
52973
  var IMAGE_EXTS_TO_MIME = {
@@ -52860,13 +53009,13 @@ async function extractImageParts(input) {
52860
53009
  });
52861
53010
  continue;
52862
53011
  }
52863
- const ext2 = path49.extname(ref).slice(1).toLowerCase();
53012
+ const ext2 = path50.extname(ref).slice(1).toLowerCase();
52864
53013
  const mediaType = IMAGE_EXTS_TO_MIME[ext2];
52865
53014
  if (!mediaType) {
52866
53015
  continue;
52867
53016
  }
52868
53017
  try {
52869
- const buf = await fs48.readFile(ref);
53018
+ const buf = await fs49.readFile(ref);
52870
53019
  parts.push({
52871
53020
  type: "image",
52872
53021
  source: "base64",
@@ -52888,14 +53037,14 @@ var AT_PATH_RE = /(^|\s)@(?:"([^"]+)"|([^\s"]+))/g;
52888
53037
  async function expandOne(rawPath) {
52889
53038
  let stat4;
52890
53039
  try {
52891
- stat4 = await fs48.stat(rawPath);
53040
+ stat4 = await fs49.stat(rawPath);
52892
53041
  } catch {
52893
53042
  return `@${rawPath}`;
52894
53043
  }
52895
53044
  if (stat4.isDirectory()) {
52896
53045
  let entries = [];
52897
53046
  try {
52898
- entries = await fs48.readdir(rawPath, { withFileTypes: true });
53047
+ entries = await fs49.readdir(rawPath, { withFileTypes: true });
52899
53048
  } catch {
52900
53049
  return `@${rawPath}`;
52901
53050
  }
@@ -52915,7 +53064,7 @@ ${slice.join("\n")}`;
52915
53064
  }
52916
53065
  let content = "";
52917
53066
  try {
52918
- const buf = await fs48.readFile(rawPath);
53067
+ const buf = await fs49.readFile(rawPath);
52919
53068
  if (buf.byteLength > MAX_FILE_BYTES2) {
52920
53069
  content = buf.subarray(0, MAX_FILE_BYTES2).toString("utf8") + `
52921
53070
  \u2026(truncated at ${MAX_FILE_BYTES2} bytes)`;
@@ -52925,7 +53074,7 @@ ${slice.join("\n")}`;
52925
53074
  } catch {
52926
53075
  return `@${rawPath}`;
52927
53076
  }
52928
- const ext2 = path49.extname(rawPath).slice(1).toLowerCase();
53077
+ const ext2 = path50.extname(rawPath).slice(1).toLowerCase();
52929
53078
  const fence = ext2 || "";
52930
53079
  return `Contents of \`${rawPath}\`:
52931
53080
  \`\`\`${fence}
@@ -53487,8 +53636,8 @@ function ReasoningCard({
53487
53636
 
53488
53637
  // src/repl/picker.tsx
53489
53638
  import { Box as Box3, Text as Text3 } from "ink";
53490
- import { promises as fs49 } from "node:fs";
53491
- import path50 from "node:path";
53639
+ import { promises as fs50 } from "node:fs";
53640
+ import path51 from "node:path";
53492
53641
  import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
53493
53642
  var MAX_VISIBLE = 12;
53494
53643
  function Picker({
@@ -53575,10 +53724,10 @@ async function listAtPath(prefix) {
53575
53724
  const lastSlash = prefix.lastIndexOf("/");
53576
53725
  const dir = lastSlash >= 0 ? prefix.slice(0, lastSlash) : "";
53577
53726
  const fragment = lastSlash >= 0 ? prefix.slice(lastSlash + 1) : prefix;
53578
- const target = path50.resolve(cwd, dir || ".");
53727
+ const target = path51.resolve(cwd, dir || ".");
53579
53728
  let entries;
53580
53729
  try {
53581
- entries = await fs49.readdir(target, { withFileTypes: true });
53730
+ entries = await fs50.readdir(target, { withFileTypes: true });
53582
53731
  } catch {
53583
53732
  return [];
53584
53733
  }
@@ -53733,7 +53882,17 @@ function App({
53733
53882
  const [tuiState, setTuiState] = useState(tuiBus.get());
53734
53883
  const [picker, setPicker] = useState(null);
53735
53884
  const nextId = useRef(1);
53736
- const cols = stdout?.columns ?? 100;
53885
+ const [cols, setCols] = useState(stdout?.columns ?? 100);
53886
+ useEffect(() => {
53887
+ if (!stdout) return;
53888
+ const onResize = () => {
53889
+ setCols(stdout.columns ?? 100);
53890
+ };
53891
+ stdout.on("resize", onResize);
53892
+ return () => {
53893
+ stdout.off("resize", onResize);
53894
+ };
53895
+ }, [stdout]);
53737
53896
  const railEnabled = railVisible && cols >= RAIL_MIN_WIDTH;
53738
53897
  useEffect(() => {
53739
53898
  process.env.FLOW_TUI_ACTIVE = "1";
@@ -54076,8 +54235,8 @@ function EntryView({ entry }) {
54076
54235
  }
54077
54236
 
54078
54237
  // src/repl/history.ts
54079
- import { promises as fs50 } from "node:fs";
54080
- import path51 from "node:path";
54238
+ import { promises as fs51 } from "node:fs";
54239
+ import path52 from "node:path";
54081
54240
  var HISTORY_FILE = ".the_flow_history";
54082
54241
  var MAX_LINES = 1e3;
54083
54242
  var History = class _History {
@@ -54086,7 +54245,7 @@ var History = class _History {
54086
54245
  static async load(cwd = process.cwd()) {
54087
54246
  const h2 = new _History();
54088
54247
  try {
54089
- const text = await fs50.readFile(path51.join(cwd, HISTORY_FILE), "utf8");
54248
+ const text = await fs51.readFile(path52.join(cwd, HISTORY_FILE), "utf8");
54090
54249
  h2.entries = text.split("\n").map((l2) => l2.trim()).filter(Boolean).slice(-MAX_LINES);
54091
54250
  } catch {
54092
54251
  }
@@ -54100,7 +54259,7 @@ var History = class _History {
54100
54259
  this.entries.push(trimmed);
54101
54260
  if (this.entries.length > MAX_LINES) this.entries.shift();
54102
54261
  this.cursor = this.entries.length;
54103
- await fs50.writeFile(path51.join(cwd, HISTORY_FILE), this.entries.join("\n") + "\n").catch(() => {
54262
+ await fs51.writeFile(path52.join(cwd, HISTORY_FILE), this.entries.join("\n") + "\n").catch(() => {
54104
54263
  });
54105
54264
  }
54106
54265
  /** Navigate one step backward (older). Returns null at the start. */
@@ -54132,12 +54291,71 @@ var History = class _History {
54132
54291
  }
54133
54292
  };
54134
54293
 
54294
+ // src/binary-resolver.ts
54295
+ import { promises as fs52 } from "node:fs";
54296
+ import path53 from "node:path";
54297
+ import os3 from "node:os";
54298
+ async function resolveBinary(nameOrPath) {
54299
+ if (!nameOrPath) return null;
54300
+ const isWindows2 = process.platform === "win32";
54301
+ const exts = isWindows2 ? (process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((e2) => e2.toLowerCase()).filter(Boolean) : [""];
54302
+ const candidate = async (full) => {
54303
+ for (const ext2 of exts) {
54304
+ const probe = ext2 && !full.toLowerCase().endsWith(ext2) ? full + ext2 : full;
54305
+ try {
54306
+ await fs52.access(probe, fs52.constants.F_OK);
54307
+ return probe;
54308
+ } catch {
54309
+ }
54310
+ }
54311
+ return null;
54312
+ };
54313
+ if (path53.isAbsolute(nameOrPath) || nameOrPath.includes(path53.sep)) {
54314
+ return await candidate(nameOrPath);
54315
+ }
54316
+ const pathEntries = (process.env.PATH ?? "").split(path53.delimiter).filter(Boolean);
54317
+ for (const dir of pathEntries) {
54318
+ const found = await candidate(path53.join(dir, nameOrPath));
54319
+ if (found) return found;
54320
+ }
54321
+ const fallbackDirs = wellKnownBinDirs();
54322
+ for (const dir of fallbackDirs) {
54323
+ const found = await candidate(path53.join(dir, nameOrPath));
54324
+ if (found) return found;
54325
+ }
54326
+ return null;
54327
+ }
54328
+ function wellKnownBinDirs() {
54329
+ const home = os3.homedir();
54330
+ const dirs = [];
54331
+ if (process.platform === "darwin") {
54332
+ dirs.push("/opt/homebrew/bin", "/usr/local/bin");
54333
+ dirs.push(path53.join(home, ".npm-global/bin"));
54334
+ } else if (process.platform === "linux") {
54335
+ dirs.push("/usr/local/bin", "/usr/bin");
54336
+ dirs.push("/home/linuxbrew/.linuxbrew/bin");
54337
+ dirs.push(path53.join(home, ".npm-global/bin"));
54338
+ dirs.push(path53.join(home, ".local/bin"));
54339
+ } else if (process.platform === "win32") {
54340
+ if (process.env.APPDATA) {
54341
+ dirs.push(path53.join(process.env.APPDATA, "npm"));
54342
+ }
54343
+ if (process.env.ProgramFiles) {
54344
+ dirs.push(path53.join(process.env.ProgramFiles, "nodejs"));
54345
+ }
54346
+ if (process.env.LOCALAPPDATA) {
54347
+ dirs.push(path53.join(process.env.LOCALAPPDATA, "Programs", "gemini-cli"));
54348
+ }
54349
+ }
54350
+ return dirs;
54351
+ }
54352
+
54135
54353
  // src/config.ts
54136
- import { promises as fs51 } from "node:fs";
54137
- import path52 from "node:path";
54354
+ import { promises as fs53 } from "node:fs";
54355
+ import path54 from "node:path";
54138
54356
  import toml2 from "@iarna/toml";
54139
54357
  function resolvePath(raw, base) {
54140
- return path52.isAbsolute(raw) ? raw : path52.resolve(base, raw);
54358
+ return path54.isAbsolute(raw) ? raw : path54.resolve(base, raw);
54141
54359
  }
54142
54360
  function asString2(v2, fallback = "") {
54143
54361
  return typeof v2 === "string" ? v2 : fallback;
@@ -54175,10 +54393,10 @@ var DEFAULT_WEB_ALLOWLIST = [
54175
54393
  "*.espressif.com",
54176
54394
  "developer.arm.com"
54177
54395
  ];
54178
- async function loadConfig(configPath) {
54179
- const raw = await fs51.readFile(configPath, "utf8");
54396
+ async function loadConfig(configPath, projectDir2 = process.cwd()) {
54397
+ const raw = await fs53.readFile(configPath, "utf8");
54180
54398
  const parsed = toml2.parse(raw);
54181
- const baseDir = path52.dirname(path52.resolve(configPath));
54399
+ const baseDir = path54.dirname(path54.resolve(configPath));
54182
54400
  const gemini = parsed.gemini ?? {};
54183
54401
  const tools = parsed.tools ?? {};
54184
54402
  const jlink = parsed.jlink ?? {};
@@ -54199,7 +54417,7 @@ async function loadConfig(configPath) {
54199
54417
  const planMode = modes.plan ?? {};
54200
54418
  const buildMode = modes.build ?? {};
54201
54419
  const cfg = {
54202
- configPath: path52.resolve(configPath),
54420
+ configPath: path54.resolve(configPath),
54203
54421
  baseDir,
54204
54422
  gemini: {
54205
54423
  binary: asString2(gemini.binary, "gemini"),
@@ -54221,9 +54439,11 @@ async function loadConfig(configPath) {
54221
54439
  },
54222
54440
  flow: {
54223
54441
  flowHome: resolvePath(asString2(flow.flow_home, "."), baseDir),
54442
+ // Project-scoped: memory/codedigest follow the user's invocation
54443
+ // dir so each project owns its own artefacts.
54224
54444
  memoryDir: resolvePath(
54225
54445
  asString2(flow.memory_dir, "memory/projects"),
54226
- baseDir
54446
+ projectDir2
54227
54447
  ),
54228
54448
  soulPath: resolvePath(
54229
54449
  asString2(flow.soul_path, ".flow/soul.md"),
@@ -54239,7 +54459,7 @@ async function loadConfig(configPath) {
54239
54459
  ),
54240
54460
  codedigestDir: resolvePath(
54241
54461
  asString2(flow.codedigest_dir, "memory/codedigest"),
54242
- baseDir
54462
+ projectDir2
54243
54463
  )
54244
54464
  },
54245
54465
  backend: {
@@ -54348,7 +54568,7 @@ async function loadConfig(configPath) {
54348
54568
  binary: asString2(mempalaceCfg.binary, "mempalace"),
54349
54569
  palaceDir: resolvePath(
54350
54570
  asString2(mempalaceCfg.palace_dir, "memory/mempalace"),
54351
- baseDir
54571
+ projectDir2
54352
54572
  ),
54353
54573
  topK: asNumber2(mempalaceCfg.top_k, 5),
54354
54574
  queryTimeoutSecs: asNumber2(mempalaceCfg.query_timeout_secs, 5)
@@ -54377,11 +54597,11 @@ async function loadConfig(configPath) {
54377
54597
  pythonTimeoutMs: asNumber2(memoryCfg.python_timeout_ms, 6e4),
54378
54598
  reasoningDir: resolvePath(
54379
54599
  asString2(memoryCfg.reasoning_dir, "memory/reasoning"),
54380
- baseDir
54600
+ projectDir2
54381
54601
  ),
54382
54602
  rvfDir: resolvePath(
54383
54603
  asString2(memoryCfg.rvf_dir, "memory/rvf"),
54384
- baseDir
54604
+ projectDir2
54385
54605
  ),
54386
54606
  reasoningOnGoalComplete: asBool(memoryCfg.reasoning_on_goal_complete, true),
54387
54607
  rvfOnGoalComplete: asBool(memoryCfg.rvf_on_goal_complete, true),
@@ -54390,7 +54610,7 @@ async function loadConfig(configPath) {
54390
54610
  sonaEnabled: asBool(memoryCfg.sona_enabled, true),
54391
54611
  sonaDir: resolvePath(
54392
54612
  asString2(memoryCfg.sona_dir, "memory/sona"),
54393
- baseDir
54613
+ projectDir2
54394
54614
  )
54395
54615
  },
54396
54616
  routing: {
@@ -54418,26 +54638,24 @@ async function loadConfig(configPath) {
54418
54638
  })()
54419
54639
  }
54420
54640
  };
54421
- if (cfg.gemini.workingDir) {
54422
- cfg.gemini.workingDir = resolvePath(cfg.gemini.workingDir, baseDir);
54423
- }
54641
+ cfg.gemini.workingDir = cfg.gemini.workingDir ? resolvePath(cfg.gemini.workingDir, projectDir2) : projectDir2;
54424
54642
  return cfg;
54425
54643
  }
54426
54644
  async function resolveDefaultConfig() {
54427
54645
  const candidates = [];
54428
54646
  const agenitHome = process.env.AGENIT_HOME;
54429
54647
  const flowHome = process.env.FLOW_HOME;
54430
- const here = path52.dirname(new URL(import.meta.url).pathname);
54431
- const siblingDir = path52.resolve(here, "..", "..", "..", "..", "config");
54648
+ const here = path54.dirname(new URL(import.meta.url).pathname);
54649
+ const siblingDir = path54.resolve(here, "..", "..", "..", "..", "config");
54432
54650
  for (const name of ["agenit.toml", "flow.toml"]) {
54433
- if (agenitHome) candidates.push(path52.join(agenitHome, "config", name));
54434
- if (flowHome) candidates.push(path52.join(flowHome, "config", name));
54435
- candidates.push(path52.join(siblingDir, name));
54436
- candidates.push(path52.join(process.cwd(), "config", name));
54651
+ if (agenitHome) candidates.push(path54.join(agenitHome, "config", name));
54652
+ if (flowHome) candidates.push(path54.join(flowHome, "config", name));
54653
+ candidates.push(path54.join(siblingDir, name));
54654
+ candidates.push(path54.join(process.cwd(), "config", name));
54437
54655
  }
54438
54656
  for (const c2 of candidates) {
54439
54657
  try {
54440
- await fs51.access(c2);
54658
+ await fs53.access(c2);
54441
54659
  return c2;
54442
54660
  } catch {
54443
54661
  }
@@ -54640,18 +54858,18 @@ async function readStdin() {
54640
54858
  }
54641
54859
 
54642
54860
  // src/update-check.ts
54643
- import { promises as fs52 } from "node:fs";
54644
- import os3 from "node:os";
54645
- import path53 from "node:path";
54861
+ import { promises as fs54 } from "node:fs";
54862
+ import os4 from "node:os";
54863
+ import path55 from "node:path";
54646
54864
  var DEFAULT_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
54647
54865
  function defaultCachePath() {
54648
54866
  const xdg = process.env.XDG_CACHE_HOME;
54649
- const base = xdg ? xdg : path53.join(os3.homedir(), ".cache");
54650
- return path53.join(base, "flow", "version-check.json");
54867
+ const base = xdg ? xdg : path55.join(os4.homedir(), ".cache");
54868
+ return path55.join(base, "flow", "version-check.json");
54651
54869
  }
54652
54870
  async function readCache(p2) {
54653
54871
  try {
54654
- const raw = await fs52.readFile(p2, "utf8");
54872
+ const raw = await fs54.readFile(p2, "utf8");
54655
54873
  const parsed = JSON.parse(raw);
54656
54874
  if (typeof parsed.checked_at === "number" && typeof parsed.installed === "string") {
54657
54875
  return {
@@ -54667,8 +54885,8 @@ async function readCache(p2) {
54667
54885
  }
54668
54886
  async function writeCache(p2, entry) {
54669
54887
  try {
54670
- await fs52.mkdir(path53.dirname(p2), { recursive: true });
54671
- await fs52.writeFile(p2, JSON.stringify(entry, null, 2));
54888
+ await fs54.mkdir(path55.dirname(p2), { recursive: true });
54889
+ await fs54.writeFile(p2, JSON.stringify(entry, null, 2));
54672
54890
  } catch {
54673
54891
  }
54674
54892
  }
@@ -54787,14 +55005,31 @@ var SoulKeeperWorker = class {
54787
55005
 
54788
55006
  // src/cli.tsx
54789
55007
  import { jsx as jsx5 } from "react/jsx-runtime";
54790
- var FLOW_VERSION = "0.5.0";
55008
+ var FLOW_VERSION = "1.0.4";
54791
55009
  var MIN_GEMINI_MAJOR = 0;
54792
55010
  var MIN_GEMINI_MINOR = 37;
54793
- async function checkGeminiCli(binary) {
55011
+ async function checkGeminiCli(cfg) {
55012
+ const configured = cfg.gemini.binary;
55013
+ const resolved = await resolveBinary(configured) ?? // Last-ditch: try the literal name in case spawn() can find it via
55014
+ // shell semantics we didn't model (cygwin, WSL bridge, etc.).
55015
+ (configured ? configured : null);
55016
+ if (!resolved) {
55017
+ throw new Error(
55018
+ `Gemini CLI not found.
55019
+ Configured binary: '${configured}' is not on PATH and was not found in any well-known install location.
55020
+ Install: npm install -g @google/gemini-cli
55021
+ Or set [gemini] binary = "<path>" in agenit.toml (or flow.toml)`
55022
+ );
55023
+ }
55024
+ cfg.gemini.binary = resolved;
54794
55025
  const out = await new Promise(
54795
55026
  (resolve3, reject) => {
54796
- const child = spawn17(binary, ["--version"], {
54797
- stdio: ["ignore", "pipe", "pipe"]
55027
+ const child = spawn17(resolved, ["--version"], {
55028
+ stdio: ["ignore", "pipe", "pipe"],
55029
+ // shell:true on Windows lets .cmd/.bat shims execute correctly
55030
+ // when invoked without their extension. POSIX leaves shell=false
55031
+ // (the default) so we don't pay the spawn-a-shell tax.
55032
+ shell: process.platform === "win32"
54798
55033
  });
54799
55034
  let stdout = "";
54800
55035
  child.stdout.setEncoding("utf8");
@@ -54807,9 +55042,8 @@ async function checkGeminiCli(binary) {
54807
55042
  ).catch(() => null);
54808
55043
  if (!out) {
54809
55044
  throw new Error(
54810
- `Gemini CLI not found at '${binary}'.
54811
- Install: npm install -g @google/gemini-cli
54812
- Then update [gemini] binary = "<path>" in agenit.toml (or flow.toml)`
55045
+ `Gemini CLI at '${resolved}' could not be executed.
55046
+ Reinstall: npm install -g @google/gemini-cli`
54813
55047
  );
54814
55048
  }
54815
55049
  for (const tok of out.stdout.split(/\s+/)) {
@@ -54828,13 +55062,13 @@ Upgrade: npm install -g @google/gemini-cli@latest`
54828
55062
  }
54829
55063
  }
54830
55064
  process.stderr.write(
54831
- `warning: could not parse Gemini CLI version from \`${binary} --version\`
55065
+ `warning: could not parse Gemini CLI version from \`${resolved} --version\`
54832
55066
  `
54833
55067
  );
54834
55068
  }
54835
55069
  async function readActiveProject() {
54836
55070
  try {
54837
- const txt = await fs53.readFile(".agenit_project", "utf8");
55071
+ const txt = await fs55.readFile(".agenit_project", "utf8");
54838
55072
  const trimmed = txt.trim();
54839
55073
  if (!trimmed) return null;
54840
55074
  if (trimmed.includes("=")) {
@@ -54846,16 +55080,17 @@ async function readActiveProject() {
54846
55080
  } catch {
54847
55081
  }
54848
55082
  try {
54849
- const txt = await fs53.readFile(".flow_project", "utf8");
55083
+ const txt = await fs55.readFile(".flow_project", "utf8");
54850
55084
  const trimmed = txt.trim();
54851
55085
  return trimmed || null;
54852
55086
  } catch {
54853
55087
  return null;
54854
55088
  }
54855
55089
  }
55090
+ var INVOCATION_CWD = process.cwd();
54856
55091
  async function loadFlowConfig(configFlag) {
54857
55092
  const configPath = configFlag ?? await resolveDefaultConfig();
54858
- const cfg = await loadConfig(configPath);
55093
+ const cfg = await loadConfig(configPath, INVOCATION_CWD);
54859
55094
  initTelemetry(cfg.telemetry);
54860
55095
  initMetrics(cfg.telemetry);
54861
55096
  return cfg;
@@ -54874,7 +55109,7 @@ async function cmdResume(cfg, idHint) {
54874
55109
  `);
54875
55110
  process.exit(1);
54876
55111
  }
54877
- await checkGeminiCli(cfg.gemini.binary);
55112
+ await checkGeminiCli(cfg);
54878
55113
  const initialProject = session.meta.project ?? await readActiveProject();
54879
55114
  const history = await History.load();
54880
55115
  await writeGuard(cfg, null);
@@ -54915,7 +55150,7 @@ async function cmdSessionsList() {
54915
55150
  }
54916
55151
  }
54917
55152
  async function cmdRepl(cfg) {
54918
- await checkGeminiCli(cfg.gemini.binary);
55153
+ await checkGeminiCli(cfg);
54919
55154
  const initialProject = await readActiveProject();
54920
55155
  const history = await History.load();
54921
55156
  await writeGuard(cfg, null);
@@ -54948,12 +55183,12 @@ async function cmdRepl(cfg) {
54948
55183
  }
54949
55184
  if (cfg.memory.soulKeeperEnabled && initialProject) {
54950
55185
  try {
54951
- const projectMemoryDir = path54.join(cfg.flow.memoryDir, initialProject);
55186
+ const projectMemoryDir = path56.join(cfg.flow.memoryDir, initialProject);
54952
55187
  getLoopWorkerPool().spawn(
54953
55188
  new SoulKeeperWorker({
54954
55189
  project: initialProject,
54955
55190
  soulPath: cfg.flow.soulPath,
54956
- contextPath: path54.join(projectMemoryDir, "context.md")
55191
+ contextPath: path56.join(projectMemoryDir, "context.md")
54957
55192
  }),
54958
55193
  { gapMs: cfg.memory.soulKeeperGapMs }
54959
55194
  );
@@ -55003,7 +55238,7 @@ async function cmdCompletions(shell) {
55003
55238
  process.stdout.write(completionScript(shell));
55004
55239
  }
55005
55240
  async function cmdRun(cfg, project, input) {
55006
- await checkGeminiCli(cfg.gemini.binary);
55241
+ await checkGeminiCli(cfg);
55007
55242
  await writeGuard(cfg, null);
55008
55243
  await ensureGuardHookRegistered();
55009
55244
  const out = await runFlow(cfg, project, input);
@@ -55020,7 +55255,7 @@ async function cmdProjects(cfg) {
55020
55255
  const dir = cfg.flow.memoryDir;
55021
55256
  let entries = [];
55022
55257
  try {
55023
- entries = await fs53.readdir(dir, { withFileTypes: true });
55258
+ entries = await fs55.readdir(dir, { withFileTypes: true });
55024
55259
  } catch {
55025
55260
  return;
55026
55261
  }
@@ -55030,34 +55265,57 @@ async function cmdProjects(cfg) {
55030
55265
  }
55031
55266
  }
55032
55267
  async function cmdInit(cfg, projectDir2, name) {
55033
- const target = path54.resolve(projectDir2);
55034
- const projectName = name ?? path54.basename(target);
55035
- const memDir = path54.join(cfg.flow.memoryDir, projectName);
55036
- await fs53.mkdir(memDir, { recursive: true });
55268
+ const target = path56.resolve(projectDir2);
55269
+ const projectName = name ?? path56.basename(target);
55270
+ const memDir = path56.join(cfg.flow.memoryDir, projectName);
55271
+ await fs55.mkdir(memDir, { recursive: true });
55037
55272
  for (const file of ["context.md", "decisions.md", "requirements.md"]) {
55038
- const p2 = path54.join(memDir, file);
55273
+ const p2 = path56.join(memDir, file);
55039
55274
  try {
55040
- await fs53.access(p2);
55275
+ await fs55.access(p2);
55041
55276
  } catch {
55042
- await fs53.writeFile(p2, "");
55277
+ await fs55.writeFile(p2, "");
55043
55278
  }
55044
55279
  }
55045
- await fs53.writeFile(
55046
- path54.join(target, ".agenit_project"),
55280
+ await fs55.writeFile(
55281
+ path56.join(target, ".agenit_project"),
55047
55282
  `project = "${projectName}"
55048
55283
  profile = "automotive"
55049
55284
  `
55050
55285
  );
55286
+ try {
55287
+ const seed = await seedGeminiAssets(target, cfg.flow.flowHome);
55288
+ process.stdout.write(
55289
+ ` Skills: ${seed.skillsCopied} copied to ${path56.join(target, ".gemini/skills")}
55290
+ `
55291
+ );
55292
+ if (seed.settingsWritten) {
55293
+ process.stdout.write(
55294
+ ` Hooks: .gemini/settings.json written (absolute hook paths under ${cfg.flow.flowHome})
55295
+ `
55296
+ );
55297
+ } else {
55298
+ process.stdout.write(
55299
+ ` Hooks: .gemini/settings.json skipped (${seed.settingsSkippedReason ?? "unknown reason"})
55300
+ `
55301
+ );
55302
+ }
55303
+ } catch (err) {
55304
+ process.stderr.write(
55305
+ ` warning: failed to seed .gemini/ assets: ${err.message}
55306
+ `
55307
+ );
55308
+ }
55051
55309
  process.stdout.write(`\u2713 Project '${projectName}' initialized at ${target}
55052
55310
  `);
55053
55311
  }
55054
55312
  async function cmdUnflow(projectDir2) {
55055
- const target = path54.resolve(projectDir2);
55313
+ const target = path56.resolve(projectDir2);
55056
55314
  let removed = false;
55057
55315
  for (const fname of [".agenit_project", ".flow_project"]) {
55058
- const marker = path54.join(target, fname);
55316
+ const marker = path56.join(target, fname);
55059
55317
  try {
55060
- await fs53.unlink(marker);
55318
+ await fs55.unlink(marker);
55061
55319
  process.stdout.write(`\u2713 Removed ${marker}
55062
55320
  `);
55063
55321
  removed = true;