@bonginkan/maria 4.3.42 → 4.3.44

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.42"}`
1712
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.44"}`
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.42"}`,
2437
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.44"}`,
2438
2438
  "Content-Type": init3.headers?.["Content-Type"] || "application/json"
2439
2439
  });
2440
2440
  const doFetch = async (token) => {
@@ -3136,11 +3136,28 @@ async function callAPI(endpoint, options = {}) {
3136
3136
  }
3137
3137
  }
3138
3138
  async function executeChat(messages) {
3139
- const response = await callAPI("/v1/ai-proxy", {
3140
- method: "POST",
3141
- body: { messages }
3142
- });
3143
- return response;
3139
+ const maxAttempts = 4;
3140
+ let lastErr;
3141
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
3142
+ try {
3143
+ const response = await callAPI("/v1/ai-proxy", {
3144
+ method: "POST",
3145
+ body: { messages, taskType: "chat" }
3146
+ });
3147
+ return response;
3148
+ } catch (e2) {
3149
+ lastErr = e2;
3150
+ const isRateLimit = e2?.name === "RateLimitError" || /rate\s*limit|429/i.test(String(e2?.message || ""));
3151
+ if (!isRateLimit || attempt === maxAttempts) {
3152
+ throw e2;
3153
+ }
3154
+ const waitSec = Math.max(1, Math.min(60, Number(e2?.retryAfter || 0)));
3155
+ const baseMs = (waitSec > 0 ? waitSec * 1e3 : 1500) * attempt;
3156
+ const jitter = Math.floor(Math.random() * 400);
3157
+ await new Promise((r2) => setTimeout(r2, Math.min(3e4, baseMs + jitter)));
3158
+ }
3159
+ }
3160
+ throw lastErr;
3144
3161
  }
