@bonginkan/maria 4.3.39 → 4.3.41

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/dist/cli.cjs CHANGED
@@ -1709,7 +1709,7 @@ var init_AuthenticationManager = __esm({
1709
1709
  const response = await fetch(`${this.apiBase}/api/user/profile`, {
1710
1710
  headers: {
1711
1711
  "Authorization": `Bearer ${tokens2.accessToken}`,
1712
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.39"}`
1712
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.41"}`
1713
1713
  }
1714
1714
  });
1715
1715
  if (response.status === 401) {
@@ -2434,7 +2434,7 @@ async function callApi(path65, init3 = {}) {
2434
2434
  "Authorization": `Bearer ${token}`,
2435
2435
  "X-Device-Id": getDeviceId(),
2436
2436
  "X-Session-Id": getSessionId() || "",
2437
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.39"}`,
2437
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.41"}`,
2438
2438
  "Content-Type": init3.headers?.["Content-Type"] || "application/json"
2439
2439
  });
2440
2440
  const doFetch = async (token) => {
@@ -16382,8 +16382,8 @@ var require_package = __commonJS({
16382
16382
  "package.json"(exports, module) {
16383
16383
  module.exports = {
16384
16384
  name: "@bonginkan/maria",
16385
- version: "4.3.39",
16386
- description: "\u{1F680} MARIA v4.3.39 - 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.",
16385
+ version: "4.3.41",
16386
+ description: "\u{1F680} MARIA v4.3.41 - 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.",
16387
16387
  keywords: [
16388
16388
  "ai",
16389
16389
  "cli",
@@ -26389,7 +26389,7 @@ var init_about_command = __esm({
26389
26389
  async execute(args2, context2) {
26390
26390
  const output3 = [];
26391
26391
  output3.push("");
26392
- output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.39"));
26392
+ output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.41"));
26393
26393
  output3.push(chalk40__default.default.gray("\u2550".repeat(40)));
26394
26394
  output3.push("");
26395
26395
  output3.push(chalk40__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
@@ -39846,20 +39846,6 @@ var init_policy = __esm({
39846
39846
  }
39847
39847
  });
39848
39848
 
39849
- // src/utils/esm-compat.ts
39850
- var esm_compat_exports = {};
39851
- __export(esm_compat_exports, {
39852
- loadGlobby: () => loadGlobby
39853
- });
39854
- async function loadGlobby() {
39855
- const mod = await import('globby');
39856
- return mod?.globby ?? mod?.default ?? mod;
39857
- }
39858
- var init_esm_compat = __esm({
39859
- "src/utils/esm-compat.ts"() {
39860
- }
39861
- });
39862
-
39863
39849
  // src/services/code-orchestrator/Orchestrator.ts
39864
39850
  var Orchestrator_exports = {};
39865
39851
  __export(Orchestrator_exports, {
@@ -39919,6 +39905,122 @@ function languageFromExt(ext2) {
39919
39905
  if (e2 === "yaml" || e2 === "yml") return "yaml";
39920
39906
  return void 0;
39921
39907
  }
39908
+ async function readHeadTail(root, rel, n) {
39909
+ try {
39910
+ const fs52 = await import('fs/promises');
39911
+ const pathMod = await import('path');
39912
+ const full = pathMod.join(root, rel);
39913
+ const buf = await fs52.readFile(full, "utf8");
39914
+ const lines = buf.split(/\r?\n/);
39915
+ const head2 = lines.slice(0, n).join("\n");
39916
+ const tail = lines.slice(Math.max(0, lines.length - n)).join("\n");
39917
+ return { head: head2, tail };
39918
+ } catch {
39919
+ return { head: "", tail: "" };
39920
+ }
39921
+ }
39922
+ function extractJsonSafe(text, kind) {
39923
+ if (!text) return null;
39924
+ const fenceRegex = /```\s*(json)?\s*\r?\n([\s\S]*?)```/i;
39925
+ const fence = fenceRegex.exec(text);
39926
+ if (fence && fence[2]) text = fence[2];
39927
+ const match2 = kind === "object" ? text.match(/\{[\s\S]*\}/) : text.match(/\[[\s\S]*\]/);
39928
+ return match2 ? match2[0] : null;
39929
+ }
39930
+ async function llmSelectEditTargets(root, request, repoFiles) {
39931
+ try {
39932
+ const candidates = repoFiles.filter((p) => /\.(html|css|js|ts|tsx)$/i.test(p)).slice(0, 150);
39933
+ const samples = [];
39934
+ for (const p of candidates.slice(0, 60)) {
39935
+ const h2 = await readHeadTail(root, p, 5);
39936
+ samples.push(`- ${p}
39937
+ ${h2.head}`);
39938
+ }
39939
+ const system = [
39940
+ "You select existing repository files that should be EDITED to satisfy a user request.",
39941
+ "Consider path names and the first lines. Return JSON array of repo-relative paths to edit.",
39942
+ "If none are relevant, return []. Do not invent paths."
39943
+ ].join("\n");
39944
+ const user = [`Request: ${request}`, "Candidates:", samples.join("\n\n")].join("\n\n");
39945
+ const resp = await executeChat([
39946
+ { role: "system", content: system },
39947
+ { role: "user", content: user }
39948
+ ]);
39949
+ const raw = (resp?.output || "").trim();
39950
+ const jsonText = (() => {
39951
+ try {
39952
+ const m2 = raw.match(/\[[\s\S]*\]/);
39953
+ return m2 ? m2[0] : raw;
39954
+ } catch {
39955
+ return raw;
39956
+ }
39957
+ })();
39958
+ const arr = JSON.parse(jsonText);
39959
+ const set = new Set(candidates.map((c) => c.toLowerCase()));
39960
+ const out = [];
39961
+ if (Array.isArray(arr)) {
39962
+ for (const v of arr) {
39963
+ if (typeof v === "string" && set.has(v.toLowerCase())) out.push(v);
39964
+ if (out.length >= 10) break;
39965
+ }
39966
+ }
39967
+ return out;
39968
+ } catch {
39969
+ return [];
39970
+ }
39971
+ }
39972
+ async function llmMapBlockToFile(root, request, block, repoFiles) {
39973
+ try {
39974
+ const lang = (block.language || "").toLowerCase();
39975
+ const extFilter = lang.includes("html") ? /\.html$/i : /(ts|tsx)/.test(lang) ? /\.(ts|tsx)$/i : /(js|jsx)/.test(lang) ? /\.(js|jsx)$/i : /\.css$/i;
39976
+ const candidates = repoFiles.filter((p) => extFilter.test(p)).slice(0, 80);
39977
+ const head2 = block.code.split(/\r?\n/).slice(0, 20).join("\n");
39978
+ const samples = [];
39979
+ for (const p of candidates.slice(0, 40)) {
39980
+ const h2 = await readHeadTail(root, p, 8);
39981
+ samples.push(`- ${p}
39982
+ ${h2.head}`);
39983
+ }
39984
+ const system = [
39985
+ "Decide where to apply an EDIT vs CREATE for a code block within an existing repository.",
39986
+ 'Return JSON: { "action": "modify"|"create", "path": string }.',
39987
+ "If modify, path must be one of the candidate repo-relative paths. If create, propose a sensible repo-relative path."
39988
+ ].join("\n");
39989
+ const user = [
39990
+ `Request: ${request}`,
39991
+ "Block:",
39992
+ "```",
39993
+ head2,
39994
+ "```",
39995
+ "Candidates:",
39996
+ samples.join("\n\n")
39997
+ ].join("\n");
39998
+ const resp = await executeChat([
39999
+ { role: "system", content: system },
40000
+ { role: "user", content: user }
40001
+ ]);
40002
+ const raw = (resp?.output || "").trim();
40003
+ const jsonText = (() => {
40004
+ try {
40005
+ const m2 = raw.match(/\{[\s\S]*\}/);
40006
+ return m2 ? m2[0] : raw;
40007
+ } catch {
40008
+ return raw;
40009
+ }
40010
+ })();
40011
+ const parsed = JSON.parse(jsonText);
40012
+ if (parsed && (parsed.action === "modify" || parsed.action === "create") && typeof parsed.path === "string") {
40013
+ return { action: parsed.action, path: parsed.path.replace(/^\/+/, "") };
40014
+ }
40015
+ } catch {
40016
+ }
40017
+ const desired = typeof block.filename === "string" && block.filename.trim() ? block.filename.trim() : null;
40018
+ const fallback2 = desired || suggestName2(request, block.language, 0);
40019
+ return { action: "create", path: fallback2 };
40020
+ }
40021
+ function tokenizeRequest(text) {
40022
+ return Array.from(new Set(text.toLowerCase().replace(/[^a-z0-9_-]+/g, " ").split(/\s+/).filter((t2) => t2.length >= 3)));
40023
+ }
39922
40024
  async function ensureCodeFallbackManager() {
39923
40025
  const policy = await loadFallbackPolicy().catch(() => getDefaultFallbackPolicy());
39924
40026
  const signature = JSON.stringify(policy);
@@ -39957,15 +40059,16 @@ async function orchestrate(request, opts) {
39957
40059
  explicitAbsMap[rel] = pathMod.join(opts.root, rel);
39958
40060
  }
39959
40061
  }
39960
- const isEditIntent = await detectEditIntentEnhanced(opts.root, request, {
39961
- hasAttachments: !!(opts.attachedFiles && opts.attachedFiles.length > 0),
39962
- explicitFiles});
40062
+ const isEditIntent = await detectEditIntentLLM(opts.root, request, {
40063
+ explicitFiles,
40064
+ attachmentsCount: Array.isArray(opts.attachedFiles) ? opts.attachedFiles.length : 0
40065
+ });
39963
40066
  let editTargets = explicitFiles;
39964
40067
  if (isEditIntent && editTargets.length === 0) {
39965
40068
  try {
39966
40069
  const repoFiles = await getRepoFiles(opts.root);
39967
- const likely = repoFiles.filter((p) => /\.(ts|tsx|js|jsx|html|css|scss|json|md)$/i.test(p));
39968
- editTargets = likely.slice(0, 20);
40070
+ const llmTargets = await llmSelectEditTargets(opts.root, request, repoFiles);
40071
+ editTargets = llmTargets;
39969
40072
  } catch {
39970
40073
  }
39971
40074
  }
@@ -40026,6 +40129,7 @@ ${editContext}`;
40026
40129
  data_base64: f3.content ? Buffer.from(f3.content, "utf8").toString("base64") : void 0
40027
40130
  })).map((a) => a.data_base64 ? a : { ...a, data_base64: void 0 }) : [];
40028
40131
  const pathAttachments = [];
40132
+ const attachedPathSet = /* @__PURE__ */ new Set();
40029
40133
  if (explicitFiles.length > 0) {
40030
40134
  try {
40031
40135
  const fs52 = await import('fs/promises');
@@ -40044,6 +40148,32 @@ ${editContext}`;
40044
40148
  mime,
40045
40149
  data_base64: buf.toString("base64")
40046
40150
  });
40151
+ attachedPathSet.add(full.toLowerCase());
40152
+ } catch {
40153
+ }
40154
+ }
40155
+ } catch {
40156
+ }
40157
+ }
40158
+ if (isEditIntent && Array.isArray(editTargets) && editTargets.length > 0) {
40159
+ try {
40160
+ const fs52 = await import('fs/promises');
40161
+ const pathMod = await import('path');
40162
+ for (const rel of editTargets) {
40163
+ try {
40164
+ const full = pathMod.isAbsolute(rel) ? rel : pathMod.join(opts.root, rel);
40165
+ const key = full.toLowerCase();
40166
+ if (attachedPathSet.has(key)) continue;
40167
+ const stat13 = await fs52.stat(full).catch(() => null);
40168
+ if (!stat13 || !stat13.isFile()) continue;
40169
+ const buf = await fs52.readFile(full);
40170
+ pathAttachments.push({
40171
+ name: pathMod.basename(full),
40172
+ path: full,
40173
+ mime: "text/plain",
40174
+ data_base64: buf.toString("base64")
40175
+ });
40176
+ attachedPathSet.add(key);
40047
40177
  } catch {
40048
40178
  }
40049
40179
  }
@@ -40148,21 +40278,31 @@ ${editContext}`;
40148
40278
  return m2 >= 0 ? f3.slice(m2) : "";
40149
40279
  })();
40150
40280
  const lang = languageFromExt(ext2);
40151
- initial.push({ path: f3, absPath: absMap[f3], noNormalize: true, kind: "source", action: "modify", description: "Edit target", language: lang, preview: "" });
40281
+ const strongMatch = /pong|retro|game|index\.(html)$|script\.(js|ts)$|style\.css/i.test(f3) || tokenizeRequest(request).some((t2) => f3.toLowerCase().includes(t2));
40282
+ if (strongMatch) {
40283
+ initial.push({ path: f3, absPath: absMap[f3], noNormalize: true, kind: "source", action: "modify", description: "Edit target", language: lang, preview: "" });
40284
+ }
40152
40285
  }
40153
40286
  } else {
40154
- for (let i2 = 0; i2 < blocks.length; i2++) {
40155
- const b = blocks[i2];
40156
- const desired = typeof b.filename === "string" && b.filename.trim() ? b.filename.trim() : null;
40157
- const path65 = desired || suggestName2(request, b.language, i2);
40158
- initial.push({
40159
- path: path65,
40160
- kind: "source",
40161
- action: "create",
40162
- description: describe2(b.language, ""),
40163
- language: b.language,
40164
- preview: b.code
40165
- });
40287
+ try {
40288
+ const repoFiles = await getRepoFiles(opts.root);
40289
+ for (let i2 = 0; i2 < blocks.length; i2++) {
40290
+ const b = blocks[i2];
40291
+ const decision = await llmMapBlockToFile(opts.root, request, b, repoFiles);
40292
+ if (decision.action === "modify" && repoFiles.includes(decision.path)) {
40293
+ const lang = languageFromExt(decision.path.replace(/^.*(\.[a-z0-9]+)$/i, "$1"));
40294
+ initial.push({ path: decision.path, kind: "source", action: "modify", description: "Modify existing file", language: lang, preview: b.code });
40295
+ } else {
40296
+ const path65 = decision.path || suggestName2(request, b.language, i2);
40297
+ initial.push({ path: path65, kind: "source", action: "create", description: describe2(b.language, ""), language: b.language, preview: b.code });
40298
+ }
40299
+ }
40300
+ } catch {
40301
+ for (let i2 = 0; i2 < blocks.length; i2++) {
40302
+ const b = blocks[i2];
40303
+ const path65 = suggestName2(request, b.language, i2);
40304
+ initial.push({ path: path65, kind: "source", action: "create", description: describe2(b.language, ""), language: b.language, preview: b.code });
40305
+ }
40166
40306
  }
40167
40307
  }
40168
40308
  }
@@ -40202,6 +40342,9 @@ ${editContext}`;
40202
40342
  } catch {
40203
40343
  p.action = "create";
40204
40344
  }
40345
+ if (p.action === "modify" && (!p.preview || p.preview.length === 0)) {
40346
+ p.action = "skip";
40347
+ }
40205
40348
  }
40206
40349
  } catch {
40207
40350
  }
@@ -40278,7 +40421,7 @@ ${editContext}`;
40278
40421
  }
40279
40422
  }
40280
40423
  const allowOverwrite = opts.flags.overwriteAllowed === true || !!opts.flags.yes || isEditIntent;
40281
- const applyRes = await applyPlans(approved, { root: opts.root, overwriteAllowed: allowOverwrite, rollback: opts.flags.rollback !== false, signal: opts.abortSignal, onProgress: (w, t2) => {
40424
+ const applyRes = await applyPlans(approved, { root: opts.root, overwriteAllowed: allowOverwrite, rollback: opts.flags.rollback !== false, signal: opts.abortSignal, onProgress: () => {
40282
40425
  }, eol: profile.eol });
40283
40426
  appliedCount = applyRes.appliedCount;
40284
40427
  durationMs = applyRes.durationMs;
@@ -40558,73 +40701,50 @@ function parseExplicitFilenames(request) {
40558
40701
  }
40559
40702
  return out;
40560
40703
  }
40561
- function detectEditIntent(request, ctx2) {
40562
- const r2 = request.toLowerCase();
40563
- const editKeywords = ["modify", "edit", "update", "fix", "refactor", "change", "patch", "\u5DEE\u5206", "\u4FEE\u6B63", "\u5909\u66F4", "\u65E2\u5B58", "\u8FFD\u8A18"];
40564
- const mentionsEdit = editKeywords.some((k) => r2.includes(k));
40565
- return ctx2.hasAttachments || ctx2.explicitFilesCount > 0 || mentionsEdit;
40566
- }
40567
- async function detectEditIntentEnhanced(root, request, ctx2) {
40568
- const baseline = detectEditIntent(request, { hasAttachments: ctx2.hasAttachments, explicitFilesCount: ctx2.explicitFiles.length });
40569
- if (baseline) return true;
40570
- const r2 = request.toLowerCase();
40571
- const softHints = ["improve", "enhance", "make it", "change the", "adjust", "tweak", "rework", "revamp", "retro", "modernize", "clean up", "polish"];
40572
- const hasSoftHint = softHints.some((k) => r2.includes(k));
40573
- if (!hasSoftHint) return false;
40574
- try {
40575
- const fs52 = await import('fs/promises');
40576
- const pathMod = await import('path');
40577
- const { loadGlobby: loadGlobby2 } = await Promise.resolve().then(() => (init_esm_compat(), esm_compat_exports));
40578
- const globby = await loadGlobby2();
40579
- const ignore = [
40580
- "**/node_modules/**",
40581
- "**/.git/**",
40582
- "**/dist/**",
40583
- "**/build/**",
40584
- "**/.maria/**",
40585
- "**/.next/**",
40586
- "**/coverage/**",
40587
- "**/.DS_Store/**",
40588
- "**/.DS_Store",
40589
- "**/.Spotlight-V100/**",
40590
- "**/.Spotlight-V100",
40591
- "**/.Trashes/**",
40592
- "**/.Trashes",
40593
- "**/.fseventsd/**",
40594
- "**/.fseventsd",
40595
- "**/.TemporaryItems/**",
40596
- "**/.TemporaryItems"
40597
- ];
40598
- const candidates = await globby(["**/*.{html,css,js,ts,tsx}"], { cwd: root, absolute: true, gitignore: true, ignore, deep: 3 });
40599
- if (candidates && candidates.length > 0) return true;
40600
- } catch {
40601
- }
40704
+ async function detectEditIntentLLM(root, request, ctx2) {
40602
40705
  try {
40603
- const short = request.trim().length <= 160;
40604
- if (!short) return false;
40706
+ const repoFiles = await getRepoFiles(root);
40707
+ const candidates = repoFiles;
40708
+ const headSnippets = [];
40709
+ for (const p of candidates) {
40710
+ const h2 = await readHeadTail(root, p, 5);
40711
+ headSnippets.push(`- ${p}
40712
+ ${h2.head}`);
40713
+ }
40605
40714
  const system = [
40606
- "You are classifying whether the user intends to EDIT existing files vs CREATE a new project.",
40607
- 'Return JSON: { "edit": true|false } only.'
40715
+ "Classify the user intent for the MARIA code orchestrator.",
40716
+ "Decide strictly between EDIT_EXISTING (modify existing files) or CREATE_NEW (generate new project/files).",
40717
+ "User is likely to have EDIT_EXITING intent when:",
40718
+ "- the coding language is not specified",
40719
+ "- it has a clear and/or relevant path of the file/directory exists",
40720
+ "- it has attachments",
40721
+ "- the wording implies modifying existing files (ex. fix, improve, update, change, patch, make it, clean up, etc.)",
40722
+ 'Return JSON: { "intent": "EDIT_EXISTING" | "CREATE_NEW" } only. No commentary.'
40608
40723
  ].join("\n");
40609
- const user = `Instruction: ${request}`;
40724
+ const user = [
40725
+ `Request: ${request}`,
40726
+ `ExplicitFiles: ${JSON.stringify(ctx2.explicitFiles || [])}`,
40727
+ `AttachmentsCount: ${ctx2.attachmentsCount}`,
40728
+ "Repo snapshot (paths with file heads):",
40729
+ headSnippets.join("\n\n")
40730
+ ].join("\n\n");
40731
+ const spin1 = new ProcessAnimation();
40732
+ spin1.start();
40610
40733
  const resp = await executeChat([
40611
40734
  { role: "system", content: system },
40612
40735
  { role: "user", content: user }
40613
40736
  ]);
40737
+ try {
40738
+ spin1.stop();
40739
+ } catch {
40740
+ }
40614
40741
  const raw = (resp?.output || "").trim();
40615
- const jsonText = (() => {
40616
- try {
40617
- const m2 = raw.match(/\{[\s\S]*\}/);
40618
- return m2 ? m2[0] : raw;
40619
- } catch {
40620
- return raw;
40621
- }
40622
- })();
40742
+ const jsonText = extractJsonSafe(raw, "object") || raw;
40623
40743
  const parsed = JSON.parse(jsonText);
40624
- if (typeof parsed?.edit === "boolean") return !!parsed.edit;
40744
+ return parsed?.intent === "EDIT_EXISTING";
40625
40745
  } catch {
40746
+ return ctx2.explicitFiles && ctx2.explicitFiles.length > 0 || ctx2.attachmentsCount > 0;
40626
40747
  }
40627
- return false;
40628
40748
  }
40629
40749
  function sanitizeFolderName(name2) {
40630
40750
  const base = name2.toLowerCase().replace(/[`~!@#$%^&*()+=\[\]{}|;:'",<>/?\\]/g, " ").replace(/\s+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
@@ -40746,7 +40866,6 @@ async function resolveExplicitPaths(root, files, hintText) {
40746
40866
  const lowerRel = normalized.toLowerCase();
40747
40867
  const ext2 = (pathMod.extname(normalized) || "").toLowerCase();
40748
40868
  const base = pathMod.basename(normalized);
40749
- base.replace(/\.[^.]+$/, "").toLowerCase();
40750
40869
  const parentPath = pathMod.dirname(normalized);
40751
40870
  const parent = parentPath.split("/").pop() || "";
40752
40871
  const dirParts = parentPath === "." ? [] : parentPath.split("/").filter(Boolean).map((s2) => s2.toLowerCase());
@@ -40907,6 +41026,7 @@ var init_Orchestrator = __esm({
40907
41026
  init_AttachmentMapper();
40908
41027
  init_FallbackManager();
40909
41028
  init_policy();
41029
+ init_animations();
40910
41030
  codeFallbackManager = null;
40911
41031
  _repoFileIndexCache = null;
40912
41032
  codeFallbackPolicySignature = null;
@@ -42397,6 +42517,16 @@ var init_loader = __esm({
42397
42517
  }
42398
42518
  });
42399
42519
 
42520
+ // src/utils/esm-compat.ts
42521
+ async function loadGlobby() {
42522
+ const mod = await import('globby');
42523
+ return mod?.globby ?? mod?.default ?? mod;
42524
+ }
42525
+ var init_esm_compat = __esm({
42526
+ "src/utils/esm-compat.ts"() {
42527
+ }
42528
+ });
42529
+
42400
42530
  // src/services/init/scanner.ts
42401
42531
  var scanner_exports = {};
42402
42532
  __export(scanner_exports, {