@docyrus/docyrus 0.0.45 → 0.0.48
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/agent-loader.js +1 -1
- package/agent-loader.js.map +2 -2
- package/main.js +111 -20
- package/main.js.map +3 -3
- package/package.json +1 -1
- package/resources/pi-agent/extensions/knowledge.ts +0 -153
- package/resources/pi-agent/extensions/server-auto-commit.ts +105 -0
- package/resources/pi-agent/extensions/tasks.ts +0 -226
- package/resources/pi-agent/prompts/agent-system.md +10 -5
- package/resources/pi-agent/prompts/coder-system.md +9 -8
- package/server-loader.js +207 -137
- package/server-loader.js.map +4 -4
package/server-loader.js
CHANGED
|
@@ -1228,11 +1228,11 @@ var require_commonjs3 = __commonJS({
|
|
|
1228
1228
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
1229
1229
|
};
|
|
1230
1230
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1231
|
-
var
|
|
1231
|
+
var path4 = {
|
|
1232
1232
|
win32: { sep: "\\" },
|
|
1233
1233
|
posix: { sep: "/" }
|
|
1234
1234
|
};
|
|
1235
|
-
exports2.sep = defaultPlatform === "win32" ?
|
|
1235
|
+
exports2.sep = defaultPlatform === "win32" ? path4.win32.sep : path4.posix.sep;
|
|
1236
1236
|
exports2.minimatch.sep = exports2.sep;
|
|
1237
1237
|
exports2.GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
|
|
1238
1238
|
exports2.minimatch.GLOBSTAR = exports2.GLOBSTAR;
|
|
@@ -2002,8 +2002,8 @@ var require_commonjs3 = __commonJS({
|
|
|
2002
2002
|
var require_lib = __commonJS({
|
|
2003
2003
|
"../../node_modules/.pnpm/ignore-walk@8.0.0/node_modules/ignore-walk/lib/index.js"(exports2, module2) {
|
|
2004
2004
|
"use strict";
|
|
2005
|
-
var
|
|
2006
|
-
var
|
|
2005
|
+
var fs5 = require("fs");
|
|
2006
|
+
var path4 = require("path");
|
|
2007
2007
|
var EE = require("events").EventEmitter;
|
|
2008
2008
|
var Minimatch = require_commonjs3().Minimatch;
|
|
2009
2009
|
var Walker = class _Walker extends EE {
|
|
@@ -2012,7 +2012,7 @@ var require_lib = __commonJS({
|
|
|
2012
2012
|
super(opts);
|
|
2013
2013
|
this.isSymbolicLink = opts.isSymbolicLink;
|
|
2014
2014
|
this.path = opts.path || process.cwd();
|
|
2015
|
-
this.basename =
|
|
2015
|
+
this.basename = path4.basename(this.path);
|
|
2016
2016
|
this.ignoreFiles = opts.ignoreFiles || [".ignore"];
|
|
2017
2017
|
this.ignoreRules = {};
|
|
2018
2018
|
this.parent = opts.parent || null;
|
|
@@ -2045,7 +2045,7 @@ var require_lib = __commonJS({
|
|
|
2045
2045
|
return ret;
|
|
2046
2046
|
}
|
|
2047
2047
|
start() {
|
|
2048
|
-
|
|
2048
|
+
fs5.readdir(this.path, (er, entries) => er ? this.emit("error", er) : this.onReaddir(entries));
|
|
2049
2049
|
return this;
|
|
2050
2050
|
}
|
|
2051
2051
|
isIgnoreFile(e) {
|
|
@@ -2078,8 +2078,8 @@ var require_lib = __commonJS({
|
|
|
2078
2078
|
newIg.forEach((e) => this.addIgnoreFile(e, then));
|
|
2079
2079
|
}
|
|
2080
2080
|
addIgnoreFile(file, then) {
|
|
2081
|
-
const ig =
|
|
2082
|
-
|
|
2081
|
+
const ig = path4.resolve(this.path, file);
|
|
2082
|
+
fs5.readFile(ig, "utf8", (er, data) => er ? this.emit("error", er) : this.onReadIgnoreFile(file, data, then));
|
|
2083
2083
|
}
|
|
2084
2084
|
onReadIgnoreFile(file, data, then) {
|
|
2085
2085
|
const mmopt = {
|
|
@@ -2134,13 +2134,13 @@ var require_lib = __commonJS({
|
|
|
2134
2134
|
}
|
|
2135
2135
|
stat({ entry, file, dir }, then) {
|
|
2136
2136
|
const abs = this.path + "/" + entry;
|
|
2137
|
-
|
|
2137
|
+
fs5.lstat(abs, (lstatErr, lstatResult) => {
|
|
2138
2138
|
if (lstatErr) {
|
|
2139
2139
|
this.emit("error", lstatErr);
|
|
2140
2140
|
} else {
|
|
2141
2141
|
const isSymbolicLink = lstatResult.isSymbolicLink();
|
|
2142
2142
|
if (this.follow && isSymbolicLink) {
|
|
2143
|
-
|
|
2143
|
+
fs5.stat(abs, (statErr, statResult) => {
|
|
2144
2144
|
if (statErr) {
|
|
2145
2145
|
this.emit("error", statErr);
|
|
2146
2146
|
} else {
|
|
@@ -2196,19 +2196,19 @@ var require_lib = __commonJS({
|
|
|
2196
2196
|
};
|
|
2197
2197
|
var WalkerSync = class _WalkerSync extends Walker {
|
|
2198
2198
|
start() {
|
|
2199
|
-
this.onReaddir(
|
|
2199
|
+
this.onReaddir(fs5.readdirSync(this.path));
|
|
2200
2200
|
return this;
|
|
2201
2201
|
}
|
|
2202
2202
|
addIgnoreFile(file, then) {
|
|
2203
|
-
const ig =
|
|
2204
|
-
this.onReadIgnoreFile(file,
|
|
2203
|
+
const ig = path4.resolve(this.path, file);
|
|
2204
|
+
this.onReadIgnoreFile(file, fs5.readFileSync(ig, "utf8"), then);
|
|
2205
2205
|
}
|
|
2206
2206
|
stat({ entry, file, dir }, then) {
|
|
2207
2207
|
const abs = this.path + "/" + entry;
|
|
2208
|
-
let st =
|
|
2208
|
+
let st = fs5.lstatSync(abs);
|
|
2209
2209
|
const isSymbolicLink = st.isSymbolicLink();
|
|
2210
2210
|
if (this.follow && isSymbolicLink) {
|
|
2211
|
-
st =
|
|
2211
|
+
st = fs5.statSync(abs);
|
|
2212
2212
|
}
|
|
2213
2213
|
this.onstat({ st, entry, file, dir, isSymbolicLink }, then);
|
|
2214
2214
|
}
|
|
@@ -10577,8 +10577,8 @@ function assertNonEmpty(part, name2) {
|
|
|
10577
10577
|
throw new Error("`" + name2 + "` cannot be empty");
|
|
10578
10578
|
}
|
|
10579
10579
|
}
|
|
10580
|
-
function assertPath(
|
|
10581
|
-
if (!
|
|
10580
|
+
function assertPath(path4, name2) {
|
|
10581
|
+
if (!path4) {
|
|
10582
10582
|
throw new Error("Setting `" + name2 + "` requires `path` to be set too");
|
|
10583
10583
|
}
|
|
10584
10584
|
}
|
|
@@ -10764,13 +10764,13 @@ var init_lib9 = __esm({
|
|
|
10764
10764
|
* @returns {undefined}
|
|
10765
10765
|
* Nothing.
|
|
10766
10766
|
*/
|
|
10767
|
-
set path(
|
|
10768
|
-
if (isUrl(
|
|
10769
|
-
|
|
10767
|
+
set path(path4) {
|
|
10768
|
+
if (isUrl(path4)) {
|
|
10769
|
+
path4 = (0, import_node_url.fileURLToPath)(path4);
|
|
10770
10770
|
}
|
|
10771
|
-
assertNonEmpty(
|
|
10772
|
-
if (this.path !==
|
|
10773
|
-
this.history.push(
|
|
10771
|
+
assertNonEmpty(path4, "path");
|
|
10772
|
+
if (this.path !== path4) {
|
|
10773
|
+
this.history.push(path4);
|
|
10774
10774
|
}
|
|
10775
10775
|
}
|
|
10776
10776
|
/**
|
|
@@ -12525,8 +12525,8 @@ var require_dist = __commonJS({
|
|
|
12525
12525
|
};
|
|
12526
12526
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
12527
12527
|
exports2.load = exports2.currentTarget = void 0;
|
|
12528
|
-
var
|
|
12529
|
-
var
|
|
12528
|
+
var path4 = __importStar(require("path"));
|
|
12529
|
+
var fs5 = __importStar(require("fs"));
|
|
12530
12530
|
function currentTarget() {
|
|
12531
12531
|
let os = null;
|
|
12532
12532
|
switch (process.platform) {
|
|
@@ -12591,8 +12591,8 @@ var require_dist = __commonJS({
|
|
|
12591
12591
|
return typeof header === "object" && !!header && "glibcVersionRuntime" in header;
|
|
12592
12592
|
}
|
|
12593
12593
|
function load(dirname9) {
|
|
12594
|
-
const m =
|
|
12595
|
-
return
|
|
12594
|
+
const m = path4.join(dirname9, "index.node");
|
|
12595
|
+
return fs5.existsSync(m) ? require(m) : null;
|
|
12596
12596
|
}
|
|
12597
12597
|
exports2.load = load;
|
|
12598
12598
|
}
|
|
@@ -12618,11 +12618,11 @@ var require_process = __commonJS({
|
|
|
12618
12618
|
var require_filesystem = __commonJS({
|
|
12619
12619
|
"../../node_modules/.pnpm/detect-libc@2.0.2/node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
12620
12620
|
"use strict";
|
|
12621
|
-
var
|
|
12621
|
+
var fs5 = require("fs");
|
|
12622
12622
|
var LDD_PATH = "/usr/bin/ldd";
|
|
12623
|
-
var readFileSync5 = (
|
|
12624
|
-
var readFile13 = (
|
|
12625
|
-
|
|
12623
|
+
var readFileSync5 = (path4) => fs5.readFileSync(path4, "utf-8");
|
|
12624
|
+
var readFile13 = (path4) => new Promise((resolve4, reject) => {
|
|
12625
|
+
fs5.readFile(path4, "utf-8", (err2, data) => {
|
|
12626
12626
|
if (err2) {
|
|
12627
12627
|
reject(err2);
|
|
12628
12628
|
} else {
|
|
@@ -12963,7 +12963,7 @@ var require_promise = __commonJS({
|
|
|
12963
12963
|
* @constructor
|
|
12964
12964
|
* @param {string} path - Path to the database file.
|
|
12965
12965
|
*/
|
|
12966
|
-
constructor(
|
|
12966
|
+
constructor(path4, opts) {
|
|
12967
12967
|
const encryptionCipher = opts?.encryptionCipher ?? "aes256cbc";
|
|
12968
12968
|
if (opts && opts.syncUrl) {
|
|
12969
12969
|
var authToken = "";
|
|
@@ -12977,15 +12977,15 @@ var require_promise = __commonJS({
|
|
|
12977
12977
|
const syncPeriod = opts?.syncPeriod ?? 0;
|
|
12978
12978
|
const offline = opts?.offline ?? false;
|
|
12979
12979
|
const remoteEncryptionKey = opts?.remoteEncryptionKey ?? "";
|
|
12980
|
-
this.db = databaseOpenWithSync(
|
|
12980
|
+
this.db = databaseOpenWithSync(path4, opts.syncUrl, authToken, encryptionCipher, encryptionKey, syncPeriod, offline, remoteEncryptionKey);
|
|
12981
12981
|
} else {
|
|
12982
12982
|
const authToken2 = opts?.authToken ?? "";
|
|
12983
12983
|
const encryptionKey = opts?.encryptionKey ?? "";
|
|
12984
12984
|
const timeout = opts?.timeout ?? 0;
|
|
12985
12985
|
const remoteEncryptionKey = opts?.remoteEncryptionKey ?? "";
|
|
12986
|
-
this.db = databaseOpen(
|
|
12986
|
+
this.db = databaseOpen(path4, authToken2, encryptionCipher, encryptionKey, timeout, remoteEncryptionKey);
|
|
12987
12987
|
}
|
|
12988
|
-
this.memory =
|
|
12988
|
+
this.memory = path4 === ":memory:";
|
|
12989
12989
|
this.readonly = false;
|
|
12990
12990
|
this.name = "";
|
|
12991
12991
|
this.open = true;
|
|
@@ -13921,7 +13921,7 @@ var init_dist = __esm({
|
|
|
13921
13921
|
});
|
|
13922
13922
|
|
|
13923
13923
|
// src/server/server-loader.ts
|
|
13924
|
-
var
|
|
13924
|
+
var import_node_fs11 = require("node:fs");
|
|
13925
13925
|
var import_node_url2 = require("node:url");
|
|
13926
13926
|
var import_node_path19 = require("node:path");
|
|
13927
13927
|
var import_picocolors2 = __toESM(require_picocolors());
|
|
@@ -14028,7 +14028,7 @@ var AgentEnvStore = class {
|
|
|
14028
14028
|
// src/agent/packagedExtensions.ts
|
|
14029
14029
|
var import_node_fs = require("node:fs");
|
|
14030
14030
|
var import_node_path2 = require("node:path");
|
|
14031
|
-
var SERVER_ONLY_PACKAGED_EXTENSION_NAMES = /* @__PURE__ */ new Set(["docyrus-web-browser"]);
|
|
14031
|
+
var SERVER_ONLY_PACKAGED_EXTENSION_NAMES = /* @__PURE__ */ new Set(["docyrus-web-browser", "server-auto-commit"]);
|
|
14032
14032
|
function isPackagedExtensionEntry(entryName, isDirectory) {
|
|
14033
14033
|
return isDirectory || entryName.endsWith(".ts") || entryName.endsWith(".js");
|
|
14034
14034
|
}
|
|
@@ -14171,26 +14171,26 @@ var handleParsingNestedValues = (form, key, value2) => {
|
|
|
14171
14171
|
};
|
|
14172
14172
|
|
|
14173
14173
|
// ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/utils/url.js
|
|
14174
|
-
var splitPath = (
|
|
14175
|
-
const paths =
|
|
14174
|
+
var splitPath = (path4) => {
|
|
14175
|
+
const paths = path4.split("/");
|
|
14176
14176
|
if (paths[0] === "") {
|
|
14177
14177
|
paths.shift();
|
|
14178
14178
|
}
|
|
14179
14179
|
return paths;
|
|
14180
14180
|
};
|
|
14181
14181
|
var splitRoutingPath = (routePath) => {
|
|
14182
|
-
const { groups, path:
|
|
14183
|
-
const paths = splitPath(
|
|
14182
|
+
const { groups, path: path4 } = extractGroupsFromPath(routePath);
|
|
14183
|
+
const paths = splitPath(path4);
|
|
14184
14184
|
return replaceGroupMarks(paths, groups);
|
|
14185
14185
|
};
|
|
14186
|
-
var extractGroupsFromPath = (
|
|
14186
|
+
var extractGroupsFromPath = (path4) => {
|
|
14187
14187
|
const groups = [];
|
|
14188
|
-
|
|
14188
|
+
path4 = path4.replace(/\{[^}]+\}/g, (match2, index2) => {
|
|
14189
14189
|
const mark = `@${index2}`;
|
|
14190
14190
|
groups.push([mark, match2]);
|
|
14191
14191
|
return mark;
|
|
14192
14192
|
});
|
|
14193
|
-
return { groups, path:
|
|
14193
|
+
return { groups, path: path4 };
|
|
14194
14194
|
};
|
|
14195
14195
|
var replaceGroupMarks = (paths, groups) => {
|
|
14196
14196
|
for (let i2 = groups.length - 1; i2 >= 0; i2--) {
|
|
@@ -14247,8 +14247,8 @@ var getPath = (request) => {
|
|
|
14247
14247
|
const queryIndex = url.indexOf("?", i2);
|
|
14248
14248
|
const hashIndex = url.indexOf("#", i2);
|
|
14249
14249
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
14250
|
-
const
|
|
14251
|
-
return tryDecodeURI(
|
|
14250
|
+
const path4 = url.slice(start2, end);
|
|
14251
|
+
return tryDecodeURI(path4.includes("%25") ? path4.replace(/%25/g, "%2525") : path4);
|
|
14252
14252
|
} else if (charCode === 63 || charCode === 35) {
|
|
14253
14253
|
break;
|
|
14254
14254
|
}
|
|
@@ -14265,11 +14265,11 @@ var mergePath = (base, sub, ...rest) => {
|
|
|
14265
14265
|
}
|
|
14266
14266
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
14267
14267
|
};
|
|
14268
|
-
var checkOptionalParameter = (
|
|
14269
|
-
if (
|
|
14268
|
+
var checkOptionalParameter = (path4) => {
|
|
14269
|
+
if (path4.charCodeAt(path4.length - 1) !== 63 || !path4.includes(":")) {
|
|
14270
14270
|
return null;
|
|
14271
14271
|
}
|
|
14272
|
-
const segments =
|
|
14272
|
+
const segments = path4.split("/");
|
|
14273
14273
|
const results = [];
|
|
14274
14274
|
let basePath = "";
|
|
14275
14275
|
segments.forEach((segment) => {
|
|
@@ -14410,9 +14410,9 @@ var HonoRequest = class {
|
|
|
14410
14410
|
*/
|
|
14411
14411
|
path;
|
|
14412
14412
|
bodyCache = {};
|
|
14413
|
-
constructor(request,
|
|
14413
|
+
constructor(request, path4 = "/", matchResult = [[]]) {
|
|
14414
14414
|
this.raw = request;
|
|
14415
|
-
this.path =
|
|
14415
|
+
this.path = path4;
|
|
14416
14416
|
this.#matchResult = matchResult;
|
|
14417
14417
|
this.#validatedData = {};
|
|
14418
14418
|
}
|
|
@@ -15149,8 +15149,8 @@ var Hono = class _Hono {
|
|
|
15149
15149
|
return this;
|
|
15150
15150
|
};
|
|
15151
15151
|
});
|
|
15152
|
-
this.on = (method,
|
|
15153
|
-
for (const p of [
|
|
15152
|
+
this.on = (method, path4, ...handlers) => {
|
|
15153
|
+
for (const p of [path4].flat()) {
|
|
15154
15154
|
this.#path = p;
|
|
15155
15155
|
for (const m of [method].flat()) {
|
|
15156
15156
|
handlers.map((handler2) => {
|
|
@@ -15207,8 +15207,8 @@ var Hono = class _Hono {
|
|
|
15207
15207
|
* app.route("/api", app2) // GET /api/user
|
|
15208
15208
|
* ```
|
|
15209
15209
|
*/
|
|
15210
|
-
route(
|
|
15211
|
-
const subApp = this.basePath(
|
|
15210
|
+
route(path4, app) {
|
|
15211
|
+
const subApp = this.basePath(path4);
|
|
15212
15212
|
app.routes.map((r) => {
|
|
15213
15213
|
let handler2;
|
|
15214
15214
|
if (app.errorHandler === errorHandler) {
|
|
@@ -15234,9 +15234,9 @@ var Hono = class _Hono {
|
|
|
15234
15234
|
* const api = new Hono().basePath('/api')
|
|
15235
15235
|
* ```
|
|
15236
15236
|
*/
|
|
15237
|
-
basePath(
|
|
15237
|
+
basePath(path4) {
|
|
15238
15238
|
const subApp = this.#clone();
|
|
15239
|
-
subApp._basePath = mergePath(this._basePath,
|
|
15239
|
+
subApp._basePath = mergePath(this._basePath, path4);
|
|
15240
15240
|
return subApp;
|
|
15241
15241
|
}
|
|
15242
15242
|
/**
|
|
@@ -15310,7 +15310,7 @@ var Hono = class _Hono {
|
|
|
15310
15310
|
* })
|
|
15311
15311
|
* ```
|
|
15312
15312
|
*/
|
|
15313
|
-
mount(
|
|
15313
|
+
mount(path4, applicationHandler, options) {
|
|
15314
15314
|
let replaceRequest;
|
|
15315
15315
|
let optionHandler;
|
|
15316
15316
|
if (options) {
|
|
@@ -15337,7 +15337,7 @@ var Hono = class _Hono {
|
|
|
15337
15337
|
return [c.env, executionContext];
|
|
15338
15338
|
};
|
|
15339
15339
|
replaceRequest ||= (() => {
|
|
15340
|
-
const mergedPath = mergePath(this._basePath,
|
|
15340
|
+
const mergedPath = mergePath(this._basePath, path4);
|
|
15341
15341
|
const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
|
|
15342
15342
|
return (request) => {
|
|
15343
15343
|
const url = new URL(request.url);
|
|
@@ -15352,14 +15352,14 @@ var Hono = class _Hono {
|
|
|
15352
15352
|
}
|
|
15353
15353
|
await next();
|
|
15354
15354
|
};
|
|
15355
|
-
this.#addRoute(METHOD_NAME_ALL, mergePath(
|
|
15355
|
+
this.#addRoute(METHOD_NAME_ALL, mergePath(path4, "*"), handler2);
|
|
15356
15356
|
return this;
|
|
15357
15357
|
}
|
|
15358
|
-
#addRoute(method,
|
|
15358
|
+
#addRoute(method, path4, handler2) {
|
|
15359
15359
|
method = method.toUpperCase();
|
|
15360
|
-
|
|
15361
|
-
const r = { basePath: this._basePath, path:
|
|
15362
|
-
this.router.add(method,
|
|
15360
|
+
path4 = mergePath(this._basePath, path4);
|
|
15361
|
+
const r = { basePath: this._basePath, path: path4, method, handler: handler2 };
|
|
15362
|
+
this.router.add(method, path4, [handler2, r]);
|
|
15363
15363
|
this.routes.push(r);
|
|
15364
15364
|
}
|
|
15365
15365
|
#handleError(err2, c) {
|
|
@@ -15372,10 +15372,10 @@ var Hono = class _Hono {
|
|
|
15372
15372
|
if (method === "HEAD") {
|
|
15373
15373
|
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env, "GET")))();
|
|
15374
15374
|
}
|
|
15375
|
-
const
|
|
15376
|
-
const matchResult = this.router.match(method,
|
|
15375
|
+
const path4 = this.getPath(request, { env });
|
|
15376
|
+
const matchResult = this.router.match(method, path4);
|
|
15377
15377
|
const c = new Context(request, {
|
|
15378
|
-
path:
|
|
15378
|
+
path: path4,
|
|
15379
15379
|
matchResult,
|
|
15380
15380
|
env,
|
|
15381
15381
|
executionCtx,
|
|
@@ -15475,7 +15475,7 @@ var Hono = class _Hono {
|
|
|
15475
15475
|
|
|
15476
15476
|
// ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
15477
15477
|
var emptyParam = [];
|
|
15478
|
-
function match(method,
|
|
15478
|
+
function match(method, path4) {
|
|
15479
15479
|
const matchers = this.buildAllMatchers();
|
|
15480
15480
|
const match2 = ((method2, path22) => {
|
|
15481
15481
|
const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
|
|
@@ -15491,7 +15491,7 @@ function match(method, path3) {
|
|
|
15491
15491
|
return [matcher[1][index2], match3];
|
|
15492
15492
|
});
|
|
15493
15493
|
this.match = match2;
|
|
15494
|
-
return match2(method,
|
|
15494
|
+
return match2(method, path4);
|
|
15495
15495
|
}
|
|
15496
15496
|
|
|
15497
15497
|
// ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
@@ -15606,12 +15606,12 @@ var Node = class _Node {
|
|
|
15606
15606
|
var Trie = class {
|
|
15607
15607
|
#context = { varIndex: 0 };
|
|
15608
15608
|
#root = new Node();
|
|
15609
|
-
insert(
|
|
15609
|
+
insert(path4, index2, pathErrorCheckOnly) {
|
|
15610
15610
|
const paramAssoc = [];
|
|
15611
15611
|
const groups = [];
|
|
15612
15612
|
for (let i2 = 0; ; ) {
|
|
15613
15613
|
let replaced = false;
|
|
15614
|
-
|
|
15614
|
+
path4 = path4.replace(/\{[^}]+\}/g, (m) => {
|
|
15615
15615
|
const mark = `@\\${i2}`;
|
|
15616
15616
|
groups[i2] = [mark, m];
|
|
15617
15617
|
i2++;
|
|
@@ -15622,7 +15622,7 @@ var Trie = class {
|
|
|
15622
15622
|
break;
|
|
15623
15623
|
}
|
|
15624
15624
|
}
|
|
15625
|
-
const tokens =
|
|
15625
|
+
const tokens = path4.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
15626
15626
|
for (let i2 = groups.length - 1; i2 >= 0; i2--) {
|
|
15627
15627
|
const [mark] = groups[i2];
|
|
15628
15628
|
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
@@ -15661,9 +15661,9 @@ var Trie = class {
|
|
|
15661
15661
|
// ../../node_modules/.pnpm/hono@4.12.12/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
15662
15662
|
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
|
|
15663
15663
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
15664
|
-
function buildWildcardRegExp(
|
|
15665
|
-
return wildcardRegExpCache[
|
|
15666
|
-
|
|
15664
|
+
function buildWildcardRegExp(path4) {
|
|
15665
|
+
return wildcardRegExpCache[path4] ??= new RegExp(
|
|
15666
|
+
path4 === "*" ? "" : `^${path4.replace(
|
|
15667
15667
|
/\/\*$|([.\\+*[^\]$()])/g,
|
|
15668
15668
|
(_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
|
|
15669
15669
|
)}$`
|
|
@@ -15685,17 +15685,17 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
15685
15685
|
);
|
|
15686
15686
|
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
15687
15687
|
for (let i2 = 0, j = -1, len = routesWithStaticPathFlag.length; i2 < len; i2++) {
|
|
15688
|
-
const [pathErrorCheckOnly,
|
|
15688
|
+
const [pathErrorCheckOnly, path4, handlers] = routesWithStaticPathFlag[i2];
|
|
15689
15689
|
if (pathErrorCheckOnly) {
|
|
15690
|
-
staticMap[
|
|
15690
|
+
staticMap[path4] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
15691
15691
|
} else {
|
|
15692
15692
|
j++;
|
|
15693
15693
|
}
|
|
15694
15694
|
let paramAssoc;
|
|
15695
15695
|
try {
|
|
15696
|
-
paramAssoc = trie.insert(
|
|
15696
|
+
paramAssoc = trie.insert(path4, j, pathErrorCheckOnly);
|
|
15697
15697
|
} catch (e) {
|
|
15698
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(
|
|
15698
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path4) : e;
|
|
15699
15699
|
}
|
|
15700
15700
|
if (pathErrorCheckOnly) {
|
|
15701
15701
|
continue;
|
|
@@ -15729,12 +15729,12 @@ function buildMatcherFromPreprocessedRoutes(routes) {
|
|
|
15729
15729
|
}
|
|
15730
15730
|
return [regexp, handlerMap, staticMap];
|
|
15731
15731
|
}
|
|
15732
|
-
function findMiddleware(middleware,
|
|
15732
|
+
function findMiddleware(middleware, path4) {
|
|
15733
15733
|
if (!middleware) {
|
|
15734
15734
|
return void 0;
|
|
15735
15735
|
}
|
|
15736
15736
|
for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
|
|
15737
|
-
if (buildWildcardRegExp(k).test(
|
|
15737
|
+
if (buildWildcardRegExp(k).test(path4)) {
|
|
15738
15738
|
return [...middleware[k]];
|
|
15739
15739
|
}
|
|
15740
15740
|
}
|
|
@@ -15748,7 +15748,7 @@ var RegExpRouter = class {
|
|
|
15748
15748
|
this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
15749
15749
|
this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
|
|
15750
15750
|
}
|
|
15751
|
-
add(method,
|
|
15751
|
+
add(method, path4, handler2) {
|
|
15752
15752
|
const middleware = this.#middleware;
|
|
15753
15753
|
const routes = this.#routes;
|
|
15754
15754
|
if (!middleware || !routes) {
|
|
@@ -15763,18 +15763,18 @@ var RegExpRouter = class {
|
|
|
15763
15763
|
});
|
|
15764
15764
|
});
|
|
15765
15765
|
}
|
|
15766
|
-
if (
|
|
15767
|
-
|
|
15766
|
+
if (path4 === "/*") {
|
|
15767
|
+
path4 = "*";
|
|
15768
15768
|
}
|
|
15769
|
-
const paramCount = (
|
|
15770
|
-
if (/\*$/.test(
|
|
15771
|
-
const re = buildWildcardRegExp(
|
|
15769
|
+
const paramCount = (path4.match(/\/:/g) || []).length;
|
|
15770
|
+
if (/\*$/.test(path4)) {
|
|
15771
|
+
const re = buildWildcardRegExp(path4);
|
|
15772
15772
|
if (method === METHOD_NAME_ALL) {
|
|
15773
15773
|
Object.keys(middleware).forEach((m) => {
|
|
15774
|
-
middleware[m][
|
|
15774
|
+
middleware[m][path4] ||= findMiddleware(middleware[m], path4) || findMiddleware(middleware[METHOD_NAME_ALL], path4) || [];
|
|
15775
15775
|
});
|
|
15776
15776
|
} else {
|
|
15777
|
-
middleware[method][
|
|
15777
|
+
middleware[method][path4] ||= findMiddleware(middleware[method], path4) || findMiddleware(middleware[METHOD_NAME_ALL], path4) || [];
|
|
15778
15778
|
}
|
|
15779
15779
|
Object.keys(middleware).forEach((m) => {
|
|
15780
15780
|
if (method === METHOD_NAME_ALL || method === m) {
|
|
@@ -15792,7 +15792,7 @@ var RegExpRouter = class {
|
|
|
15792
15792
|
});
|
|
15793
15793
|
return;
|
|
15794
15794
|
}
|
|
15795
|
-
const paths = checkOptionalParameter(
|
|
15795
|
+
const paths = checkOptionalParameter(path4) || [path4];
|
|
15796
15796
|
for (let i2 = 0, len = paths.length; i2 < len; i2++) {
|
|
15797
15797
|
const path22 = paths[i2];
|
|
15798
15798
|
Object.keys(routes).forEach((m) => {
|
|
@@ -15819,13 +15819,13 @@ var RegExpRouter = class {
|
|
|
15819
15819
|
const routes = [];
|
|
15820
15820
|
let hasOwnRoute = method === METHOD_NAME_ALL;
|
|
15821
15821
|
[this.#middleware, this.#routes].forEach((r) => {
|
|
15822
|
-
const ownRoute = r[method] ? Object.keys(r[method]).map((
|
|
15822
|
+
const ownRoute = r[method] ? Object.keys(r[method]).map((path4) => [path4, r[method][path4]]) : [];
|
|
15823
15823
|
if (ownRoute.length !== 0) {
|
|
15824
15824
|
hasOwnRoute ||= true;
|
|
15825
15825
|
routes.push(...ownRoute);
|
|
15826
15826
|
} else if (method !== METHOD_NAME_ALL) {
|
|
15827
15827
|
routes.push(
|
|
15828
|
-
...Object.keys(r[METHOD_NAME_ALL]).map((
|
|
15828
|
+
...Object.keys(r[METHOD_NAME_ALL]).map((path4) => [path4, r[METHOD_NAME_ALL][path4]])
|
|
15829
15829
|
);
|
|
15830
15830
|
}
|
|
15831
15831
|
});
|
|
@@ -15845,13 +15845,13 @@ var SmartRouter = class {
|
|
|
15845
15845
|
constructor(init2) {
|
|
15846
15846
|
this.#routers = init2.routers;
|
|
15847
15847
|
}
|
|
15848
|
-
add(method,
|
|
15848
|
+
add(method, path4, handler2) {
|
|
15849
15849
|
if (!this.#routes) {
|
|
15850
15850
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
15851
15851
|
}
|
|
15852
|
-
this.#routes.push([method,
|
|
15852
|
+
this.#routes.push([method, path4, handler2]);
|
|
15853
15853
|
}
|
|
15854
|
-
match(method,
|
|
15854
|
+
match(method, path4) {
|
|
15855
15855
|
if (!this.#routes) {
|
|
15856
15856
|
throw new Error("Fatal error");
|
|
15857
15857
|
}
|
|
@@ -15866,7 +15866,7 @@ var SmartRouter = class {
|
|
|
15866
15866
|
for (let i22 = 0, len2 = routes.length; i22 < len2; i22++) {
|
|
15867
15867
|
router.add(...routes[i22]);
|
|
15868
15868
|
}
|
|
15869
|
-
res = router.match(method,
|
|
15869
|
+
res = router.match(method, path4);
|
|
15870
15870
|
} catch (e) {
|
|
15871
15871
|
if (e instanceof UnsupportedPathError) {
|
|
15872
15872
|
continue;
|
|
@@ -15916,10 +15916,10 @@ var Node2 = class _Node2 {
|
|
|
15916
15916
|
}
|
|
15917
15917
|
this.#patterns = [];
|
|
15918
15918
|
}
|
|
15919
|
-
insert(method,
|
|
15919
|
+
insert(method, path4, handler2) {
|
|
15920
15920
|
this.#order = ++this.#order;
|
|
15921
15921
|
let curNode = this;
|
|
15922
|
-
const parts2 = splitRoutingPath(
|
|
15922
|
+
const parts2 = splitRoutingPath(path4);
|
|
15923
15923
|
const possibleKeys = [];
|
|
15924
15924
|
for (let i2 = 0, len = parts2.length; i2 < len; i2++) {
|
|
15925
15925
|
const p = parts2[i2];
|
|
@@ -15968,12 +15968,12 @@ var Node2 = class _Node2 {
|
|
|
15968
15968
|
}
|
|
15969
15969
|
}
|
|
15970
15970
|
}
|
|
15971
|
-
search(method,
|
|
15971
|
+
search(method, path4) {
|
|
15972
15972
|
const handlerSets = [];
|
|
15973
15973
|
this.#params = emptyParams;
|
|
15974
15974
|
const curNode = this;
|
|
15975
15975
|
let curNodes = [curNode];
|
|
15976
|
-
const parts2 = splitPath(
|
|
15976
|
+
const parts2 = splitPath(path4);
|
|
15977
15977
|
const curNodesQueue = [];
|
|
15978
15978
|
const len = parts2.length;
|
|
15979
15979
|
let partOffsets = null;
|
|
@@ -16015,13 +16015,13 @@ var Node2 = class _Node2 {
|
|
|
16015
16015
|
if (matcher instanceof RegExp) {
|
|
16016
16016
|
if (partOffsets === null) {
|
|
16017
16017
|
partOffsets = new Array(len);
|
|
16018
|
-
let offset =
|
|
16018
|
+
let offset = path4[0] === "/" ? 1 : 0;
|
|
16019
16019
|
for (let p = 0; p < len; p++) {
|
|
16020
16020
|
partOffsets[p] = offset;
|
|
16021
16021
|
offset += parts2[p].length + 1;
|
|
16022
16022
|
}
|
|
16023
16023
|
}
|
|
16024
|
-
const restPathString =
|
|
16024
|
+
const restPathString = path4.substring(partOffsets[i2]);
|
|
16025
16025
|
const m = matcher.exec(restPathString);
|
|
16026
16026
|
if (m) {
|
|
16027
16027
|
params[name2] = m[0];
|
|
@@ -16074,18 +16074,18 @@ var TrieRouter = class {
|
|
|
16074
16074
|
constructor() {
|
|
16075
16075
|
this.#node = new Node2();
|
|
16076
16076
|
}
|
|
16077
|
-
add(method,
|
|
16078
|
-
const results = checkOptionalParameter(
|
|
16077
|
+
add(method, path4, handler2) {
|
|
16078
|
+
const results = checkOptionalParameter(path4);
|
|
16079
16079
|
if (results) {
|
|
16080
16080
|
for (let i2 = 0, len = results.length; i2 < len; i2++) {
|
|
16081
16081
|
this.#node.insert(method, results[i2], handler2);
|
|
16082
16082
|
}
|
|
16083
16083
|
return;
|
|
16084
16084
|
}
|
|
16085
|
-
this.#node.insert(method,
|
|
16085
|
+
this.#node.insert(method, path4, handler2);
|
|
16086
16086
|
}
|
|
16087
|
-
match(method,
|
|
16088
|
-
return this.#node.search(method,
|
|
16087
|
+
match(method, path4) {
|
|
16088
|
+
return this.#node.search(method, path4);
|
|
16089
16089
|
}
|
|
16090
16090
|
};
|
|
16091
16091
|
|
|
@@ -18944,11 +18944,11 @@ var Module2 = (() => {
|
|
|
18944
18944
|
throw toThrow;
|
|
18945
18945
|
}, "quit_");
|
|
18946
18946
|
var scriptDirectory = "";
|
|
18947
|
-
function locateFile(
|
|
18947
|
+
function locateFile(path4) {
|
|
18948
18948
|
if (Module["locateFile"]) {
|
|
18949
|
-
return Module["locateFile"](
|
|
18949
|
+
return Module["locateFile"](path4, scriptDirectory);
|
|
18950
18950
|
}
|
|
18951
|
-
return scriptDirectory +
|
|
18951
|
+
return scriptDirectory + path4;
|
|
18952
18952
|
}
|
|
18953
18953
|
__name(locateFile, "locateFile");
|
|
18954
18954
|
var readAsync, readBinary;
|
|
@@ -23487,16 +23487,30 @@ function normalizeTaskId(featureId, type, title) {
|
|
|
23487
23487
|
function compareStrings(left, right) {
|
|
23488
23488
|
return left.localeCompare(right);
|
|
23489
23489
|
}
|
|
23490
|
+
function compareOrder(left, right) {
|
|
23491
|
+
if (left !== void 0 && right !== void 0) {
|
|
23492
|
+
return left - right;
|
|
23493
|
+
}
|
|
23494
|
+
if (left !== void 0) {
|
|
23495
|
+
return -1;
|
|
23496
|
+
}
|
|
23497
|
+
if (right !== void 0) {
|
|
23498
|
+
return 1;
|
|
23499
|
+
}
|
|
23500
|
+
return 0;
|
|
23501
|
+
}
|
|
23490
23502
|
function sortGraph(graph) {
|
|
23491
23503
|
return {
|
|
23492
23504
|
version: 1,
|
|
23493
|
-
sections: [...graph.sections].sort(
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
|
|
23498
|
-
|
|
23499
|
-
|
|
23505
|
+
sections: [...graph.sections].sort(
|
|
23506
|
+
(left, right) => compareOrder(left.order, right.order) || compareStrings(left.id, right.id)
|
|
23507
|
+
),
|
|
23508
|
+
features: [...graph.features].sort(
|
|
23509
|
+
(left, right) => compareOrder(left.order, right.order) || compareStrings(left.sectionId, right.sectionId) || compareStrings(left.title, right.title) || compareStrings(left.id, right.id)
|
|
23510
|
+
),
|
|
23511
|
+
tasks: [...graph.tasks].sort(
|
|
23512
|
+
(left, right) => compareOrder(left.order, right.order) || compareStrings(left.sectionId, right.sectionId) || compareStrings(left.featureId, right.featureId) || compareStrings(left.title, right.title) || compareStrings(left.id, right.id)
|
|
23513
|
+
)
|
|
23500
23514
|
};
|
|
23501
23515
|
}
|
|
23502
23516
|
function resolveProjectPlanDirectory(root) {
|
|
@@ -23524,14 +23538,16 @@ function parseProjectPlanGraph(rawValue) {
|
|
|
23524
23538
|
id: isNonEmptyString2(value2.id) ? value2.id.trim() : "",
|
|
23525
23539
|
title: isNonEmptyString2(value2.title) ? value2.title.trim() : "",
|
|
23526
23540
|
slug: isNonEmptyString2(value2.slug) ? value2.slug.trim() : "",
|
|
23527
|
-
summary: typeof value2.summary === "string" ? value2.summary.trim() : ""
|
|
23541
|
+
summary: typeof value2.summary === "string" ? value2.summary.trim() : "",
|
|
23542
|
+
...typeof value2.order === "number" ? { order: value2.order } : {}
|
|
23528
23543
|
})).filter((value2) => value2.id.length > 0) : [];
|
|
23529
23544
|
const features = Array.isArray(rawValue.features) ? rawValue.features.filter((value2) => isRecord3(value2)).map((value2) => ({
|
|
23530
23545
|
id: isNonEmptyString2(value2.id) ? value2.id.trim() : "",
|
|
23531
23546
|
title: isNonEmptyString2(value2.title) ? value2.title.trim() : "",
|
|
23532
23547
|
slug: isNonEmptyString2(value2.slug) ? value2.slug.trim() : "",
|
|
23533
23548
|
summary: typeof value2.summary === "string" ? value2.summary.trim() : "",
|
|
23534
|
-
sectionId: isNonEmptyString2(value2.sectionId) ? value2.sectionId.trim() : ""
|
|
23549
|
+
sectionId: isNonEmptyString2(value2.sectionId) ? value2.sectionId.trim() : "",
|
|
23550
|
+
...typeof value2.order === "number" ? { order: value2.order } : {}
|
|
23535
23551
|
})).filter((value2) => value2.id.length > 0) : [];
|
|
23536
23552
|
const tasks = Array.isArray(rawValue.tasks) ? rawValue.tasks.filter((value2) => isRecord3(value2)).map((value2) => ({
|
|
23537
23553
|
id: isNonEmptyString2(value2.id) ? value2.id.trim() : "",
|
|
@@ -23542,7 +23558,8 @@ function parseProjectPlanGraph(rawValue) {
|
|
|
23542
23558
|
status: typeof value2.status === "string" ? value2.status : "planned",
|
|
23543
23559
|
acceptanceCriteria: normalizeStringArray(value2.acceptanceCriteria),
|
|
23544
23560
|
featureId: isNonEmptyString2(value2.featureId) ? value2.featureId.trim() : "",
|
|
23545
|
-
sectionId: isNonEmptyString2(value2.sectionId) ? value2.sectionId.trim() : ""
|
|
23561
|
+
sectionId: isNonEmptyString2(value2.sectionId) ? value2.sectionId.trim() : "",
|
|
23562
|
+
...typeof value2.order === "number" ? { order: value2.order } : {}
|
|
23546
23563
|
})).filter((value2) => value2.id.length > 0) : [];
|
|
23547
23564
|
return sortGraph({
|
|
23548
23565
|
version: 1,
|
|
@@ -23912,7 +23929,8 @@ async function upsertProjectPlanSection(params) {
|
|
|
23912
23929
|
id: existing?.id || sectionId,
|
|
23913
23930
|
title: params.title.trim(),
|
|
23914
23931
|
slug,
|
|
23915
|
-
summary: params.summary?.trim() || ""
|
|
23932
|
+
summary: params.summary?.trim() || "",
|
|
23933
|
+
...params.order !== void 0 ? { order: params.order } : existing?.order !== void 0 ? { order: existing.order } : {}
|
|
23916
23934
|
};
|
|
23917
23935
|
const nextSections = existing ? graph.sections.map((section) => section.id === existing.id ? nextSection : section) : [...graph.sections, nextSection];
|
|
23918
23936
|
await writeProjectPlanFiles(params.root, {
|
|
@@ -23932,7 +23950,8 @@ async function upsertProjectPlanFeature(params) {
|
|
|
23932
23950
|
title: params.title.trim(),
|
|
23933
23951
|
slug,
|
|
23934
23952
|
summary: params.summary?.trim() || "",
|
|
23935
|
-
sectionId: params.sectionId
|
|
23953
|
+
sectionId: params.sectionId,
|
|
23954
|
+
...params.order !== void 0 ? { order: params.order } : existing?.order !== void 0 ? { order: existing.order } : {}
|
|
23936
23955
|
};
|
|
23937
23956
|
const nextFeatures = existing ? graph.features.map((feature) => feature.id === existing.id ? nextFeature : feature) : [...graph.features, nextFeature];
|
|
23938
23957
|
await writeProjectPlanFiles(params.root, {
|
|
@@ -23974,7 +23993,8 @@ async function upsertProjectPlanTask(params) {
|
|
|
23974
23993
|
status: params.status || "planned",
|
|
23975
23994
|
acceptanceCriteria: [...new Set((params.acceptanceCriteria || []).map((item) => item.trim()).filter(Boolean))],
|
|
23976
23995
|
featureId: feature.id,
|
|
23977
|
-
sectionId
|
|
23996
|
+
sectionId,
|
|
23997
|
+
...params.order !== void 0 ? { order: params.order } : existing?.order !== void 0 ? { order: existing.order } : {}
|
|
23978
23998
|
};
|
|
23979
23999
|
const nextTasks = existing ? graph.tasks.map((task) => task.id === existing.id ? nextTask : task) : [...graph.tasks, nextTask];
|
|
23980
24000
|
await writeProjectPlanFiles(params.root, {
|
|
@@ -24911,9 +24931,9 @@ async function readJsonFile2(filePath) {
|
|
|
24911
24931
|
}
|
|
24912
24932
|
}
|
|
24913
24933
|
async function loadMcpServerConfig(agentDir, cwd) {
|
|
24914
|
-
const
|
|
24934
|
+
const configPath2 = getMcpConfigPath(agentDir);
|
|
24915
24935
|
let config = { mcpServers: {} };
|
|
24916
|
-
const raw2 = await readJsonFile2(
|
|
24936
|
+
const raw2 = await readJsonFile2(configPath2);
|
|
24917
24937
|
if (raw2) {
|
|
24918
24938
|
config = parseConfigFile(raw2);
|
|
24919
24939
|
}
|
|
@@ -24937,7 +24957,7 @@ async function loadMcpServerConfig(agentDir, cwd) {
|
|
|
24937
24957
|
}
|
|
24938
24958
|
}
|
|
24939
24959
|
const projectPath = (0, import_node_path16.resolve)(cwd, PROJECT_CONFIG_NAME);
|
|
24940
|
-
if (projectPath !==
|
|
24960
|
+
if (projectPath !== configPath2) {
|
|
24941
24961
|
const projectRaw = await readJsonFile2(projectPath);
|
|
24942
24962
|
if (projectRaw) {
|
|
24943
24963
|
const validated = parseConfigFile(projectRaw);
|
|
@@ -25046,9 +25066,9 @@ async function getServerProvenance(agentDir, cwd) {
|
|
|
25046
25066
|
return provenance;
|
|
25047
25067
|
}
|
|
25048
25068
|
async function readUserConfig(agentDir) {
|
|
25049
|
-
const
|
|
25069
|
+
const configPath2 = getMcpConfigPath(agentDir);
|
|
25050
25070
|
let raw2 = {};
|
|
25051
|
-
const parsed = await readJsonFile2(
|
|
25071
|
+
const parsed = await readJsonFile2(configPath2);
|
|
25052
25072
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
25053
25073
|
raw2 = parsed;
|
|
25054
25074
|
}
|
|
@@ -25056,11 +25076,11 @@ async function readUserConfig(agentDir) {
|
|
|
25056
25076
|
return { raw: raw2, config };
|
|
25057
25077
|
}
|
|
25058
25078
|
async function writeUserConfig(agentDir, raw2) {
|
|
25059
|
-
const
|
|
25060
|
-
await (0, import_promises12.mkdir)((0, import_node_path16.dirname)(
|
|
25061
|
-
const tmpPath = `${
|
|
25079
|
+
const configPath2 = getMcpConfigPath(agentDir);
|
|
25080
|
+
await (0, import_promises12.mkdir)((0, import_node_path16.dirname)(configPath2), { recursive: true });
|
|
25081
|
+
const tmpPath = `${configPath2}.${process.pid}.tmp`;
|
|
25062
25082
|
await (0, import_promises12.writeFile)(tmpPath, JSON.stringify(raw2, null, 2) + "\n", "utf-8");
|
|
25063
|
-
await (0, import_promises12.rename)(tmpPath,
|
|
25083
|
+
await (0, import_promises12.rename)(tmpPath, configPath2);
|
|
25064
25084
|
}
|
|
25065
25085
|
async function addMcpServer(agentDir, name2, entry) {
|
|
25066
25086
|
const { raw: raw2, config } = await readUserConfig(agentDir);
|
|
@@ -25140,9 +25160,9 @@ function parseFrontmatter2(content3) {
|
|
|
25140
25160
|
const body2 = content3.slice(endIndex + 4).trimStart();
|
|
25141
25161
|
return { frontmatter: frontmatter2, body: body2 };
|
|
25142
25162
|
}
|
|
25143
|
-
async function dirExists(
|
|
25163
|
+
async function dirExists(path4) {
|
|
25144
25164
|
try {
|
|
25145
|
-
const s = await (0, import_promises13.stat)(
|
|
25165
|
+
const s = await (0, import_promises13.stat)(path4);
|
|
25146
25166
|
return s.isDirectory();
|
|
25147
25167
|
} catch {
|
|
25148
25168
|
return false;
|
|
@@ -25307,6 +25327,30 @@ async function listAllTools(params) {
|
|
|
25307
25327
|
return tools;
|
|
25308
25328
|
}
|
|
25309
25329
|
|
|
25330
|
+
// src/server/sessionConfig.ts
|
|
25331
|
+
var import_node_fs10 = require("node:fs");
|
|
25332
|
+
var path3 = __toESM(require("node:path"));
|
|
25333
|
+
var DEFAULT_CONFIG = { autoCommit: false };
|
|
25334
|
+
function configPath(agentDir, sessionId) {
|
|
25335
|
+
return path3.join(agentDir, "session-config", `${sessionId}.json`);
|
|
25336
|
+
}
|
|
25337
|
+
async function readSessionConfig(agentDir, sessionId) {
|
|
25338
|
+
try {
|
|
25339
|
+
const raw2 = await import_node_fs10.promises.readFile(configPath(agentDir, sessionId), "utf-8");
|
|
25340
|
+
return { ...DEFAULT_CONFIG, ...JSON.parse(raw2) };
|
|
25341
|
+
} catch {
|
|
25342
|
+
return { ...DEFAULT_CONFIG };
|
|
25343
|
+
}
|
|
25344
|
+
}
|
|
25345
|
+
async function writeSessionConfig(agentDir, sessionId, patch) {
|
|
25346
|
+
const dir = path3.join(agentDir, "session-config");
|
|
25347
|
+
await import_node_fs10.promises.mkdir(dir, { recursive: true });
|
|
25348
|
+
const current = await readSessionConfig(agentDir, sessionId);
|
|
25349
|
+
const next = { ...current, ...patch };
|
|
25350
|
+
await import_node_fs10.promises.writeFile(configPath(agentDir, sessionId), JSON.stringify(next, null, 2), "utf-8");
|
|
25351
|
+
return next;
|
|
25352
|
+
}
|
|
25353
|
+
|
|
25310
25354
|
// src/server/agentServer.ts
|
|
25311
25355
|
function generateMessageId() {
|
|
25312
25356
|
return `msg_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
@@ -26009,6 +26053,7 @@ async function createAgentServer(params) {
|
|
|
26009
26053
|
});
|
|
26010
26054
|
app.post("/api/sessions", async (c) => {
|
|
26011
26055
|
try {
|
|
26056
|
+
const body2 = await c.req.json().catch(() => ({}));
|
|
26012
26057
|
if (activeSession.isStreaming) {
|
|
26013
26058
|
await activeSession.abort();
|
|
26014
26059
|
await waitForIdle(activeSession);
|
|
@@ -26019,6 +26064,9 @@ async function createAgentServer(params) {
|
|
|
26019
26064
|
if (!sessionId) {
|
|
26020
26065
|
return c.json({ error: "Created session is missing an id" }, 500);
|
|
26021
26066
|
}
|
|
26067
|
+
if (body2.autoCommit !== void 0) {
|
|
26068
|
+
await writeSessionConfig(context.agentDir, sessionId, { autoCommit: body2.autoCommit });
|
|
26069
|
+
}
|
|
26022
26070
|
const sessions = await sessionManager.list();
|
|
26023
26071
|
const match2 = sessions.find((session) => session.id === sessionId);
|
|
26024
26072
|
return c.json({
|
|
@@ -26026,13 +26074,35 @@ async function createAgentServer(params) {
|
|
|
26026
26074
|
sessionId,
|
|
26027
26075
|
sessionName: match2?.name ?? null,
|
|
26028
26076
|
cwd: match2?.cwd ?? context.cwd,
|
|
26029
|
-
model: activeSession.model ? { provider: activeSession.model.provider, id: activeSession.model.id } : null
|
|
26077
|
+
model: activeSession.model ? { provider: activeSession.model.provider, id: activeSession.model.id } : null,
|
|
26078
|
+
autoCommit: body2.autoCommit ?? false
|
|
26030
26079
|
});
|
|
26031
26080
|
} catch (error) {
|
|
26032
26081
|
const message = error instanceof Error ? error.message : String(error);
|
|
26033
26082
|
return c.json({ error: message }, 500);
|
|
26034
26083
|
}
|
|
26035
26084
|
});
|
|
26085
|
+
app.get("/api/sessions/:sessionId/config", async (c) => {
|
|
26086
|
+
const sessionId = c.req.param("sessionId");
|
|
26087
|
+
try {
|
|
26088
|
+
const config = await readSessionConfig(context.agentDir, sessionId);
|
|
26089
|
+
return c.json({ sessionId, ...config });
|
|
26090
|
+
} catch (error) {
|
|
26091
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
26092
|
+
return c.json({ error: message }, 500);
|
|
26093
|
+
}
|
|
26094
|
+
});
|
|
26095
|
+
app.patch("/api/sessions/:sessionId/config", async (c) => {
|
|
26096
|
+
const sessionId = c.req.param("sessionId");
|
|
26097
|
+
try {
|
|
26098
|
+
const body2 = await c.req.json();
|
|
26099
|
+
const config = await writeSessionConfig(context.agentDir, sessionId, body2);
|
|
26100
|
+
return c.json({ ok: true, sessionId, ...config });
|
|
26101
|
+
} catch (error) {
|
|
26102
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
26103
|
+
return c.json({ error: message }, 500);
|
|
26104
|
+
}
|
|
26105
|
+
});
|
|
26036
26106
|
app.get("/api/sessions/:sessionId/messages", async (c) => {
|
|
26037
26107
|
const sessionId = c.req.param("sessionId");
|
|
26038
26108
|
try {
|
|
@@ -27788,7 +27858,7 @@ function resolvePackagedPiResourceRoot() {
|
|
|
27788
27858
|
(0, import_node_path19.resolve)(__dirname, "resources/pi-agent"),
|
|
27789
27859
|
(0, import_node_path19.resolve)(process.cwd(), "dist/apps/api-cli/resources/pi-agent")
|
|
27790
27860
|
];
|
|
27791
|
-
const resolved = candidates.find((candidate) => (0,
|
|
27861
|
+
const resolved = candidates.find((candidate) => (0, import_node_fs11.existsSync)(candidate));
|
|
27792
27862
|
if (!resolved) {
|
|
27793
27863
|
throw new Error(`Unable to locate pi agent resources. Checked: ${candidates.join(", ")}`);
|
|
27794
27864
|
}
|
|
@@ -27960,7 +28030,7 @@ async function main() {
|
|
|
27960
28030
|
port: request.port,
|
|
27961
28031
|
sessionManager: {
|
|
27962
28032
|
list: () => pi.SessionManager.list(cwd, request.sessionDir),
|
|
27963
|
-
open: (
|
|
28033
|
+
open: (path4) => pi.SessionManager.open(path4, request.sessionDir)
|
|
27964
28034
|
},
|
|
27965
28035
|
modelRegistry,
|
|
27966
28036
|
authRuntime: {
|