@bonginkan/maria 4.3.30 → 4.3.32
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/README.md +4 -4
- package/dist/READY.manifest.json +1 -1
- package/dist/bin/maria.cjs +1349 -202
- package/dist/bin/maria.cjs.map +1 -1
- package/dist/cli.cjs +1346 -199
- package/dist/cli.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/server/express-server.cjs +1 -1
- package/dist/server/express-server.js +1 -1
- package/dist/server-express.cjs +1 -1
- package/dist/server-express.cjs.map +1 -1
- package/package.json +2 -2
- package/src/slash-commands/READY.manifest.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -189,13 +189,13 @@ function getPackageJson() {
|
|
|
189
189
|
)
|
|
190
190
|
];
|
|
191
191
|
let packageJsonPath = null;
|
|
192
|
-
for (const
|
|
193
|
-
if (fs19.existsSync(
|
|
192
|
+
for (const path64 of possiblePaths) {
|
|
193
|
+
if (fs19.existsSync(path64)) {
|
|
194
194
|
try {
|
|
195
|
-
const content = fs19.readFileSync(
|
|
195
|
+
const content = fs19.readFileSync(path64, "utf-8");
|
|
196
196
|
const parsed = JSON.parse(content);
|
|
197
197
|
if (parsed.name === "@bonginkan/maria") {
|
|
198
|
-
packageJsonPath =
|
|
198
|
+
packageJsonPath = path64;
|
|
199
199
|
break;
|
|
200
200
|
}
|
|
201
201
|
} catch {
|
|
@@ -1704,7 +1704,7 @@ var init_AuthenticationManager = __esm({
|
|
|
1704
1704
|
const response = await fetch(`${this.apiBase}/api/user/profile`, {
|
|
1705
1705
|
headers: {
|
|
1706
1706
|
"Authorization": `Bearer ${tokens2.accessToken}`,
|
|
1707
|
-
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.
|
|
1707
|
+
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.32"}`
|
|
1708
1708
|
}
|
|
1709
1709
|
});
|
|
1710
1710
|
if (response.status === 401) {
|
|
@@ -2394,9 +2394,9 @@ function getDeviceId() {
|
|
|
2394
2394
|
function getSessionId() {
|
|
2395
2395
|
return global.MARIA_SESSION_ID;
|
|
2396
2396
|
}
|
|
2397
|
-
async function callApi(
|
|
2397
|
+
async function callApi(path64, init3 = {}) {
|
|
2398
2398
|
const apiBase = process.env.MARIA_API_BASE || "https://api.maria-code.ai";
|
|
2399
|
-
const fullUrl = `${apiBase}${
|
|
2399
|
+
const fullUrl = `${apiBase}${path64}`;
|
|
2400
2400
|
let tokens2 = await authManager.getValidTokens();
|
|
2401
2401
|
if (!tokens2) {
|
|
2402
2402
|
console.log(chalk40__default.default.red(ERR.AUTH_REQUIRED.msg));
|
|
@@ -2407,7 +2407,7 @@ async function callApi(path60, init3 = {}) {
|
|
|
2407
2407
|
"Authorization": `Bearer ${token}`,
|
|
2408
2408
|
"X-Device-Id": getDeviceId(),
|
|
2409
2409
|
"X-Session-Id": getSessionId() || "",
|
|
2410
|
-
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.
|
|
2410
|
+
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.32"}`,
|
|
2411
2411
|
"Content-Type": init3.headers?.["Content-Type"] || "application/json"
|
|
2412
2412
|
});
|
|
2413
2413
|
const doFetch = async (token) => {
|
|
@@ -2465,8 +2465,8 @@ async function callApi(path60, init3 = {}) {
|
|
|
2465
2465
|
}
|
|
2466
2466
|
return response;
|
|
2467
2467
|
}
|
|
2468
|
-
async function callApiJson(
|
|
2469
|
-
const response = await callApi(
|
|
2468
|
+
async function callApiJson(path64, init3 = {}) {
|
|
2469
|
+
const response = await callApi(path64, init3);
|
|
2470
2470
|
if (!response.ok) {
|
|
2471
2471
|
const error2 = await response.json().catch(() => ({
|
|
2472
2472
|
message: `API error: ${response.status} ${response.statusText}`
|
|
@@ -7954,12 +7954,12 @@ var init_esm4 = __esm({
|
|
|
7954
7954
|
/**
|
|
7955
7955
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
7956
7956
|
*/
|
|
7957
|
-
resolve(
|
|
7958
|
-
if (!
|
|
7957
|
+
resolve(path64) {
|
|
7958
|
+
if (!path64) {
|
|
7959
7959
|
return this;
|
|
7960
7960
|
}
|
|
7961
|
-
const rootPath = this.getRootString(
|
|
7962
|
-
const dir =
|
|
7961
|
+
const rootPath = this.getRootString(path64);
|
|
7962
|
+
const dir = path64.substring(rootPath.length);
|
|
7963
7963
|
const dirParts = dir.split(this.splitSep);
|
|
7964
7964
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
7965
7965
|
return result;
|
|
@@ -8711,8 +8711,8 @@ var init_esm4 = __esm({
|
|
|
8711
8711
|
/**
|
|
8712
8712
|
* @internal
|
|
8713
8713
|
*/
|
|
8714
|
-
getRootString(
|
|
8715
|
-
return path10.win32.parse(
|
|
8714
|
+
getRootString(path64) {
|
|
8715
|
+
return path10.win32.parse(path64).root;
|
|
8716
8716
|
}
|
|
8717
8717
|
/**
|
|
8718
8718
|
* @internal
|
|
@@ -8758,8 +8758,8 @@ var init_esm4 = __esm({
|
|
|
8758
8758
|
/**
|
|
8759
8759
|
* @internal
|
|
8760
8760
|
*/
|
|
8761
|
-
getRootString(
|
|
8762
|
-
return
|
|
8761
|
+
getRootString(path64) {
|
|
8762
|
+
return path64.startsWith("/") ? "/" : "";
|
|
8763
8763
|
}
|
|
8764
8764
|
/**
|
|
8765
8765
|
* @internal
|
|
@@ -8808,8 +8808,8 @@ var init_esm4 = __esm({
|
|
|
8808
8808
|
*
|
|
8809
8809
|
* @internal
|
|
8810
8810
|
*/
|
|
8811
|
-
constructor(cwd2 = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
8812
|
-
this.#fs = fsFromOption(
|
|
8811
|
+
constructor(cwd2 = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs51 = defaultFS } = {}) {
|
|
8812
|
+
this.#fs = fsFromOption(fs51);
|
|
8813
8813
|
if (cwd2 instanceof URL || cwd2.startsWith("file://")) {
|
|
8814
8814
|
cwd2 = url.fileURLToPath(cwd2);
|
|
8815
8815
|
}
|
|
@@ -8848,11 +8848,11 @@ var init_esm4 = __esm({
|
|
|
8848
8848
|
/**
|
|
8849
8849
|
* Get the depth of a provided path, string, or the cwd
|
|
8850
8850
|
*/
|
|
8851
|
-
depth(
|
|
8852
|
-
if (typeof
|
|
8853
|
-
|
|
8851
|
+
depth(path64 = this.cwd) {
|
|
8852
|
+
if (typeof path64 === "string") {
|
|
8853
|
+
path64 = this.cwd.resolve(path64);
|
|
8854
8854
|
}
|
|
8855
|
-
return
|
|
8855
|
+
return path64.depth();
|
|
8856
8856
|
}
|
|
8857
8857
|
/**
|
|
8858
8858
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -9339,9 +9339,9 @@ var init_esm4 = __esm({
|
|
|
9339
9339
|
process11();
|
|
9340
9340
|
return results;
|
|
9341
9341
|
}
|
|
9342
|
-
chdir(
|
|
9342
|
+
chdir(path64 = this.cwd) {
|
|
9343
9343
|
const oldCwd = this.cwd;
|
|
9344
|
-
this.cwd = typeof
|
|
9344
|
+
this.cwd = typeof path64 === "string" ? this.cwd.resolve(path64) : path64;
|
|
9345
9345
|
this.cwd[setAsCwd](oldCwd);
|
|
9346
9346
|
}
|
|
9347
9347
|
};
|
|
@@ -9367,8 +9367,8 @@ var init_esm4 = __esm({
|
|
|
9367
9367
|
/**
|
|
9368
9368
|
* @internal
|
|
9369
9369
|
*/
|
|
9370
|
-
newRoot(
|
|
9371
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
9370
|
+
newRoot(fs51) {
|
|
9371
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs51 });
|
|
9372
9372
|
}
|
|
9373
9373
|
/**
|
|
9374
9374
|
* Return true if the provided path string is an absolute path
|
|
@@ -9396,8 +9396,8 @@ var init_esm4 = __esm({
|
|
|
9396
9396
|
/**
|
|
9397
9397
|
* @internal
|
|
9398
9398
|
*/
|
|
9399
|
-
newRoot(
|
|
9400
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
9399
|
+
newRoot(fs51) {
|
|
9400
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs51 });
|
|
9401
9401
|
}
|
|
9402
9402
|
/**
|
|
9403
9403
|
* Return true if the provided path string is an absolute path
|
|
@@ -9716,8 +9716,8 @@ var init_processor = __esm({
|
|
|
9716
9716
|
}
|
|
9717
9717
|
// match, absolute, ifdir
|
|
9718
9718
|
entries() {
|
|
9719
|
-
return [...this.store.entries()].map(([
|
|
9720
|
-
|
|
9719
|
+
return [...this.store.entries()].map(([path64, n]) => [
|
|
9720
|
+
path64,
|
|
9721
9721
|
!!(n & 2),
|
|
9722
9722
|
!!(n & 1)
|
|
9723
9723
|
]);
|
|
@@ -9930,9 +9930,9 @@ var init_walker = __esm({
|
|
|
9930
9930
|
signal;
|
|
9931
9931
|
maxDepth;
|
|
9932
9932
|
includeChildMatches;
|
|
9933
|
-
constructor(patterns,
|
|
9933
|
+
constructor(patterns, path64, opts) {
|
|
9934
9934
|
this.patterns = patterns;
|
|
9935
|
-
this.path =
|
|
9935
|
+
this.path = path64;
|
|
9936
9936
|
this.opts = opts;
|
|
9937
9937
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
9938
9938
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -9951,11 +9951,11 @@ var init_walker = __esm({
|
|
|
9951
9951
|
});
|
|
9952
9952
|
}
|
|
9953
9953
|
}
|
|
9954
|
-
#ignored(
|
|
9955
|
-
return this.seen.has(
|
|
9954
|
+
#ignored(path64) {
|
|
9955
|
+
return this.seen.has(path64) || !!this.#ignore?.ignored?.(path64);
|
|
9956
9956
|
}
|
|
9957
|
-
#childrenIgnored(
|
|
9958
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
9957
|
+
#childrenIgnored(path64) {
|
|
9958
|
+
return !!this.#ignore?.childrenIgnored?.(path64);
|
|
9959
9959
|
}
|
|
9960
9960
|
// backpressure mechanism
|
|
9961
9961
|
pause() {
|
|
@@ -10170,8 +10170,8 @@ var init_walker = __esm({
|
|
|
10170
10170
|
};
|
|
10171
10171
|
GlobWalker = class extends GlobUtil {
|
|
10172
10172
|
matches = /* @__PURE__ */ new Set();
|
|
10173
|
-
constructor(patterns,
|
|
10174
|
-
super(patterns,
|
|
10173
|
+
constructor(patterns, path64, opts) {
|
|
10174
|
+
super(patterns, path64, opts);
|
|
10175
10175
|
}
|
|
10176
10176
|
matchEmit(e2) {
|
|
10177
10177
|
this.matches.add(e2);
|
|
@@ -10208,8 +10208,8 @@ var init_walker = __esm({
|
|
|
10208
10208
|
};
|
|
10209
10209
|
GlobStream = class extends GlobUtil {
|
|
10210
10210
|
results;
|
|
10211
|
-
constructor(patterns,
|
|
10212
|
-
super(patterns,
|
|
10211
|
+
constructor(patterns, path64, opts) {
|
|
10212
|
+
super(patterns, path64, opts);
|
|
10213
10213
|
this.results = new Minipass({
|
|
10214
10214
|
signal: this.signal,
|
|
10215
10215
|
objectMode: true
|
|
@@ -15964,9 +15964,9 @@ var init_SafetyGuard = __esm({
|
|
|
15964
15964
|
}
|
|
15965
15965
|
}
|
|
15966
15966
|
if (action.args.paths && Array.isArray(action.args.paths)) {
|
|
15967
|
-
for (const
|
|
15968
|
-
if (!this.validatePath(
|
|
15969
|
-
violations.push(`Invalid path: ${
|
|
15967
|
+
for (const path64 of action.args.paths) {
|
|
15968
|
+
if (!this.validatePath(path64)) {
|
|
15969
|
+
violations.push(`Invalid path: ${path64}`);
|
|
15970
15970
|
}
|
|
15971
15971
|
}
|
|
15972
15972
|
}
|
|
@@ -16022,15 +16022,15 @@ var init_SafetyGuard = __esm({
|
|
|
16022
16022
|
* Validate file path against allowed/blocked lists
|
|
16023
16023
|
*/
|
|
16024
16024
|
validatePath(filePath) {
|
|
16025
|
-
const
|
|
16026
|
-
const resolvedPath =
|
|
16025
|
+
const path64 = __require("path");
|
|
16026
|
+
const resolvedPath = path64.resolve(filePath);
|
|
16027
16027
|
for (const blockedPath of this.constraints.blockedPaths) {
|
|
16028
|
-
if (resolvedPath.startsWith(
|
|
16028
|
+
if (resolvedPath.startsWith(path64.resolve(blockedPath))) {
|
|
16029
16029
|
return false;
|
|
16030
16030
|
}
|
|
16031
16031
|
}
|
|
16032
16032
|
for (const allowedPath of this.constraints.allowedPaths) {
|
|
16033
|
-
if (resolvedPath.startsWith(
|
|
16033
|
+
if (resolvedPath.startsWith(path64.resolve(allowedPath))) {
|
|
16034
16034
|
return true;
|
|
16035
16035
|
}
|
|
16036
16036
|
}
|
|
@@ -16059,9 +16059,9 @@ var init_SafetyGuard = __esm({
|
|
|
16059
16059
|
violations.push(`Invalid path in ${action.type}: ${action.args.path}`);
|
|
16060
16060
|
}
|
|
16061
16061
|
if (action.args.paths && Array.isArray(action.args.paths)) {
|
|
16062
|
-
for (const
|
|
16063
|
-
if (!this.validatePath(
|
|
16064
|
-
violations.push(`Invalid path in ${action.type}: ${
|
|
16062
|
+
for (const path64 of action.args.paths) {
|
|
16063
|
+
if (!this.validatePath(path64)) {
|
|
16064
|
+
violations.push(`Invalid path in ${action.type}: ${path64}`);
|
|
16065
16065
|
}
|
|
16066
16066
|
}
|
|
16067
16067
|
}
|
|
@@ -16121,8 +16121,8 @@ var require_package = __commonJS({
|
|
|
16121
16121
|
"package.json"(exports, module) {
|
|
16122
16122
|
module.exports = {
|
|
16123
16123
|
name: "@bonginkan/maria",
|
|
16124
|
-
version: "4.3.
|
|
16125
|
-
description: "\u{1F680} MARIA v4.3.
|
|
16124
|
+
version: "4.3.32",
|
|
16125
|
+
description: "\u{1F680} MARIA v4.3.32 - Enterprise AI Development Platform with identity system and character voice implementation. Features 74 production-ready commands with comprehensive fallback implementation, local LLM support, and zero external dependencies. Includes natural language coding, AI safety evaluation, intelligent evolution system, episodic memory with PII masking, and real-time monitoring dashboard. Built with TypeScript AST-powered code generation, OAuth2.0 + PKCE authentication, quantum-resistant cryptography, and enterprise-grade performance.",
|
|
16126
16126
|
keywords: [
|
|
16127
16127
|
"ai",
|
|
16128
16128
|
"cli",
|
|
@@ -17556,8 +17556,8 @@ var init_ConfigActionExecutor = __esm({
|
|
|
17556
17556
|
/**
|
|
17557
17557
|
* Set nested configuration value using dot notation
|
|
17558
17558
|
*/
|
|
17559
|
-
setNestedValue(obj,
|
|
17560
|
-
const keys =
|
|
17559
|
+
setNestedValue(obj, path64, value) {
|
|
17560
|
+
const keys = path64.split(".");
|
|
17561
17561
|
let current = obj;
|
|
17562
17562
|
for (let i2 = 0; i2 < keys.length - 1; i2++) {
|
|
17563
17563
|
const key = keys[i2];
|
|
@@ -25817,7 +25817,7 @@ var init_about_command = __esm({
|
|
|
25817
25817
|
async execute(args2, context2) {
|
|
25818
25818
|
const output3 = [];
|
|
25819
25819
|
output3.push("");
|
|
25820
|
-
output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.
|
|
25820
|
+
output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.32"));
|
|
25821
25821
|
output3.push(chalk40__default.default.gray("\u2550".repeat(40)));
|
|
25822
25822
|
output3.push("");
|
|
25823
25823
|
output3.push(chalk40__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
|
|
@@ -28598,22 +28598,22 @@ function dataUriToBuffer(uri) {
|
|
|
28598
28598
|
if (firstComma === -1 || firstComma <= 4) {
|
|
28599
28599
|
throw new TypeError("malformed data: URI");
|
|
28600
28600
|
}
|
|
28601
|
-
const
|
|
28601
|
+
const meta27 = uri.substring(5, firstComma).split(";");
|
|
28602
28602
|
let charset = "";
|
|
28603
28603
|
let base64 = false;
|
|
28604
|
-
const type =
|
|
28604
|
+
const type = meta27[0] || "text/plain";
|
|
28605
28605
|
let typeFull = type;
|
|
28606
|
-
for (let i2 = 1; i2 <
|
|
28607
|
-
if (
|
|
28606
|
+
for (let i2 = 1; i2 < meta27.length; i2++) {
|
|
28607
|
+
if (meta27[i2] === "base64") {
|
|
28608
28608
|
base64 = true;
|
|
28609
|
-
} else if (
|
|
28610
|
-
typeFull += `;${
|
|
28611
|
-
if (
|
|
28612
|
-
charset =
|
|
28609
|
+
} else if (meta27[i2]) {
|
|
28610
|
+
typeFull += `;${meta27[i2]}`;
|
|
28611
|
+
if (meta27[i2].indexOf("charset=") === 0) {
|
|
28612
|
+
charset = meta27[i2].substring(8);
|
|
28613
28613
|
}
|
|
28614
28614
|
}
|
|
28615
28615
|
}
|
|
28616
|
-
if (!
|
|
28616
|
+
if (!meta27[0] && !charset.length) {
|
|
28617
28617
|
typeFull += ";charset=US-ASCII";
|
|
28618
28618
|
charset = "US-ASCII";
|
|
28619
28619
|
}
|
|
@@ -33387,22 +33387,22 @@ var init_from = __esm({
|
|
|
33387
33387
|
init_file();
|
|
33388
33388
|
init_fetch_blob();
|
|
33389
33389
|
({ stat: stat9 } = fs19.promises);
|
|
33390
|
-
blobFromSync = (
|
|
33391
|
-
blobFrom = (
|
|
33392
|
-
fileFrom = (
|
|
33393
|
-
fileFromSync = (
|
|
33394
|
-
fromBlob = (stat13,
|
|
33395
|
-
path:
|
|
33390
|
+
blobFromSync = (path64, type) => fromBlob(fs19.statSync(path64), path64, type);
|
|
33391
|
+
blobFrom = (path64, type) => stat9(path64).then((stat13) => fromBlob(stat13, path64, type));
|
|
33392
|
+
fileFrom = (path64, type) => stat9(path64).then((stat13) => fromFile(stat13, path64, type));
|
|
33393
|
+
fileFromSync = (path64, type) => fromFile(fs19.statSync(path64), path64, type);
|
|
33394
|
+
fromBlob = (stat13, path64, type = "") => new fetch_blob_default([new BlobDataItem({
|
|
33395
|
+
path: path64,
|
|
33396
33396
|
size: stat13.size,
|
|
33397
33397
|
lastModified: stat13.mtimeMs,
|
|
33398
33398
|
start: 0
|
|
33399
33399
|
})], { type });
|
|
33400
|
-
fromFile = (stat13,
|
|
33401
|
-
path:
|
|
33400
|
+
fromFile = (stat13, path64, type = "") => new file_default([new BlobDataItem({
|
|
33401
|
+
path: path64,
|
|
33402
33402
|
size: stat13.size,
|
|
33403
33403
|
lastModified: stat13.mtimeMs,
|
|
33404
33404
|
start: 0
|
|
33405
|
-
})], path10.basename(
|
|
33405
|
+
})], path10.basename(path64), { type, lastModified: stat13.mtimeMs });
|
|
33406
33406
|
BlobDataItem = class _BlobDataItem {
|
|
33407
33407
|
#path;
|
|
33408
33408
|
#start;
|
|
@@ -37171,12 +37171,12 @@ ${this.toYamlLike(value, indent + 1)}`;
|
|
|
37171
37171
|
}
|
|
37172
37172
|
static async loadFromFile(configPath) {
|
|
37173
37173
|
const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
37174
|
-
const
|
|
37174
|
+
const fs51 = await importNodeBuiltin2("fs");
|
|
37175
37175
|
const _path = await importNodeBuiltin2("_path");
|
|
37176
37176
|
const os23 = await importNodeBuiltin2("os");
|
|
37177
37177
|
const targetPath = configPath || _path.join(os23.homedir(), ".maria", "config.json");
|
|
37178
37178
|
try {
|
|
37179
|
-
const data = await
|
|
37179
|
+
const data = await fs51.promises.readFile(targetPath, "utf-8");
|
|
37180
37180
|
return JSON.parse(data);
|
|
37181
37181
|
} catch (innerError) {
|
|
37182
37182
|
if (innerError?.code === "ENOENT") {
|
|
@@ -37190,25 +37190,25 @@ ${this.toYamlLike(value, indent + 1)}`;
|
|
|
37190
37190
|
}
|
|
37191
37191
|
async save(configPath, options) {
|
|
37192
37192
|
const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
37193
|
-
const
|
|
37193
|
+
const fs51 = await importNodeBuiltin2("fs");
|
|
37194
37194
|
const _path = await importNodeBuiltin2("_path");
|
|
37195
37195
|
const os23 = await importNodeBuiltin2("os");
|
|
37196
37196
|
const targetPath = configPath || _path.join(os23.homedir(), ".maria", "config.json");
|
|
37197
37197
|
try {
|
|
37198
37198
|
if (options?.backup) {
|
|
37199
37199
|
try {
|
|
37200
|
-
await
|
|
37200
|
+
await fs51.promises.access(targetPath);
|
|
37201
37201
|
const backupPath = `${targetPath}.backup.${Date.now()}`;
|
|
37202
|
-
await
|
|
37202
|
+
await fs51.promises.copyFile(targetPath, backupPath);
|
|
37203
37203
|
} catch {
|
|
37204
37204
|
}
|
|
37205
37205
|
}
|
|
37206
|
-
await
|
|
37206
|
+
await fs51.promises.mkdir(_path.dirname(targetPath), { recursive: true });
|
|
37207
37207
|
const dataToSave = this.getAll({
|
|
37208
37208
|
maskSensitive: options?.maskSensitive ?? true,
|
|
37209
37209
|
includeSourceMap: options?.includeSourceMap ?? false
|
|
37210
37210
|
});
|
|
37211
|
-
await
|
|
37211
|
+
await fs51.promises.writeFile(
|
|
37212
37212
|
targetPath,
|
|
37213
37213
|
JSON.stringify(dataToSave, null, 2),
|
|
37214
37214
|
{ mode: 384 }
|
|
@@ -37252,12 +37252,12 @@ ${this.toYamlLike(value, indent + 1)}`;
|
|
|
37252
37252
|
}
|
|
37253
37253
|
if (outputPath) {
|
|
37254
37254
|
const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
37255
|
-
const
|
|
37255
|
+
const fs51 = await importNodeBuiltin2("fs");
|
|
37256
37256
|
const _path = await importNodeBuiltin2(
|
|
37257
37257
|
"_path"
|
|
37258
37258
|
);
|
|
37259
|
-
await
|
|
37260
|
-
await
|
|
37259
|
+
await fs51.promises.mkdir(_path.dirname(outputPath), { recursive: true });
|
|
37260
|
+
await fs51.promises.writeFile(outputPath, content, "utf-8");
|
|
37261
37261
|
console.log(`\u2705 Configuration exported to ${outputPath}`);
|
|
37262
37262
|
}
|
|
37263
37263
|
return content;
|
|
@@ -38061,10 +38061,10 @@ function suggestName(fp, p) {
|
|
|
38061
38061
|
const base = (fp.description || "file").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
38062
38062
|
return base || "file";
|
|
38063
38063
|
}
|
|
38064
|
-
function guessKindByPath(
|
|
38065
|
-
if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(
|
|
38066
|
-
if (/^docs\//.test(
|
|
38067
|
-
if (/\.(json|cjs|js|ts)$/.test(
|
|
38064
|
+
function guessKindByPath(path64) {
|
|
38065
|
+
if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(path64)) return "test";
|
|
38066
|
+
if (/^docs\//.test(path64) || /\.md$/.test(path64)) return "doc";
|
|
38067
|
+
if (/\.(json|cjs|js|ts)$/.test(path64) && !/src\//.test(path64)) return "config";
|
|
38068
38068
|
return "source";
|
|
38069
38069
|
}
|
|
38070
38070
|
var init_PathInferencer = __esm({
|
|
@@ -38324,9 +38324,9 @@ function formatPlanAsDiff(files, opts) {
|
|
|
38324
38324
|
function readCurrentFileSafe(root, rel, abs) {
|
|
38325
38325
|
if (!root && !abs) return "";
|
|
38326
38326
|
try {
|
|
38327
|
-
const
|
|
38327
|
+
const fs51 = __require("fs");
|
|
38328
38328
|
const p = abs ? abs : __require("path").join(root, rel);
|
|
38329
|
-
return
|
|
38329
|
+
return fs51.existsSync(p) ? fs51.readFileSync(p, "utf8") : "";
|
|
38330
38330
|
} catch {
|
|
38331
38331
|
return "";
|
|
38332
38332
|
}
|
|
@@ -39199,9 +39199,9 @@ ${editContext}`;
|
|
|
39199
39199
|
for (let i2 = 0; i2 < blocks.length; i2++) {
|
|
39200
39200
|
const b = blocks[i2];
|
|
39201
39201
|
const desired = typeof b.filename === "string" && b.filename.trim() ? b.filename.trim() : null;
|
|
39202
|
-
const
|
|
39202
|
+
const path64 = desired || suggestName2(request, b.language, i2);
|
|
39203
39203
|
initial.push({
|
|
39204
|
-
path:
|
|
39204
|
+
path: path64,
|
|
39205
39205
|
kind: "source",
|
|
39206
39206
|
action: "create",
|
|
39207
39207
|
description: describe2(b.language, ""),
|
|
@@ -39232,13 +39232,13 @@ ${editContext}`;
|
|
|
39232
39232
|
{ root: opts.root }
|
|
39233
39233
|
);
|
|
39234
39234
|
try {
|
|
39235
|
-
const [{ access: access18 },
|
|
39235
|
+
const [{ access: access18 }, path64] = await Promise.all([
|
|
39236
39236
|
import('fs/promises'),
|
|
39237
39237
|
import('path')
|
|
39238
39238
|
]);
|
|
39239
39239
|
for (const p of normalized) {
|
|
39240
39240
|
try {
|
|
39241
|
-
const absCandidate = p.absPath ? p.absPath :
|
|
39241
|
+
const absCandidate = p.absPath ? p.absPath : path64.join(opts.root, p.path);
|
|
39242
39242
|
await access18(absCandidate);
|
|
39243
39243
|
p.action = "modify";
|
|
39244
39244
|
if (isEditIntent) {
|
|
@@ -39430,12 +39430,12 @@ function languageExt(lang) {
|
|
|
39430
39430
|
}
|
|
39431
39431
|
async function journalResume(root, request, files) {
|
|
39432
39432
|
try {
|
|
39433
|
-
const
|
|
39433
|
+
const fs51 = await import('fs/promises');
|
|
39434
39434
|
const dir = path10__namespace.default.join(root, ".maria", "memory");
|
|
39435
|
-
await
|
|
39435
|
+
await fs51.mkdir(dir, { recursive: true });
|
|
39436
39436
|
const out = path10__namespace.default.join(dir, "resume-plan.json");
|
|
39437
39437
|
const payload = { request, createdAt: (/* @__PURE__ */ new Date()).toISOString(), files };
|
|
39438
|
-
await
|
|
39438
|
+
await fs51.writeFile(out, JSON.stringify(payload, null, 2), "utf8");
|
|
39439
39439
|
} catch {
|
|
39440
39440
|
}
|
|
39441
39441
|
}
|
|
@@ -39595,14 +39595,14 @@ async function ensureTopFolder(root, proposed, plans) {
|
|
|
39595
39595
|
return { folderName: unique };
|
|
39596
39596
|
}
|
|
39597
39597
|
async function ensureUniqueFolder(root, base) {
|
|
39598
|
-
const
|
|
39598
|
+
const fs51 = await import('fs/promises');
|
|
39599
39599
|
const pathMod = await import('path');
|
|
39600
39600
|
let name2 = sanitizeFolderName(base);
|
|
39601
39601
|
let suffix = 0;
|
|
39602
39602
|
for (; suffix < Number.MAX_SAFE_INTEGER; ) {
|
|
39603
39603
|
const candidate = suffix === 0 ? name2 : `${name2}-${String(suffix).padStart(2, "0")}`;
|
|
39604
39604
|
try {
|
|
39605
|
-
await
|
|
39605
|
+
await fs51.access(pathMod.join(root, candidate));
|
|
39606
39606
|
suffix += 1;
|
|
39607
39607
|
} catch {
|
|
39608
39608
|
return candidate;
|
|
@@ -39612,13 +39612,13 @@ async function ensureUniqueFolder(root, base) {
|
|
|
39612
39612
|
}
|
|
39613
39613
|
async function buildEditContext(root, files, maxLines, maxBytes) {
|
|
39614
39614
|
try {
|
|
39615
|
-
const
|
|
39615
|
+
const fs51 = await import('fs/promises');
|
|
39616
39616
|
const pathMod = await import('path');
|
|
39617
39617
|
const sections = [];
|
|
39618
39618
|
for (const rel of files) {
|
|
39619
39619
|
const full = pathMod.join(root, rel);
|
|
39620
39620
|
try {
|
|
39621
|
-
const buf = await
|
|
39621
|
+
const buf = await fs51.readFile(full);
|
|
39622
39622
|
const clipped = buf.length > maxBytes ? buf.subarray(0, maxBytes) : buf;
|
|
39623
39623
|
const text = clipped.toString("utf8").replace(/\r\n/g, "\n");
|
|
39624
39624
|
const lines = text.split("\n").slice(0, maxLines).join("\n");
|
|
@@ -39635,7 +39635,7 @@ ${lines}
|
|
|
39635
39635
|
}
|
|
39636
39636
|
}
|
|
39637
39637
|
async function resolveExplicitPaths(root, files, hintText) {
|
|
39638
|
-
const
|
|
39638
|
+
const fs51 = await import('fs/promises');
|
|
39639
39639
|
const pathMod = await import('path');
|
|
39640
39640
|
const { loadGlobby: loadGlobby2 } = await Promise.resolve().then(() => (init_esm_compat(), esm_compat_exports));
|
|
39641
39641
|
const globby = await loadGlobby2();
|
|
@@ -39653,7 +39653,7 @@ async function resolveExplicitPaths(root, files, hintText) {
|
|
|
39653
39653
|
const normalized = rel.replace(/^\/+/, "").replace(/\\/g, "/");
|
|
39654
39654
|
const fullExact = pathMod.join(root, normalized);
|
|
39655
39655
|
try {
|
|
39656
|
-
await
|
|
39656
|
+
await fs51.access(fullExact);
|
|
39657
39657
|
return normalized;
|
|
39658
39658
|
} catch {
|
|
39659
39659
|
}
|
|
@@ -39700,7 +39700,7 @@ async function resolveExplicitPaths(root, files, hintText) {
|
|
|
39700
39700
|
for (const pre of prefixes) {
|
|
39701
39701
|
const cand = pathMod.join(root, pre + normalized);
|
|
39702
39702
|
try {
|
|
39703
|
-
await
|
|
39703
|
+
await fs51.access(cand);
|
|
39704
39704
|
return (pre + normalized).replace(/^\/+/, "");
|
|
39705
39705
|
} catch {
|
|
39706
39706
|
}
|
|
@@ -39755,14 +39755,14 @@ async function resolveExplicitPaths(root, files, hintText) {
|
|
|
39755
39755
|
return out;
|
|
39756
39756
|
}
|
|
39757
39757
|
async function pickExistingFolderPrefix(root, parentPath) {
|
|
39758
|
-
const
|
|
39758
|
+
const fs51 = await import('fs/promises');
|
|
39759
39759
|
const pathMod = await import('path');
|
|
39760
39760
|
const parts = parentPath.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
39761
39761
|
const prefixes = ["src", "app", "pages", ""];
|
|
39762
39762
|
for (const pre of prefixes) {
|
|
39763
39763
|
const test = pre ? pathMod.join(root, pre, ...parts) : pathMod.join(root, ...parts);
|
|
39764
39764
|
try {
|
|
39765
|
-
await
|
|
39765
|
+
await fs51.access(test);
|
|
39766
39766
|
return pre ? `${pre}/` : "";
|
|
39767
39767
|
} catch {
|
|
39768
39768
|
}
|
|
@@ -40122,16 +40122,16 @@ ${pretty}`);
|
|
|
40122
40122
|
}
|
|
40123
40123
|
async persistLastPlan(root, plans) {
|
|
40124
40124
|
try {
|
|
40125
|
-
const
|
|
40125
|
+
const fs51 = await import('fs/promises');
|
|
40126
40126
|
const p = path10__namespace.join(root, ".maria");
|
|
40127
|
-
await
|
|
40127
|
+
await fs51.mkdir(p, { recursive: true });
|
|
40128
40128
|
const out = path10__namespace.join(p, "last-plan.json");
|
|
40129
|
-
await
|
|
40129
|
+
await fs51.writeFile(out, JSON.stringify({ createdAt: (/* @__PURE__ */ new Date()).toISOString(), plans }, null, 2), "utf8");
|
|
40130
40130
|
} catch {
|
|
40131
40131
|
}
|
|
40132
40132
|
}
|
|
40133
40133
|
async applyPlan(plans, options) {
|
|
40134
|
-
const
|
|
40134
|
+
const fs51 = await import('fs/promises');
|
|
40135
40135
|
const created = [];
|
|
40136
40136
|
const modified = [];
|
|
40137
40137
|
const skipped = [];
|
|
@@ -40150,9 +40150,9 @@ ${pretty}`);
|
|
|
40150
40150
|
continue;
|
|
40151
40151
|
}
|
|
40152
40152
|
const tmp = full + `.tmp-${process.pid}-${Date.now()}`;
|
|
40153
|
-
await
|
|
40154
|
-
await
|
|
40155
|
-
await
|
|
40153
|
+
await fs51.mkdir(path10__namespace.dirname(full), { recursive: true });
|
|
40154
|
+
await fs51.writeFile(tmp, plan.preview || "", "utf8");
|
|
40155
|
+
await fs51.rename(tmp, full);
|
|
40156
40156
|
if (exists2) modified.push(plan.path);
|
|
40157
40157
|
else created.push(plan.path);
|
|
40158
40158
|
written++;
|
|
@@ -40163,7 +40163,7 @@ ${pretty}`);
|
|
|
40163
40163
|
if (options.rollback) {
|
|
40164
40164
|
for (const p of [...created, ...modified]) {
|
|
40165
40165
|
try {
|
|
40166
|
-
await
|
|
40166
|
+
await fs51.unlink(path10__namespace.join(options.root, p));
|
|
40167
40167
|
} catch {
|
|
40168
40168
|
}
|
|
40169
40169
|
}
|
|
@@ -40173,8 +40173,8 @@ ${pretty}`);
|
|
|
40173
40173
|
}
|
|
40174
40174
|
async pathExists(p) {
|
|
40175
40175
|
try {
|
|
40176
|
-
const
|
|
40177
|
-
await
|
|
40176
|
+
const fs51 = await import('fs/promises');
|
|
40177
|
+
await fs51.access(p);
|
|
40178
40178
|
return true;
|
|
40179
40179
|
} catch {
|
|
40180
40180
|
return false;
|
|
@@ -40285,17 +40285,17 @@ ${pretty}`);
|
|
|
40285
40285
|
// Attempt to collect attached files from context; map to AttachedFileContext
|
|
40286
40286
|
async collectAttachedFiles(context2) {
|
|
40287
40287
|
const list = [];
|
|
40288
|
-
const
|
|
40289
|
-
const
|
|
40288
|
+
const fs51 = await import('fs/promises');
|
|
40289
|
+
const path64 = await import('path');
|
|
40290
40290
|
const att = context2 && (context2.attachments || context2.input?.attachments) || [];
|
|
40291
40291
|
for (const a of att) {
|
|
40292
40292
|
try {
|
|
40293
40293
|
const p = a.path || a.filePath || a.name || "";
|
|
40294
|
-
const originalName = a.name ||
|
|
40294
|
+
const originalName = a.name || path64.basename(p || `attachment_${Date.now().toString(36)}`);
|
|
40295
40295
|
let content = a.content;
|
|
40296
40296
|
if (!content && p) {
|
|
40297
|
-
const abs =
|
|
40298
|
-
content = await
|
|
40297
|
+
const abs = path64.isAbsolute(p) ? p : path64.join(process.cwd(), p);
|
|
40298
|
+
content = await fs51.readFile(abs, "utf8");
|
|
40299
40299
|
}
|
|
40300
40300
|
if (!content) continue;
|
|
40301
40301
|
list.push({ originalName, pathHint: p || void 0, content, size: Buffer.byteLength(content, "utf8"), mime: a.mime || a.type });
|
|
@@ -41100,12 +41100,12 @@ async function scanRoot(opts) {
|
|
|
41100
41100
|
const filepath = path10__namespace.join(cwd2, name2);
|
|
41101
41101
|
const result = await safeRead(filepath, 512 * 1024, maxLines, signal);
|
|
41102
41102
|
if (result.head || result.meta) {
|
|
41103
|
-
let
|
|
41103
|
+
let meta27 = result.meta || object;
|
|
41104
41104
|
if (name2 === "package.json" && result.head) {
|
|
41105
41105
|
try {
|
|
41106
41106
|
const pkg = JSON.parse(result.head);
|
|
41107
|
-
|
|
41108
|
-
...
|
|
41107
|
+
meta27 = {
|
|
41108
|
+
...meta27,
|
|
41109
41109
|
name: pkg.name,
|
|
41110
41110
|
version: pkg.version,
|
|
41111
41111
|
type: pkg.type,
|
|
@@ -41118,14 +41118,14 @@ async function scanRoot(opts) {
|
|
|
41118
41118
|
workspaces: pkg.workspaces
|
|
41119
41119
|
};
|
|
41120
41120
|
} catch (e2) {
|
|
41121
|
-
|
|
41121
|
+
meta27.parseError = true;
|
|
41122
41122
|
}
|
|
41123
41123
|
}
|
|
41124
41124
|
findings.push({
|
|
41125
41125
|
file: name2,
|
|
41126
41126
|
kind: "read",
|
|
41127
41127
|
head: result.head,
|
|
41128
|
-
meta:
|
|
41128
|
+
meta: meta27,
|
|
41129
41129
|
truncated: result.truncated
|
|
41130
41130
|
});
|
|
41131
41131
|
}
|
|
@@ -41463,19 +41463,19 @@ function extractPackageInfo(findings) {
|
|
|
41463
41463
|
hasPostinstall: false
|
|
41464
41464
|
};
|
|
41465
41465
|
}
|
|
41466
|
-
const
|
|
41466
|
+
const meta27 = pkgFinding.meta;
|
|
41467
41467
|
return {
|
|
41468
|
-
name:
|
|
41469
|
-
version:
|
|
41470
|
-
type:
|
|
41471
|
-
scripts:
|
|
41472
|
-
hasPostinstall: !!
|
|
41473
|
-
bin:
|
|
41474
|
-
main:
|
|
41475
|
-
exports:
|
|
41476
|
-
dependencies:
|
|
41477
|
-
devDependencies:
|
|
41478
|
-
workspaces:
|
|
41468
|
+
name: meta27.name,
|
|
41469
|
+
version: meta27.version,
|
|
41470
|
+
type: meta27.type,
|
|
41471
|
+
scripts: meta27.scripts ? Object.keys(meta27.scripts) : [],
|
|
41472
|
+
hasPostinstall: !!meta27.scripts?.postinstall,
|
|
41473
|
+
bin: meta27.bin,
|
|
41474
|
+
main: meta27.main,
|
|
41475
|
+
exports: meta27.exports,
|
|
41476
|
+
dependencies: meta27.dependencies || [],
|
|
41477
|
+
devDependencies: meta27.devDependencies || [],
|
|
41478
|
+
workspaces: meta27.workspaces
|
|
41479
41479
|
};
|
|
41480
41480
|
}
|
|
41481
41481
|
function collectWarnings(pkg, findings, cwd2) {
|
|
@@ -41626,9 +41626,9 @@ function calculateMetrics(findings, startTime) {
|
|
|
41626
41626
|
}
|
|
41627
41627
|
function renderFinding(f3) {
|
|
41628
41628
|
const title = `### ${f3.kind.toUpperCase()} \u2014 ${f3.file}`;
|
|
41629
|
-
let
|
|
41629
|
+
let meta27 = "";
|
|
41630
41630
|
if (f3.meta && Object.keys(f3.meta).length > 0) {
|
|
41631
|
-
|
|
41631
|
+
meta27 = `
|
|
41632
41632
|
<details><summary>meta</summary>
|
|
41633
41633
|
|
|
41634
41634
|
\`\`\`json
|
|
@@ -41649,7 +41649,7 @@ ${f3.head.trim()}
|
|
|
41649
41649
|
}
|
|
41650
41650
|
const truncInfo = f3.truncated ? `
|
|
41651
41651
|
> _truncated preview_` : "";
|
|
41652
|
-
return [title,
|
|
41652
|
+
return [title, meta27, content, truncInfo, ""].join("\n");
|
|
41653
41653
|
}
|
|
41654
41654
|
function safeJsonStringify(obj) {
|
|
41655
41655
|
try {
|
|
@@ -49878,17 +49878,17 @@ var init_GraphEngine = __esm({
|
|
|
49878
49878
|
const visited = /* @__PURE__ */ new Set();
|
|
49879
49879
|
const queue = [{ id: from, path: [from] }];
|
|
49880
49880
|
while (queue.length) {
|
|
49881
|
-
const { id, path:
|
|
49881
|
+
const { id, path: path64 } = queue.shift();
|
|
49882
49882
|
if (visited.has(id)) continue;
|
|
49883
49883
|
visited.add(id);
|
|
49884
49884
|
const neighbors = this.edges.get(id) || /* @__PURE__ */ new Set();
|
|
49885
49885
|
for (const e2 of neighbors) {
|
|
49886
49886
|
if (e2.to === to) {
|
|
49887
|
-
const res = [...
|
|
49887
|
+
const res = [...path64, to];
|
|
49888
49888
|
this.recordQueryTime(Date.now() - start);
|
|
49889
49889
|
return res;
|
|
49890
49890
|
}
|
|
49891
|
-
if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...
|
|
49891
|
+
if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...path64, e2.to] });
|
|
49892
49892
|
}
|
|
49893
49893
|
}
|
|
49894
49894
|
this.recordQueryTime(Date.now() - start);
|
|
@@ -52555,12 +52555,12 @@ This will:
|
|
|
52555
52555
|
};
|
|
52556
52556
|
const result = await this.deltaDetector.detectDelta(root, deltaOptions);
|
|
52557
52557
|
const files = [
|
|
52558
|
-
...result.changed.map((
|
|
52559
|
-
_path:
|
|
52560
|
-
type: previousState?.fileHashes?.[
|
|
52558
|
+
...result.changed.map((path64) => ({
|
|
52559
|
+
_path: path64,
|
|
52560
|
+
type: previousState?.fileHashes?.[path64] ? "modified" : "added"
|
|
52561
52561
|
})),
|
|
52562
|
-
...result.deleted.map((
|
|
52563
|
-
_path:
|
|
52562
|
+
...result.deleted.map((path64) => ({
|
|
52563
|
+
_path: path64,
|
|
52564
52564
|
type: "deleted"
|
|
52565
52565
|
}))
|
|
52566
52566
|
];
|
|
@@ -56287,13 +56287,13 @@ async function checkShield(commandName, userPlan = "free") {
|
|
|
56287
56287
|
}
|
|
56288
56288
|
async function loadManifest() {
|
|
56289
56289
|
try {
|
|
56290
|
-
const
|
|
56291
|
-
const
|
|
56292
|
-
const manifestPath =
|
|
56290
|
+
const fs51 = await import('fs');
|
|
56291
|
+
const path64 = await import('path');
|
|
56292
|
+
const manifestPath = path64.join(
|
|
56293
56293
|
__dirname,
|
|
56294
56294
|
"../command-manifest-v2.1.json"
|
|
56295
56295
|
);
|
|
56296
|
-
const content =
|
|
56296
|
+
const content = fs51.readFileSync(manifestPath, "utf-8");
|
|
56297
56297
|
return JSON.parse(content);
|
|
56298
56298
|
} catch {
|
|
56299
56299
|
return { commands: [] };
|
|
@@ -57387,6 +57387,1145 @@ var init_gpu_command = __esm({
|
|
|
57387
57387
|
gpu_command_default = GPUCommand;
|
|
57388
57388
|
}
|
|
57389
57389
|
});
|
|
57390
|
+
var CriteriaManager;
|
|
57391
|
+
var init_CriteriaManager = __esm({
|
|
57392
|
+
"src/services/evaluation/CriteriaManager.ts"() {
|
|
57393
|
+
CriteriaManager = class {
|
|
57394
|
+
constructor(projectRoot) {
|
|
57395
|
+
this.projectRoot = projectRoot;
|
|
57396
|
+
}
|
|
57397
|
+
getDefaultPath() {
|
|
57398
|
+
return path10__namespace.default.join(this.projectRoot, ".maria", "evaluation.criteria.json");
|
|
57399
|
+
}
|
|
57400
|
+
async ensureCriteriaFile(customPath) {
|
|
57401
|
+
const criteriaPath = customPath ? path10__namespace.default.isAbsolute(customPath) ? customPath : path10__namespace.default.join(this.projectRoot, customPath) : this.getDefaultPath();
|
|
57402
|
+
const dir = path10__namespace.default.dirname(criteriaPath);
|
|
57403
|
+
await fs19.promises.mkdir(dir, { recursive: true });
|
|
57404
|
+
try {
|
|
57405
|
+
await fs19.promises.access(criteriaPath);
|
|
57406
|
+
return criteriaPath;
|
|
57407
|
+
} catch {
|
|
57408
|
+
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
57409
|
+
const payload = {
|
|
57410
|
+
version: "1.0.0",
|
|
57411
|
+
project: path10__namespace.default.basename(this.projectRoot) || "project",
|
|
57412
|
+
createdAt: now2,
|
|
57413
|
+
updatedAt: now2,
|
|
57414
|
+
items: this.createDefaultCriteria()
|
|
57415
|
+
};
|
|
57416
|
+
await fs19.promises.writeFile(criteriaPath, JSON.stringify(payload, null, 2), "utf8");
|
|
57417
|
+
return criteriaPath;
|
|
57418
|
+
}
|
|
57419
|
+
}
|
|
57420
|
+
async loadCriteria(criteriaPath) {
|
|
57421
|
+
const buf = await fs19.promises.readFile(criteriaPath, "utf8");
|
|
57422
|
+
const json = JSON.parse(buf);
|
|
57423
|
+
if (!Array.isArray(json.items)) {
|
|
57424
|
+
throw new Error("Invalid criteria file: items missing");
|
|
57425
|
+
}
|
|
57426
|
+
return json;
|
|
57427
|
+
}
|
|
57428
|
+
async updateCriteria(criteriaPath, updater) {
|
|
57429
|
+
const current = await this.loadCriteria(criteriaPath);
|
|
57430
|
+
const next = updater({ ...current, updatedAt: (/* @__PURE__ */ new Date()).toISOString() });
|
|
57431
|
+
await fs19.promises.writeFile(criteriaPath, JSON.stringify(next, null, 2), "utf8");
|
|
57432
|
+
}
|
|
57433
|
+
createDefaultCriteria() {
|
|
57434
|
+
const items = [
|
|
57435
|
+
["clarity", "Clarity: Clear goals and requirements", 0.15, "Are requirements, specs, and assumptions explicitly stated?"],
|
|
57436
|
+
["feasibility", "Feasibility: Realistic scope and timeline", 0.15, "Are dependencies, risks, and alternatives considered?"],
|
|
57437
|
+
["maintainability", "Maintainability: Structure and reuse", 0.15, "Does design follow separation of concerns and sound naming?"],
|
|
57438
|
+
["testability", "Testability: Strategy and coverage", 0.1, "Are unit/integration/regression test approaches considered?"],
|
|
57439
|
+
["security", "Security: Validation and secret handling", 0.1, "Are input validation, authz, and secret management addressed?"],
|
|
57440
|
+
["performance", "Performance: Efficiency and scalability", 0.1, "Are data volume, I/O, and bottlenecks considered?"],
|
|
57441
|
+
["alignment", "Project Alignment: Conventions and structure", 0.15, "Does it follow folder structure, naming, and tooling?"],
|
|
57442
|
+
["completeness", "Completeness: Edge cases and failures", 0.1, "Are inputs/outputs/errors/logging/edge cases covered?"]
|
|
57443
|
+
];
|
|
57444
|
+
return items.map(([id, name2, weight, rubric]) => ({ id, name: name2, weight, rubric, description: name2 }));
|
|
57445
|
+
}
|
|
57446
|
+
};
|
|
57447
|
+
}
|
|
57448
|
+
});
|
|
57449
|
+
|
|
57450
|
+
// src/services/evaluation/ScoringEngine.ts
|
|
57451
|
+
var ScoringEngine;
|
|
57452
|
+
var init_ScoringEngine = __esm({
|
|
57453
|
+
"src/services/evaluation/ScoringEngine.ts"() {
|
|
57454
|
+
ScoringEngine = class {
|
|
57455
|
+
async evaluate(input3, criteria) {
|
|
57456
|
+
const textBundle = this.joinInput(input3);
|
|
57457
|
+
const details = [];
|
|
57458
|
+
for (const item of criteria.items) {
|
|
57459
|
+
const score = this.heuristicScore(textBundle, item.id);
|
|
57460
|
+
const reason = this.generateReason(textBundle, item.id);
|
|
57461
|
+
details.push({ id: item.id, name: item.name, weight: item.weight, score, reason });
|
|
57462
|
+
}
|
|
57463
|
+
const totalWeight = details.reduce((s2, d) => s2 + d.weight, 0) || 1;
|
|
57464
|
+
const totalScore = details.reduce((s2, d) => s2 + d.score * d.weight, 0) / totalWeight;
|
|
57465
|
+
return { totalScore, details };
|
|
57466
|
+
}
|
|
57467
|
+
joinInput(input3) {
|
|
57468
|
+
const parts = [];
|
|
57469
|
+
if (input3.idea) parts.push(`IDEA:
|
|
57470
|
+
${input3.idea}`);
|
|
57471
|
+
if (input3.code) parts.push(`CODE:
|
|
57472
|
+
${input3.code}`);
|
|
57473
|
+
if (input3.files && input3.files.length) {
|
|
57474
|
+
for (const f3 of input3.files) {
|
|
57475
|
+
parts.push(`FILE ${f3.path}:
|
|
57476
|
+
${f3.content}`);
|
|
57477
|
+
}
|
|
57478
|
+
}
|
|
57479
|
+
return parts.join("\n\n");
|
|
57480
|
+
}
|
|
57481
|
+
heuristicScore(bundle, aspect) {
|
|
57482
|
+
const lower2 = bundle.toLowerCase();
|
|
57483
|
+
const checks = {
|
|
57484
|
+
clarity: ["objective", "\u76EE\u7684", "\u8981\u4EF6", "spec", "\u4ED5\u69D8"],
|
|
57485
|
+
feasibility: ["risk", "\u30EA\u30B9\u30AF", "plan", "\u8A08\u753B", "timeline"],
|
|
57486
|
+
maintainability: ["function", "class", "interface", "\u5206\u5272", "\u30E2\u30B8\u30E5\u30FC\u30EB"],
|
|
57487
|
+
testability: ["test", "spec", "vitest", "jest", "coverage"],
|
|
57488
|
+
security: ["secret", "env", "sanitize", "validation", "\u6A29\u9650"],
|
|
57489
|
+
performance: ["cache", "\u6027\u80FD", "optimiz", "stream", "memo"],
|
|
57490
|
+
alignment: ["src/", "pnpm", "eslint", "prettier", "convention"],
|
|
57491
|
+
completeness: ["edge case", "\u7570\u5E38\u7CFB", "\u30A8\u30E9\u30FC", "fallback", "retry"]
|
|
57492
|
+
};
|
|
57493
|
+
const words = checks[aspect] || [];
|
|
57494
|
+
const hits = words.reduce((c, w) => c + (lower2.includes(w) ? 1 : 0), 0);
|
|
57495
|
+
if (hits === 0) return 0.3;
|
|
57496
|
+
if (hits === 1) return 0.55;
|
|
57497
|
+
if (hits === 2) return 0.75;
|
|
57498
|
+
return 0.9;
|
|
57499
|
+
}
|
|
57500
|
+
generateReason(bundle, aspect) {
|
|
57501
|
+
switch (aspect) {
|
|
57502
|
+
case "clarity":
|
|
57503
|
+
return "\u8981\u6C42\u3084\u4ED5\u69D8\u306E\u660E\u793A\u5EA6\u304B\u3089\u6982\u7B97";
|
|
57504
|
+
case "feasibility":
|
|
57505
|
+
return "\u30EA\u30B9\u30AF\u30FB\u8A08\u753B\u306E\u8A18\u8F09\u6709\u7121\u304B\u3089\u6982\u7B97";
|
|
57506
|
+
case "maintainability":
|
|
57507
|
+
return "\u69CB\u9020\u5316\u30FB\u518D\u5229\u7528\u6027\u306E\u5146\u5019\u304B\u3089\u6982\u7B97";
|
|
57508
|
+
case "testability":
|
|
57509
|
+
return "\u30C6\u30B9\u30C8\u95A2\u9023\u306E\u8A00\u53CA\u304B\u3089\u6982\u7B97";
|
|
57510
|
+
case "security":
|
|
57511
|
+
return "\u79D8\u5BC6\u7BA1\u7406\u30FB\u5165\u529B\u691C\u8A3C\u306E\u8A00\u53CA\u304B\u3089\u6982\u7B97";
|
|
57512
|
+
case "performance":
|
|
57513
|
+
return "\u6027\u80FD\u6700\u9069\u5316\u306E\u793A\u5506\u304B\u3089\u6982\u7B97";
|
|
57514
|
+
case "alignment":
|
|
57515
|
+
return "\u30EA\u30DD\u30B8\u30C8\u30EA\u898F\u7D04\u3078\u306E\u8A00\u53CA\u304B\u3089\u6982\u7B97";
|
|
57516
|
+
case "completeness":
|
|
57517
|
+
return "\u7570\u5E38\u7CFB\u30FB\u30A8\u30C3\u30B8\u30B1\u30FC\u30B9\u306E\u7DB2\u7F85\u5EA6\u304B\u3089\u6982\u7B97";
|
|
57518
|
+
default:
|
|
57519
|
+
return "\u30D2\u30E5\u30FC\u30EA\u30B9\u30C6\u30A3\u30C3\u30AF\u8A55\u4FA1";
|
|
57520
|
+
}
|
|
57521
|
+
}
|
|
57522
|
+
};
|
|
57523
|
+
}
|
|
57524
|
+
});
|
|
57525
|
+
var EvaluationOrchestrator;
|
|
57526
|
+
var init_EvaluationOrchestrator = __esm({
|
|
57527
|
+
"src/services/evaluation/EvaluationOrchestrator.ts"() {
|
|
57528
|
+
init_CriteriaManager();
|
|
57529
|
+
init_ScoringEngine();
|
|
57530
|
+
init_api_caller();
|
|
57531
|
+
EvaluationOrchestrator = class {
|
|
57532
|
+
constructor(projectRoot) {
|
|
57533
|
+
this.projectRoot = projectRoot;
|
|
57534
|
+
this.criteriaManager = new CriteriaManager(projectRoot);
|
|
57535
|
+
this.engine = new ScoringEngine();
|
|
57536
|
+
}
|
|
57537
|
+
criteriaManager;
|
|
57538
|
+
engine;
|
|
57539
|
+
async assess(options) {
|
|
57540
|
+
const criteriaPath = options.criteria ? path10__namespace.default.isAbsolute(options.criteria) ? options.criteria : path10__namespace.default.join(this.projectRoot, options.criteria) : this.criteriaManager.getDefaultPath();
|
|
57541
|
+
const needGenerate = !!options.regenerateCriteria || !await this.exists(criteriaPath);
|
|
57542
|
+
if (needGenerate) {
|
|
57543
|
+
try {
|
|
57544
|
+
await this.generateCriteriaWithLLM(criteriaPath, {
|
|
57545
|
+
idea: options.idea,
|
|
57546
|
+
code: options.code,
|
|
57547
|
+
files: options.files || []
|
|
57548
|
+
});
|
|
57549
|
+
} catch {
|
|
57550
|
+
await this.criteriaManager.ensureCriteriaFile(criteriaPath);
|
|
57551
|
+
}
|
|
57552
|
+
} else {
|
|
57553
|
+
await this.criteriaManager.ensureCriteriaFile(criteriaPath);
|
|
57554
|
+
}
|
|
57555
|
+
const criteria = await this.criteriaManager.loadCriteria(criteriaPath);
|
|
57556
|
+
if (options.criteriaOnly) {
|
|
57557
|
+
return { criteriaPath, result: null };
|
|
57558
|
+
}
|
|
57559
|
+
const files = await this.readFiles(options.files || []);
|
|
57560
|
+
const input3 = {
|
|
57561
|
+
idea: options.idea,
|
|
57562
|
+
code: options.code,
|
|
57563
|
+
files
|
|
57564
|
+
};
|
|
57565
|
+
const result = await this.scoreWithLLM(input3, criteria);
|
|
57566
|
+
result.files = input3.files || [];
|
|
57567
|
+
return { criteriaPath, result };
|
|
57568
|
+
}
|
|
57569
|
+
async exists(p) {
|
|
57570
|
+
try {
|
|
57571
|
+
await fs19.promises.stat(p);
|
|
57572
|
+
return true;
|
|
57573
|
+
} catch {
|
|
57574
|
+
return false;
|
|
57575
|
+
}
|
|
57576
|
+
}
|
|
57577
|
+
async generateCriteriaWithLLM(criteriaPath, context2) {
|
|
57578
|
+
const relPath = path10__namespace.default.relative(this.projectRoot, criteriaPath).replace(/\\/g, "/");
|
|
57579
|
+
const targetPath = relPath.startsWith(".") ? relPath : relPath;
|
|
57580
|
+
const dir = path10__namespace.default.dirname(criteriaPath);
|
|
57581
|
+
await fs19.promises.mkdir(dir, { recursive: true });
|
|
57582
|
+
const system = [
|
|
57583
|
+
"You are an expert evaluation designer.",
|
|
57584
|
+
"Create a JSON criteria file for evaluating the given idea/code/files. If a local file path is provided, make sure you read the uploaded file before taking any actions.",
|
|
57585
|
+
"Respond ONLY with a single multi-file section in this exact format:",
|
|
57586
|
+
`[BEGIN file: ${targetPath}]`,
|
|
57587
|
+
"{JSON}",
|
|
57588
|
+
"[END]",
|
|
57589
|
+
"Do not include any other text or markdown.",
|
|
57590
|
+
"JSON schema:",
|
|
57591
|
+
'{ "version": "1.0.0", "project": string, "createdAt": ISO string, "updatedAt": ISO string, "items": [{ "id": string, "name": string, "description": string, "weight": number (0..1), "rubric": string }] }',
|
|
57592
|
+
"Total weight across items should be ~1. Use concise English labels and rubrics tailored to the input."
|
|
57593
|
+
].join("\n");
|
|
57594
|
+
const user = [
|
|
57595
|
+
`Project: ${path10__namespace.default.basename(this.projectRoot)}`,
|
|
57596
|
+
context2.idea ? `Idea:
|
|
57597
|
+
${context2.idea}` : void 0,
|
|
57598
|
+
context2.code ? `Code snippet:
|
|
57599
|
+
${context2.code}` : void 0,
|
|
57600
|
+
context2.files.length ? `Files:
|
|
57601
|
+
${context2.files.map((f3) => `- ${f3}`).join("\n")}` : void 0
|
|
57602
|
+
].filter(Boolean).join("\n\n");
|
|
57603
|
+
const response = await callAPI("/v1/ai-proxy", {
|
|
57604
|
+
method: "POST",
|
|
57605
|
+
body: {
|
|
57606
|
+
prompt: `${system}
|
|
57607
|
+
|
|
57608
|
+
---
|
|
57609
|
+
|
|
57610
|
+
${user}`,
|
|
57611
|
+
taskType: "evaluation"
|
|
57612
|
+
}
|
|
57613
|
+
});
|
|
57614
|
+
const content = (response?.data?.content || response?.output || "").trim();
|
|
57615
|
+
if (!content) throw new Error("Empty LLM response");
|
|
57616
|
+
const fileMap = this.parseFileSections(content);
|
|
57617
|
+
let payload;
|
|
57618
|
+
if (fileMap.size > 0) {
|
|
57619
|
+
payload = fileMap.get(targetPath) || Array.from(fileMap.values())[0];
|
|
57620
|
+
} else {
|
|
57621
|
+
payload = this.extractFirstJsonObject(content) || content;
|
|
57622
|
+
}
|
|
57623
|
+
try {
|
|
57624
|
+
JSON.parse(payload);
|
|
57625
|
+
} catch {
|
|
57626
|
+
throw new Error("Invalid JSON in generated criteria");
|
|
57627
|
+
}
|
|
57628
|
+
await fs19.promises.writeFile(criteriaPath, payload, "utf8");
|
|
57629
|
+
}
|
|
57630
|
+
parseFileSections(text) {
|
|
57631
|
+
const map = /* @__PURE__ */ new Map();
|
|
57632
|
+
const regex2 = /\[BEGIN\s+file:\s*([^\]]+)\]\r?\n([\s\S]*?)\[END\]/gi;
|
|
57633
|
+
let m2;
|
|
57634
|
+
while ((m2 = regex2.exec(text)) !== null) {
|
|
57635
|
+
const file = m2[1].trim();
|
|
57636
|
+
const body = m2[2];
|
|
57637
|
+
map.set(file, body);
|
|
57638
|
+
}
|
|
57639
|
+
return map;
|
|
57640
|
+
}
|
|
57641
|
+
extractFirstJsonObject(text) {
|
|
57642
|
+
const fenceJson = /```\s*json\s*\r?\n([\s\S]*?)```/i.exec(text);
|
|
57643
|
+
if (fenceJson) return fenceJson[1];
|
|
57644
|
+
const fencePlain = /```\s*\r?\n([\s\S]*?)```/i.exec(text);
|
|
57645
|
+
if (fencePlain) {
|
|
57646
|
+
const body = fencePlain[1];
|
|
57647
|
+
try {
|
|
57648
|
+
JSON.parse(body);
|
|
57649
|
+
return body;
|
|
57650
|
+
} catch {
|
|
57651
|
+
}
|
|
57652
|
+
}
|
|
57653
|
+
const defenced = text.replace(/```[a-zA-Z]*\s*\r?\n([\s\S]*?)```/g, "$1");
|
|
57654
|
+
const start = defenced.indexOf("{");
|
|
57655
|
+
const end = defenced.lastIndexOf("}");
|
|
57656
|
+
if (start >= 0 && end > start) {
|
|
57657
|
+
const cand = defenced.slice(start, end + 1);
|
|
57658
|
+
try {
|
|
57659
|
+
JSON.parse(cand);
|
|
57660
|
+
return cand;
|
|
57661
|
+
} catch {
|
|
57662
|
+
}
|
|
57663
|
+
}
|
|
57664
|
+
return null;
|
|
57665
|
+
}
|
|
57666
|
+
async scoreWithLLM(input3, criteria) {
|
|
57667
|
+
const criteriaPreview = criteria.items.map((it) => ({ id: it.id, name: it.name, weight: it.weight, rubric: it.rubric })).slice(0, 20);
|
|
57668
|
+
const parts = [];
|
|
57669
|
+
if (input3.idea) parts.push(`Idea:
|
|
57670
|
+
${input3.idea}`);
|
|
57671
|
+
if (input3.code) parts.push(`Code:
|
|
57672
|
+
${input3.code}`);
|
|
57673
|
+
const files = input3.files || [];
|
|
57674
|
+
if (files.length) {
|
|
57675
|
+
parts.push(`Files attached:
|
|
57676
|
+
${files.slice(0, 20).map((f3) => `- ${f3.path}`).join("\n")}`);
|
|
57677
|
+
}
|
|
57678
|
+
const bundle = parts.join("\n\n");
|
|
57679
|
+
const system = [
|
|
57680
|
+
"You are an impartial evaluator. Score each criterion between 0 and 1.",
|
|
57681
|
+
"If a local file path is provided, make sure you read the uploaded file before taking any actions.",
|
|
57682
|
+
"Return JSON only in the following schema:",
|
|
57683
|
+
'{ "totalScore": number (0..1), "details": [{ "id": string, "score": number (0..1), "reason": string }] }',
|
|
57684
|
+
"Keep reasons short (<= 120 chars)."
|
|
57685
|
+
].join("\n");
|
|
57686
|
+
const user = [
|
|
57687
|
+
`Criteria: ${JSON.stringify(criteriaPreview)}`,
|
|
57688
|
+
"Input to evaluate:",
|
|
57689
|
+
bundle
|
|
57690
|
+
].join("\n\n");
|
|
57691
|
+
(input3.files || []).some((f3) => f3.mime && f3.mime !== "text/plain");
|
|
57692
|
+
const provider = "google";
|
|
57693
|
+
const model = "gemini-2.5-flash";
|
|
57694
|
+
const response = await callAPI("/v1/ai-proxy", {
|
|
57695
|
+
method: "POST",
|
|
57696
|
+
body: {
|
|
57697
|
+
provider,
|
|
57698
|
+
model,
|
|
57699
|
+
prompt: `${system}
|
|
57700
|
+
|
|
57701
|
+
---
|
|
57702
|
+
|
|
57703
|
+
${user}`,
|
|
57704
|
+
taskType: "evaluation",
|
|
57705
|
+
metadata: {
|
|
57706
|
+
attachments: (input3.files || []).map((f3) => this.toAttachmentPayload(f3))
|
|
57707
|
+
}
|
|
57708
|
+
}
|
|
57709
|
+
});
|
|
57710
|
+
const raw = (response?.data?.content || response?.output || "").trim();
|
|
57711
|
+
if (!raw) throw new Error("Empty LLM scoring response");
|
|
57712
|
+
let jsonText = this.extractFirstJsonObject(raw) || raw;
|
|
57713
|
+
const sections = this.parseFileSections(raw);
|
|
57714
|
+
if (sections.size > 0) {
|
|
57715
|
+
jsonText = Array.from(sections.values())[0];
|
|
57716
|
+
}
|
|
57717
|
+
let parsed;
|
|
57718
|
+
try {
|
|
57719
|
+
parsed = JSON.parse(jsonText);
|
|
57720
|
+
} catch {
|
|
57721
|
+
return { totalScore: 0, details: criteria.items.map((it) => ({ id: it.id, name: it.name, weight: it.weight, score: 0, reason: "" })), passThroughText: raw };
|
|
57722
|
+
}
|
|
57723
|
+
const details = criteria.items.map((it) => {
|
|
57724
|
+
const found = parsed.details.find((d) => d.id === it.id);
|
|
57725
|
+
const score = Math.max(0, Math.min(1, found?.score ?? 0));
|
|
57726
|
+
return { id: it.id, name: it.name, weight: it.weight, score, reason: found?.reason || "" };
|
|
57727
|
+
});
|
|
57728
|
+
const totalWeight = details.reduce((s2, d) => s2 + d.weight, 0) || 1;
|
|
57729
|
+
const weighted = details.reduce((s2, d) => s2 + d.score * d.weight, 0) / totalWeight;
|
|
57730
|
+
const totalScore = Number.isFinite(parsed.totalScore) ? Math.max(0, Math.min(1, parsed.totalScore)) : weighted;
|
|
57731
|
+
return { totalScore, details };
|
|
57732
|
+
}
|
|
57733
|
+
toAttachmentPayload(file) {
|
|
57734
|
+
const ext2 = path10__namespace.default.extname(file.path).toLowerCase();
|
|
57735
|
+
const mime = file.mime || (ext2 === ".pdf" ? "application/pdf" : "text/plain");
|
|
57736
|
+
const b64 = file.binaryBase64 || Buffer.from(file.content || "", "utf8").toString("base64");
|
|
57737
|
+
return { name: path10__namespace.default.basename(file.path), path: file.path, mime, data_base64: b64 };
|
|
57738
|
+
}
|
|
57739
|
+
async readFiles(pathsInput) {
|
|
57740
|
+
const out = [];
|
|
57741
|
+
for (const p of pathsInput) {
|
|
57742
|
+
const normalized = p.replace(/^"|"$/g, "").replace(/^'|'$/g, "");
|
|
57743
|
+
const abs = path10__namespace.default.isAbsolute(normalized) ? normalized : path10__namespace.default.join(this.projectRoot, normalized);
|
|
57744
|
+
try {
|
|
57745
|
+
const stat13 = await fs19.promises.stat(abs);
|
|
57746
|
+
if (stat13.isDirectory()) {
|
|
57747
|
+
continue;
|
|
57748
|
+
}
|
|
57749
|
+
const ext2 = path10__namespace.default.extname(abs).toLowerCase();
|
|
57750
|
+
const raw = await fs19.promises.readFile(abs);
|
|
57751
|
+
let content = "";
|
|
57752
|
+
if (/\.pdf$/i.test(abs)) {
|
|
57753
|
+
content = await this.tryExtractPdfText(abs);
|
|
57754
|
+
} else {
|
|
57755
|
+
try {
|
|
57756
|
+
content = raw.toString("utf8");
|
|
57757
|
+
} catch {
|
|
57758
|
+
content = "";
|
|
57759
|
+
}
|
|
57760
|
+
}
|
|
57761
|
+
const mime = ext2 === ".pdf" ? "application/pdf" : "text/plain";
|
|
57762
|
+
const binaryBase64 = raw.toString("base64");
|
|
57763
|
+
out.push({ path: abs, content, binaryBase64, mime });
|
|
57764
|
+
} catch {
|
|
57765
|
+
}
|
|
57766
|
+
}
|
|
57767
|
+
return out;
|
|
57768
|
+
}
|
|
57769
|
+
async tryExtractPdfText(absPath) {
|
|
57770
|
+
try {
|
|
57771
|
+
const buf = await fs19.promises.readFile(absPath);
|
|
57772
|
+
try {
|
|
57773
|
+
const mod = await import('pdf-parse');
|
|
57774
|
+
const pdfParse = mod?.default || mod;
|
|
57775
|
+
if (typeof pdfParse === "function") {
|
|
57776
|
+
const res = await pdfParse(buf);
|
|
57777
|
+
const text = (res?.text || "").trim();
|
|
57778
|
+
if (text) return text;
|
|
57779
|
+
}
|
|
57780
|
+
} catch {
|
|
57781
|
+
}
|
|
57782
|
+
const kb = Math.round(buf.byteLength / 1024);
|
|
57783
|
+
return `[[PDF ${absPath} (${kb} KB) \u2014 text extraction unavailable in this environment]]`;
|
|
57784
|
+
} catch {
|
|
57785
|
+
return "[[PDF read error]]";
|
|
57786
|
+
}
|
|
57787
|
+
}
|
|
57788
|
+
};
|
|
57789
|
+
}
|
|
57790
|
+
});
|
|
57791
|
+
function extractFirstJson(text) {
|
|
57792
|
+
const fence = /```json\r?\n([\s\S]*?)```/i.exec(text);
|
|
57793
|
+
if (fence) return fence[1];
|
|
57794
|
+
const start = text.indexOf("{");
|
|
57795
|
+
const end = text.lastIndexOf("}");
|
|
57796
|
+
if (start >= 0 && end > start) {
|
|
57797
|
+
const cand = text.slice(start, end + 1);
|
|
57798
|
+
try {
|
|
57799
|
+
JSON.parse(cand);
|
|
57800
|
+
return cand;
|
|
57801
|
+
} catch {
|
|
57802
|
+
}
|
|
57803
|
+
}
|
|
57804
|
+
return null;
|
|
57805
|
+
}
|
|
57806
|
+
function sanitizePath(candidate, cwd2) {
|
|
57807
|
+
const normalized = path10__namespace.default.normalize(candidate);
|
|
57808
|
+
const absolute = path10__namespace.default.isAbsolute(normalized) ? normalized : path10__namespace.default.join(cwd2, normalized);
|
|
57809
|
+
const resolved = path10__namespace.default.resolve(absolute);
|
|
57810
|
+
const root = path10__namespace.default.resolve(cwd2);
|
|
57811
|
+
if (!resolved.startsWith(root)) return void 0;
|
|
57812
|
+
return resolved;
|
|
57813
|
+
}
|
|
57814
|
+
async function inferAssessParams(rawText, cwd2) {
|
|
57815
|
+
const system = [
|
|
57816
|
+
"You extract structured options for an evaluation command.",
|
|
57817
|
+
'Return JSON only with keys: { "criteriaPath"?: string, "regenerate"?: boolean, "criteriaOnly"?: boolean, "files"?: string[], "idea"?: string, "code"?: string }.',
|
|
57818
|
+
'Prefer concise relative paths for criteria (e.g., "AGI-hackathon-ideathon/evaluation.criteria.json").',
|
|
57819
|
+
'If the text says "do not regenerate" or "DO NOT regenerate", set regenerate=false (override any other hint).',
|
|
57820
|
+
"If the text asks to create/save criteria/rubric (without asking for evaluation), set criteriaOnly=true.",
|
|
57821
|
+
"If the text mentions saving criteria to a folder, set criteriaPath accordingly and regenerate=true.",
|
|
57822
|
+
"If it references files or folders, include them in files[] (relative to cwd).",
|
|
57823
|
+
"If idea content is present, place in idea; do not paraphrase."
|
|
57824
|
+
].join("\n");
|
|
57825
|
+
const user = rawText;
|
|
57826
|
+
const response = await callAPI("/v1/ai-proxy", {
|
|
57827
|
+
method: "POST",
|
|
57828
|
+
body: {
|
|
57829
|
+
prompt: `${system}
|
|
57830
|
+
|
|
57831
|
+
---
|
|
57832
|
+
|
|
57833
|
+
${user}`,
|
|
57834
|
+
taskType: "evaluation"
|
|
57835
|
+
}
|
|
57836
|
+
});
|
|
57837
|
+
const raw = (response?.data?.content || response?.output || "").trim();
|
|
57838
|
+
const jsonText = extractFirstJson(raw) || raw;
|
|
57839
|
+
let parsed = {};
|
|
57840
|
+
try {
|
|
57841
|
+
parsed = JSON.parse(jsonText);
|
|
57842
|
+
} catch {
|
|
57843
|
+
return {};
|
|
57844
|
+
}
|
|
57845
|
+
const out = {};
|
|
57846
|
+
if (typeof parsed.idea === "string" && parsed.idea.trim()) out.idea = parsed.idea.trim();
|
|
57847
|
+
if (typeof parsed.code === "string" && parsed.code.trim()) out.code = parsed.code.trim();
|
|
57848
|
+
if (typeof parsed.regenerate === "boolean") out.regenerate = parsed.regenerate;
|
|
57849
|
+
if (typeof parsed.criteriaOnly === "boolean") out.criteriaOnly = parsed.criteriaOnly;
|
|
57850
|
+
if (typeof parsed.criteriaPath === "string" && parsed.criteriaPath.trim()) {
|
|
57851
|
+
const safe = sanitizePath(parsed.criteriaPath.trim(), cwd2);
|
|
57852
|
+
if (safe) out.criteriaPath = safe;
|
|
57853
|
+
}
|
|
57854
|
+
if (Array.isArray(parsed.files)) {
|
|
57855
|
+
out.files = parsed.files.filter((f3) => typeof f3 === "string" && f3.trim()).map((f3) => sanitizePath(f3.trim(), cwd2)).filter((x2) => Boolean(x2));
|
|
57856
|
+
}
|
|
57857
|
+
return out;
|
|
57858
|
+
}
|
|
57859
|
+
var init_ArgumentInference = __esm({
|
|
57860
|
+
"src/services/evaluation/ArgumentInference.ts"() {
|
|
57861
|
+
init_api_caller();
|
|
57862
|
+
}
|
|
57863
|
+
});
|
|
57864
|
+
|
|
57865
|
+
// src/slash-commands/categories/evaluation/evaluate.command.ts
|
|
57866
|
+
var evaluate_command_exports = {};
|
|
57867
|
+
__export(evaluate_command_exports, {
|
|
57868
|
+
EvaluateCommand: () => EvaluateCommand,
|
|
57869
|
+
default: () => evaluate_command_default,
|
|
57870
|
+
meta: () => meta26
|
|
57871
|
+
});
|
|
57872
|
+
var EvaluateCommand, meta26, evaluate_command_default;
|
|
57873
|
+
var init_evaluate_command = __esm({
|
|
57874
|
+
"src/slash-commands/categories/evaluation/evaluate.command.ts"() {
|
|
57875
|
+
init_base_command();
|
|
57876
|
+
init_logger();
|
|
57877
|
+
init_EvaluationOrchestrator();
|
|
57878
|
+
init_api_caller();
|
|
57879
|
+
init_animations();
|
|
57880
|
+
init_ArgumentInference();
|
|
57881
|
+
EvaluateCommand = class extends BaseCommand {
|
|
57882
|
+
name = "evaluate";
|
|
57883
|
+
category = "evaluation";
|
|
57884
|
+
description = "\u{1F9EA} Run A/B tests and quality evaluations using the Phase 4 framework";
|
|
57885
|
+
aliases = ["eval", "test", "ab"];
|
|
57886
|
+
usage = "[run|status|results|stop|assess] [--config <path>] [--dataset <path>] [--format <format>] [--compare-baseline] [--idea <text>] [--code <text>] [--file <path> ...] [--criteria <path>]";
|
|
57887
|
+
examples = [
|
|
57888
|
+
{
|
|
57889
|
+
input: "/evaluate run --config tests/golden/config.json",
|
|
57890
|
+
description: "Run A/B evaluation with specified configuration",
|
|
57891
|
+
output: "Started evaluation test with nDCG and MRR metrics"
|
|
57892
|
+
},
|
|
57893
|
+
{
|
|
57894
|
+
input: "/evaluate status",
|
|
57895
|
+
description: "Show current evaluation status and active tests",
|
|
57896
|
+
output: "Evaluation system status with running/completed tests"
|
|
57897
|
+
},
|
|
57898
|
+
{
|
|
57899
|
+
input: "/evaluate results --format table",
|
|
57900
|
+
description: "Display latest evaluation results in table format",
|
|
57901
|
+
output: "Formatted table with quality metrics and improvements"
|
|
57902
|
+
},
|
|
57903
|
+
{
|
|
57904
|
+
input: "/evaluate run --dataset golden/sharepoint.json --compare-baseline",
|
|
57905
|
+
description: "Run evaluation against custom dataset with baseline comparison",
|
|
57906
|
+
output: "A/B test results with statistical significance analysis"
|
|
57907
|
+
},
|
|
57908
|
+
{
|
|
57909
|
+
input: "/evaluate assess --idea 'CLI\u306E\u8A2D\u8A08\u65B9\u91DD' --file src/cli.ts",
|
|
57910
|
+
description: "Generate criteria if missing and assess idea/files",
|
|
57911
|
+
output: "Weighted score and per-criterion breakdown"
|
|
57912
|
+
}
|
|
57913
|
+
];
|
|
57914
|
+
permissions = {
|
|
57915
|
+
requiresAuth: false,
|
|
57916
|
+
role: void 0
|
|
57917
|
+
};
|
|
57918
|
+
rateLimit = {
|
|
57919
|
+
requests: 10,
|
|
57920
|
+
window: "5m"
|
|
57921
|
+
};
|
|
57922
|
+
async execute(args2, context2) {
|
|
57923
|
+
try {
|
|
57924
|
+
const { options, parsed } = args2;
|
|
57925
|
+
const positional = parsed["positional"] || [];
|
|
57926
|
+
const candidate = positional[0];
|
|
57927
|
+
const hasFreeText = Array.isArray(args2.raw) && args2.raw.length > 0;
|
|
57928
|
+
const subcommand = candidate ? candidate : hasFreeText ? "assess" : "status";
|
|
57929
|
+
const normalized = subcommand.toLowerCase();
|
|
57930
|
+
const allowed = /* @__PURE__ */ new Set(["run", "status", "results", "stop", "assess"]);
|
|
57931
|
+
if (!allowed.has(normalized)) {
|
|
57932
|
+
const idea = (args2.raw || []).join(" ").trim();
|
|
57933
|
+
return await this.assessInput({ ...options, idea }, context2, args2);
|
|
57934
|
+
}
|
|
57935
|
+
switch (normalized) {
|
|
57936
|
+
case "run":
|
|
57937
|
+
return await this.runEvaluation(options, context2);
|
|
57938
|
+
case "status":
|
|
57939
|
+
return await this.getEvaluationStatus(options);
|
|
57940
|
+
case "results":
|
|
57941
|
+
return await this.getEvaluationResults(options);
|
|
57942
|
+
case "stop":
|
|
57943
|
+
return await this.stopEvaluation(options);
|
|
57944
|
+
case "assess":
|
|
57945
|
+
return await this.assessInput(options, context2, args2);
|
|
57946
|
+
default:
|
|
57947
|
+
return await this.assessInput(options, context2, args2);
|
|
57948
|
+
}
|
|
57949
|
+
} catch (error2) {
|
|
57950
|
+
logger.error("Evaluation command failed:", error2);
|
|
57951
|
+
return this.error(
|
|
57952
|
+
"Evaluation execution failed",
|
|
57953
|
+
"EVALUATION_ERROR",
|
|
57954
|
+
error2 instanceof Error ? error2.message : "Unknown error occurred"
|
|
57955
|
+
);
|
|
57956
|
+
}
|
|
57957
|
+
}
|
|
57958
|
+
/**
|
|
57959
|
+
* Assess idea/code/files using criteria (creates default criteria if missing)
|
|
57960
|
+
*/
|
|
57961
|
+
async assessInput(options, context2, commandArgs) {
|
|
57962
|
+
const root = context2.environment?.cwd || process.cwd();
|
|
57963
|
+
const rawText = (commandArgs?.raw || []).join(" ");
|
|
57964
|
+
const cwd2 = root;
|
|
57965
|
+
let inferred = {};
|
|
57966
|
+
try {
|
|
57967
|
+
const inferSpin = new ProcessAnimation();
|
|
57968
|
+
inferSpin.start();
|
|
57969
|
+
try {
|
|
57970
|
+
inferred = await inferAssessParams(rawText, cwd2);
|
|
57971
|
+
} finally {
|
|
57972
|
+
try {
|
|
57973
|
+
inferSpin.stop();
|
|
57974
|
+
} catch {
|
|
57975
|
+
}
|
|
57976
|
+
}
|
|
57977
|
+
} catch {
|
|
57978
|
+
}
|
|
57979
|
+
const filesOption = options["file"];
|
|
57980
|
+
const filesFromFlags = Array.isArray(filesOption) ? filesOption : filesOption ? [filesOption] : [];
|
|
57981
|
+
const detectedFromText = Array.from(rawText.match(/[A-Za-z]:\\[^\r\n]+/g) || []).map((s2) => s2.trim().replace(/[\s\.,;\)]*$/, ""));
|
|
57982
|
+
const noRegen = /\bdo\s*not\s*regenerate\b|\bdo\s*not\s*re\s*gen\b|\bdo\s*not\s*re\s*create\b|\bno\s*regen\b|\bDO\s*NOT\s*REGENERATE\b/i.test(rawText);
|
|
57983
|
+
const files = Array.from(/* @__PURE__ */ new Set([...inferred.files || [], ...filesFromFlags, ...detectedFromText]));
|
|
57984
|
+
const orchestrator = new EvaluationOrchestrator(root);
|
|
57985
|
+
const spinner = new ProcessAnimation();
|
|
57986
|
+
spinner.start();
|
|
57987
|
+
let criteriaPath;
|
|
57988
|
+
let result;
|
|
57989
|
+
try {
|
|
57990
|
+
const assessed = await orchestrator.assess({
|
|
57991
|
+
root,
|
|
57992
|
+
criteria: options["criteria"] || inferred.criteriaPath || void 0,
|
|
57993
|
+
files,
|
|
57994
|
+
idea: options["idea"] || inferred.idea || void 0,
|
|
57995
|
+
code: options["code"] || inferred.code || void 0,
|
|
57996
|
+
regenerateCriteria: noRegen ? false : !!options["regenerate"] || !!options["regen"] || !options["criteria"] || !!inferred.regenerate,
|
|
57997
|
+
llmScoring: options["no-llm-scoring"] ? false : true,
|
|
57998
|
+
criteriaOnly: !!options["criteria-only"] || !!inferred.criteriaOnly
|
|
57999
|
+
});
|
|
58000
|
+
criteriaPath = assessed.criteriaPath;
|
|
58001
|
+
result = assessed.result;
|
|
58002
|
+
} finally {
|
|
58003
|
+
try {
|
|
58004
|
+
spinner.stop();
|
|
58005
|
+
} catch {
|
|
58006
|
+
}
|
|
58007
|
+
}
|
|
58008
|
+
const system = [
|
|
58009
|
+
"You are an expert evaluator.",
|
|
58010
|
+
"Return a concise English assessment with:",
|
|
58011
|
+
"- A one-line overall verdict",
|
|
58012
|
+
"- A weighted score (0-100)",
|
|
58013
|
+
"- A short bullet breakdown per criterion (name: score/100 - brief reason)",
|
|
58014
|
+
"Be direct and professional.",
|
|
58015
|
+
// Strong guard: attachments are uploaded; do not ask for local file content
|
|
58016
|
+
"The input files are already uploaded and referenced via file URIs.",
|
|
58017
|
+
"Use the provided attachments; do not ask the user to paste file contents.",
|
|
58018
|
+
"Do not claim you cannot access local file paths."
|
|
58019
|
+
].join("\n");
|
|
58020
|
+
if (result === null) {
|
|
58021
|
+
const rel = path10__namespace.default.relative(root, criteriaPath);
|
|
58022
|
+
return this.success(`Criteria file created: ${rel}`);
|
|
58023
|
+
}
|
|
58024
|
+
if (result?.passThroughText) {
|
|
58025
|
+
return this.success(result.passThroughText, {
|
|
58026
|
+
type: "evaluation-assess-passthrough",
|
|
58027
|
+
total: 0
|
|
58028
|
+
});
|
|
58029
|
+
}
|
|
58030
|
+
const breakdown = result.details.map((d) => `- ${d.name} (${Math.round(d.weight * 100)}%): ${Math.round(d.score * 100)}/100 - ${d.reason}`).join("\n");
|
|
58031
|
+
const user = [
|
|
58032
|
+
`Project root: ${path10__namespace.default.basename(root)}`,
|
|
58033
|
+
`Criteria file: ${path10__namespace.default.relative(root, criteriaPath)}`,
|
|
58034
|
+
`Weighted total: ${Math.round(result.totalScore * 100)}/100`,
|
|
58035
|
+
`Breakdown:
|
|
58036
|
+
${breakdown}`,
|
|
58037
|
+
options["idea"] || inferred.idea ? `Idea:
|
|
58038
|
+
${options["idea"] || inferred.idea}` : void 0,
|
|
58039
|
+
options["code"] || inferred.code ? `Code snippet:
|
|
58040
|
+
${options["code"] || inferred.code}` : void 0
|
|
58041
|
+
// No inline file contents; rely on attachments only
|
|
58042
|
+
].filter(Boolean).join("\n\n");
|
|
58043
|
+
const llmSpinner = new ProcessAnimation();
|
|
58044
|
+
llmSpinner.start();
|
|
58045
|
+
try {
|
|
58046
|
+
const enriched = [
|
|
58047
|
+
system,
|
|
58048
|
+
"\n---\n",
|
|
58049
|
+
user
|
|
58050
|
+
].join("\n");
|
|
58051
|
+
const attachments = Array.isArray(result?.files) ? result.files.map((f3) => ({
|
|
58052
|
+
name: path10__namespace.default.basename(String(f3.path || "attachment.txt")),
|
|
58053
|
+
path: String(f3.path || ""),
|
|
58054
|
+
mime: String(f3.mime || "text/plain"),
|
|
58055
|
+
data_base64: f3.binaryBase64 ? String(f3.binaryBase64) : f3.content ? Buffer.from(f3.content, "utf8").toString("base64") : void 0
|
|
58056
|
+
})).filter((a) => !!a.data_base64) : [];
|
|
58057
|
+
const response = await callAPI("/v1/ai-proxy", {
|
|
58058
|
+
method: "POST",
|
|
58059
|
+
body: {
|
|
58060
|
+
// Force Google route and always use the attachments-capable model
|
|
58061
|
+
provider: "google",
|
|
58062
|
+
model: "gemini-2.5-flash",
|
|
58063
|
+
prompt: enriched,
|
|
58064
|
+
taskType: "evaluation",
|
|
58065
|
+
metadata: attachments.length ? { attachments } : void 0
|
|
58066
|
+
}
|
|
58067
|
+
});
|
|
58068
|
+
const routedModel = response?.data?.routedModel;
|
|
58069
|
+
const content = (response?.data?.content || response?.output || "").trim();
|
|
58070
|
+
const uploads = response?.data?.uploads || [];
|
|
58071
|
+
if (content) {
|
|
58072
|
+
const uploadNote = uploads.length ? `Attached ${uploads.length} file(s) uploaded and referenced.` : attachments.length ? `Attached ${attachments.length} local file(s).` : void 0;
|
|
58073
|
+
const finalText = uploadNote ? `${uploadNote}
|
|
58074
|
+
|
|
58075
|
+
${content}` : content;
|
|
58076
|
+
return this.success(finalText, {
|
|
58077
|
+
type: "evaluation-assess",
|
|
58078
|
+
total: result.totalScore,
|
|
58079
|
+
details: result.details,
|
|
58080
|
+
routedModel,
|
|
58081
|
+
uploads
|
|
58082
|
+
});
|
|
58083
|
+
}
|
|
58084
|
+
} catch (e2) {
|
|
58085
|
+
try {
|
|
58086
|
+
llmSpinner.stop();
|
|
58087
|
+
} catch {
|
|
58088
|
+
}
|
|
58089
|
+
const msg = e2?.message || "LLM scoring failed";
|
|
58090
|
+
return this.error(`Evaluation failed: ${msg}`, "EVALUATION_ERROR", "LLM scoring is required and fallback is disabled");
|
|
58091
|
+
} finally {
|
|
58092
|
+
try {
|
|
58093
|
+
llmSpinner.stop();
|
|
58094
|
+
} catch {
|
|
58095
|
+
}
|
|
58096
|
+
}
|
|
58097
|
+
return this.error("Evaluation failed: unknown state", "EVALUATION_ERROR");
|
|
58098
|
+
}
|
|
58099
|
+
/**
|
|
58100
|
+
* Run A/B evaluation test
|
|
58101
|
+
*/
|
|
58102
|
+
async runEvaluation(options, context2) {
|
|
58103
|
+
const config2 = this.parseEvaluationConfig(options);
|
|
58104
|
+
const validation = await this.validateConfig(config2);
|
|
58105
|
+
if (!validation.success) {
|
|
58106
|
+
return this.error(
|
|
58107
|
+
validation.error || "Invalid configuration",
|
|
58108
|
+
"CONFIG_ERROR"
|
|
58109
|
+
);
|
|
58110
|
+
}
|
|
58111
|
+
logger.info("Starting A/B evaluation test", {
|
|
58112
|
+
config: config2,
|
|
58113
|
+
user: context2.user?.id
|
|
58114
|
+
});
|
|
58115
|
+
const testResult = await this.executeEvaluation(config2);
|
|
58116
|
+
const formattedOutput = this.formatEvaluationStart(testResult);
|
|
58117
|
+
return this.success(formattedOutput, {
|
|
58118
|
+
testId: testResult.testId,
|
|
58119
|
+
status: testResult.status,
|
|
58120
|
+
type: "evaluation-started"
|
|
58121
|
+
});
|
|
58122
|
+
}
|
|
58123
|
+
/**
|
|
58124
|
+
* Get evaluation system status
|
|
58125
|
+
*/
|
|
58126
|
+
async getEvaluationStatus(_options) {
|
|
58127
|
+
const status = await this.fetchEvaluationStatus();
|
|
58128
|
+
const formattedOutput = this.formatEvaluationStatus(status);
|
|
58129
|
+
return this.success(formattedOutput, {
|
|
58130
|
+
activeTests: status.activeTests.length,
|
|
58131
|
+
completedTests: status.completedTests.length,
|
|
58132
|
+
systemHealth: status.systemHealth,
|
|
58133
|
+
type: "evaluation-status"
|
|
58134
|
+
});
|
|
58135
|
+
}
|
|
58136
|
+
/**
|
|
58137
|
+
* Get evaluation results
|
|
58138
|
+
*/
|
|
58139
|
+
async getEvaluationResults(options) {
|
|
58140
|
+
const format = options["format"] || "table";
|
|
58141
|
+
const results = await this.fetchLatestResults();
|
|
58142
|
+
const formattedOutput = this.formatEvaluationResults(results, format);
|
|
58143
|
+
return this.success(formattedOutput, {
|
|
58144
|
+
resultCount: results.length,
|
|
58145
|
+
format,
|
|
58146
|
+
type: "evaluation-results"
|
|
58147
|
+
});
|
|
58148
|
+
}
|
|
58149
|
+
/**
|
|
58150
|
+
* Stop running evaluation
|
|
58151
|
+
*/
|
|
58152
|
+
async stopEvaluation(options) {
|
|
58153
|
+
const testId = options["test-id"];
|
|
58154
|
+
if (!testId) {
|
|
58155
|
+
return this.error(
|
|
58156
|
+
"Test ID is required to stop evaluation",
|
|
58157
|
+
"MISSING_TEST_ID",
|
|
58158
|
+
"Use --test-id <id> to specify which test to stop"
|
|
58159
|
+
);
|
|
58160
|
+
}
|
|
58161
|
+
await this.terminateEvaluation(testId);
|
|
58162
|
+
return this.success(`Evaluation test ${testId} stopped successfully`, {
|
|
58163
|
+
testId,
|
|
58164
|
+
type: "evaluation-stopped"
|
|
58165
|
+
});
|
|
58166
|
+
}
|
|
58167
|
+
/**
|
|
58168
|
+
* Parse evaluation configuration
|
|
58169
|
+
*/
|
|
58170
|
+
parseEvaluationConfig(options) {
|
|
58171
|
+
return {
|
|
58172
|
+
datasetPath: options["dataset"] || options["config"],
|
|
58173
|
+
testName: options["name"] || `eval_${Date.now()}`,
|
|
58174
|
+
maxQueries: parseInt(options["max-queries"] || "100", 10),
|
|
58175
|
+
metrics: (options["metrics"] || "nDCG,MRR,precision").split(","),
|
|
58176
|
+
outputFormat: options["format"] || "table",
|
|
58177
|
+
compareBaseline: options["compare-baseline"] || false
|
|
58178
|
+
};
|
|
58179
|
+
}
|
|
58180
|
+
/**
|
|
58181
|
+
* Validate evaluation configuration
|
|
58182
|
+
*/
|
|
58183
|
+
async validateConfig(config2) {
|
|
58184
|
+
if (config2.datasetPath && !config2.datasetPath.endsWith(".json")) {
|
|
58185
|
+
return { success: false, error: "Dataset must be a JSON file" };
|
|
58186
|
+
}
|
|
58187
|
+
if (config2.maxQueries && (config2.maxQueries < 1 || config2.maxQueries > 1e4)) {
|
|
58188
|
+
return {
|
|
58189
|
+
success: false,
|
|
58190
|
+
error: "Max queries must be between 1 and 10000"
|
|
58191
|
+
};
|
|
58192
|
+
}
|
|
58193
|
+
const validMetrics = ["nDCG", "MRR", "precision", "recall", "latency"];
|
|
58194
|
+
if (config2.metrics && !config2.metrics.every((m2) => validMetrics.includes(m2))) {
|
|
58195
|
+
return {
|
|
58196
|
+
success: false,
|
|
58197
|
+
error: `Invalid metrics. Valid options: ${validMetrics.join(", ")}`
|
|
58198
|
+
};
|
|
58199
|
+
}
|
|
58200
|
+
const validFormats = ["table", "json", "csv"];
|
|
58201
|
+
if (config2.outputFormat && !validFormats.includes(config2.outputFormat)) {
|
|
58202
|
+
return {
|
|
58203
|
+
success: false,
|
|
58204
|
+
error: `Invalid format. Valid options: ${validFormats.join(", ")}`
|
|
58205
|
+
};
|
|
58206
|
+
}
|
|
58207
|
+
return { success: true };
|
|
58208
|
+
}
|
|
58209
|
+
/**
|
|
58210
|
+
* Execute evaluation (mock implementation)
|
|
58211
|
+
*/
|
|
58212
|
+
async executeEvaluation(config2) {
|
|
58213
|
+
await new Promise((resolve19) => setTimeout(resolve19, 500));
|
|
58214
|
+
return {
|
|
58215
|
+
testId: `eval_${Math.random().toString(36).substr(2, 9)}`,
|
|
58216
|
+
testName: config2.testName || "Unnamed Test",
|
|
58217
|
+
timestamp: Date.now(),
|
|
58218
|
+
status: "running",
|
|
58219
|
+
metrics: {
|
|
58220
|
+
nDCG_at_1: 0,
|
|
58221
|
+
nDCG_at_5: 0,
|
|
58222
|
+
nDCG_at_10: 0,
|
|
58223
|
+
MRR: 0,
|
|
58224
|
+
precision_at_1: 0,
|
|
58225
|
+
precision_at_5: 0,
|
|
58226
|
+
recall_at_10: 0,
|
|
58227
|
+
latency_p50: 0,
|
|
58228
|
+
latency_p95: 0
|
|
58229
|
+
},
|
|
58230
|
+
queryCount: 0,
|
|
58231
|
+
duration: 0
|
|
58232
|
+
};
|
|
58233
|
+
}
|
|
58234
|
+
/**
|
|
58235
|
+
* Fetch evaluation system status
|
|
58236
|
+
*/
|
|
58237
|
+
async fetchEvaluationStatus() {
|
|
58238
|
+
return {
|
|
58239
|
+
activeTests: [
|
|
58240
|
+
{
|
|
58241
|
+
testId: "eval_abc123",
|
|
58242
|
+
testName: "SharePoint RAG Evaluation",
|
|
58243
|
+
timestamp: Date.now() - 3e5,
|
|
58244
|
+
// 5 minutes ago
|
|
58245
|
+
status: "running",
|
|
58246
|
+
metrics: {
|
|
58247
|
+
nDCG_at_1: 0.75,
|
|
58248
|
+
nDCG_at_5: 0.68,
|
|
58249
|
+
nDCG_at_10: 0.64,
|
|
58250
|
+
MRR: 0.72,
|
|
58251
|
+
precision_at_1: 0.75,
|
|
58252
|
+
precision_at_5: 0.68,
|
|
58253
|
+
recall_at_10: 0.85,
|
|
58254
|
+
latency_p50: 245.5,
|
|
58255
|
+
latency_p95: 520.2
|
|
58256
|
+
},
|
|
58257
|
+
queryCount: 45,
|
|
58258
|
+
duration: 300
|
|
58259
|
+
}
|
|
58260
|
+
],
|
|
58261
|
+
completedTests: [
|
|
58262
|
+
{
|
|
58263
|
+
testId: "eval_xyz789",
|
|
58264
|
+
testName: "Baseline Comparison Test",
|
|
58265
|
+
timestamp: Date.now() - 36e5,
|
|
58266
|
+
// 1 hour ago
|
|
58267
|
+
status: "completed",
|
|
58268
|
+
metrics: {
|
|
58269
|
+
nDCG_at_1: 0.82,
|
|
58270
|
+
nDCG_at_5: 0.74,
|
|
58271
|
+
nDCG_at_10: 0.69,
|
|
58272
|
+
MRR: 0.79,
|
|
58273
|
+
precision_at_1: 0.82,
|
|
58274
|
+
precision_at_5: 0.74,
|
|
58275
|
+
recall_at_10: 0.89,
|
|
58276
|
+
latency_p50: 189.3,
|
|
58277
|
+
latency_p95: 445.8
|
|
58278
|
+
},
|
|
58279
|
+
queryCount: 100,
|
|
58280
|
+
duration: 1247,
|
|
58281
|
+
baselineComparison: {
|
|
58282
|
+
improvement: {
|
|
58283
|
+
nDCG_at_1: 0.08,
|
|
58284
|
+
nDCG_at_5: 0.12,
|
|
58285
|
+
MRR: 0.15,
|
|
58286
|
+
latency_p50: -0.22
|
|
58287
|
+
},
|
|
58288
|
+
significant: {
|
|
58289
|
+
nDCG_at_1: true,
|
|
58290
|
+
nDCG_at_5: true,
|
|
58291
|
+
MRR: true,
|
|
58292
|
+
latency_p50: true
|
|
58293
|
+
}
|
|
58294
|
+
}
|
|
58295
|
+
}
|
|
58296
|
+
],
|
|
58297
|
+
systemHealth: {
|
|
58298
|
+
evaluationService: "healthy",
|
|
58299
|
+
datasetAccess: "available",
|
|
58300
|
+
metricsCollection: "active"
|
|
58301
|
+
}
|
|
58302
|
+
};
|
|
58303
|
+
}
|
|
58304
|
+
/**
|
|
58305
|
+
* Fetch latest evaluation results
|
|
58306
|
+
*/
|
|
58307
|
+
async fetchLatestResults() {
|
|
58308
|
+
const status = await this.fetchEvaluationStatus();
|
|
58309
|
+
return [...status.activeTests, ...status.completedTests].slice(0, 5);
|
|
58310
|
+
}
|
|
58311
|
+
/**
|
|
58312
|
+
* Terminate evaluation
|
|
58313
|
+
*/
|
|
58314
|
+
async terminateEvaluation(_testId) {
|
|
58315
|
+
await new Promise((resolve19) => setTimeout(resolve19, 200));
|
|
58316
|
+
return true;
|
|
58317
|
+
}
|
|
58318
|
+
/**
|
|
58319
|
+
* Format evaluation start message
|
|
58320
|
+
*/
|
|
58321
|
+
formatEvaluationStart(_result) {
|
|
58322
|
+
const lines = [];
|
|
58323
|
+
lines.push("");
|
|
58324
|
+
lines.push("\u{1F9EA} A/B EVALUATION STARTED");
|
|
58325
|
+
lines.push("\u2550".repeat(40));
|
|
58326
|
+
lines.push("");
|
|
58327
|
+
lines.push(`Test ID: ${_result.testId}`);
|
|
58328
|
+
lines.push(`Test Name: ${_result.testName}`);
|
|
58329
|
+
lines.push(`Status: ${_result.status.toUpperCase()}`);
|
|
58330
|
+
lines.push(`Started: ${new Date(_result.timestamp).toLocaleString()}`);
|
|
58331
|
+
lines.push("");
|
|
58332
|
+
lines.push("\u{1F4CA} **Metrics to Collect:**");
|
|
58333
|
+
lines.push(" \u2022 nDCG@1, nDCG@5, nDCG@10");
|
|
58334
|
+
lines.push(" \u2022 Mean Reciprocal Rank (MRR)");
|
|
58335
|
+
lines.push(" \u2022 Precision@1, Precision@5");
|
|
58336
|
+
lines.push(" \u2022 Recall@10");
|
|
58337
|
+
lines.push(" \u2022 Latency (p50, p95)");
|
|
58338
|
+
lines.push("");
|
|
58339
|
+
lines.push("\u{1F4A1} **Monitor Progress:**");
|
|
58340
|
+
lines.push(" Use `/evaluate status` to check progress");
|
|
58341
|
+
lines.push(" Use `/evaluate results` to see latest metrics");
|
|
58342
|
+
return lines.join("\n");
|
|
58343
|
+
}
|
|
58344
|
+
/**
|
|
58345
|
+
* Format evaluation status
|
|
58346
|
+
*/
|
|
58347
|
+
formatEvaluationStatus(status) {
|
|
58348
|
+
const lines = [];
|
|
58349
|
+
lines.push("");
|
|
58350
|
+
lines.push("\u{1F4CA} EVALUATION SYSTEM STATUS");
|
|
58351
|
+
lines.push("\u2550".repeat(40));
|
|
58352
|
+
lines.push("");
|
|
58353
|
+
lines.push("\u{1F527} **System Health:**");
|
|
58354
|
+
lines.push(
|
|
58355
|
+
` Evaluation Service: ${this.getHealthIcon(status.systemHealth.evaluationService)} ${status.systemHealth.evaluationService}`
|
|
58356
|
+
);
|
|
58357
|
+
lines.push(
|
|
58358
|
+
` Dataset Access: ${this.getHealthIcon(status.systemHealth.datasetAccess)} ${status.systemHealth.datasetAccess}`
|
|
58359
|
+
);
|
|
58360
|
+
lines.push(
|
|
58361
|
+
` Metrics Collection: ${this.getHealthIcon(status.systemHealth.metricsCollection)} ${status.systemHealth.metricsCollection}`
|
|
58362
|
+
);
|
|
58363
|
+
lines.push("");
|
|
58364
|
+
if (status.activeTests.length > 0) {
|
|
58365
|
+
lines.push(`\u26A1 **Active Tests (${status.activeTests.length}):**`);
|
|
58366
|
+
for (const test of status.activeTests) {
|
|
58367
|
+
lines.push(` \u2022 ${test.testName} (${test.testId})`);
|
|
58368
|
+
lines.push(
|
|
58369
|
+
` Progress: ${test.queryCount} queries, ${Math.round(test.duration / 60)}m elapsed`
|
|
58370
|
+
);
|
|
58371
|
+
lines.push(` Current nDCG@5: ${test.metrics.nDCG_at_5.toFixed(3)}`);
|
|
58372
|
+
}
|
|
58373
|
+
lines.push("");
|
|
58374
|
+
}
|
|
58375
|
+
if (status.completedTests.length > 0) {
|
|
58376
|
+
lines.push(
|
|
58377
|
+
`\u2705 **Recent Completed Tests (${status.completedTests.length}):**`
|
|
58378
|
+
);
|
|
58379
|
+
for (const test of status.completedTests.slice(0, 3)) {
|
|
58380
|
+
const timeAgo = Math.round((Date.now() - test.timestamp) / 6e4);
|
|
58381
|
+
lines.push(` \u2022 ${test.testName} - ${timeAgo}m ago`);
|
|
58382
|
+
lines.push(
|
|
58383
|
+
` nDCG@5: ${test.metrics.nDCG_at_5.toFixed(3)}, MRR: ${test.metrics.MRR.toFixed(3)}`
|
|
58384
|
+
);
|
|
58385
|
+
if (test.baselineComparison) {
|
|
58386
|
+
const improvement = (test.baselineComparison.improvement.nDCG_at_5 * 100).toFixed(1);
|
|
58387
|
+
lines.push(` Improvement: +${improvement}% vs baseline`);
|
|
58388
|
+
}
|
|
58389
|
+
}
|
|
58390
|
+
}
|
|
58391
|
+
return lines.join("\n");
|
|
58392
|
+
}
|
|
58393
|
+
/**
|
|
58394
|
+
* Format evaluation results
|
|
58395
|
+
*/
|
|
58396
|
+
formatEvaluationResults(results, format) {
|
|
58397
|
+
if (format === "json") {
|
|
58398
|
+
return JSON.stringify(results, null, 2);
|
|
58399
|
+
}
|
|
58400
|
+
if (format === "csv") {
|
|
58401
|
+
const headers = [
|
|
58402
|
+
"Test ID",
|
|
58403
|
+
"Name",
|
|
58404
|
+
"Status",
|
|
58405
|
+
"nDCG@5",
|
|
58406
|
+
"MRR",
|
|
58407
|
+
"P@1",
|
|
58408
|
+
"Latency P50"
|
|
58409
|
+
];
|
|
58410
|
+
const rows = results.map((r2) => [
|
|
58411
|
+
r2.testId,
|
|
58412
|
+
r2.testName,
|
|
58413
|
+
r2.status,
|
|
58414
|
+
r2.metrics.nDCG_at_5.toFixed(3),
|
|
58415
|
+
r2.metrics.MRR.toFixed(3),
|
|
58416
|
+
r2.metrics.precision_at_1.toFixed(3),
|
|
58417
|
+
r2.metrics.latency_p50.toFixed(1)
|
|
58418
|
+
]);
|
|
58419
|
+
return [headers.join(","), ...rows.map((row) => row.join(","))].join(
|
|
58420
|
+
"\n"
|
|
58421
|
+
);
|
|
58422
|
+
}
|
|
58423
|
+
const lines = [];
|
|
58424
|
+
lines.push("");
|
|
58425
|
+
lines.push("\u{1F4C8} EVALUATION RESULTS");
|
|
58426
|
+
lines.push("\u2550".repeat(60));
|
|
58427
|
+
lines.push("");
|
|
58428
|
+
for (const _result of results) {
|
|
58429
|
+
lines.push(`**${_result.testName}** (${_result.testId})`);
|
|
58430
|
+
lines.push(
|
|
58431
|
+
`Status: ${_result.status.toUpperCase()} | Queries: ${_result.queryCount} | Duration: ${Math.round(_result.duration / 60)}m`
|
|
58432
|
+
);
|
|
58433
|
+
lines.push("");
|
|
58434
|
+
lines.push("\u{1F4CA} **Quality Metrics:**");
|
|
58435
|
+
lines.push(
|
|
58436
|
+
` nDCG@1: ${_result.metrics.nDCG_at_1.toFixed(3)} nDCG@5: ${_result.metrics.nDCG_at_5.toFixed(3)} nDCG@10: ${_result.metrics.nDCG_at_10.toFixed(3)}`
|
|
58437
|
+
);
|
|
58438
|
+
lines.push(
|
|
58439
|
+
` MRR: ${_result.metrics.MRR.toFixed(3)} P@1: ${_result.metrics.precision_at_1.toFixed(3)} P@5: ${_result.metrics.precision_at_5.toFixed(3)}`
|
|
58440
|
+
);
|
|
58441
|
+
lines.push(` Recall@10: ${_result.metrics.recall_at_10.toFixed(3)}`);
|
|
58442
|
+
lines.push("");
|
|
58443
|
+
lines.push("\u26A1 **Performance:**");
|
|
58444
|
+
lines.push(
|
|
58445
|
+
` Latency P50: ${_result.metrics.latency_p50.toFixed(1)}ms P95: ${_result.metrics.latency_p95.toFixed(1)}ms`
|
|
58446
|
+
);
|
|
58447
|
+
if (_result.baselineComparison) {
|
|
58448
|
+
lines.push("");
|
|
58449
|
+
lines.push("\u{1F504} **vs Baseline:**");
|
|
58450
|
+
const improvement = _result.baselineComparison.improvement;
|
|
58451
|
+
const significant = _result.baselineComparison.significant;
|
|
58452
|
+
lines.push(
|
|
58453
|
+
` nDCG@5: ${improvement.nDCG_at_5 >= 0 ? "+" : ""}${(improvement.nDCG_at_5 * 100).toFixed(1)}% ${significant.nDCG_at_5 ? "\u2713" : "\u2717"}`
|
|
58454
|
+
);
|
|
58455
|
+
lines.push(
|
|
58456
|
+
` MRR: ${improvement.MRR >= 0 ? "+" : ""}${(improvement.MRR * 100).toFixed(1)}% ${significant.MRR ? "\u2713" : "\u2717"}`
|
|
58457
|
+
);
|
|
58458
|
+
lines.push(
|
|
58459
|
+
` Latency: ${improvement.latency_p50 >= 0 ? "+" : ""}${(improvement.latency_p50 * 100).toFixed(1)}% ${significant.latency_p50 ? "\u2713" : "\u2717"}`
|
|
58460
|
+
);
|
|
58461
|
+
}
|
|
58462
|
+
lines.push("");
|
|
58463
|
+
lines.push("\u2500".repeat(40));
|
|
58464
|
+
lines.push("");
|
|
58465
|
+
}
|
|
58466
|
+
return lines.join("\n");
|
|
58467
|
+
}
|
|
58468
|
+
/**
|
|
58469
|
+
* Get health status icon
|
|
58470
|
+
*/
|
|
58471
|
+
getHealthIcon(status) {
|
|
58472
|
+
switch (status) {
|
|
58473
|
+
case "healthy":
|
|
58474
|
+
case "available":
|
|
58475
|
+
case "active":
|
|
58476
|
+
return "\u{1F7E2}";
|
|
58477
|
+
case "degraded":
|
|
58478
|
+
case "limited":
|
|
58479
|
+
return "\u{1F7E1}";
|
|
58480
|
+
case "down":
|
|
58481
|
+
case "unavailable":
|
|
58482
|
+
case "inactive":
|
|
58483
|
+
return "\u{1F534}";
|
|
58484
|
+
default:
|
|
58485
|
+
return "\u26AA";
|
|
58486
|
+
}
|
|
58487
|
+
}
|
|
58488
|
+
/**
|
|
58489
|
+
* Command validation
|
|
58490
|
+
*/
|
|
58491
|
+
async validate(args2) {
|
|
58492
|
+
const { parsed, options } = args2;
|
|
58493
|
+
const positional = parsed["positional"] || [];
|
|
58494
|
+
const subcommand = positional[0];
|
|
58495
|
+
if (subcommand === "run") {
|
|
58496
|
+
if (options["max-queries"] && isNaN(parseInt(options["max-queries"], 10))) {
|
|
58497
|
+
return {
|
|
58498
|
+
success: false,
|
|
58499
|
+
error: "max-queries must be a number"
|
|
58500
|
+
};
|
|
58501
|
+
}
|
|
58502
|
+
}
|
|
58503
|
+
if (subcommand === "stop" && !options["test-id"]) {
|
|
58504
|
+
return {
|
|
58505
|
+
success: false,
|
|
58506
|
+
error: "stop command requires --test-id parameter"
|
|
58507
|
+
};
|
|
58508
|
+
}
|
|
58509
|
+
return { success: true };
|
|
58510
|
+
}
|
|
58511
|
+
};
|
|
58512
|
+
meta26 = {
|
|
58513
|
+
name: "evaluate",
|
|
58514
|
+
category: "evaluation",
|
|
58515
|
+
description: "A/B testing and quality evaluation framework",
|
|
58516
|
+
aliases: ["eval", "test", "ab"],
|
|
58517
|
+
usage: "/evaluate [run|status|results|stop] [options]",
|
|
58518
|
+
examples: [
|
|
58519
|
+
"/evaluate run --dataset data.json",
|
|
58520
|
+
"/evaluate status",
|
|
58521
|
+
"/evaluate results --format table",
|
|
58522
|
+
"/evaluate stop --test-id eval_abc123"
|
|
58523
|
+
],
|
|
58524
|
+
deps: []
|
|
58525
|
+
};
|
|
58526
|
+
evaluate_command_default = EvaluateCommand;
|
|
58527
|
+
}
|
|
58528
|
+
});
|
|
57390
58529
|
|
|
57391
58530
|
// src/slash-commands/index.ts
|
|
57392
58531
|
var slash_commands_exports = {};
|
|
@@ -57876,15 +59015,23 @@ async function registerBuiltInCommands() {
|
|
|
57876
59015
|
initialize: async () => {
|
|
57877
59016
|
}
|
|
57878
59017
|
});
|
|
57879
|
-
|
|
57880
|
-
|
|
57881
|
-
|
|
57882
|
-
|
|
57883
|
-
|
|
57884
|
-
|
|
57885
|
-
|
|
57886
|
-
|
|
57887
|
-
|
|
59018
|
+
try {
|
|
59019
|
+
const EvaluateModule = await Promise.resolve().then(() => (init_evaluate_command(), evaluate_command_exports));
|
|
59020
|
+
const EvaluateClass = EvaluateModule.EvaluateCommand || EvaluateModule.default;
|
|
59021
|
+
const evaluate = new EvaluateClass();
|
|
59022
|
+
if (evaluate.initialize) await evaluate.initialize();
|
|
59023
|
+
commandRegistry.register(evaluate);
|
|
59024
|
+
} catch {
|
|
59025
|
+
commandRegistry.register({
|
|
59026
|
+
name: "evaluate",
|
|
59027
|
+
category: "evaluation",
|
|
59028
|
+
description: "Evaluation system",
|
|
59029
|
+
aliases: [],
|
|
59030
|
+
execute: async () => shield2({ message: "\u{1F512} Not available in this build" }),
|
|
59031
|
+
initialize: async () => {
|
|
59032
|
+
}
|
|
59033
|
+
});
|
|
59034
|
+
}
|
|
57888
59035
|
commandRegistry.register({
|
|
57889
59036
|
name: "multimodal",
|
|
57890
59037
|
category: "multimodal",
|
|
@@ -68383,8 +69530,8 @@ var init_ConfigService = __esm({
|
|
|
68383
69530
|
/**
|
|
68384
69531
|
* ネストされた設定値の取得
|
|
68385
69532
|
*/
|
|
68386
|
-
getNestedValue(
|
|
68387
|
-
const keys =
|
|
69533
|
+
getNestedValue(path64) {
|
|
69534
|
+
const keys = path64.split(".");
|
|
68388
69535
|
let value = this._config;
|
|
68389
69536
|
for (const key of keys) {
|
|
68390
69537
|
if (value && typeof value === "object" && key in value) {
|
|
@@ -68414,8 +69561,8 @@ var init_ConfigService = __esm({
|
|
|
68414
69561
|
/**
|
|
68415
69562
|
* ネストされた設定値の更新
|
|
68416
69563
|
*/
|
|
68417
|
-
async setNestedValue(
|
|
68418
|
-
const keys =
|
|
69564
|
+
async setNestedValue(path64, value) {
|
|
69565
|
+
const keys = path64.split(".");
|
|
68419
69566
|
const lastKey = keys.pop();
|
|
68420
69567
|
let target = this._config;
|
|
68421
69568
|
for (const key of keys) {
|
|
@@ -68428,7 +69575,7 @@ var init_ConfigService = __esm({
|
|
|
68428
69575
|
target[lastKey] = value;
|
|
68429
69576
|
this.validateConfig();
|
|
68430
69577
|
this.emitChange({
|
|
68431
|
-
path:
|
|
69578
|
+
path: path64,
|
|
68432
69579
|
oldValue,
|
|
68433
69580
|
newValue: value,
|
|
68434
69581
|
timestamp: /* @__PURE__ */ new Date()
|
|
@@ -68473,8 +69620,8 @@ var init_ConfigService = __esm({
|
|
|
68473
69620
|
setupAutoSave() {
|
|
68474
69621
|
process.on("exit", () => {
|
|
68475
69622
|
if (this._isDirty) {
|
|
68476
|
-
const
|
|
68477
|
-
|
|
69623
|
+
const fs51 = __require("fs");
|
|
69624
|
+
fs51.writeFileSync(
|
|
68478
69625
|
this._userConfigPath,
|
|
68479
69626
|
JSON.stringify(this._config, null, 2),
|
|
68480
69627
|
"utf-8"
|
|
@@ -68485,13 +69632,13 @@ var init_ConfigService = __esm({
|
|
|
68485
69632
|
/**
|
|
68486
69633
|
* 変更リスナーの登録
|
|
68487
69634
|
*/
|
|
68488
|
-
onChange(
|
|
68489
|
-
if (!this._listeners.has(
|
|
68490
|
-
this._listeners.set(
|
|
69635
|
+
onChange(path64, listener) {
|
|
69636
|
+
if (!this._listeners.has(path64)) {
|
|
69637
|
+
this._listeners.set(path64, []);
|
|
68491
69638
|
}
|
|
68492
|
-
this._listeners.get(
|
|
69639
|
+
this._listeners.get(path64).push(listener);
|
|
68493
69640
|
return () => {
|
|
68494
|
-
const listeners = this._listeners.get(
|
|
69641
|
+
const listeners = this._listeners.get(path64);
|
|
68495
69642
|
if (listeners) {
|
|
68496
69643
|
const index = listeners.indexOf(listener);
|
|
68497
69644
|
if (index !== -1) {
|
|
@@ -68980,7 +70127,7 @@ var init_ValidationService = __esm({
|
|
|
68980
70127
|
);
|
|
68981
70128
|
this._schemas.set(
|
|
68982
70129
|
"filePath",
|
|
68983
|
-
zod.z.string().min(1).max(this._config.maxFilePathLength).refine((
|
|
70130
|
+
zod.z.string().min(1).max(this._config.maxFilePathLength).refine((path64) => !this.containsPathTraversal(path64), {
|
|
68984
70131
|
message: "Path traversal detected"
|
|
68985
70132
|
})
|
|
68986
70133
|
);
|
|
@@ -69119,11 +70266,11 @@ var init_ValidationService = __esm({
|
|
|
69119
70266
|
/**
|
|
69120
70267
|
* ファイルパス検証
|
|
69121
70268
|
*/
|
|
69122
|
-
validateFilePath(
|
|
70269
|
+
validateFilePath(path64) {
|
|
69123
70270
|
try {
|
|
69124
70271
|
const schema = this._schemas.get("filePath");
|
|
69125
|
-
const result = schema.parse(
|
|
69126
|
-
if (this.isSystemPath(
|
|
70272
|
+
const result = schema.parse(path64);
|
|
70273
|
+
if (this.isSystemPath(path64)) {
|
|
69127
70274
|
return {
|
|
69128
70275
|
valid: false,
|
|
69129
70276
|
errors: [
|
|
@@ -69269,8 +70416,8 @@ var init_ValidationService = __esm({
|
|
|
69269
70416
|
/**
|
|
69270
70417
|
* パストラバーサルの検出
|
|
69271
70418
|
*/
|
|
69272
|
-
containsPathTraversal(
|
|
69273
|
-
return /\.\.[/\\]/.test(
|
|
70419
|
+
containsPathTraversal(path64) {
|
|
70420
|
+
return /\.\.[/\\]/.test(path64) || path64.includes("..\\") || path64.includes("../");
|
|
69274
70421
|
}
|
|
69275
70422
|
/**
|
|
69276
70423
|
* 危険なコマンドの判定
|
|
@@ -69297,7 +70444,7 @@ var init_ValidationService = __esm({
|
|
|
69297
70444
|
/**
|
|
69298
70445
|
* システムパスの判定
|
|
69299
70446
|
*/
|
|
69300
|
-
isSystemPath(
|
|
70447
|
+
isSystemPath(path64) {
|
|
69301
70448
|
const systemPaths = [
|
|
69302
70449
|
"/etc",
|
|
69303
70450
|
"/sys",
|
|
@@ -69311,7 +70458,7 @@ var init_ValidationService = __esm({
|
|
|
69311
70458
|
"/sbin"
|
|
69312
70459
|
];
|
|
69313
70460
|
return systemPaths.some(
|
|
69314
|
-
(sysPath) =>
|
|
70461
|
+
(sysPath) => path64.toLowerCase().startsWith(sysPath.toLowerCase())
|
|
69315
70462
|
);
|
|
69316
70463
|
}
|
|
69317
70464
|
/**
|
|
@@ -73838,10 +74985,10 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
|
|
|
73838
74985
|
const finalize = async (text, data) => {
|
|
73839
74986
|
if (outputPath) {
|
|
73840
74987
|
try {
|
|
73841
|
-
const
|
|
73842
|
-
const
|
|
73843
|
-
const abs =
|
|
73844
|
-
await
|
|
74988
|
+
const fs51 = await import('fs/promises');
|
|
74989
|
+
const path64 = await import('path');
|
|
74990
|
+
const abs = path64.resolve(outputPath);
|
|
74991
|
+
await fs51.writeFile(abs, text, "utf-8");
|
|
73845
74992
|
const msg = `Saved doctor report to ${abs}`;
|
|
73846
74993
|
return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
|
|
73847
74994
|
} catch (e2) {
|
|
@@ -73931,10 +75078,10 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
|
|
|
73931
75078
|
const finalize = async (text, data) => {
|
|
73932
75079
|
if (outputPath) {
|
|
73933
75080
|
try {
|
|
73934
|
-
const
|
|
73935
|
-
const
|
|
73936
|
-
const abs =
|
|
73937
|
-
await
|
|
75081
|
+
const fs51 = await import('fs/promises');
|
|
75082
|
+
const path64 = await import('path');
|
|
75083
|
+
const abs = path64.resolve(outputPath);
|
|
75084
|
+
await fs51.writeFile(abs, text, "utf-8");
|
|
73938
75085
|
const msg = `Saved metrics to ${abs}`;
|
|
73939
75086
|
return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
|
|
73940
75087
|
} catch (e2) {
|
|
@@ -74323,15 +75470,15 @@ var init_SessionOrchestrator = __esm({
|
|
|
74323
75470
|
/**
|
|
74324
75471
|
* 設定の取得
|
|
74325
75472
|
*/
|
|
74326
|
-
getConfig(
|
|
74327
|
-
return this._configService?.getNestedValue(
|
|
75473
|
+
getConfig(path64) {
|
|
75474
|
+
return this._configService?.getNestedValue(path64);
|
|
74328
75475
|
}
|
|
74329
75476
|
/**
|
|
74330
75477
|
* 設定の更新
|
|
74331
75478
|
*/
|
|
74332
|
-
async setConfig(
|
|
75479
|
+
async setConfig(path64, value) {
|
|
74333
75480
|
if (this._configService) {
|
|
74334
|
-
await this._configService.setNestedValue(
|
|
75481
|
+
await this._configService.setNestedValue(path64, value);
|
|
74335
75482
|
}
|
|
74336
75483
|
}
|
|
74337
75484
|
/**
|
|
@@ -74449,11 +75596,11 @@ var init_interactive_session2 = __esm({
|
|
|
74449
75596
|
getStats() {
|
|
74450
75597
|
return this.orchestrator.getSessionStats();
|
|
74451
75598
|
}
|
|
74452
|
-
getConfig(
|
|
74453
|
-
return this.orchestrator.getConfig(
|
|
75599
|
+
getConfig(path64) {
|
|
75600
|
+
return this.orchestrator.getConfig(path64);
|
|
74454
75601
|
}
|
|
74455
|
-
async setConfig(
|
|
74456
|
-
await this.orchestrator.setConfig(
|
|
75602
|
+
async setConfig(path64, value) {
|
|
75603
|
+
await this.orchestrator.setConfig(path64, value);
|
|
74457
75604
|
}
|
|
74458
75605
|
};
|
|
74459
75606
|
}
|