@bonginkan/maria 4.3.9 → 4.3.10

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.
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var fs22 = require('fs');
5
- var path54 = require('path');
5
+ var path55 = require('path');
6
6
  var chalk36 = require('chalk');
7
7
  var os16 = require('os');
8
8
  var Stream = require('stream');
@@ -55,7 +55,7 @@ function _interopNamespace(e) {
55
55
  }
56
56
 
57
57
  var fs22__namespace = /*#__PURE__*/_interopNamespace(fs22);
58
- var path54__namespace = /*#__PURE__*/_interopNamespace(path54);
58
+ var path55__namespace = /*#__PURE__*/_interopNamespace(path55);
59
59
  var chalk36__default = /*#__PURE__*/_interopDefault(chalk36);
60
60
  var os16__namespace = /*#__PURE__*/_interopNamespace(os16);
61
61
  var Stream__default = /*#__PURE__*/_interopDefault(Stream);
@@ -207,25 +207,25 @@ function getPackageJson() {
207
207
  try {
208
208
  const possiblePaths = [
209
209
  // When running from built dist/
210
- path54.join(__dirname, "../../package.json"),
210
+ path55.join(__dirname, "../../package.json"),
211
211
  // When running from source
212
- path54.join(__dirname, "../../../package.json"),
212
+ path55.join(__dirname, "../../../package.json"),
213
213
  // Current working directory
214
- path54.join(process.cwd(), "package.json"),
214
+ path55.join(process.cwd(), "package.json"),
215
215
  // One level up from current working directory
216
- path54.join(process.cwd(), "../package.json"),
216
+ path55.join(process.cwd(), "../package.json"),
217
217
  // For globally installed packages
218
- path54.join(__dirname, "../../../../package.json"),
219
- path54.join(__dirname, "../../../../../package.json"),
218
+ path55.join(__dirname, "../../../../package.json"),
219
+ path55.join(__dirname, "../../../../../package.json"),
220
220
  // npm global install locations
221
221
  "/usr/local/lib/node_modules/@bonginkan/maria/package.json",
222
222
  "/usr/lib/node_modules/@bonginkan/maria/package.json",
223
223
  // User home npm global
224
- path54.join(
224
+ path55.join(
225
225
  process.env.HOME || "",
226
226
  ".npm-global/lib/node_modules/@bonginkan/maria/package.json"
227
227
  ),
228
- path54.join(
228
+ path55.join(
229
229
  process.env.HOME || "",
230
230
  ".nvm/versions/node",
231
231
  process.version,
@@ -233,13 +233,13 @@ function getPackageJson() {
233
233
  )
234
234
  ];
235
235
  let packageJsonPath = null;
236
- for (const path55 of possiblePaths) {
237
- if (fs22.existsSync(path55)) {
236
+ for (const path56 of possiblePaths) {
237
+ if (fs22.existsSync(path56)) {
238
238
  try {
239
- const content = fs22.readFileSync(path55, "utf-8");
239
+ const content = fs22.readFileSync(path56, "utf-8");
240
240
  const parsed = JSON.parse(content);
241
241
  if (parsed.name === "@bonginkan/maria") {
242
- packageJsonPath = path55;
242
+ packageJsonPath = path56;
243
243
  break;
244
244
  }
245
245
  } catch {
@@ -508,8 +508,8 @@ var USE_LEGACY_PROVIDERS2, DEFAULT_PROVIDER2, DEFAULT_MODEL2;
508
508
  var init_config = __esm({
509
509
  "src/providers/config.ts"() {
510
510
  USE_LEGACY_PROVIDERS2 = false;
511
- DEFAULT_PROVIDER2 = process.env.DEFAULT_PROVIDER || "openai";
512
- DEFAULT_MODEL2 = process.env.OPENAI_MODEL || process.env.MARIA_DEFAULT_MODEL || "gpt-5-mini";
511
+ DEFAULT_PROVIDER2 = process.env.DEFAULT_PROVIDER || "google";
512
+ DEFAULT_MODEL2 = process.env.MARIA_DEFAULT_MODEL || process.env.OPENAI_MODEL || "gemini-2.5-flash";
513
513
  }
514
514
  });
515
515
 
@@ -5312,22 +5312,22 @@ var init_from = __esm({
5312
5312
  init_file();
5313
5313
  init_fetch_blob();
5314
5314
  ({ stat } = fs22.promises);
5315
- blobFromSync = (path55, type) => fromBlob(fs22.statSync(path55), path55, type);
5316
- blobFrom = (path55, type) => stat(path55).then((stat13) => fromBlob(stat13, path55, type));
5317
- fileFrom = (path55, type) => stat(path55).then((stat13) => fromFile(stat13, path55, type));
5318
- fileFromSync = (path55, type) => fromFile(fs22.statSync(path55), path55, type);
5319
- fromBlob = (stat13, path55, type = "") => new fetch_blob_default([new BlobDataItem({
5320
- path: path55,
5315
+ blobFromSync = (path56, type) => fromBlob(fs22.statSync(path56), path56, type);
5316
+ blobFrom = (path56, type) => stat(path56).then((stat13) => fromBlob(stat13, path56, type));
5317
+ fileFrom = (path56, type) => stat(path56).then((stat13) => fromFile(stat13, path56, type));
5318
+ fileFromSync = (path56, type) => fromFile(fs22.statSync(path56), path56, type);
5319
+ fromBlob = (stat13, path56, type = "") => new fetch_blob_default([new BlobDataItem({
5320
+ path: path56,
5321
5321
  size: stat13.size,
5322
5322
  lastModified: stat13.mtimeMs,
5323
5323
  start: 0
5324
5324
  })], { type });
5325
- fromFile = (stat13, path55, type = "") => new file_default([new BlobDataItem({
5326
- path: path55,
5325
+ fromFile = (stat13, path56, type = "") => new file_default([new BlobDataItem({
5326
+ path: path56,
5327
5327
  size: stat13.size,
5328
5328
  lastModified: stat13.mtimeMs,
5329
5329
  start: 0
5330
- })], path54.basename(path55), { type, lastModified: stat13.mtimeMs });
5330
+ })], path55.basename(path56), { type, lastModified: stat13.mtimeMs });
5331
5331
  BlobDataItem = class _BlobDataItem {
5332
5332
  #path;
5333
5333
  #start;
@@ -9565,12 +9565,12 @@ ${this.toYamlLike(value, indent + 1)}`;
9565
9565
  }
9566
9566
  static async loadFromFile(configPath) {
9567
9567
  const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
9568
- const fs45 = await importNodeBuiltin2("fs");
9568
+ const fs46 = await importNodeBuiltin2("fs");
9569
9569
  const _path = await importNodeBuiltin2("_path");
9570
9570
  const os24 = await importNodeBuiltin2("os");
9571
9571
  const targetPath = configPath || _path.join(os24.homedir(), ".maria", "config.json");
9572
9572
  try {
9573
- const data = await fs45.promises.readFile(targetPath, "utf-8");
9573
+ const data = await fs46.promises.readFile(targetPath, "utf-8");
9574
9574
  return JSON.parse(data);
9575
9575
  } catch (innerError) {
9576
9576
  if (innerError?.code === "ENOENT") {
@@ -9584,25 +9584,25 @@ ${this.toYamlLike(value, indent + 1)}`;
9584
9584
  }
9585
9585
  async save(configPath, options) {
9586
9586
  const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
9587
- const fs45 = await importNodeBuiltin2("fs");
9587
+ const fs46 = await importNodeBuiltin2("fs");
9588
9588
  const _path = await importNodeBuiltin2("_path");
9589
9589
  const os24 = await importNodeBuiltin2("os");
9590
9590
  const targetPath = configPath || _path.join(os24.homedir(), ".maria", "config.json");
9591
9591
  try {
9592
9592
  if (options?.backup) {
9593
9593
  try {
9594
- await fs45.promises.access(targetPath);
9594
+ await fs46.promises.access(targetPath);
9595
9595
  const backupPath = `${targetPath}.backup.${Date.now()}`;
9596
- await fs45.promises.copyFile(targetPath, backupPath);
9596
+ await fs46.promises.copyFile(targetPath, backupPath);
9597
9597
  } catch {
9598
9598
  }
9599
9599
  }
9600
- await fs45.promises.mkdir(_path.dirname(targetPath), { recursive: true });
9600
+ await fs46.promises.mkdir(_path.dirname(targetPath), { recursive: true });
9601
9601
  const dataToSave = this.getAll({
9602
9602
  maskSensitive: options?.maskSensitive ?? true,
9603
9603
  includeSourceMap: options?.includeSourceMap ?? false
9604
9604
  });
9605
- await fs45.promises.writeFile(
9605
+ await fs46.promises.writeFile(
9606
9606
  targetPath,
9607
9607
  JSON.stringify(dataToSave, null, 2),
9608
9608
  { mode: 384 }
@@ -9646,12 +9646,12 @@ ${this.toYamlLike(value, indent + 1)}`;
9646
9646
  }
9647
9647
  if (outputPath) {
9648
9648
  const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
9649
- const fs45 = await importNodeBuiltin2("fs");
9649
+ const fs46 = await importNodeBuiltin2("fs");
9650
9650
  const _path = await importNodeBuiltin2(
9651
9651
  "_path"
9652
9652
  );
9653
- await fs45.promises.mkdir(_path.dirname(outputPath), { recursive: true });
9654
- await fs45.promises.writeFile(outputPath, content, "utf-8");
9653
+ await fs46.promises.mkdir(_path.dirname(outputPath), { recursive: true });
9654
+ await fs46.promises.writeFile(outputPath, content, "utf-8");
9655
9655
  console.log(`\u2705 Configuration exported to ${outputPath}`);
9656
9656
  }
9657
9657
  return content;
@@ -9960,13 +9960,13 @@ async function loadEnvironmentConfig() {
9960
9960
  }
9961
9961
  try {
9962
9962
  const { importNodeBuiltin: importNodeBuiltin2, safeDynamicImport: safeDynamicImport2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
9963
- const fs45 = await safeDynamicImport2("fs-extra").catch(
9963
+ const fs46 = await safeDynamicImport2("fs-extra").catch(
9964
9964
  () => importNodeBuiltin2("fs")
9965
9965
  );
9966
9966
  const _path = await importNodeBuiltin2("_path");
9967
9967
  const _envPath = _path.join(process.cwd(), ".env.local");
9968
- if (await fs45.pathExists(_envPath)) {
9969
- const _envContent = await fs45.readFile(_envPath, "utf-8");
9968
+ if (await fs46.pathExists(_envPath)) {
9969
+ const _envContent = await fs46.readFile(_envPath, "utf-8");
9970
9970
  console.log("Loading environment from:", _envPath);
9971
9971
  environmentLoaded = true;
9972
9972
  const _lines = _envContent.split("\n");
@@ -10032,14 +10032,14 @@ var init_NaturalLanguageProcessor = __esm({
10032
10032
  }
10033
10033
  async process(input3, language = "en") {
10034
10034
  const normalized = this.normalize(input3, language);
10035
- const tokens = this.tokenize(normalized, language);
10036
- const stems = this.stem(tokens, language);
10035
+ const tokens2 = this.tokenize(normalized, language);
10036
+ const stems = this.stem(tokens2, language);
10037
10037
  const entities = this.extractEntities(input3);
10038
- const _keywords = this.extractKeywords(tokens, language);
10038
+ const _keywords = this.extractKeywords(tokens2, language);
10039
10039
  return {
10040
10040
  original: input3,
10041
10041
  normalized,
10042
- tokens,
10042
+ tokens: tokens2,
10043
10043
  stems,
10044
10044
  entities,
10045
10045
  language,
@@ -10089,7 +10089,7 @@ var init_NaturalLanguageProcessor = __esm({
10089
10089
  return text.split(/\s+/).filter((token) => token.length > 0);
10090
10090
  }
10091
10091
  tokenizeJapanese(text) {
10092
- const tokens = [];
10092
+ const tokens2 = [];
10093
10093
  const _patterns = [
10094
10094
  /[\u4e00-\u9faf]+/g,
10095
10095
  // Kanji
@@ -10105,24 +10105,24 @@ var init_NaturalLanguageProcessor = __esm({
10105
10105
  _patterns.forEach((pattern) => {
10106
10106
  const _matches = text.match(pattern);
10107
10107
  if (_matches) {
10108
- tokens.push(..._matches);
10108
+ tokens2.push(..._matches);
10109
10109
  }
10110
10110
  });
10111
- return tokens;
10111
+ return tokens2;
10112
10112
  }
10113
10113
  tokenizeChinese(text) {
10114
- const tokens = [];
10114
+ const tokens2 = [];
10115
10115
  for (const char of text) {
10116
10116
  if (/[\u4e00-\u9faf]/.test(char)) {
10117
- tokens.push(char);
10117
+ tokens2.push(char);
10118
10118
  } else if (/[a-zA-Z0-9]+/.test(char)) {
10119
- tokens.push(char);
10119
+ tokens2.push(char);
10120
10120
  }
10121
10121
  }
10122
- return tokens;
10122
+ return tokens2;
10123
10123
  }
10124
10124
  tokenizeKorean(text) {
10125
- const tokens = [];
10125
+ const tokens2 = [];
10126
10126
  const _patterns = [
10127
10127
  /[\uac00-\ud7af]+/g,
10128
10128
  // Hangul
@@ -10134,16 +10134,16 @@ var init_NaturalLanguageProcessor = __esm({
10134
10134
  _patterns.forEach((pattern) => {
10135
10135
  const _matches = text.match(pattern);
10136
10136
  if (_matches) {
10137
- tokens.push(..._matches);
10137
+ tokens2.push(..._matches);
10138
10138
  }
10139
10139
  });
10140
- return tokens;
10140
+ return tokens2;
10141
10141
  }
10142
- stem(tokens, language) {
10142
+ stem(tokens2, language) {
10143
10143
  if (language !== "en") {
10144
- return tokens;
10144
+ return tokens2;
10145
10145
  }
10146
- return tokens.map((token) => {
10146
+ return tokens2.map((token) => {
10147
10147
  let stem = token;
10148
10148
  if (stem.endsWith("ing")) {
10149
10149
  stem = stem.slice(0, -3);
@@ -10239,9 +10239,9 @@ var init_NaturalLanguageProcessor = __esm({
10239
10239
  });
10240
10240
  return entities;
10241
10241
  }
10242
- extractKeywords(tokens, language) {
10242
+ extractKeywords(tokens2, language) {
10243
10243
  const stopWords = this.stopWords.get(language) ?? /* @__PURE__ */ new Set();
10244
- const _keywords = tokens.filter((token) => {
10244
+ const _keywords = tokens2.filter((token) => {
10245
10245
  return token.length > 2 && !stopWords.has(token.toLowerCase());
10246
10246
  });
10247
10247
  const frequency = /* @__PURE__ */ new Map();
@@ -19136,11 +19136,11 @@ var init_ConfigService = __esm({
19136
19136
  _saveDebounceTimer = null;
19137
19137
  _isDirty = false;
19138
19138
  constructor(configDir = process.env.MARIA_CONFIG_DIR || "~/.maria") {
19139
- this._configPath = path54__namespace.join(
19139
+ this._configPath = path55__namespace.join(
19140
19140
  this.expandHome(configDir),
19141
19141
  "session.config.json"
19142
19142
  );
19143
- this._userConfigPath = path54__namespace.join(
19143
+ this._userConfigPath = path55__namespace.join(
19144
19144
  this.expandHome(configDir),
19145
19145
  "user.config.json"
19146
19146
  );
@@ -19215,8 +19215,8 @@ var init_ConfigService = __esm({
19215
19215
  /**
19216
19216
  * ネストされた設定値の取得
19217
19217
  */
19218
- getNestedValue(path55) {
19219
- const keys = path55.split(".");
19218
+ getNestedValue(path56) {
19219
+ const keys = path56.split(".");
19220
19220
  let value = this._config;
19221
19221
  for (const key of keys) {
19222
19222
  if (value && typeof value === "object" && key in value) {
@@ -19246,8 +19246,8 @@ var init_ConfigService = __esm({
19246
19246
  /**
19247
19247
  * ネストされた設定値の更新
19248
19248
  */
19249
- async setNestedValue(path55, value) {
19250
- const keys = path55.split(".");
19249
+ async setNestedValue(path56, value) {
19250
+ const keys = path56.split(".");
19251
19251
  const lastKey = keys.pop();
19252
19252
  let target = this._config;
19253
19253
  for (const key of keys) {
@@ -19260,7 +19260,7 @@ var init_ConfigService = __esm({
19260
19260
  target[lastKey] = value;
19261
19261
  this.validateConfig();
19262
19262
  this.emitChange({
19263
- path: path55,
19263
+ path: path56,
19264
19264
  oldValue,
19265
19265
  newValue: value,
19266
19266
  timestamp: /* @__PURE__ */ new Date()
@@ -19274,7 +19274,7 @@ var init_ConfigService = __esm({
19274
19274
  async save() {
19275
19275
  if (!this._isDirty) return;
19276
19276
  try {
19277
- const configDir = path54__namespace.dirname(this._userConfigPath);
19277
+ const configDir = path55__namespace.dirname(this._userConfigPath);
19278
19278
  await fsp__namespace.mkdir(configDir, { recursive: true });
19279
19279
  await fsp__namespace.writeFile(
19280
19280
  this._userConfigPath,
@@ -19305,8 +19305,8 @@ var init_ConfigService = __esm({
19305
19305
  setupAutoSave() {
19306
19306
  process.on("exit", () => {
19307
19307
  if (this._isDirty) {
19308
- const fs45 = __require("fs");
19309
- fs45.writeFileSync(
19308
+ const fs46 = __require("fs");
19309
+ fs46.writeFileSync(
19310
19310
  this._userConfigPath,
19311
19311
  JSON.stringify(this._config, null, 2),
19312
19312
  "utf-8"
@@ -19317,13 +19317,13 @@ var init_ConfigService = __esm({
19317
19317
  /**
19318
19318
  * 変更リスナーの登録
19319
19319
  */
19320
- onChange(path55, listener) {
19321
- if (!this._listeners.has(path55)) {
19322
- this._listeners.set(path55, []);
19320
+ onChange(path56, listener) {
19321
+ if (!this._listeners.has(path56)) {
19322
+ this._listeners.set(path56, []);
19323
19323
  }
19324
- this._listeners.get(path55).push(listener);
19324
+ this._listeners.get(path56).push(listener);
19325
19325
  return () => {
19326
- const listeners = this._listeners.get(path55);
19326
+ const listeners = this._listeners.get(path56);
19327
19327
  if (listeners) {
19328
19328
  const index = listeners.indexOf(listener);
19329
19329
  if (index !== -1) {
@@ -19374,7 +19374,7 @@ var init_ConfigService = __esm({
19374
19374
  */
19375
19375
  expandHome(filePath) {
19376
19376
  if (filePath.startsWith("~/")) {
19377
- return path54__namespace.join(process.env.HOME || "", filePath.slice(2));
19377
+ return path55__namespace.join(process.env.HOME || "", filePath.slice(2));
19378
19378
  }
19379
19379
  return filePath;
19380
19380
  }
@@ -19812,7 +19812,7 @@ var init_ValidationService = __esm({
19812
19812
  );
19813
19813
  this._schemas.set(
19814
19814
  "filePath",
19815
- zod.z.string().min(1).max(this._config.maxFilePathLength).refine((path55) => !this.containsPathTraversal(path55), {
19815
+ zod.z.string().min(1).max(this._config.maxFilePathLength).refine((path56) => !this.containsPathTraversal(path56), {
19816
19816
  message: "Path traversal detected"
19817
19817
  })
19818
19818
  );
@@ -19951,11 +19951,11 @@ var init_ValidationService = __esm({
19951
19951
  /**
19952
19952
  * ファイルパス検証
19953
19953
  */
19954
- validateFilePath(path55) {
19954
+ validateFilePath(path56) {
19955
19955
  try {
19956
19956
  const schema = this._schemas.get("filePath");
19957
- const result = schema.parse(path55);
19958
- if (this.isSystemPath(path55)) {
19957
+ const result = schema.parse(path56);
19958
+ if (this.isSystemPath(path56)) {
19959
19959
  return {
19960
19960
  valid: false,
19961
19961
  errors: [
@@ -20101,8 +20101,8 @@ var init_ValidationService = __esm({
20101
20101
  /**
20102
20102
  * パストラバーサルの検出
20103
20103
  */
20104
- containsPathTraversal(path55) {
20105
- return /\.\.[/\\]/.test(path55) || path55.includes("..\\") || path55.includes("../");
20104
+ containsPathTraversal(path56) {
20105
+ return /\.\.[/\\]/.test(path56) || path56.includes("..\\") || path56.includes("../");
20106
20106
  }
20107
20107
  /**
20108
20108
  * 危険なコマンドの判定
@@ -20129,7 +20129,7 @@ var init_ValidationService = __esm({
20129
20129
  /**
20130
20130
  * システムパスの判定
20131
20131
  */
20132
- isSystemPath(path55) {
20132
+ isSystemPath(path56) {
20133
20133
  const systemPaths = [
20134
20134
  "/etc",
20135
20135
  "/sys",
@@ -20143,7 +20143,7 @@ var init_ValidationService = __esm({
20143
20143
  "/sbin"
20144
20144
  ];
20145
20145
  return systemPaths.some(
20146
- (sysPath) => path55.toLowerCase().startsWith(sysPath.toLowerCase())
20146
+ (sysPath) => path56.toLowerCase().startsWith(sysPath.toLowerCase())
20147
20147
  );
20148
20148
  }
20149
20149
  /**
@@ -25085,10 +25085,10 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
25085
25085
  const finalize = async (text, data) => {
25086
25086
  if (outputPath) {
25087
25087
  try {
25088
- const fs45 = await import('fs/promises');
25089
- const path55 = await import('path');
25090
- const abs = path55.resolve(outputPath);
25091
- await fs45.writeFile(abs, text, "utf-8");
25088
+ const fs46 = await import('fs/promises');
25089
+ const path56 = await import('path');
25090
+ const abs = path56.resolve(outputPath);
25091
+ await fs46.writeFile(abs, text, "utf-8");
25092
25092
  const msg = `Saved doctor report to ${abs}`;
25093
25093
  return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
25094
25094
  } catch (e2) {
@@ -25178,10 +25178,10 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
25178
25178
  const finalize = async (text, data) => {
25179
25179
  if (outputPath) {
25180
25180
  try {
25181
- const fs45 = await import('fs/promises');
25182
- const path55 = await import('path');
25183
- const abs = path55.resolve(outputPath);
25184
- await fs45.writeFile(abs, text, "utf-8");
25181
+ const fs46 = await import('fs/promises');
25182
+ const path56 = await import('path');
25183
+ const abs = path56.resolve(outputPath);
25184
+ await fs46.writeFile(abs, text, "utf-8");
25185
25185
  const msg = `Saved metrics to ${abs}`;
25186
25186
  return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
25187
25187
  } catch (e2) {
@@ -25564,15 +25564,15 @@ var init_SessionOrchestrator = __esm({
25564
25564
  /**
25565
25565
  * 設定の取得
25566
25566
  */
25567
- getConfig(path55) {
25568
- return this._configService?.getNestedValue(path55);
25567
+ getConfig(path56) {
25568
+ return this._configService?.getNestedValue(path56);
25569
25569
  }
25570
25570
  /**
25571
25571
  * 設定の更新
25572
25572
  */
25573
- async setConfig(path55, value) {
25573
+ async setConfig(path56, value) {
25574
25574
  if (this._configService) {
25575
- await this._configService.setNestedValue(path55, value);
25575
+ await this._configService.setNestedValue(path56, value);
25576
25576
  }
25577
25577
  }
25578
25578
  /**
@@ -25690,11 +25690,11 @@ var init_interactive_session = __esm({
25690
25690
  getStats() {
25691
25691
  return this.orchestrator.getSessionStats();
25692
25692
  }
25693
- getConfig(path55) {
25694
- return this.orchestrator.getConfig(path55);
25693
+ getConfig(path56) {
25694
+ return this.orchestrator.getConfig(path56);
25695
25695
  }
25696
- async setConfig(path55, value) {
25697
- await this.orchestrator.setConfig(path55, value);
25696
+ async setConfig(path56, value) {
25697
+ await this.orchestrator.setConfig(path56, value);
25698
25698
  }
25699
25699
  };
25700
25700
  }
@@ -25705,8 +25705,8 @@ var require_package = __commonJS({
25705
25705
  "package.json"(exports, module) {
25706
25706
  module.exports = {
25707
25707
  name: "@bonginkan/maria",
25708
- version: "4.3.9",
25709
- description: "\u{1F680} MARIA v4.3.9 - Enterprise AI Development Platform with 100% Command Availability. 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.",
25708
+ version: "4.3.10",
25709
+ description: "\u{1F680} MARIA v4.3.10 - Enterprise AI Development Platform with 100% Command Availability. 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.",
25710
25710
  keywords: [
25711
25711
  "ai",
25712
25712
  "cli",
@@ -26222,27 +26222,30 @@ var require_package = __commonJS({
26222
26222
  }
26223
26223
  });
26224
26224
  function loadEnvironmentVariables() {
26225
- const _envPath = path54__namespace.join(process.cwd(), ".env");
26225
+ const _envPath = path55__namespace.join(process.cwd(), ".env");
26226
26226
  if (fs22__namespace.existsSync(_envPath)) {
26227
26227
  const _result = dotenv__namespace.config({ path: _envPath });
26228
26228
  if (_result.error) {
26229
26229
  console.warn("Error loading .env:", _result.error);
26230
26230
  }
26231
26231
  }
26232
- const _envLocalPath = path54__namespace.join(process.cwd(), ".env.local");
26232
+ const _envLocalPath = path55__namespace.join(process.cwd(), ".env.local");
26233
26233
  if (fs22__namespace.existsSync(_envLocalPath)) {
26234
26234
  const _result = dotenv__namespace.config({ path: _envLocalPath, override: true });
26235
26235
  if (_result.error) {
26236
26236
  console.warn("Error loading .env.local:", _result.error);
26237
26237
  }
26238
26238
  }
26239
- const _lmstudioEnvPath = path54__namespace.join(process.cwd(), ".env.lmstudio");
26239
+ const _lmstudioEnvPath = path55__namespace.join(process.cwd(), ".env.lmstudio");
26240
26240
  if (fs22__namespace.existsSync(_lmstudioEnvPath)) {
26241
26241
  const _result = dotenv__namespace.config({ path: _lmstudioEnvPath, override: false });
26242
26242
  if (_result.error) {
26243
26243
  console.warn("Error loading .env.lmstudio:", _result.error);
26244
26244
  }
26245
26245
  }
26246
+ if (!process.env.MARIA_API_BASE) process.env.MARIA_API_BASE = "https://api.maria-code.ai";
26247
+ if (!process.env.MARIA_USE_API) process.env.MARIA_USE_API = "1";
26248
+ if (!process.env.MARIA_USE_REMOTE_MEDIA) process.env.MARIA_USE_REMOTE_MEDIA = "1";
26246
26249
  }
26247
26250
  var init_env_loader = __esm({
26248
26251
  "src/utils/env-loader.ts"() {
@@ -26561,11 +26564,11 @@ var init_OAuth2PKCEClient = __esm({
26561
26564
  redirectUri: config2.redirectUri || "http://127.0.0.1:9876/callback",
26562
26565
  authServerUrl: config2.authServerUrl || "https://maria-code.ai"
26563
26566
  };
26564
- const configDir = path54__namespace.join(os16__namespace.homedir(), ".maria");
26567
+ const configDir = path55__namespace.join(os16__namespace.homedir(), ".maria");
26565
26568
  if (!fs22__namespace.existsSync(configDir)) {
26566
26569
  fs22__namespace.mkdirSync(configDir, { recursive: true });
26567
26570
  }
26568
- this.tokenStoragePath = path54__namespace.join(configDir, "auth-tokens.json");
26571
+ this.tokenStoragePath = path55__namespace.join(configDir, "auth-tokens.json");
26569
26572
  }
26570
26573
  /**
26571
26574
  * Generate cryptographically secure random string
@@ -26744,13 +26747,13 @@ var init_OAuth2PKCEClient = __esm({
26744
26747
  /**
26745
26748
  * Store tokens securely
26746
26749
  */
26747
- async storeTokens(tokens) {
26750
+ async storeTokens(tokens2) {
26748
26751
  const storedTokens = {
26749
- accessToken: tokens.access_token,
26750
- refreshToken: tokens.refresh_token,
26751
- idToken: tokens.id_token,
26752
- expiresAt: Date.now() + tokens.expires_in * 1e3,
26753
- scopes: tokens.scope?.split(" ") || this.config.scopes,
26752
+ accessToken: tokens2.access_token,
26753
+ refreshToken: tokens2.refresh_token,
26754
+ idToken: tokens2.id_token,
26755
+ expiresAt: Date.now() + tokens2.expires_in * 1e3,
26756
+ scopes: tokens2.scope?.split(" ") || this.config.scopes,
26754
26757
  obtainedAt: Date.now()
26755
26758
  };
26756
26759
  fs22__namespace.writeFileSync(
@@ -26769,16 +26772,16 @@ var init_OAuth2PKCEClient = __esm({
26769
26772
  }
26770
26773
  try {
26771
26774
  const data = fs22__namespace.readFileSync(this.tokenStoragePath, "utf-8");
26772
- const tokens = JSON.parse(data);
26773
- if (Date.now() >= tokens.expiresAt) {
26774
- if (tokens.refreshToken) {
26775
- const newTokens = await this.refreshAccessToken(tokens.refreshToken);
26775
+ const tokens2 = JSON.parse(data);
26776
+ if (Date.now() >= tokens2.expiresAt) {
26777
+ if (tokens2.refreshToken) {
26778
+ const newTokens = await this.refreshAccessToken(tokens2.refreshToken);
26776
26779
  await this.storeTokens(newTokens);
26777
26780
  return this.loadStoredTokens();
26778
26781
  }
26779
26782
  return null;
26780
26783
  }
26781
- return tokens;
26784
+ return tokens2;
26782
26785
  } catch (error2) {
26783
26786
  console.error("Failed to load stored tokens:", error2);
26784
26787
  return null;
@@ -26831,8 +26834,8 @@ ${authUrl}
26831
26834
  const code = await codePromise;
26832
26835
  console.log("\u2705 Authorization code received");
26833
26836
  console.log("\u{1F504} Exchanging code for tokens...");
26834
- const tokens = await this.exchangeCodeForTokens(code);
26835
- await this.storeTokens(tokens);
26837
+ const tokens2 = await this.exchangeCodeForTokens(code);
26838
+ await this.storeTokens(tokens2);
26836
26839
  console.log("\u2705 Authentication complete! Tokens stored securely.");
26837
26840
  return this.loadStoredTokens();
26838
26841
  } finally {
@@ -26852,15 +26855,15 @@ ${authUrl}
26852
26855
  * Get current access token
26853
26856
  */
26854
26857
  async getAccessToken() {
26855
- const tokens = await this.loadStoredTokens();
26856
- return tokens?.accessToken || null;
26858
+ const tokens2 = await this.loadStoredTokens();
26859
+ return tokens2?.accessToken || null;
26857
26860
  }
26858
26861
  /**
26859
26862
  * Check if authenticated
26860
26863
  */
26861
26864
  async isAuthenticated() {
26862
- const tokens = await this.loadStoredTokens();
26863
- return tokens !== null;
26865
+ const tokens2 = await this.loadStoredTokens();
26866
+ return tokens2 !== null;
26864
26867
  }
26865
26868
  };
26866
26869
  }
@@ -26911,10 +26914,10 @@ var init_MariaAPIClient = __esm({
26911
26914
  const responseData = await response.json();
26912
26915
  if (!response.ok) {
26913
26916
  if (response.status === 401) {
26914
- const tokens = await this.authClient.loadStoredTokens();
26915
- if (tokens?.refreshToken) {
26917
+ const tokens2 = await this.authClient.loadStoredTokens();
26918
+ if (tokens2?.refreshToken) {
26916
26919
  try {
26917
- await this.authClient.refreshAccessToken(tokens.refreshToken);
26920
+ await this.authClient.refreshAccessToken(tokens2.refreshToken);
26918
26921
  continue;
26919
26922
  } catch {
26920
26923
  throw new Error("Session expired. Please login again.");
@@ -27143,11 +27146,11 @@ var init_CLIAuthService = __esm({
27143
27146
  configPath;
27144
27147
  config;
27145
27148
  constructor(config2) {
27146
- const configDir = path54__namespace.join(os16__namespace.homedir(), ".maria");
27149
+ const configDir = path55__namespace.join(os16__namespace.homedir(), ".maria");
27147
27150
  if (!fs22__namespace.existsSync(configDir)) {
27148
27151
  fs22__namespace.mkdirSync(configDir, { recursive: true });
27149
27152
  }
27150
- this.configPath = path54__namespace.join(configDir, "cli-config.json");
27153
+ this.configPath = path55__namespace.join(configDir, "cli-config.json");
27151
27154
  this.config = this.loadConfig(config2);
27152
27155
  this.authClient = new OAuth2PKCEClient({
27153
27156
  authorizationEndpoint: `${this.config.authServerUrl}/oauth/authorize`,
@@ -27250,7 +27253,7 @@ var init_CLIAuthService = __esm({
27250
27253
  }
27251
27254
  console.log("\u{1F4F1} Starting authentication flow...");
27252
27255
  console.log("A browser window will open for you to authenticate.\n");
27253
- const tokens = await this.authClient.authenticate();
27256
+ const tokens2 = await this.authClient.authenticate();
27254
27257
  this.config.lastLogin = (/* @__PURE__ */ new Date()).toISOString();
27255
27258
  this.saveConfig();
27256
27259
  console.log("\n\u2705 Authentication successful!");
@@ -27469,13 +27472,13 @@ var init_TokenStorage = __esm({
27469
27472
  TokenStorage = class {
27470
27473
  SERVICE_NAME = "maria-cli";
27471
27474
  ACCOUNT_NAME = "default";
27472
- CONFIG_DIR = path54__namespace.default.join(os16__namespace.default.homedir(), ".maria");
27473
- TOKEN_FILE = path54__namespace.default.join(this.CONFIG_DIR, "auth-tokens.json");
27475
+ CONFIG_DIR = path55__namespace.default.join(os16__namespace.default.homedir(), ".maria");
27476
+ TOKEN_FILE = path55__namespace.default.join(this.CONFIG_DIR, "auth-tokens.json");
27474
27477
  /**
27475
27478
  * Save tokens securely
27476
27479
  */
27477
- async save(tokens) {
27478
- const tokenData = JSON.stringify(tokens);
27480
+ async save(tokens2) {
27481
+ const tokenData = JSON.stringify(tokens2);
27479
27482
  if (keytar) {
27480
27483
  try {
27481
27484
  await keytar.setPassword(this.SERVICE_NAME, this.ACCOUNT_NAME, tokenData);
@@ -27484,7 +27487,7 @@ var init_TokenStorage = __esm({
27484
27487
  console.warn("Keychain storage failed, falling back to encrypted file");
27485
27488
  }
27486
27489
  }
27487
- await this.saveToFile(tokens);
27490
+ await this.saveToFile(tokens2);
27488
27491
  }
27489
27492
  /**
27490
27493
  * Load tokens securely
@@ -27520,12 +27523,12 @@ var init_TokenStorage = __esm({
27520
27523
  /**
27521
27524
  * Save tokens to encrypted file
27522
27525
  */
27523
- async saveToFile(tokens) {
27526
+ async saveToFile(tokens2) {
27524
27527
  await fsp__namespace.default.mkdir(this.CONFIG_DIR, { recursive: true });
27525
27528
  const key = await this.getEncryptionKey();
27526
27529
  const iv = crypto6__namespace.default.randomBytes(16);
27527
27530
  const cipher = crypto6__namespace.default.createCipheriv("aes-256-gcm", key, iv);
27528
- const tokenData = JSON.stringify(tokens);
27531
+ const tokenData = JSON.stringify(tokens2);
27529
27532
  let encrypted = cipher.update(tokenData, "utf8", "hex");
27530
27533
  encrypted += cipher.final("hex");
27531
27534
  const authTag = cipher.getAuthTag();
@@ -27585,9 +27588,9 @@ var init_TokenStorage = __esm({
27585
27588
  const decipher = crypto6__namespace.default.createDecipheriv("aes-256-cbc", keyBuffer, Buffer.alloc(16, 0));
27586
27589
  let decrypted = decipher.update(fileData.data, "hex", "utf8");
27587
27590
  decrypted += decipher.final("utf8");
27588
- const tokens = JSON.parse(decrypted);
27589
- await this.saveToFile(tokens);
27590
- return tokens;
27591
+ const tokens2 = JSON.parse(decrypted);
27592
+ await this.saveToFile(tokens2);
27593
+ return tokens2;
27591
27594
  } catch {
27592
27595
  return null;
27593
27596
  }
@@ -27887,9 +27890,9 @@ var init_AuthenticationManager = __esm({
27887
27890
  async isAuthenticated() {
27888
27891
  await this.ensureInitialized();
27889
27892
  try {
27890
- const tokens = await this.tokenStorage.load();
27891
- if (!tokens) return false;
27892
- if (Date.now() >= tokens.expiresAt + this.CLOCK_SKEW) {
27893
+ const tokens2 = await this.tokenStorage.load();
27894
+ if (!tokens2) return false;
27895
+ if (Date.now() >= tokens2.expiresAt + this.CLOCK_SKEW) {
27893
27896
  return await this.refreshToken();
27894
27897
  }
27895
27898
  return true;
@@ -27914,8 +27917,8 @@ var init_AuthenticationManager = __esm({
27914
27917
  async getCurrentUser() {
27915
27918
  await this.ensureInitialized();
27916
27919
  if (process.env.MARIA_AUTH_MODE === "local") {
27917
- const tokens2 = await this.tokenStorage.load();
27918
- if (!tokens2) {
27920
+ const tokens3 = await this.tokenStorage.load();
27921
+ if (!tokens3) {
27919
27922
  throw new AuthenticationRequiredError(ERROR_MESSAGES.AUTH_REQUIRED);
27920
27923
  }
27921
27924
  return {
@@ -27932,15 +27935,15 @@ var init_AuthenticationManager = __esm({
27932
27935
  models: []
27933
27936
  };
27934
27937
  }
27935
- const tokens = await this.getValidTokens();
27936
- if (!tokens) {
27938
+ const tokens2 = await this.getValidTokens();
27939
+ if (!tokens2) {
27937
27940
  throw new AuthenticationRequiredError(ERROR_MESSAGES.AUTH_REQUIRED);
27938
27941
  }
27939
27942
  try {
27940
27943
  const response = await fetch(`${this.apiBase}/api/user/profile`, {
27941
27944
  headers: {
27942
- "Authorization": `Bearer ${tokens.accessToken}`,
27943
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.9"}`
27945
+ "Authorization": `Bearer ${tokens2.accessToken}`,
27946
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.10"}`
27944
27947
  }
27945
27948
  });
27946
27949
  if (response.status === 401) {
@@ -27975,16 +27978,16 @@ var init_AuthenticationManager = __esm({
27975
27978
  if (process.env.MARIA_AUTH_MODE === "local") {
27976
27979
  return await this.loginWithLocalMock();
27977
27980
  }
27978
- let tokens;
27981
+ let tokens2;
27979
27982
  const forceDevice = options.device || process.env.MARIA_AUTH_DEVICE_FLOW === "true" || !this.canLaunchBrowser();
27980
27983
  if (forceDevice) {
27981
27984
  if (!options.device) {
27982
27985
  console.warn("PKCE is unavailable in this environment; using device flow.");
27983
27986
  }
27984
- tokens = await this.loginWithDeviceFlow();
27987
+ tokens2 = await this.loginWithDeviceFlow();
27985
27988
  } else {
27986
27989
  try {
27987
- tokens = await this.loginWithPKCEFlow();
27990
+ tokens2 = await this.loginWithPKCEFlow();
27988
27991
  } catch (error2) {
27989
27992
  console.error("PKCE flow error:", error2);
27990
27993
  if (error2.message?.includes("ECONNREFUSED") || error2.message?.includes("fetch failed")) {
@@ -28001,12 +28004,12 @@ var init_AuthenticationManager = __esm({
28001
28004
  throw new Error("Authentication service unavailable. See above for alternatives.");
28002
28005
  }
28003
28006
  console.warn("PKCE flow failed, falling back to device flow");
28004
- tokens = await this.loginWithDeviceFlow();
28007
+ tokens2 = await this.loginWithDeviceFlow();
28005
28008
  }
28006
28009
  }
28007
- await this.tokenStorage.save(tokens);
28010
+ await this.tokenStorage.save(tokens2);
28008
28011
  const user = await this.getCurrentUser();
28009
- return { success: true, user, tokens };
28012
+ return { success: true, user, tokens: tokens2 };
28010
28013
  } catch (error2) {
28011
28014
  console.error("Login failed:", error2);
28012
28015
  return {
@@ -28056,10 +28059,10 @@ var init_AuthenticationManager = __esm({
28056
28059
  async logout(options = {}) {
28057
28060
  await this.ensureInitialized();
28058
28061
  try {
28059
- const tokens = await this.tokenStorage.load();
28060
- if (tokens && !options.force) {
28062
+ const tokens2 = await this.tokenStorage.load();
28063
+ if (tokens2 && !options.force) {
28061
28064
  try {
28062
- await this.revokeTokens(tokens, options.all || false);
28065
+ await this.revokeTokens(tokens2, options.all || false);
28063
28066
  } catch (error2) {
28064
28067
  console.warn("Server token revocation failed:", error2);
28065
28068
  }
@@ -28078,14 +28081,14 @@ var init_AuthenticationManager = __esm({
28078
28081
  async refreshToken() {
28079
28082
  await this.ensureInitialized();
28080
28083
  try {
28081
- const tokens = await this.tokenStorage.load();
28082
- if (!tokens?.refreshToken) return false;
28084
+ const tokens2 = await this.tokenStorage.load();
28085
+ if (!tokens2?.refreshToken) return false;
28083
28086
  const response = await fetch(`${this.authBase}/auth/token`, {
28084
28087
  method: "POST",
28085
28088
  headers: { "Content-Type": "application/json" },
28086
28089
  body: JSON.stringify({
28087
28090
  grant_type: "refresh_token",
28088
- refresh_token: tokens.refreshToken,
28091
+ refresh_token: tokens2.refreshToken,
28089
28092
  client_id: this.clientId
28090
28093
  })
28091
28094
  });
@@ -28094,7 +28097,7 @@ var init_AuthenticationManager = __esm({
28094
28097
  const updatedTokens = {
28095
28098
  idToken: newTokens.id_token,
28096
28099
  accessToken: newTokens.access_token,
28097
- refreshToken: newTokens.refresh_token || tokens.refreshToken,
28100
+ refreshToken: newTokens.refresh_token || tokens2.refreshToken,
28098
28101
  customToken: newTokens.custom_token,
28099
28102
  expiresAt: Date.now() + newTokens.expires_in * 1e3
28100
28103
  };
@@ -28209,13 +28212,13 @@ var init_AuthenticationManager = __esm({
28209
28212
  if (!finishResponse.ok) {
28210
28213
  throw new Error(`Device flow failed: ${finishResponse.statusText}`);
28211
28214
  }
28212
- const tokens = await finishResponse.json();
28215
+ const tokens2 = await finishResponse.json();
28213
28216
  return {
28214
- idToken: tokens.id_token || tokens.access_token || "",
28215
- accessToken: tokens.access_token || tokens.id_token || "",
28216
- refreshToken: tokens.refresh_token || "",
28217
- customToken: tokens.custom_token,
28218
- expiresAt: Date.now() + (tokens.expires_in ? Number(tokens.expires_in) : 600) * 1e3
28217
+ idToken: tokens2.id_token || tokens2.access_token || "",
28218
+ accessToken: tokens2.access_token || tokens2.id_token || "",
28219
+ refreshToken: tokens2.refresh_token || "",
28220
+ customToken: tokens2.custom_token,
28221
+ expiresAt: Date.now() + (tokens2.expires_in ? Number(tokens2.expires_in) : 600) * 1e3
28219
28222
  };
28220
28223
  }
28221
28224
  throw new Error(ERROR_MESSAGES.LOGIN_TIMEOUT);
@@ -28356,13 +28359,13 @@ var init_AuthenticationManager = __esm({
28356
28359
  console.error("Token exchange failed:", response.status, response.statusText, bodyText);
28357
28360
  throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
28358
28361
  }
28359
- const tokens = await response.json();
28362
+ const tokens2 = await response.json();
28360
28363
  return {
28361
- idToken: tokens.id_token,
28362
- accessToken: tokens.access_token,
28363
- refreshToken: tokens.refresh_token,
28364
- customToken: tokens.custom_token,
28365
- expiresAt: Date.now() + tokens.expires_in * 1e3
28364
+ idToken: tokens2.id_token,
28365
+ accessToken: tokens2.access_token,
28366
+ refreshToken: tokens2.refresh_token,
28367
+ customToken: tokens2.custom_token,
28368
+ expiresAt: Date.now() + tokens2.expires_in * 1e3
28366
28369
  };
28367
28370
  } catch (error2) {
28368
28371
  console.error("Token exchange request error:", error2);
@@ -28372,15 +28375,15 @@ var init_AuthenticationManager = __esm({
28372
28375
  /**
28373
28376
  * Revoke tokens on server
28374
28377
  */
28375
- async revokeTokens(tokens, allDevices) {
28378
+ async revokeTokens(tokens2, allDevices) {
28376
28379
  const response = await fetch(`${this.apiBase}/api/auth/revoke`, {
28377
28380
  method: "POST",
28378
28381
  headers: {
28379
28382
  "Content-Type": "application/json",
28380
- "Authorization": `Bearer ${tokens.accessToken}`
28383
+ "Authorization": `Bearer ${tokens2.accessToken}`
28381
28384
  },
28382
28385
  body: JSON.stringify({
28383
- refresh_token: tokens.refreshToken,
28386
+ refresh_token: tokens2.refreshToken,
28384
28387
  all_devices: allDevices
28385
28388
  })
28386
28389
  });
@@ -28392,17 +28395,17 @@ var init_AuthenticationManager = __esm({
28392
28395
  * Get valid tokens (refresh if needed)
28393
28396
  */
28394
28397
  async getValidTokens() {
28395
- const tokens = await this.tokenStorage.load();
28396
- if (!tokens) return null;
28398
+ const tokens2 = await this.tokenStorage.load();
28399
+ if (!tokens2) return null;
28397
28400
  const now2 = Date.now();
28398
- const expiresWithBuffer = tokens.expiresAt - this.REFRESH_THRESHOLD + this.CLOCK_SKEW;
28401
+ const expiresWithBuffer = tokens2.expiresAt - this.REFRESH_THRESHOLD + this.CLOCK_SKEW;
28399
28402
  if (now2 >= expiresWithBuffer) {
28400
28403
  if (await this.refreshToken()) {
28401
28404
  return await this.tokenStorage.load();
28402
28405
  }
28403
28406
  return null;
28404
28407
  }
28405
- return tokens;
28408
+ return tokens2;
28406
28409
  }
28407
28410
  /**
28408
28411
  * Secure string comparison
@@ -28481,15 +28484,15 @@ function withAuth(fn) {
28481
28484
  return async (...args2) => {
28482
28485
  const testMode = process.env.MARIA_TEST_MODE === "1" || process.env.VITEST === "true" || process.env.NODE_ENV === "test";
28483
28486
  try {
28484
- const tokens = await authManager.getValidTokens();
28485
- if (!tokens) {
28487
+ const tokens2 = await authManager.getValidTokens();
28488
+ if (!tokens2) {
28486
28489
  console.log(chalk36__default.default.red("\u{1F510} Authentication required \xB7 Run: maria /login"));
28487
28490
  if (!testMode) process.exit(AUTH_EXIT_CODES.AUTH_REQUIRED);
28488
28491
  return { success: false, message: "AUTH_REQUIRED" };
28489
28492
  }
28490
- global.MARIA_ID_TOKEN = tokens.idToken;
28491
- global.MARIA_ACCESS_TOKEN = tokens.accessToken;
28492
- global.MARIA_SESSION_ID = tokens.sessionId;
28493
+ global.MARIA_ID_TOKEN = tokens2.idToken;
28494
+ global.MARIA_ACCESS_TOKEN = tokens2.accessToken;
28495
+ global.MARIA_SESSION_ID = tokens2.sessionId;
28493
28496
  return await fn(...args2);
28494
28497
  } catch (error2) {
28495
28498
  if (error2.code === "AUTH_REQUIRED") {
@@ -28559,11 +28562,11 @@ function getDeviceId() {
28559
28562
  function getSessionId() {
28560
28563
  return global.MARIA_SESSION_ID;
28561
28564
  }
28562
- async function callApi(path55, init2 = {}) {
28565
+ async function callApi(path56, init2 = {}) {
28563
28566
  const apiBase = process.env.MARIA_API_BASE || "http://localhost:3001";
28564
- const fullUrl = `${apiBase}${path55}`;
28565
- let tokens = await authManager.getValidTokens();
28566
- if (!tokens) {
28567
+ const fullUrl = `${apiBase}${path56}`;
28568
+ let tokens2 = await authManager.getValidTokens();
28569
+ if (!tokens2) {
28567
28570
  console.log(chalk36__default.default.red(ERR.AUTH_REQUIRED.msg));
28568
28571
  process.exit(ERR.AUTH_REQUIRED.code);
28569
28572
  }
@@ -28572,7 +28575,7 @@ async function callApi(path55, init2 = {}) {
28572
28575
  "Authorization": `Bearer ${token}`,
28573
28576
  "X-Device-Id": getDeviceId(),
28574
28577
  "X-Session-Id": getSessionId() || "",
28575
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.9"}`,
28578
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.10"}`,
28576
28579
  "Content-Type": init2.headers?.["Content-Type"] || "application/json"
28577
28580
  });
28578
28581
  const doFetch = async (token) => {
@@ -28589,7 +28592,7 @@ async function callApi(path55, init2 = {}) {
28589
28592
  throw error2;
28590
28593
  }
28591
28594
  };
28592
- let response = await doFetch(tokens.accessToken);
28595
+ let response = await doFetch(tokens2.accessToken);
28593
28596
  if (response.status === 401) {
28594
28597
  console.log(chalk36__default.default.gray("Token expired, refreshing..."));
28595
28598
  const refreshed = await authManager.refreshToken();
@@ -28597,12 +28600,12 @@ async function callApi(path55, init2 = {}) {
28597
28600
  console.log(chalk36__default.default.red(ERR.REAUTH_REQUIRED.msg));
28598
28601
  process.exit(ERR.REAUTH_REQUIRED.code);
28599
28602
  }
28600
- tokens = await authManager.getValidTokens();
28601
- if (!tokens) {
28603
+ tokens2 = await authManager.getValidTokens();
28604
+ if (!tokens2) {
28602
28605
  console.log(chalk36__default.default.red(ERR.REAUTH_REQUIRED.msg));
28603
28606
  process.exit(ERR.REAUTH_REQUIRED.code);
28604
28607
  }
28605
- response = await doFetch(tokens.accessToken);
28608
+ response = await doFetch(tokens2.accessToken);
28606
28609
  if (response.status === 401) {
28607
28610
  console.log(chalk36__default.default.red(ERR.REAUTH_REQUIRED.msg));
28608
28611
  process.exit(ERR.REAUTH_REQUIRED.code);
@@ -28615,7 +28618,7 @@ async function callApi(path55, init2 = {}) {
28615
28618
  const waitTime = Math.min(retryAfter, 60);
28616
28619
  console.log(chalk36__default.default.yellow(`\u23F1\uFE0F Rate limit: wait ${waitTime}s`));
28617
28620
  await new Promise((resolve17) => setTimeout(resolve17, waitTime * 1e3));
28618
- response = await doFetch(tokens.accessToken);
28621
+ response = await doFetch(tokens2.accessToken);
28619
28622
  }
28620
28623
  if (response.status === 402) {
28621
28624
  console.log(chalk36__default.default.yellow(ERR.QUOTA.msg));
@@ -28630,8 +28633,8 @@ async function callApi(path55, init2 = {}) {
28630
28633
  }
28631
28634
  return response;
28632
28635
  }
28633
- async function callApiJson(path55, init2 = {}) {
28634
- const response = await callApi(path55, init2);
28636
+ async function callApiJson(path56, init2 = {}) {
28637
+ const response = await callApi(path56, init2);
28635
28638
  if (!response.ok) {
28636
28639
  const error2 = await response.json().catch(() => ({
28637
28640
  message: `API error: ${response.status} ${response.statusText}`
@@ -28692,7 +28695,7 @@ var init_chat_context_service = __esm({
28692
28695
  // 400K session window
28693
28696
  compressionThreshold: config2?.compressionThreshold || 0.8,
28694
28697
  summaryTokenLimit: config2?.summaryTokenLimit || 2e3,
28695
- persistPath: config2?.persistPath || path54__namespace.join(process.env["HOME"] || "", ".maria", "context")
28698
+ persistPath: config2?.persistPath || path55__namespace.join(process.env["HOME"] || "", ".maria", "context")
28696
28699
  };
28697
28700
  this.sessionId = this.generateSessionId();
28698
28701
  }
@@ -28713,16 +28716,16 @@ var init_chat_context_service = __esm({
28713
28716
  }
28714
28717
  }
28715
28718
  async addMessage(message) {
28716
- const tokens = this.countTokens(message.content);
28719
+ const tokens2 = this.countTokens(message.content);
28717
28720
  const fullMessage = {
28718
28721
  ...message,
28719
28722
  timestamp: /* @__PURE__ */ new Date(),
28720
- tokens
28723
+ tokens: tokens2
28721
28724
  };
28722
28725
  this.fullHistory.push(fullMessage);
28723
28726
  this.contextWindow.push(fullMessage);
28724
- this.currentTokens += tokens;
28725
- this.sessionTokens += tokens;
28727
+ this.currentTokens += tokens2;
28728
+ this.sessionTokens += tokens2;
28726
28729
  await this.optimizeMemory();
28727
28730
  this.emit("message-added", fullMessage);
28728
28731
  this.emit("context-updated", this.getStats());
@@ -28816,7 +28819,7 @@ var init_chat_context_service = __esm({
28816
28819
  if (!this.config.persistPath) return;
28817
28820
  try {
28818
28821
  await fsp__namespace.mkdir(this.config.persistPath, { recursive: true });
28819
- const sessionFile = path54__namespace.join(
28822
+ const sessionFile = path55__namespace.join(
28820
28823
  this.config.persistPath,
28821
28824
  `${this.sessionId}.json`
28822
28825
  );
@@ -28887,8 +28890,8 @@ var init_conversation_persistence = __esm({
28887
28890
  autoSaveInterval = null;
28888
28891
  pendingWrites = [];
28889
28892
  constructor(maxHistorySize = 100) {
28890
- const configDir = path54__namespace.join(os16__namespace.homedir(), ".maria");
28891
- this.sessionFile = path54__namespace.join(configDir, "conversation-history.json");
28893
+ const configDir = path55__namespace.join(os16__namespace.homedir(), ".maria");
28894
+ this.sessionFile = path55__namespace.join(configDir, "conversation-history.json");
28892
28895
  this.maxHistorySize = maxHistorySize;
28893
28896
  this.ensureConfigDir();
28894
28897
  this.startAutoSave();
@@ -28898,7 +28901,7 @@ var init_conversation_persistence = __esm({
28898
28901
  */
28899
28902
  async ensureConfigDir() {
28900
28903
  try {
28901
- const configDir = path54__namespace.dirname(this.sessionFile);
28904
+ const configDir = path55__namespace.dirname(this.sessionFile);
28902
28905
  await fs22.promises.mkdir(configDir, { recursive: true });
28903
28906
  } catch (error2) {
28904
28907
  console.warn("Failed to create config directory:", error2);
@@ -30427,8 +30430,8 @@ __export(api_caller_exports, {
30427
30430
  executeCode: () => executeCode
30428
30431
  });
30429
30432
  async function callAPI(endpoint, options = {}) {
30430
- const tokens = await authManager2.getValidTokens();
30431
- if (!tokens) {
30433
+ const tokens2 = await authManager2.getValidTokens();
30434
+ if (!tokens2) {
30432
30435
  throw new Error("Authentication required. Please run /login first.");
30433
30436
  }
30434
30437
  const apiBase = process.env.MARIA_API_BASE || "https://api.maria-code.ai";
@@ -30443,7 +30446,7 @@ async function callAPI(endpoint, options = {}) {
30443
30446
  const response = await fetch(url2, {
30444
30447
  method: options.method || "GET",
30445
30448
  headers: {
30446
- "Authorization": `Bearer ${tokens.accessToken}`,
30449
+ "Authorization": `Bearer ${tokens2.accessToken}`,
30447
30450
  "Content-Type": "application/json",
30448
30451
  ...options.headers
30449
30452
  },
@@ -31284,14 +31287,14 @@ var init_ReadyCommandsService = __esm({
31284
31287
  } else {
31285
31288
  const possiblePaths = [
31286
31289
  // For bundled dist version
31287
- path54__namespace.join(__dirname, "READY.manifest.json"),
31288
- path54__namespace.join(__dirname, "../READY.manifest.json"),
31289
- path54__namespace.join(process.cwd(), "dist/READY.manifest.json"),
31290
+ path55__namespace.join(__dirname, "READY.manifest.json"),
31291
+ path55__namespace.join(__dirname, "../READY.manifest.json"),
31292
+ path55__namespace.join(process.cwd(), "dist/READY.manifest.json"),
31290
31293
  // For development/source version
31291
- path54__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
31292
- path54__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
31293
- path54__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
31294
- path54__namespace.join(process.cwd(), "READY.manifest.json")
31294
+ path55__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
31295
+ path55__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
31296
+ path55__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
31297
+ path55__namespace.join(process.cwd(), "READY.manifest.json")
31295
31298
  ];
31296
31299
  this.manifestPath = possiblePaths[0];
31297
31300
  }
@@ -31302,17 +31305,17 @@ var init_ReadyCommandsService = __esm({
31302
31305
  async findManifestPath() {
31303
31306
  const possiblePaths = [
31304
31307
  // For bundled dist version
31305
- path54__namespace.join(__dirname, "READY.manifest.json"),
31306
- path54__namespace.join(__dirname, "../READY.manifest.json"),
31307
- path54__namespace.join(process.cwd(), "dist/READY.manifest.json"),
31308
+ path55__namespace.join(__dirname, "READY.manifest.json"),
31309
+ path55__namespace.join(__dirname, "../READY.manifest.json"),
31310
+ path55__namespace.join(process.cwd(), "dist/READY.manifest.json"),
31308
31311
  // For development/source version
31309
- path54__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
31310
- path54__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
31311
- path54__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
31312
- path54__namespace.join(process.cwd(), "READY.manifest.json"),
31312
+ path55__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
31313
+ path55__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
31314
+ path55__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
31315
+ path55__namespace.join(process.cwd(), "READY.manifest.json"),
31313
31316
  // Additional paths for different build scenarios
31314
- path54__namespace.resolve(__dirname, "../../../src/slash-commands/READY.manifest.json"),
31315
- path54__namespace.resolve(process.cwd(), "src/slash-commands/READY.manifest.json")
31317
+ path55__namespace.resolve(__dirname, "../../../src/slash-commands/READY.manifest.json"),
31318
+ path55__namespace.resolve(process.cwd(), "src/slash-commands/READY.manifest.json")
31316
31319
  ];
31317
31320
  for (const testPath of possiblePaths) {
31318
31321
  try {
@@ -31874,7 +31877,7 @@ async function loadFirebaseAdmin() {
31874
31877
  try {
31875
31878
  const firebaseAdminModule = await import('firebase-admin/app');
31876
31879
  const firestoreModule = await import('firebase-admin/firestore');
31877
- const keyPath = path54__namespace.join(process.cwd(), "config", "maria-cli-firestore-key.json");
31880
+ const keyPath = path55__namespace.join(process.cwd(), "config", "maria-cli-firestore-key.json");
31878
31881
  if (!adminApp && firebaseAdminModule.getApps().length === 0) {
31879
31882
  adminApp = firebaseAdminModule.initializeApp({
31880
31883
  credential: firebaseAdminModule.cert(keyPath),
@@ -32246,8 +32249,8 @@ var init_bigquery_telemetry = __esm({
32246
32249
  });
32247
32250
  async function getUserContext() {
32248
32251
  try {
32249
- const configDir = path54__namespace.join(process.env.HOME || process.env.USERPROFILE || "", ".maria");
32250
- const authFile = path54__namespace.join(configDir, "auth.json");
32252
+ const configDir = path55__namespace.join(process.env.HOME || process.env.USERPROFILE || "", ".maria");
32253
+ const authFile = path55__namespace.join(configDir, "auth.json");
32251
32254
  if (await fs10__namespace.pathExists(authFile)) {
32252
32255
  const authData = await fs10__namespace.readJson(authFile);
32253
32256
  return {
@@ -33423,7 +33426,7 @@ var init_setup_command = __esm({
33423
33426
  if (_setupRecord.filesGenerated) {
33424
33427
  for (const file of _setupRecord.filesGenerated) {
33425
33428
  try {
33426
- const _filePath = path54__namespace.default.join(context2.environment.cwd, file);
33429
+ const _filePath = path55__namespace.default.join(context2.environment.cwd, file);
33427
33430
  await fsp__namespace.default.unlink(_filePath);
33428
33431
  restoredFiles.push(file);
33429
33432
  } catch (innerError) {
@@ -33433,7 +33436,7 @@ var init_setup_command = __esm({
33433
33436
  }
33434
33437
  }
33435
33438
  }
33436
- const _setupRecordPath = path54__namespace.default.join(
33439
+ const _setupRecordPath = path55__namespace.default.join(
33437
33440
  context2.environment.cwd,
33438
33441
  ".maria",
33439
33442
  "setup.json"
@@ -33501,7 +33504,7 @@ var init_setup_command = __esm({
33501
33504
  }
33502
33505
  }
33503
33506
  async recordSetupCompletion(_context, result) {
33504
- const _mariaDir = path54__namespace.default.join(_context.environment.cwd, ".maria");
33507
+ const _mariaDir = path55__namespace.default.join(_context.environment.cwd, ".maria");
33505
33508
  await fsp__namespace.default.mkdir(_mariaDir, { recursive: true });
33506
33509
  const _setupRecord = {
33507
33510
  ...result,
@@ -33509,7 +33512,7 @@ var init_setup_command = __esm({
33509
33512
  version: "1.0.0",
33510
33513
  environment: _context.environment
33511
33514
  };
33512
- const _recordPath = path54__namespace.default.join(_mariaDir, "setup.json");
33515
+ const _recordPath = path55__namespace.default.join(_mariaDir, "setup.json");
33513
33516
  await fsp__namespace.default.writeFile(
33514
33517
  _recordPath,
33515
33518
  JSON.stringify(_setupRecord, null, 2),
@@ -33608,14 +33611,14 @@ Estimated time: 3-5 minutes
33608
33611
  }
33609
33612
  async detectConfigurationIssues(context2) {
33610
33613
  const _issues = [];
33611
- if (!await this.fileExists(path54__namespace.default.join(context2.environment.cwd, ".env.local"))) {
33614
+ if (!await this.fileExists(path55__namespace.default.join(context2.environment.cwd, ".env.local"))) {
33612
33615
  _issues.push({
33613
33616
  description: "Missing .env.local file",
33614
33617
  severity: "error"
33615
33618
  });
33616
33619
  }
33617
33620
  if (!await this.fileExists(
33618
- path54__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
33621
+ path55__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
33619
33622
  )) {
33620
33623
  _issues.push({
33621
33624
  description: "Missing .maria-code.toml file",
@@ -33631,7 +33634,7 @@ Estimated time: 3-5 minutes
33631
33634
  }
33632
33635
  async getSetupRecord(context2) {
33633
33636
  try {
33634
- const _recordPath = path54__namespace.default.join(
33637
+ const _recordPath = path55__namespace.default.join(
33635
33638
  context2.environment.cwd,
33636
33639
  ".maria",
33637
33640
  "setup.json"
@@ -33643,11 +33646,11 @@ Estimated time: 3-5 minutes
33643
33646
  }
33644
33647
  }
33645
33648
  async validateEnvironmentFile(context2) {
33646
- return this.fileExists(path54__namespace.default.join(context2.environment.cwd, ".env.local"));
33649
+ return this.fileExists(path55__namespace.default.join(context2.environment.cwd, ".env.local"));
33647
33650
  }
33648
33651
  async validateConfigFile(context2) {
33649
33652
  return this.fileExists(
33650
- path54__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
33653
+ path55__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
33651
33654
  );
33652
33655
  }
33653
33656
  async validateProviderConnections(_context) {
@@ -33674,7 +33677,7 @@ VLLM_API_URL=http://localhost:8000
33674
33677
  DEBUG=false
33675
33678
  LOG_LEVEL=info
33676
33679
  `;
33677
- const _envPath = path54__namespace.default.join(process.cwd(), ".env.local");
33680
+ const _envPath = path55__namespace.default.join(process.cwd(), ".env.local");
33678
33681
  await fsp__namespace.default.writeFile(_envPath, _envContent, "utf-8");
33679
33682
  return this.success("Environment template generated successfully", {
33680
33683
  files: [".env.local"],
@@ -33748,8 +33751,8 @@ var init_ConfigurationCommandService = __esm({
33748
33751
  var DIR, FILE, QuickPersistence;
33749
33752
  var init_quick_persistence = __esm({
33750
33753
  "src/services/memory-system/quick-persistence.ts"() {
33751
- DIR = path54__namespace.join(os16__namespace.homedir(), ".maria", "memory");
33752
- FILE = path54__namespace.join(DIR, "memories.jsonl");
33754
+ DIR = path55__namespace.join(os16__namespace.homedir(), ".maria", "memory");
33755
+ FILE = path55__namespace.join(DIR, "memories.jsonl");
33753
33756
  QuickPersistence = class {
33754
33757
  static async init() {
33755
33758
  await fsp__namespace.mkdir(DIR, { recursive: true });
@@ -33871,8 +33874,8 @@ var init_quick_persistence = __esm({
33871
33874
  const mine = rows.filter((r2) => r2.userId === userId);
33872
33875
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
33873
33876
  const filename = `maria-memory-export-${timestamp}.${format}`;
33874
- const exportDir = path54__namespace.join(os16__namespace.homedir(), ".maria", "exports");
33875
- const exportPath = path54__namespace.join(exportDir, filename);
33877
+ const exportDir = path55__namespace.join(os16__namespace.homedir(), ".maria", "exports");
33878
+ const exportPath = path55__namespace.join(exportDir, filename);
33876
33879
  await fsp__namespace.mkdir(exportDir, { recursive: true });
33877
33880
  if (format === "jsonl") {
33878
33881
  await fsp__namespace.writeFile(
@@ -36506,7 +36509,7 @@ var init_StateManager = __esm({
36506
36509
  maxCheckpointAge = 7 * 24 * 60 * 60 * 1e3;
36507
36510
  // 7 days
36508
36511
  constructor() {
36509
- this.checkpointsDir = path54__namespace.join(os16__namespace.homedir(), ".maria", "checkpoints");
36512
+ this.checkpointsDir = path55__namespace.join(os16__namespace.homedir(), ".maria", "checkpoints");
36510
36513
  }
36511
36514
  /**
36512
36515
  * Initialize checkpoints directory
@@ -36532,7 +36535,7 @@ var init_StateManager = __esm({
36532
36535
  const checkpointId = `${planId}_${Date.now()}`;
36533
36536
  const timestamp = Date.now();
36534
36537
  try {
36535
- const checkpointPath = path54__namespace.join(this.checkpointsDir, checkpointId);
36538
+ const checkpointPath = path55__namespace.join(this.checkpointsDir, checkpointId);
36536
36539
  await fsp__namespace.mkdir(checkpointPath, { recursive: true });
36537
36540
  const backups = await this.createBackups(actions, checkpointPath);
36538
36541
  const configSnapshots = await this.createConfigSnapshots(
@@ -36551,7 +36554,7 @@ var init_StateManager = __esm({
36551
36554
  riskScore
36552
36555
  }
36553
36556
  };
36554
- const metadataPath = path54__namespace.join(checkpointPath, "checkpoint.json");
36557
+ const metadataPath = path55__namespace.join(checkpointPath, "checkpoint.json");
36555
36558
  await fsp__namespace.writeFile(
36556
36559
  metadataPath,
36557
36560
  JSON.stringify(checkpoint, null, 2),
@@ -36723,7 +36726,7 @@ var init_StateManager = __esm({
36723
36726
  */
36724
36727
  async removeCheckpoint(checkpointId) {
36725
36728
  try {
36726
- const checkpointPath = path54__namespace.join(this.checkpointsDir, checkpointId);
36729
+ const checkpointPath = path55__namespace.join(this.checkpointsDir, checkpointId);
36727
36730
  await fsp__namespace.rm(checkpointPath, { recursive: true, force: true });
36728
36731
  logger.info(`StateManager: Removed checkpoint ${checkpointId}`);
36729
36732
  return true;
@@ -36754,7 +36757,7 @@ var init_StateManager = __esm({
36754
36757
  */
36755
36758
  async createBackups(actions, checkpointPath) {
36756
36759
  const backups = [];
36757
- const backupDir = path54__namespace.join(checkpointPath, "backups");
36760
+ const backupDir = path55__namespace.join(checkpointPath, "backups");
36758
36761
  await fsp__namespace.mkdir(backupDir, { recursive: true });
36759
36762
  for (const action of actions) {
36760
36763
  const filesToBackup = this.extractFilePathsFromAction(action);
@@ -36763,7 +36766,7 @@ var init_StateManager = __esm({
36763
36766
  const resolvedPath = this.resolvePath(filePath);
36764
36767
  const stats = await fsp__namespace.stat(resolvedPath);
36765
36768
  const backupFileName = this.sanitizeFileName(resolvedPath);
36766
- const backupPath = path54__namespace.join(backupDir, backupFileName);
36769
+ const backupPath = path55__namespace.join(backupDir, backupFileName);
36767
36770
  await fsp__namespace.copyFile(resolvedPath, backupPath);
36768
36771
  backups.push({
36769
36772
  originalPath: resolvedPath,
@@ -36786,7 +36789,7 @@ var init_StateManager = __esm({
36786
36789
  */
36787
36790
  async createConfigSnapshots(actions, checkpointPath) {
36788
36791
  const snapshots = [];
36789
- const configDir = path54__namespace.join(checkpointPath, "configs");
36792
+ const configDir = path55__namespace.join(checkpointPath, "configs");
36790
36793
  await fsp__namespace.mkdir(configDir, { recursive: true });
36791
36794
  const configPaths = /* @__PURE__ */ new Set();
36792
36795
  for (const action of actions) {
@@ -36819,7 +36822,7 @@ var init_StateManager = __esm({
36819
36822
  * Load checkpoint from disk
36820
36823
  */
36821
36824
  async loadCheckpoint(checkpointId) {
36822
- const metadataPath = path54__namespace.join(
36825
+ const metadataPath = path55__namespace.join(
36823
36826
  this.checkpointsDir,
36824
36827
  checkpointId,
36825
36828
  "checkpoint.json"
@@ -36845,9 +36848,9 @@ var init_StateManager = __esm({
36845
36848
  */
36846
36849
  resolvePath(filePath) {
36847
36850
  if (filePath.startsWith("~/")) {
36848
- return path54__namespace.join(os16__namespace.homedir(), filePath.slice(2));
36851
+ return path55__namespace.join(os16__namespace.homedir(), filePath.slice(2));
36849
36852
  }
36850
- return path54__namespace.resolve(filePath);
36853
+ return path55__namespace.resolve(filePath);
36851
36854
  }
36852
36855
  /**
36853
36856
  * Sanitize filename for backup storage
@@ -36911,7 +36914,7 @@ var init_StateManager = __esm({
36911
36914
  } catch {
36912
36915
  }
36913
36916
  } else {
36914
- await fsp__namespace.mkdir(path54__namespace.dirname(config2.configPath), { recursive: true });
36917
+ await fsp__namespace.mkdir(path55__namespace.dirname(config2.configPath), { recursive: true });
36915
36918
  await fsp__namespace.writeFile(config2.configPath, config2.content, "utf-8");
36916
36919
  }
36917
36920
  logger.debug(`StateManager: Restored config ${config2.configPath}`);
@@ -37029,9 +37032,9 @@ var init_SafetyGuard = __esm({
37029
37032
  }
37030
37033
  }
37031
37034
  if (action.args.paths && Array.isArray(action.args.paths)) {
37032
- for (const path55 of action.args.paths) {
37033
- if (!this.validatePath(path55)) {
37034
- violations.push(`Invalid path: ${path55}`);
37035
+ for (const path56 of action.args.paths) {
37036
+ if (!this.validatePath(path56)) {
37037
+ violations.push(`Invalid path: ${path56}`);
37035
37038
  }
37036
37039
  }
37037
37040
  }
@@ -37087,15 +37090,15 @@ var init_SafetyGuard = __esm({
37087
37090
  * Validate file path against allowed/blocked lists
37088
37091
  */
37089
37092
  validatePath(filePath) {
37090
- const path55 = __require("path");
37091
- const resolvedPath = path55.resolve(filePath);
37093
+ const path56 = __require("path");
37094
+ const resolvedPath = path56.resolve(filePath);
37092
37095
  for (const blockedPath of this.constraints.blockedPaths) {
37093
- if (resolvedPath.startsWith(path55.resolve(blockedPath))) {
37096
+ if (resolvedPath.startsWith(path56.resolve(blockedPath))) {
37094
37097
  return false;
37095
37098
  }
37096
37099
  }
37097
37100
  for (const allowedPath of this.constraints.allowedPaths) {
37098
- if (resolvedPath.startsWith(path55.resolve(allowedPath))) {
37101
+ if (resolvedPath.startsWith(path56.resolve(allowedPath))) {
37099
37102
  return true;
37100
37103
  }
37101
37104
  }
@@ -37124,9 +37127,9 @@ var init_SafetyGuard = __esm({
37124
37127
  violations.push(`Invalid path in ${action.type}: ${action.args.path}`);
37125
37128
  }
37126
37129
  if (action.args.paths && Array.isArray(action.args.paths)) {
37127
- for (const path55 of action.args.paths) {
37128
- if (!this.validatePath(path55)) {
37129
- violations.push(`Invalid path in ${action.type}: ${path55}`);
37130
+ for (const path56 of action.args.paths) {
37131
+ if (!this.validatePath(path56)) {
37132
+ violations.push(`Invalid path in ${action.type}: ${path56}`);
37130
37133
  }
37131
37134
  }
37132
37135
  }
@@ -37225,7 +37228,7 @@ var init_AuditLogger = __esm({
37225
37228
  constructor(sessionId, options = {}) {
37226
37229
  this.sessionId = sessionId;
37227
37230
  this.options = {
37228
- logDir: path54__namespace.join(os16__namespace.homedir(), ".maria", "audit"),
37231
+ logDir: path55__namespace.join(os16__namespace.homedir(), ".maria", "audit"),
37229
37232
  maxLogSize: 10 * 1024 * 1024,
37230
37233
  // 10MB
37231
37234
  maxLogFiles: 30,
@@ -37235,7 +37238,7 @@ var init_AuditLogger = __esm({
37235
37238
  ...options
37236
37239
  };
37237
37240
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
37238
- this.logFilePath = path54__namespace.join(this.options.logDir, `audit-${date}.jsonl`);
37241
+ this.logFilePath = path55__namespace.join(this.options.logDir, `audit-${date}.jsonl`);
37239
37242
  }
37240
37243
  /**
37241
37244
  * Initialize audit logging
@@ -37524,7 +37527,7 @@ var init_AuditLogger = __esm({
37524
37527
  try {
37525
37528
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
37526
37529
  const timestamp = Date.now();
37527
- const archivePath = path54__namespace.join(
37530
+ const archivePath = path55__namespace.join(
37528
37531
  this.options.logDir,
37529
37532
  `audit-${date}-${timestamp}.jsonl`
37530
37533
  );
@@ -37564,7 +37567,7 @@ var init_AuditLogger = __esm({
37564
37567
  if (logFiles.length > this.options.maxLogFiles) {
37565
37568
  const toRemove = logFiles.slice(this.options.maxLogFiles);
37566
37569
  for (const file of toRemove) {
37567
- const filePath = path54__namespace.join(this.options.logDir, file);
37570
+ const filePath = path55__namespace.join(this.options.logDir, file);
37568
37571
  await fsp__namespace.unlink(filePath);
37569
37572
  logger.debug(`AuditLogger: Removed old log file ${file}`);
37570
37573
  }
@@ -37606,7 +37609,7 @@ var init_FileActionExecutor = __esm({
37606
37609
  FileActionExecutor = class {
37607
37610
  ALLOWED_PATHS = [
37608
37611
  process.cwd(),
37609
- path54__namespace.join(os16__namespace.homedir(), ".maria")
37612
+ path55__namespace.join(os16__namespace.homedir(), ".maria")
37610
37613
  ];
37611
37614
  /**
37612
37615
  * Execute file action
@@ -37668,7 +37671,7 @@ var init_FileActionExecutor = __esm({
37668
37671
  await fsp__namespace.access(resolvedPath);
37669
37672
  return { action: "already_exists", path: resolvedPath };
37670
37673
  } catch {
37671
- await fsp__namespace.mkdir(path54__namespace.dirname(resolvedPath), { recursive: true });
37674
+ await fsp__namespace.mkdir(path55__namespace.dirname(resolvedPath), { recursive: true });
37672
37675
  await fsp__namespace.writeFile(resolvedPath, "", "utf-8");
37673
37676
  logger.info(`Created file: ${resolvedPath}`);
37674
37677
  return { action: "created", path: resolvedPath };
@@ -37885,20 +37888,20 @@ var init_FileActionExecutor = __esm({
37885
37888
  */
37886
37889
  resolvePath(filePath) {
37887
37890
  if (filePath.startsWith("~/")) {
37888
- return path54__namespace.join(os16__namespace.homedir(), filePath.slice(2));
37891
+ return path55__namespace.join(os16__namespace.homedir(), filePath.slice(2));
37889
37892
  }
37890
- if (path54__namespace.isAbsolute(filePath)) {
37893
+ if (path55__namespace.isAbsolute(filePath)) {
37891
37894
  return filePath;
37892
37895
  }
37893
- return path54__namespace.resolve(process.cwd(), filePath);
37896
+ return path55__namespace.resolve(process.cwd(), filePath);
37894
37897
  }
37895
37898
  /**
37896
37899
  * Validate path is within allowed directories
37897
37900
  */
37898
37901
  validatePath(filePath) {
37899
- const resolvedPath = path54__namespace.resolve(filePath);
37902
+ const resolvedPath = path55__namespace.resolve(filePath);
37900
37903
  for (const allowedPath of this.ALLOWED_PATHS) {
37901
- const allowedResolved = path54__namespace.resolve(allowedPath);
37904
+ const allowedResolved = path55__namespace.resolve(allowedPath);
37902
37905
  if (resolvedPath.startsWith(allowedResolved)) {
37903
37906
  return;
37904
37907
  }
@@ -37913,7 +37916,7 @@ var init_ConfigActionExecutor = __esm({
37913
37916
  "src/services/self-healing/executors/ConfigActionExecutor.ts"() {
37914
37917
  init_logger();
37915
37918
  ConfigActionExecutor = class {
37916
- DEFAULT_CONFIG_PATH = path54__namespace.join(
37919
+ DEFAULT_CONFIG_PATH = path55__namespace.join(
37917
37920
  os16__namespace.homedir(),
37918
37921
  ".maria",
37919
37922
  "config.json"
@@ -37960,7 +37963,7 @@ var init_ConfigActionExecutor = __esm({
37960
37963
  };
37961
37964
  }
37962
37965
  try {
37963
- await fsp__namespace.mkdir(path54__namespace.dirname(resolvedPath), { recursive: true });
37966
+ await fsp__namespace.mkdir(path55__namespace.dirname(resolvedPath), { recursive: true });
37964
37967
  let config2 = {};
37965
37968
  try {
37966
37969
  const content = await fsp__namespace.readFile(resolvedPath, "utf-8");
@@ -37995,7 +37998,7 @@ var init_ConfigActionExecutor = __esm({
37995
37998
  };
37996
37999
  }
37997
38000
  try {
37998
- await fsp__namespace.mkdir(path54__namespace.dirname(resolvedPath), { recursive: true });
38001
+ await fsp__namespace.mkdir(path55__namespace.dirname(resolvedPath), { recursive: true });
37999
38002
  let config2 = {};
38000
38003
  try {
38001
38004
  const content = await fsp__namespace.readFile(resolvedPath, "utf-8");
@@ -38095,8 +38098,8 @@ var init_ConfigActionExecutor = __esm({
38095
38098
  /**
38096
38099
  * Set nested configuration value using dot notation
38097
38100
  */
38098
- setNestedValue(obj, path55, value) {
38099
- const keys = path55.split(".");
38101
+ setNestedValue(obj, path56, value) {
38102
+ const keys = path56.split(".");
38100
38103
  let current = obj;
38101
38104
  for (let i2 = 0; i2 < keys.length - 1; i2++) {
38102
38105
  const key = keys[i2];
@@ -38113,9 +38116,9 @@ var init_ConfigActionExecutor = __esm({
38113
38116
  resolveConfigPath(configPath) {
38114
38117
  if (configPath) {
38115
38118
  if (configPath.startsWith("~/")) {
38116
- return path54__namespace.join(os16__namespace.homedir(), configPath.slice(2));
38119
+ return path55__namespace.join(os16__namespace.homedir(), configPath.slice(2));
38117
38120
  }
38118
- return path54__namespace.resolve(configPath);
38121
+ return path55__namespace.resolve(configPath);
38119
38122
  }
38120
38123
  return this.DEFAULT_CONFIG_PATH;
38121
38124
  }
@@ -38128,10 +38131,10 @@ var init_CacheActionExecutor = __esm({
38128
38131
  init_logger();
38129
38132
  CacheActionExecutor = class {
38130
38133
  CACHE_PATHS = [
38131
- path54__namespace.join(os16__namespace.homedir(), ".maria", "cache"),
38132
- path54__namespace.join(process.cwd(), ".turbo"),
38133
- path54__namespace.join(process.cwd(), ".cache", "maria"),
38134
- path54__namespace.join(process.cwd(), "node_modules", ".cache")
38134
+ path55__namespace.join(os16__namespace.homedir(), ".maria", "cache"),
38135
+ path55__namespace.join(process.cwd(), ".turbo"),
38136
+ path55__namespace.join(process.cwd(), ".cache", "maria"),
38137
+ path55__namespace.join(process.cwd(), "node_modules", ".cache")
38135
38138
  ];
38136
38139
  /**
38137
38140
  * Execute cache action
@@ -38312,10 +38315,10 @@ var init_CacheActionExecutor = __esm({
38312
38315
  * Warmup specific target
38313
38316
  */
38314
38317
  async warmupTarget(target) {
38315
- const cacheDir = path54__namespace.join(os16__namespace.homedir(), ".maria", "cache");
38318
+ const cacheDir = path55__namespace.join(os16__namespace.homedir(), ".maria", "cache");
38316
38319
  switch (target) {
38317
38320
  case "models:list":
38318
- const modelsDir = path54__namespace.join(cacheDir, "models");
38321
+ const modelsDir = path55__namespace.join(cacheDir, "models");
38319
38322
  await fsp__namespace.mkdir(modelsDir, { recursive: true });
38320
38323
  const modelsData = {
38321
38324
  timestamp: Date.now(),
@@ -38326,12 +38329,12 @@ var init_CacheActionExecutor = __esm({
38326
38329
  ]
38327
38330
  };
38328
38331
  await fsp__namespace.writeFile(
38329
- path54__namespace.join(modelsDir, "available.json"),
38332
+ path55__namespace.join(modelsDir, "available.json"),
38330
38333
  JSON.stringify(modelsData, null, 2)
38331
38334
  );
38332
38335
  return { itemsCreated: 1, size: JSON.stringify(modelsData).length };
38333
38336
  case "aliases":
38334
- const aliasesDir = path54__namespace.join(cacheDir, "aliases");
38337
+ const aliasesDir = path55__namespace.join(cacheDir, "aliases");
38335
38338
  await fsp__namespace.mkdir(aliasesDir, { recursive: true });
38336
38339
  const aliasesData = {
38337
38340
  timestamp: Date.now(),
@@ -38342,12 +38345,12 @@ var init_CacheActionExecutor = __esm({
38342
38345
  }
38343
38346
  };
38344
38347
  await fsp__namespace.writeFile(
38345
- path54__namespace.join(aliasesDir, "model-aliases.json"),
38348
+ path55__namespace.join(aliasesDir, "model-aliases.json"),
38346
38349
  JSON.stringify(aliasesData, null, 2)
38347
38350
  );
38348
38351
  return { itemsCreated: 1, size: JSON.stringify(aliasesData).length };
38349
38352
  case "templates":
38350
- const templatesDir = path54__namespace.join(cacheDir, "templates");
38353
+ const templatesDir = path55__namespace.join(cacheDir, "templates");
38351
38354
  await fsp__namespace.mkdir(templatesDir, { recursive: true });
38352
38355
  const templatesData = {
38353
38356
  timestamp: Date.now(),
@@ -38358,7 +38361,7 @@ var init_CacheActionExecutor = __esm({
38358
38361
  }
38359
38362
  };
38360
38363
  await fsp__namespace.writeFile(
38361
- path54__namespace.join(templatesDir, "prompt-templates.json"),
38364
+ path55__namespace.join(templatesDir, "prompt-templates.json"),
38362
38365
  JSON.stringify(templatesData, null, 2)
38363
38366
  );
38364
38367
  return { itemsCreated: 1, size: JSON.stringify(templatesData).length };
@@ -38404,7 +38407,7 @@ var init_CacheActionExecutor = __esm({
38404
38407
  try {
38405
38408
  const entries = await fsp__namespace.readdir(dirPath, { withFileTypes: true });
38406
38409
  for (const entry of entries) {
38407
- const entryPath = path54__namespace.join(dirPath, entry.name);
38410
+ const entryPath = path55__namespace.join(dirPath, entry.name);
38408
38411
  if (entry.isDirectory()) {
38409
38412
  totalSize += await this.getDirectorySize(entryPath);
38410
38413
  } else {
@@ -38425,7 +38428,7 @@ var init_CacheActionExecutor = __esm({
38425
38428
  const entries = await fsp__namespace.readdir(dirPath, { withFileTypes: true });
38426
38429
  for (const entry of entries) {
38427
38430
  if (entry.isDirectory()) {
38428
- const entryPath = path54__namespace.join(dirPath, entry.name);
38431
+ const entryPath = path55__namespace.join(dirPath, entry.name);
38429
38432
  count += await this.countFiles(entryPath);
38430
38433
  } else {
38431
38434
  count++;
@@ -38453,12 +38456,12 @@ var init_CacheActionExecutor = __esm({
38453
38456
  */
38454
38457
  resolvePath(cachePath) {
38455
38458
  if (cachePath.startsWith("~/")) {
38456
- return path54__namespace.join(os16__namespace.homedir(), cachePath.slice(2));
38459
+ return path55__namespace.join(os16__namespace.homedir(), cachePath.slice(2));
38457
38460
  }
38458
- if (path54__namespace.isAbsolute(cachePath)) {
38461
+ if (path55__namespace.isAbsolute(cachePath)) {
38459
38462
  return cachePath;
38460
38463
  }
38461
- return path54__namespace.resolve(process.cwd(), cachePath);
38464
+ return path55__namespace.resolve(process.cwd(), cachePath);
38462
38465
  }
38463
38466
  };
38464
38467
  }
@@ -38731,7 +38734,7 @@ var init_SelfHealingService = __esm({
38731
38734
  const timestamp = /* @__PURE__ */ new Date();
38732
38735
  await this.auditLogger.logDiagnosis("started", { diagnostics: context2 });
38733
38736
  try {
38734
- const envPath = path54__namespace.join(context2.cwd, ".env.local");
38737
+ const envPath = path55__namespace.join(context2.cwd, ".env.local");
38735
38738
  try {
38736
38739
  await fsp__namespace.access(envPath);
38737
38740
  } catch {
@@ -38746,7 +38749,7 @@ var init_SelfHealingService = __esm({
38746
38749
  suggestion: "Create .env.local with API keys template"
38747
38750
  });
38748
38751
  }
38749
- const nodeModulesPath = path54__namespace.join(context2.cwd, "node_modules");
38752
+ const nodeModulesPath = path55__namespace.join(context2.cwd, "node_modules");
38750
38753
  try {
38751
38754
  await fsp__namespace.access(nodeModulesPath);
38752
38755
  } catch {
@@ -38761,7 +38764,7 @@ var init_SelfHealingService = __esm({
38761
38764
  suggestion: "Run package manager install command"
38762
38765
  });
38763
38766
  }
38764
- const cachePath = path54__namespace.join(process.env.HOME || "", ".maria", "cache");
38767
+ const cachePath = path55__namespace.join(process.env.HOME || "", ".maria", "cache");
38765
38768
  try {
38766
38769
  const stats = await fsp__namespace.stat(cachePath);
38767
38770
  if (stats.size > 100 * 1024 * 1024) {
@@ -39343,7 +39346,7 @@ function createConfigCheck() {
39343
39346
  runsIn: "read-only",
39344
39347
  estimateMs: 20,
39345
39348
  async run(ctx2) {
39346
- const pkgPath = path54.resolve(ctx2.cwd, "package.json");
39349
+ const pkgPath = path55.resolve(ctx2.cwd, "package.json");
39347
39350
  try {
39348
39351
  const raw = await fsp.readFile(pkgPath, "utf-8");
39349
39352
  const pkg = JSON.parse(raw);
@@ -39412,7 +39415,7 @@ function createDependenciesCheck() {
39412
39415
  runsIn: "read-only",
39413
39416
  estimateMs: 25,
39414
39417
  async run(ctx2) {
39415
- const nm = path54.resolve(ctx2.cwd, "node_modules");
39418
+ const nm = path55.resolve(ctx2.cwd, "node_modules");
39416
39419
  try {
39417
39420
  const s2 = await fsp.stat(nm);
39418
39421
  if (!s2.isDirectory()) {
@@ -39507,7 +39510,7 @@ function createGitRepoCheck() {
39507
39510
  runsIn: "read-only",
39508
39511
  estimateMs: 10,
39509
39512
  async run(ctx2) {
39510
- const dotgit = path54.resolve(ctx2.cwd, ".git");
39513
+ const dotgit = path55.resolve(ctx2.cwd, ".git");
39511
39514
  try {
39512
39515
  await fsp.access(dotgit);
39513
39516
  return { name: "Git Repository", category: "config", status: "pass", message: "Git repo detected" };
@@ -39593,9 +39596,9 @@ function createProvidersSecretConfigCheck() {
39593
39596
  groq: !!process.env.GROQ_API_KEY
39594
39597
  };
39595
39598
  const candidates = [
39596
- path54.resolve(ctx2.cwd, ".maria/secrets.local.json"),
39597
- path54.resolve(ctx2.cwd, "secrets/local.json"),
39598
- path54.resolve(ctx2.cwd, ".secrets.local.json")
39599
+ path55.resolve(ctx2.cwd, ".maria/secrets.local.json"),
39600
+ path55.resolve(ctx2.cwd, "secrets/local.json"),
39601
+ path55.resolve(ctx2.cwd, ".secrets.local.json")
39599
39602
  ];
39600
39603
  let fileCfg = null;
39601
39604
  for (const p of candidates) {
@@ -39667,8 +39670,8 @@ async function applyPlans(plans, opts) {
39667
39670
  try {
39668
39671
  for (const plan of plans) {
39669
39672
  if (opts.signal?.aborted) throw abortErr();
39670
- const target = path54__namespace.default.join(opts.root, plan.path);
39671
- const dir = path54__namespace.default.dirname(target);
39673
+ const target = path55__namespace.default.join(opts.root, plan.path);
39674
+ const dir = path55__namespace.default.dirname(target);
39672
39675
  await fs22.promises.mkdir(dir, { recursive: true });
39673
39676
  const exists = await fileExists(target);
39674
39677
  const perFileAllowed = plan.overwritePolicy === "allow";
@@ -39697,7 +39700,7 @@ async function applyPlans(plans, opts) {
39697
39700
  if (opts.rollback) {
39698
39701
  for (const rel of created) {
39699
39702
  try {
39700
- await fs22.promises.unlink(path54__namespace.default.join(opts.root, rel));
39703
+ await fs22.promises.unlink(path55__namespace.default.join(opts.root, rel));
39701
39704
  } catch {
39702
39705
  }
39703
39706
  }
@@ -39818,7 +39821,7 @@ async function applyFixes(plans, opts) {
39818
39821
  continue;
39819
39822
  }
39820
39823
  if (plan.action === "file.create") {
39821
- const full = path54.resolve(opts.cwd, plan.path);
39824
+ const full = path55.resolve(opts.cwd, plan.path);
39822
39825
  try {
39823
39826
  await fsp.access(full);
39824
39827
  results.push({ plan, status: "skipped", message: "File exists" });
@@ -39831,7 +39834,7 @@ async function applyFixes(plans, opts) {
39831
39834
  continue;
39832
39835
  }
39833
39836
  if (plan.action === "file.modify") {
39834
- const full = path54.resolve(opts.cwd, plan.path);
39837
+ const full = path55.resolve(opts.cwd, plan.path);
39835
39838
  const st = await fsp.stat(full).catch(() => null);
39836
39839
  if (!st) {
39837
39840
  await ensureDir(full);
@@ -39848,7 +39851,7 @@ ${plan.diff ?? plan.content ?? ""}`;
39848
39851
  continue;
39849
39852
  }
39850
39853
  if (plan.action === "file.json-merge") {
39851
- const full = path54.resolve(opts.cwd, plan.path);
39854
+ const full = path55.resolve(opts.cwd, plan.path);
39852
39855
  const raw = await readFileSafe(full);
39853
39856
  let json = {};
39854
39857
  if (raw) {
@@ -39883,14 +39886,14 @@ function validatePath2(rel, cwd2) {
39883
39886
  if (rel.includes("..")) return { valid: false, reason: "path traversal" };
39884
39887
  if (rel.startsWith("/") || rel.includes("\\")) return { valid: false, reason: "absolute or backslashes not allowed" };
39885
39888
  if (rel.startsWith(".env") || rel.endsWith(".pem") || rel.endsWith("id_rsa")) return { valid: false, reason: "sensitive path" };
39886
- const full = path54.resolve(cwd2, rel);
39887
- const normCwd = path54.normalize(cwd2) + path54.sep;
39888
- const normFull = path54.normalize(full);
39889
+ const full = path55.resolve(cwd2, rel);
39890
+ const normCwd = path55.normalize(cwd2) + path55.sep;
39891
+ const normFull = path55.normalize(full);
39889
39892
  if (!normFull.startsWith(normCwd)) return { valid: false, reason: "outside cwd" };
39890
39893
  return { valid: true };
39891
39894
  }
39892
39895
  async function ensureDir(fullPath) {
39893
- const i2 = fullPath.lastIndexOf(path54.sep);
39896
+ const i2 = fullPath.lastIndexOf(path55.sep);
39894
39897
  if (i2 <= 0) return;
39895
39898
  const dir = fullPath.slice(0, i2);
39896
39899
  try {
@@ -44012,12 +44015,12 @@ var init_esm4 = __esm({
44012
44015
  /**
44013
44016
  * Get the Path object referenced by the string path, resolved from this Path
44014
44017
  */
44015
- resolve(path55) {
44016
- if (!path55) {
44018
+ resolve(path56) {
44019
+ if (!path56) {
44017
44020
  return this;
44018
44021
  }
44019
- const rootPath = this.getRootString(path55);
44020
- const dir = path55.substring(rootPath.length);
44022
+ const rootPath = this.getRootString(path56);
44023
+ const dir = path56.substring(rootPath.length);
44021
44024
  const dirParts = dir.split(this.splitSep);
44022
44025
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
44023
44026
  return result;
@@ -44769,8 +44772,8 @@ var init_esm4 = __esm({
44769
44772
  /**
44770
44773
  * @internal
44771
44774
  */
44772
- getRootString(path55) {
44773
- return path54.win32.parse(path55).root;
44775
+ getRootString(path56) {
44776
+ return path55.win32.parse(path56).root;
44774
44777
  }
44775
44778
  /**
44776
44779
  * @internal
@@ -44816,8 +44819,8 @@ var init_esm4 = __esm({
44816
44819
  /**
44817
44820
  * @internal
44818
44821
  */
44819
- getRootString(path55) {
44820
- return path55.startsWith("/") ? "/" : "";
44822
+ getRootString(path56) {
44823
+ return path56.startsWith("/") ? "/" : "";
44821
44824
  }
44822
44825
  /**
44823
44826
  * @internal
@@ -44866,8 +44869,8 @@ var init_esm4 = __esm({
44866
44869
  *
44867
44870
  * @internal
44868
44871
  */
44869
- constructor(cwd2 = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs45 = defaultFS } = {}) {
44870
- this.#fs = fsFromOption(fs45);
44872
+ constructor(cwd2 = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs46 = defaultFS } = {}) {
44873
+ this.#fs = fsFromOption(fs46);
44871
44874
  if (cwd2 instanceof URL || cwd2.startsWith("file://")) {
44872
44875
  cwd2 = url.fileURLToPath(cwd2);
44873
44876
  }
@@ -44906,11 +44909,11 @@ var init_esm4 = __esm({
44906
44909
  /**
44907
44910
  * Get the depth of a provided path, string, or the cwd
44908
44911
  */
44909
- depth(path55 = this.cwd) {
44910
- if (typeof path55 === "string") {
44911
- path55 = this.cwd.resolve(path55);
44912
+ depth(path56 = this.cwd) {
44913
+ if (typeof path56 === "string") {
44914
+ path56 = this.cwd.resolve(path56);
44912
44915
  }
44913
- return path55.depth();
44916
+ return path56.depth();
44914
44917
  }
44915
44918
  /**
44916
44919
  * Return the cache of child entries. Exposed so subclasses can create
@@ -45397,9 +45400,9 @@ var init_esm4 = __esm({
45397
45400
  process11();
45398
45401
  return results;
45399
45402
  }
45400
- chdir(path55 = this.cwd) {
45403
+ chdir(path56 = this.cwd) {
45401
45404
  const oldCwd = this.cwd;
45402
- this.cwd = typeof path55 === "string" ? this.cwd.resolve(path55) : path55;
45405
+ this.cwd = typeof path56 === "string" ? this.cwd.resolve(path56) : path56;
45403
45406
  this.cwd[setAsCwd](oldCwd);
45404
45407
  }
45405
45408
  };
@@ -45410,7 +45413,7 @@ var init_esm4 = __esm({
45410
45413
  sep = "\\";
45411
45414
  constructor(cwd2 = process.cwd(), opts = {}) {
45412
45415
  const { nocase = true } = opts;
45413
- super(cwd2, path54.win32, "\\", { ...opts, nocase });
45416
+ super(cwd2, path55.win32, "\\", { ...opts, nocase });
45414
45417
  this.nocase = nocase;
45415
45418
  for (let p = this.cwd; p; p = p.parent) {
45416
45419
  p.nocase = this.nocase;
@@ -45420,13 +45423,13 @@ var init_esm4 = __esm({
45420
45423
  * @internal
45421
45424
  */
45422
45425
  parseRootPath(dir) {
45423
- return path54.win32.parse(dir).root.toUpperCase();
45426
+ return path55.win32.parse(dir).root.toUpperCase();
45424
45427
  }
45425
45428
  /**
45426
45429
  * @internal
45427
45430
  */
45428
- newRoot(fs45) {
45429
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs45 });
45431
+ newRoot(fs46) {
45432
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs46 });
45430
45433
  }
45431
45434
  /**
45432
45435
  * Return true if the provided path string is an absolute path
@@ -45442,7 +45445,7 @@ var init_esm4 = __esm({
45442
45445
  sep = "/";
45443
45446
  constructor(cwd2 = process.cwd(), opts = {}) {
45444
45447
  const { nocase = false } = opts;
45445
- super(cwd2, path54.posix, "/", { ...opts, nocase });
45448
+ super(cwd2, path55.posix, "/", { ...opts, nocase });
45446
45449
  this.nocase = nocase;
45447
45450
  }
45448
45451
  /**
@@ -45454,8 +45457,8 @@ var init_esm4 = __esm({
45454
45457
  /**
45455
45458
  * @internal
45456
45459
  */
45457
- newRoot(fs45) {
45458
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs45 });
45460
+ newRoot(fs46) {
45461
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs46 });
45459
45462
  }
45460
45463
  /**
45461
45464
  * Return true if the provided path string is an absolute path
@@ -45774,8 +45777,8 @@ var init_processor = __esm({
45774
45777
  }
45775
45778
  // match, absolute, ifdir
45776
45779
  entries() {
45777
- return [...this.store.entries()].map(([path55, n]) => [
45778
- path55,
45780
+ return [...this.store.entries()].map(([path56, n]) => [
45781
+ path56,
45779
45782
  !!(n & 2),
45780
45783
  !!(n & 1)
45781
45784
  ]);
@@ -45988,9 +45991,9 @@ var init_walker = __esm({
45988
45991
  signal;
45989
45992
  maxDepth;
45990
45993
  includeChildMatches;
45991
- constructor(patterns, path55, opts) {
45994
+ constructor(patterns, path56, opts) {
45992
45995
  this.patterns = patterns;
45993
- this.path = path55;
45996
+ this.path = path56;
45994
45997
  this.opts = opts;
45995
45998
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
45996
45999
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -46009,11 +46012,11 @@ var init_walker = __esm({
46009
46012
  });
46010
46013
  }
46011
46014
  }
46012
- #ignored(path55) {
46013
- return this.seen.has(path55) || !!this.#ignore?.ignored?.(path55);
46015
+ #ignored(path56) {
46016
+ return this.seen.has(path56) || !!this.#ignore?.ignored?.(path56);
46014
46017
  }
46015
- #childrenIgnored(path55) {
46016
- return !!this.#ignore?.childrenIgnored?.(path55);
46018
+ #childrenIgnored(path56) {
46019
+ return !!this.#ignore?.childrenIgnored?.(path56);
46017
46020
  }
46018
46021
  // backpressure mechanism
46019
46022
  pause() {
@@ -46228,8 +46231,8 @@ var init_walker = __esm({
46228
46231
  };
46229
46232
  GlobWalker = class extends GlobUtil {
46230
46233
  matches = /* @__PURE__ */ new Set();
46231
- constructor(patterns, path55, opts) {
46232
- super(patterns, path55, opts);
46234
+ constructor(patterns, path56, opts) {
46235
+ super(patterns, path56, opts);
46233
46236
  }
46234
46237
  matchEmit(e2) {
46235
46238
  this.matches.add(e2);
@@ -46266,8 +46269,8 @@ var init_walker = __esm({
46266
46269
  };
46267
46270
  GlobStream = class extends GlobUtil {
46268
46271
  results;
46269
- constructor(patterns, path55, opts) {
46270
- super(patterns, path55, opts);
46272
+ constructor(patterns, path56, opts) {
46273
+ super(patterns, path56, opts);
46271
46274
  this.results = new Minipass({
46272
46275
  signal: this.signal,
46273
46276
  objectMode: true
@@ -46816,7 +46819,7 @@ ${usageLine}`;
46816
46819
  async autoRegister(directory) {
46817
46820
  logger.info(`Auto-registering commands from ${directory}`);
46818
46821
  try {
46819
- const pattern = path54__namespace.join(directory, "**/*.command.{ts,js}");
46822
+ const pattern = path55__namespace.join(directory, "**/*.command.{ts,js}");
46820
46823
  const files = await glob(pattern);
46821
46824
  logger.info(`Found ${files.length} command files`);
46822
46825
  for (const file of files) {
@@ -47520,7 +47523,7 @@ ${fixPlan.note}` : ""));
47520
47523
  async runConfigurationChecks(context2) {
47521
47524
  const checks = [];
47522
47525
  const cwd2 = context2.environment?.cwd || process.cwd();
47523
- const packageJsonPath = path54__namespace.join(cwd2, "package.json");
47526
+ const packageJsonPath = path55__namespace.join(cwd2, "package.json");
47524
47527
  try {
47525
47528
  await fsp__namespace.access(packageJsonPath);
47526
47529
  const content = await fsp__namespace.readFile(packageJsonPath, "utf-8");
@@ -47546,7 +47549,7 @@ ${fixPlan.note}` : ""));
47546
47549
  fixable: true
47547
47550
  });
47548
47551
  }
47549
- const envPath = path54__namespace.join(cwd2, ".env.local");
47552
+ const envPath = path55__namespace.join(cwd2, ".env.local");
47550
47553
  try {
47551
47554
  await fsp__namespace.access(envPath);
47552
47555
  checks.push({
@@ -47564,7 +47567,7 @@ ${fixPlan.note}` : ""));
47564
47567
  fixable: true
47565
47568
  });
47566
47569
  }
47567
- const gitPath = path54__namespace.join(cwd2, ".git");
47570
+ const gitPath = path55__namespace.join(cwd2, ".git");
47568
47571
  try {
47569
47572
  await fsp__namespace.access(gitPath);
47570
47573
  checks.push({
@@ -47588,7 +47591,7 @@ ${fixPlan.note}` : ""));
47588
47591
  async runDependencyChecks(context2) {
47589
47592
  const checks = [];
47590
47593
  const cwd2 = context2.environment?.cwd || process.cwd();
47591
- const nodeModulesPath = path54__namespace.join(cwd2, "node_modules");
47594
+ const nodeModulesPath = path55__namespace.join(cwd2, "node_modules");
47592
47595
  try {
47593
47596
  await fsp__namespace.access(nodeModulesPath);
47594
47597
  const stats = await fsp__namespace.stat(nodeModulesPath);
@@ -47820,7 +47823,7 @@ ${fixPlan.note}` : ""));
47820
47823
  }
47821
47824
  break;
47822
47825
  case "CACHE_CORRUPT":
47823
- const cacheDir = path54__namespace.join(
47826
+ const cacheDir = path55__namespace.join(
47824
47827
  context2.environment?.cwd || process.cwd(),
47825
47828
  ".maria",
47826
47829
  "cache"
@@ -47839,7 +47842,7 @@ ${fixPlan.note}` : ""));
47839
47842
  * Create environment template
47840
47843
  */
47841
47844
  async createEnvTemplate(context2) {
47842
- const envPath = path54__namespace.join(
47845
+ const envPath = path55__namespace.join(
47843
47846
  context2.environment?.cwd || process.cwd(),
47844
47847
  ".env.local"
47845
47848
  );
@@ -47895,7 +47898,7 @@ LOG_LEVEL=info
47895
47898
  async getSystemInfo(context2) {
47896
47899
  let mariaVersion = "Unknown";
47897
47900
  try {
47898
- const packagePath = path54__namespace.join(
47901
+ const packagePath = path55__namespace.join(
47899
47902
  context2.environment?.cwd || process.cwd(),
47900
47903
  "package.json"
47901
47904
  );
@@ -49566,7 +49569,7 @@ var init_TerminalSetupCommand = __esm({
49566
49569
  if (_shell.includes("fish")) return "fish";
49567
49570
  if (_shell.includes("powershell")) return "powershell";
49568
49571
  if (_shell.includes("cmd")) return "cmd";
49569
- return path54__namespace.basename(_shell) || "unknown";
49572
+ return path55__namespace.basename(_shell) || "unknown";
49570
49573
  }
49571
49574
  generateTerminalRecommendations(type, _features, _shell) {
49572
49575
  const _recommendations = [];
@@ -49883,9 +49886,9 @@ function clampInt(v, min, max, name2) {
49883
49886
  return Math.min(max, Math.max(min, Math.floor(n)));
49884
49887
  }
49885
49888
  function sanitizeOut(outDir, root) {
49886
- const full = path54__namespace.default.resolve(root, outDir);
49887
- const rel = path54__namespace.default.relative(root, full);
49888
- if (rel.startsWith("..") || path54__namespace.default.isAbsolute(rel)) throw new Error("out path escapes root");
49889
+ const full = path55__namespace.default.resolve(root, outDir);
49890
+ const rel = path55__namespace.default.relative(root, full);
49891
+ if (rel.startsWith("..") || path55__namespace.default.isAbsolute(rel)) throw new Error("out path escapes root");
49889
49892
  return rel.replace(/\\/g, "/");
49890
49893
  }
49891
49894
  var init_Normalizer = __esm({
@@ -49897,15 +49900,15 @@ function ensureDirSync(p) {
49897
49900
  fs22__namespace.mkdirSync(p, { recursive: true });
49898
49901
  }
49899
49902
  function safeJoin(root, ...segs) {
49900
- const full = path54__namespace.resolve(root, ...segs);
49901
- const rel = path54__namespace.relative(root, full);
49902
- if (rel.startsWith("..") || path54__namespace.isAbsolute(rel)) {
49903
+ const full = path55__namespace.resolve(root, ...segs);
49904
+ const rel = path55__namespace.relative(root, full);
49905
+ if (rel.startsWith("..") || path55__namespace.isAbsolute(rel)) {
49903
49906
  throw new Error(`path escapes root: ${segs.join("/")}`);
49904
49907
  }
49905
49908
  return { full, rel };
49906
49909
  }
49907
49910
  function stageDir(root, trace) {
49908
- return path54__namespace.join(root, `.stage/${trace}`);
49911
+ return path55__namespace.join(root, `.stage/${trace}`);
49909
49912
  }
49910
49913
  async function existsSameHash(destFull) {
49911
49914
  try {
@@ -49970,10 +49973,10 @@ async function saveArtifacts(ctx2, items, manifest) {
49970
49973
  const fname = `${contentHash}${ext2}`;
49971
49974
  const dest = safeJoin(root, `${outDirSeg}/${fname}`);
49972
49975
  validateWinPathEdge(dest.full);
49973
- if (await hasCaseInsensitiveCollision(path54__namespace.dirname(dest.full), path54__namespace.basename(dest.full))) {
49976
+ if (await hasCaseInsensitiveCollision(path55__namespace.dirname(dest.full), path55__namespace.basename(dest.full))) {
49974
49977
  throw new Error("case-insensitive filename collision");
49975
49978
  }
49976
- const stg = path54__namespace.join(stage, `${fname}.part`);
49979
+ const stg = path55__namespace.join(stage, `${fname}.part`);
49977
49980
  if (await existsSameHash(dest.full)) {
49978
49981
  saved.push(dest.rel);
49979
49982
  continue;
@@ -49986,10 +49989,10 @@ async function saveArtifacts(ctx2, items, manifest) {
49986
49989
  manifestVersion: 1,
49987
49990
  ...manifest,
49988
49991
  createdAt: manifest.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
49989
- artifacts: manifest.artifacts && manifest.artifacts.length > 0 ? manifest.artifacts : saved.map((file) => ({ file, hash: `sha256:${path54__namespace.basename(file).split(".")[0]}` }))
49992
+ artifacts: manifest.artifacts && manifest.artifacts.length > 0 ? manifest.artifacts : saved.map((file) => ({ file, hash: `sha256:${path55__namespace.basename(file).split(".")[0]}` }))
49990
49993
  };
49991
49994
  const manifestPathRel = `${outDirSeg}/manifest.json`;
49992
- const manifestStage = path54__namespace.join(stage, "manifest.json.part");
49995
+ const manifestStage = path55__namespace.join(stage, "manifest.json.part");
49993
49996
  const manifestFull = safeJoin(root, manifestPathRel).full;
49994
49997
  await fsp__namespace.writeFile(manifestStage, JSON.stringify(manifestObj, null, 2), "utf8");
49995
49998
  await atomicRename(manifestStage, manifestFull);
@@ -50346,10 +50349,10 @@ var init_session = __esm({
50346
50349
  this.root = root;
50347
50350
  }
50348
50351
  file() {
50349
- return path54__namespace.default.join(this.root, ".maria", "memory", "session.json");
50352
+ return path55__namespace.default.join(this.root, ".maria", "memory", "session.json");
50350
50353
  }
50351
50354
  lockFile() {
50352
- return path54__namespace.default.join(this.root, ".maria", "memory", ".session.lock");
50355
+ return path55__namespace.default.join(this.root, ".maria", "memory", ".session.lock");
50353
50356
  }
50354
50357
  load() {
50355
50358
  try {
@@ -50364,7 +50367,7 @@ var init_session = __esm({
50364
50367
  */
50365
50368
  save(data) {
50366
50369
  const target = this.file();
50367
- const dir = path54__namespace.default.dirname(target);
50370
+ const dir = path55__namespace.default.dirname(target);
50368
50371
  fs22__namespace.default.mkdirSync(dir, { recursive: true });
50369
50372
  try {
50370
50373
  this.rotateIfStale(target, 7 * 24 * 60 * 60 * 1e3);
@@ -50397,7 +50400,7 @@ var init_session = __esm({
50397
50400
  const body = `${pid}
50398
50401
  ${(/* @__PURE__ */ new Date()).toISOString()}`;
50399
50402
  const start = Date.now();
50400
- fs22__namespace.default.mkdirSync(path54__namespace.default.dirname(lockPath), { recursive: true });
50403
+ fs22__namespace.default.mkdirSync(path55__namespace.default.dirname(lockPath), { recursive: true });
50401
50404
  const maxWaitTime = Date.now() + waitMs;
50402
50405
  while (Date.now() < maxWaitTime) {
50403
50406
  try {
@@ -50436,10 +50439,10 @@ ${(/* @__PURE__ */ new Date()).toISOString()}`;
50436
50439
  if (age > ttlMs) {
50437
50440
  const d = new Date(st.mtimeMs);
50438
50441
  const yyyymmdd = `${d.getUTCFullYear()}${String(d.getUTCMonth() + 1).padStart(2, "0")}${String(d.getUTCDate()).padStart(2, "0")}`;
50439
- const archiveDir = path54__namespace.default.join(path54__namespace.default.dirname(filePath), "archive", yyyymmdd);
50442
+ const archiveDir = path55__namespace.default.join(path55__namespace.default.dirname(filePath), "archive", yyyymmdd);
50440
50443
  fs22__namespace.default.mkdirSync(archiveDir, { recursive: true });
50441
50444
  const ts = d.toISOString().replace(/[:]/g, "-");
50442
- const dest = path54__namespace.default.join(archiveDir, `session-${ts}.json`);
50445
+ const dest = path55__namespace.default.join(archiveDir, `session-${ts}.json`);
50443
50446
  fs22__namespace.default.renameSync(filePath, dest);
50444
50447
  }
50445
50448
  } catch {
@@ -50561,7 +50564,7 @@ var init_firestore = __esm({
50561
50564
  return s2.slice(0, limit);
50562
50565
  }
50563
50566
  readLocal() {
50564
- const sessionPath = path54__namespace.default.join(this.cwd, ".maria", "memory", "session.json");
50567
+ const sessionPath = path55__namespace.default.join(this.cwd, ".maria", "memory", "session.json");
50565
50568
  const candidates = [];
50566
50569
  try {
50567
50570
  const raw = JSON.parse(fs22__namespace.default.readFileSync(sessionPath, "utf8"));
@@ -50810,13 +50813,13 @@ async function hasFfmpeg() {
50810
50813
  });
50811
50814
  }
50812
50815
  async function muxFramesToMp4(framesDir, fps) {
50813
- const outFile = path54__namespace.join(framesDir, `out-${Date.now()}.mp4`);
50816
+ const outFile = path55__namespace.join(framesDir, `out-${Date.now()}.mp4`);
50814
50817
  await execFfmpeg([
50815
50818
  "-y",
50816
50819
  "-framerate",
50817
50820
  String(fps),
50818
50821
  "-i",
50819
- path54__namespace.join(framesDir, "%06d.png"),
50822
+ path55__namespace.join(framesDir, "%06d.png"),
50820
50823
  "-pix_fmt",
50821
50824
  "yuv420p",
50822
50825
  "-c:v",
@@ -50882,11 +50885,11 @@ async function runVideoPipeline(params2, opts) {
50882
50885
  let saved;
50883
50886
  let warnFallback = false;
50884
50887
  if (frames.length > 0 && await hasFfmpeg()) {
50885
- const tmpDir = path54__namespace.join(opts.root, ".stage", manifest.trace || "FFMPEG");
50888
+ const tmpDir = path55__namespace.join(opts.root, ".stage", manifest.trace || "FFMPEG");
50886
50889
  await fsp__namespace.mkdir(tmpDir, { recursive: true });
50887
50890
  for (let i2 = 0; i2 < frames.length; i2++) {
50888
50891
  const fname = String(i2 + 1).padStart(6, "0") + ".png";
50889
- await fsp__namespace.writeFile(path54__namespace.join(tmpDir, fname), frames[i2]);
50892
+ await fsp__namespace.writeFile(path55__namespace.join(tmpDir, fname), frames[i2]);
50890
50893
  }
50891
50894
  const outBuf = await muxFramesToMp4(tmpDir, params2.fps);
50892
50895
  saved = await saveArtifacts({ root: opts.root, kind: "video", baseDir: opts.outDir }, [{ bytes: outBuf, ext: ".mp4" }], manifest);
@@ -51574,7 +51577,7 @@ var init_about_command = __esm({
51574
51577
  async execute(args2, context2) {
51575
51578
  const output3 = [];
51576
51579
  output3.push("");
51577
- output3.push(chalk36__default.default.cyan.bold("\u{1F916} About MARIA v4.3.9"));
51580
+ output3.push(chalk36__default.default.cyan.bold("\u{1F916} About MARIA v4.3.10"));
51578
51581
  output3.push(chalk36__default.default.gray("\u2550".repeat(40)));
51579
51582
  output3.push("");
51580
51583
  output3.push(chalk36__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
@@ -53123,11 +53126,11 @@ var init_ConfigPortAdapter = __esm({
53123
53126
  backupCount: 5
53124
53127
  };
53125
53128
  constructor() {
53126
- this.globalConfigPath = path54__namespace.default.join(os16__namespace.default.homedir(), ".maria", "config.json");
53127
- this.userConfigPath = path54__namespace.default.join(os16__namespace.default.homedir(), ".maria", "user-config.json");
53128
- this.projectConfigPath = path54__namespace.default.join(process.cwd(), ".maria-config.json");
53129
- this.historyPath = path54__namespace.default.join(os16__namespace.default.homedir(), ".maria", "config-history.json");
53130
- this.templatesPath = path54__namespace.default.join(os16__namespace.default.homedir(), ".maria", "templates");
53129
+ this.globalConfigPath = path55__namespace.default.join(os16__namespace.default.homedir(), ".maria", "config.json");
53130
+ this.userConfigPath = path55__namespace.default.join(os16__namespace.default.homedir(), ".maria", "user-config.json");
53131
+ this.projectConfigPath = path55__namespace.default.join(process.cwd(), ".maria-config.json");
53132
+ this.historyPath = path55__namespace.default.join(os16__namespace.default.homedir(), ".maria", "config-history.json");
53133
+ this.templatesPath = path55__namespace.default.join(os16__namespace.default.homedir(), ".maria", "templates");
53131
53134
  }
53132
53135
  async get(key) {
53133
53136
  const layered = await this.getLayered(key);
@@ -53384,7 +53387,7 @@ var init_ConfigPortAdapter = __esm({
53384
53387
  for (const file of files) {
53385
53388
  if (file.endsWith(".json")) {
53386
53389
  try {
53387
- const templatePath = path54__namespace.default.join(this.templatesPath, file);
53390
+ const templatePath = path55__namespace.default.join(this.templatesPath, file);
53388
53391
  const content = await fsp__namespace.default.readFile(templatePath, "utf-8");
53389
53392
  const template = JSON.parse(content);
53390
53393
  templates.push(template);
@@ -53466,7 +53469,7 @@ var init_ConfigPortAdapter = __esm({
53466
53469
  }
53467
53470
  async saveLayerConfig(layer, config2) {
53468
53471
  const configPath = this.getLayerConfigPath(layer);
53469
- await fsp__namespace.default.mkdir(path54__namespace.default.dirname(configPath), { recursive: true });
53472
+ await fsp__namespace.default.mkdir(path55__namespace.default.dirname(configPath), { recursive: true });
53470
53473
  await fsp__namespace.default.writeFile(configPath, JSON.stringify(config2, null, 2), "utf-8");
53471
53474
  }
53472
53475
  getLayerConfigPath(layer) {
@@ -53478,7 +53481,7 @@ var init_ConfigPortAdapter = __esm({
53478
53481
  case "project":
53479
53482
  return this.projectConfigPath;
53480
53483
  case "runtime":
53481
- return path54__namespace.default.join(os16__namespace.default.tmpdir(), "maria-runtime-config.json");
53484
+ return path55__namespace.default.join(os16__namespace.default.tmpdir(), "maria-runtime-config.json");
53482
53485
  default:
53483
53486
  return this.userConfigPath;
53484
53487
  }
@@ -53532,7 +53535,7 @@ var init_ConfigPortAdapter = __esm({
53532
53535
  const history = JSON.parse(historyContent);
53533
53536
  history.push(entry);
53534
53537
  const trimmedHistory = history.slice(-1e3);
53535
- await fsp__namespace.default.mkdir(path54__namespace.default.dirname(this.historyPath), { recursive: true });
53538
+ await fsp__namespace.default.mkdir(path55__namespace.default.dirname(this.historyPath), { recursive: true });
53536
53539
  await fsp__namespace.default.writeFile(
53537
53540
  this.historyPath,
53538
53541
  JSON.stringify(trimmedHistory, null, 2),
@@ -53544,7 +53547,7 @@ var init_ConfigPortAdapter = __esm({
53544
53547
  }
53545
53548
  async loadTemplate(templateId) {
53546
53549
  try {
53547
- const templatePath = path54__namespace.default.join(this.templatesPath, `${templateId}.json`);
53550
+ const templatePath = path55__namespace.default.join(this.templatesPath, `${templateId}.json`);
53548
53551
  const content = await fsp__namespace.default.readFile(templatePath, "utf-8");
53549
53552
  return JSON.parse(content);
53550
53553
  } catch (error2) {
@@ -54723,7 +54726,7 @@ var init_rate_limit_handler = __esm({
54723
54726
  async function scanRepo(cwd2) {
54724
54727
  if (_cache && _cache.root === cwd2) return _cache;
54725
54728
  const root = cwd2;
54726
- const pkgPath = path54.join(root, "package.json");
54729
+ const pkgPath = path55.join(root, "package.json");
54727
54730
  let pkg = {};
54728
54731
  try {
54729
54732
  pkg = JSON.parse(await fsp.readFile(pkgPath, "utf8"));
@@ -54733,17 +54736,17 @@ async function scanRepo(cwd2) {
54733
54736
  const usesReact = !!deps["react"];
54734
54737
  const usesNext = !!deps["next"];
54735
54738
  const jsModuleType = pkg.type === "module" ? "esm" : "cjs";
54736
- const hasSrc = fs22.existsSync(path54.join(root, "src"));
54739
+ const hasSrc = fs22.existsSync(path55.join(root, "src"));
54737
54740
  const srcRoot = hasSrc ? "src" : "";
54738
- const tsconfigPath = path54.join(root, "tsconfig.json");
54741
+ const tsconfigPath = path55.join(root, "tsconfig.json");
54739
54742
  let usesTS = fs22.existsSync(tsconfigPath) || !!deps["typescript"];
54740
54743
  if (!usesTS && hasSrc) {
54741
54744
  const candidates = ["index.ts", "main.ts", "App.tsx"];
54742
- usesTS = candidates.some((f3) => fs22.existsSync(path54.join(root, "src", f3)));
54745
+ usesTS = candidates.some((f3) => fs22.existsSync(path55.join(root, "src", f3)));
54743
54746
  }
54744
- const nextAppDir = usesNext && fs22.existsSync(path54.join(root, "app"));
54747
+ const nextAppDir = usesNext && fs22.existsSync(path55.join(root, "app"));
54745
54748
  const testRunner = deps["vitest"] ? "vitest" : deps["jest"] ? "jest" : null;
54746
- const isMonorepo2 = fs22.existsSync(path54.join(root, "pnpm-workspace.yaml")) || fs22.existsSync(path54.join(root, "packages")) || fs22.existsSync(path54.join(root, "apps"));
54749
+ const isMonorepo2 = fs22.existsSync(path55.join(root, "pnpm-workspace.yaml")) || fs22.existsSync(path55.join(root, "packages")) || fs22.existsSync(path55.join(root, "apps"));
54747
54750
  const packages = [];
54748
54751
  let aliasPaths = {};
54749
54752
  try {
@@ -54753,7 +54756,7 @@ async function scanRepo(cwd2) {
54753
54756
  }
54754
54757
  let eol = "lf";
54755
54758
  try {
54756
- const ec = await fsp.readFile(path54.join(root, ".editorconfig"), "utf8");
54759
+ const ec = await fsp.readFile(path55.join(root, ".editorconfig"), "utf8");
54757
54760
  if (/end_of_line\s*=\s*crlf/i.test(ec)) eol = "crlf";
54758
54761
  if (/end_of_line\s*=\s*lf/i.test(ec)) eol = "lf";
54759
54762
  } catch {
@@ -54772,7 +54775,7 @@ function normalizePlanItem(fp, p) {
54772
54775
  const base = decideBaseDir(fp, p);
54773
54776
  const desired = sanitize(fp.path || suggestName(fp));
54774
54777
  const withExt = ensureExt(desired, ext2, fp.kind);
54775
- const rel = base ? path54.join(base, withExt) : withExt;
54778
+ const rel = base ? path55.join(base, withExt) : withExt;
54776
54779
  return { ...fp, path: rel.replace(/\\/g, "/") };
54777
54780
  }
54778
54781
  function decideExt(fp, p) {
@@ -54812,10 +54815,10 @@ function suggestName(fp, p) {
54812
54815
  const base = (fp.description || "file").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
54813
54816
  return base || "file";
54814
54817
  }
54815
- function guessKindByPath(path55) {
54816
- if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(path55)) return "test";
54817
- if (/^docs\//.test(path55) || /\.md$/.test(path55)) return "doc";
54818
- if (/\.(json|cjs|js|ts)$/.test(path55) && !/src\//.test(path55)) return "config";
54818
+ function guessKindByPath(path56) {
54819
+ if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(path56)) return "test";
54820
+ if (/^docs\//.test(path56) || /\.md$/.test(path56)) return "doc";
54821
+ if (/\.(json|cjs|js|ts)$/.test(path56) && !/src\//.test(path56)) return "config";
54819
54822
  return "source";
54820
54823
  }
54821
54824
  var init_PathInferencer = __esm({
@@ -54877,15 +54880,15 @@ async function validatePlan(plans, opts) {
54877
54880
  skipped.push(fp.path);
54878
54881
  continue;
54879
54882
  }
54880
- const full = path54__namespace.default.join(opts.root, rel);
54881
- if (!full.startsWith(path54__namespace.default.resolve(opts.root))) {
54883
+ const full = path55__namespace.default.join(opts.root, rel);
54884
+ if (!full.startsWith(path55__namespace.default.resolve(opts.root))) {
54882
54885
  warnings.push(`Outside root denied: ${fp.path}`);
54883
54886
  skipped.push(fp.path);
54884
54887
  continue;
54885
54888
  }
54886
54889
  if (process.platform === "win32" || process.env.MOCK_WIN32 === "1") {
54887
54890
  const invalidChars = /[<>:"/\\|?*]/;
54888
- const name2 = path54__namespace.default.basename(rel);
54891
+ const name2 = path55__namespace.default.basename(rel);
54889
54892
  if (invalidChars.test(rel)) {
54890
54893
  warnings.push(`Invalid characters in path (Windows): ${fp.path}`);
54891
54894
  skipped.push(fp.path);
@@ -54924,7 +54927,7 @@ async function validatePlan(plans, opts) {
54924
54927
  }
54925
54928
  }
54926
54929
  for (const fp of clamped) {
54927
- const full = path54__namespace.default.join(opts.root, fp.path);
54930
+ const full = path55__namespace.default.join(opts.root, fp.path);
54928
54931
  const exists = await exists(full);
54929
54932
  const willModify = exists;
54930
54933
  if (willModify) {
@@ -54975,6 +54978,9 @@ function formatPlan(summary, opts) {
54975
54978
  const sep4 = " ".repeat(leftPad);
54976
54979
  const lines = [];
54977
54980
  lines.push(`Plan: ${summary.planned} files`);
54981
+ if (opts.mode === "diff") {
54982
+ return formatPlanAsDiff(summary.files, opts);
54983
+ }
54978
54984
  for (const f3 of summary.files) {
54979
54985
  const kind = f3.action.padEnd(kindCol);
54980
54986
  const p = truncate(f3.path, pathCol);
@@ -54989,7 +54995,7 @@ function formatPlan(summary, opts) {
54989
54995
  return lines.join("\n");
54990
54996
  }
54991
54997
  function nextHintForPlan(requestText) {
54992
- return `Next: /code --apply --yes "${requestText}" (or preview: --output detail --preview-lines 20)`;
54998
+ return `Next: /code --apply --yes "${requestText}" (or preview: --output diff --diff-lines 200)`;
54993
54999
  }
54994
55000
  function okLine(text) {
54995
55001
  return `OK: ${text}`;
@@ -55003,6 +55009,86 @@ function truncate(s2, n) {
55003
55009
  function headLines(s2, n) {
55004
55010
  return s2.split(/\r?\n/).slice(0, n);
55005
55011
  }
55012
+ function formatPlanAsDiff(files, opts) {
55013
+ const budget = normalizeDiffBudget(opts.diffBudget);
55014
+ const lines = [];
55015
+ let bytesUsed = 0;
55016
+ let shownFiles = 0;
55017
+ for (const f3 of files) {
55018
+ if (budget.globalMaxFiles !== void 0 && shownFiles >= budget.globalMaxFiles) break;
55019
+ const before = readCurrentFileSafe(opts.root, f3.path);
55020
+ const after = f3.preview || "";
55021
+ const diff = unifiedSingleHunkDiff(f3.path, before, after, budget);
55022
+ const diffBytes = Buffer.byteLength(diff, "utf8");
55023
+ if (budget.globalMaxBytes !== void 0 && bytesUsed + diffBytes > budget.globalMaxBytes && shownFiles > 0) {
55024
+ lines.push(`
55025
+ [truncated: global diff byte budget reached]`);
55026
+ break;
55027
+ }
55028
+ lines.push(diff);
55029
+ bytesUsed += diffBytes;
55030
+ shownFiles++;
55031
+ }
55032
+ if (files.length > shownFiles) {
55033
+ lines.push(`
55034
+ [${files.length - shownFiles} more file(s) omitted; re-run with --output diff --diff-lines ${budget.diffLines ?? 200}]`);
55035
+ }
55036
+ return lines.join("\n");
55037
+ }
55038
+ function readCurrentFileSafe(root, rel) {
55039
+ if (!root) return "";
55040
+ try {
55041
+ const fs46 = __require("fs");
55042
+ const p = __require("path").join(root, rel);
55043
+ return fs46.existsSync(p) ? fs46.readFileSync(p, "utf8") : "";
55044
+ } catch {
55045
+ return "";
55046
+ }
55047
+ }
55048
+ function normalizeDiffBudget(b) {
55049
+ const envGlobalBytes = Number(process.env.MARIA_DIFF_GLOBAL_MAX_BYTES || "262144");
55050
+ const envGlobalFiles = Number(process.env.MARIA_DIFF_GLOBAL_MAX_FILES || "20");
55051
+ return {
55052
+ diffLines: b?.diffLines && b.diffLines > 0 ? b.diffLines : 200,
55053
+ diffBytes: b?.diffBytes && b.diffBytes > 0 ? b.diffBytes : 64 * 1024,
55054
+ diffHunks: b?.diffHunks && b.diffHunks > 0 ? b.diffHunks : 8,
55055
+ globalMaxBytes: Number.isFinite(b?.globalMaxBytes) ? b.globalMaxBytes : envGlobalBytes,
55056
+ globalMaxFiles: Number.isFinite(b?.globalMaxFiles) ? b.globalMaxFiles : envGlobalFiles
55057
+ };
55058
+ }
55059
+ function unifiedSingleHunkDiff(relPath, before, after, b) {
55060
+ const beforeLines = before.split(/\r?\n/);
55061
+ const afterLines = after.split(/\r?\n/);
55062
+ let i2 = 0;
55063
+ while (i2 < beforeLines.length && i2 < afterLines.length && beforeLines[i2] === afterLines[i2]) i2++;
55064
+ let j = 0;
55065
+ while (j < beforeLines.length - i2 && j < afterLines.length - i2 && beforeLines[beforeLines.length - 1 - j] === afterLines[afterLines.length - 1 - j]) j++;
55066
+ const oldMid = beforeLines.slice(i2, beforeLines.length - j);
55067
+ const newMid = afterLines.slice(i2, afterLines.length - j);
55068
+ const header = [`--- a/${relPath}`, `+++ b/${relPath}`];
55069
+ const body = [];
55070
+ const ctxPrefix = Math.max(0, i2 - 3);
55071
+ Math.min(beforeLines.length, beforeLines.length - j + 3);
55072
+ const preCtx = beforeLines.slice(ctxPrefix, i2).map((l) => ` ${l}`);
55073
+ const postCtx = beforeLines.slice(beforeLines.length - j, Math.min(beforeLines.length - j + 3, beforeLines.length)).map((l) => ` ${l}`);
55074
+ const del = oldMid.map((l) => `-${l}`);
55075
+ const add = newMid.map((l) => `+${l}`);
55076
+ body.push(...preCtx);
55077
+ body.push(...del);
55078
+ body.push(...add);
55079
+ body.push(...postCtx);
55080
+ const maxLines = b.diffLines;
55081
+ let sliced = body.slice(0, maxLines);
55082
+ let out = header.concat(sliced).join("\n");
55083
+ if (sliced.length < body.length) out += `
55084
+ [truncated ${body.length - sliced.length} line(s); re-run with higher --diff-lines]`;
55085
+ if (Buffer.byteLength(out, "utf8") > b.diffBytes) {
55086
+ while (sliced.length > 0 && Buffer.byteLength(header.concat(sliced).join("\n"), "utf8") > b.diffBytes) sliced = sliced.slice(0, Math.max(0, sliced.length - 10));
55087
+ out = header.concat(sliced).join("\n") + `
55088
+ [truncated by byte budget]`;
55089
+ }
55090
+ return out;
55091
+ }
55006
55092
  var init_OutputFormatter = __esm({
55007
55093
  "src/services/code-orchestrator/OutputFormatter.ts"() {
55008
55094
  }
@@ -55013,64 +55099,63 @@ async function interactiveApprovePlan(files, opts = {}) {
55013
55099
  if (!process.stdin.isTTY) {
55014
55100
  return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
55015
55101
  }
55016
- const first = await ask(`Approve entire plan? [a=all / q=cancel] `, timeoutMs);
55102
+ const first = await ask(`Approve all [A] / review [r] / cancel [q]: `, timeoutMs);
55017
55103
  if (!first.ok) {
55018
55104
  return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
55019
55105
  }
55020
- const ans1 = (first.line || "").trim().toLowerCase();
55021
- if (ans1 === "q") return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
55022
- if (ans1 === "a" || autoSelect && ans1 === "") return { approveAll: true, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: false };
55106
+ const a1 = (first.line || "").trim().toLowerCase();
55107
+ if (a1 === "q") return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
55108
+ if (a1 === "a" || autoSelect && a1 === "") return { approveAll: true, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: false };
55023
55109
  const approved = /* @__PURE__ */ new Set();
55024
55110
  const skipped = /* @__PURE__ */ new Set();
55025
- for (const f3 of files) {
55026
- const short = `${f3.action} ${f3.path}`;
55027
- const out = await ask(`${short} [a=approve / s=skip / v=view / d=diff / q=cancel] `, timeoutMs);
55111
+ let i2 = 0;
55112
+ const total = files.length;
55113
+ while (i2 >= 0 && i2 < total) {
55114
+ const f3 = files[i2];
55115
+ process.stdout.write(`\rfile ${i2 + 1}/${total}: ${f3.action} ${f3.path}
55116
+ `);
55117
+ const out = await ask(`[n]ext [p]rev [a]pprove [s]kip [v]iew [d]iff [aa] all [ss] skip [q]uit: `, timeoutMs);
55028
55118
  if (!out.ok) {
55029
55119
  console.log("Interactive prompt timed out (15s). Cancelled.");
55030
55120
  return { approveAll: false, approved, skipped, cancelled: true };
55031
55121
  }
55032
55122
  const ans = (out.line || "").trim().toLowerCase();
55033
55123
  if (ans === "q") return { approveAll: false, approved, skipped, cancelled: true };
55124
+ if (ans === "n" || ans === "") {
55125
+ i2++;
55126
+ continue;
55127
+ }
55128
+ if (ans === "p") {
55129
+ i2 = Math.max(0, i2 - 1);
55130
+ continue;
55131
+ }
55132
+ if (ans === "aa") {
55133
+ for (const x2 of files) approved.add(x2.path);
55134
+ break;
55135
+ }
55136
+ if (ans === "ss") {
55137
+ for (const x2 of files) skipped.add(x2.path);
55138
+ break;
55139
+ }
55140
+ if (ans === "a") {
55141
+ approved.add(f3.path);
55142
+ i2++;
55143
+ continue;
55144
+ }
55034
55145
  if (ans === "s") {
55035
55146
  skipped.add(f3.path);
55147
+ i2++;
55036
55148
  continue;
55037
55149
  }
55038
55150
  if (ans === "v") {
55039
- if (f3.preview) console.log(head(f3.preview, 20));
55040
- else console.log("(no preview)");
55041
- const again = await ask(`Approve? [a / s / q] `, timeoutMs);
55042
- if (!again.ok) return { approveAll: false, approved, skipped, cancelled: true };
55043
- const ans2 = (again.line || "").trim().toLowerCase();
55044
- if (ans2 === "q") return { approveAll: false, approved, skipped, cancelled: true };
55045
- if (ans2 === "s") {
55046
- skipped.add(f3.path);
55047
- continue;
55048
- }
55049
- approved.add(f3.path);
55050
- } else if (ans === "d") {
55051
- try {
55052
- const fs45 = await import('fs/promises');
55053
- const p = (opts.root || process.cwd()) + "/" + f3.path;
55054
- const current = await fs45.readFile(p, "utf8").catch(() => "");
55055
- console.log("--- current (head) ---");
55056
- console.log(head(current, 20) || "(file does not exist)");
55057
- console.log("--- proposed (head) ---");
55058
- console.log(head(f3.preview || "", 20) || "(no preview)");
55059
- } catch {
55060
- }
55061
- const again = await ask(`Approve? [a / s / q] `, timeoutMs);
55062
- if (!again.ok) return { approveAll: false, approved, skipped, cancelled: true };
55063
- const ans2 = (again.line || "").trim().toLowerCase();
55064
- if (ans2 === "q") return { approveAll: false, approved, skipped, cancelled: true };
55065
- if (ans2 === "s") {
55066
- skipped.add(f3.path);
55067
- continue;
55068
- }
55069
- approved.add(f3.path);
55070
- } else {
55071
- if (ans === "a" || ans === "") approved.add(f3.path);
55072
- else skipped.add(f3.path);
55151
+ console.log(f3.preview ? head(f3.preview, 20) : "(no preview)");
55152
+ continue;
55073
55153
  }
55154
+ if (ans === "d") {
55155
+ await showHeadDiff(opts.root || process.cwd(), f3.path, f3.preview || "");
55156
+ continue;
55157
+ }
55158
+ i2++;
55074
55159
  }
55075
55160
  return { approveAll: false, approved, skipped, cancelled: false };
55076
55161
  }
@@ -55108,10 +55193,187 @@ function ask(prompt, timeoutMs) {
55108
55193
  function head(s2, n) {
55109
55194
  return s2.split(/\r?\n/).slice(0, n).join("\n");
55110
55195
  }
55196
+ async function showHeadDiff(root, rel, proposal) {
55197
+ try {
55198
+ const fs46 = await import('fs/promises');
55199
+ const p = __require("path").join(root, rel);
55200
+ const current = await fs46.readFile(p, "utf8").catch(() => "");
55201
+ console.log("--- current (head) ---");
55202
+ console.log(head(current, 20) || "(file does not exist)");
55203
+ console.log("--- proposed (head) ---");
55204
+ console.log(head(proposal, 20) || "(no preview)");
55205
+ } catch {
55206
+ }
55207
+ }
55111
55208
  var init_InteractiveController = __esm({
55112
55209
  "src/services/code-orchestrator/InteractiveController.ts"() {
55113
55210
  }
55114
55211
  });
55212
+ async function mapAttachmentsToTargets(attached, opts) {
55213
+ const warnings = [];
55214
+ const mapped = [];
55215
+ const ambiguous = [];
55216
+ const root = path55__namespace.default.resolve(opts.root);
55217
+ const maxN = Math.min(attached.length, Math.max(1, opts.maxAttachments));
55218
+ const pool = attached.slice(0, maxN);
55219
+ if (attached.length > maxN) warnings.push(`Attachments clamped: ${attached.length} \u2192 ${maxN}`);
55220
+ const repoFiles = await listRepoFiles(root);
55221
+ for (const a of pool) {
55222
+ if (!Number.isFinite(a.size) || a.size > PER_FILE_SIZE_CAP) {
55223
+ warnings.push(`Attachment too large (>${PER_FILE_SIZE_CAP} bytes): ${a.originalName}`);
55224
+ continue;
55225
+ }
55226
+ if (looksBinary(a.content, a.mime)) {
55227
+ warnings.push(`Binary/non-text attachment skipped: ${a.originalName}`);
55228
+ continue;
55229
+ }
55230
+ if (a.pathHint) {
55231
+ const safeRel = sanitizeRel(a.pathHint);
55232
+ const full = path55__namespace.default.join(root, safeRel);
55233
+ if (!full.startsWith(root)) {
55234
+ warnings.push(`Path traversal/absolute denied: ${a.pathHint}`);
55235
+ } else if (!opts.allowDotfiles && hasDotSegment(safeRel)) {
55236
+ warnings.push(`Dotfile path denied: ${a.pathHint}`);
55237
+ } else {
55238
+ const exists = repoFiles.has(safeRel);
55239
+ mapped.push({ path: safeRel, exists, reason: "pathHint", attachment: a });
55240
+ continue;
55241
+ }
55242
+ }
55243
+ const name2 = a.originalName.toLowerCase();
55244
+ const matches = Array.from(repoFiles.values()).filter((p) => path55__namespace.default.basename(p).toLowerCase() === name2);
55245
+ if (matches.length === 1) {
55246
+ mapped.push({ path: matches[0], exists: true, reason: "filename", attachment: a });
55247
+ continue;
55248
+ } else if (matches.length > 1) ;
55249
+ const ext2 = extOf(name2);
55250
+ const candidates = Array.from(repoFiles.values()).filter((p) => extOf(p.toLowerCase()) === ext2);
55251
+ let best = null;
55252
+ let second = null;
55253
+ const head2 = headText(a.content, 20);
55254
+ const tail = tailText(a.content, 20);
55255
+ for (const p of candidates.slice(0, 500)) {
55256
+ let score = 0;
55257
+ try {
55258
+ const full = path55__namespace.default.join(root, p);
55259
+ const body = await safeReadHeadTail(full, 20);
55260
+ score = jaccard(tokens(head2), tokens(body.head)) * 0.6 + jaccard(tokens(tail), tokens(body.tail)) * 0.4;
55261
+ } catch {
55262
+ }
55263
+ if (!best || score > best.score) {
55264
+ second = best;
55265
+ best = { p, score };
55266
+ } else if (!second || score > second.score) {
55267
+ second = { p, score };
55268
+ }
55269
+ }
55270
+ if (best && (second ? best.score - second.score >= 0.2 : best.score >= 0.3)) {
55271
+ mapped.push({ path: best.p, exists: true, reason: "fuzzy", attachment: a });
55272
+ continue;
55273
+ }
55274
+ const proposed = proposePath(root, a.originalName);
55275
+ if (!opts.allowDotfiles && hasDotSegment(proposed)) {
55276
+ if (opts.mode === "strict") {
55277
+ warnings.push(`Proposed dotfile denied under strict mode: ${proposed}`);
55278
+ continue;
55279
+ }
55280
+ }
55281
+ if (opts.mode === "strict" && (matches.length > 1 || best && second && best.score - second.score < 0.2)) {
55282
+ ambiguous.push({ attachment: a, candidates: matches, reason: "ambiguous" });
55283
+ continue;
55284
+ }
55285
+ mapped.push({ path: proposed, exists: false, reason: "proposed", attachment: a });
55286
+ }
55287
+ return { mapped, ambiguous, warnings };
55288
+ }
55289
+ function sanitizeRel(rel) {
55290
+ const s2 = rel.replace(/^\/+/, "").replace(/\r|\n/g, "").replace(/\\/g, "/");
55291
+ return s2.replace(/\.\.+/g, "");
55292
+ }
55293
+ function hasDotSegment(p) {
55294
+ return p.split(/\/+|\\+/).some((seg) => seg.startsWith("."));
55295
+ }
55296
+ function looksBinary(content, mime) {
55297
+ if (mime && !/^text\//i.test(mime)) return true;
55298
+ let nul = 0;
55299
+ const len = Math.min(content.length, PER_FILE_SIZE_CAP);
55300
+ for (let i2 = 0; i2 < len; i2++) if (content.charCodeAt(i2) === 0) nul++;
55301
+ return len > 0 && nul / len > 0.1;
55302
+ }
55303
+ async function listRepoFiles(root) {
55304
+ const out = /* @__PURE__ */ new Set();
55305
+ async function walk2(dir, relBase) {
55306
+ let entries = [];
55307
+ try {
55308
+ entries = await fs22.promises.readdir(dir, { withFileTypes: true });
55309
+ } catch {
55310
+ return;
55311
+ }
55312
+ for (const e2 of entries) {
55313
+ const name2 = e2.name;
55314
+ if (name2 === ".git" || name2 === "node_modules" || name2 === "dist" || name2 === ".maria") continue;
55315
+ const full = path55__namespace.default.join(dir, name2);
55316
+ const rel = path55__namespace.default.relative(root, full).replace(/\\/g, "/");
55317
+ if (e2.isDirectory()) {
55318
+ await walk2(full);
55319
+ continue;
55320
+ }
55321
+ out.add(rel);
55322
+ }
55323
+ }
55324
+ await walk2(root);
55325
+ return out;
55326
+ }
55327
+ function extOf(name2) {
55328
+ const i2 = name2.lastIndexOf(".");
55329
+ return i2 >= 0 ? name2.slice(i2 + 1) : "";
55330
+ }
55331
+ function headText(s2, n) {
55332
+ return s2.split(/\r?\n/).slice(0, n).join("\n");
55333
+ }
55334
+ function tailText(s2, n) {
55335
+ const a = s2.split(/\r?\n/);
55336
+ return a.slice(Math.max(0, a.length - n)).join("\n");
55337
+ }
55338
+ async function safeReadHeadTail(full, n) {
55339
+ try {
55340
+ const buf = await fs22.promises.readFile(full, "utf8");
55341
+ return { head: headText(buf, n), tail: tailText(buf, n) };
55342
+ } catch {
55343
+ return { head: "", tail: "" };
55344
+ }
55345
+ }
55346
+ function tokens(s2) {
55347
+ return new Set(s2.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean));
55348
+ }
55349
+ function jaccard(a, b) {
55350
+ if (a.size === 0 && b.size === 0) return 1;
55351
+ let inter = 0;
55352
+ for (const t2 of a) if (b.has(t2)) inter++;
55353
+ const union = a.size + b.size - inter;
55354
+ return union === 0 ? 0 : inter / union;
55355
+ }
55356
+ function proposePath(root, original) {
55357
+ const base = path55__namespace.default.basename(original).replace(/\s+/g, "-").replace(/[^a-zA-Z0-9._-]/g, "").toLowerCase();
55358
+ const src = path55__namespace.default.join(root, "src");
55359
+ const dir = existsSync8(src) ? "src" : "";
55360
+ const rel = dir ? path55__namespace.default.join(dir, base) : base;
55361
+ return rel.replace(/\\/g, "/");
55362
+ }
55363
+ function existsSync8(p) {
55364
+ try {
55365
+ __require("fs").accessSync(p);
55366
+ return true;
55367
+ } catch {
55368
+ return false;
55369
+ }
55370
+ }
55371
+ var PER_FILE_SIZE_CAP;
55372
+ var init_AttachmentMapper = __esm({
55373
+ "src/services/code-orchestrator/AttachmentMapper.ts"() {
55374
+ PER_FILE_SIZE_CAP = 256 * 1024;
55375
+ }
55376
+ });
55115
55377
 
55116
55378
  // src/services/code-orchestrator/Orchestrator.ts
55117
55379
  var Orchestrator_exports = {};
@@ -55120,26 +55382,92 @@ __export(Orchestrator_exports, {
55120
55382
  });
55121
55383
  async function orchestrate(request, opts) {
55122
55384
  const profile = await scanRepo(opts.root);
55123
- const result = process.env.MARIA_E2E_FAKE_CODE === "1" ? { output: "```ts\nexport const demo=1;\n```" } : await executeCode(request);
55124
- const blocks = extractBlocks(result.output || "");
55125
- const initial = blocks.map((b, i2) => ({
55126
- path: suggestName2(request, b.language, i2),
55127
- kind: "source",
55128
- action: "create",
55129
- description: describe2(b.language, ""),
55130
- language: b.language,
55131
- preview: b.code
55132
- }));
55385
+ const initial = [];
55386
+ let attachWarnings = [];
55387
+ if (opts.attachedFiles && opts.attachedFiles.length > 0) {
55388
+ const mapRes = await mapAttachmentsToTargets(opts.attachedFiles, {
55389
+ root: opts.root,
55390
+ mode: opts.flags.attachMode || "assist",
55391
+ maxAttachments: opts.flags.maxAttachments || 50,
55392
+ allowDotfiles: !!opts.flags.allowDotfiles
55393
+ });
55394
+ attachWarnings = mapRes.warnings.slice();
55395
+ for (const m2 of mapRes.mapped) {
55396
+ initial.push({
55397
+ path: m2.path,
55398
+ kind: "source",
55399
+ action: m2.exists ? "modify" : "create",
55400
+ description: m2.exists ? "Modify (attachment)" : "Create (attachment)",
55401
+ preview: m2.attachment.content
55402
+ });
55403
+ }
55404
+ }
55405
+ const onlyAttached = !!opts.flags.onlyAttached;
55406
+ const explicitFiles = parseExplicitFilenames(request);
55407
+ if (!onlyAttached) {
55408
+ const result = process.env.MARIA_E2E_FAKE_CODE === "1" ? { output: "```ts\nexport const demo=1;\n```" } : await executeCode(request);
55409
+ const blocks = extractBlocks(result.output || "");
55410
+ if (explicitFiles.length > 0) {
55411
+ const mapped = /* @__PURE__ */ new Set();
55412
+ const htmlIdx = blocks.findIndex((b) => /html/i.test(b.language));
55413
+ const htmlFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".html"));
55414
+ if (htmlIdx >= 0 && htmlFile) {
55415
+ initial.push({ path: htmlFile, kind: "source", action: "create", description: "HTML page", language: "html", preview: blocks[htmlIdx].code });
55416
+ mapped.add(htmlFile);
55417
+ }
55418
+ const jsIdx = blocks.findIndex((b) => /(ts|tsx|jsx|javascript|js)/i.test(b.language));
55419
+ const jsFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".js"));
55420
+ if (jsIdx >= 0 && jsFile && !mapped.has(jsFile)) {
55421
+ initial.push({ path: jsFile, kind: "source", action: "create", description: "Script", language: "javascript", preview: blocks[jsIdx].code });
55422
+ mapped.add(jsFile);
55423
+ }
55424
+ const cssIdx = blocks.findIndex((b) => /css/i.test(b.language));
55425
+ const cssFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".css"));
55426
+ if (cssIdx >= 0 && cssFile && !mapped.has(cssFile)) {
55427
+ initial.push({ path: cssFile, kind: "source", action: "create", description: "Stylesheet", language: "css", preview: blocks[cssIdx].code });
55428
+ mapped.add(cssFile);
55429
+ }
55430
+ for (const f3 of explicitFiles) {
55431
+ if (mapped.has(f3)) continue;
55432
+ initial.push(scaffoldForFilename(f3, explicitFiles));
55433
+ }
55434
+ } else {
55435
+ for (let i2 = 0; i2 < blocks.length; i2++) {
55436
+ const b = blocks[i2];
55437
+ initial.push({
55438
+ path: suggestName2(request, b.language, i2),
55439
+ kind: "source",
55440
+ action: "create",
55441
+ description: describe2(b.language, ""),
55442
+ language: b.language,
55443
+ preview: b.code
55444
+ });
55445
+ }
55446
+ }
55447
+ }
55448
+ if (explicitFiles.length > 0 && initial.filter((f3) => !!f3.preview).length === 0) {
55449
+ for (const f3 of explicitFiles) {
55450
+ initial.push(scaffoldForFilename(f3, explicitFiles));
55451
+ }
55452
+ }
55133
55453
  const normalized = await normalizePlans(initial, { root: opts.root });
55134
55454
  const validated = await validatePlan(normalized, { root: opts.root, profile, flags: { maxFiles: opts.flags.maxFiles, yes: opts.flags.yes, interactive: !!opts.flags.interactive, ...opts.flags } });
55135
55455
  const outputMode = resolveOutputMode(opts.flags.output, validated.files.length, !!opts.flags.hideCode);
55136
55456
  const summary = summarizePlan(validated.files);
55137
55457
  const lines = [
55138
- formatPlan(summary, { mode: outputMode, previewLines: normalizePreviewLines(opts.flags.previewLines) })
55458
+ formatPlan(summary, {
55459
+ mode: outputMode,
55460
+ previewLines: normalizePreviewLines(opts.flags.previewLines),
55461
+ diffBudget: collectDiffBudget(opts.flags),
55462
+ root: opts.root
55463
+ })
55139
55464
  ];
55140
55465
  if (validated.warnings.length) {
55141
55466
  for (const w of validated.warnings) lines.push(`WARN: ${w}`);
55142
55467
  }
55468
+ if (attachWarnings.length) {
55469
+ for (const w of attachWarnings) lines.push(`WARN: ${w}`);
55470
+ }
55143
55471
  if (opts.flags.planOnly || opts.flags.dryRun || !opts.flags.apply) {
55144
55472
  lines.push("", nextHintForPlan(request));
55145
55473
  return { plan: normalized, validated, summaryLines: lines };
@@ -55161,6 +55489,14 @@ async function orchestrate(request, opts) {
55161
55489
  }
55162
55490
  approved = approved.map((f3) => f3.action === "modify" ? { ...f3, overwritePolicy: "allow" } : f3);
55163
55491
  }
55492
+ const softIssues = scanSoftIssues(approved);
55493
+ if ((softIssues.hasTrailingWhitespace || softIssues.hasConflictMarkers) && !opts.flags.interactive && !opts.flags.yes && opts.flags.apply) {
55494
+ lines.push("");
55495
+ if (softIssues.hasTrailingWhitespace) lines.push(warnLine("Proposed changes contain trailing whitespace"));
55496
+ if (softIssues.hasConflictMarkers) lines.push(warnLine("Proposed changes contain conflict markers"));
55497
+ lines.push("Tip: Re-run with --yes to apply anyway, or use --interactive to review.");
55498
+ return { plan: normalized, validated, summaryLines: lines };
55499
+ }
55164
55500
  let appliedCount = 0;
55165
55501
  let durationMs = 0;
55166
55502
  let rolledBack = false;
@@ -55217,6 +55553,15 @@ function resolveOutputMode(mode, count, hideCode) {
55217
55553
  if (mode) return mode;
55218
55554
  return count >= 5 ? "summary" : "detail";
55219
55555
  }
55556
+ function collectDiffBudget(flags) {
55557
+ return {
55558
+ diffLines: normalizePreviewLines(flags?.diffLines) || void 0,
55559
+ diffBytes: normalizePreviewLines(flags?.diffBytes) || void 0,
55560
+ diffHunks: normalizePreviewLines(flags?.diffHunks) || void 0,
55561
+ globalMaxBytes: typeof flags?.diffGlobalMaxBytes === "number" ? flags.diffGlobalMaxBytes : void 0,
55562
+ globalMaxFiles: typeof flags?.diffGlobalMaxFiles === "number" ? flags.diffGlobalMaxFiles : void 0
55563
+ };
55564
+ }
55220
55565
  function extractBlocks(content) {
55221
55566
  const blocks = [];
55222
55567
  const re = /```(\w*)\n([\s\S]*?)```/g;
@@ -55254,12 +55599,12 @@ function languageExt(lang) {
55254
55599
  }
55255
55600
  async function journalResume(root, request, files) {
55256
55601
  try {
55257
- const fs45 = await import('fs/promises');
55258
- const dir = path54__namespace.default.join(root, ".maria", "memory");
55259
- await fs45.mkdir(dir, { recursive: true });
55260
- const out = path54__namespace.default.join(dir, "resume-plan.json");
55602
+ const fs46 = await import('fs/promises');
55603
+ const dir = path55__namespace.default.join(root, ".maria", "memory");
55604
+ await fs46.mkdir(dir, { recursive: true });
55605
+ const out = path55__namespace.default.join(dir, "resume-plan.json");
55261
55606
  const payload = { request, createdAt: (/* @__PURE__ */ new Date()).toISOString(), files };
55262
- await fs45.writeFile(out, JSON.stringify(payload, null, 2), "utf8");
55607
+ await fs46.writeFile(out, JSON.stringify(payload, null, 2), "utf8");
55263
55608
  } catch {
55264
55609
  }
55265
55610
  }
@@ -55355,6 +55700,72 @@ async function buildAutoTag(prefix) {
55355
55700
  return `${prefix}${Date.now()}`;
55356
55701
  }
55357
55702
  }
55703
+ function scanSoftIssues(files) {
55704
+ let tw = false;
55705
+ let cm = false;
55706
+ for (const f3 of files) {
55707
+ const body = f3.preview || "";
55708
+ if (!tw && /\s+$/.test(body.split(/\r?\n/).find((l) => /\s+$/.test(l)) || "")) tw = true;
55709
+ if (!cm && /(<<<<<<<|=======|>>>>>>>)\s/.test(body)) cm = true;
55710
+ if (tw && cm) break;
55711
+ }
55712
+ return { hasTrailingWhitespace: tw, hasConflictMarkers: cm };
55713
+ }
55714
+ function parseExplicitFilenames(request) {
55715
+ const matches = request.match(/([\w.-]+\.(?:html|css|js|jsx|ts|tsx))/gi);
55716
+ if (!matches) return [];
55717
+ const seen = /* @__PURE__ */ new Set();
55718
+ const out = [];
55719
+ for (const m2 of matches) {
55720
+ const rel = m2.replace(/^\/+/, "").replace(/\r|\n/g, "");
55721
+ if (rel.includes("..")) continue;
55722
+ if (!seen.has(rel)) {
55723
+ seen.add(rel);
55724
+ out.push(rel);
55725
+ }
55726
+ }
55727
+ return out;
55728
+ }
55729
+ function scaffoldForFilename(filename, all) {
55730
+ const lower2 = filename.toLowerCase();
55731
+ if (lower2.endsWith(".html")) {
55732
+ const css = all.find((f3) => f3.toLowerCase().endsWith(".css")) || "style.css";
55733
+ const js = all.find((f3) => f3.toLowerCase().endsWith(".js")) || "script.js";
55734
+ const body = `<!doctype html>
55735
+ <html lang="ja">
55736
+ <head>
55737
+ <meta charset="utf-8"/>
55738
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
55739
+ <title>Pong</title>
55740
+ <link rel="stylesheet" href="${css}">
55741
+ </head>
55742
+ <body>
55743
+ <canvas id="game" width="640" height="480"></canvas>
55744
+ <script src="${js}"></script>
55745
+ </body>
55746
+ </html>
55747
+ `;
55748
+ return { path: filename, kind: "source", action: "create", description: "HTML page", language: "html", preview: body };
55749
+ }
55750
+ if (lower2.endsWith(".css")) {
55751
+ const body = `html,body{margin:0;height:100%;background:#111;color:#eee;font-family:system-ui,sans-serif}
55752
+ #game{display:block;margin:0 auto;background:#000;border:2px solid #444}`;
55753
+ return { path: filename, kind: "source", action: "create", description: "Stylesheet", language: "css", preview: body };
55754
+ }
55755
+ if (lower2.endsWith(".js")) {
55756
+ const body = `// Minimal Pong scaffold
55757
+ const canvas = document.getElementById('game');
55758
+ const ctx = canvas.getContext('2d');
55759
+ let last = 0;
55760
+ const state = { ball:{x:320,y:240,vx:3,vy:2,r:6}, p1:{y:200}, p2:{y:200} };
55761
+ function step(t){ const dt=(t-last)||16; last=t; update(dt); draw(); requestAnimationFrame(step); }
55762
+ function update(dt){ const b=state.ball; b.x+=b.vx; b.y+=b.vy; if(b.y<0||b.y>canvas.height) b.vy*=-1; if(b.x<0||b.x>canvas.width) b.vx*=-1; }
55763
+ function draw(){ ctx.clearRect(0,0,canvas.width,canvas.height); const b=state.ball; ctx.fillStyle='#0f0'; ctx.fillRect(20,state.p1.y,10,80); ctx.fillRect(canvas.width-30,state.p2.y,10,80); ctx.fillStyle='#fff'; ctx.beginPath(); ctx.arc(b.x,b.y,b.r,0,Math.PI*2); ctx.fill(); }
55764
+ requestAnimationFrame(step);`;
55765
+ return { path: filename, kind: "source", action: "create", description: "Script", language: "javascript", preview: body };
55766
+ }
55767
+ return { path: filename, kind: "source", action: "create", description: "Source file", preview: "" };
55768
+ }
55358
55769
  var init_Orchestrator = __esm({
55359
55770
  "src/services/code-orchestrator/Orchestrator.ts"() {
55360
55771
  init_RepoScanner();
@@ -55366,6 +55777,7 @@ var init_Orchestrator = __esm({
55366
55777
  init_api_caller();
55367
55778
  init_AuthenticationManager();
55368
55779
  init_MariaAPIClient();
55780
+ init_AttachmentMapper();
55369
55781
  }
55370
55782
  });
55371
55783
 
@@ -55403,7 +55815,7 @@ var init_code_command = __esm({
55403
55815
  name = "code";
55404
55816
  category = "code";
55405
55817
  description = "Generate code with AI";
55406
- usage = "<request> [--plan-only|--sow] [--apply] [--dry-run] [--interactive] [--yes] [--max-files N] [--root DIR] [--rollback on|off] [--output names|summary|detail] [--no-code] [--preview-lines N]";
55818
+ usage = "<request> [--plan-only|--sow] [--apply] [--dry-run] [--interactive] [--yes] [--max-files N] [--root DIR] [--rollback on|off] [--output names|summary|detail|diff] [--no-code] [--preview-lines N] [--only-attached] [--attach-mode strict|assist] [--max-attachments N] [--diff-lines N] [--diff-bytes N] [--diff-hunks N]";
55407
55819
  aliases = ["c"];
55408
55820
  examples = [
55409
55821
  {
@@ -55426,11 +55838,12 @@ var init_code_command = __esm({
55426
55838
  const opts = this.parseV2Options(commandArgs.raw);
55427
55839
  const root = opts.root || process.cwd();
55428
55840
  const { orchestrate: orchestrate2 } = await Promise.resolve().then(() => (init_Orchestrator(), Orchestrator_exports));
55841
+ const attachments = await this.collectAttachedFiles(context2).catch(() => []);
55429
55842
  const abort = new AbortController();
55430
55843
  const onSigint = () => abort.abort();
55431
55844
  process.once("SIGINT", onSigint);
55432
55845
  try {
55433
- const res = await orchestrate2(request, { root, flags: { planOnly: opts.planOnly, apply: opts.apply, dryRun: opts.dryRun, interactive: opts.interactive, yes: opts.yes, maxFiles: opts.maxFiles, output: opts.output, hideCode: opts.noCode, previewLines: this.normalizePreviewLines(opts.previewLines), verbose: opts.verbose }, abortSignal: abort.signal });
55846
+ const res = await orchestrate2(request, { root, flags: { planOnly: opts.planOnly, apply: opts.apply, dryRun: opts.dryRun, interactive: opts.interactive, yes: opts.yes, maxFiles: opts.maxFiles, output: opts.output, hideCode: opts.noCode, previewLines: this.normalizePreviewLines(opts.previewLines), verbose: opts.verbose, onlyAttached: opts.onlyAttached, attachMode: opts.attachMode, maxAttachments: opts.maxAttachments, diffLines: opts.diffLines, diffBytes: opts.diffBytes, diffHunks: opts.diffHunks, allowDotfiles: opts.allowDotfiles }, abortSignal: abort.signal, attachedFiles: attachments });
55434
55847
  const out = res.summaryLines.join("\n");
55435
55848
  return this.success(out);
55436
55849
  } finally {
@@ -55479,7 +55892,7 @@ ${pretty}`);
55479
55892
  }
55480
55893
  // v2.0 helpers
55481
55894
  parseV2Options(raw) {
55482
- const opts = { planOnly: false, apply: false, dryRun: false, interactive: false, yes: false, rollback: true, output: void 0, noCode: false, previewLines: 0, root: void 0, maxFiles: void 0, verbose: false, gitGuard: void 0, allowDotfiles: false, confirmOverwrites: [], gitCommit: void 0, gitBranch: void 0, gitTag: void 0, gitTagPrefix: void 0, gitPush: void 0, gitPushRemote: void 0 };
55895
+ const opts = { planOnly: false, apply: false, dryRun: false, interactive: false, yes: false, rollback: true, output: void 0, noCode: false, previewLines: 0, root: void 0, maxFiles: void 0, verbose: false, gitGuard: void 0, allowDotfiles: false, confirmOverwrites: [], gitCommit: void 0, gitBranch: void 0, gitTag: void 0, gitTagPrefix: void 0, gitPush: void 0, gitPushRemote: void 0, onlyAttached: false, attachMode: "assist", maxAttachments: 50, diffLines: void 0, diffBytes: void 0, diffHunks: void 0 };
55483
55896
  const a = raw.slice();
55484
55897
  while (a.length) {
55485
55898
  const x2 = a.shift();
@@ -55534,6 +55947,26 @@ ${pretty}`);
55534
55947
  case "allow-dotfiles":
55535
55948
  opts.allowDotfiles = true;
55536
55949
  break;
55950
+ case "only-attached":
55951
+ opts.onlyAttached = true;
55952
+ break;
55953
+ case "attach-mode": {
55954
+ const val = (v || a.shift() || "").toLowerCase();
55955
+ opts.attachMode = val === "strict" || val === "assist" ? val : "assist";
55956
+ break;
55957
+ }
55958
+ case "max-attachments":
55959
+ opts.maxAttachments = Number(v || a.shift());
55960
+ break;
55961
+ case "diff-lines":
55962
+ opts.diffLines = Number(v || a.shift());
55963
+ break;
55964
+ case "diff-bytes":
55965
+ opts.diffBytes = Number(v || a.shift());
55966
+ break;
55967
+ case "diff-hunks":
55968
+ opts.diffHunks = Number(v || a.shift());
55969
+ break;
55537
55970
  case "confirm-overwrites": {
55538
55971
  const list = (v || a.shift() || "").split(",").map((s2) => s2.trim()).filter(Boolean);
55539
55972
  opts.confirmOverwrites = list;
@@ -55595,7 +56028,7 @@ ${pretty}`);
55595
56028
  const { normalizePlans: normalizePlans2 } = await Promise.resolve().then(() => (init_FilePlanBuilder(), FilePlanBuilder_exports));
55596
56029
  const normalized = await normalizePlans2(plans, { root });
55597
56030
  for (const p of normalized) {
55598
- const exists = await this.pathExists(path54__namespace.join(root, p.path));
56031
+ const exists = await this.pathExists(path55__namespace.join(root, p.path));
55599
56032
  p.action = exists ? "modify" : "create";
55600
56033
  }
55601
56034
  return normalized;
@@ -55610,16 +56043,16 @@ ${pretty}`);
55610
56043
  }
55611
56044
  async persistLastPlan(root, plans) {
55612
56045
  try {
55613
- const fs45 = await import('fs/promises');
55614
- const p = path54__namespace.join(root, ".maria");
55615
- await fs45.mkdir(p, { recursive: true });
55616
- const out = path54__namespace.join(p, "last-plan.json");
55617
- await fs45.writeFile(out, JSON.stringify({ createdAt: (/* @__PURE__ */ new Date()).toISOString(), plans }, null, 2), "utf8");
56046
+ const fs46 = await import('fs/promises');
56047
+ const p = path55__namespace.join(root, ".maria");
56048
+ await fs46.mkdir(p, { recursive: true });
56049
+ const out = path55__namespace.join(p, "last-plan.json");
56050
+ await fs46.writeFile(out, JSON.stringify({ createdAt: (/* @__PURE__ */ new Date()).toISOString(), plans }, null, 2), "utf8");
55618
56051
  } catch {
55619
56052
  }
55620
56053
  }
55621
56054
  async applyPlan(plans, options) {
55622
- const fs45 = await import('fs/promises');
56055
+ const fs46 = await import('fs/promises');
55623
56056
  const created = [];
55624
56057
  const modified = [];
55625
56058
  const skipped = [];
@@ -55629,7 +56062,7 @@ ${pretty}`);
55629
56062
  try {
55630
56063
  for (const plan of plans) {
55631
56064
  if (options.signal?.aborted) throw new Error("INTERRUPTED");
55632
- const full = path54__namespace.join(options.root, plan.path);
56065
+ const full = path55__namespace.join(options.root, plan.path);
55633
56066
  const exists = await this.pathExists(full);
55634
56067
  if (exists && !options.overwriteAllowed) {
55635
56068
  skipped.push(plan.path);
@@ -55638,9 +56071,9 @@ ${pretty}`);
55638
56071
  continue;
55639
56072
  }
55640
56073
  const tmp = full + `.tmp-${process.pid}-${Date.now()}`;
55641
- await fs45.mkdir(path54__namespace.dirname(full), { recursive: true });
55642
- await fs45.writeFile(tmp, plan.preview || "", "utf8");
55643
- await fs45.rename(tmp, full);
56074
+ await fs46.mkdir(path55__namespace.dirname(full), { recursive: true });
56075
+ await fs46.writeFile(tmp, plan.preview || "", "utf8");
56076
+ await fs46.rename(tmp, full);
55644
56077
  if (exists) modified.push(plan.path);
55645
56078
  else created.push(plan.path);
55646
56079
  written++;
@@ -55651,7 +56084,7 @@ ${pretty}`);
55651
56084
  if (options.rollback) {
55652
56085
  for (const p of [...created, ...modified]) {
55653
56086
  try {
55654
- await fs45.unlink(path54__namespace.join(options.root, p));
56087
+ await fs46.unlink(path55__namespace.join(options.root, p));
55655
56088
  } catch {
55656
56089
  }
55657
56090
  }
@@ -55661,8 +56094,8 @@ ${pretty}`);
55661
56094
  }
55662
56095
  async pathExists(p) {
55663
56096
  try {
55664
- const fs45 = await import('fs/promises');
55665
- await fs45.access(p);
56097
+ const fs46 = await import('fs/promises');
56098
+ await fs46.access(p);
55666
56099
  return true;
55667
56100
  } catch {
55668
56101
  return false;
@@ -55731,13 +56164,13 @@ ${pretty}`);
55731
56164
  const extension = LANGUAGE_EXTENSIONS[block.language] || ".txt";
55732
56165
  const timestamp = Date.now().toString(36);
55733
56166
  const filename = index === 0 ? `${baseName}${extension}` : `${baseName}_${index + 1}${extension}`;
55734
- const fullPath = path54__namespace.join(process.cwd(), filename);
56167
+ const fullPath = path55__namespace.join(process.cwd(), filename);
55735
56168
  try {
55736
56169
  await fsp.writeFile(fullPath, block.code, "utf8");
55737
56170
  return fullPath;
55738
56171
  } catch (error2) {
55739
56172
  const fallbackName = `code_${timestamp}${extension}`;
55740
- const fallbackPath = path54__namespace.join(process.cwd(), fallbackName);
56173
+ const fallbackPath = path55__namespace.join(process.cwd(), fallbackName);
55741
56174
  await fsp.writeFile(fallbackPath, block.code, "utf8");
55742
56175
  return fallbackPath;
55743
56176
  }
@@ -55767,6 +56200,28 @@ ${pretty}`);
55767
56200
  }
55768
56201
  return null;
55769
56202
  }
56203
+ // Attempt to collect attached files from context; map to AttachedFileContext
56204
+ async collectAttachedFiles(context2) {
56205
+ const list = [];
56206
+ const fs46 = await import('fs/promises');
56207
+ const path56 = await import('path');
56208
+ const att = context2 && (context2.attachments || context2.input?.attachments) || [];
56209
+ for (const a of att) {
56210
+ try {
56211
+ const p = a.path || a.filePath || a.name || "";
56212
+ const originalName = a.name || path56.basename(p || `attachment_${Date.now().toString(36)}`);
56213
+ let content = a.content;
56214
+ if (!content && p) {
56215
+ const abs = path56.isAbsolute(p) ? p : path56.join(process.cwd(), p);
56216
+ content = await fs46.readFile(abs, "utf8");
56217
+ }
56218
+ if (!content) continue;
56219
+ list.push({ originalName, pathHint: p || void 0, content, size: Buffer.byteLength(content, "utf8"), mime: a.mime || a.type });
56220
+ } catch {
56221
+ }
56222
+ }
56223
+ return list;
56224
+ }
55770
56225
  };
55771
56226
  codeCommand = new CodeCommand();
55772
56227
  metadata4 = {
@@ -55867,7 +56322,7 @@ function getKnowledgeProviderFromEnv(root = process.cwd()) {
55867
56322
  function safeListFiles(dir) {
55868
56323
  try {
55869
56324
  return fs22__namespace.default.readdirSync(dir, { withFileTypes: true }).flatMap((d) => {
55870
- const p = path54__namespace.default.join(dir, d.name);
56325
+ const p = path55__namespace.default.join(dir, d.name);
55871
56326
  if (d.isDirectory()) {
55872
56327
  if (/node_modules|\.git|dist|coverage|artifacts|reports/.test(p)) return [];
55873
56328
  return safeListFiles(p);
@@ -55903,7 +56358,7 @@ var init_KnowledgeProvider = __esm({
55903
56358
  }
55904
56359
  async getPrinciples(_projectId, _taskId) {
55905
56360
  const candidates = [
55906
- path54__namespace.default.join(this.root, "docs"),
56361
+ path55__namespace.default.join(this.root, "docs"),
55907
56362
  this.root
55908
56363
  ];
55909
56364
  const out = [];
@@ -55965,7 +56420,7 @@ function promptLine(timeoutMs = 15e3) {
55965
56420
  }
55966
56421
  async function readLastDebugStatusSafe(cwd2) {
55967
56422
  try {
55968
- const p = path54__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
56423
+ const p = path55__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
55969
56424
  const buf = await fsp__namespace.readFile(p, "utf8");
55970
56425
  const arr = JSON.parse(buf);
55971
56426
  if (Array.isArray(arr) && arr.length) return arr[arr.length - 1];
@@ -55976,7 +56431,7 @@ async function readLastDebugStatusSafe(cwd2) {
55976
56431
  }
55977
56432
  async function readDebugJournalListSafe(cwd2, count) {
55978
56433
  try {
55979
- const p = path54__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
56434
+ const p = path55__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
55980
56435
  const buf = await fsp__namespace.readFile(p, "utf8");
55981
56436
  const arr = JSON.parse(buf);
55982
56437
  if (!Array.isArray(arr) || arr.length === 0) return [];
@@ -56271,11 +56726,11 @@ async function runWithBudget(tasks, totalMs = 6e3, perStepMs = 600) {
56271
56726
  return out;
56272
56727
  }
56273
56728
  function isSensitive(filepath) {
56274
- const basename15 = path54__namespace.basename(filepath);
56729
+ const basename15 = path55__namespace.basename(filepath);
56275
56730
  return SENSITIVE_PATTERNS2.some((pattern) => pattern.test(basename15) || pattern.test(filepath));
56276
56731
  }
56277
56732
  function isBinary(filepath) {
56278
- const ext2 = path54__namespace.extname(filepath).toLowerCase();
56733
+ const ext2 = path55__namespace.extname(filepath).toLowerCase();
56279
56734
  return BINARY_EXTENSIONS.has(ext2);
56280
56735
  }
56281
56736
  async function safeRead(file, maxBytes = 512 * 1024, maxLines = 200, signal) {
@@ -56331,7 +56786,7 @@ async function scanRoot(opts) {
56331
56786
  ];
56332
56787
  for (const { name: name2, maxLines } of rootFiles) {
56333
56788
  if (signal.aborted || remainMs() < 100) break;
56334
- const filepath = path54__namespace.join(cwd2, name2);
56789
+ const filepath = path55__namespace.join(cwd2, name2);
56335
56790
  const result = await safeRead(filepath, 512 * 1024, maxLines, signal);
56336
56791
  if (result.head || result.meta) {
56337
56792
  let meta24 = result.meta || object;
@@ -56387,7 +56842,7 @@ async function scanBuild(opts) {
56387
56842
  ];
56388
56843
  for (const name2 of buildFiles) {
56389
56844
  if (signal.aborted || remainMs() < 100) break;
56390
- const filepath = path54__namespace.join(cwd2, name2);
56845
+ const filepath = path55__namespace.join(cwd2, name2);
56391
56846
  const result = await safeRead(filepath, 512 * 1024, 100, signal);
56392
56847
  if (result.head || result.meta) {
56393
56848
  findings.push({
@@ -56424,7 +56879,7 @@ async function scanQuality(opts) {
56424
56879
  ];
56425
56880
  for (const name2 of qualityFiles) {
56426
56881
  if (signal.aborted || remainMs() < 100) break;
56427
- const filepath = path54__namespace.join(cwd2, name2);
56882
+ const filepath = path55__namespace.join(cwd2, name2);
56428
56883
  const result = await safeRead(filepath, 512 * 1024, 50, signal);
56429
56884
  if (result.head || result.meta) {
56430
56885
  findings.push({
@@ -56469,7 +56924,7 @@ async function scanScripts(opts) {
56469
56924
  const sample = files.slice(0, 5);
56470
56925
  for (const file of sample) {
56471
56926
  if (signal.aborted || remainMs() < 100) break;
56472
- const result = await safeRead(path54__namespace.join(cwd2, file), 512 * 1024, 100, signal);
56927
+ const result = await safeRead(path55__namespace.join(cwd2, file), 512 * 1024, 100, signal);
56473
56928
  if (result.head || result.meta) {
56474
56929
  findings.push({
56475
56930
  file,
@@ -56511,7 +56966,7 @@ async function scanEntries(opts) {
56511
56966
  ];
56512
56967
  for (const name2 of entryFiles) {
56513
56968
  if (signal.aborted || remainMs() < 100) break;
56514
- const filepath = path54__namespace.join(cwd2, name2);
56969
+ const filepath = path55__namespace.join(cwd2, name2);
56515
56970
  const result = await safeRead(filepath, 512 * 1024, 80, signal);
56516
56971
  if (result.head || result.meta) {
56517
56972
  findings.push({
@@ -56592,9 +57047,9 @@ function checkBinAlignment(pkg, cwd2) {
56592
57047
  const bin = typeof pkg.bin === "string" ? { [pkg.name]: pkg.bin } : pkg.bin;
56593
57048
  for (const [name2, rel] of Object.entries(bin)) {
56594
57049
  const binPath = rel;
56595
- const srcPath = path54__namespace.join(cwd2, binPath);
57050
+ const srcPath = path55__namespace.join(cwd2, binPath);
56596
57051
  if (!fs22__namespace.existsSync(srcPath)) {
56597
- const distGuess = path54__namespace.join(
57052
+ const distGuess = path55__namespace.join(
56598
57053
  cwd2,
56599
57054
  "dist",
56600
57055
  binPath.replace(/^src\//, "").replace(/^bin\//, "bin/")
@@ -57103,7 +57558,7 @@ async function detectMonorepoType(root) {
57103
57558
  const files = await fsp__namespace.readdir(root);
57104
57559
  if (files.includes("package.json")) {
57105
57560
  const pkg = JSON.parse(
57106
- await fsp__namespace.readFile(path54__namespace.join(root, "package.json"), "utf8")
57561
+ await fsp__namespace.readFile(path55__namespace.join(root, "package.json"), "utf8")
57107
57562
  );
57108
57563
  if (pkg.workspaces) {
57109
57564
  if (files.includes("pnpm-workspace.yaml")) return "pnpm";
@@ -57126,7 +57581,7 @@ async function findWorkspaces(root, type) {
57126
57581
  try {
57127
57582
  switch (type) {
57128
57583
  case "pnpm": {
57129
- const wsFile = path54__namespace.join(root, "pnpm-workspace.yaml");
57584
+ const wsFile = path55__namespace.join(root, "pnpm-workspace.yaml");
57130
57585
  try {
57131
57586
  const content = await fsp__namespace.readFile(wsFile, "utf8");
57132
57587
  const patterns = content.match(/packages:\s*\n((?:\s+-\s+.+\n?)+)/);
@@ -57148,7 +57603,7 @@ async function findWorkspaces(root, type) {
57148
57603
  }
57149
57604
  case "yarn":
57150
57605
  case "npm": {
57151
- const pkgPath = path54__namespace.join(root, "package.json");
57606
+ const pkgPath = path55__namespace.join(root, "package.json");
57152
57607
  try {
57153
57608
  const pkg = JSON.parse(await fsp__namespace.readFile(pkgPath, "utf8"));
57154
57609
  const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages || [];
@@ -57167,7 +57622,7 @@ async function findWorkspaces(root, type) {
57167
57622
  }
57168
57623
  case "lerna": {
57169
57624
  try {
57170
- const lernaPath = path54__namespace.join(root, "lerna.json");
57625
+ const lernaPath = path55__namespace.join(root, "lerna.json");
57171
57626
  const lerna = JSON.parse(await fsp__namespace.readFile(lernaPath, "utf8"));
57172
57627
  const patterns = lerna.packages || ["packages/*"];
57173
57628
  for (const pattern of patterns) {
@@ -57226,13 +57681,13 @@ async function findWorkspaces(root, type) {
57226
57681
  }
57227
57682
  async function analyzeWorkspace(workspacePath, root) {
57228
57683
  const info = {
57229
- name: path54__namespace.basename(workspacePath),
57684
+ name: path55__namespace.basename(workspacePath),
57230
57685
  path: workspacePath,
57231
57686
  type: "unknown",
57232
57687
  language: "unknown"
57233
57688
  };
57234
57689
  try {
57235
- const pkgPath = path54__namespace.join(root, workspacePath, "package.json");
57690
+ const pkgPath = path55__namespace.join(root, workspacePath, "package.json");
57236
57691
  const pkgContent = await safeRead(pkgPath, 512 * 1024, 1e3);
57237
57692
  if (pkgContent.head) {
57238
57693
  try {
@@ -57275,7 +57730,7 @@ async function analyzeWorkspace(workspacePath, root) {
57275
57730
  }
57276
57731
  const globby = await loadGlobby();
57277
57732
  const files = await globby(["**/*.{ts,tsx,js,jsx,mjs,cjs}"], {
57278
- cwd: path54__namespace.join(root, workspacePath),
57733
+ cwd: path55__namespace.join(root, workspacePath),
57279
57734
  deep: 2,
57280
57735
  ignore: ["node_modules", "dist", "build"],
57281
57736
  stats: false
@@ -57830,12 +58285,12 @@ function getModuleName(filePath) {
57830
58285
  if (srcIndex >= 0 && srcIndex < parts.length - 1) {
57831
58286
  return parts[srcIndex + 1];
57832
58287
  }
57833
- return path54__namespace.dirname(filePath).split("/").pop() || "root";
58288
+ return path55__namespace.dirname(filePath).split("/").pop() || "root";
57834
58289
  }
57835
58290
  function resolveLocalImport(fromFile2, importPath) {
57836
58291
  if (!importPath.startsWith(".")) return null;
57837
- const dir = path54__namespace.dirname(fromFile2);
57838
- const resolved = path54__namespace.resolve(dir, importPath);
58292
+ const dir = path55__namespace.dirname(fromFile2);
58293
+ const resolved = path55__namespace.resolve(dir, importPath);
57839
58294
  return getModuleName(resolved);
57840
58295
  }
57841
58296
  function getMetricStatus(metric, value) {
@@ -57965,7 +58420,7 @@ async function extractCodeSnippets(files, projectRoot, maxSnippets, includeExamp
57965
58420
  }
57966
58421
  async function extractFileSnippet(file, projectRoot, category) {
57967
58422
  try {
57968
- const fullPath = path54__namespace.join(projectRoot, file.path);
58423
+ const fullPath = path55__namespace.join(projectRoot, file.path);
57969
58424
  const content = await safeRead(fullPath, 512 * 1024, 50);
57970
58425
  if (!content.head) return null;
57971
58426
  const lines = content.head.split("\n");
@@ -57976,7 +58431,7 @@ async function extractFileSnippet(file, projectRoot, category) {
57976
58431
  const codeLines = lines.slice(codeStart, codeStart + 30);
57977
58432
  return {
57978
58433
  file: file.path,
57979
- title: `${path54__namespace.basename(file.path)} - ${category}`,
58434
+ title: `${path55__namespace.basename(file.path)} - ${category}`,
57980
58435
  description: getFileDescription(file),
57981
58436
  code: codeLines.join("\n"),
57982
58437
  language: file.language || "javascript",
@@ -58064,7 +58519,7 @@ function extractAPIDocumentation(files) {
58064
58519
  async function extractConfigurationDetails(projectRoot) {
58065
58520
  const details = [];
58066
58521
  try {
58067
- const pkgPath = path54__namespace.join(projectRoot, "package.json");
58522
+ const pkgPath = path55__namespace.join(projectRoot, "package.json");
58068
58523
  const pkgContent = await fsp__namespace.readFile(pkgPath, "utf8");
58069
58524
  const pkg = JSON.parse(pkgContent);
58070
58525
  if (pkg.engines) {
@@ -58097,7 +58552,7 @@ async function extractConfigurationDetails(projectRoot) {
58097
58552
  } catch {
58098
58553
  }
58099
58554
  try {
58100
- const tsconfigPath = path54__namespace.join(projectRoot, "tsconfig.json");
58555
+ const tsconfigPath = path55__namespace.join(projectRoot, "tsconfig.json");
58101
58556
  const tsconfigContent = await fsp__namespace.readFile(tsconfigPath, "utf8");
58102
58557
  const tsconfig = JSON.parse(tsconfigContent);
58103
58558
  if (tsconfig.compilerOptions?.strict !== void 0) {
@@ -58121,7 +58576,7 @@ async function extractConfigurationDetails(projectRoot) {
58121
58576
  } catch {
58122
58577
  }
58123
58578
  try {
58124
- const envExamplePath = path54__namespace.join(projectRoot, ".env.example");
58579
+ const envExamplePath = path55__namespace.join(projectRoot, ".env.example");
58125
58580
  const envContent = await fsp__namespace.readFile(envExamplePath, "utf8");
58126
58581
  const envVars = envContent.match(/^[A-Z_]+=/gm);
58127
58582
  if (envVars) {
@@ -59059,7 +59514,7 @@ function generateFooter3(data) {
59059
59514
  }
59060
59515
  function generateFallbackMariaMd(error2, projectPath) {
59061
59516
  const data = {
59062
- projectName: path54__namespace.basename(projectPath),
59517
+ projectName: path55__namespace.basename(projectPath),
59063
59518
  projectPath,
59064
59519
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
59065
59520
  errors: [error2.message]
@@ -59074,13 +59529,13 @@ var init_maria_template = __esm({
59074
59529
  });
59075
59530
  async function writeAtomic(filePath, content, options = {}) {
59076
59531
  const { encoding = "utf8", mode = 420, fsync = true, tmpDir } = options;
59077
- const dir = path54__namespace.dirname(filePath);
59078
- const basename15 = path54__namespace.basename(filePath);
59532
+ const dir = path55__namespace.dirname(filePath);
59533
+ const basename15 = path55__namespace.basename(filePath);
59079
59534
  const tmpSuffix = `.tmp-${Date.now()}-${crypto6.randomBytes(4).toString("hex")}`;
59080
- const tmpPath = tmpDir ? path54__namespace.join(tmpDir, `${basename15}${tmpSuffix}`) : path54__namespace.join(dir, `${basename15}${tmpSuffix}`);
59535
+ const tmpPath = tmpDir ? path55__namespace.join(tmpDir, `${basename15}${tmpSuffix}`) : path55__namespace.join(dir, `${basename15}${tmpSuffix}`);
59081
59536
  let fileHandle = null;
59082
59537
  try {
59083
- await fsp__namespace.mkdir(path54__namespace.dirname(tmpPath), { recursive: true });
59538
+ await fsp__namespace.mkdir(path55__namespace.dirname(tmpPath), { recursive: true });
59084
59539
  if (Buffer.isBuffer(content)) {
59085
59540
  await fsp__namespace.writeFile(tmpPath, content, { mode });
59086
59541
  } else {
@@ -59800,13 +60255,13 @@ var init_initialization_manager = __esm({
59800
60255
  if (!stats.isDirectory()) {
59801
60256
  this.errors.push(`Working directory is not a directory: ${cwd2}`);
59802
60257
  }
59803
- const packagePath = path54__namespace.join(cwd2, "package.json");
60258
+ const packagePath = path55__namespace.join(cwd2, "package.json");
59804
60259
  try {
59805
60260
  await fsp__namespace.access(packagePath);
59806
60261
  } catch {
59807
60262
  this.warnings.push("No package.json found in working directory");
59808
60263
  }
59809
- const gitPath = path54__namespace.join(cwd2, ".git");
60264
+ const gitPath = path55__namespace.join(cwd2, ".git");
59810
60265
  try {
59811
60266
  await fsp__namespace.access(gitPath);
59812
60267
  } catch {
@@ -59858,7 +60313,7 @@ var init_initialization_manager = __esm({
59858
60313
  }
59859
60314
  async validateMonorepoConfig(cwd2) {
59860
60315
  try {
59861
- const packagePath = path54__namespace.join(cwd2, "package.json");
60316
+ const packagePath = path55__namespace.join(cwd2, "package.json");
59862
60317
  const content = await fsp__namespace.readFile(packagePath, "utf-8");
59863
60318
  const pkg = JSON.parse(content);
59864
60319
  if (pkg.workspaces) {
@@ -60248,7 +60703,7 @@ var init_initialization_manager = __esm({
60248
60703
  async generateEnhancedMariaMd(summary, opts) {
60249
60704
  try {
60250
60705
  return generateMariaMd2({
60251
- projectName: summary.projectName || path54__namespace.basename(opts.cwd || process.cwd()),
60706
+ projectName: summary.projectName || path55__namespace.basename(opts.cwd || process.cwd()),
60252
60707
  projectPath: opts.cwd || process.cwd(),
60253
60708
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
60254
60709
  summary,
@@ -60269,7 +60724,7 @@ var init_initialization_manager = __esm({
60269
60724
  const cwd2 = opts.cwd || process.cwd();
60270
60725
  for (const [filename, content] of Object.entries(artifacts)) {
60271
60726
  if (typeof content === "string") {
60272
- const filePath = path54__namespace.join(cwd2, filename);
60727
+ const filePath = path55__namespace.join(cwd2, filename);
60273
60728
  try {
60274
60729
  await writeAtomic(filePath, content);
60275
60730
  this.progressTracker.addMetric(
@@ -60294,7 +60749,7 @@ var init_initialization_manager = __esm({
60294
60749
  */
60295
60750
  async verifyOutput(opts) {
60296
60751
  const cwd2 = opts.cwd || process.cwd();
60297
- const mariaMdPath = path54__namespace.join(cwd2, "MARIA.md");
60752
+ const mariaMdPath = path55__namespace.join(cwd2, "MARIA.md");
60298
60753
  try {
60299
60754
  const content = await fsp__namespace.readFile(mariaMdPath, "utf-8");
60300
60755
  const minLength = 2e3;
@@ -60327,7 +60782,7 @@ var init_initialization_manager = __esm({
60327
60782
  createMinimalSummary(opts) {
60328
60783
  const cwd2 = opts.cwd || process.cwd();
60329
60784
  return {
60330
- projectName: path54__namespace.basename(cwd2),
60785
+ projectName: path55__namespace.basename(cwd2),
60331
60786
  projectPath: cwd2,
60332
60787
  description: "Project analysis incomplete due to errors",
60333
60788
  techStack: {
@@ -60362,7 +60817,7 @@ var init_initialization_manager = __esm({
60362
60817
  */
60363
60818
  async generateFallbackArtifacts(error2, opts) {
60364
60819
  const cwd2 = opts.cwd || process.cwd();
60365
- path54__namespace.basename(cwd2);
60820
+ path55__namespace.basename(cwd2);
60366
60821
  const mariaMd = generateFallbackMariaMd({
60367
60822
  });
60368
60823
  const initReport = `# Init Report - Error Recovery Mode
@@ -60419,7 +60874,7 @@ async function safeBackup(_filePath) {
60419
60874
  await fsp__namespace.copyFile(_filePath, bakPath);
60420
60875
  if (!process.env.MARIA_INIT_QUIET) {
60421
60876
  console.log(
60422
- chalk36__default.default.gray(` \u21B3 backup: ${path54__namespace.relative(process.cwd(), bakPath)}`)
60877
+ chalk36__default.default.gray(` \u21B3 backup: ${path55__namespace.relative(process.cwd(), bakPath)}`)
60423
60878
  );
60424
60879
  }
60425
60880
  } catch {
@@ -60457,7 +60912,7 @@ async function writeArtifacts(artifacts, opts, cwd2, reporter) {
60457
60912
  { name: "INIT_SUMMARY.txt", content: artifacts.initSummaryTxt }
60458
60913
  ];
60459
60914
  for (const { name: name2, content } of files) {
60460
- const _filePath = path54__namespace.join(cwd2, name2);
60915
+ const _filePath = path55__namespace.join(cwd2, name2);
60461
60916
  if (await fileExists2(_filePath) && !opts.force) {
60462
60917
  await safeBackup(_filePath);
60463
60918
  }
@@ -60567,7 +61022,7 @@ This process will:
60567
61022
  );
60568
61023
  const artifacts = generateArtifacts(summary, findings, startTime);
60569
61024
  const mariaMdContent = generateMariaMd2({
60570
- projectName: summary.projectName || path54__namespace.basename(cwd2),
61025
+ projectName: summary.projectName || path55__namespace.basename(cwd2),
60571
61026
  projectPath: cwd2,
60572
61027
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
60573
61028
  summary,
@@ -60727,7 +61182,7 @@ var init_delta_detector = __esm({
60727
61182
  const changes = stdout2.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => {
60728
61183
  const [status, ...rest] = line.split(/\s+/);
60729
61184
  const file = rest.join(" ");
60730
- return { status, file: path54__namespace.resolve(root, file) };
61185
+ return { status, file: path55__namespace.resolve(root, file) };
60731
61186
  });
60732
61187
  const filtered = await this.filterFiles(
60733
61188
  changes.map((c) => c.file),
@@ -60736,8 +61191,8 @@ var init_delta_detector = __esm({
60736
61191
  );
60737
61192
  const filteredSet = new Set(filtered);
60738
61193
  const filteredChanges = changes.filter((c) => filteredSet.has(c.file));
60739
- const deleted = filteredChanges.filter((c) => c.status === "D").map((c) => path54__namespace.relative(root, c.file));
60740
- const changed = filteredChanges.filter((c) => c.status !== "D").map((c) => path54__namespace.relative(root, c.file));
61194
+ const deleted = filteredChanges.filter((c) => c.status === "D").map((c) => path55__namespace.relative(root, c.file));
61195
+ const changed = filteredChanges.filter((c) => c.status !== "D").map((c) => path55__namespace.relative(root, c.file));
60741
61196
  return {
60742
61197
  mode: "git",
60743
61198
  ref,
@@ -60769,7 +61224,7 @@ var init_delta_detector = __esm({
60769
61224
  break;
60770
61225
  }
60771
61226
  if (entry.mtime && entry.mtime > since) {
60772
- changed.push(path54__namespace.relative(root, entry.file));
61227
+ changed.push(path55__namespace.relative(root, entry.file));
60773
61228
  }
60774
61229
  if (options.maxFiles && changed.length >= options.maxFiles) {
60775
61230
  break;
@@ -60793,7 +61248,7 @@ var init_delta_detector = __esm({
60793
61248
  * Detect changes by comparing with state.json
60794
61249
  */
60795
61250
  async detectByState(root, options) {
60796
- const statePath = path54__namespace.join(root, ".maria", "state.json");
61251
+ const statePath = path55__namespace.join(root, ".maria", "state.json");
60797
61252
  let lastHashes = {};
60798
61253
  try {
60799
61254
  const stateContent = await fsp__namespace.readFile(statePath, "utf-8");
@@ -60809,7 +61264,7 @@ var init_delta_detector = __esm({
60809
61264
  if (options.budgetMs && Date.now() - this.startTime > options.budgetMs) {
60810
61265
  break;
60811
61266
  }
60812
- const relativePath = path54__namespace.relative(root, entry.file);
61267
+ const relativePath = path55__namespace.relative(root, entry.file);
60813
61268
  const hash = entry.hash || await this.hashFile(entry.file);
60814
61269
  nowHashes[relativePath] = hash;
60815
61270
  if (!lastHashes[relativePath] || lastHashes[relativePath] !== hash) {
@@ -60889,7 +61344,7 @@ var init_delta_detector = __esm({
60889
61344
  }
60890
61345
  const patterns = options.include || ["**/*"];
60891
61346
  const ignore = options.exclude || [];
60892
- const relativePaths = files.map((f3) => path54__namespace.relative(root, f3));
61347
+ const relativePaths = files.map((f3) => path55__namespace.relative(root, f3));
60893
61348
  const globby = await loadGlobby();
60894
61349
  const matched = await globby(patterns, {
60895
61350
  cwd: root,
@@ -60914,8 +61369,8 @@ var init_delta_detector = __esm({
60914
61369
  * Update state.json with new hashes
60915
61370
  */
60916
61371
  async updateState(root, delta) {
60917
- const statePath = path54__namespace.join(root, ".maria", "state.json");
60918
- await fsp__namespace.mkdir(path54__namespace.dirname(statePath), { recursive: true });
61372
+ const statePath = path55__namespace.join(root, ".maria", "state.json");
61373
+ await fsp__namespace.mkdir(path55__namespace.dirname(statePath), { recursive: true });
60919
61374
  let state;
60920
61375
  try {
60921
61376
  const content = await fsp__namespace.readFile(statePath, "utf-8");
@@ -60940,7 +61395,7 @@ var init_delta_detector = __esm({
60940
61395
  delete currentHashes[file];
60941
61396
  });
60942
61397
  for (const file of delta.changed) {
60943
- const fullPath = path54__namespace.join(root, file);
61398
+ const fullPath = path55__namespace.join(root, file);
60944
61399
  try {
60945
61400
  const hash = await this.hashFile(fullPath);
60946
61401
  if (hash) {
@@ -61800,8 +62255,8 @@ var init_init_command = __esm({
61800
62255
  async execute(options = {}) {
61801
62256
  const startTime = Date.now();
61802
62257
  const root = options.root || process.cwd();
61803
- const stateDir = path54__namespace.join(root, ".maria");
61804
- const statePath = path54__namespace.join(stateDir, "state.json");
62258
+ const stateDir = path55__namespace.join(root, ".maria");
62259
+ const statePath = path55__namespace.join(stateDir, "state.json");
61805
62260
  this.logger.header("MARIA /init - Enhanced Codebase Analysis");
61806
62261
  const hasExistingState = await this.fileExists(statePath);
61807
62262
  if (hasExistingState && !options.force) {
@@ -61926,7 +62381,7 @@ var init_init_command = __esm({
61926
62381
  nodes.push({
61927
62382
  id: file._path,
61928
62383
  type: "file",
61929
- name: path54__namespace.basename(file._path),
62384
+ name: path55__namespace.basename(file._path),
61930
62385
  language: file.language,
61931
62386
  size: file.size,
61932
62387
  complexity: file.complexity
@@ -62031,7 +62486,7 @@ ${file.summary || ""}`,
62031
62486
  async generateArtifacts(root, scanResult, graphResult) {
62032
62487
  this.logger.start("artifacts", "Generating artifacts...");
62033
62488
  const mariaMd = this.generateMariaMd(scanResult, graphResult);
62034
- const mariaMdPath = path54__namespace.join(root, "MARIA.md");
62489
+ const mariaMdPath = path55__namespace.join(root, "MARIA.md");
62035
62490
  await fsp__namespace.writeFile(mariaMdPath, mariaMd, "utf-8");
62036
62491
  const depMapJson = {
62037
62492
  version: "3.2.2",
@@ -62048,7 +62503,7 @@ ${file.summary || ""}`,
62048
62503
  edges: graphResult.edgesCreated
62049
62504
  }
62050
62505
  };
62051
- const depMapPath = path54__namespace.join(root, "DEPENDENCY_MAP.json");
62506
+ const depMapPath = path55__namespace.join(root, "DEPENDENCY_MAP.json");
62052
62507
  await fsp__namespace.writeFile(
62053
62508
  depMapPath,
62054
62509
  JSON.stringify(depMapJson, null, 2),
@@ -62229,7 +62684,7 @@ Last updated: ${(/* @__PURE__ */ new Date()).toISOString()}
62229
62684
  }
62230
62685
  async saveState(stateDir, state) {
62231
62686
  await fsp__namespace.mkdir(stateDir, { recursive: true });
62232
- const statePath = path54__namespace.join(stateDir, "state.json");
62687
+ const statePath = path55__namespace.join(stateDir, "state.json");
62233
62688
  await fsp__namespace.writeFile(statePath, JSON.stringify(state, null, 2), "utf-8");
62234
62689
  }
62235
62690
  async fileExists(_path) {
@@ -62333,8 +62788,8 @@ var init_GraphEngine = __esm({
62333
62788
  this.nameIndex.get(lname).add(node.id);
62334
62789
  const p = (node.path || node._path || "") + "";
62335
62790
  if (p) this.pathIndex.set(p, node.id);
62336
- const tokens = this.tokenize(`${lname} ${p.toLowerCase()}`);
62337
- for (const tok of tokens) {
62791
+ const tokens2 = this.tokenize(`${lname} ${p.toLowerCase()}`);
62792
+ for (const tok of tokens2) {
62338
62793
  if (!this.tokenIndex.has(tok)) this.tokenIndex.set(tok, /* @__PURE__ */ new Set());
62339
62794
  this.tokenIndex.get(tok).add(node.id);
62340
62795
  this.tokenTrie.insert(tok, node.id);
@@ -62374,8 +62829,8 @@ var init_GraphEngine = __esm({
62374
62829
  }
62375
62830
  const p = (node.path || node._path || "") + "";
62376
62831
  if (p) this.pathIndex.delete(p);
62377
- const tokens = this.tokenize(`${(node.name || "").toLowerCase()} ${p.toLowerCase()}`);
62378
- for (const tok of tokens) {
62832
+ const tokens2 = this.tokenize(`${(node.name || "").toLowerCase()} ${p.toLowerCase()}`);
62833
+ for (const tok of tokens2) {
62379
62834
  const set2 = this.tokenIndex.get(tok);
62380
62835
  if (set2) {
62381
62836
  set2.delete(id);
@@ -62457,17 +62912,17 @@ var init_GraphEngine = __esm({
62457
62912
  const visited = /* @__PURE__ */ new Set();
62458
62913
  const queue = [{ id: from, path: [from] }];
62459
62914
  while (queue.length) {
62460
- const { id, path: path55 } = queue.shift();
62915
+ const { id, path: path56 } = queue.shift();
62461
62916
  if (visited.has(id)) continue;
62462
62917
  visited.add(id);
62463
62918
  const neighbors = this.edges.get(id) || /* @__PURE__ */ new Set();
62464
62919
  for (const e2 of neighbors) {
62465
62920
  if (e2.to === to) {
62466
- const res = [...path55, to];
62921
+ const res = [...path56, to];
62467
62922
  this.recordQueryTime(Date.now() - start);
62468
62923
  return res;
62469
62924
  }
62470
- if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...path55, e2.to] });
62925
+ if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...path56, e2.to] });
62471
62926
  }
62472
62927
  }
62473
62928
  this.recordQueryTime(Date.now() - start);
@@ -62654,8 +63109,8 @@ var init_GraphStore = __esm({
62654
63109
  accessCounter = 0;
62655
63110
  constructor(_maxNodes = 1e4) {
62656
63111
  this._maxNodes = _maxNodes;
62657
- this.storageDir = path54__namespace.default.join(process.cwd(), ".maria", "graph");
62658
- this.graphFile = path54__namespace.default.join(this.storageDir, "knowledge-graph.json");
63112
+ this.storageDir = path55__namespace.default.join(process.cwd(), ".maria", "graph");
63113
+ this.graphFile = path55__namespace.default.join(this.storageDir, "knowledge-graph.json");
62659
63114
  this.startPeriodicSave();
62660
63115
  }
62661
63116
  /**
@@ -63179,8 +63634,8 @@ var init_DependencyAnalyzer = __esm({
63179
63634
  */
63180
63635
  resolveImportPath(_importSource, fromFile2, rootDir) {
63181
63636
  if (_importSource.startsWith("./") || _importSource.startsWith("../")) {
63182
- const _fromDir = path54__namespace.default.dirname(fromFile2);
63183
- const _resolved = path54__namespace.default.resolve(_fromDir, _importSource);
63637
+ const _fromDir = path55__namespace.default.dirname(fromFile2);
63638
+ const _resolved = path55__namespace.default.resolve(_fromDir, _importSource);
63184
63639
  for (const _ext of this.SUPPORTED_EXTENSIONS) {
63185
63640
  if (_resolved.endsWith(_ext)) {
63186
63641
  return _resolved;
@@ -63190,7 +63645,7 @@ var init_DependencyAnalyzer = __esm({
63190
63645
  __require.resolve(_withExt);
63191
63646
  return _withExt;
63192
63647
  } catch {
63193
- const _indexFile = path54__namespace.default.join(_resolved, `index${_ext}`);
63648
+ const _indexFile = path55__namespace.default.join(_resolved, `index${_ext}`);
63194
63649
  try {
63195
63650
  __require.resolve(_indexFile);
63196
63651
  return _indexFile;
@@ -63202,7 +63657,7 @@ var init_DependencyAnalyzer = __esm({
63202
63657
  return _resolved;
63203
63658
  }
63204
63659
  if (!_importSource.startsWith("@") && !_importSource.includes("node_modules")) {
63205
- const _resolved = path54__namespace.default.resolve(rootDir, _importSource);
63660
+ const _resolved = path55__namespace.default.resolve(rootDir, _importSource);
63206
63661
  for (const _ext of this.SUPPORTED_EXTENSIONS) {
63207
63662
  const _withExt = _resolved + _ext;
63208
63663
  try {
@@ -63225,7 +63680,7 @@ var init_DependencyAnalyzer = __esm({
63225
63680
  try {
63226
63681
  const _entries = await fsp__namespace.default.readdir(dir, { withFileTypes: true });
63227
63682
  for (const entry of _entries) {
63228
- const _fullPath = path54__namespace.default.join(dir, entry.name);
63683
+ const _fullPath = path55__namespace.default.join(dir, entry.name);
63229
63684
  if (entry.isDirectory()) {
63230
63685
  if (!["node_modules", ".git", "dist", "build", ".next"].includes(
63231
63686
  entry.name
@@ -63233,7 +63688,7 @@ var init_DependencyAnalyzer = __esm({
63233
63688
  await traverse(_fullPath);
63234
63689
  }
63235
63690
  } else if (entry.isFile()) {
63236
- const _ext = path54__namespace.default.extname(entry.name);
63691
+ const _ext = path55__namespace.default.extname(entry.name);
63237
63692
  if ([".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(_ext)) {
63238
63693
  files.push(_fullPath);
63239
63694
  }
@@ -63389,7 +63844,7 @@ var init_DependencyAnalyzer = __esm({
63389
63844
  return {
63390
63845
  id: this.generateNodeId(_filePath),
63391
63846
  type: "file",
63392
- name: path54__namespace.default.basename(_filePath),
63847
+ name: path55__namespace.default.basename(_filePath),
63393
63848
  _path: _filePath,
63394
63849
  metadata: {
63395
63850
  size: _stats.size,
@@ -63429,7 +63884,7 @@ var init_DependencyAnalyzer = __esm({
63429
63884
  }
63430
63885
  }
63431
63886
  detectLanguage(_filePath) {
63432
- const _ext = path54__namespace.default.extname(_filePath);
63887
+ const _ext = path55__namespace.default.extname(_filePath);
63433
63888
  switch (_ext) {
63434
63889
  case ".ts":
63435
63890
  case ".tsx":
@@ -64227,7 +64682,7 @@ var init_KnowledgeGraphService = __esm({
64227
64682
  _filePath,
64228
64683
  depth
64229
64684
  );
64230
- const _fileName2 = path54__namespace.default.basename(_filePath);
64685
+ const _fileName2 = path55__namespace.default.basename(_filePath);
64231
64686
  const _relatedNodes = this.graphEngine.searchNodes(_fileName2);
64232
64687
  const suggestions = [];
64233
64688
  for (const node of _graphContext.nodes.slice(0, 5)) {
@@ -64541,8 +64996,8 @@ async function legacyInit(args2) {
64541
64996
  const cliCwd = process.cwd();
64542
64997
  console.log(chalk36__default.default.blue("\u{1F680} Initializing MARIA configuration..."));
64543
64998
  const options = parseInitOptions(args2);
64544
- const repoRoot = path54__namespace.resolve(options.root || await findRepoRoot(cliCwd));
64545
- const tomlPath = path54__namespace.join(repoRoot, ".maria-code.toml");
64999
+ const repoRoot = path55__namespace.resolve(options.root || await findRepoRoot(cliCwd));
65000
+ const tomlPath = path55__namespace.join(repoRoot, ".maria-code.toml");
64546
65001
  const existingConfig = await fileExists3(tomlPath);
64547
65002
  if (existingConfig && !args2.includes("--force")) {
64548
65003
  const result = await prompts__default.default({
@@ -64556,7 +65011,7 @@ async function legacyInit(args2) {
64556
65011
  return "exit";
64557
65012
  }
64558
65013
  await safeBackup2(tomlPath);
64559
- const mdPath2 = path54__namespace.join(repoRoot, "MARIA.md");
65014
+ const mdPath2 = path55__namespace.join(repoRoot, "MARIA.md");
64560
65015
  if (await fileExists3(mdPath2)) {
64561
65016
  await safeBackup2(mdPath2);
64562
65017
  }
@@ -64570,35 +65025,35 @@ async function legacyInit(args2) {
64570
65025
  const tomlContent = generateTomlConfig(projectConfig);
64571
65026
  try {
64572
65027
  const tomlStatus = await safeWriteIfChanged(tomlPath, tomlContent);
64573
- const rel = path54__namespace.relative(cliCwd, tomlPath);
65028
+ const rel = path55__namespace.relative(cliCwd, tomlPath);
64574
65029
  if (tomlStatus.status === "up-to-date") {
64575
65030
  console.log(chalk36__default.default.gray(`\u2139\uFE0F Up-to-date: ${rel}`));
64576
65031
  } else if (tomlStatus.status === "created") {
64577
65032
  console.log(chalk36__default.default.green(`\u2705 Created: ${rel}`));
64578
65033
  } else if (tomlStatus.status === "updated") {
64579
- console.log(chalk36__default.default.green(`\u2705 Updated: ${rel}`) + (tomlStatus.backup ? chalk36__default.default.gray(` (backup: ${path54__namespace.relative(cliCwd, tomlStatus.backup)})`) : ""));
65034
+ console.log(chalk36__default.default.green(`\u2705 Updated: ${rel}`) + (tomlStatus.backup ? chalk36__default.default.gray(` (backup: ${path55__namespace.relative(cliCwd, tomlStatus.backup)})`) : ""));
64580
65035
  }
64581
65036
  } catch (e2) {
64582
65037
  console.error(chalk36__default.default.red("\u274C Failed to write .maria-code.toml:"), adviceFromFsError(e2));
64583
65038
  }
64584
- const mdPath = path54__namespace.join(repoRoot, "MARIA.md");
65039
+ const mdPath = path55__namespace.join(repoRoot, "MARIA.md");
64585
65040
  const lang = resolveLang(options.lang);
64586
65041
  const mdContent = generateMariaMd3(projectConfig, lang);
64587
65042
  try {
64588
65043
  const mdStatus = await safeWriteIfChanged(mdPath, mdContent);
64589
- const rel = path54__namespace.relative(cliCwd, mdPath);
65044
+ const rel = path55__namespace.relative(cliCwd, mdPath);
64590
65045
  if (mdStatus.status === "up-to-date") {
64591
65046
  console.log(chalk36__default.default.gray(`Saved: ${rel} (up-to-date)`));
64592
65047
  } else if (mdStatus.status === "created") {
64593
65048
  console.log(chalk36__default.default.green(`Saved: ${rel} (created)`));
64594
65049
  } else if (mdStatus.status === "updated") {
64595
- const bakRel = mdStatus.backup ? path54__namespace.relative(cliCwd, mdStatus.backup) : void 0;
65050
+ const bakRel = mdStatus.backup ? path55__namespace.relative(cliCwd, mdStatus.backup) : void 0;
64596
65051
  console.log(chalk36__default.default.green(`Saved: ${rel} (updated${bakRel ? `, backup: ${bakRel}` : ""})`));
64597
65052
  }
64598
65053
  } catch (e2) {
64599
65054
  console.error(chalk36__default.default.red("\u274C Failed to write MARIA.md:"), adviceFromFsError(e2));
64600
65055
  }
64601
- if (projectConfig.gitInit && !await fileExists3(path54__namespace.join(repoRoot, ".git"))) {
65056
+ if (projectConfig.gitInit && !await fileExists3(path55__namespace.join(repoRoot, ".git"))) {
64602
65057
  try {
64603
65058
  const { execSync } = await import('child_process');
64604
65059
  execSync("git init", { cwd: repoRoot, stdio: "pipe" });
@@ -64632,13 +65087,13 @@ async function safeBackup2(_filePath) {
64632
65087
  const bakPath = `${_filePath}.bak.${stamp}`;
64633
65088
  await fsp__namespace.copyFile(_filePath, bakPath);
64634
65089
  console.log(
64635
- chalk36__default.default.gray(` \u21B3 backup: ${path54__namespace.relative(process.cwd(), bakPath)}`)
65090
+ chalk36__default.default.gray(` \u21B3 backup: ${path55__namespace.relative(process.cwd(), bakPath)}`)
64636
65091
  );
64637
65092
  } catch {
64638
65093
  }
64639
65094
  }
64640
65095
  async function interactiveSetup() {
64641
- const packageJsonPath = path54__namespace.join(process.cwd(), "package.json");
65096
+ const packageJsonPath = path55__namespace.join(process.cwd(), "package.json");
64642
65097
  let packageJson2 = {};
64643
65098
  try {
64644
65099
  const packageData = await fsp__namespace.readFile(packageJsonPath, "utf-8");
@@ -64650,7 +65105,7 @@ async function interactiveSetup() {
64650
65105
  type: "text",
64651
65106
  name: "name",
64652
65107
  message: "Project name:",
64653
- initial: packageJson2.name || path54__namespace.basename(process.cwd())
65108
+ initial: packageJson2.name || path55__namespace.basename(process.cwd())
64654
65109
  },
64655
65110
  {
64656
65111
  type: "select",
@@ -64694,7 +65149,7 @@ async function interactiveSetup() {
64694
65149
  }
64695
65150
  function getDefaultConfig() {
64696
65151
  return {
64697
- name: path54__namespace.basename(process.cwd()),
65152
+ name: path55__namespace.basename(process.cwd()),
64698
65153
  type: "auto",
64699
65154
  description: "AI-powered development project using MARIA",
64700
65155
  author: "",
@@ -64875,13 +65330,13 @@ function resolveLang(input3) {
64875
65330
  return "en";
64876
65331
  }
64877
65332
  async function findRepoRoot(startDir) {
64878
- let dir = path54__namespace.resolve(startDir);
65333
+ let dir = path55__namespace.resolve(startDir);
64879
65334
  let lastGitDir = null;
64880
65335
  while (true) {
64881
- const gitPath = path54__namespace.join(dir, ".git");
65336
+ const gitPath = path55__namespace.join(dir, ".git");
64882
65337
  const hasGit = await fileExists3(gitPath);
64883
65338
  if (hasGit) lastGitDir = dir;
64884
- const parent = path54__namespace.dirname(dir);
65339
+ const parent = path55__namespace.dirname(dir);
64885
65340
  if (parent === dir) break;
64886
65341
  dir = parent;
64887
65342
  }
@@ -64963,8 +65418,8 @@ var init_update_command = __esm({
64963
65418
  async execute(options = {}) {
64964
65419
  const startTime = Date.now();
64965
65420
  const root = options.root || process.cwd();
64966
- const stateDir = path54__namespace.join(root, ".maria");
64967
- const statePath = path54__namespace.join(stateDir, "state.json");
65421
+ const stateDir = path55__namespace.join(root, ".maria");
65422
+ const statePath = path55__namespace.join(stateDir, "state.json");
64968
65423
  this.reporter.thinking(`Performing incremental update to detect and process changes.
64969
65424
  This will:
64970
65425
  - Detect file changes since last update
@@ -65134,12 +65589,12 @@ This will:
65134
65589
  };
65135
65590
  const result = await this.deltaDetector.detectDelta(root, deltaOptions);
65136
65591
  const files = [
65137
- ...result.changed.map((path55) => ({
65138
- _path: path55,
65139
- type: previousState?.fileHashes?.[path55] ? "modified" : "added"
65592
+ ...result.changed.map((path56) => ({
65593
+ _path: path56,
65594
+ type: previousState?.fileHashes?.[path56] ? "modified" : "added"
65140
65595
  })),
65141
- ...result.deleted.map((path55) => ({
65142
- _path: path55,
65596
+ ...result.deleted.map((path56) => ({
65597
+ _path: path56,
65143
65598
  type: "deleted"
65144
65599
  }))
65145
65600
  ];
@@ -65256,7 +65711,7 @@ This will:
65256
65711
  nodeUpdates.push({
65257
65712
  id: file._path,
65258
65713
  type: "file",
65259
- name: path54__namespace.basename(file._path),
65714
+ name: path55__namespace.basename(file._path),
65260
65715
  language: file.language,
65261
65716
  size: file.size,
65262
65717
  complexity: file.complexity,
@@ -65356,7 +65811,7 @@ ${file.summary || ""}`,
65356
65811
  */
65357
65812
  async updateArtifacts(root, deltaResult, processResult) {
65358
65813
  this.logger.start("artifacts", "Updating artifacts...");
65359
- const mariaMdPath = path54__namespace.join(root, "MARIA.md");
65814
+ const mariaMdPath = path55__namespace.join(root, "MARIA.md");
65360
65815
  let existingContent = "";
65361
65816
  try {
65362
65817
  existingContent = await fsp__namespace.readFile(mariaMdPath, "utf-8");
@@ -65370,7 +65825,7 @@ ${file.summary || ""}`,
65370
65825
  );
65371
65826
  await fsp__namespace.writeFile(mariaMdPath, updatedMariaMd, "utf-8");
65372
65827
  this.reporter.write("MARIA.md", updatedMariaMd.length);
65373
- const depMapPath = path54__namespace.join(root, "DEPENDENCY_MAP.json");
65828
+ const depMapPath = path55__namespace.join(root, "DEPENDENCY_MAP.json");
65374
65829
  try {
65375
65830
  const existingDepMap = JSON.parse(await fsp__namespace.readFile(depMapPath, "utf-8"));
65376
65831
  this.reporter.read(
@@ -65489,7 +65944,7 @@ ${delta.modified > 5 ? `... and ${delta.modified - 5} more` : ""}
65489
65944
  }
65490
65945
  }
65491
65946
  async saveState(statePath, state) {
65492
- const dir = path54__namespace.dirname(statePath);
65947
+ const dir = path55__namespace.dirname(statePath);
65493
65948
  await fsp__namespace.mkdir(dir, { recursive: true });
65494
65949
  if (state.fileHashes instanceof Map) {
65495
65950
  state.fileHashes = Object.fromEntries(state.fileHashes);
@@ -65932,7 +66387,7 @@ var init_ResearchCommand = __esm({
65932
66387
  constructor() {
65933
66388
  super();
65934
66389
  this.contentExtractor = new ContentExtractor();
65935
- this.knowledgeBasePath = path54__namespace.default.join(os16__namespace.default.homedir(), ".maria", "knowledge-base");
66390
+ this.knowledgeBasePath = path55__namespace.default.join(os16__namespace.default.homedir(), ".maria", "knowledge-base");
65936
66391
  }
65937
66392
  async initialize() {
65938
66393
  try {
@@ -66463,7 +66918,7 @@ ${JSON.stringify(_result, null, 2)}
66463
66918
  readingTime: _content.metadata.readingTime
66464
66919
  }
66465
66920
  };
66466
- const _entryPath = path54__namespace.default.join(this.knowledgeBasePath, "entries", `${id}.json`);
66921
+ const _entryPath = path55__namespace.default.join(this.knowledgeBasePath, "entries", `${id}.json`);
66467
66922
  await fsp__namespace.default.writeFile(_entryPath, JSON.stringify(_entry, null, 2));
66468
66923
  await this.updateKnowledgeBaseIndex(_entry);
66469
66924
  logger.info(`Saved to knowledge base: ${id}`);
@@ -66474,7 +66929,7 @@ ${JSON.stringify(_result, null, 2)}
66474
66929
  }
66475
66930
  }
66476
66931
  async updateKnowledgeBaseIndex(_entry) {
66477
- const _indexPath = path54__namespace.default.join(this.knowledgeBasePath, "index.json");
66932
+ const _indexPath = path55__namespace.default.join(this.knowledgeBasePath, "index.json");
66478
66933
  try {
66479
66934
  const _indexContent = await fsp__namespace.default.readFile(_indexPath, "utf-8");
66480
66935
  const _index = JSON.parse(_indexContent);
@@ -66494,7 +66949,7 @@ ${JSON.stringify(_result, null, 2)}
66494
66949
  async ensureKnowledgeBaseDirectory() {
66495
66950
  try {
66496
66951
  await fsp__namespace.default.mkdir(this.knowledgeBasePath, { recursive: true });
66497
- await fsp__namespace.default.mkdir(path54__namespace.default.join(this.knowledgeBasePath, "entries"), { recursive: true });
66952
+ await fsp__namespace.default.mkdir(path55__namespace.default.join(this.knowledgeBasePath, "entries"), { recursive: true });
66498
66953
  } catch (innerError) {
66499
66954
  logger.error("Failed to create knowledge base directory:", error);
66500
66955
  }
@@ -66562,7 +67017,7 @@ ${JSON.stringify(_result, null, 2)}
66562
67017
  `;
66563
67018
  }
66564
67019
  try {
66565
- const _indexPath = path54__namespace.default.join(this.knowledgeBasePath, "index.json");
67020
+ const _indexPath = path55__namespace.default.join(this.knowledgeBasePath, "index.json");
66566
67021
  const _indexContent = await fsp__namespace.default.readFile(_indexPath, "utf-8");
66567
67022
  const _index = JSON.parse(_indexContent);
66568
67023
  message += `**Knowledge Base**: \u2705 Available
@@ -68836,13 +69291,13 @@ async function checkShield(commandName, userPlan = "free") {
68836
69291
  }
68837
69292
  async function loadManifest() {
68838
69293
  try {
68839
- const fs45 = await import('fs');
68840
- const path55 = await import('path');
68841
- const manifestPath = path55.join(
69294
+ const fs46 = await import('fs');
69295
+ const path56 = await import('path');
69296
+ const manifestPath = path56.join(
68842
69297
  __dirname,
68843
69298
  "../command-manifest-v2.1.json"
68844
69299
  );
68845
- const content = fs45.readFileSync(manifestPath, "utf-8");
69300
+ const content = fs46.readFileSync(manifestPath, "utf-8");
68846
69301
  return JSON.parse(content);
68847
69302
  } catch {
68848
69303
  return { commands: [] };
@@ -70526,11 +70981,11 @@ var init_ImageCommand = __esm({
70526
70981
  const height = m2 ? parseInt(m2[2], 10) : 1024;
70527
70982
  const format = String(options.format || "png");
70528
70983
  const res = await provider.generateImage({ prompt, width, height, format });
70529
- const path55 = __require("path");
70530
- const fs45 = await import('fs/promises');
70531
- const outPath = path55.join(process.cwd(), "outputs", "images", `image_${Date.now()}.png`);
70532
- await fs45.mkdir(path55.dirname(outPath), { recursive: true });
70533
- await fs45.writeFile(outPath, res.bytes);
70984
+ const path56 = __require("path");
70985
+ const fs46 = await import('fs/promises');
70986
+ const outPath = path56.join(process.cwd(), "outputs", "images", `image_${Date.now()}.png`);
70987
+ await fs46.mkdir(path56.dirname(outPath), { recursive: true });
70988
+ await fs46.writeFile(outPath, res.bytes);
70534
70989
  return { success: true, output: `OK: Saved image \u2192 ${outPath}` };
70535
70990
  } catch (e2) {
70536
70991
  return { success: false, output: `ERROR: Image generation failed. ${e2?.message || e2}` };
@@ -70581,12 +71036,12 @@ var init_VideoCommand = __esm({
70581
71036
  const fps = Math.max(1, parseInt(getVal("fps", "8"), 10) || 8);
70582
71037
  const duration = Math.max(1, parseInt(getVal("duration", "2"), 10) || 2);
70583
71038
  const frames = await provider.generateVideoFrames({ prompt, width: 640, height: 360, fps, duration, format: "mp4" });
70584
- const path55 = __require("path");
70585
- const fs45 = await import('fs/promises');
70586
- const dir = path55.join(process.cwd(), "outputs", "videos", `video_${Date.now()}`);
70587
- await fs45.mkdir(dir, { recursive: true });
71039
+ const path56 = __require("path");
71040
+ const fs46 = await import('fs/promises');
71041
+ const dir = path56.join(process.cwd(), "outputs", "videos", `video_${Date.now()}`);
71042
+ await fs46.mkdir(dir, { recursive: true });
70588
71043
  const framePattern = "frame_%04d.png";
70589
- await Promise.all(frames.frames.map((buf, i2) => fs45.writeFile(path55.join(dir, `frame_${i2.toString().padStart(4, "0")}.png`), buf)));
71044
+ await Promise.all(frames.frames.map((buf, i2) => fs46.writeFile(path56.join(dir, `frame_${i2.toString().padStart(4, "0")}.png`), buf)));
70590
71045
  const wantMerge = has("merge") || has("mp4");
70591
71046
  if (wantMerge && process.env.CI !== "true" && process.env.MARIA_TEST_MODE !== "1") {
70592
71047
  const ok = await this.mergeWithFFmpeg(dir, framePattern, fps).catch(() => false);
@@ -70603,8 +71058,8 @@ var init_VideoCommand = __esm({
70603
71058
  if (!available) return false;
70604
71059
  return new Promise((resolve17) => {
70605
71060
  const { spawn: spawn4 } = __require("child_process");
70606
- const path55 = __require("path");
70607
- const out = path55.join(dir, "video.mp4");
71061
+ const path56 = __require("path");
71062
+ const out = path56.join(dir, "video.mp4");
70608
71063
  const ffmpeg = spawn4("ffmpeg", ["-y", "-framerate", String(fps), "-i", pattern, "-pix_fmt", "yuv420p", out], { cwd: dir, stdio: "ignore" });
70609
71064
  let done = false;
70610
71065
  ffmpeg.on("error", () => {
@@ -72044,14 +72499,14 @@ ${model.description}
72044
72499
  };
72045
72500
  return emojis[provider.toLowerCase()] || "\u{1F52E}";
72046
72501
  }
72047
- formatTokens(tokens) {
72048
- if (tokens >= 1e6) {
72049
- return `${(tokens / 1e6).toFixed(1)}M`;
72502
+ formatTokens(tokens2) {
72503
+ if (tokens2 >= 1e6) {
72504
+ return `${(tokens2 / 1e6).toFixed(1)}M`;
72050
72505
  }
72051
- if (tokens >= 1e3) {
72052
- return `${(tokens / 1e3).toFixed(0)}K`;
72506
+ if (tokens2 >= 1e3) {
72507
+ return `${(tokens2 / 1e3).toFixed(0)}K`;
72053
72508
  }
72054
- return tokens.toString();
72509
+ return tokens2.toString();
72055
72510
  }
72056
72511
  async performModelTest(model) {
72057
72512
  const latency = Math.random() * 1e3 + 100;
@@ -72334,8 +72789,8 @@ var init_ConfigCommand2 = __esm({
72334
72789
  validate: (v) => typeof v === "string"
72335
72790
  }
72336
72791
  };
72337
- globalConfigPath = path54__namespace.default.join(os16__namespace.default.homedir(), ".maria", "config.json");
72338
- localConfigPath = path54__namespace.default.join(process.cwd(), ".maria-config.json");
72792
+ globalConfigPath = path55__namespace.default.join(os16__namespace.default.homedir(), ".maria", "config.json");
72793
+ localConfigPath = path55__namespace.default.join(process.cwd(), ".maria-config.json");
72339
72794
  async execute(_args, context2) {
72340
72795
  try {
72341
72796
  const _startTime = Date.now();
@@ -72721,7 +73176,7 @@ var init_ConfigCommand2 = __esm({
72721
73176
  }
72722
73177
  async saveConfiguration(_config, _scope) {
72723
73178
  const _configPath = _scope === "global" ? this.globalConfigPath : this.localConfigPath;
72724
- await fsp__namespace.default.mkdir(path54__namespace.default.dirname(_configPath), { recursive: true });
73179
+ await fsp__namespace.default.mkdir(path55__namespace.default.dirname(_configPath), { recursive: true });
72725
73180
  await fsp__namespace.default.writeFile(_configPath, JSON.stringify(_config, null, 2), "utf-8");
72726
73181
  this.setCache(`_config:${_scope}`, _config, 300);
72727
73182
  }
@@ -73138,8 +73593,8 @@ async function enforceAuth(cmd) {
73138
73593
  return true;
73139
73594
  }
73140
73595
  try {
73141
- const tokens = await authManager.getValidTokens();
73142
- if (!tokens) {
73596
+ const tokens2 = await authManager.getValidTokens();
73597
+ if (!tokens2) {
73143
73598
  console.log(chalk36__default.default.red("\u{1F510} Authentication required \xB7 Run: maria /login"));
73144
73599
  return false;
73145
73600
  }
@@ -73938,23 +74393,23 @@ function coerceExtension(ext2, fallback2) {
73938
74393
  return fallback2;
73939
74394
  }
73940
74395
  function safeResolve(root, fname) {
73941
- const abs = path54__namespace.resolve(root, fname);
73942
- const base = path54__namespace.resolve(root);
73943
- if (!(abs + path54__namespace.sep).startsWith(base + path54__namespace.sep) && abs !== base) {
74396
+ const abs = path55__namespace.resolve(root, fname);
74397
+ const base = path55__namespace.resolve(root);
74398
+ if (!(abs + path55__namespace.sep).startsWith(base + path55__namespace.sep) && abs !== base) {
73944
74399
  throw new Error("Path traversal detected");
73945
74400
  }
73946
74401
  return abs;
73947
74402
  }
73948
74403
  async function ensureUniquePath(absPath) {
73949
- const dir = path54__namespace.dirname(absPath);
73950
- const ext2 = path54__namespace.extname(absPath);
73951
- const base = path54__namespace.basename(absPath, ext2);
74404
+ const dir = path55__namespace.dirname(absPath);
74405
+ const ext2 = path55__namespace.extname(absPath);
74406
+ const base = path55__namespace.basename(absPath, ext2);
73952
74407
  let candidate = absPath;
73953
74408
  let i2 = 1;
73954
74409
  while (true) {
73955
74410
  try {
73956
74411
  await fsp__namespace.access(candidate);
73957
- candidate = path54__namespace.join(dir, `${base}(${i2})${ext2}`);
74412
+ candidate = path55__namespace.join(dir, `${base}(${i2})${ext2}`);
73958
74413
  i2++;
73959
74414
  } catch {
73960
74415
  return candidate;
@@ -74033,7 +74488,7 @@ async function handleCodeCommand(prompt) {
74033
74488
  for (const { language, code, extension, filename: suggested } of artifacts) {
74034
74489
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74035
74490
  filename = sanitizeFilenameStrict(filename);
74036
- const ext2 = path54__namespace.extname(filename).slice(1);
74491
+ const ext2 = path55__namespace.extname(filename).slice(1);
74037
74492
  const isBinary2 = isLikelyBinary(code);
74038
74493
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74039
74494
  const finalExt = coerceExtension(ext2, inferred);
@@ -74046,15 +74501,13 @@ async function handleCodeCommand(prompt) {
74046
74501
  files += 1;
74047
74502
  if (progress) clearInterval(progress);
74048
74503
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74049
- console.log(chalk36__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74050
- console.log(chalk36__default.default.gray(`\u{1F4CD} ${filepath}`));
74051
- console.log(chalk36__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74504
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74505
+ console.log(`\u{1F4CD} ${filepath}`);
74052
74506
  const pm = getProviderManager();
74053
74507
  const provider = pm.getLastUsedProvider() || "fallback";
74054
74508
  const model = pm.getLastUsedModel() || "n/a";
74055
74509
  const source = pm.getConfigSource();
74056
- const summary = { filename: path54__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: true, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74057
- console.log(chalk36__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74510
+ const summary = { filename: path55__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: true, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74058
74511
  try {
74059
74512
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74060
74513
  } catch {
@@ -74062,7 +74515,6 @@ async function handleCodeCommand(prompt) {
74062
74515
  }
74063
74516
  const pmBatch = getProviderManager();
74064
74517
  const batch = { files, total_bytes: totalBytes, provider: String(pmBatch.getLastUsedProvider() || "fallback"), model: String(pmBatch.getLastUsedModel() || "n/a"), config_source: pmBatch.getConfigSource(), fallback_any: true, latency_ms: pmBatch.getLastLatencyMs(), total_tokens: pmBatch.getLastUsage()?.totalTokens };
74065
- console.log(chalk36__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74066
74518
  try {
74067
74519
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74068
74520
  } catch {
@@ -74093,7 +74545,7 @@ async function handleCodeCommand(prompt) {
74093
74545
  for (const { language, code, extension, filename: suggested } of artifacts) {
74094
74546
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74095
74547
  filename = sanitizeFilenameStrict(filename);
74096
- const ext2 = path54__namespace.extname(filename).slice(1);
74548
+ const ext2 = path55__namespace.extname(filename).slice(1);
74097
74549
  const isBinary2 = isLikelyBinary(code);
74098
74550
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74099
74551
  const finalExt = coerceExtension(ext2, inferred);
@@ -74106,15 +74558,13 @@ async function handleCodeCommand(prompt) {
74106
74558
  files += 1;
74107
74559
  if (progress) clearInterval(progress);
74108
74560
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74109
- console.log(chalk36__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74110
- console.log(chalk36__default.default.gray(`\u{1F4CD} ${filepath}`));
74111
- console.log(chalk36__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74561
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74562
+ console.log(`\u{1F4CD} ${filepath}`);
74112
74563
  const pm = getProviderManager();
74113
74564
  const provider = pm.getLastUsedProvider() || "unknown";
74114
74565
  const model = pm.getLastUsedModel() || "auto";
74115
74566
  const source = pm.getConfigSource();
74116
- const summary = { filename: path54__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: false, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74117
- console.log(chalk36__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74567
+ const summary = { filename: path55__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: false, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74118
74568
  try {
74119
74569
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74120
74570
  } catch {
@@ -74122,7 +74572,6 @@ async function handleCodeCommand(prompt) {
74122
74572
  }
74123
74573
  const pmBatch = getProviderManager();
74124
74574
  const batch = { files, total_bytes: totalBytes, provider: String(pmBatch.getLastUsedProvider() || "unknown"), model: String(pmBatch.getLastUsedModel() || "auto"), config_source: pmBatch.getConfigSource(), fallback_any: false, latency_ms: pmBatch.getLastLatencyMs(), total_tokens: pmBatch.getLastUsage()?.totalTokens };
74125
- console.log(chalk36__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74126
74575
  try {
74127
74576
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74128
74577
  } catch {
@@ -74147,7 +74596,7 @@ async function handleCodeCommand(prompt) {
74147
74596
  for (const { language, code, extension, filename: suggested } of artifacts) {
74148
74597
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74149
74598
  filename = sanitizeFilenameStrict(filename);
74150
- const ext2 = path54__namespace.extname(filename).slice(1);
74599
+ const ext2 = path55__namespace.extname(filename).slice(1);
74151
74600
  const isBinary2 = isLikelyBinary(code);
74152
74601
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74153
74602
  const finalExt = coerceExtension(ext2, inferred);
@@ -74160,15 +74609,13 @@ async function handleCodeCommand(prompt) {
74160
74609
  files += 1;
74161
74610
  if (progress) clearInterval(progress);
74162
74611
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74163
- console.log(chalk36__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74164
- console.log(chalk36__default.default.gray(`\u{1F4CD} ${filepath}`));
74165
- console.log(chalk36__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74612
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74613
+ console.log(`\u{1F4CD} ${filepath}`);
74166
74614
  const pm = getProviderManager();
74167
74615
  const provider = pm.getLastUsedProvider() || "fallback";
74168
74616
  const model = pm.getLastUsedModel() || "n/a";
74169
74617
  const source = pm.getConfigSource();
74170
- const summary = { filename: path54__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: true, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74171
- console.log(chalk36__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74618
+ const summary = { filename: path55__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: true, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74172
74619
  try {
74173
74620
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74174
74621
  } catch {
@@ -74176,7 +74623,6 @@ async function handleCodeCommand(prompt) {
74176
74623
  }
74177
74624
  const pmBatch = getProviderManager();
74178
74625
  const batch = { files, total_bytes: totalBytes, provider: String(pmBatch.getLastUsedProvider() || "fallback"), model: String(pmBatch.getLastUsedModel() || "n/a"), config_source: pmBatch.getConfigSource(), fallback_any: true, latency_ms: pmBatch.getLastLatencyMs(), total_tokens: pmBatch.getLastUsage()?.totalTokens };
74179
- console.log(chalk36__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74180
74626
  try {
74181
74627
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74182
74628
  } catch {
@@ -74234,7 +74680,7 @@ ${e2.stack}`));
74234
74680
  for (const { language, code, extension, filename: suggested } of artifacts) {
74235
74681
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74236
74682
  filename = sanitizeFilenameStrict(filename);
74237
- const ext2 = path54__namespace.extname(filename).slice(1);
74683
+ const ext2 = path55__namespace.extname(filename).slice(1);
74238
74684
  const isBinary2 = isLikelyBinary(code);
74239
74685
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74240
74686
  const finalExt = coerceExtension(ext2, inferred);
@@ -74247,15 +74693,13 @@ ${e2.stack}`));
74247
74693
  files += 1;
74248
74694
  if (progress) clearInterval(progress);
74249
74695
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74250
- console.log(chalk36__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74251
- console.log(chalk36__default.default.gray(`\u{1F4CD} ${filepath}`));
74252
- console.log(chalk36__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74696
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74697
+ console.log(`\u{1F4CD} ${filepath}`);
74253
74698
  const pm = getProviderManager();
74254
74699
  const provider = pm.getLastUsedProvider() || "fallback";
74255
74700
  const model = pm.getLastUsedModel() || "n/a";
74256
74701
  const source = pm.getConfigSource();
74257
- const summary = { filename: path54__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: true, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74258
- console.log(chalk36__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74702
+ const summary = { filename: path55__namespace.basename(filepath), lang: String(language), provider: String(provider), model: String(model), config_source: source, fallback: true, latency_ms: pm.getLastLatencyMs(), ...pm.getLastUsage() ? { total_tokens: pm.getLastUsage().totalTokens, prompt_tokens: pm.getLastUsage().promptTokens, completion_tokens: pm.getLastUsage().completionTokens } : {}, file_size: bytes };
74259
74703
  try {
74260
74704
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74261
74705
  } catch {
@@ -74263,7 +74707,6 @@ ${e2.stack}`));
74263
74707
  }
74264
74708
  const pmBatch = getProviderManager();
74265
74709
  const batch = { files, total_bytes: totalBytes, provider: String(pmBatch.getLastUsedProvider() || "fallback"), model: String(pmBatch.getLastUsedModel() || "n/a"), config_source: pmBatch.getConfigSource(), fallback_any: true, latency_ms: pmBatch.getLastLatencyMs(), total_tokens: pmBatch.getLastUsage()?.totalTokens };
74266
- console.log(chalk36__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74267
74710
  try {
74268
74711
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74269
74712
  } catch {
@@ -74813,24 +75256,24 @@ function createCLI() {
74813
75256
  if (options.server) {
74814
75257
  console.log(chalk36__default.default.green("\u{1F680} Starting MARIA server mode..."));
74815
75258
  try {
74816
- const distDir = path54__namespace.dirname(process.argv[1] || process.cwd());
75259
+ const distDir = path55__namespace.dirname(process.argv[1] || process.cwd());
74817
75260
  const candidateNames = [
74818
75261
  "server-express.mjs",
74819
75262
  "server-express.cjs",
74820
75263
  "server-express.js",
74821
75264
  // tsup emits CJS for server entry as dist/server/express-server.js
74822
- path54__namespace.join("server", "express-server.js"),
74823
- path54__namespace.join("server", "express-server.cjs")
75265
+ path55__namespace.join("server", "express-server.js"),
75266
+ path55__namespace.join("server", "express-server.cjs")
74824
75267
  ];
74825
75268
  const candidateDirs = [
74826
75269
  distDir,
74827
- path54__namespace.resolve(distDir, ".."),
75270
+ path55__namespace.resolve(distDir, ".."),
74828
75271
  process.cwd()
74829
75272
  ];
74830
75273
  let serverPath = null;
74831
75274
  for (const dir of candidateDirs) {
74832
75275
  for (const name2 of candidateNames) {
74833
- const p = path54__namespace.join(dir, name2);
75276
+ const p = path55__namespace.join(dir, name2);
74834
75277
  try {
74835
75278
  await fsp__namespace.access(p);
74836
75279
  serverPath = p;
@@ -74850,7 +75293,7 @@ function createCLI() {
74850
75293
  const serverProcess = spawn4("node", [serverPath], {
74851
75294
  stdio: "inherit",
74852
75295
  env: process.env,
74853
- cwd: path54__namespace.dirname(serverPath)
75296
+ cwd: path55__namespace.dirname(serverPath)
74854
75297
  });
74855
75298
  let shutdownTimer = null;
74856
75299
  const forceExit = (defaultCode) => {