3145
3162
  async function executeCode(input3) {
3146
3163
  const isOptions = typeof input3 === "object";
@@ -3154,17 +3171,34 @@ async function executeCode(input3) {
3154
3171
  if (attachments && attachments.length > 0) {
3155
3172
  body.metadata = { attachments };
3156
3173
  }
3157
- const response = await callAPI("/v1/ai-proxy", {
3158
- method: "POST",
3159
- body
3160
- });
3161
- if (response.data?.routedModel) {
3162
- response.routedModel = response.data.routedModel;
3163
- }
3164
- if (response.data?.content) {
3165
- response.output = response.data.content;
3174
+ const maxAttempts = 5;
3175
+ let lastErr;
3176
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
3177
+ try {
3178
+ const response = await callAPI("/v1/ai-proxy", {
3179
+ method: "POST",
3180
+ body
3181
+ });
3182
+ if (response.data?.routedModel) {
3183
+ response.routedModel = response.data.routedModel;
3184
+ }
3185
+ if (response.data?.content) {
3186
+ response.output = response.data.content;
3187
+ }
3188
+ return response;
3189
+ } catch (e2) {
3190
+ lastErr = e2;
3191
+ const isRateLimit = e2?.name === "RateLimitError" || /rate\s*limit|429/i.test(String(e2?.message || ""));
3192
+ if (!isRateLimit || attempt === maxAttempts) {
3193
+ throw e2;
3194
+ }
3195
+ const waitSec = Math.max(1, Math.min(60, Number(e2?.retryAfter || 0)));
3196
+ const baseMs = (waitSec > 0 ? waitSec * 1e3 : 2e3) * attempt;
3197
+ const jitter = Math.floor(Math.random() * 500);
3198
+ await new Promise((r2) => setTimeout(r2, Math.min(45e3, baseMs + jitter)));
3199
+ }
3166
3200
  }
3167
- return response;
3201
+ throw lastErr;
3168
3202
  }
3169
3203
  async function executeAIProxy(provider, model, messages, options) {
3170
3204
  return callAPI("/v1/ai-proxy", {
@@ -16382,8 +16416,8 @@ var require_package = __commonJS({
16382
16416
  "package.json"(exports, module) {
16383
16417
  module.exports = {
16384
16418
  name: "@bonginkan/maria",
16385
- version: "4.3.42",
16386
- description: "\u{1F680} MARIA v4.3.42 - 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.",
16419
+ version: "4.3.44",
16420
+ description: "\u{1F680} MARIA v4.3.44 - 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
16421
  keywords: [
16388
16422
  "ai",
16389
16423
  "cli",
@@ -26389,7 +26423,7 @@ var init_about_command = __esm({
26389
26423
  async execute(args2, context2) {
26390
26424
  const output3 = [];
26391
26425
  output3.push("");
26392
- output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.42"));
26426
+ output3.push(chalk40__default.default.cyan.bold("\u{1F916} About MARIA v4.3.44"));
26393
26427
  output3.push(chalk40__default.default.gray("\u2550".repeat(40)));
26394
26428
  output3.push("");
26395
26429
  output3.push(chalk40__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
@@ -39947,14 +39981,7 @@ ${h2.head}`);
39947
39981
  { role: "user", content: user }
39948
39982
  ]);
39949
39983
  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
- })();
39984
+ const jsonText = extractJsonSafe(raw, "array") || raw;
39958
39985
  const arr = JSON.parse(jsonText);
39959
39986
  const set = new Set(candidates.map((c) => c.toLowerCase()));
39960
39987
  const out = [];
@@ -39969,54 +39996,68 @@ ${h2.head}`);
39969
39996
  return [];
39970
39997
  }
39971
39998
  }
39972
- async function llmMapBlockToFile(root, request, block, repoFiles) {
39999
+ async function llmMapBlocksBatch(root, request, blocks, repoFiles) {
39973
40000
  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");
40001
+ const candidates = repoFiles.filter((p) => /\.(html|css|js|ts|tsx)$/i.test(p)).slice(0, 120);
40002
+ const blockSnippets = blocks.slice(0, 20).map((b, i2) => {
40003
+ const head2 = (b.code || "").split(/\r?\n/).slice(0, 20).join("\n");
40004
+ return `# block ${i2}
40005
+
40006
+ \`\`\`
40007
+ ${head2}
40008
+ \`\`\``;
40009
+ }).join("\n\n");
39978
40010
  const samples = [];
39979
- for (const p of candidates.slice(0, 40)) {
40011
+ for (const p of candidates.slice(0, 60)) {
39980
40012
  const h2 = await readHeadTail(root, p, 8);
39981
40013
  samples.push(`- ${p}
39982
40014
  ${h2.head}`);
39983
40015
  }
39984
40016
  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."
40017
+ "For each provided code block, decide whether to MODIFY an existing repo file or CREATE a new file.",
40018
+ 'Return JSON array of objects: [{ "index": number, "action": "modify"|"create", "path": string }].',
40019
+ "When action is modify, path MUST be one of the candidate repo-relative paths listed."
39988
40020
  ].join("\n");
39989
40021
  const user = [
39990
40022
  `Request: ${request}`,
39991
- "Block:",
39992
- "```",
39993
- head2,
39994
- "```",
40023
+ "Blocks:",
40024
+ blockSnippets,
39995
40025
  "Candidates:",
39996
40026
  samples.join("\n\n")
39997
- ].join("\n");
40027
+ ].join("\n\n");
40028
+ const spin = new ProcessAnimation();
40029
+ spin.start();
39998
40030
  const resp = await executeChat([
39999
40031
  { role: "system", content: system },
40000
40032
  { role: "user", content: user }
40001
40033
  ]);
40034
+ try {
40035
+ spin.stop();
40036
+ } catch {
40037
+ }
40002
40038
  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;
40039
+ const jsonText = extractJsonSafe(raw, "array") || raw;
40040
+ const arr = JSON.parse(jsonText);
40041
+ const set = new Set(candidates.map((c) => c.toLowerCase()));
40042
+ const out = [];
40043
+ if (Array.isArray(arr)) {
40044
+ for (const item of arr) {
40045
+ const idx = typeof item?.index === "number" ? item.index : -1;
40046
+ const action = item?.action === "modify" ? "modify" : "create";
40047
+ const path65 = typeof item?.path === "string" ? String(item.path) : "";
40048
+ if (idx >= 0 && idx < blocks.length) {
40049
+ if (action === "modify" && set.has(path65.toLowerCase())) out[idx] = { action, path: path65.replace(/^\/+/, "") };
40050
+ else out[idx] = { action: "create", path: path65 || suggestName2(request, blocks[idx].language || "javascript", idx) };
40051
+ }
40009
40052
  }
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
40053
  }
40054
+ for (let i2 = 0; i2 < blocks.length; i2++) {
40055
+ if (!out[i2]) out[i2] = { action: "create", path: suggestName2(request, blocks[i2].language || "javascript", i2) };
40056
+ }
40057
+ return out;
40015
40058
  } catch {
40059
+ return blocks.map((b, i2) => ({ action: "create", path: suggestName2(request, b.language || "javascript", i2) }));
40016
40060
  }
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
40061
  }
40021
40062
  function tokenizeRequest(text) {
40022
40063
  return Array.from(new Set(text.toLowerCase().replace(/[^a-z0-9_-]+/g, " ").split(/\s+/).filter((t2) => t2.length >= 3)));
@@ -40286,15 +40327,16 @@ ${editContext}`;
40286
40327
  } else {
40287
40328
  try {
40288
40329
  const repoFiles = await getRepoFiles(opts.root);
40330
+ const decisions = await llmMapBlocksBatch(opts.root, request, blocks, repoFiles);
40289
40331
  for (let i2 = 0; i2 < blocks.length; i2++) {
40290
40332
  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 });
40333
+ const d = decisions[i2] || { action: "create", path: suggestName2(request, b.language, i2) };
40334
+ if (d.action === "modify" && repoFiles.includes(d.path)) {
40335
+ const lang = languageFromExt(d.path.replace(/^.*(\.[a-z0-9]+)$/i, "$1"));
40336
+ initial.push({ path: d.path, kind: "source", action: "modify", description: "Modify existing file", language: lang, preview: b.code });
40295
40337
  } 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 });
40338
+ const pth = d.path || suggestName2(request, b.language, i2);
40339
+ initial.push({ path: pth, kind: "source", action: "create", description: describe2(b.language, ""), language: b.language, preview: b.code });
40298
40340
  }
40299
40341
  }
40300
40342
  } catch {