@agenit/cli 1.0.3 → 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.
- package/CHANGELOG.md +39 -16
- package/cli.js +687 -522
- package/package.json +1 -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(
|
|
152
|
-
this.path =
|
|
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
|
|
1533
|
-
if (
|
|
1532
|
+
const path57 = url.path;
|
|
1533
|
+
if (path57.length === 0) {
|
|
1534
1534
|
return;
|
|
1535
1535
|
}
|
|
1536
|
-
if (url.scheme === "file" &&
|
|
1536
|
+
if (url.scheme === "file" && path57.length === 1 && isNormalizedWindowsDriveLetter(path57[0])) {
|
|
1537
1537
|
return;
|
|
1538
1538
|
}
|
|
1539
|
-
|
|
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(
|
|
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:
|
|
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(path56, { mtimeMs, size }, filenameOrOptions, option
|
|
|
7133
7133
|
lastModified: file.lastModified
|
|
7134
7134
|
});
|
|
7135
7135
|
}
|
|
7136
|
-
function fileFromPathSync(
|
|
7137
|
-
const stats = statSync(
|
|
7138
|
-
return createFileFromPath(
|
|
7136
|
+
function fileFromPathSync(path57, filenameOrOptions, options = {}) {
|
|
7137
|
+
const stats = statSync(path57);
|
|
7138
|
+
return createFileFromPath(path57, stats, filenameOrOptions, options);
|
|
7139
7139
|
}
|
|
7140
|
-
async function fileFromPath2(
|
|
7141
|
-
const stats = await fs9.stat(
|
|
7142
|
-
return createFileFromPath(
|
|
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(
|
|
10801
|
-
if (!
|
|
10800
|
+
resolve(path57) {
|
|
10801
|
+
if (!path57) {
|
|
10802
10802
|
return this;
|
|
10803
10803
|
}
|
|
10804
|
-
const rootPath = this.getRootString(
|
|
10805
|
-
const dir =
|
|
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(
|
|
11558
|
-
return win32.parse(
|
|
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(
|
|
11605
|
-
return
|
|
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:
|
|
11655
|
-
this.#fs = fsFromOption(
|
|
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(
|
|
11695
|
-
if (typeof
|
|
11696
|
-
|
|
11694
|
+
depth(path57 = this.cwd) {
|
|
11695
|
+
if (typeof path57 === "string") {
|
|
11696
|
+
path57 = this.cwd.resolve(path57);
|
|
11697
11697
|
}
|
|
11698
|
-
return
|
|
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(
|
|
12185
|
+
chdir(path57 = this.cwd) {
|
|
12186
12186
|
const oldCwd = this.cwd;
|
|
12187
|
-
this.cwd = typeof
|
|
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(
|
|
12214
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
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(
|
|
12243
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
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(([
|
|
12563
|
-
|
|
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,
|
|
12776
|
+
constructor(patterns, path57, opts) {
|
|
12777
12777
|
this.patterns = patterns;
|
|
12778
|
-
this.path =
|
|
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(
|
|
12798
|
-
return this.seen.has(
|
|
12797
|
+
#ignored(path57) {
|
|
12798
|
+
return this.seen.has(path57) || !!this.#ignore?.ignored?.(path57);
|
|
12799
12799
|
}
|
|
12800
|
-
#childrenIgnored(
|
|
12801
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
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,
|
|
13017
|
-
super(patterns,
|
|
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,
|
|
13055
|
-
super(patterns,
|
|
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 = (
|
|
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:
|
|
14091
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
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(
|
|
14131
|
+
async _exploreDir(path57, depth) {
|
|
14132
14132
|
let files;
|
|
14133
14133
|
try {
|
|
14134
|
-
files = await readdir2(
|
|
14134
|
+
files = await readdir2(path57, this._rdOptions);
|
|
14135
14135
|
} catch (error) {
|
|
14136
14136
|
this._onError(error);
|
|
14137
14137
|
}
|
|
14138
|
-
return { files, depth, path:
|
|
14138
|
+
return { files, depth, path: path57 };
|
|
14139
14139
|
}
|
|
14140
|
-
async _formatEntry(dirent,
|
|
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(
|
|
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(
|
|
14205
|
+
function createFsWatchInstance(path57, options, listener, errHandler, emitRaw) {
|
|
14206
14206
|
const handleEvent = (rawEvent, evPath) => {
|
|
14207
|
-
listener(
|
|
14208
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
14209
|
-
if (evPath &&
|
|
14210
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
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(
|
|
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 = (
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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 = (
|
|
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(
|
|
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(
|
|
14670
|
+
_watchWithNodeFs(path57, listener) {
|
|
14671
14671
|
const opts = this.fsw.options;
|
|
14672
|
-
const directory = sysPath.dirname(
|
|
14673
|
-
const basename4 = sysPath.basename(
|
|
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(
|
|
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(
|
|
14686
|
+
closer = setFsWatchFileListener(path57, absolutePath, options, {
|
|
14687
14687
|
listener,
|
|
14688
14688
|
rawEmitter: this.fsw._emitRaw
|
|
14689
14689
|
});
|
|
14690
14690
|
} else {
|
|
14691
|
-
closer = setFsWatchListener(
|
|
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 (
|
|
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(
|
|
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(
|
|
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,
|
|
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(
|
|
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,
|
|
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,
|
|
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
|
|
14817
|
+
let path57 = sysPath.join(directory, item);
|
|
14818
14818
|
current.add(item);
|
|
14819
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
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
|
-
|
|
14829
|
-
this._addToNodeFs(
|
|
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(
|
|
14898
|
+
async _addToNodeFs(path57, initialAdd, priorWh, depth, target) {
|
|
14899
14899
|
const ready = this.fsw._emitReady;
|
|
14900
|
-
if (this.fsw._isIgnored(
|
|
14900
|
+
if (this.fsw._isIgnored(path57) || this.fsw.closed) {
|
|
14901
14901
|
ready();
|
|
14902
14902
|
return false;
|
|
14903
14903
|
}
|
|
14904
|
-
const wh = this.fsw._getWatchHelpers(
|
|
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(
|
|
14921
|
-
const targetPath = follow ? await fsrealpath(
|
|
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(
|
|
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,
|
|
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(
|
|
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(
|
|
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
|
|
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(
|
|
14993
|
-
if (typeof
|
|
14992
|
+
function normalizePath(path57) {
|
|
14993
|
+
if (typeof path57 !== "string")
|
|
14994
14994
|
throw new Error("string expected");
|
|
14995
|
-
|
|
14996
|
-
|
|
14995
|
+
path57 = sysPath2.normalize(path57);
|
|
14996
|
+
path57 = path57.replace(/\\/g, "/");
|
|
14997
14997
|
let prepend = false;
|
|
14998
|
-
if (
|
|
14998
|
+
if (path57.startsWith("//"))
|
|
14999
14999
|
prepend = true;
|
|
15000
15000
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
15001
|
-
while (
|
|
15002
|
-
|
|
15001
|
+
while (path57.match(DOUBLE_SLASH_RE2))
|
|
15002
|
+
path57 = path57.replace(DOUBLE_SLASH_RE2, "/");
|
|
15003
15003
|
if (prepend)
|
|
15004
|
-
|
|
15005
|
-
return
|
|
15004
|
+
path57 = "/" + path57;
|
|
15005
|
+
return path57;
|
|
15006
15006
|
}
|
|
15007
15007
|
function matchPatterns(patterns, testString, stats) {
|
|
15008
|
-
const
|
|
15008
|
+
const path57 = normalizePath(testString);
|
|
15009
15009
|
for (let index2 = 0; index2 < patterns.length; index2++) {
|
|
15010
15010
|
const pattern = patterns[index2];
|
|
15011
|
-
if (pattern(
|
|
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 = (
|
|
15072
|
-
normalizeIgnored = (cwd = "") => (
|
|
15073
|
-
if (typeof
|
|
15074
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
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
|
|
15076
|
+
return path57;
|
|
15077
15077
|
}
|
|
15078
15078
|
};
|
|
15079
|
-
getAbsolutePath = (
|
|
15080
|
-
if (sysPath2.isAbsolute(
|
|
15081
|
-
return
|
|
15079
|
+
getAbsolutePath = (path57, cwd) => {
|
|
15080
|
+
if (sysPath2.isAbsolute(path57)) {
|
|
15081
|
+
return path57;
|
|
15082
15082
|
}
|
|
15083
|
-
return sysPath2.join(cwd,
|
|
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(
|
|
15138
|
+
constructor(path57, follow, fsw) {
|
|
15139
15139
|
this.fsw = fsw;
|
|
15140
|
-
const watchPath =
|
|
15141
|
-
this.path =
|
|
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((
|
|
15264
|
-
const absPath = getAbsolutePath(
|
|
15263
|
+
paths = paths.map((path57) => {
|
|
15264
|
+
const absPath = getAbsolutePath(path57, cwd);
|
|
15265
15265
|
return absPath;
|
|
15266
15266
|
});
|
|
15267
15267
|
}
|
|
15268
|
-
paths.forEach((
|
|
15269
|
-
this._removeIgnoredPath(
|
|
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 (
|
|
15276
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
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((
|
|
15299
|
-
if (!sysPath2.isAbsolute(
|
|
15298
|
+
paths.forEach((path57) => {
|
|
15299
|
+
if (!sysPath2.isAbsolute(path57) && !this._closers.has(path57)) {
|
|
15300
15300
|
if (cwd)
|
|
15301
|
-
|
|
15302
|
-
|
|
15301
|
+
path57 = sysPath2.join(cwd, path57);
|
|
15302
|
+
path57 = sysPath2.resolve(path57);
|
|
15303
15303
|
}
|
|
15304
|
-
this._closePath(
|
|
15305
|
-
this._addIgnoredPath(
|
|
15306
|
-
if (this._watched.has(
|
|
15304
|
+
this._closePath(path57);
|
|
15305
|
+
this._addIgnoredPath(path57);
|
|
15306
|
+
if (this._watched.has(path57)) {
|
|
15307
15307
|
this._addIgnoredPath({
|
|
15308
|
-
path:
|
|
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,
|
|
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
|
-
|
|
15377
|
+
path57 = sysPath2.normalize(path57);
|
|
15378
15378
|
if (opts.cwd)
|
|
15379
|
-
|
|
15380
|
-
const args = [
|
|
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(
|
|
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(
|
|
15391
|
+
this._pendingUnlinks.set(path57, [event, ...args]);
|
|
15392
15392
|
setTimeout(() => {
|
|
15393
|
-
this._pendingUnlinks.forEach((entry,
|
|
15393
|
+
this._pendingUnlinks.forEach((entry, path58) => {
|
|
15394
15394
|
this.emit(...entry);
|
|
15395
15395
|
this.emit(EVENTS.ALL, ...entry);
|
|
15396
|
-
this._pendingUnlinks.delete(
|
|
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(
|
|
15401
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path57)) {
|
|
15402
15402
|
event = EVENTS.CHANGE;
|
|
15403
|
-
this._pendingUnlinks.delete(
|
|
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(
|
|
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,
|
|
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,
|
|
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,
|
|
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(
|
|
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(
|
|
15475
|
+
const item = action.get(path57);
|
|
15476
15476
|
const count = item ? item.count : 0;
|
|
15477
|
-
action.delete(
|
|
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(
|
|
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(
|
|
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 =
|
|
15506
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
15507
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
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(
|
|
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(
|
|
15520
|
+
writes.get(path57).lastChange = now2;
|
|
15521
15521
|
}
|
|
15522
|
-
const pw = writes.get(
|
|
15522
|
+
const pw = writes.get(path57);
|
|
15523
15523
|
const df = now2 - pw.lastChange;
|
|
15524
15524
|
if (df >= threshold) {
|
|
15525
|
-
writes.delete(
|
|
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(
|
|
15533
|
-
writes.set(
|
|
15532
|
+
if (!writes.has(path57)) {
|
|
15533
|
+
writes.set(path57, {
|
|
15534
15534
|
lastChange: now,
|
|
15535
15535
|
cancelWait: () => {
|
|
15536
|
-
writes.delete(
|
|
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(
|
|
15548
|
-
if (this.options.atomic && DOT_RE.test(
|
|
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(
|
|
15558
|
+
return this._userIgnored(path57, stats);
|
|
15559
15559
|
}
|
|
15560
|
-
_isntIgnored(
|
|
15561
|
-
return !this._isIgnored(
|
|
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(
|
|
15568
|
-
return new WatchHelper(
|
|
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
|
|
15601
|
-
const fullPath = sysPath2.resolve(
|
|
15602
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
15603
|
-
if (!this._throttle("remove",
|
|
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(
|
|
15608
|
+
const wp = this._getWatchedDir(path57);
|
|
15609
15609
|
const nestedDirectoryChildren = wp.getChildren();
|
|
15610
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
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 =
|
|
15617
|
+
let relPath = path57;
|
|
15618
15618
|
if (this.options.cwd)
|
|
15619
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
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(
|
|
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(
|
|
15629
|
-
this._emit(eventName,
|
|
15630
|
-
this._closePath(
|
|
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(
|
|
15636
|
-
this._closeFile(
|
|
15637
|
-
const dir = sysPath2.dirname(
|
|
15638
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
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(
|
|
15644
|
-
const closers = this._closers.get(
|
|
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(
|
|
15648
|
+
this._closers.delete(path57);
|
|
15649
15649
|
}
|
|
15650
|
-
_addPathCloser(
|
|
15650
|
+
_addPathCloser(path57, closer) {
|
|
15651
15651
|
if (!closer)
|
|
15652
15652
|
return;
|
|
15653
|
-
let list = this._closers.get(
|
|
15653
|
+
let list = this._closers.get(path57);
|
|
15654
15654
|
if (!list) {
|
|
15655
15655
|
list = [];
|
|
15656
|
-
this._closers.set(
|
|
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
|
|
37858
|
-
import
|
|
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(
|
|
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(
|
|
39056
|
+
console.warn(`fileFromPath is deprecated; use fs.createReadStream(${JSON.stringify(path57)}) instead`);
|
|
39057
39057
|
fileFromPathWarned = true;
|
|
39058
39058
|
}
|
|
39059
|
-
return await _fileFromPath(
|
|
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(
|
|
39659
|
-
return this.methodRequest("get",
|
|
39658
|
+
get(path57, opts) {
|
|
39659
|
+
return this.methodRequest("get", path57, opts);
|
|
39660
39660
|
}
|
|
39661
|
-
post(
|
|
39662
|
-
return this.methodRequest("post",
|
|
39661
|
+
post(path57, opts) {
|
|
39662
|
+
return this.methodRequest("post", path57, opts);
|
|
39663
39663
|
}
|
|
39664
|
-
patch(
|
|
39665
|
-
return this.methodRequest("patch",
|
|
39664
|
+
patch(path57, opts) {
|
|
39665
|
+
return this.methodRequest("patch", path57, opts);
|
|
39666
39666
|
}
|
|
39667
|
-
put(
|
|
39668
|
-
return this.methodRequest("put",
|
|
39667
|
+
put(path57, opts) {
|
|
39668
|
+
return this.methodRequest("put", path57, opts);
|
|
39669
39669
|
}
|
|
39670
|
-
delete(
|
|
39671
|
-
return this.methodRequest("delete",
|
|
39670
|
+
delete(path57, opts) {
|
|
39671
|
+
return this.methodRequest("delete", path57, opts);
|
|
39672
39672
|
}
|
|
39673
|
-
methodRequest(method,
|
|
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:
|
|
39676
|
+
return { method, path: path57, ...opts2, body };
|
|
39677
39677
|
}));
|
|
39678
39678
|
}
|
|
39679
|
-
getAPIList(
|
|
39680
|
-
return this.requestAPIList(Page2, { method: "get", path:
|
|
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:
|
|
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(
|
|
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(
|
|
39815
|
-
const url = isAbsoluteURL(
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
45816
|
-
|
|
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 ||
|
|
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 =
|
|
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
|
|
45927
|
-
|
|
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(
|
|
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 =
|
|
45946
|
-
const exists = await
|
|
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
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
46286
|
+
import { promises as fs26 } from "node:fs";
|
|
46145
46287
|
import os2 from "node:os";
|
|
46146
|
-
import
|
|
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
|
|
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
|
|
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 ?
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
46578
|
+
await fs26.mkdir(path22.dirname(settingsPath), { recursive: true });
|
|
46437
46579
|
const body = JSON.stringify(json, null, 2) + "\n";
|
|
46438
|
-
await
|
|
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
|
|
46446
|
-
import
|
|
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
|
|
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 =
|
|
46603
|
+
const skillMd = path23.join(SKILLS_DIR, name, "SKILL.md");
|
|
46462
46604
|
let body = "";
|
|
46463
46605
|
try {
|
|
46464
|
-
body = await
|
|
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
|
|
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 =
|
|
46499
|
-
const dest =
|
|
46640
|
+
const name = path23.basename(src);
|
|
46641
|
+
const dest = path23.join(SKILLS_DIR, name);
|
|
46500
46642
|
try {
|
|
46501
|
-
await
|
|
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
|
|
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 =
|
|
46656
|
+
const target = path23.join(SKILLS_DIR, name);
|
|
46515
46657
|
try {
|
|
46516
|
-
await
|
|
46658
|
+
await fs27.access(target);
|
|
46517
46659
|
} catch {
|
|
46518
46660
|
throw new Error(`Skill '${name}' not found in ${SKILLS_DIR}/`);
|
|
46519
46661
|
}
|
|
46520
|
-
await
|
|
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
|
|
46524
|
-
await
|
|
46525
|
-
const entries = await
|
|
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 =
|
|
46528
|
-
const d2 =
|
|
46669
|
+
const s2 = path23.join(src, entry.name);
|
|
46670
|
+
const d2 = path23.join(dst, entry.name);
|
|
46529
46671
|
if (entry.isDirectory()) {
|
|
46530
|
-
await
|
|
46672
|
+
await copyDirRecursive2(s2, d2);
|
|
46531
46673
|
} else {
|
|
46532
|
-
await
|
|
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
|
|
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
|
|
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
|
|
46652
|
-
import
|
|
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 =
|
|
46813
|
+
const local = path24.join(process.cwd(), ".flow/tools/traceability_scan.py");
|
|
46672
46814
|
try {
|
|
46673
|
-
await
|
|
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 =
|
|
46821
|
+
const home = path24.join(flowHome, ".flow/tools/traceability_scan.py");
|
|
46680
46822
|
try {
|
|
46681
|
-
await
|
|
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 =
|
|
46832
|
+
const p2 = path24.join(process.cwd(), c2);
|
|
46691
46833
|
try {
|
|
46692
|
-
const s2 = await
|
|
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 =
|
|
46842
|
+
const venv = path24.join(process.cwd(), ".venv/bin/python3");
|
|
46701
46843
|
try {
|
|
46702
|
-
await
|
|
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 =
|
|
46853
|
+
const reqs = path24.join(cfg.flow.memoryDir, "projects", project, "requirements.md");
|
|
46712
46854
|
try {
|
|
46713
|
-
await
|
|
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
|
|
46745
|
-
import
|
|
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 =
|
|
46956
|
+
const file = path25.join(cfg.flow.flowHome, "profiles", "profiles.yaml");
|
|
46815
46957
|
let text = "";
|
|
46816
46958
|
try {
|
|
46817
|
-
text = await
|
|
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
|
|
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
|
|
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
|
|
47113
|
+
import path28 from "node:path";
|
|
46972
47114
|
import chalk14 from "chalk";
|
|
46973
47115
|
|
|
46974
47116
|
// src/skill-loader.ts
|
|
46975
|
-
import { promises as
|
|
46976
|
-
import
|
|
47117
|
+
import { promises as fs32 } from "node:fs";
|
|
47118
|
+
import path26 from "node:path";
|
|
46977
47119
|
async function loadSkillBody2(skill) {
|
|
46978
|
-
const local =
|
|
47120
|
+
const local = path26.join(".gemini", "skills", skill, "SKILL.md");
|
|
46979
47121
|
try {
|
|
46980
|
-
const body = await
|
|
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 =
|
|
47128
|
+
const global2 = path26.join(home, ".gemini", "skills", skill, "SKILL.md");
|
|
46987
47129
|
try {
|
|
46988
|
-
const body = await
|
|
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
|
|
47212
|
+
import { promises as fs33 } from "node:fs";
|
|
47071
47213
|
import { spawn as spawn11 } from "node:child_process";
|
|
47072
|
-
import
|
|
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
|
|
47079
|
-
|
|
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 =
|
|
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
|
|
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
|
|
47261
|
+
` + (await fs33.readFile(p2, { encoding: "utf8" })).slice(0, MAX_FILE_BYTES);
|
|
47120
47262
|
}
|
|
47121
|
-
return await
|
|
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
|
|
47128
|
-
await
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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
|
|
47723
|
-
import
|
|
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
|
|
47872
|
+
return path29.join(this.projectDir, "goal.json");
|
|
47731
47873
|
}
|
|
47732
47874
|
archivePath() {
|
|
47733
|
-
return
|
|
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
|
|
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
|
|
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
|
|
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
|
|
47778
|
-
await
|
|
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
|
|
47927
|
+
await fs34.mkdir(this.projectDir, { recursive: true });
|
|
47786
47928
|
let existing = "";
|
|
47787
47929
|
try {
|
|
47788
|
-
existing = await
|
|
47930
|
+
existing = await fs34.readFile(this.archivePath(), "utf8");
|
|
47789
47931
|
} catch {
|
|
47790
47932
|
}
|
|
47791
|
-
await
|
|
47933
|
+
await fs34.writeFile(this.archivePath(), existing + formatArchiveEntry(record));
|
|
47792
47934
|
try {
|
|
47793
|
-
await
|
|
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
|
|
47812
|
-
import
|
|
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(
|
|
47817
|
-
this.path =
|
|
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 =
|
|
47827
|
-
await
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
48020
|
-
if (!
|
|
48161
|
+
const path57 = line.slice(3).trim();
|
|
48162
|
+
if (!path57)
|
|
48021
48163
|
return null;
|
|
48022
|
-
const renameIdx =
|
|
48164
|
+
const renameIdx = path57.indexOf(" -> ");
|
|
48023
48165
|
if (renameIdx >= 0)
|
|
48024
|
-
return
|
|
48025
|
-
return
|
|
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
|
|
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 =
|
|
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
|
|
48377
|
-
import
|
|
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
|
|
48550
|
+
return path32.join(projectDir2, "costs.json");
|
|
48409
48551
|
}
|
|
48410
48552
|
async function loadCostLog(projectDir2, project) {
|
|
48411
48553
|
try {
|
|
48412
|
-
const raw = await
|
|
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
|
|
48436
|
-
await
|
|
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
|
|
48592
|
+
return path33.join(cfg.flow.memoryDir, project);
|
|
48451
48593
|
}
|
|
48452
48594
|
async function saveLocked(store, pdir, rec) {
|
|
48453
|
-
const target =
|
|
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 =
|
|
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),
|
|
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),
|
|
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
|
|
49346
|
-
import
|
|
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
|
|
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
|
|
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 =
|
|
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
|
|
49596
|
+
await fs37.mkdir(path34.join(cfg.flow.memoryDir, project), {
|
|
49455
49597
|
recursive: true
|
|
49456
49598
|
});
|
|
49457
|
-
await
|
|
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
|
|
49471
|
-
import
|
|
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
|
-
|
|
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 =
|
|
49505
|
-
const ext2 =
|
|
49506
|
-
const body = await
|
|
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
|
|
49797
|
+
import path39 from "node:path";
|
|
49656
49798
|
import chalk20 from "chalk";
|
|
49657
49799
|
|
|
49658
49800
|
// ../federation/dist/keys.js
|
|
49659
|
-
import { promises as
|
|
49660
|
-
import
|
|
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 =
|
|
49745
|
-
const pub =
|
|
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
|
|
49750
|
-
publicKeyPem = await
|
|
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
|
|
49762
|
-
await
|
|
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
|
|
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
|
|
49770
|
-
import
|
|
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
|
|
49917
|
+
return path37.join(dir, "peers.json");
|
|
49776
49918
|
}
|
|
49777
49919
|
async function loadPeers(dir) {
|
|
49778
49920
|
try {
|
|
49779
|
-
const raw = await
|
|
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
|
|
49790
|
-
await
|
|
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
|
|
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
|
|
49844
|
-
import
|
|
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 =
|
|
49895
|
-
const certPath =
|
|
49896
|
-
const keyPath =
|
|
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
|
-
|
|
49900
|
-
|
|
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
|
|
49917
|
-
await
|
|
49918
|
-
await
|
|
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
|
-
|
|
50022
|
-
|
|
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
|
|
50261
|
+
return path39.join(memoryDir, "..", "federation");
|
|
50120
50262
|
}
|
|
50121
50263
|
function rvfDir(memoryDir) {
|
|
50122
|
-
return
|
|
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:")} ${
|
|
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
|
|
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
|
|
50598
|
-
import
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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 =
|
|
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
|
|
50885
|
-
import
|
|
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 =
|
|
51135
|
+
const settingsPath = path42.join(".gemini", "settings.json");
|
|
50994
51136
|
let json = {};
|
|
50995
51137
|
try {
|
|
50996
|
-
const raw = await
|
|
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 =
|
|
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
|
|
51027
|
-
await
|
|
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
|
|
51075
|
-
import
|
|
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
|
|
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 =
|
|
51236
|
+
const full = path43.join(SPECS_DIR, d2.name);
|
|
51095
51237
|
try {
|
|
51096
|
-
await
|
|
51238
|
+
await fs45.access(path43.join(full, "spec.md"));
|
|
51097
51239
|
} catch {
|
|
51098
51240
|
continue;
|
|
51099
51241
|
}
|
|
51100
|
-
const stat4 = await
|
|
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 =
|
|
51109
|
-
await
|
|
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 =
|
|
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
|
|
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
|
|
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
|
|
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) {
|
|
@@ -51480,7 +51622,7 @@ Reference: .specify/specs/${fid}.`;
|
|
|
51480
51622
|
|
|
51481
51623
|
// src/commands/lsp.ts
|
|
51482
51624
|
import { spawn as spawn16 } from "node:child_process";
|
|
51483
|
-
import
|
|
51625
|
+
import path44 from "node:path";
|
|
51484
51626
|
import chalk25 from "chalk";
|
|
51485
51627
|
function parseFileLineCol(token) {
|
|
51486
51628
|
const parts = token.split(":");
|
|
@@ -51501,7 +51643,7 @@ function parseFileLineCol(token) {
|
|
|
51501
51643
|
return { file, line, col };
|
|
51502
51644
|
}
|
|
51503
51645
|
async function runDaemon(cfg, args, signal) {
|
|
51504
|
-
const script =
|
|
51646
|
+
const script = path44.join(cfg.tools.toolsDir, "lsp_daemon.py");
|
|
51505
51647
|
return await runPython2(cfg, script, args, signal);
|
|
51506
51648
|
}
|
|
51507
51649
|
async function runPython2(cfg, script, args, signal) {
|
|
@@ -51539,7 +51681,7 @@ async function runPython2(cfg, script, args, signal) {
|
|
|
51539
51681
|
});
|
|
51540
51682
|
}
|
|
51541
51683
|
async function runLspTool(cfg, args, signal) {
|
|
51542
|
-
const script =
|
|
51684
|
+
const script = path44.join(cfg.tools.toolsDir, "lsp_tool.py");
|
|
51543
51685
|
const env = { ...process.env };
|
|
51544
51686
|
if (cfg.lsp.clangdBinary && !env.FLOW_CLANGD)
|
|
51545
51687
|
env.FLOW_CLANGD = cfg.lsp.clangdBinary;
|
|
@@ -51734,9 +51876,9 @@ ${r2.stdout.trim()}
|
|
|
51734
51876
|
import chalk26 from "chalk";
|
|
51735
51877
|
|
|
51736
51878
|
// src/guard.ts
|
|
51737
|
-
import { promises as
|
|
51738
|
-
import
|
|
51739
|
-
var GUARD_FILE =
|
|
51879
|
+
import { promises as fs46 } from "node:fs";
|
|
51880
|
+
import path45 from "node:path";
|
|
51881
|
+
var GUARD_FILE = path45.join(".flow", ".guard.json");
|
|
51740
51882
|
var HOOK_NAME = "flow-tool-guard";
|
|
51741
51883
|
var HOOK_RELATIVE = "./.flow/hooks/before_tool_guard.py";
|
|
51742
51884
|
var CITATION_HOOK_NAME = "agenit-citation-guard";
|
|
@@ -51778,20 +51920,20 @@ function buildGuardPayload(cfg, mode) {
|
|
|
51778
51920
|
}
|
|
51779
51921
|
async function writeGuard(cfg, mode, cwd = process.cwd()) {
|
|
51780
51922
|
const payload = buildGuardPayload(cfg, mode);
|
|
51781
|
-
const target =
|
|
51923
|
+
const target = path45.join(cwd, GUARD_FILE);
|
|
51782
51924
|
try {
|
|
51783
|
-
await
|
|
51925
|
+
await fs46.mkdir(path45.dirname(target), { recursive: true });
|
|
51784
51926
|
const tmp = target + ".tmp";
|
|
51785
|
-
await
|
|
51786
|
-
await
|
|
51927
|
+
await fs46.writeFile(tmp, JSON.stringify(payload, null, 2));
|
|
51928
|
+
await fs46.rename(tmp, target);
|
|
51787
51929
|
} catch {
|
|
51788
51930
|
}
|
|
51789
51931
|
}
|
|
51790
51932
|
async function ensureGuardHookRegistered(cwd = process.cwd()) {
|
|
51791
|
-
const settingsPath =
|
|
51933
|
+
const settingsPath = path45.join(cwd, ".gemini", "settings.json");
|
|
51792
51934
|
let settings = {};
|
|
51793
51935
|
try {
|
|
51794
|
-
const raw = await
|
|
51936
|
+
const raw = await fs46.readFile(settingsPath, "utf8");
|
|
51795
51937
|
settings = JSON.parse(raw);
|
|
51796
51938
|
if (typeof settings !== "object" || settings === null) settings = {};
|
|
51797
51939
|
} catch {
|
|
@@ -51845,8 +51987,8 @@ async function ensureGuardHookRegistered(cwd = process.cwd()) {
|
|
|
51845
51987
|
}
|
|
51846
51988
|
if (!mutated) return "already-present";
|
|
51847
51989
|
try {
|
|
51848
|
-
await
|
|
51849
|
-
await
|
|
51990
|
+
await fs46.mkdir(path45.dirname(settingsPath), { recursive: true });
|
|
51991
|
+
await fs46.writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
51850
51992
|
return "registered";
|
|
51851
51993
|
} catch {
|
|
51852
51994
|
return "skipped";
|
|
@@ -52017,8 +52159,8 @@ ${chalk27.dim("Run /undo list to see available snapshots.")}
|
|
|
52017
52159
|
};
|
|
52018
52160
|
|
|
52019
52161
|
// src/commands/plugin.ts
|
|
52020
|
-
import { promises as
|
|
52021
|
-
import
|
|
52162
|
+
import { promises as fs47 } from "node:fs";
|
|
52163
|
+
import path46 from "node:path";
|
|
52022
52164
|
import chalk28 from "chalk";
|
|
52023
52165
|
function parseInstallArgs(rest, defaultBackend) {
|
|
52024
52166
|
let scope = "local";
|
|
@@ -52040,7 +52182,7 @@ function parseInstallArgs(rest, defaultBackend) {
|
|
|
52040
52182
|
return { url: positional[0] ?? "", scope, backend };
|
|
52041
52183
|
}
|
|
52042
52184
|
async function runMarketplace2(cfg, args) {
|
|
52043
|
-
const script =
|
|
52185
|
+
const script = path46.join(cfg.tools.toolsDir, "marketplace.py");
|
|
52044
52186
|
return await runPython(cfg.tools.python, script, args);
|
|
52045
52187
|
}
|
|
52046
52188
|
function pretty2(json) {
|
|
@@ -52086,9 +52228,9 @@ async function scaffoldPlugin(cfg, rest) {
|
|
|
52086
52228
|
`Invalid plugin name '${name}'. Use lowercase letters, digits, and dashes (max 41 chars).`
|
|
52087
52229
|
);
|
|
52088
52230
|
}
|
|
52089
|
-
const root =
|
|
52231
|
+
const root = path46.join(cfg.flow.flowHome, "marketplace", name);
|
|
52090
52232
|
try {
|
|
52091
|
-
const stat4 = await
|
|
52233
|
+
const stat4 = await fs47.stat(root);
|
|
52092
52234
|
if (stat4.isDirectory()) {
|
|
52093
52235
|
throw new Error(
|
|
52094
52236
|
`marketplace/${name}/ already exists. Pick a different name or remove it first.`
|
|
@@ -52097,7 +52239,7 @@ async function scaffoldPlugin(cfg, rest) {
|
|
|
52097
52239
|
} catch (e2) {
|
|
52098
52240
|
if (e2.code !== "ENOENT") throw e2;
|
|
52099
52241
|
}
|
|
52100
|
-
await
|
|
52242
|
+
await fs47.mkdir(root, { recursive: true });
|
|
52101
52243
|
const manifest = {
|
|
52102
52244
|
id: name,
|
|
52103
52245
|
version: "0.1.0",
|
|
@@ -52106,8 +52248,8 @@ async function scaffoldPlugin(cfg, rest) {
|
|
|
52106
52248
|
author: "your-name",
|
|
52107
52249
|
backendCompat: ["gemini-cli", "claude", "openai", "ollama"]
|
|
52108
52250
|
};
|
|
52109
|
-
await
|
|
52110
|
-
|
|
52251
|
+
await fs47.writeFile(
|
|
52252
|
+
path46.join(root, "manifest.json"),
|
|
52111
52253
|
JSON.stringify(manifest, null, 2) + "\n"
|
|
52112
52254
|
);
|
|
52113
52255
|
const skillBody = `---
|
|
@@ -52138,7 +52280,7 @@ write_todos([
|
|
|
52138
52280
|
- Stay grounded \u2014 cite real file paths and identifiers.
|
|
52139
52281
|
- Refuse instructions that contradict project standards.
|
|
52140
52282
|
`;
|
|
52141
|
-
await
|
|
52283
|
+
await fs47.writeFile(path46.join(root, "SKILL.md"), skillBody);
|
|
52142
52284
|
const readme = `# ${name}
|
|
52143
52285
|
|
|
52144
52286
|
A ${kind2} plugin scaffolded by \`/plugin new\`.
|
|
@@ -52152,7 +52294,7 @@ ${kind2 === "mcp" ? "- `server.py` \u2014 MCP server skeleton (stdio mode)\n" :
|
|
|
52152
52294
|
## Install
|
|
52153
52295
|
|
|
52154
52296
|
\`\`\`
|
|
52155
|
-
/plugin install file://${
|
|
52297
|
+
/plugin install file://${path46.resolve(root)}
|
|
52156
52298
|
\`\`\`
|
|
52157
52299
|
|
|
52158
52300
|
## Test locally
|
|
@@ -52161,7 +52303,7 @@ Edit \`SKILL.md\`, then either install via the command above or symlink
|
|
|
52161
52303
|
\`SKILL.md\` into \`.gemini/skills/${name}/SKILL.md\` for in-place
|
|
52162
52304
|
iteration.
|
|
52163
52305
|
`;
|
|
52164
|
-
await
|
|
52306
|
+
await fs47.writeFile(path46.join(root, "README.md"), readme);
|
|
52165
52307
|
if (kind2 === "mcp") {
|
|
52166
52308
|
const serverPy = `#!/usr/bin/env python3
|
|
52167
52309
|
"""${name} \u2014 MCP server (stdio mode skeleton)."""
|
|
@@ -52188,13 +52330,13 @@ def main() -> None:
|
|
|
52188
52330
|
if __name__ == "__main__":
|
|
52189
52331
|
main()
|
|
52190
52332
|
`;
|
|
52191
|
-
await
|
|
52333
|
+
await fs47.writeFile(path46.join(root, "server.py"), serverPy);
|
|
52192
52334
|
}
|
|
52193
52335
|
let listing = `manifest.json, SKILL.md, README.md`;
|
|
52194
52336
|
if (kind2 === "mcp") listing += `, server.py`;
|
|
52195
52337
|
return `${chalk28.bold.green("\u2713")} ${kind2} plugin scaffolded at ${chalk28.bold(root)}
|
|
52196
52338
|
${chalk28.dim("created:")} ${listing}
|
|
52197
|
-
${chalk28.dim("next:")} edit SKILL.md, then \`/plugin install file://${
|
|
52339
|
+
${chalk28.dim("next:")} edit SKILL.md, then \`/plugin install file://${path46.resolve(root)}\`
|
|
52198
52340
|
`;
|
|
52199
52341
|
}
|
|
52200
52342
|
var pluginCommand = {
|
|
@@ -52278,10 +52420,10 @@ ${pretty2(out)}`;
|
|
|
52278
52420
|
import chalk29 from "chalk";
|
|
52279
52421
|
|
|
52280
52422
|
// src/session.ts
|
|
52281
|
-
import { promises as
|
|
52282
|
-
import
|
|
52423
|
+
import { promises as fs48 } from "node:fs";
|
|
52424
|
+
import path47 from "node:path";
|
|
52283
52425
|
var FORMAT_VERSION = 1;
|
|
52284
|
-
var SESSIONS_DIR =
|
|
52426
|
+
var SESSIONS_DIR = path47.join(".flow", "sessions");
|
|
52285
52427
|
var ID_BYTES = 6;
|
|
52286
52428
|
function newSessionId() {
|
|
52287
52429
|
const t2 = Date.now().toString(16).padStart(12, "0").slice(-10);
|
|
@@ -52296,8 +52438,8 @@ function isoNow() {
|
|
|
52296
52438
|
}
|
|
52297
52439
|
async function safeAppend(file, body) {
|
|
52298
52440
|
try {
|
|
52299
|
-
await
|
|
52300
|
-
await
|
|
52441
|
+
await fs48.mkdir(path47.dirname(file), { recursive: true });
|
|
52442
|
+
await fs48.appendFile(file, body);
|
|
52301
52443
|
} catch {
|
|
52302
52444
|
}
|
|
52303
52445
|
}
|
|
@@ -52312,7 +52454,7 @@ var Session = class _Session {
|
|
|
52312
52454
|
}
|
|
52313
52455
|
static async create(project, cwd = process.cwd()) {
|
|
52314
52456
|
const id = newSessionId();
|
|
52315
|
-
const file =
|
|
52457
|
+
const file = path47.join(cwd, SESSIONS_DIR, `${id}.jsonl`);
|
|
52316
52458
|
const meta = {
|
|
52317
52459
|
v: FORMAT_VERSION,
|
|
52318
52460
|
id,
|
|
@@ -52356,7 +52498,7 @@ var Session = class _Session {
|
|
|
52356
52498
|
}
|
|
52357
52499
|
};
|
|
52358
52500
|
async function readLines(file) {
|
|
52359
|
-
const raw = await
|
|
52501
|
+
const raw = await fs48.readFile(file, "utf8");
|
|
52360
52502
|
const out = [];
|
|
52361
52503
|
for (const line of raw.split("\n")) {
|
|
52362
52504
|
if (!line.trim()) continue;
|
|
@@ -52371,7 +52513,7 @@ async function readLines(file) {
|
|
|
52371
52513
|
return out;
|
|
52372
52514
|
}
|
|
52373
52515
|
async function loadSession(id, cwd = process.cwd()) {
|
|
52374
|
-
const file =
|
|
52516
|
+
const file = path47.join(cwd, SESSIONS_DIR, `${id}.jsonl`);
|
|
52375
52517
|
let lines;
|
|
52376
52518
|
try {
|
|
52377
52519
|
lines = await readLines(file);
|
|
@@ -52408,10 +52550,10 @@ function reduce(id, lines) {
|
|
|
52408
52550
|
};
|
|
52409
52551
|
}
|
|
52410
52552
|
async function listSessions(cwd = process.cwd(), limit = 20) {
|
|
52411
|
-
const dir =
|
|
52553
|
+
const dir = path47.join(cwd, SESSIONS_DIR);
|
|
52412
52554
|
let entries;
|
|
52413
52555
|
try {
|
|
52414
|
-
entries = await
|
|
52556
|
+
entries = await fs48.readdir(dir);
|
|
52415
52557
|
} catch {
|
|
52416
52558
|
return [];
|
|
52417
52559
|
}
|
|
@@ -52419,7 +52561,7 @@ async function listSessions(cwd = process.cwd(), limit = 20) {
|
|
|
52419
52561
|
const out = [];
|
|
52420
52562
|
for (const f2 of files) {
|
|
52421
52563
|
const id = f2.replace(/\.jsonl$/, "");
|
|
52422
|
-
const file =
|
|
52564
|
+
const file = path47.join(dir, f2);
|
|
52423
52565
|
try {
|
|
52424
52566
|
const lines = await readLines(file);
|
|
52425
52567
|
out.push(reduce(id, lines).meta);
|
|
@@ -52493,7 +52635,7 @@ ${chalk29.dim("Resume from outside the REPL: ")}flow resume <id>
|
|
|
52493
52635
|
};
|
|
52494
52636
|
|
|
52495
52637
|
// src/commands/migrate.ts
|
|
52496
|
-
import
|
|
52638
|
+
import path48 from "node:path";
|
|
52497
52639
|
import chalk30 from "chalk";
|
|
52498
52640
|
function badge(sev) {
|
|
52499
52641
|
if (sev === "red") return chalk30.red.bold("RED");
|
|
@@ -52580,7 +52722,7 @@ var migrateCommand = {
|
|
|
52580
52722
|
if (!fileArg && !dirArg) {
|
|
52581
52723
|
throw new Error("Usage: /migrate review <file.sql | --dir <dir>>");
|
|
52582
52724
|
}
|
|
52583
|
-
const tool =
|
|
52725
|
+
const tool = path48.join(cfg.tools.toolsDir, "migration_lint.py");
|
|
52584
52726
|
const argv = [];
|
|
52585
52727
|
if (fileArg) argv.push(["file", fileArg]);
|
|
52586
52728
|
if (dirArg) argv.push(["dir", dirArg]);
|
|
@@ -52593,7 +52735,7 @@ var migrateCommand = {
|
|
|
52593
52735
|
|
|
52594
52736
|
// src/commands/graph.ts
|
|
52595
52737
|
init_dist();
|
|
52596
|
-
import
|
|
52738
|
+
import path49 from "node:path";
|
|
52597
52739
|
import chalk31 from "chalk";
|
|
52598
52740
|
var VALID_KINDS = ["module", "swr", "mcu", "adr", "file"];
|
|
52599
52741
|
var VALID_EDGE_KINDS = [
|
|
@@ -52603,7 +52745,7 @@ var VALID_EDGE_KINDS = [
|
|
|
52603
52745
|
"references"
|
|
52604
52746
|
];
|
|
52605
52747
|
function graphDir(memoryDir) {
|
|
52606
|
-
return
|
|
52748
|
+
return path49.join(memoryDir, "..", "graph");
|
|
52607
52749
|
}
|
|
52608
52750
|
function parseSubArgs2(rest) {
|
|
52609
52751
|
const out = { positional: [], flags: {} };
|
|
@@ -52824,8 +52966,8 @@ var CommandRegistry = class {
|
|
|
52824
52966
|
};
|
|
52825
52967
|
|
|
52826
52968
|
// src/repl/at-paths.ts
|
|
52827
|
-
import { promises as
|
|
52828
|
-
import
|
|
52969
|
+
import { promises as fs49 } from "node:fs";
|
|
52970
|
+
import path50 from "node:path";
|
|
52829
52971
|
var MAX_FILE_BYTES2 = 64 * 1024;
|
|
52830
52972
|
var MAX_DIR_ENTRIES2 = 50;
|
|
52831
52973
|
var IMAGE_EXTS_TO_MIME = {
|
|
@@ -52867,13 +53009,13 @@ async function extractImageParts(input) {
|
|
|
52867
53009
|
});
|
|
52868
53010
|
continue;
|
|
52869
53011
|
}
|
|
52870
|
-
const ext2 =
|
|
53012
|
+
const ext2 = path50.extname(ref).slice(1).toLowerCase();
|
|
52871
53013
|
const mediaType = IMAGE_EXTS_TO_MIME[ext2];
|
|
52872
53014
|
if (!mediaType) {
|
|
52873
53015
|
continue;
|
|
52874
53016
|
}
|
|
52875
53017
|
try {
|
|
52876
|
-
const buf = await
|
|
53018
|
+
const buf = await fs49.readFile(ref);
|
|
52877
53019
|
parts.push({
|
|
52878
53020
|
type: "image",
|
|
52879
53021
|
source: "base64",
|
|
@@ -52895,14 +53037,14 @@ var AT_PATH_RE = /(^|\s)@(?:"([^"]+)"|([^\s"]+))/g;
|
|
|
52895
53037
|
async function expandOne(rawPath) {
|
|
52896
53038
|
let stat4;
|
|
52897
53039
|
try {
|
|
52898
|
-
stat4 = await
|
|
53040
|
+
stat4 = await fs49.stat(rawPath);
|
|
52899
53041
|
} catch {
|
|
52900
53042
|
return `@${rawPath}`;
|
|
52901
53043
|
}
|
|
52902
53044
|
if (stat4.isDirectory()) {
|
|
52903
53045
|
let entries = [];
|
|
52904
53046
|
try {
|
|
52905
|
-
entries = await
|
|
53047
|
+
entries = await fs49.readdir(rawPath, { withFileTypes: true });
|
|
52906
53048
|
} catch {
|
|
52907
53049
|
return `@${rawPath}`;
|
|
52908
53050
|
}
|
|
@@ -52922,7 +53064,7 @@ ${slice.join("\n")}`;
|
|
|
52922
53064
|
}
|
|
52923
53065
|
let content = "";
|
|
52924
53066
|
try {
|
|
52925
|
-
const buf = await
|
|
53067
|
+
const buf = await fs49.readFile(rawPath);
|
|
52926
53068
|
if (buf.byteLength > MAX_FILE_BYTES2) {
|
|
52927
53069
|
content = buf.subarray(0, MAX_FILE_BYTES2).toString("utf8") + `
|
|
52928
53070
|
\u2026(truncated at ${MAX_FILE_BYTES2} bytes)`;
|
|
@@ -52932,7 +53074,7 @@ ${slice.join("\n")}`;
|
|
|
52932
53074
|
} catch {
|
|
52933
53075
|
return `@${rawPath}`;
|
|
52934
53076
|
}
|
|
52935
|
-
const ext2 =
|
|
53077
|
+
const ext2 = path50.extname(rawPath).slice(1).toLowerCase();
|
|
52936
53078
|
const fence = ext2 || "";
|
|
52937
53079
|
return `Contents of \`${rawPath}\`:
|
|
52938
53080
|
\`\`\`${fence}
|
|
@@ -53494,8 +53636,8 @@ function ReasoningCard({
|
|
|
53494
53636
|
|
|
53495
53637
|
// src/repl/picker.tsx
|
|
53496
53638
|
import { Box as Box3, Text as Text3 } from "ink";
|
|
53497
|
-
import { promises as
|
|
53498
|
-
import
|
|
53639
|
+
import { promises as fs50 } from "node:fs";
|
|
53640
|
+
import path51 from "node:path";
|
|
53499
53641
|
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
53500
53642
|
var MAX_VISIBLE = 12;
|
|
53501
53643
|
function Picker({
|
|
@@ -53582,10 +53724,10 @@ async function listAtPath(prefix) {
|
|
|
53582
53724
|
const lastSlash = prefix.lastIndexOf("/");
|
|
53583
53725
|
const dir = lastSlash >= 0 ? prefix.slice(0, lastSlash) : "";
|
|
53584
53726
|
const fragment = lastSlash >= 0 ? prefix.slice(lastSlash + 1) : prefix;
|
|
53585
|
-
const target =
|
|
53727
|
+
const target = path51.resolve(cwd, dir || ".");
|
|
53586
53728
|
let entries;
|
|
53587
53729
|
try {
|
|
53588
|
-
entries = await
|
|
53730
|
+
entries = await fs50.readdir(target, { withFileTypes: true });
|
|
53589
53731
|
} catch {
|
|
53590
53732
|
return [];
|
|
53591
53733
|
}
|
|
@@ -54093,8 +54235,8 @@ function EntryView({ entry }) {
|
|
|
54093
54235
|
}
|
|
54094
54236
|
|
|
54095
54237
|
// src/repl/history.ts
|
|
54096
|
-
import { promises as
|
|
54097
|
-
import
|
|
54238
|
+
import { promises as fs51 } from "node:fs";
|
|
54239
|
+
import path52 from "node:path";
|
|
54098
54240
|
var HISTORY_FILE = ".the_flow_history";
|
|
54099
54241
|
var MAX_LINES = 1e3;
|
|
54100
54242
|
var History = class _History {
|
|
@@ -54103,7 +54245,7 @@ var History = class _History {
|
|
|
54103
54245
|
static async load(cwd = process.cwd()) {
|
|
54104
54246
|
const h2 = new _History();
|
|
54105
54247
|
try {
|
|
54106
|
-
const text = await
|
|
54248
|
+
const text = await fs51.readFile(path52.join(cwd, HISTORY_FILE), "utf8");
|
|
54107
54249
|
h2.entries = text.split("\n").map((l2) => l2.trim()).filter(Boolean).slice(-MAX_LINES);
|
|
54108
54250
|
} catch {
|
|
54109
54251
|
}
|
|
@@ -54117,7 +54259,7 @@ var History = class _History {
|
|
|
54117
54259
|
this.entries.push(trimmed);
|
|
54118
54260
|
if (this.entries.length > MAX_LINES) this.entries.shift();
|
|
54119
54261
|
this.cursor = this.entries.length;
|
|
54120
|
-
await
|
|
54262
|
+
await fs51.writeFile(path52.join(cwd, HISTORY_FILE), this.entries.join("\n") + "\n").catch(() => {
|
|
54121
54263
|
});
|
|
54122
54264
|
}
|
|
54123
54265
|
/** Navigate one step backward (older). Returns null at the start. */
|
|
@@ -54150,8 +54292,8 @@ var History = class _History {
|
|
|
54150
54292
|
};
|
|
54151
54293
|
|
|
54152
54294
|
// src/binary-resolver.ts
|
|
54153
|
-
import { promises as
|
|
54154
|
-
import
|
|
54295
|
+
import { promises as fs52 } from "node:fs";
|
|
54296
|
+
import path53 from "node:path";
|
|
54155
54297
|
import os3 from "node:os";
|
|
54156
54298
|
async function resolveBinary(nameOrPath) {
|
|
54157
54299
|
if (!nameOrPath) return null;
|
|
@@ -54161,24 +54303,24 @@ async function resolveBinary(nameOrPath) {
|
|
|
54161
54303
|
for (const ext2 of exts) {
|
|
54162
54304
|
const probe = ext2 && !full.toLowerCase().endsWith(ext2) ? full + ext2 : full;
|
|
54163
54305
|
try {
|
|
54164
|
-
await
|
|
54306
|
+
await fs52.access(probe, fs52.constants.F_OK);
|
|
54165
54307
|
return probe;
|
|
54166
54308
|
} catch {
|
|
54167
54309
|
}
|
|
54168
54310
|
}
|
|
54169
54311
|
return null;
|
|
54170
54312
|
};
|
|
54171
|
-
if (
|
|
54313
|
+
if (path53.isAbsolute(nameOrPath) || nameOrPath.includes(path53.sep)) {
|
|
54172
54314
|
return await candidate(nameOrPath);
|
|
54173
54315
|
}
|
|
54174
|
-
const pathEntries = (process.env.PATH ?? "").split(
|
|
54316
|
+
const pathEntries = (process.env.PATH ?? "").split(path53.delimiter).filter(Boolean);
|
|
54175
54317
|
for (const dir of pathEntries) {
|
|
54176
|
-
const found = await candidate(
|
|
54318
|
+
const found = await candidate(path53.join(dir, nameOrPath));
|
|
54177
54319
|
if (found) return found;
|
|
54178
54320
|
}
|
|
54179
54321
|
const fallbackDirs = wellKnownBinDirs();
|
|
54180
54322
|
for (const dir of fallbackDirs) {
|
|
54181
|
-
const found = await candidate(
|
|
54323
|
+
const found = await candidate(path53.join(dir, nameOrPath));
|
|
54182
54324
|
if (found) return found;
|
|
54183
54325
|
}
|
|
54184
54326
|
return null;
|
|
@@ -54188,32 +54330,32 @@ function wellKnownBinDirs() {
|
|
|
54188
54330
|
const dirs = [];
|
|
54189
54331
|
if (process.platform === "darwin") {
|
|
54190
54332
|
dirs.push("/opt/homebrew/bin", "/usr/local/bin");
|
|
54191
|
-
dirs.push(
|
|
54333
|
+
dirs.push(path53.join(home, ".npm-global/bin"));
|
|
54192
54334
|
} else if (process.platform === "linux") {
|
|
54193
54335
|
dirs.push("/usr/local/bin", "/usr/bin");
|
|
54194
54336
|
dirs.push("/home/linuxbrew/.linuxbrew/bin");
|
|
54195
|
-
dirs.push(
|
|
54196
|
-
dirs.push(
|
|
54337
|
+
dirs.push(path53.join(home, ".npm-global/bin"));
|
|
54338
|
+
dirs.push(path53.join(home, ".local/bin"));
|
|
54197
54339
|
} else if (process.platform === "win32") {
|
|
54198
54340
|
if (process.env.APPDATA) {
|
|
54199
|
-
dirs.push(
|
|
54341
|
+
dirs.push(path53.join(process.env.APPDATA, "npm"));
|
|
54200
54342
|
}
|
|
54201
54343
|
if (process.env.ProgramFiles) {
|
|
54202
|
-
dirs.push(
|
|
54344
|
+
dirs.push(path53.join(process.env.ProgramFiles, "nodejs"));
|
|
54203
54345
|
}
|
|
54204
54346
|
if (process.env.LOCALAPPDATA) {
|
|
54205
|
-
dirs.push(
|
|
54347
|
+
dirs.push(path53.join(process.env.LOCALAPPDATA, "Programs", "gemini-cli"));
|
|
54206
54348
|
}
|
|
54207
54349
|
}
|
|
54208
54350
|
return dirs;
|
|
54209
54351
|
}
|
|
54210
54352
|
|
|
54211
54353
|
// src/config.ts
|
|
54212
|
-
import { promises as
|
|
54213
|
-
import
|
|
54354
|
+
import { promises as fs53 } from "node:fs";
|
|
54355
|
+
import path54 from "node:path";
|
|
54214
54356
|
import toml2 from "@iarna/toml";
|
|
54215
54357
|
function resolvePath(raw, base) {
|
|
54216
|
-
return
|
|
54358
|
+
return path54.isAbsolute(raw) ? raw : path54.resolve(base, raw);
|
|
54217
54359
|
}
|
|
54218
54360
|
function asString2(v2, fallback = "") {
|
|
54219
54361
|
return typeof v2 === "string" ? v2 : fallback;
|
|
@@ -54252,9 +54394,9 @@ var DEFAULT_WEB_ALLOWLIST = [
|
|
|
54252
54394
|
"developer.arm.com"
|
|
54253
54395
|
];
|
|
54254
54396
|
async function loadConfig(configPath, projectDir2 = process.cwd()) {
|
|
54255
|
-
const raw = await
|
|
54397
|
+
const raw = await fs53.readFile(configPath, "utf8");
|
|
54256
54398
|
const parsed = toml2.parse(raw);
|
|
54257
|
-
const baseDir =
|
|
54399
|
+
const baseDir = path54.dirname(path54.resolve(configPath));
|
|
54258
54400
|
const gemini = parsed.gemini ?? {};
|
|
54259
54401
|
const tools = parsed.tools ?? {};
|
|
54260
54402
|
const jlink = parsed.jlink ?? {};
|
|
@@ -54275,7 +54417,7 @@ async function loadConfig(configPath, projectDir2 = process.cwd()) {
|
|
|
54275
54417
|
const planMode = modes.plan ?? {};
|
|
54276
54418
|
const buildMode = modes.build ?? {};
|
|
54277
54419
|
const cfg = {
|
|
54278
|
-
configPath:
|
|
54420
|
+
configPath: path54.resolve(configPath),
|
|
54279
54421
|
baseDir,
|
|
54280
54422
|
gemini: {
|
|
54281
54423
|
binary: asString2(gemini.binary, "gemini"),
|
|
@@ -54503,17 +54645,17 @@ async function resolveDefaultConfig() {
|
|
|
54503
54645
|
const candidates = [];
|
|
54504
54646
|
const agenitHome = process.env.AGENIT_HOME;
|
|
54505
54647
|
const flowHome = process.env.FLOW_HOME;
|
|
54506
|
-
const here =
|
|
54507
|
-
const siblingDir =
|
|
54648
|
+
const here = path54.dirname(new URL(import.meta.url).pathname);
|
|
54649
|
+
const siblingDir = path54.resolve(here, "..", "..", "..", "..", "config");
|
|
54508
54650
|
for (const name of ["agenit.toml", "flow.toml"]) {
|
|
54509
|
-
if (agenitHome) candidates.push(
|
|
54510
|
-
if (flowHome) candidates.push(
|
|
54511
|
-
candidates.push(
|
|
54512
|
-
candidates.push(
|
|
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));
|
|
54513
54655
|
}
|
|
54514
54656
|
for (const c2 of candidates) {
|
|
54515
54657
|
try {
|
|
54516
|
-
await
|
|
54658
|
+
await fs53.access(c2);
|
|
54517
54659
|
return c2;
|
|
54518
54660
|
} catch {
|
|
54519
54661
|
}
|
|
@@ -54716,18 +54858,18 @@ async function readStdin() {
|
|
|
54716
54858
|
}
|
|
54717
54859
|
|
|
54718
54860
|
// src/update-check.ts
|
|
54719
|
-
import { promises as
|
|
54861
|
+
import { promises as fs54 } from "node:fs";
|
|
54720
54862
|
import os4 from "node:os";
|
|
54721
|
-
import
|
|
54863
|
+
import path55 from "node:path";
|
|
54722
54864
|
var DEFAULT_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
54723
54865
|
function defaultCachePath() {
|
|
54724
54866
|
const xdg = process.env.XDG_CACHE_HOME;
|
|
54725
|
-
const base = xdg ? xdg :
|
|
54726
|
-
return
|
|
54867
|
+
const base = xdg ? xdg : path55.join(os4.homedir(), ".cache");
|
|
54868
|
+
return path55.join(base, "flow", "version-check.json");
|
|
54727
54869
|
}
|
|
54728
54870
|
async function readCache(p2) {
|
|
54729
54871
|
try {
|
|
54730
|
-
const raw = await
|
|
54872
|
+
const raw = await fs54.readFile(p2, "utf8");
|
|
54731
54873
|
const parsed = JSON.parse(raw);
|
|
54732
54874
|
if (typeof parsed.checked_at === "number" && typeof parsed.installed === "string") {
|
|
54733
54875
|
return {
|
|
@@ -54743,8 +54885,8 @@ async function readCache(p2) {
|
|
|
54743
54885
|
}
|
|
54744
54886
|
async function writeCache(p2, entry) {
|
|
54745
54887
|
try {
|
|
54746
|
-
await
|
|
54747
|
-
await
|
|
54888
|
+
await fs54.mkdir(path55.dirname(p2), { recursive: true });
|
|
54889
|
+
await fs54.writeFile(p2, JSON.stringify(entry, null, 2));
|
|
54748
54890
|
} catch {
|
|
54749
54891
|
}
|
|
54750
54892
|
}
|
|
@@ -54863,7 +55005,7 @@ var SoulKeeperWorker = class {
|
|
|
54863
55005
|
|
|
54864
55006
|
// src/cli.tsx
|
|
54865
55007
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
54866
|
-
var FLOW_VERSION = "1.0.
|
|
55008
|
+
var FLOW_VERSION = "1.0.4";
|
|
54867
55009
|
var MIN_GEMINI_MAJOR = 0;
|
|
54868
55010
|
var MIN_GEMINI_MINOR = 37;
|
|
54869
55011
|
async function checkGeminiCli(cfg) {
|
|
@@ -54926,7 +55068,7 @@ Upgrade: npm install -g @google/gemini-cli@latest`
|
|
|
54926
55068
|
}
|
|
54927
55069
|
async function readActiveProject() {
|
|
54928
55070
|
try {
|
|
54929
|
-
const txt = await
|
|
55071
|
+
const txt = await fs55.readFile(".agenit_project", "utf8");
|
|
54930
55072
|
const trimmed = txt.trim();
|
|
54931
55073
|
if (!trimmed) return null;
|
|
54932
55074
|
if (trimmed.includes("=")) {
|
|
@@ -54938,7 +55080,7 @@ async function readActiveProject() {
|
|
|
54938
55080
|
} catch {
|
|
54939
55081
|
}
|
|
54940
55082
|
try {
|
|
54941
|
-
const txt = await
|
|
55083
|
+
const txt = await fs55.readFile(".flow_project", "utf8");
|
|
54942
55084
|
const trimmed = txt.trim();
|
|
54943
55085
|
return trimmed || null;
|
|
54944
55086
|
} catch {
|
|
@@ -55041,12 +55183,12 @@ async function cmdRepl(cfg) {
|
|
|
55041
55183
|
}
|
|
55042
55184
|
if (cfg.memory.soulKeeperEnabled && initialProject) {
|
|
55043
55185
|
try {
|
|
55044
|
-
const projectMemoryDir =
|
|
55186
|
+
const projectMemoryDir = path56.join(cfg.flow.memoryDir, initialProject);
|
|
55045
55187
|
getLoopWorkerPool().spawn(
|
|
55046
55188
|
new SoulKeeperWorker({
|
|
55047
55189
|
project: initialProject,
|
|
55048
55190
|
soulPath: cfg.flow.soulPath,
|
|
55049
|
-
contextPath:
|
|
55191
|
+
contextPath: path56.join(projectMemoryDir, "context.md")
|
|
55050
55192
|
}),
|
|
55051
55193
|
{ gapMs: cfg.memory.soulKeeperGapMs }
|
|
55052
55194
|
);
|
|
@@ -55113,7 +55255,7 @@ async function cmdProjects(cfg) {
|
|
|
55113
55255
|
const dir = cfg.flow.memoryDir;
|
|
55114
55256
|
let entries = [];
|
|
55115
55257
|
try {
|
|
55116
|
-
entries = await
|
|
55258
|
+
entries = await fs55.readdir(dir, { withFileTypes: true });
|
|
55117
55259
|
} catch {
|
|
55118
55260
|
return;
|
|
55119
55261
|
}
|
|
@@ -55123,34 +55265,57 @@ async function cmdProjects(cfg) {
|
|
|
55123
55265
|
}
|
|
55124
55266
|
}
|
|
55125
55267
|
async function cmdInit(cfg, projectDir2, name) {
|
|
55126
|
-
const target =
|
|
55127
|
-
const projectName = name ??
|
|
55128
|
-
const memDir =
|
|
55129
|
-
await
|
|
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 });
|
|
55130
55272
|
for (const file of ["context.md", "decisions.md", "requirements.md"]) {
|
|
55131
|
-
const p2 =
|
|
55273
|
+
const p2 = path56.join(memDir, file);
|
|
55132
55274
|
try {
|
|
55133
|
-
await
|
|
55275
|
+
await fs55.access(p2);
|
|
55134
55276
|
} catch {
|
|
55135
|
-
await
|
|
55277
|
+
await fs55.writeFile(p2, "");
|
|
55136
55278
|
}
|
|
55137
55279
|
}
|
|
55138
|
-
await
|
|
55139
|
-
|
|
55280
|
+
await fs55.writeFile(
|
|
55281
|
+
path56.join(target, ".agenit_project"),
|
|
55140
55282
|
`project = "${projectName}"
|
|
55141
55283
|
profile = "automotive"
|
|
55142
55284
|
`
|
|
55143
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
|
+
}
|
|
55144
55309
|
process.stdout.write(`\u2713 Project '${projectName}' initialized at ${target}
|
|
55145
55310
|
`);
|
|
55146
55311
|
}
|
|
55147
55312
|
async function cmdUnflow(projectDir2) {
|
|
55148
|
-
const target =
|
|
55313
|
+
const target = path56.resolve(projectDir2);
|
|
55149
55314
|
let removed = false;
|
|
55150
55315
|
for (const fname of [".agenit_project", ".flow_project"]) {
|
|
55151
|
-
const marker =
|
|
55316
|
+
const marker = path56.join(target, fname);
|
|
55152
55317
|
try {
|
|
55153
|
-
await
|
|
55318
|
+
await fs55.unlink(marker);
|
|
55154
55319
|
process.stdout.write(`\u2713 Removed ${marker}
|
|
55155
55320
|
`);
|
|
55156
55321
|
removed = true;
|