@bonginkan/maria 4.3.27 → 4.3.29
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 +414 -68
- package/dist/bin/maria.cjs.map +1 -1
- package/dist/cli.cjs +414 -68
- 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/bin/maria.cjs
CHANGED
|
@@ -26066,8 +26066,8 @@ var require_package = __commonJS({
|
|
|
26066
26066
|
"package.json"(exports, module) {
|
|
26067
26067
|
module.exports = {
|
|
26068
26068
|
name: "@bonginkan/maria",
|
|
26069
|
-
version: "4.3.
|
|
26070
|
-
description: "\u{1F680} MARIA v4.3.
|
|
26069
|
+
version: "4.3.29",
|
|
26070
|
+
description: "\u{1F680} MARIA v4.3.29 - 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.",
|
|
26071
26071
|
keywords: [
|
|
26072
26072
|
"ai",
|
|
26073
26073
|
"cli",
|
|
@@ -28099,7 +28099,7 @@ var init_AuthenticationManager = __esm({
|
|
|
28099
28099
|
const response = await fetch(`${this.apiBase}/api/user/profile`, {
|
|
28100
28100
|
headers: {
|
|
28101
28101
|
"Authorization": `Bearer ${tokens2.accessToken}`,
|
|
28102
|
-
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.
|
|
28102
|
+
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.29"}`
|
|
28103
28103
|
}
|
|
28104
28104
|
});
|
|
28105
28105
|
if (response.status === 401) {
|
|
@@ -28731,7 +28731,7 @@ async function callApi(path60, init3 = {}) {
|
|
|
28731
28731
|
"Authorization": `Bearer ${token}`,
|
|
28732
28732
|
"X-Device-Id": getDeviceId(),
|
|
28733
28733
|
"X-Session-Id": getSessionId() || "",
|
|
28734
|
-
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.
|
|
28734
|
+
"User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.29"}`,
|
|
28735
28735
|
"Content-Type": init3.headers?.["Content-Type"] || "application/json"
|
|
28736
28736
|
});
|
|
28737
28737
|
const doFetch = async (token) => {
|
|
@@ -44443,7 +44443,7 @@ async function applyPlans(plans, opts) {
|
|
|
44443
44443
|
try {
|
|
44444
44444
|
for (const plan of plans) {
|
|
44445
44445
|
if (opts.signal?.aborted) throw abortErr();
|
|
44446
|
-
const target = path11__namespace.default.join(opts.root, plan.path);
|
|
44446
|
+
const target = plan.absPath ? plan.absPath : path11__namespace.default.join(opts.root, plan.path);
|
|
44447
44447
|
const dir = path11__namespace.default.dirname(target);
|
|
44448
44448
|
await fs21.promises.mkdir(dir, { recursive: true });
|
|
44449
44449
|
const exists2 = await fileExists(target);
|
|
@@ -47985,8 +47985,19 @@ async function runImagePipeline(params2, opts) {
|
|
|
47985
47985
|
metrics: { durationMs, retries: totalRetries, fallbacks: 0 },
|
|
47986
47986
|
trace: Math.random().toString(36).slice(2, 8).toUpperCase()
|
|
47987
47987
|
};
|
|
47988
|
-
const
|
|
47989
|
-
const
|
|
47988
|
+
const baseDir = opts.outDir && opts.outDir.length > 0 ? opts.outDir : "image";
|
|
47989
|
+
const rawPrefix = (params2.prompt || "").slice(0, 20).replace(/\s+/g, "_");
|
|
47990
|
+
let promptPrefix = rawPrefix.replace(/[\x00-\x1F<>:"/\\|?*]/g, "_").replace(/[. ]+$/g, "");
|
|
47991
|
+
if (!promptPrefix) promptPrefix = "untitled";
|
|
47992
|
+
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(promptPrefix)) promptPrefix = `${promptPrefix}_`;
|
|
47993
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
47994
|
+
const filtered = successes.filter(Boolean);
|
|
47995
|
+
const items = filtered.map((b, i2) => ({
|
|
47996
|
+
bytes: b,
|
|
47997
|
+
ext: `.${params2.format}`,
|
|
47998
|
+
logicalName: `${promptPrefix}-${utc}${filtered.length > 1 ? `-${String(i2 + 1).padStart(2, "0")}` : ""}`
|
|
47999
|
+
}));
|
|
48000
|
+
const saved = await saveArtifacts({ root: opts.root, kind: "image", baseDir, flat: true, skipManifest: true }, items, manifest);
|
|
47990
48001
|
progress.done();
|
|
47991
48002
|
return {
|
|
47992
48003
|
saved,
|
|
@@ -48402,7 +48413,6 @@ var init_image_command = __esm({
|
|
|
48402
48413
|
const spinner = new ProcessAnimation();
|
|
48403
48414
|
spinner.start();
|
|
48404
48415
|
try {
|
|
48405
|
-
const useRemote = String(process.env.MARIA_USE_REMOTE_MEDIA || "").toLowerCase() === "1" && await authManager.isAuthenticated();
|
|
48406
48416
|
if (useRemote) {
|
|
48407
48417
|
try {
|
|
48408
48418
|
const body = {
|
|
@@ -48435,14 +48445,23 @@ var init_image_command = __esm({
|
|
|
48435
48445
|
const pathMod = await import('path');
|
|
48436
48446
|
const fsMod = await import('fs/promises');
|
|
48437
48447
|
const savedPaths = [];
|
|
48448
|
+
const baseDir = "image";
|
|
48449
|
+
const rawPrefix = (cli.prompt || "").slice(0, 20).replace(/\s+/g, "_");
|
|
48450
|
+
let promptPrefix = rawPrefix.replace(/[\x00-\x1F<>:"/\\|?*]/g, "_").replace(/[. ]+$/g, "");
|
|
48451
|
+
if (!promptPrefix) promptPrefix = "untitled";
|
|
48452
|
+
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(promptPrefix)) promptPrefix = `${promptPrefix}_`;
|
|
48453
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
48454
|
+
let idx = 0;
|
|
48438
48455
|
for (const f3 of filesInline) {
|
|
48439
48456
|
const original = String(f3.file || "").replace(/^[\\/]+/, "");
|
|
48440
|
-
const
|
|
48441
|
-
const
|
|
48457
|
+
const ext2 = pathMod.extname(original) || `.${cli.format}`;
|
|
48458
|
+
const name2 = `${promptPrefix}-${utc}${filesInline.length > 1 ? `-${String(++idx).padStart(2, "0")}` : ""}${ext2}`;
|
|
48459
|
+
const rel = pathMod.join(baseDir, name2);
|
|
48460
|
+
const full = pathMod.resolve(root, rel);
|
|
48442
48461
|
await fsMod.mkdir(pathMod.dirname(full), { recursive: true });
|
|
48443
48462
|
const buf = Buffer.from(String(f3.bytesBase64 || ""), "base64");
|
|
48444
48463
|
await fsMod.writeFile(full, buf);
|
|
48445
|
-
savedPaths.push(
|
|
48464
|
+
savedPaths.push(rel.replace(/\\/g, "/"));
|
|
48446
48465
|
}
|
|
48447
48466
|
const { formatImageOutput: formatImageOutput3 } = await Promise.resolve().then(() => (init_cli_style(), cli_style_exports));
|
|
48448
48467
|
const output4 = await formatImageOutput3(root, {
|
|
@@ -48468,18 +48487,24 @@ var init_image_command = __esm({
|
|
|
48468
48487
|
const fsMod = await import('fs/promises');
|
|
48469
48488
|
const base = (process.env.MARIA_API_BASE || "https://api.maria-code.ai").replace(/\/$/, "");
|
|
48470
48489
|
const savedPaths = [];
|
|
48490
|
+
const baseDir = "image";
|
|
48491
|
+
const promptPrefix = (cli.prompt || "").slice(0, 20).replace(/\s+/g, "_").replace(/[^A-Za-z0-9_\-]/g, "_") || "untitled";
|
|
48492
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
48493
|
+
let idx = 0;
|
|
48471
48494
|
for (const relRaw of filesList) {
|
|
48472
48495
|
const originalRel = String(relRaw || "").replace(/^[\\/]+/, "");
|
|
48473
48496
|
const url2 = `${base}/${originalRel}`;
|
|
48474
|
-
const
|
|
48475
|
-
const
|
|
48497
|
+
const ext2 = pathMod.extname(originalRel) || `.${cli.format}`;
|
|
48498
|
+
const name2 = `${promptPrefix}-${utc}${filesList.length > 1 ? `-${String(++idx).padStart(2, "0")}` : ""}${ext2}`;
|
|
48499
|
+
const rel = pathMod.join(baseDir, name2);
|
|
48500
|
+
const full = pathMod.resolve(root, rel);
|
|
48476
48501
|
await fsMod.mkdir(pathMod.dirname(full), { recursive: true });
|
|
48477
48502
|
const res2 = await fetch(url2);
|
|
48478
48503
|
if (!res2.ok) throw new Error(`Failed to download image: ${res2.status}`);
|
|
48479
48504
|
const arrayBuf = await res2.arrayBuffer();
|
|
48480
48505
|
const buf = Buffer.from(arrayBuf);
|
|
48481
48506
|
await fsMod.writeFile(full, buf);
|
|
48482
|
-
savedPaths.push(
|
|
48507
|
+
savedPaths.push(rel.replace(/\\/g, "/"));
|
|
48483
48508
|
}
|
|
48484
48509
|
const { formatImageOutput: formatImageOutput3 } = await Promise.resolve().then(() => (init_cli_style(), cli_style_exports));
|
|
48485
48510
|
const output4 = await formatImageOutput3(root, {
|
|
@@ -48735,8 +48760,17 @@ async function runVideoPipeline(params2, opts) {
|
|
|
48735
48760
|
metrics: { durationMs: Date.now() - started, retries: 0, fallbacks: 0 },
|
|
48736
48761
|
trace: Math.random().toString(36).slice(2, 8).toUpperCase()
|
|
48737
48762
|
};
|
|
48738
|
-
const baseDir = opts.outDir
|
|
48739
|
-
const
|
|
48763
|
+
const baseDir = opts.outDir && opts.outDir.length > 0 ? opts.outDir : "video";
|
|
48764
|
+
const rawPrefix = (params2.prompt || "").slice(0, 20).replace(/\s+/g, "_");
|
|
48765
|
+
let promptPrefix = rawPrefix.replace(/[\x00-\x1F<>:\"/\\|?*]/g, "_").replace(/[. ]+$/g, "");
|
|
48766
|
+
if (!promptPrefix) promptPrefix = "untitled";
|
|
48767
|
+
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(promptPrefix)) promptPrefix = `${promptPrefix}_`;
|
|
48768
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
48769
|
+
const saved2 = await saveArtifacts(
|
|
48770
|
+
{ root: opts.root, kind: "video", baseDir, flat: true },
|
|
48771
|
+
[{ bytes, ext: ext2, logicalName: `${promptPrefix}-${utc}` }],
|
|
48772
|
+
manifest2
|
|
48773
|
+
);
|
|
48740
48774
|
return { saved: saved2, durationMs: Date.now() - started, frames: 0, warnFallback: false, retries: 0 };
|
|
48741
48775
|
}
|
|
48742
48776
|
} catch {
|
|
@@ -48782,14 +48816,28 @@ async function runVideoPipeline(params2, opts) {
|
|
|
48782
48816
|
}
|
|
48783
48817
|
const outBuf = await muxFramesToMp4(tmpDir, params2.fps);
|
|
48784
48818
|
{
|
|
48785
|
-
const baseDir = opts.outDir
|
|
48786
|
-
|
|
48819
|
+
const baseDir = opts.outDir && opts.outDir.length > 0 ? opts.outDir : "video";
|
|
48820
|
+
const rawPrefix = (params2.prompt || "").slice(0, 20).replace(/\s+/g, "_");
|
|
48821
|
+
let promptPrefix = rawPrefix.replace(/[\x00-\x1F<>:\"/\\|?*]/g, "_").replace(/[. ]+$/g, "");
|
|
48822
|
+
if (!promptPrefix) promptPrefix = "untitled";
|
|
48823
|
+
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(promptPrefix)) promptPrefix = `${promptPrefix}_`;
|
|
48824
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
48825
|
+
saved = await saveArtifacts(
|
|
48826
|
+
{ root: opts.root, kind: "video", baseDir, flat: true },
|
|
48827
|
+
[{ bytes: outBuf, ext: ".mp4", logicalName: `${promptPrefix}-${utc}` }],
|
|
48828
|
+
manifest
|
|
48829
|
+
);
|
|
48787
48830
|
}
|
|
48788
48831
|
await fsp__namespace.rm(tmpDir, { recursive: true, force: true });
|
|
48789
48832
|
} else {
|
|
48790
|
-
const
|
|
48833
|
+
const rawPrefix = (params2.prompt || "").slice(0, 20).replace(/\s+/g, "_");
|
|
48834
|
+
let promptPrefix = rawPrefix.replace(/[\x00-\x1F<>:\"/\\|?*]/g, "_").replace(/[. ]+$/g, "");
|
|
48835
|
+
if (!promptPrefix) promptPrefix = "untitled";
|
|
48836
|
+
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(promptPrefix)) promptPrefix = `${promptPrefix}_`;
|
|
48837
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
48838
|
+
const items = frames.map((b, i2) => ({ bytes: b, ext: `.png`, logicalName: `${promptPrefix}-${utc}-frame-${String(i2 + 1).padStart(4, "0")}` }));
|
|
48791
48839
|
{
|
|
48792
|
-
const baseDir = opts.outDir
|
|
48840
|
+
const baseDir = opts.outDir && opts.outDir.length > 0 ? opts.outDir : "video";
|
|
48793
48841
|
saved = await saveArtifacts({ root: opts.root, kind: "video", baseDir, flat: true }, items, manifest);
|
|
48794
48842
|
}
|
|
48795
48843
|
warnFallback = true;
|
|
@@ -48850,8 +48898,8 @@ var init_video_command = __esm({
|
|
|
48850
48898
|
const spinner = new ProcessAnimation();
|
|
48851
48899
|
spinner.start();
|
|
48852
48900
|
try {
|
|
48853
|
-
const
|
|
48854
|
-
if (
|
|
48901
|
+
const useRemote2 = String(process.env.MARIA_USE_REMOTE_MEDIA || "").toLowerCase() === "1" && await authManager.isAuthenticated();
|
|
48902
|
+
if (useRemote2) {
|
|
48855
48903
|
try {
|
|
48856
48904
|
const body = {
|
|
48857
48905
|
prompt: cli.prompt,
|
|
@@ -48881,14 +48929,23 @@ var init_video_command = __esm({
|
|
|
48881
48929
|
const pathMod = await import('path');
|
|
48882
48930
|
const fsMod = await import('fs/promises');
|
|
48883
48931
|
const savedPaths = [];
|
|
48932
|
+
const baseDir = "video";
|
|
48933
|
+
const rawPrefix = (cli.prompt || "").slice(0, 20).replace(/\s+/g, "_");
|
|
48934
|
+
let promptPrefix = rawPrefix.replace(/[\x00-\x1F<>:"/\\|?*]/g, "_").replace(/[. ]+$/g, "");
|
|
48935
|
+
if (!promptPrefix) promptPrefix = "untitled";
|
|
48936
|
+
if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(promptPrefix)) promptPrefix = `${promptPrefix}_`;
|
|
48937
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
48938
|
+
let idx = 0;
|
|
48884
48939
|
for (const f3 of filesInline) {
|
|
48885
48940
|
const original = String(f3.file || "").replace(/^[\\/]+/, "");
|
|
48886
|
-
const
|
|
48887
|
-
const
|
|
48941
|
+
const ext2 = pathMod.extname(original) || `.${cli.format}`;
|
|
48942
|
+
const name2 = `${promptPrefix}-${utc}${filesInline.length > 1 ? `-${String(++idx).padStart(2, "0")}` : ""}${ext2}`;
|
|
48943
|
+
const rel = pathMod.join(baseDir, name2);
|
|
48944
|
+
const full = pathMod.resolve(root, rel);
|
|
48888
48945
|
await fsMod.mkdir(pathMod.dirname(full), { recursive: true });
|
|
48889
48946
|
const buf = Buffer.from(String(f3.bytesBase64 || ""), "base64");
|
|
48890
48947
|
await fsMod.writeFile(full, buf);
|
|
48891
|
-
savedPaths.push(
|
|
48948
|
+
savedPaths.push(rel.replace(/\\/g, "/"));
|
|
48892
48949
|
}
|
|
48893
48950
|
const { formatVideoOutput: formatVideoOutput3 } = await Promise.resolve().then(() => (init_cli_style(), cli_style_exports));
|
|
48894
48951
|
const output4 = await formatVideoOutput3(root, {
|
|
@@ -48917,18 +48974,24 @@ var init_video_command = __esm({
|
|
|
48917
48974
|
const fsMod = await import('fs/promises');
|
|
48918
48975
|
const base = (process.env.MARIA_API_BASE || "https://api.maria-code.ai").replace(/\/$/, "");
|
|
48919
48976
|
const savedPaths = [];
|
|
48977
|
+
const baseDir = "video";
|
|
48978
|
+
const promptPrefix = (cli.prompt || "").slice(0, 20).replace(/\s+/g, "_").replace(/[^A-Za-z0-9_\-]/g, "_") || "untitled";
|
|
48979
|
+
const utc = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
48980
|
+
let idx = 0;
|
|
48920
48981
|
for (const relRaw of filesFromApi) {
|
|
48921
|
-
const
|
|
48922
|
-
const url2 = `${base}/${
|
|
48923
|
-
const
|
|
48924
|
-
const
|
|
48982
|
+
const relApi = String(relRaw || "").replace(/^[\\/]+/, "");
|
|
48983
|
+
const url2 = `${base}/${relApi}`;
|
|
48984
|
+
const ext2 = pathMod.extname(relApi) || `.${cli.format}`;
|
|
48985
|
+
const name2 = `${promptPrefix}-${utc}${filesFromApi.length > 1 ? `-${String(++idx).padStart(2, "0")}` : ""}${ext2}`;
|
|
48986
|
+
const rel = pathMod.join(baseDir, name2);
|
|
48987
|
+
const full = pathMod.resolve(root, rel);
|
|
48925
48988
|
await fsMod.mkdir(pathMod.dirname(full), { recursive: true });
|
|
48926
48989
|
const res2 = await fetch(url2);
|
|
48927
48990
|
if (!res2.ok) throw new Error(`Failed to download video: ${res2.status}`);
|
|
48928
48991
|
const arrayBuf = await res2.arrayBuffer();
|
|
48929
48992
|
const buf = Buffer.from(arrayBuf);
|
|
48930
48993
|
await fsMod.writeFile(full, buf);
|
|
48931
|
-
savedPaths.push(
|
|
48994
|
+
savedPaths.push(rel.replace(/\\/g, "/"));
|
|
48932
48995
|
}
|
|
48933
48996
|
const { formatVideoOutput: formatVideoOutput3 } = await Promise.resolve().then(() => (init_cli_style(), cli_style_exports));
|
|
48934
48997
|
const output4 = await formatVideoOutput3(root, {
|
|
@@ -50625,7 +50688,7 @@ var init_about_command = __esm({
|
|
|
50625
50688
|
async execute(args2, context2) {
|
|
50626
50689
|
const output3 = [];
|
|
50627
50690
|
output3.push("");
|
|
50628
|
-
output3.push(chalk14__default.default.cyan.bold("\u{1F916} About MARIA v4.3.
|
|
50691
|
+
output3.push(chalk14__default.default.cyan.bold("\u{1F916} About MARIA v4.3.29"));
|
|
50629
50692
|
output3.push(chalk14__default.default.gray("\u2550".repeat(40)));
|
|
50630
50693
|
output3.push("");
|
|
50631
50694
|
output3.push(chalk14__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
|
|
@@ -54127,6 +54190,10 @@ async function normalizePlans(plans, opts) {
|
|
|
54127
54190
|
const profile = await scanRepo(opts.root);
|
|
54128
54191
|
const out = [];
|
|
54129
54192
|
for (const fp of plans) {
|
|
54193
|
+
if (fp.noNormalize) {
|
|
54194
|
+
out.push(fp);
|
|
54195
|
+
continue;
|
|
54196
|
+
}
|
|
54130
54197
|
const n = normalizePlanItem(fp, profile);
|
|
54131
54198
|
if (!n.kind) n.kind = guessKindByPath(n.path);
|
|
54132
54199
|
out.push(n);
|
|
@@ -54171,7 +54238,7 @@ async function validatePlan(plans, opts) {
|
|
|
54171
54238
|
skipped.push(fp.path);
|
|
54172
54239
|
continue;
|
|
54173
54240
|
}
|
|
54174
|
-
const full = path11__namespace.default.join(opts.root, rel);
|
|
54241
|
+
const full = fp.absPath ? fp.absPath : path11__namespace.default.join(opts.root, rel);
|
|
54175
54242
|
if (!full.startsWith(path11__namespace.default.resolve(opts.root))) {
|
|
54176
54243
|
warnings.push(`Outside root denied: ${fp.path}`);
|
|
54177
54244
|
skipped.push(fp.path);
|
|
@@ -54302,10 +54369,10 @@ function formatPlan(summary, opts) {
|
|
|
54302
54369
|
budget.diffLines = Math.min(budget.diffLines, 20);
|
|
54303
54370
|
lines.push("", `Diff preview (truncated to ${budget.diffLines} lines per file):`);
|
|
54304
54371
|
for (const f3 of summary.files) {
|
|
54305
|
-
if (f3.action
|
|
54306
|
-
const before = readCurrentFileSafe(opts.root, f3.path);
|
|
54372
|
+
if (f3.action !== "modify") continue;
|
|
54373
|
+
const before = readCurrentFileSafe(opts.root, f3.path, f3.absPath);
|
|
54307
54374
|
const after = f3.preview || "";
|
|
54308
|
-
const diff = buildUnifiedDiff(f3.path, before, after, budget);
|
|
54375
|
+
const diff = buildUnifiedDiff(f3.path, before, after, budget, f3.absPath);
|
|
54309
54376
|
lines.push(diff, "");
|
|
54310
54377
|
}
|
|
54311
54378
|
}
|
|
@@ -54342,9 +54409,10 @@ function formatPlanAsDiff(files, opts) {
|
|
|
54342
54409
|
let shownFiles = 0;
|
|
54343
54410
|
for (const f3 of files) {
|
|
54344
54411
|
if (budget.globalMaxFiles !== void 0 && shownFiles >= budget.globalMaxFiles) break;
|
|
54345
|
-
|
|
54412
|
+
if (f3.action !== "modify") continue;
|
|
54413
|
+
const before = readCurrentFileSafe(opts.root, f3.path, f3.absPath);
|
|
54346
54414
|
const after = f3.preview || "";
|
|
54347
|
-
const diff = buildUnifiedDiff(f3.path, before, after, budget);
|
|
54415
|
+
const diff = buildUnifiedDiff(f3.path, before, after, budget, f3.absPath);
|
|
54348
54416
|
const diffBytes = Buffer.byteLength(diff, "utf8");
|
|
54349
54417
|
if (budget.globalMaxBytes !== void 0 && bytesUsed + diffBytes > budget.globalMaxBytes && shownFiles > 0) {
|
|
54350
54418
|
lines.push(`
|
|
@@ -54361,11 +54429,11 @@ function formatPlanAsDiff(files, opts) {
|
|
|
54361
54429
|
}
|
|
54362
54430
|
return lines.join("\n");
|
|
54363
54431
|
}
|
|
54364
|
-
function readCurrentFileSafe(root, rel) {
|
|
54365
|
-
if (!root) return "";
|
|
54432
|
+
function readCurrentFileSafe(root, rel, abs) {
|
|
54433
|
+
if (!root && !abs) return "";
|
|
54366
54434
|
try {
|
|
54367
54435
|
const fs49 = __require("fs");
|
|
54368
|
-
const p = __require("path").join(root, rel);
|
|
54436
|
+
const p = abs ? abs : __require("path").join(root, rel);
|
|
54369
54437
|
return fs49.existsSync(p) ? fs49.readFileSync(p, "utf8") : "";
|
|
54370
54438
|
} catch {
|
|
54371
54439
|
return "";
|
|
@@ -54382,7 +54450,7 @@ function normalizeDiffBudget(b) {
|
|
|
54382
54450
|
globalMaxFiles: Number.isFinite(b?.globalMaxFiles) ? b.globalMaxFiles : envGlobalFiles
|
|
54383
54451
|
};
|
|
54384
54452
|
}
|
|
54385
|
-
function buildUnifiedDiff(relPath, before, after, b) {
|
|
54453
|
+
function buildUnifiedDiff(relPath, before, after, b, abs) {
|
|
54386
54454
|
const beforeLines = before.split(/\r?\n/);
|
|
54387
54455
|
const afterLines = after.split(/\r?\n/);
|
|
54388
54456
|
let i2 = 0;
|
|
@@ -54391,14 +54459,15 @@ function buildUnifiedDiff(relPath, before, after, b) {
|
|
|
54391
54459
|
while (j < beforeLines.length - i2 && j < afterLines.length - i2 && beforeLines[beforeLines.length - 1 - j] === afterLines[afterLines.length - 1 - j]) j++;
|
|
54392
54460
|
const oldMid = beforeLines.slice(i2, beforeLines.length - j);
|
|
54393
54461
|
const newMid = afterLines.slice(i2, afterLines.length - j);
|
|
54394
|
-
const
|
|
54462
|
+
const headerPath = abs ? abs : relPath;
|
|
54463
|
+
const header = [`--- ${headerPath}`, `+++ ${headerPath}`];
|
|
54395
54464
|
const body = [];
|
|
54396
54465
|
const ctxPrefix = Math.max(0, i2 - 3);
|
|
54397
54466
|
Math.min(beforeLines.length, beforeLines.length - j + 3);
|
|
54398
54467
|
const preCtx = beforeLines.slice(ctxPrefix, i2).map((l) => ` ${l}`);
|
|
54399
54468
|
const postCtx = beforeLines.slice(beforeLines.length - j, Math.min(beforeLines.length - j + 3, beforeLines.length)).map((l) => ` ${l}`);
|
|
54400
|
-
const del = oldMid.map((l) => `-${l}`);
|
|
54401
|
-
const add = newMid.map((l) => `+${l}`);
|
|
54469
|
+
const del = oldMid.map((l) => colorRed(`-${l}`));
|
|
54470
|
+
const add = newMid.map((l) => colorGreen(`+${l}`));
|
|
54402
54471
|
body.push(...preCtx);
|
|
54403
54472
|
body.push(...del);
|
|
54404
54473
|
body.push(...add);
|
|
@@ -54415,6 +54484,22 @@ function buildUnifiedDiff(relPath, before, after, b) {
|
|
|
54415
54484
|
}
|
|
54416
54485
|
return out;
|
|
54417
54486
|
}
|
|
54487
|
+
function colorGreen(s2) {
|
|
54488
|
+
try {
|
|
54489
|
+
const chalk44 = __require("chalk");
|
|
54490
|
+
return chalk44.green(s2);
|
|
54491
|
+
} catch {
|
|
54492
|
+
return s2;
|
|
54493
|
+
}
|
|
54494
|
+
}
|
|
54495
|
+
function colorRed(s2) {
|
|
54496
|
+
try {
|
|
54497
|
+
const chalk44 = __require("chalk");
|
|
54498
|
+
return chalk44.red(s2);
|
|
54499
|
+
} catch {
|
|
54500
|
+
return s2;
|
|
54501
|
+
}
|
|
54502
|
+
}
|
|
54418
54503
|
function languageLabel(lang, filePath) {
|
|
54419
54504
|
if (lang) {
|
|
54420
54505
|
const l = lang.toLowerCase();
|
|
@@ -55041,6 +55126,20 @@ var init_policy = __esm({
|
|
|
55041
55126
|
}
|
|
55042
55127
|
});
|
|
55043
55128
|
|
|
55129
|
+
// src/utils/esm-compat.ts
|
|
55130
|
+
var esm_compat_exports = {};
|
|
55131
|
+
__export(esm_compat_exports, {
|
|
55132
|
+
loadGlobby: () => loadGlobby
|
|
55133
|
+
});
|
|
55134
|
+
async function loadGlobby() {
|
|
55135
|
+
const mod = await import('globby');
|
|
55136
|
+
return mod?.globby ?? mod?.default ?? mod;
|
|
55137
|
+
}
|
|
55138
|
+
var init_esm_compat = __esm({
|
|
55139
|
+
"src/utils/esm-compat.ts"() {
|
|
55140
|
+
}
|
|
55141
|
+
});
|
|
55142
|
+
|
|
55044
55143
|
// src/services/code-orchestrator/Orchestrator.ts
|
|
55045
55144
|
var Orchestrator_exports = {};
|
|
55046
55145
|
__export(Orchestrator_exports, {
|
|
@@ -55075,6 +55174,20 @@ async function orchestrate(request, opts) {
|
|
|
55075
55174
|
const initial = [];
|
|
55076
55175
|
const fallbackNotices = [];
|
|
55077
55176
|
const withNotices = (base) => fallbackNotices.length > 0 ? [...fallbackNotices, ...base] : base;
|
|
55177
|
+
const explicitFilesRaw = parseExplicitFilenames(request);
|
|
55178
|
+
const explicitFiles = explicitFilesRaw.length > 0 ? await resolveExplicitPaths(opts.root, explicitFilesRaw, request) : [];
|
|
55179
|
+
const explicitAbsMap = /* @__PURE__ */ Object.create(null);
|
|
55180
|
+
if (explicitFiles.length > 0) {
|
|
55181
|
+
const pathMod = await import('path');
|
|
55182
|
+
for (const rel of explicitFiles) {
|
|
55183
|
+
explicitAbsMap[rel] = pathMod.join(opts.root, rel);
|
|
55184
|
+
}
|
|
55185
|
+
}
|
|
55186
|
+
const isEditIntent = detectEditIntent(request, {
|
|
55187
|
+
hasAttachments: !!(opts.attachedFiles && opts.attachedFiles.length > 0),
|
|
55188
|
+
explicitFilesCount: explicitFiles.length
|
|
55189
|
+
});
|
|
55190
|
+
const editContext = isEditIntent && explicitFiles.length > 0 ? await buildEditContext(opts.root, explicitFiles, 200, 512 * 1024) : "";
|
|
55078
55191
|
if (opts.attachedFiles && opts.attachedFiles.length > 0) {
|
|
55079
55192
|
const mapRes = await mapAttachmentsToTargets(opts.attachedFiles, {
|
|
55080
55193
|
root: opts.root,
|
|
@@ -55094,7 +55207,6 @@ async function orchestrate(request, opts) {
|
|
|
55094
55207
|
}
|
|
55095
55208
|
}
|
|
55096
55209
|
const onlyAttached = !!opts.flags.onlyAttached;
|
|
55097
|
-
const explicitFiles = parseExplicitFilenames(request);
|
|
55098
55210
|
if (!onlyAttached) {
|
|
55099
55211
|
let codeOutput = "";
|
|
55100
55212
|
if (process.env.MARIA_E2E_FAKE_CODE === "1") {
|
|
@@ -55114,9 +55226,17 @@ async function orchestrate(request, opts) {
|
|
|
55114
55226
|
"[BEGIN file: path]\n<content>\n[END]",
|
|
55115
55227
|
"Do not include any prose before/after; no menus/questions/suggestions; start immediately with ``` or [BEGIN file: ...]."
|
|
55116
55228
|
].join("\n");
|
|
55229
|
+
const requestPreamble = isEditIntent ? [
|
|
55230
|
+
"// EDIT MODE: modify existing files, preserve unrelated content.",
|
|
55231
|
+
"// Follow existing structure and only touch requested files.",
|
|
55232
|
+
editContext ? "// Current file snapshots provided below." : ""
|
|
55233
|
+
].filter(Boolean).join("\n") : "";
|
|
55117
55234
|
const enriched = `${FILE_FORMAT_INSTRUCTIONS}
|
|
55118
55235
|
|
|
55119
|
-
${
|
|
55236
|
+
${requestPreamble}
|
|
55237
|
+
${request}
|
|
55238
|
+
|
|
55239
|
+
${editContext}`;
|
|
55120
55240
|
const response = await executeCode(enriched);
|
|
55121
55241
|
const raw = (response.output || response?.data?.content || "").trim();
|
|
55122
55242
|
if (!raw) {
|
|
@@ -55161,24 +55281,27 @@ ${request}`;
|
|
|
55161
55281
|
const htmlIdx = blocks.findIndex((b) => /html/i.test(b.language));
|
|
55162
55282
|
const htmlFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".html"));
|
|
55163
55283
|
if (htmlIdx >= 0 && htmlFile) {
|
|
55164
|
-
initial.push({ path: htmlFile, kind: "source", action: "create", description: "HTML page", language: "html", preview: blocks[htmlIdx].code });
|
|
55284
|
+
initial.push({ path: htmlFile, absPath: explicitAbsMap[htmlFile], noNormalize: true, kind: "source", action: "create", description: "HTML page", language: "html", preview: blocks[htmlIdx].code });
|
|
55165
55285
|
mapped.add(htmlFile);
|
|
55166
55286
|
}
|
|
55167
55287
|
const jsIdx = blocks.findIndex((b) => /(ts|tsx|jsx|javascript|js)/i.test(b.language));
|
|
55168
55288
|
const jsFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".js"));
|
|
55169
55289
|
if (jsIdx >= 0 && jsFile && !mapped.has(jsFile)) {
|
|
55170
|
-
initial.push({ path: jsFile, kind: "source", action: "create", description: "Script", language: "javascript", preview: blocks[jsIdx].code });
|
|
55290
|
+
initial.push({ path: jsFile, absPath: explicitAbsMap[jsFile], noNormalize: true, kind: "source", action: "create", description: "Script", language: "javascript", preview: blocks[jsIdx].code });
|
|
55171
55291
|
mapped.add(jsFile);
|
|
55172
55292
|
}
|
|
55173
55293
|
const cssIdx = blocks.findIndex((b) => /css/i.test(b.language));
|
|
55174
55294
|
const cssFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".css"));
|
|
55175
55295
|
if (cssIdx >= 0 && cssFile && !mapped.has(cssFile)) {
|
|
55176
|
-
initial.push({ path: cssFile, kind: "source", action: "create", description: "Stylesheet", language: "css", preview: blocks[cssIdx].code });
|
|
55296
|
+
initial.push({ path: cssFile, absPath: explicitAbsMap[cssFile], noNormalize: true, kind: "source", action: "create", description: "Stylesheet", language: "css", preview: blocks[cssIdx].code });
|
|
55177
55297
|
mapped.add(cssFile);
|
|
55178
55298
|
}
|
|
55179
55299
|
for (const f3 of explicitFiles) {
|
|
55180
55300
|
if (mapped.has(f3)) continue;
|
|
55181
|
-
|
|
55301
|
+
const plan = scaffoldForFilename(f3, explicitFiles);
|
|
55302
|
+
plan.absPath = explicitAbsMap[f3];
|
|
55303
|
+
plan.noNormalize = true;
|
|
55304
|
+
initial.push(plan);
|
|
55182
55305
|
}
|
|
55183
55306
|
} else {
|
|
55184
55307
|
for (let i2 = 0; i2 < blocks.length; i2++) {
|
|
@@ -55196,12 +55319,26 @@ ${request}`;
|
|
|
55196
55319
|
}
|
|
55197
55320
|
}
|
|
55198
55321
|
}
|
|
55322
|
+
if (!isEditIntent) {
|
|
55323
|
+
const proposedTop = deriveProjectFolderName(request);
|
|
55324
|
+
const { folderName, detectedTop } = await ensureTopFolder(opts.root, proposedTop, initial);
|
|
55325
|
+
if (folderName) {
|
|
55326
|
+
for (const p of initial) {
|
|
55327
|
+
if (!startsWithTopFolder(p.path, detectedTop || folderName)) {
|
|
55328
|
+
p.path = prefixWithTopFolder(p.path, folderName);
|
|
55329
|
+
}
|
|
55330
|
+
}
|
|
55331
|
+
}
|
|
55332
|
+
}
|
|
55199
55333
|
if (explicitFiles.length > 0 && initial.filter((f3) => !!f3.preview).length === 0) {
|
|
55200
55334
|
for (const f3 of explicitFiles) {
|
|
55201
55335
|
initial.push(scaffoldForFilename(f3, explicitFiles));
|
|
55202
55336
|
}
|
|
55203
55337
|
}
|
|
55204
|
-
const normalized = await normalizePlans(
|
|
55338
|
+
const normalized = await normalizePlans(
|
|
55339
|
+
initial.map((p) => p.noNormalize ? p : p),
|
|
55340
|
+
{ root: opts.root }
|
|
55341
|
+
);
|
|
55205
55342
|
try {
|
|
55206
55343
|
const [{ access: access18 }, path60] = await Promise.all([
|
|
55207
55344
|
import('fs/promises'),
|
|
@@ -55209,8 +55346,12 @@ ${request}`;
|
|
|
55209
55346
|
]);
|
|
55210
55347
|
for (const p of normalized) {
|
|
55211
55348
|
try {
|
|
55212
|
-
|
|
55349
|
+
const absCandidate = p.absPath ? p.absPath : path60.join(opts.root, p.path);
|
|
55350
|
+
await access18(absCandidate);
|
|
55213
55351
|
p.action = "modify";
|
|
55352
|
+
if (isEditIntent) {
|
|
55353
|
+
p.overwritePolicy = "allow";
|
|
55354
|
+
}
|
|
55214
55355
|
} catch {
|
|
55215
55356
|
p.action = "create";
|
|
55216
55357
|
}
|
|
@@ -55218,10 +55359,12 @@ ${request}`;
|
|
|
55218
55359
|
} catch {
|
|
55219
55360
|
}
|
|
55220
55361
|
const validated = await validatePlan(normalized, { root: opts.root, profile, flags: { maxFiles: opts.flags.maxFiles, yes: opts.flags.yes, interactive: !!opts.flags.interactive, ...opts.flags } });
|
|
55221
|
-
const
|
|
55222
|
-
const
|
|
55223
|
-
|
|
55224
|
-
);
|
|
55362
|
+
const hasAnyModify = validated.files.some((f3) => f3.action === "modify") || isEditIntent;
|
|
55363
|
+
const outputMode = !opts.flags.hideCode && hasAnyModify ? "diff" : resolveOutputMode(opts.flags.output, validated.files.length, !!opts.flags.hideCode);
|
|
55364
|
+
const skippedSetForLookup = new Set(validated.skipped || []);
|
|
55365
|
+
const skippedPlans = normalized.filter((f3) => skippedSetForLookup.has(f3.path));
|
|
55366
|
+
const remainingSkipped = (validated.skipped || []).filter((p) => !skippedPlans.some((sp) => sp.path === p)).map((p) => ({ path: p, kind: "source", action: "skip", description: "" }));
|
|
55367
|
+
const displayFiles = validated.files.concat(skippedPlans).concat(remainingSkipped);
|
|
55225
55368
|
const summary = summarizePlan(displayFiles);
|
|
55226
55369
|
const lines = [
|
|
55227
55370
|
formatPlan(summary, {
|
|
@@ -55259,6 +55402,7 @@ ${request}`;
|
|
|
55259
55402
|
if (softIssues.hasTrailingWhitespace) lines.push(warnLine("Proposed changes contain trailing whitespace"));
|
|
55260
55403
|
if (softIssues.hasConflictMarkers) lines.push(warnLine("Proposed changes contain conflict markers"));
|
|
55261
55404
|
}
|
|
55405
|
+
const preApplyOutput = withNotices(lines);
|
|
55262
55406
|
let appliedCount = 0;
|
|
55263
55407
|
let durationMs = 0;
|
|
55264
55408
|
let rolledBack = false;
|
|
@@ -55270,7 +55414,7 @@ ${request}`;
|
|
|
55270
55414
|
return { plan: normalized, validated, summaryLines: withNotices([errorLine("working tree not clean (commit or stash first). Re-run after cleaning your git status.")]) };
|
|
55271
55415
|
}
|
|
55272
55416
|
}
|
|
55273
|
-
const allowOverwrite = opts.flags.overwriteAllowed === true || !!opts.flags.yes;
|
|
55417
|
+
const allowOverwrite = opts.flags.overwriteAllowed === true || !!opts.flags.yes || isEditIntent;
|
|
55274
55418
|
const applyRes = await applyPlans(approved, { root: opts.root, overwriteAllowed: allowOverwrite, rollback: opts.flags.rollback !== false, signal: opts.abortSignal, onProgress: (w, t2) => {
|
|
55275
55419
|
}, eol: profile.eol });
|
|
55276
55420
|
appliedCount = applyRes.appliedCount;
|
|
@@ -55300,7 +55444,7 @@ ${request}`;
|
|
|
55300
55444
|
const savedList = [].concat(applyRes.created, applyRes.modified);
|
|
55301
55445
|
const savedAbs = savedList.map((rel) => path11__namespace.default.resolve(opts.root, rel));
|
|
55302
55446
|
const footer = savedAbs.length > 0 ? ["Saved files (full paths):", ...savedAbs.map((p) => `- ${p}`)] : [];
|
|
55303
|
-
return { plan: normalized, validated, applied: { count: appliedCount, durationMs, rolledBack }, summaryLines:
|
|
55447
|
+
return { plan: normalized, validated, applied: { count: appliedCount, durationMs, rolledBack }, summaryLines: [...preApplyOutput, "", msg, ...footer] };
|
|
55304
55448
|
} catch (e2) {
|
|
55305
55449
|
if (e2?.name === "AbortError") {
|
|
55306
55450
|
await journalResume(opts.root, request, validated.files);
|
|
@@ -55521,6 +55665,218 @@ function parseExplicitFilenames(request) {
|
|
|
55521
55665
|
}
|
|
55522
55666
|
return out;
|
|
55523
55667
|
}
|
|
55668
|
+
function detectEditIntent(request, ctx2) {
|
|
55669
|
+
const r2 = request.toLowerCase();
|
|
55670
|
+
const editKeywords = ["modify", "edit", "update", "fix", "refactor", "change", "patch", "\u5DEE\u5206", "\u4FEE\u6B63", "\u5909\u66F4", "\u65E2\u5B58", "\u8FFD\u8A18"];
|
|
55671
|
+
const mentionsEdit = editKeywords.some((k) => r2.includes(k));
|
|
55672
|
+
return ctx2.hasAttachments || ctx2.explicitFilesCount > 0 || mentionsEdit;
|
|
55673
|
+
}
|
|
55674
|
+
function sanitizeFolderName(name2) {
|
|
55675
|
+
const base = name2.toLowerCase().replace(/[`~!@#$%^&*()+=\[\]{}|;:'",<>/?\\]/g, " ").replace(/\s+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
|
|
55676
|
+
return base || "project";
|
|
55677
|
+
}
|
|
55678
|
+
function deriveProjectFolderName(request) {
|
|
55679
|
+
const words = request.toLowerCase().replace(/[^a-z0-9\s-]/g, " ").split(/\s+/).filter((w) => w.length > 2).slice(0, 4).join("-");
|
|
55680
|
+
return sanitizeFolderName(words || "project");
|
|
55681
|
+
}
|
|
55682
|
+
function startsWithTopFolder(p, folder) {
|
|
55683
|
+
if (!folder) return false;
|
|
55684
|
+
const seg = p.replace(/^\/+/, "").split("/")[0];
|
|
55685
|
+
return seg.toLowerCase() === folder.toLowerCase();
|
|
55686
|
+
}
|
|
55687
|
+
function prefixWithTopFolder(p, folder) {
|
|
55688
|
+
const rel = p.replace(/^\/+/, "");
|
|
55689
|
+
return `${folder}/${rel}`;
|
|
55690
|
+
}
|
|
55691
|
+
async function ensureTopFolder(root, proposed, plans) {
|
|
55692
|
+
const tops = /* @__PURE__ */ new Set();
|
|
55693
|
+
for (const p of plans) {
|
|
55694
|
+
const seg = p.path.replace(/^\/+/, "").split("/")[0] || "";
|
|
55695
|
+
if (seg) tops.add(seg);
|
|
55696
|
+
}
|
|
55697
|
+
if (tops.size === 1) {
|
|
55698
|
+
const only = Array.from(tops)[0];
|
|
55699
|
+
const unique2 = await ensureUniqueFolder(root, only);
|
|
55700
|
+
return { folderName: unique2, detectedTop: only };
|
|
55701
|
+
}
|
|
55702
|
+
const unique = await ensureUniqueFolder(root, proposed);
|
|
55703
|
+
return { folderName: unique };
|
|
55704
|
+
}
|
|
55705
|
+
async function ensureUniqueFolder(root, base) {
|
|
55706
|
+
const fs49 = await import('fs/promises');
|
|
55707
|
+
const pathMod = await import('path');
|
|
55708
|
+
let name2 = sanitizeFolderName(base);
|
|
55709
|
+
let suffix = 0;
|
|
55710
|
+
for (; suffix < Number.MAX_SAFE_INTEGER; ) {
|
|
55711
|
+
const candidate = suffix === 0 ? name2 : `${name2}-${String(suffix).padStart(2, "0")}`;
|
|
55712
|
+
try {
|
|
55713
|
+
await fs49.access(pathMod.join(root, candidate));
|
|
55714
|
+
suffix += 1;
|
|
55715
|
+
} catch {
|
|
55716
|
+
return candidate;
|
|
55717
|
+
}
|
|
55718
|
+
}
|
|
55719
|
+
throw new Error("ensureUniqueFolder: exhausted attempts to find a unique folder name");
|
|
55720
|
+
}
|
|
55721
|
+
async function buildEditContext(root, files, maxLines, maxBytes) {
|
|
55722
|
+
try {
|
|
55723
|
+
const fs49 = await import('fs/promises');
|
|
55724
|
+
const pathMod = await import('path');
|
|
55725
|
+
const sections = [];
|
|
55726
|
+
for (const rel of files) {
|
|
55727
|
+
const full = pathMod.join(root, rel);
|
|
55728
|
+
try {
|
|
55729
|
+
const buf = await fs49.readFile(full);
|
|
55730
|
+
const clipped = buf.length > maxBytes ? buf.subarray(0, maxBytes) : buf;
|
|
55731
|
+
const text = clipped.toString("utf8").replace(/\r\n/g, "\n");
|
|
55732
|
+
const lines = text.split("\n").slice(0, maxLines).join("\n");
|
|
55733
|
+
sections.push(`[BEGIN file: ${rel}]
|
|
55734
|
+
${lines}
|
|
55735
|
+
[END]`);
|
|
55736
|
+
} catch {
|
|
55737
|
+
}
|
|
55738
|
+
}
|
|
55739
|
+
if (sections.length === 0) return "";
|
|
55740
|
+
return ["// Current repository files (read-only context):", ...sections].join("\n");
|
|
55741
|
+
} catch {
|
|
55742
|
+
return "";
|
|
55743
|
+
}
|
|
55744
|
+
}
|
|
55745
|
+
async function resolveExplicitPaths(root, files, hintText) {
|
|
55746
|
+
const fs49 = await import('fs/promises');
|
|
55747
|
+
const pathMod = await import('path');
|
|
55748
|
+
const { loadGlobby: loadGlobby2 } = await Promise.resolve().then(() => (init_esm_compat(), esm_compat_exports));
|
|
55749
|
+
const globby = await loadGlobby2();
|
|
55750
|
+
const ignore = [
|
|
55751
|
+
"**/node_modules/**",
|
|
55752
|
+
"**/.git/**",
|
|
55753
|
+
"**/dist/**",
|
|
55754
|
+
"**/build/**",
|
|
55755
|
+
"**/.maria/**",
|
|
55756
|
+
"**/.next/**",
|
|
55757
|
+
"**/coverage/**"
|
|
55758
|
+
];
|
|
55759
|
+
const hintTokens = Array.from(new Set(hintText.toLowerCase().replace(/[^a-z0-9_/.-]+/g, " ").split(/\s+/).filter(Boolean)));
|
|
55760
|
+
async function findBest(rel) {
|
|
55761
|
+
const normalized = rel.replace(/^\/+/, "").replace(/\\/g, "/");
|
|
55762
|
+
const fullExact = pathMod.join(root, normalized);
|
|
55763
|
+
try {
|
|
55764
|
+
await fs49.access(fullExact);
|
|
55765
|
+
return normalized;
|
|
55766
|
+
} catch {
|
|
55767
|
+
}
|
|
55768
|
+
const lowerRel = normalized.toLowerCase();
|
|
55769
|
+
const ext2 = (pathMod.extname(normalized) || "").toLowerCase();
|
|
55770
|
+
const base = pathMod.basename(normalized);
|
|
55771
|
+
const nameNoExt = base.replace(/\.[^.]+$/, "").toLowerCase();
|
|
55772
|
+
const parentPath = pathMod.dirname(normalized);
|
|
55773
|
+
const parent = parentPath.split("/").pop() || "";
|
|
55774
|
+
const dirParts = parentPath === "." ? [] : parentPath.split("/").filter(Boolean).map((s2) => s2.toLowerCase());
|
|
55775
|
+
const patterns = [];
|
|
55776
|
+
patterns.push(`**/${normalized}`);
|
|
55777
|
+
if (parent && parent !== "." && parent !== "/") patterns.push(`**/${parent}/${base}`);
|
|
55778
|
+
if (base) patterns.push(`**/${base}`);
|
|
55779
|
+
patterns.push(`**/*${base}`);
|
|
55780
|
+
if (!ext2) {
|
|
55781
|
+
patterns.push(`**/${nameNoExt}.*`);
|
|
55782
|
+
}
|
|
55783
|
+
const uniqPatterns = Array.from(new Set(patterns));
|
|
55784
|
+
const candidatesSet = /* @__PURE__ */ new Set();
|
|
55785
|
+
for (const pat of uniqPatterns) {
|
|
55786
|
+
const found = await globby(pat, { cwd: root, absolute: false, gitignore: true, ignore });
|
|
55787
|
+
for (const f3 of found) {
|
|
55788
|
+
candidatesSet.add(f3.replace(/\\/g, "/"));
|
|
55789
|
+
}
|
|
55790
|
+
if (candidatesSet.size > 200) break;
|
|
55791
|
+
}
|
|
55792
|
+
let candidates = Array.from(candidatesSet);
|
|
55793
|
+
if (dirParts.length > 0) {
|
|
55794
|
+
const filtered = candidates.filter((relp) => {
|
|
55795
|
+
const segs = relp.toLowerCase().split("/");
|
|
55796
|
+
let pos = -1;
|
|
55797
|
+
for (const part of dirParts) {
|
|
55798
|
+
const next = segs.indexOf(part, pos + 1);
|
|
55799
|
+
if (next === -1) return false;
|
|
55800
|
+
pos = next;
|
|
55801
|
+
}
|
|
55802
|
+
return true;
|
|
55803
|
+
});
|
|
55804
|
+
if (filtered.length > 0) candidates = filtered;
|
|
55805
|
+
}
|
|
55806
|
+
if (candidates.length === 0) {
|
|
55807
|
+
const prefixes = ["", "src/", "app/", "pages/"];
|
|
55808
|
+
for (const pre of prefixes) {
|
|
55809
|
+
const cand = pathMod.join(root, pre + normalized);
|
|
55810
|
+
try {
|
|
55811
|
+
await fs49.access(cand);
|
|
55812
|
+
return (pre + normalized).replace(/^\/+/, "");
|
|
55813
|
+
} catch {
|
|
55814
|
+
}
|
|
55815
|
+
}
|
|
55816
|
+
if (dirParts.length > 0) {
|
|
55817
|
+
if (/^(src|app|pages)\//i.test(normalized)) return normalized;
|
|
55818
|
+
const pref = await pickExistingFolderPrefix(root, parentPath);
|
|
55819
|
+
const combined = (pref + normalized).replace(/^\/+/, "").replace(/^(src\/)src\//i, "$1");
|
|
55820
|
+
return combined;
|
|
55821
|
+
}
|
|
55822
|
+
return normalized.replace(/^(src\/)src\//i, "$1");
|
|
55823
|
+
}
|
|
55824
|
+
function score(relPath) {
|
|
55825
|
+
const lower2 = relPath.toLowerCase();
|
|
55826
|
+
let s2 = 0;
|
|
55827
|
+
if (lower2.endsWith(lowerRel)) s2 += 80;
|
|
55828
|
+
if (lower2.split("/").pop() === base.toLowerCase()) s2 += 40;
|
|
55829
|
+
if (ext2 && lower2.endsWith(ext2)) s2 += 10;
|
|
55830
|
+
if (lower2.startsWith("src/")) s2 += 18;
|
|
55831
|
+
if (parent && lower2.includes(`/${parent.toLowerCase()}/`)) s2 += 15;
|
|
55832
|
+
if (parentPath && lower2.endsWith(`/${parentPath.toLowerCase()}/${base.toLowerCase()}`)) s2 += 40;
|
|
55833
|
+
if (dirParts.length > 0) {
|
|
55834
|
+
for (const part of dirParts) {
|
|
55835
|
+
if (lower2.includes(`/${part}/`)) s2 += 20;
|
|
55836
|
+
else s2 -= 120;
|
|
55837
|
+
}
|
|
55838
|
+
}
|
|
55839
|
+
for (const t2 of hintTokens) {
|
|
55840
|
+
if (t2.length >= 3 && lower2.includes(`/${t2}/`)) {
|
|
55841
|
+
s2 += 2;
|
|
55842
|
+
}
|
|
55843
|
+
}
|
|
55844
|
+
s2 -= Math.min(10, Math.floor(relPath.length / 80));
|
|
55845
|
+
return s2;
|
|
55846
|
+
}
|
|
55847
|
+
let best = candidates[0];
|
|
55848
|
+
let bestScore = score(best);
|
|
55849
|
+
for (let i2 = 1; i2 < candidates.length; i2++) {
|
|
55850
|
+
const c = candidates[i2];
|
|
55851
|
+
const sc = score(c);
|
|
55852
|
+
if (sc > bestScore) {
|
|
55853
|
+
best = c;
|
|
55854
|
+
bestScore = sc;
|
|
55855
|
+
}
|
|
55856
|
+
}
|
|
55857
|
+
return best.replace(/^\/+/, "");
|
|
55858
|
+
}
|
|
55859
|
+
const out = [];
|
|
55860
|
+
for (const f3 of files) {
|
|
55861
|
+
out.push(await findBest(f3));
|
|
55862
|
+
}
|
|
55863
|
+
return out;
|
|
55864
|
+
}
|
|
55865
|
+
async function pickExistingFolderPrefix(root, parentPath) {
|
|
55866
|
+
const fs49 = await import('fs/promises');
|
|
55867
|
+
const pathMod = await import('path');
|
|
55868
|
+
const parts = parentPath.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
55869
|
+
const prefixes = ["src", "app", "pages", ""];
|
|
55870
|
+
for (const pre of prefixes) {
|
|
55871
|
+
const test = pre ? pathMod.join(root, pre, ...parts) : pathMod.join(root, ...parts);
|
|
55872
|
+
try {
|
|
55873
|
+
await fs49.access(test);
|
|
55874
|
+
return pre ? `${pre}/` : "";
|
|
55875
|
+
} catch {
|
|
55876
|
+
}
|
|
55877
|
+
}
|
|
55878
|
+
return "src/";
|
|
55879
|
+
}
|
|
55524
55880
|
function scaffoldForFilename(filename, all) {
|
|
55525
55881
|
const lower2 = filename.toLowerCase();
|
|
55526
55882
|
if (lower2.endsWith(".html")) {
|
|
@@ -56495,16 +56851,6 @@ var init_resume_command = __esm({
|
|
|
56495
56851
|
}
|
|
56496
56852
|
});
|
|
56497
56853
|
|
|
56498
|
-
// src/utils/esm-compat.ts
|
|
56499
|
-
async function loadGlobby() {
|
|
56500
|
-
const mod = await import('globby');
|
|
56501
|
-
return mod?.globby ?? mod?.default ?? mod;
|
|
56502
|
-
}
|
|
56503
|
-
var init_esm_compat = __esm({
|
|
56504
|
-
"src/utils/esm-compat.ts"() {
|
|
56505
|
-
}
|
|
56506
|
-
});
|
|
56507
|
-
|
|
56508
56854
|
// src/services/init/scanner.ts
|
|
56509
56855
|
var scanner_exports = {};
|
|
56510
56856
|
__export(scanner_exports, {
|