@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.
package/dist/cli.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  var fs21 = require('fs');
5
- var path54 = require('path');
5
+ var path55 = require('path');
6
6
  var dotenv = require('dotenv');
7
7
  var chalk37 = require('chalk');
8
8
  var crypto4 = require('crypto');
@@ -54,7 +54,7 @@ function _interopNamespace(e) {
54
54
  }
55
55
 
56
56
  var fs21__namespace = /*#__PURE__*/_interopNamespace(fs21);
57
- var path54__namespace = /*#__PURE__*/_interopNamespace(path54);
57
+ var path55__namespace = /*#__PURE__*/_interopNamespace(path55);
58
58
  var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
59
59
  var chalk37__default = /*#__PURE__*/_interopDefault(chalk37);
60
60
  var crypto4__namespace = /*#__PURE__*/_interopNamespace(crypto4);
@@ -112,27 +112,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
112
112
  mod
113
113
  ));
114
114
  function loadEnvironmentVariables() {
115
- const _envPath = path54__namespace.join(process.cwd(), ".env");
115
+ const _envPath = path55__namespace.join(process.cwd(), ".env");
116
116
  if (fs21__namespace.existsSync(_envPath)) {
117
117
  const _result = dotenv__namespace.config({ path: _envPath });
118
118
  if (_result.error) {
119
119
  console.warn("Error loading .env:", _result.error);
120
120
  }
121
121
  }
122
- const _envLocalPath = path54__namespace.join(process.cwd(), ".env.local");
122
+ const _envLocalPath = path55__namespace.join(process.cwd(), ".env.local");
123
123
  if (fs21__namespace.existsSync(_envLocalPath)) {
124
124
  const _result = dotenv__namespace.config({ path: _envLocalPath, override: true });
125
125
  if (_result.error) {
126
126
  console.warn("Error loading .env.local:", _result.error);
127
127
  }
128
128
  }
129
- const _lmstudioEnvPath = path54__namespace.join(process.cwd(), ".env.lmstudio");
129
+ const _lmstudioEnvPath = path55__namespace.join(process.cwd(), ".env.lmstudio");
130
130
  if (fs21__namespace.existsSync(_lmstudioEnvPath)) {
131
131
  const _result = dotenv__namespace.config({ path: _lmstudioEnvPath, override: false });
132
132
  if (_result.error) {
133
133
  console.warn("Error loading .env.lmstudio:", _result.error);
134
134
  }
135
135
  }
136
+ if (!process.env.MARIA_API_BASE) process.env.MARIA_API_BASE = "https://api.maria-code.ai";
137
+ if (!process.env.MARIA_USE_API) process.env.MARIA_USE_API = "1";
138
+ if (!process.env.MARIA_USE_REMOTE_MEDIA) process.env.MARIA_USE_REMOTE_MEDIA = "1";
136
139
  }
137
140
  var init_env_loader = __esm({
138
141
  "src/utils/env-loader.ts"() {
@@ -158,25 +161,25 @@ function getPackageJson() {
158
161
  try {
159
162
  const possiblePaths = [
160
163
  // When running from built dist/
161
- path54.join(__dirname, "../../package.json"),
164
+ path55.join(__dirname, "../../package.json"),
162
165
  // When running from source
163
- path54.join(__dirname, "../../../package.json"),
166
+ path55.join(__dirname, "../../../package.json"),
164
167
  // Current working directory
165
- path54.join(process.cwd(), "package.json"),
168
+ path55.join(process.cwd(), "package.json"),
166
169
  // One level up from current working directory
167
- path54.join(process.cwd(), "../package.json"),
170
+ path55.join(process.cwd(), "../package.json"),
168
171
  // For globally installed packages
169
- path54.join(__dirname, "../../../../package.json"),
170
- path54.join(__dirname, "../../../../../package.json"),
172
+ path55.join(__dirname, "../../../../package.json"),
173
+ path55.join(__dirname, "../../../../../package.json"),
171
174
  // npm global install locations
172
175
  "/usr/local/lib/node_modules/@bonginkan/maria/package.json",
173
176
  "/usr/lib/node_modules/@bonginkan/maria/package.json",
174
177
  // User home npm global
175
- path54.join(
178
+ path55.join(
176
179
  process.env.HOME || "",
177
180
  ".npm-global/lib/node_modules/@bonginkan/maria/package.json"
178
181
  ),
179
- path54.join(
182
+ path55.join(
180
183
  process.env.HOME || "",
181
184
  ".nvm/versions/node",
182
185
  process.version,
@@ -184,13 +187,13 @@ function getPackageJson() {
184
187
  )
185
188
  ];
186
189
  let packageJsonPath = null;
187
- for (const path55 of possiblePaths) {
188
- if (fs21.existsSync(path55)) {
190
+ for (const path56 of possiblePaths) {
191
+ if (fs21.existsSync(path56)) {
189
192
  try {
190
- const content = fs21.readFileSync(path55, "utf-8");
193
+ const content = fs21.readFileSync(path56, "utf-8");
191
194
  const parsed = JSON.parse(content);
192
195
  if (parsed.name === "@bonginkan/maria") {
193
- packageJsonPath = path55;
196
+ packageJsonPath = path56;
194
197
  break;
195
198
  }
196
199
  } catch {
@@ -529,11 +532,11 @@ var init_OAuth2PKCEClient = __esm({
529
532
  redirectUri: config2.redirectUri || "http://127.0.0.1:9876/callback",
530
533
  authServerUrl: config2.authServerUrl || "https://maria-code.ai"
531
534
  };
532
- const configDir = path54__namespace.join(os13__namespace.homedir(), ".maria");
535
+ const configDir = path55__namespace.join(os13__namespace.homedir(), ".maria");
533
536
  if (!fs21__namespace.existsSync(configDir)) {
534
537
  fs21__namespace.mkdirSync(configDir, { recursive: true });
535
538
  }
536
- this.tokenStoragePath = path54__namespace.join(configDir, "auth-tokens.json");
539
+ this.tokenStoragePath = path55__namespace.join(configDir, "auth-tokens.json");
537
540
  }
538
541
  /**
539
542
  * Generate cryptographically secure random string
@@ -712,13 +715,13 @@ var init_OAuth2PKCEClient = __esm({
712
715
  /**
713
716
  * Store tokens securely
714
717
  */
715
- async storeTokens(tokens) {
718
+ async storeTokens(tokens2) {
716
719
  const storedTokens = {
717
- accessToken: tokens.access_token,
718
- refreshToken: tokens.refresh_token,
719
- idToken: tokens.id_token,
720
- expiresAt: Date.now() + tokens.expires_in * 1e3,
721
- scopes: tokens.scope?.split(" ") || this.config.scopes,
720
+ accessToken: tokens2.access_token,
721
+ refreshToken: tokens2.refresh_token,
722
+ idToken: tokens2.id_token,
723
+ expiresAt: Date.now() + tokens2.expires_in * 1e3,
724
+ scopes: tokens2.scope?.split(" ") || this.config.scopes,
722
725
  obtainedAt: Date.now()
723
726
  };
724
727
  fs21__namespace.writeFileSync(
@@ -737,16 +740,16 @@ var init_OAuth2PKCEClient = __esm({
737
740
  }
738
741
  try {
739
742
  const data = fs21__namespace.readFileSync(this.tokenStoragePath, "utf-8");
740
- const tokens = JSON.parse(data);
741
- if (Date.now() >= tokens.expiresAt) {
742
- if (tokens.refreshToken) {
743
- const newTokens = await this.refreshAccessToken(tokens.refreshToken);
743
+ const tokens2 = JSON.parse(data);
744
+ if (Date.now() >= tokens2.expiresAt) {
745
+ if (tokens2.refreshToken) {
746
+ const newTokens = await this.refreshAccessToken(tokens2.refreshToken);
744
747
  await this.storeTokens(newTokens);
745
748
  return this.loadStoredTokens();
746
749
  }
747
750
  return null;
748
751
  }
749
- return tokens;
752
+ return tokens2;
750
753
  } catch (error2) {
751
754
  console.error("Failed to load stored tokens:", error2);
752
755
  return null;
@@ -799,8 +802,8 @@ ${authUrl}
799
802
  const code = await codePromise;
800
803
  console.log("\u2705 Authorization code received");
801
804
  console.log("\u{1F504} Exchanging code for tokens...");
802
- const tokens = await this.exchangeCodeForTokens(code);
803
- await this.storeTokens(tokens);
805
+ const tokens2 = await this.exchangeCodeForTokens(code);
806
+ await this.storeTokens(tokens2);
804
807
  console.log("\u2705 Authentication complete! Tokens stored securely.");
805
808
  return this.loadStoredTokens();
806
809
  } finally {
@@ -820,15 +823,15 @@ ${authUrl}
820
823
  * Get current access token
821
824
  */
822
825
  async getAccessToken() {
823
- const tokens = await this.loadStoredTokens();
824
- return tokens?.accessToken || null;
826
+ const tokens2 = await this.loadStoredTokens();
827
+ return tokens2?.accessToken || null;
825
828
  }
826
829
  /**
827
830
  * Check if authenticated
828
831
  */
829
832
  async isAuthenticated() {
830
- const tokens = await this.loadStoredTokens();
831
- return tokens !== null;
833
+ const tokens2 = await this.loadStoredTokens();
834
+ return tokens2 !== null;
832
835
  }
833
836
  };
834
837
  }
@@ -879,10 +882,10 @@ var init_MariaAPIClient = __esm({
879
882
  const responseData = await response.json();
880
883
  if (!response.ok) {
881
884
  if (response.status === 401) {
882
- const tokens = await this.authClient.loadStoredTokens();
883
- if (tokens?.refreshToken) {
885
+ const tokens2 = await this.authClient.loadStoredTokens();
886
+ if (tokens2?.refreshToken) {
884
887
  try {
885
- await this.authClient.refreshAccessToken(tokens.refreshToken);
888
+ await this.authClient.refreshAccessToken(tokens2.refreshToken);
886
889
  continue;
887
890
  } catch {
888
891
  throw new Error("Session expired. Please login again.");
@@ -1111,11 +1114,11 @@ var init_CLIAuthService = __esm({
1111
1114
  configPath;
1112
1115
  config;
1113
1116
  constructor(config2) {
1114
- const configDir = path54__namespace.join(os13__namespace.homedir(), ".maria");
1117
+ const configDir = path55__namespace.join(os13__namespace.homedir(), ".maria");
1115
1118
  if (!fs21__namespace.existsSync(configDir)) {
1116
1119
  fs21__namespace.mkdirSync(configDir, { recursive: true });
1117
1120
  }
1118
- this.configPath = path54__namespace.join(configDir, "cli-config.json");
1121
+ this.configPath = path55__namespace.join(configDir, "cli-config.json");
1119
1122
  this.config = this.loadConfig(config2);
1120
1123
  this.authClient = new OAuth2PKCEClient({
1121
1124
  authorizationEndpoint: `${this.config.authServerUrl}/oauth/authorize`,
@@ -1218,7 +1221,7 @@ var init_CLIAuthService = __esm({
1218
1221
  }
1219
1222
  console.log("\u{1F4F1} Starting authentication flow...");
1220
1223
  console.log("A browser window will open for you to authenticate.\n");
1221
- const tokens = await this.authClient.authenticate();
1224
+ const tokens2 = await this.authClient.authenticate();
1222
1225
  this.config.lastLogin = (/* @__PURE__ */ new Date()).toISOString();
1223
1226
  this.saveConfig();
1224
1227
  console.log("\n\u2705 Authentication successful!");
@@ -1437,13 +1440,13 @@ var init_TokenStorage = __esm({
1437
1440
  TokenStorage = class {
1438
1441
  SERVICE_NAME = "maria-cli";
1439
1442
  ACCOUNT_NAME = "default";
1440
- CONFIG_DIR = path54__namespace.default.join(os13__namespace.default.homedir(), ".maria");
1441
- TOKEN_FILE = path54__namespace.default.join(this.CONFIG_DIR, "auth-tokens.json");
1443
+ CONFIG_DIR = path55__namespace.default.join(os13__namespace.default.homedir(), ".maria");
1444
+ TOKEN_FILE = path55__namespace.default.join(this.CONFIG_DIR, "auth-tokens.json");
1442
1445
  /**
1443
1446
  * Save tokens securely
1444
1447
  */
1445
- async save(tokens) {
1446
- const tokenData = JSON.stringify(tokens);
1448
+ async save(tokens2) {
1449
+ const tokenData = JSON.stringify(tokens2);
1447
1450
  if (keytar) {
1448
1451
  try {
1449
1452
  await keytar.setPassword(this.SERVICE_NAME, this.ACCOUNT_NAME, tokenData);
@@ -1452,7 +1455,7 @@ var init_TokenStorage = __esm({
1452
1455
  console.warn("Keychain storage failed, falling back to encrypted file");
1453
1456
  }
1454
1457
  }
1455
- await this.saveToFile(tokens);
1458
+ await this.saveToFile(tokens2);
1456
1459
  }
1457
1460
  /**
1458
1461
  * Load tokens securely
@@ -1488,12 +1491,12 @@ var init_TokenStorage = __esm({
1488
1491
  /**
1489
1492
  * Save tokens to encrypted file
1490
1493
  */
1491
- async saveToFile(tokens) {
1494
+ async saveToFile(tokens2) {
1492
1495
  await fsp__namespace.default.mkdir(this.CONFIG_DIR, { recursive: true });
1493
1496
  const key = await this.getEncryptionKey();
1494
1497
  const iv = crypto4__namespace.default.randomBytes(16);
1495
1498
  const cipher = crypto4__namespace.default.createCipheriv("aes-256-gcm", key, iv);
1496
- const tokenData = JSON.stringify(tokens);
1499
+ const tokenData = JSON.stringify(tokens2);
1497
1500
  let encrypted = cipher.update(tokenData, "utf8", "hex");
1498
1501
  encrypted += cipher.final("hex");
1499
1502
  const authTag = cipher.getAuthTag();
@@ -1553,9 +1556,9 @@ var init_TokenStorage = __esm({
1553
1556
  const decipher = crypto4__namespace.default.createDecipheriv("aes-256-cbc", keyBuffer, Buffer.alloc(16, 0));
1554
1557
  let decrypted = decipher.update(fileData.data, "hex", "utf8");
1555
1558
  decrypted += decipher.final("utf8");
1556
- const tokens = JSON.parse(decrypted);
1557
- await this.saveToFile(tokens);
1558
- return tokens;
1559
+ const tokens2 = JSON.parse(decrypted);
1560
+ await this.saveToFile(tokens2);
1561
+ return tokens2;
1559
1562
  } catch {
1560
1563
  return null;
1561
1564
  }
@@ -1855,9 +1858,9 @@ var init_AuthenticationManager = __esm({
1855
1858
  async isAuthenticated() {
1856
1859
  await this.ensureInitialized();
1857
1860
  try {
1858
- const tokens = await this.tokenStorage.load();
1859
- if (!tokens) return false;
1860
- if (Date.now() >= tokens.expiresAt + this.CLOCK_SKEW) {
1861
+ const tokens2 = await this.tokenStorage.load();
1862
+ if (!tokens2) return false;
1863
+ if (Date.now() >= tokens2.expiresAt + this.CLOCK_SKEW) {
1861
1864
  return await this.refreshToken();
1862
1865
  }
1863
1866
  return true;
@@ -1882,8 +1885,8 @@ var init_AuthenticationManager = __esm({
1882
1885
  async getCurrentUser() {
1883
1886
  await this.ensureInitialized();
1884
1887
  if (process.env.MARIA_AUTH_MODE === "local") {
1885
- const tokens2 = await this.tokenStorage.load();
1886
- if (!tokens2) {
1888
+ const tokens3 = await this.tokenStorage.load();
1889
+ if (!tokens3) {
1887
1890
  throw new AuthenticationRequiredError(ERROR_MESSAGES.AUTH_REQUIRED);
1888
1891
  }
1889
1892
  return {
@@ -1900,15 +1903,15 @@ var init_AuthenticationManager = __esm({
1900
1903
  models: []
1901
1904
  };
1902
1905
  }
1903
- const tokens = await this.getValidTokens();
1904
- if (!tokens) {
1906
+ const tokens2 = await this.getValidTokens();
1907
+ if (!tokens2) {
1905
1908
  throw new AuthenticationRequiredError(ERROR_MESSAGES.AUTH_REQUIRED);
1906
1909
  }
1907
1910
  try {
1908
1911
  const response = await fetch(`${this.apiBase}/api/user/profile`, {
1909
1912
  headers: {
1910
- "Authorization": `Bearer ${tokens.accessToken}`,
1911
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.9"}`
1913
+ "Authorization": `Bearer ${tokens2.accessToken}`,
1914
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.10"}`
1912
1915
  }
1913
1916
  });
1914
1917
  if (response.status === 401) {
@@ -1943,16 +1946,16 @@ var init_AuthenticationManager = __esm({
1943
1946
  if (process.env.MARIA_AUTH_MODE === "local") {
1944
1947
  return await this.loginWithLocalMock();
1945
1948
  }
1946
- let tokens;
1949
+ let tokens2;
1947
1950
  const forceDevice = options.device || process.env.MARIA_AUTH_DEVICE_FLOW === "true" || !this.canLaunchBrowser();
1948
1951
  if (forceDevice) {
1949
1952
  if (!options.device) {
1950
1953
  console.warn("PKCE is unavailable in this environment; using device flow.");
1951
1954
  }
1952
- tokens = await this.loginWithDeviceFlow();
1955
+ tokens2 = await this.loginWithDeviceFlow();
1953
1956
  } else {
1954
1957
  try {
1955
- tokens = await this.loginWithPKCEFlow();
1958
+ tokens2 = await this.loginWithPKCEFlow();
1956
1959
  } catch (error2) {
1957
1960
  console.error("PKCE flow error:", error2);
1958
1961
  if (error2.message?.includes("ECONNREFUSED") || error2.message?.includes("fetch failed")) {
@@ -1969,12 +1972,12 @@ var init_AuthenticationManager = __esm({
1969
1972
  throw new Error("Authentication service unavailable. See above for alternatives.");
1970
1973
  }
1971
1974
  console.warn("PKCE flow failed, falling back to device flow");
1972
- tokens = await this.loginWithDeviceFlow();
1975
+ tokens2 = await this.loginWithDeviceFlow();
1973
1976
  }
1974
1977
  }
1975
- await this.tokenStorage.save(tokens);
1978
+ await this.tokenStorage.save(tokens2);
1976
1979
  const user = await this.getCurrentUser();
1977
- return { success: true, user, tokens };
1980
+ return { success: true, user, tokens: tokens2 };
1978
1981
  } catch (error2) {
1979
1982
  console.error("Login failed:", error2);
1980
1983
  return {
@@ -2024,10 +2027,10 @@ var init_AuthenticationManager = __esm({
2024
2027
  async logout(options = {}) {
2025
2028
  await this.ensureInitialized();
2026
2029
  try {
2027
- const tokens = await this.tokenStorage.load();
2028
- if (tokens && !options.force) {
2030
+ const tokens2 = await this.tokenStorage.load();
2031
+ if (tokens2 && !options.force) {
2029
2032
  try {
2030
- await this.revokeTokens(tokens, options.all || false);
2033
+ await this.revokeTokens(tokens2, options.all || false);
2031
2034
  } catch (error2) {
2032
2035
  console.warn("Server token revocation failed:", error2);
2033
2036
  }
@@ -2046,14 +2049,14 @@ var init_AuthenticationManager = __esm({
2046
2049
  async refreshToken() {
2047
2050
  await this.ensureInitialized();
2048
2051
  try {
2049
- const tokens = await this.tokenStorage.load();
2050
- if (!tokens?.refreshToken) return false;
2052
+ const tokens2 = await this.tokenStorage.load();
2053
+ if (!tokens2?.refreshToken) return false;
2051
2054
  const response = await fetch(`${this.authBase}/auth/token`, {
2052
2055
  method: "POST",
2053
2056
  headers: { "Content-Type": "application/json" },
2054
2057
  body: JSON.stringify({
2055
2058
  grant_type: "refresh_token",
2056
- refresh_token: tokens.refreshToken,
2059
+ refresh_token: tokens2.refreshToken,
2057
2060
  client_id: this.clientId
2058
2061
  })
2059
2062
  });
@@ -2062,7 +2065,7 @@ var init_AuthenticationManager = __esm({
2062
2065
  const updatedTokens = {
2063
2066
  idToken: newTokens.id_token,
2064
2067
  accessToken: newTokens.access_token,
2065
- refreshToken: newTokens.refresh_token || tokens.refreshToken,
2068
+ refreshToken: newTokens.refresh_token || tokens2.refreshToken,
2066
2069
  customToken: newTokens.custom_token,
2067
2070
  expiresAt: Date.now() + newTokens.expires_in * 1e3
2068
2071
  };
@@ -2177,13 +2180,13 @@ var init_AuthenticationManager = __esm({
2177
2180
  if (!finishResponse.ok) {
2178
2181
  throw new Error(`Device flow failed: ${finishResponse.statusText}`);
2179
2182
  }
2180
- const tokens = await finishResponse.json();
2183
+ const tokens2 = await finishResponse.json();
2181
2184
  return {
2182
- idToken: tokens.id_token || tokens.access_token || "",
2183
- accessToken: tokens.access_token || tokens.id_token || "",
2184
- refreshToken: tokens.refresh_token || "",
2185
- customToken: tokens.custom_token,
2186
- expiresAt: Date.now() + (tokens.expires_in ? Number(tokens.expires_in) : 600) * 1e3
2185
+ idToken: tokens2.id_token || tokens2.access_token || "",
2186
+ accessToken: tokens2.access_token || tokens2.id_token || "",
2187
+ refreshToken: tokens2.refresh_token || "",
2188
+ customToken: tokens2.custom_token,
2189
+ expiresAt: Date.now() + (tokens2.expires_in ? Number(tokens2.expires_in) : 600) * 1e3
2187
2190
  };
2188
2191
  }
2189
2192
  throw new Error(ERROR_MESSAGES.LOGIN_TIMEOUT);
@@ -2324,13 +2327,13 @@ var init_AuthenticationManager = __esm({
2324
2327
  console.error("Token exchange failed:", response.status, response.statusText, bodyText);
2325
2328
  throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
2326
2329
  }
2327
- const tokens = await response.json();
2330
+ const tokens2 = await response.json();
2328
2331
  return {
2329
- idToken: tokens.id_token,
2330
- accessToken: tokens.access_token,
2331
- refreshToken: tokens.refresh_token,
2332
- customToken: tokens.custom_token,
2333
- expiresAt: Date.now() + tokens.expires_in * 1e3
2332
+ idToken: tokens2.id_token,
2333
+ accessToken: tokens2.access_token,
2334
+ refreshToken: tokens2.refresh_token,
2335
+ customToken: tokens2.custom_token,
2336
+ expiresAt: Date.now() + tokens2.expires_in * 1e3
2334
2337
  };
2335
2338
  } catch (error2) {
2336
2339
  console.error("Token exchange request error:", error2);
@@ -2340,15 +2343,15 @@ var init_AuthenticationManager = __esm({
2340
2343
  /**
2341
2344
  * Revoke tokens on server
2342
2345
  */
2343
- async revokeTokens(tokens, allDevices) {
2346
+ async revokeTokens(tokens2, allDevices) {
2344
2347
  const response = await fetch(`${this.apiBase}/api/auth/revoke`, {
2345
2348
  method: "POST",
2346
2349
  headers: {
2347
2350
  "Content-Type": "application/json",
2348
- "Authorization": `Bearer ${tokens.accessToken}`
2351
+ "Authorization": `Bearer ${tokens2.accessToken}`
2349
2352
  },
2350
2353
  body: JSON.stringify({
2351
- refresh_token: tokens.refreshToken,
2354
+ refresh_token: tokens2.refreshToken,
2352
2355
  all_devices: allDevices
2353
2356
  })
2354
2357
  });
@@ -2360,17 +2363,17 @@ var init_AuthenticationManager = __esm({
2360
2363
  * Get valid tokens (refresh if needed)
2361
2364
  */
2362
2365
  async getValidTokens() {
2363
- const tokens = await this.tokenStorage.load();
2364
- if (!tokens) return null;
2366
+ const tokens2 = await this.tokenStorage.load();
2367
+ if (!tokens2) return null;
2365
2368
  const now2 = Date.now();
2366
- const expiresWithBuffer = tokens.expiresAt - this.REFRESH_THRESHOLD + this.CLOCK_SKEW;
2369
+ const expiresWithBuffer = tokens2.expiresAt - this.REFRESH_THRESHOLD + this.CLOCK_SKEW;
2367
2370
  if (now2 >= expiresWithBuffer) {
2368
2371
  if (await this.refreshToken()) {
2369
2372
  return await this.tokenStorage.load();
2370
2373
  }
2371
2374
  return null;
2372
2375
  }
2373
- return tokens;
2376
+ return tokens2;
2374
2377
  }
2375
2378
  /**
2376
2379
  * Secure string comparison
@@ -2449,15 +2452,15 @@ function withAuth(fn) {
2449
2452
  return async (...args2) => {
2450
2453
  const testMode = process.env.MARIA_TEST_MODE === "1" || process.env.VITEST === "true" || process.env.NODE_ENV === "test";
2451
2454
  try {
2452
- const tokens = await authManager.getValidTokens();
2453
- if (!tokens) {
2455
+ const tokens2 = await authManager.getValidTokens();
2456
+ if (!tokens2) {
2454
2457
  console.log(chalk37__default.default.red("\u{1F510} Authentication required \xB7 Run: maria /login"));
2455
2458
  if (!testMode) process.exit(AUTH_EXIT_CODES.AUTH_REQUIRED);
2456
2459
  return { success: false, message: "AUTH_REQUIRED" };
2457
2460
  }
2458
- global.MARIA_ID_TOKEN = tokens.idToken;
2459
- global.MARIA_ACCESS_TOKEN = tokens.accessToken;
2460
- global.MARIA_SESSION_ID = tokens.sessionId;
2461
+ global.MARIA_ID_TOKEN = tokens2.idToken;
2462
+ global.MARIA_ACCESS_TOKEN = tokens2.accessToken;
2463
+ global.MARIA_SESSION_ID = tokens2.sessionId;
2461
2464
  return await fn(...args2);
2462
2465
  } catch (error2) {
2463
2466
  if (error2.code === "AUTH_REQUIRED") {
@@ -2598,11 +2601,11 @@ function getDeviceId() {
2598
2601
  function getSessionId() {
2599
2602
  return global.MARIA_SESSION_ID;
2600
2603
  }
2601
- async function callApi(path55, init2 = {}) {
2604
+ async function callApi(path56, init2 = {}) {
2602
2605
  const apiBase = process.env.MARIA_API_BASE || "http://localhost:3001";
2603
- const fullUrl = `${apiBase}${path55}`;
2604
- let tokens = await authManager.getValidTokens();
2605
- if (!tokens) {
2606
+ const fullUrl = `${apiBase}${path56}`;
2607
+ let tokens2 = await authManager.getValidTokens();
2608
+ if (!tokens2) {
2606
2609
  console.log(chalk37__default.default.red(ERR.AUTH_REQUIRED.msg));
2607
2610
  process.exit(ERR.AUTH_REQUIRED.code);
2608
2611
  }
@@ -2611,7 +2614,7 @@ async function callApi(path55, init2 = {}) {
2611
2614
  "Authorization": `Bearer ${token}`,
2612
2615
  "X-Device-Id": getDeviceId(),
2613
2616
  "X-Session-Id": getSessionId() || "",
2614
- "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.9"}`,
2617
+ "User-Agent": `maria-cli/${process.env.CLI_VERSION || "4.3.10"}`,
2615
2618
  "Content-Type": init2.headers?.["Content-Type"] || "application/json"
2616
2619
  });
2617
2620
  const doFetch = async (token) => {
@@ -2628,7 +2631,7 @@ async function callApi(path55, init2 = {}) {
2628
2631
  throw error2;
2629
2632
  }
2630
2633
  };
2631
- let response = await doFetch(tokens.accessToken);
2634
+ let response = await doFetch(tokens2.accessToken);
2632
2635
  if (response.status === 401) {
2633
2636
  console.log(chalk37__default.default.gray("Token expired, refreshing..."));
2634
2637
  const refreshed = await authManager.refreshToken();
@@ -2636,12 +2639,12 @@ async function callApi(path55, init2 = {}) {
2636
2639
  console.log(chalk37__default.default.red(ERR.REAUTH_REQUIRED.msg));
2637
2640
  process.exit(ERR.REAUTH_REQUIRED.code);
2638
2641
  }
2639
- tokens = await authManager.getValidTokens();
2640
- if (!tokens) {
2642
+ tokens2 = await authManager.getValidTokens();
2643
+ if (!tokens2) {
2641
2644
  console.log(chalk37__default.default.red(ERR.REAUTH_REQUIRED.msg));
2642
2645
  process.exit(ERR.REAUTH_REQUIRED.code);
2643
2646
  }
2644
- response = await doFetch(tokens.accessToken);
2647
+ response = await doFetch(tokens2.accessToken);
2645
2648
  if (response.status === 401) {
2646
2649
  console.log(chalk37__default.default.red(ERR.REAUTH_REQUIRED.msg));
2647
2650
  process.exit(ERR.REAUTH_REQUIRED.code);
@@ -2654,7 +2657,7 @@ async function callApi(path55, init2 = {}) {
2654
2657
  const waitTime = Math.min(retryAfter, 60);
2655
2658
  console.log(chalk37__default.default.yellow(`\u23F1\uFE0F Rate limit: wait ${waitTime}s`));
2656
2659
  await new Promise((resolve17) => setTimeout(resolve17, waitTime * 1e3));
2657
- response = await doFetch(tokens.accessToken);
2660
+ response = await doFetch(tokens2.accessToken);
2658
2661
  }
2659
2662
  if (response.status === 402) {
2660
2663
  console.log(chalk37__default.default.yellow(ERR.QUOTA.msg));
@@ -2669,8 +2672,8 @@ async function callApi(path55, init2 = {}) {
2669
2672
  }
2670
2673
  return response;
2671
2674
  }
2672
- async function callApiJson(path55, init2 = {}) {
2673
- const response = await callApi(path55, init2);
2675
+ async function callApiJson(path56, init2 = {}) {
2676
+ const response = await callApi(path56, init2);
2674
2677
  if (!response.ok) {
2675
2678
  const error2 = await response.json().catch(() => ({
2676
2679
  message: `API error: ${response.status} ${response.statusText}`
@@ -2710,8 +2713,8 @@ var USE_LEGACY_PROVIDERS2, DEFAULT_PROVIDER2, DEFAULT_MODEL2;
2710
2713
  var init_config = __esm({
2711
2714
  "src/providers/config.ts"() {
2712
2715
  USE_LEGACY_PROVIDERS2 = false;
2713
- DEFAULT_PROVIDER2 = process.env.DEFAULT_PROVIDER || "openai";
2714
- DEFAULT_MODEL2 = process.env.OPENAI_MODEL || process.env.MARIA_DEFAULT_MODEL || "gpt-5-mini";
2716
+ DEFAULT_PROVIDER2 = process.env.DEFAULT_PROVIDER || "google";
2717
+ DEFAULT_MODEL2 = process.env.MARIA_DEFAULT_MODEL || process.env.OPENAI_MODEL || "gemini-2.5-flash";
2715
2718
  }
2716
2719
  });
2717
2720
 
@@ -7514,22 +7517,22 @@ var init_from = __esm({
7514
7517
  init_file();
7515
7518
  init_fetch_blob();
7516
7519
  ({ stat } = fs21.promises);
7517
- blobFromSync = (path55, type) => fromBlob(fs21.statSync(path55), path55, type);
7518
- blobFrom = (path55, type) => stat(path55).then((stat13) => fromBlob(stat13, path55, type));
7519
- fileFrom = (path55, type) => stat(path55).then((stat13) => fromFile(stat13, path55, type));
7520
- fileFromSync = (path55, type) => fromFile(fs21.statSync(path55), path55, type);
7521
- fromBlob = (stat13, path55, type = "") => new fetch_blob_default([new BlobDataItem({
7522
- path: path55,
7520
+ blobFromSync = (path56, type) => fromBlob(fs21.statSync(path56), path56, type);
7521
+ blobFrom = (path56, type) => stat(path56).then((stat13) => fromBlob(stat13, path56, type));
7522
+ fileFrom = (path56, type) => stat(path56).then((stat13) => fromFile(stat13, path56, type));
7523
+ fileFromSync = (path56, type) => fromFile(fs21.statSync(path56), path56, type);
7524
+ fromBlob = (stat13, path56, type = "") => new fetch_blob_default([new BlobDataItem({
7525
+ path: path56,
7523
7526
  size: stat13.size,
7524
7527
  lastModified: stat13.mtimeMs,
7525
7528
  start: 0
7526
7529
  })], { type });
7527
- fromFile = (stat13, path55, type = "") => new file_default([new BlobDataItem({
7528
- path: path55,
7530
+ fromFile = (stat13, path56, type = "") => new file_default([new BlobDataItem({
7531
+ path: path56,
7529
7532
  size: stat13.size,
7530
7533
  lastModified: stat13.mtimeMs,
7531
7534
  start: 0
7532
- })], path54.basename(path55), { type, lastModified: stat13.mtimeMs });
7535
+ })], path55.basename(path56), { type, lastModified: stat13.mtimeMs });
7533
7536
  BlobDataItem = class _BlobDataItem {
7534
7537
  #path;
7535
7538
  #start;
@@ -11249,7 +11252,7 @@ var init_chat_context_service = __esm({
11249
11252
  // 400K session window
11250
11253
  compressionThreshold: config2?.compressionThreshold || 0.8,
11251
11254
  summaryTokenLimit: config2?.summaryTokenLimit || 2e3,
11252
- persistPath: config2?.persistPath || path54__namespace.join(process.env["HOME"] || "", ".maria", "context")
11255
+ persistPath: config2?.persistPath || path55__namespace.join(process.env["HOME"] || "", ".maria", "context")
11253
11256
  };
11254
11257
  this.sessionId = this.generateSessionId();
11255
11258
  }
@@ -11270,16 +11273,16 @@ var init_chat_context_service = __esm({
11270
11273
  }
11271
11274
  }
11272
11275
  async addMessage(message) {
11273
- const tokens = this.countTokens(message.content);
11276
+ const tokens2 = this.countTokens(message.content);
11274
11277
  const fullMessage = {
11275
11278
  ...message,
11276
11279
  timestamp: /* @__PURE__ */ new Date(),
11277
- tokens
11280
+ tokens: tokens2
11278
11281
  };
11279
11282
  this.fullHistory.push(fullMessage);
11280
11283
  this.contextWindow.push(fullMessage);
11281
- this.currentTokens += tokens;
11282
- this.sessionTokens += tokens;
11284
+ this.currentTokens += tokens2;
11285
+ this.sessionTokens += tokens2;
11283
11286
  await this.optimizeMemory();
11284
11287
  this.emit("message-added", fullMessage);
11285
11288
  this.emit("context-updated", this.getStats());
@@ -11373,7 +11376,7 @@ var init_chat_context_service = __esm({
11373
11376
  if (!this.config.persistPath) return;
11374
11377
  try {
11375
11378
  await fsp__namespace.mkdir(this.config.persistPath, { recursive: true });
11376
- const sessionFile = path54__namespace.join(
11379
+ const sessionFile = path55__namespace.join(
11377
11380
  this.config.persistPath,
11378
11381
  `${this.sessionId}.json`
11379
11382
  );
@@ -11444,8 +11447,8 @@ var init_conversation_persistence = __esm({
11444
11447
  autoSaveInterval = null;
11445
11448
  pendingWrites = [];
11446
11449
  constructor(maxHistorySize = 100) {
11447
- const configDir = path54__namespace.join(os13__namespace.homedir(), ".maria");
11448
- this.sessionFile = path54__namespace.join(configDir, "conversation-history.json");
11450
+ const configDir = path55__namespace.join(os13__namespace.homedir(), ".maria");
11451
+ this.sessionFile = path55__namespace.join(configDir, "conversation-history.json");
11449
11452
  this.maxHistorySize = maxHistorySize;
11450
11453
  this.ensureConfigDir();
11451
11454
  this.startAutoSave();
@@ -11455,7 +11458,7 @@ var init_conversation_persistence = __esm({
11455
11458
  */
11456
11459
  async ensureConfigDir() {
11457
11460
  try {
11458
- const configDir = path54__namespace.dirname(this.sessionFile);
11461
+ const configDir = path55__namespace.dirname(this.sessionFile);
11459
11462
  await fs21.promises.mkdir(configDir, { recursive: true });
11460
11463
  } catch (error2) {
11461
11464
  console.warn("Failed to create config directory:", error2);
@@ -12984,8 +12987,8 @@ __export(api_caller_exports, {
12984
12987
  executeCode: () => executeCode
12985
12988
  });
12986
12989
  async function callAPI(endpoint, options = {}) {
12987
- const tokens = await authManager2.getValidTokens();
12988
- if (!tokens) {
12990
+ const tokens2 = await authManager2.getValidTokens();
12991
+ if (!tokens2) {
12989
12992
  throw new Error("Authentication required. Please run /login first.");
12990
12993
  }
12991
12994
  const apiBase = process.env.MARIA_API_BASE || "https://api.maria-code.ai";
@@ -13000,7 +13003,7 @@ async function callAPI(endpoint, options = {}) {
13000
13003
  const response = await fetch(url2, {
13001
13004
  method: options.method || "GET",
13002
13005
  headers: {
13003
- "Authorization": `Bearer ${tokens.accessToken}`,
13006
+ "Authorization": `Bearer ${tokens2.accessToken}`,
13004
13007
  "Content-Type": "application/json",
13005
13008
  ...options.headers
13006
13009
  },
@@ -14066,14 +14069,14 @@ var init_ReadyCommandsService = __esm({
14066
14069
  } else {
14067
14070
  const possiblePaths = [
14068
14071
  // For bundled dist version
14069
- path54__namespace.join(__dirname, "READY.manifest.json"),
14070
- path54__namespace.join(__dirname, "../READY.manifest.json"),
14071
- path54__namespace.join(process.cwd(), "dist/READY.manifest.json"),
14072
+ path55__namespace.join(__dirname, "READY.manifest.json"),
14073
+ path55__namespace.join(__dirname, "../READY.manifest.json"),
14074
+ path55__namespace.join(process.cwd(), "dist/READY.manifest.json"),
14072
14075
  // For development/source version
14073
- path54__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
14074
- path54__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
14075
- path54__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
14076
- path54__namespace.join(process.cwd(), "READY.manifest.json")
14076
+ path55__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
14077
+ path55__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
14078
+ path55__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
14079
+ path55__namespace.join(process.cwd(), "READY.manifest.json")
14077
14080
  ];
14078
14081
  this.manifestPath = possiblePaths[0];
14079
14082
  }
@@ -14084,17 +14087,17 @@ var init_ReadyCommandsService = __esm({
14084
14087
  async findManifestPath() {
14085
14088
  const possiblePaths = [
14086
14089
  // For bundled dist version
14087
- path54__namespace.join(__dirname, "READY.manifest.json"),
14088
- path54__namespace.join(__dirname, "../READY.manifest.json"),
14089
- path54__namespace.join(process.cwd(), "dist/READY.manifest.json"),
14090
+ path55__namespace.join(__dirname, "READY.manifest.json"),
14091
+ path55__namespace.join(__dirname, "../READY.manifest.json"),
14092
+ path55__namespace.join(process.cwd(), "dist/READY.manifest.json"),
14090
14093
  // For development/source version
14091
- path54__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
14092
- path54__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
14093
- path54__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
14094
- path54__namespace.join(process.cwd(), "READY.manifest.json"),
14094
+ path55__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
14095
+ path55__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
14096
+ path55__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
14097
+ path55__namespace.join(process.cwd(), "READY.manifest.json"),
14095
14098
  // Additional paths for different build scenarios
14096
- path54__namespace.resolve(__dirname, "../../../src/slash-commands/READY.manifest.json"),
14097
- path54__namespace.resolve(process.cwd(), "src/slash-commands/READY.manifest.json")
14099
+ path55__namespace.resolve(__dirname, "../../../src/slash-commands/READY.manifest.json"),
14100
+ path55__namespace.resolve(process.cwd(), "src/slash-commands/READY.manifest.json")
14098
14101
  ];
14099
14102
  for (const testPath of possiblePaths) {
14100
14103
  try {
@@ -14656,7 +14659,7 @@ async function loadFirebaseAdmin() {
14656
14659
  try {
14657
14660
  const firebaseAdminModule = await import('firebase-admin/app');
14658
14661
  const firestoreModule = await import('firebase-admin/firestore');
14659
- const keyPath = path54__namespace.join(process.cwd(), "config", "maria-cli-firestore-key.json");
14662
+ const keyPath = path55__namespace.join(process.cwd(), "config", "maria-cli-firestore-key.json");
14660
14663
  if (!adminApp && firebaseAdminModule.getApps().length === 0) {
14661
14664
  adminApp = firebaseAdminModule.initializeApp({
14662
14665
  credential: firebaseAdminModule.cert(keyPath),
@@ -15028,8 +15031,8 @@ var init_bigquery_telemetry = __esm({
15028
15031
  });
15029
15032
  async function getUserContext() {
15030
15033
  try {
15031
- const configDir = path54__namespace.join(process.env.HOME || process.env.USERPROFILE || "", ".maria");
15032
- const authFile = path54__namespace.join(configDir, "auth.json");
15034
+ const configDir = path55__namespace.join(process.env.HOME || process.env.USERPROFILE || "", ".maria");
15035
+ const authFile = path55__namespace.join(configDir, "auth.json");
15033
15036
  if (await fs9__namespace.pathExists(authFile)) {
15034
15037
  const authData = await fs9__namespace.readJson(authFile);
15035
15038
  return {
@@ -16205,7 +16208,7 @@ var init_setup_command = __esm({
16205
16208
  if (_setupRecord.filesGenerated) {
16206
16209
  for (const file of _setupRecord.filesGenerated) {
16207
16210
  try {
16208
- const _filePath = path54__namespace.default.join(context2.environment.cwd, file);
16211
+ const _filePath = path55__namespace.default.join(context2.environment.cwd, file);
16209
16212
  await fsp__namespace.default.unlink(_filePath);
16210
16213
  restoredFiles.push(file);
16211
16214
  } catch (innerError) {
@@ -16215,7 +16218,7 @@ var init_setup_command = __esm({
16215
16218
  }
16216
16219
  }
16217
16220
  }
16218
- const _setupRecordPath = path54__namespace.default.join(
16221
+ const _setupRecordPath = path55__namespace.default.join(
16219
16222
  context2.environment.cwd,
16220
16223
  ".maria",
16221
16224
  "setup.json"
@@ -16283,7 +16286,7 @@ var init_setup_command = __esm({
16283
16286
  }
16284
16287
  }
16285
16288
  async recordSetupCompletion(_context, result) {
16286
- const _mariaDir = path54__namespace.default.join(_context.environment.cwd, ".maria");
16289
+ const _mariaDir = path55__namespace.default.join(_context.environment.cwd, ".maria");
16287
16290
  await fsp__namespace.default.mkdir(_mariaDir, { recursive: true });
16288
16291
  const _setupRecord = {
16289
16292
  ...result,
@@ -16291,7 +16294,7 @@ var init_setup_command = __esm({
16291
16294
  version: "1.0.0",
16292
16295
  environment: _context.environment
16293
16296
  };
16294
- const _recordPath = path54__namespace.default.join(_mariaDir, "setup.json");
16297
+ const _recordPath = path55__namespace.default.join(_mariaDir, "setup.json");
16295
16298
  await fsp__namespace.default.writeFile(
16296
16299
  _recordPath,
16297
16300
  JSON.stringify(_setupRecord, null, 2),
@@ -16390,14 +16393,14 @@ Estimated time: 3-5 minutes
16390
16393
  }
16391
16394
  async detectConfigurationIssues(context2) {
16392
16395
  const _issues = [];
16393
- if (!await this.fileExists(path54__namespace.default.join(context2.environment.cwd, ".env.local"))) {
16396
+ if (!await this.fileExists(path55__namespace.default.join(context2.environment.cwd, ".env.local"))) {
16394
16397
  _issues.push({
16395
16398
  description: "Missing .env.local file",
16396
16399
  severity: "error"
16397
16400
  });
16398
16401
  }
16399
16402
  if (!await this.fileExists(
16400
- path54__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
16403
+ path55__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
16401
16404
  )) {
16402
16405
  _issues.push({
16403
16406
  description: "Missing .maria-code.toml file",
@@ -16413,7 +16416,7 @@ Estimated time: 3-5 minutes
16413
16416
  }
16414
16417
  async getSetupRecord(context2) {
16415
16418
  try {
16416
- const _recordPath = path54__namespace.default.join(
16419
+ const _recordPath = path55__namespace.default.join(
16417
16420
  context2.environment.cwd,
16418
16421
  ".maria",
16419
16422
  "setup.json"
@@ -16425,11 +16428,11 @@ Estimated time: 3-5 minutes
16425
16428
  }
16426
16429
  }
16427
16430
  async validateEnvironmentFile(context2) {
16428
- return this.fileExists(path54__namespace.default.join(context2.environment.cwd, ".env.local"));
16431
+ return this.fileExists(path55__namespace.default.join(context2.environment.cwd, ".env.local"));
16429
16432
  }
16430
16433
  async validateConfigFile(context2) {
16431
16434
  return this.fileExists(
16432
- path54__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
16435
+ path55__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
16433
16436
  );
16434
16437
  }
16435
16438
  async validateProviderConnections(_context) {
@@ -16456,7 +16459,7 @@ VLLM_API_URL=http://localhost:8000
16456
16459
  DEBUG=false
16457
16460
  LOG_LEVEL=info
16458
16461
  `;
16459
- const _envPath = path54__namespace.default.join(process.cwd(), ".env.local");
16462
+ const _envPath = path55__namespace.default.join(process.cwd(), ".env.local");
16460
16463
  await fsp__namespace.default.writeFile(_envPath, _envContent, "utf-8");
16461
16464
  return this.success("Environment template generated successfully", {
16462
16465
  files: [".env.local"],
@@ -16530,8 +16533,8 @@ var init_ConfigurationCommandService = __esm({
16530
16533
  var DIR, FILE, QuickPersistence;
16531
16534
  var init_quick_persistence = __esm({
16532
16535
  "src/services/memory-system/quick-persistence.ts"() {
16533
- DIR = path54__namespace.join(os13__namespace.homedir(), ".maria", "memory");
16534
- FILE = path54__namespace.join(DIR, "memories.jsonl");
16536
+ DIR = path55__namespace.join(os13__namespace.homedir(), ".maria", "memory");
16537
+ FILE = path55__namespace.join(DIR, "memories.jsonl");
16535
16538
  QuickPersistence = class {
16536
16539
  static async init() {
16537
16540
  await fsp__namespace.mkdir(DIR, { recursive: true });
@@ -16653,8 +16656,8 @@ var init_quick_persistence = __esm({
16653
16656
  const mine = rows.filter((r2) => r2.userId === userId);
16654
16657
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
16655
16658
  const filename = `maria-memory-export-${timestamp}.${format}`;
16656
- const exportDir = path54__namespace.join(os13__namespace.homedir(), ".maria", "exports");
16657
- const exportPath = path54__namespace.join(exportDir, filename);
16659
+ const exportDir = path55__namespace.join(os13__namespace.homedir(), ".maria", "exports");
16660
+ const exportPath = path55__namespace.join(exportDir, filename);
16658
16661
  await fsp__namespace.mkdir(exportDir, { recursive: true });
16659
16662
  if (format === "jsonl") {
16660
16663
  await fsp__namespace.writeFile(
@@ -19288,7 +19291,7 @@ var init_StateManager = __esm({
19288
19291
  maxCheckpointAge = 7 * 24 * 60 * 60 * 1e3;
19289
19292
  // 7 days
19290
19293
  constructor() {
19291
- this.checkpointsDir = path54__namespace.join(os13__namespace.homedir(), ".maria", "checkpoints");
19294
+ this.checkpointsDir = path55__namespace.join(os13__namespace.homedir(), ".maria", "checkpoints");
19292
19295
  }
19293
19296
  /**
19294
19297
  * Initialize checkpoints directory
@@ -19314,7 +19317,7 @@ var init_StateManager = __esm({
19314
19317
  const checkpointId = `${planId}_${Date.now()}`;
19315
19318
  const timestamp = Date.now();
19316
19319
  try {
19317
- const checkpointPath = path54__namespace.join(this.checkpointsDir, checkpointId);
19320
+ const checkpointPath = path55__namespace.join(this.checkpointsDir, checkpointId);
19318
19321
  await fsp__namespace.mkdir(checkpointPath, { recursive: true });
19319
19322
  const backups = await this.createBackups(actions, checkpointPath);
19320
19323
  const configSnapshots = await this.createConfigSnapshots(
@@ -19333,7 +19336,7 @@ var init_StateManager = __esm({
19333
19336
  riskScore
19334
19337
  }
19335
19338
  };
19336
- const metadataPath = path54__namespace.join(checkpointPath, "checkpoint.json");
19339
+ const metadataPath = path55__namespace.join(checkpointPath, "checkpoint.json");
19337
19340
  await fsp__namespace.writeFile(
19338
19341
  metadataPath,
19339
19342
  JSON.stringify(checkpoint, null, 2),
@@ -19505,7 +19508,7 @@ var init_StateManager = __esm({
19505
19508
  */
19506
19509
  async removeCheckpoint(checkpointId) {
19507
19510
  try {
19508
- const checkpointPath = path54__namespace.join(this.checkpointsDir, checkpointId);
19511
+ const checkpointPath = path55__namespace.join(this.checkpointsDir, checkpointId);
19509
19512
  await fsp__namespace.rm(checkpointPath, { recursive: true, force: true });
19510
19513
  logger.info(`StateManager: Removed checkpoint ${checkpointId}`);
19511
19514
  return true;
@@ -19536,7 +19539,7 @@ var init_StateManager = __esm({
19536
19539
  */
19537
19540
  async createBackups(actions, checkpointPath) {
19538
19541
  const backups = [];
19539
- const backupDir = path54__namespace.join(checkpointPath, "backups");
19542
+ const backupDir = path55__namespace.join(checkpointPath, "backups");
19540
19543
  await fsp__namespace.mkdir(backupDir, { recursive: true });
19541
19544
  for (const action of actions) {
19542
19545
  const filesToBackup = this.extractFilePathsFromAction(action);
@@ -19545,7 +19548,7 @@ var init_StateManager = __esm({
19545
19548
  const resolvedPath = this.resolvePath(filePath);
19546
19549
  const stats = await fsp__namespace.stat(resolvedPath);
19547
19550
  const backupFileName = this.sanitizeFileName(resolvedPath);
19548
- const backupPath = path54__namespace.join(backupDir, backupFileName);
19551
+ const backupPath = path55__namespace.join(backupDir, backupFileName);
19549
19552
  await fsp__namespace.copyFile(resolvedPath, backupPath);
19550
19553
  backups.push({
19551
19554
  originalPath: resolvedPath,
@@ -19568,7 +19571,7 @@ var init_StateManager = __esm({
19568
19571
  */
19569
19572
  async createConfigSnapshots(actions, checkpointPath) {
19570
19573
  const snapshots = [];
19571
- const configDir = path54__namespace.join(checkpointPath, "configs");
19574
+ const configDir = path55__namespace.join(checkpointPath, "configs");
19572
19575
  await fsp__namespace.mkdir(configDir, { recursive: true });
19573
19576
  const configPaths = /* @__PURE__ */ new Set();
19574
19577
  for (const action of actions) {
@@ -19601,7 +19604,7 @@ var init_StateManager = __esm({
19601
19604
  * Load checkpoint from disk
19602
19605
  */
19603
19606
  async loadCheckpoint(checkpointId) {
19604
- const metadataPath = path54__namespace.join(
19607
+ const metadataPath = path55__namespace.join(
19605
19608
  this.checkpointsDir,
19606
19609
  checkpointId,
19607
19610
  "checkpoint.json"
@@ -19627,9 +19630,9 @@ var init_StateManager = __esm({
19627
19630
  */
19628
19631
  resolvePath(filePath) {
19629
19632
  if (filePath.startsWith("~/")) {
19630
- return path54__namespace.join(os13__namespace.homedir(), filePath.slice(2));
19633
+ return path55__namespace.join(os13__namespace.homedir(), filePath.slice(2));
19631
19634
  }
19632
- return path54__namespace.resolve(filePath);
19635
+ return path55__namespace.resolve(filePath);
19633
19636
  }
19634
19637
  /**
19635
19638
  * Sanitize filename for backup storage
@@ -19693,7 +19696,7 @@ var init_StateManager = __esm({
19693
19696
  } catch {
19694
19697
  }
19695
19698
  } else {
19696
- await fsp__namespace.mkdir(path54__namespace.dirname(config2.configPath), { recursive: true });
19699
+ await fsp__namespace.mkdir(path55__namespace.dirname(config2.configPath), { recursive: true });
19697
19700
  await fsp__namespace.writeFile(config2.configPath, config2.content, "utf-8");
19698
19701
  }
19699
19702
  logger.debug(`StateManager: Restored config ${config2.configPath}`);
@@ -19811,9 +19814,9 @@ var init_SafetyGuard = __esm({
19811
19814
  }
19812
19815
  }
19813
19816
  if (action.args.paths && Array.isArray(action.args.paths)) {
19814
- for (const path55 of action.args.paths) {
19815
- if (!this.validatePath(path55)) {
19816
- violations.push(`Invalid path: ${path55}`);
19817
+ for (const path56 of action.args.paths) {
19818
+ if (!this.validatePath(path56)) {
19819
+ violations.push(`Invalid path: ${path56}`);
19817
19820
  }
19818
19821
  }
19819
19822
  }
@@ -19869,15 +19872,15 @@ var init_SafetyGuard = __esm({
19869
19872
  * Validate file path against allowed/blocked lists
19870
19873
  */
19871
19874
  validatePath(filePath) {
19872
- const path55 = __require("path");
19873
- const resolvedPath = path55.resolve(filePath);
19875
+ const path56 = __require("path");
19876
+ const resolvedPath = path56.resolve(filePath);
19874
19877
  for (const blockedPath of this.constraints.blockedPaths) {
19875
- if (resolvedPath.startsWith(path55.resolve(blockedPath))) {
19878
+ if (resolvedPath.startsWith(path56.resolve(blockedPath))) {
19876
19879
  return false;
19877
19880
  }
19878
19881
  }
19879
19882
  for (const allowedPath of this.constraints.allowedPaths) {
19880
- if (resolvedPath.startsWith(path55.resolve(allowedPath))) {
19883
+ if (resolvedPath.startsWith(path56.resolve(allowedPath))) {
19881
19884
  return true;
19882
19885
  }
19883
19886
  }
@@ -19906,9 +19909,9 @@ var init_SafetyGuard = __esm({
19906
19909
  violations.push(`Invalid path in ${action.type}: ${action.args.path}`);
19907
19910
  }
19908
19911
  if (action.args.paths && Array.isArray(action.args.paths)) {
19909
- for (const path55 of action.args.paths) {
19910
- if (!this.validatePath(path55)) {
19911
- violations.push(`Invalid path in ${action.type}: ${path55}`);
19912
+ for (const path56 of action.args.paths) {
19913
+ if (!this.validatePath(path56)) {
19914
+ violations.push(`Invalid path in ${action.type}: ${path56}`);
19912
19915
  }
19913
19916
  }
19914
19917
  }
@@ -19968,8 +19971,8 @@ var require_package = __commonJS({
19968
19971
  "package.json"(exports, module) {
19969
19972
  module.exports = {
19970
19973
  name: "@bonginkan/maria",
19971
- version: "4.3.9",
19972
- 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.",
19974
+ version: "4.3.10",
19975
+ 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.",
19973
19976
  keywords: [
19974
19977
  "ai",
19975
19978
  "cli",
@@ -20529,7 +20532,7 @@ var init_AuditLogger = __esm({
20529
20532
  constructor(sessionId, options = {}) {
20530
20533
  this.sessionId = sessionId;
20531
20534
  this.options = {
20532
- logDir: path54__namespace.join(os13__namespace.homedir(), ".maria", "audit"),
20535
+ logDir: path55__namespace.join(os13__namespace.homedir(), ".maria", "audit"),
20533
20536
  maxLogSize: 10 * 1024 * 1024,
20534
20537
  // 10MB
20535
20538
  maxLogFiles: 30,
@@ -20539,7 +20542,7 @@ var init_AuditLogger = __esm({
20539
20542
  ...options
20540
20543
  };
20541
20544
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
20542
- this.logFilePath = path54__namespace.join(this.options.logDir, `audit-${date}.jsonl`);
20545
+ this.logFilePath = path55__namespace.join(this.options.logDir, `audit-${date}.jsonl`);
20543
20546
  }
20544
20547
  /**
20545
20548
  * Initialize audit logging
@@ -20828,7 +20831,7 @@ var init_AuditLogger = __esm({
20828
20831
  try {
20829
20832
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
20830
20833
  const timestamp = Date.now();
20831
- const archivePath = path54__namespace.join(
20834
+ const archivePath = path55__namespace.join(
20832
20835
  this.options.logDir,
20833
20836
  `audit-${date}-${timestamp}.jsonl`
20834
20837
  );
@@ -20868,7 +20871,7 @@ var init_AuditLogger = __esm({
20868
20871
  if (logFiles.length > this.options.maxLogFiles) {
20869
20872
  const toRemove = logFiles.slice(this.options.maxLogFiles);
20870
20873
  for (const file of toRemove) {
20871
- const filePath = path54__namespace.join(this.options.logDir, file);
20874
+ const filePath = path55__namespace.join(this.options.logDir, file);
20872
20875
  await fsp__namespace.unlink(filePath);
20873
20876
  logger.debug(`AuditLogger: Removed old log file ${file}`);
20874
20877
  }
@@ -20910,7 +20913,7 @@ var init_FileActionExecutor = __esm({
20910
20913
  FileActionExecutor = class {
20911
20914
  ALLOWED_PATHS = [
20912
20915
  process.cwd(),
20913
- path54__namespace.join(os13__namespace.homedir(), ".maria")
20916
+ path55__namespace.join(os13__namespace.homedir(), ".maria")
20914
20917
  ];
20915
20918
  /**
20916
20919
  * Execute file action
@@ -20972,7 +20975,7 @@ var init_FileActionExecutor = __esm({
20972
20975
  await fsp__namespace.access(resolvedPath);
20973
20976
  return { action: "already_exists", path: resolvedPath };
20974
20977
  } catch {
20975
- await fsp__namespace.mkdir(path54__namespace.dirname(resolvedPath), { recursive: true });
20978
+ await fsp__namespace.mkdir(path55__namespace.dirname(resolvedPath), { recursive: true });
20976
20979
  await fsp__namespace.writeFile(resolvedPath, "", "utf-8");
20977
20980
  logger.info(`Created file: ${resolvedPath}`);
20978
20981
  return { action: "created", path: resolvedPath };
@@ -21189,20 +21192,20 @@ var init_FileActionExecutor = __esm({
21189
21192
  */
21190
21193
  resolvePath(filePath) {
21191
21194
  if (filePath.startsWith("~/")) {
21192
- return path54__namespace.join(os13__namespace.homedir(), filePath.slice(2));
21195
+ return path55__namespace.join(os13__namespace.homedir(), filePath.slice(2));
21193
21196
  }
21194
- if (path54__namespace.isAbsolute(filePath)) {
21197
+ if (path55__namespace.isAbsolute(filePath)) {
21195
21198
  return filePath;
21196
21199
  }
21197
- return path54__namespace.resolve(process.cwd(), filePath);
21200
+ return path55__namespace.resolve(process.cwd(), filePath);
21198
21201
  }
21199
21202
  /**
21200
21203
  * Validate path is within allowed directories
21201
21204
  */
21202
21205
  validatePath(filePath) {
21203
- const resolvedPath = path54__namespace.resolve(filePath);
21206
+ const resolvedPath = path55__namespace.resolve(filePath);
21204
21207
  for (const allowedPath of this.ALLOWED_PATHS) {
21205
- const allowedResolved = path54__namespace.resolve(allowedPath);
21208
+ const allowedResolved = path55__namespace.resolve(allowedPath);
21206
21209
  if (resolvedPath.startsWith(allowedResolved)) {
21207
21210
  return;
21208
21211
  }
@@ -21217,7 +21220,7 @@ var init_ConfigActionExecutor = __esm({
21217
21220
  "src/services/self-healing/executors/ConfigActionExecutor.ts"() {
21218
21221
  init_logger();
21219
21222
  ConfigActionExecutor = class {
21220
- DEFAULT_CONFIG_PATH = path54__namespace.join(
21223
+ DEFAULT_CONFIG_PATH = path55__namespace.join(
21221
21224
  os13__namespace.homedir(),
21222
21225
  ".maria",
21223
21226
  "config.json"
@@ -21264,7 +21267,7 @@ var init_ConfigActionExecutor = __esm({
21264
21267
  };
21265
21268
  }
21266
21269
  try {
21267
- await fsp__namespace.mkdir(path54__namespace.dirname(resolvedPath), { recursive: true });
21270
+ await fsp__namespace.mkdir(path55__namespace.dirname(resolvedPath), { recursive: true });
21268
21271
  let config2 = {};
21269
21272
  try {
21270
21273
  const content = await fsp__namespace.readFile(resolvedPath, "utf-8");
@@ -21299,7 +21302,7 @@ var init_ConfigActionExecutor = __esm({
21299
21302
  };
21300
21303
  }
21301
21304
  try {
21302
- await fsp__namespace.mkdir(path54__namespace.dirname(resolvedPath), { recursive: true });
21305
+ await fsp__namespace.mkdir(path55__namespace.dirname(resolvedPath), { recursive: true });
21303
21306
  let config2 = {};
21304
21307
  try {
21305
21308
  const content = await fsp__namespace.readFile(resolvedPath, "utf-8");
@@ -21399,8 +21402,8 @@ var init_ConfigActionExecutor = __esm({
21399
21402
  /**
21400
21403
  * Set nested configuration value using dot notation
21401
21404
  */
21402
- setNestedValue(obj, path55, value) {
21403
- const keys = path55.split(".");
21405
+ setNestedValue(obj, path56, value) {
21406
+ const keys = path56.split(".");
21404
21407
  let current = obj;
21405
21408
  for (let i2 = 0; i2 < keys.length - 1; i2++) {
21406
21409
  const key = keys[i2];
@@ -21417,9 +21420,9 @@ var init_ConfigActionExecutor = __esm({
21417
21420
  resolveConfigPath(configPath) {
21418
21421
  if (configPath) {
21419
21422
  if (configPath.startsWith("~/")) {
21420
- return path54__namespace.join(os13__namespace.homedir(), configPath.slice(2));
21423
+ return path55__namespace.join(os13__namespace.homedir(), configPath.slice(2));
21421
21424
  }
21422
- return path54__namespace.resolve(configPath);
21425
+ return path55__namespace.resolve(configPath);
21423
21426
  }
21424
21427
  return this.DEFAULT_CONFIG_PATH;
21425
21428
  }
@@ -21432,10 +21435,10 @@ var init_CacheActionExecutor = __esm({
21432
21435
  init_logger();
21433
21436
  CacheActionExecutor = class {
21434
21437
  CACHE_PATHS = [
21435
- path54__namespace.join(os13__namespace.homedir(), ".maria", "cache"),
21436
- path54__namespace.join(process.cwd(), ".turbo"),
21437
- path54__namespace.join(process.cwd(), ".cache", "maria"),
21438
- path54__namespace.join(process.cwd(), "node_modules", ".cache")
21438
+ path55__namespace.join(os13__namespace.homedir(), ".maria", "cache"),
21439
+ path55__namespace.join(process.cwd(), ".turbo"),
21440
+ path55__namespace.join(process.cwd(), ".cache", "maria"),
21441
+ path55__namespace.join(process.cwd(), "node_modules", ".cache")
21439
21442
  ];
21440
21443
  /**
21441
21444
  * Execute cache action
@@ -21616,10 +21619,10 @@ var init_CacheActionExecutor = __esm({
21616
21619
  * Warmup specific target
21617
21620
  */
21618
21621
  async warmupTarget(target) {
21619
- const cacheDir = path54__namespace.join(os13__namespace.homedir(), ".maria", "cache");
21622
+ const cacheDir = path55__namespace.join(os13__namespace.homedir(), ".maria", "cache");
21620
21623
  switch (target) {
21621
21624
  case "models:list":
21622
- const modelsDir = path54__namespace.join(cacheDir, "models");
21625
+ const modelsDir = path55__namespace.join(cacheDir, "models");
21623
21626
  await fsp__namespace.mkdir(modelsDir, { recursive: true });
21624
21627
  const modelsData = {
21625
21628
  timestamp: Date.now(),
@@ -21630,12 +21633,12 @@ var init_CacheActionExecutor = __esm({
21630
21633
  ]
21631
21634
  };
21632
21635
  await fsp__namespace.writeFile(
21633
- path54__namespace.join(modelsDir, "available.json"),
21636
+ path55__namespace.join(modelsDir, "available.json"),
21634
21637
  JSON.stringify(modelsData, null, 2)
21635
21638
  );
21636
21639
  return { itemsCreated: 1, size: JSON.stringify(modelsData).length };
21637
21640
  case "aliases":
21638
- const aliasesDir = path54__namespace.join(cacheDir, "aliases");
21641
+ const aliasesDir = path55__namespace.join(cacheDir, "aliases");
21639
21642
  await fsp__namespace.mkdir(aliasesDir, { recursive: true });
21640
21643
  const aliasesData = {
21641
21644
  timestamp: Date.now(),
@@ -21646,12 +21649,12 @@ var init_CacheActionExecutor = __esm({
21646
21649
  }
21647
21650
  };
21648
21651
  await fsp__namespace.writeFile(
21649
- path54__namespace.join(aliasesDir, "model-aliases.json"),
21652
+ path55__namespace.join(aliasesDir, "model-aliases.json"),
21650
21653
  JSON.stringify(aliasesData, null, 2)
21651
21654
  );
21652
21655
  return { itemsCreated: 1, size: JSON.stringify(aliasesData).length };
21653
21656
  case "templates":
21654
- const templatesDir = path54__namespace.join(cacheDir, "templates");
21657
+ const templatesDir = path55__namespace.join(cacheDir, "templates");
21655
21658
  await fsp__namespace.mkdir(templatesDir, { recursive: true });
21656
21659
  const templatesData = {
21657
21660
  timestamp: Date.now(),
@@ -21662,7 +21665,7 @@ var init_CacheActionExecutor = __esm({
21662
21665
  }
21663
21666
  };
21664
21667
  await fsp__namespace.writeFile(
21665
- path54__namespace.join(templatesDir, "prompt-templates.json"),
21668
+ path55__namespace.join(templatesDir, "prompt-templates.json"),
21666
21669
  JSON.stringify(templatesData, null, 2)
21667
21670
  );
21668
21671
  return { itemsCreated: 1, size: JSON.stringify(templatesData).length };
@@ -21708,7 +21711,7 @@ var init_CacheActionExecutor = __esm({
21708
21711
  try {
21709
21712
  const entries = await fsp__namespace.readdir(dirPath, { withFileTypes: true });
21710
21713
  for (const entry of entries) {
21711
- const entryPath = path54__namespace.join(dirPath, entry.name);
21714
+ const entryPath = path55__namespace.join(dirPath, entry.name);
21712
21715
  if (entry.isDirectory()) {
21713
21716
  totalSize += await this.getDirectorySize(entryPath);
21714
21717
  } else {
@@ -21729,7 +21732,7 @@ var init_CacheActionExecutor = __esm({
21729
21732
  const entries = await fsp__namespace.readdir(dirPath, { withFileTypes: true });
21730
21733
  for (const entry of entries) {
21731
21734
  if (entry.isDirectory()) {
21732
- const entryPath = path54__namespace.join(dirPath, entry.name);
21735
+ const entryPath = path55__namespace.join(dirPath, entry.name);
21733
21736
  count += await this.countFiles(entryPath);
21734
21737
  } else {
21735
21738
  count++;
@@ -21757,12 +21760,12 @@ var init_CacheActionExecutor = __esm({
21757
21760
  */
21758
21761
  resolvePath(cachePath) {
21759
21762
  if (cachePath.startsWith("~/")) {
21760
- return path54__namespace.join(os13__namespace.homedir(), cachePath.slice(2));
21763
+ return path55__namespace.join(os13__namespace.homedir(), cachePath.slice(2));
21761
21764
  }
21762
- if (path54__namespace.isAbsolute(cachePath)) {
21765
+ if (path55__namespace.isAbsolute(cachePath)) {
21763
21766
  return cachePath;
21764
21767
  }
21765
- return path54__namespace.resolve(process.cwd(), cachePath);
21768
+ return path55__namespace.resolve(process.cwd(), cachePath);
21766
21769
  }
21767
21770
  };
21768
21771
  }
@@ -22035,7 +22038,7 @@ var init_SelfHealingService = __esm({
22035
22038
  const timestamp = /* @__PURE__ */ new Date();
22036
22039
  await this.auditLogger.logDiagnosis("started", { diagnostics: context2 });
22037
22040
  try {
22038
- const envPath = path54__namespace.join(context2.cwd, ".env.local");
22041
+ const envPath = path55__namespace.join(context2.cwd, ".env.local");
22039
22042
  try {
22040
22043
  await fsp__namespace.access(envPath);
22041
22044
  } catch {
@@ -22050,7 +22053,7 @@ var init_SelfHealingService = __esm({
22050
22053
  suggestion: "Create .env.local with API keys template"
22051
22054
  });
22052
22055
  }
22053
- const nodeModulesPath = path54__namespace.join(context2.cwd, "node_modules");
22056
+ const nodeModulesPath = path55__namespace.join(context2.cwd, "node_modules");
22054
22057
  try {
22055
22058
  await fsp__namespace.access(nodeModulesPath);
22056
22059
  } catch {
@@ -22065,7 +22068,7 @@ var init_SelfHealingService = __esm({
22065
22068
  suggestion: "Run package manager install command"
22066
22069
  });
22067
22070
  }
22068
- const cachePath = path54__namespace.join(process.env.HOME || "", ".maria", "cache");
22071
+ const cachePath = path55__namespace.join(process.env.HOME || "", ".maria", "cache");
22069
22072
  try {
22070
22073
  const stats = await fsp__namespace.stat(cachePath);
22071
22074
  if (stats.size > 100 * 1024 * 1024) {
@@ -22647,7 +22650,7 @@ function createConfigCheck() {
22647
22650
  runsIn: "read-only",
22648
22651
  estimateMs: 20,
22649
22652
  async run(ctx2) {
22650
- const pkgPath = path54.resolve(ctx2.cwd, "package.json");
22653
+ const pkgPath = path55.resolve(ctx2.cwd, "package.json");
22651
22654
  try {
22652
22655
  const raw = await fsp.readFile(pkgPath, "utf-8");
22653
22656
  const pkg = JSON.parse(raw);
@@ -22716,7 +22719,7 @@ function createDependenciesCheck() {
22716
22719
  runsIn: "read-only",
22717
22720
  estimateMs: 25,
22718
22721
  async run(ctx2) {
22719
- const nm = path54.resolve(ctx2.cwd, "node_modules");
22722
+ const nm = path55.resolve(ctx2.cwd, "node_modules");
22720
22723
  try {
22721
22724
  const s2 = await fsp.stat(nm);
22722
22725
  if (!s2.isDirectory()) {
@@ -22811,7 +22814,7 @@ function createGitRepoCheck() {
22811
22814
  runsIn: "read-only",
22812
22815
  estimateMs: 10,
22813
22816
  async run(ctx2) {
22814
- const dotgit = path54.resolve(ctx2.cwd, ".git");
22817
+ const dotgit = path55.resolve(ctx2.cwd, ".git");
22815
22818
  try {
22816
22819
  await fsp.access(dotgit);
22817
22820
  return { name: "Git Repository", category: "config", status: "pass", message: "Git repo detected" };
@@ -22897,9 +22900,9 @@ function createProvidersSecretConfigCheck() {
22897
22900
  groq: !!process.env.GROQ_API_KEY
22898
22901
  };
22899
22902
  const candidates = [
22900
- path54.resolve(ctx2.cwd, ".maria/secrets.local.json"),
22901
- path54.resolve(ctx2.cwd, "secrets/local.json"),
22902
- path54.resolve(ctx2.cwd, ".secrets.local.json")
22903
+ path55.resolve(ctx2.cwd, ".maria/secrets.local.json"),
22904
+ path55.resolve(ctx2.cwd, "secrets/local.json"),
22905
+ path55.resolve(ctx2.cwd, ".secrets.local.json")
22903
22906
  ];
22904
22907
  let fileCfg = null;
22905
22908
  for (const p of candidates) {
@@ -22971,8 +22974,8 @@ async function applyPlans(plans, opts) {
22971
22974
  try {
22972
22975
  for (const plan of plans) {
22973
22976
  if (opts.signal?.aborted) throw abortErr();
22974
- const target = path54__namespace.default.join(opts.root, plan.path);
22975
- const dir = path54__namespace.default.dirname(target);
22977
+ const target = path55__namespace.default.join(opts.root, plan.path);
22978
+ const dir = path55__namespace.default.dirname(target);
22976
22979
  await fs21.promises.mkdir(dir, { recursive: true });
22977
22980
  const exists = await fileExists(target);
22978
22981
  const perFileAllowed = plan.overwritePolicy === "allow";
@@ -23001,7 +23004,7 @@ async function applyPlans(plans, opts) {
23001
23004
  if (opts.rollback) {
23002
23005
  for (const rel of created) {
23003
23006
  try {
23004
- await fs21.promises.unlink(path54__namespace.default.join(opts.root, rel));
23007
+ await fs21.promises.unlink(path55__namespace.default.join(opts.root, rel));
23005
23008
  } catch {
23006
23009
  }
23007
23010
  }
@@ -23122,7 +23125,7 @@ async function applyFixes(plans, opts) {
23122
23125
  continue;
23123
23126
  }
23124
23127
  if (plan.action === "file.create") {
23125
- const full = path54.resolve(opts.cwd, plan.path);
23128
+ const full = path55.resolve(opts.cwd, plan.path);
23126
23129
  try {
23127
23130
  await fsp.access(full);
23128
23131
  results.push({ plan, status: "skipped", message: "File exists" });
@@ -23135,7 +23138,7 @@ async function applyFixes(plans, opts) {
23135
23138
  continue;
23136
23139
  }
23137
23140
  if (plan.action === "file.modify") {
23138
- const full = path54.resolve(opts.cwd, plan.path);
23141
+ const full = path55.resolve(opts.cwd, plan.path);
23139
23142
  const st = await fsp.stat(full).catch(() => null);
23140
23143
  if (!st) {
23141
23144
  await ensureDir(full);
@@ -23152,7 +23155,7 @@ ${plan.diff ?? plan.content ?? ""}`;
23152
23155
  continue;
23153
23156
  }
23154
23157
  if (plan.action === "file.json-merge") {
23155
- const full = path54.resolve(opts.cwd, plan.path);
23158
+ const full = path55.resolve(opts.cwd, plan.path);
23156
23159
  const raw = await readFileSafe(full);
23157
23160
  let json = {};
23158
23161
  if (raw) {
@@ -23187,14 +23190,14 @@ function validatePath2(rel, cwd2) {
23187
23190
  if (rel.includes("..")) return { valid: false, reason: "path traversal" };
23188
23191
  if (rel.startsWith("/") || rel.includes("\\")) return { valid: false, reason: "absolute or backslashes not allowed" };
23189
23192
  if (rel.startsWith(".env") || rel.endsWith(".pem") || rel.endsWith("id_rsa")) return { valid: false, reason: "sensitive path" };
23190
- const full = path54.resolve(cwd2, rel);
23191
- const normCwd = path54.normalize(cwd2) + path54.sep;
23192
- const normFull = path54.normalize(full);
23193
+ const full = path55.resolve(cwd2, rel);
23194
+ const normCwd = path55.normalize(cwd2) + path55.sep;
23195
+ const normFull = path55.normalize(full);
23193
23196
  if (!normFull.startsWith(normCwd)) return { valid: false, reason: "outside cwd" };
23194
23197
  return { valid: true };
23195
23198
  }
23196
23199
  async function ensureDir(fullPath) {
23197
- const i2 = fullPath.lastIndexOf(path54.sep);
23200
+ const i2 = fullPath.lastIndexOf(path55.sep);
23198
23201
  if (i2 <= 0) return;
23199
23202
  const dir = fullPath.slice(0, i2);
23200
23203
  try {
@@ -27316,12 +27319,12 @@ var init_esm4 = __esm({
27316
27319
  /**
27317
27320
  * Get the Path object referenced by the string path, resolved from this Path
27318
27321
  */
27319
- resolve(path55) {
27320
- if (!path55) {
27322
+ resolve(path56) {
27323
+ if (!path56) {
27321
27324
  return this;
27322
27325
  }
27323
- const rootPath = this.getRootString(path55);
27324
- const dir = path55.substring(rootPath.length);
27326
+ const rootPath = this.getRootString(path56);
27327
+ const dir = path56.substring(rootPath.length);
27325
27328
  const dirParts = dir.split(this.splitSep);
27326
27329
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
27327
27330
  return result;
@@ -28073,8 +28076,8 @@ var init_esm4 = __esm({
28073
28076
  /**
28074
28077
  * @internal
28075
28078
  */
28076
- getRootString(path55) {
28077
- return path54.win32.parse(path55).root;
28079
+ getRootString(path56) {
28080
+ return path55.win32.parse(path56).root;
28078
28081
  }
28079
28082
  /**
28080
28083
  * @internal
@@ -28120,8 +28123,8 @@ var init_esm4 = __esm({
28120
28123
  /**
28121
28124
  * @internal
28122
28125
  */
28123
- getRootString(path55) {
28124
- return path55.startsWith("/") ? "/" : "";
28126
+ getRootString(path56) {
28127
+ return path56.startsWith("/") ? "/" : "";
28125
28128
  }
28126
28129
  /**
28127
28130
  * @internal
@@ -28170,8 +28173,8 @@ var init_esm4 = __esm({
28170
28173
  *
28171
28174
  * @internal
28172
28175
  */
28173
- constructor(cwd2 = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs45 = defaultFS } = {}) {
28174
- this.#fs = fsFromOption(fs45);
28176
+ constructor(cwd2 = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs46 = defaultFS } = {}) {
28177
+ this.#fs = fsFromOption(fs46);
28175
28178
  if (cwd2 instanceof URL || cwd2.startsWith("file://")) {
28176
28179
  cwd2 = url.fileURLToPath(cwd2);
28177
28180
  }
@@ -28210,11 +28213,11 @@ var init_esm4 = __esm({
28210
28213
  /**
28211
28214
  * Get the depth of a provided path, string, or the cwd
28212
28215
  */
28213
- depth(path55 = this.cwd) {
28214
- if (typeof path55 === "string") {
28215
- path55 = this.cwd.resolve(path55);
28216
+ depth(path56 = this.cwd) {
28217
+ if (typeof path56 === "string") {
28218
+ path56 = this.cwd.resolve(path56);
28216
28219
  }
28217
- return path55.depth();
28220
+ return path56.depth();
28218
28221
  }
28219
28222
  /**
28220
28223
  * Return the cache of child entries. Exposed so subclasses can create
@@ -28701,9 +28704,9 @@ var init_esm4 = __esm({
28701
28704
  process11();
28702
28705
  return results;
28703
28706
  }
28704
- chdir(path55 = this.cwd) {
28707
+ chdir(path56 = this.cwd) {
28705
28708
  const oldCwd = this.cwd;
28706
- this.cwd = typeof path55 === "string" ? this.cwd.resolve(path55) : path55;
28709
+ this.cwd = typeof path56 === "string" ? this.cwd.resolve(path56) : path56;
28707
28710
  this.cwd[setAsCwd](oldCwd);
28708
28711
  }
28709
28712
  };
@@ -28714,7 +28717,7 @@ var init_esm4 = __esm({
28714
28717
  sep = "\\";
28715
28718
  constructor(cwd2 = process.cwd(), opts = {}) {
28716
28719
  const { nocase = true } = opts;
28717
- super(cwd2, path54.win32, "\\", { ...opts, nocase });
28720
+ super(cwd2, path55.win32, "\\", { ...opts, nocase });
28718
28721
  this.nocase = nocase;
28719
28722
  for (let p = this.cwd; p; p = p.parent) {
28720
28723
  p.nocase = this.nocase;
@@ -28724,13 +28727,13 @@ var init_esm4 = __esm({
28724
28727
  * @internal
28725
28728
  */
28726
28729
  parseRootPath(dir) {
28727
- return path54.win32.parse(dir).root.toUpperCase();
28730
+ return path55.win32.parse(dir).root.toUpperCase();
28728
28731
  }
28729
28732
  /**
28730
28733
  * @internal
28731
28734
  */
28732
- newRoot(fs45) {
28733
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs45 });
28735
+ newRoot(fs46) {
28736
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs46 });
28734
28737
  }
28735
28738
  /**
28736
28739
  * Return true if the provided path string is an absolute path
@@ -28746,7 +28749,7 @@ var init_esm4 = __esm({
28746
28749
  sep = "/";
28747
28750
  constructor(cwd2 = process.cwd(), opts = {}) {
28748
28751
  const { nocase = false } = opts;
28749
- super(cwd2, path54.posix, "/", { ...opts, nocase });
28752
+ super(cwd2, path55.posix, "/", { ...opts, nocase });
28750
28753
  this.nocase = nocase;
28751
28754
  }
28752
28755
  /**
@@ -28758,8 +28761,8 @@ var init_esm4 = __esm({
28758
28761
  /**
28759
28762
  * @internal
28760
28763
  */
28761
- newRoot(fs45) {
28762
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs45 });
28764
+ newRoot(fs46) {
28765
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs46 });
28763
28766
  }
28764
28767
  /**
28765
28768
  * Return true if the provided path string is an absolute path
@@ -29078,8 +29081,8 @@ var init_processor = __esm({
29078
29081
  }
29079
29082
  // match, absolute, ifdir
29080
29083
  entries() {
29081
- return [...this.store.entries()].map(([path55, n]) => [
29082
- path55,
29084
+ return [...this.store.entries()].map(([path56, n]) => [
29085
+ path56,
29083
29086
  !!(n & 2),
29084
29087
  !!(n & 1)
29085
29088
  ]);
@@ -29292,9 +29295,9 @@ var init_walker = __esm({
29292
29295
  signal;
29293
29296
  maxDepth;
29294
29297
  includeChildMatches;
29295
- constructor(patterns, path55, opts) {
29298
+ constructor(patterns, path56, opts) {
29296
29299
  this.patterns = patterns;
29297
- this.path = path55;
29300
+ this.path = path56;
29298
29301
  this.opts = opts;
29299
29302
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
29300
29303
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -29313,11 +29316,11 @@ var init_walker = __esm({
29313
29316
  });
29314
29317
  }
29315
29318
  }
29316
- #ignored(path55) {
29317
- return this.seen.has(path55) || !!this.#ignore?.ignored?.(path55);
29319
+ #ignored(path56) {
29320
+ return this.seen.has(path56) || !!this.#ignore?.ignored?.(path56);
29318
29321
  }
29319
- #childrenIgnored(path55) {
29320
- return !!this.#ignore?.childrenIgnored?.(path55);
29322
+ #childrenIgnored(path56) {
29323
+ return !!this.#ignore?.childrenIgnored?.(path56);
29321
29324
  }
29322
29325
  // backpressure mechanism
29323
29326
  pause() {
@@ -29532,8 +29535,8 @@ var init_walker = __esm({
29532
29535
  };
29533
29536
  GlobWalker = class extends GlobUtil {
29534
29537
  matches = /* @__PURE__ */ new Set();
29535
- constructor(patterns, path55, opts) {
29536
- super(patterns, path55, opts);
29538
+ constructor(patterns, path56, opts) {
29539
+ super(patterns, path56, opts);
29537
29540
  }
29538
29541
  matchEmit(e2) {
29539
29542
  this.matches.add(e2);
@@ -29570,8 +29573,8 @@ var init_walker = __esm({
29570
29573
  };
29571
29574
  GlobStream = class extends GlobUtil {
29572
29575
  results;
29573
- constructor(patterns, path55, opts) {
29574
- super(patterns, path55, opts);
29576
+ constructor(patterns, path56, opts) {
29577
+ super(patterns, path56, opts);
29575
29578
  this.results = new Minipass({
29576
29579
  signal: this.signal,
29577
29580
  objectMode: true
@@ -30120,7 +30123,7 @@ ${usageLine}`;
30120
30123
  async autoRegister(directory) {
30121
30124
  logger.info(`Auto-registering commands from ${directory}`);
30122
30125
  try {
30123
- const pattern = path54__namespace.join(directory, "**/*.command.{ts,js}");
30126
+ const pattern = path55__namespace.join(directory, "**/*.command.{ts,js}");
30124
30127
  const files = await glob(pattern);
30125
30128
  logger.info(`Found ${files.length} command files`);
30126
30129
  for (const file of files) {
@@ -30824,7 +30827,7 @@ ${fixPlan.note}` : ""));
30824
30827
  async runConfigurationChecks(context2) {
30825
30828
  const checks = [];
30826
30829
  const cwd2 = context2.environment?.cwd || process.cwd();
30827
- const packageJsonPath = path54__namespace.join(cwd2, "package.json");
30830
+ const packageJsonPath = path55__namespace.join(cwd2, "package.json");
30828
30831
  try {
30829
30832
  await fsp__namespace.access(packageJsonPath);
30830
30833
  const content = await fsp__namespace.readFile(packageJsonPath, "utf-8");
@@ -30850,7 +30853,7 @@ ${fixPlan.note}` : ""));
30850
30853
  fixable: true
30851
30854
  });
30852
30855
  }
30853
- const envPath = path54__namespace.join(cwd2, ".env.local");
30856
+ const envPath = path55__namespace.join(cwd2, ".env.local");
30854
30857
  try {
30855
30858
  await fsp__namespace.access(envPath);
30856
30859
  checks.push({
@@ -30868,7 +30871,7 @@ ${fixPlan.note}` : ""));
30868
30871
  fixable: true
30869
30872
  });
30870
30873
  }
30871
- const gitPath = path54__namespace.join(cwd2, ".git");
30874
+ const gitPath = path55__namespace.join(cwd2, ".git");
30872
30875
  try {
30873
30876
  await fsp__namespace.access(gitPath);
30874
30877
  checks.push({
@@ -30892,7 +30895,7 @@ ${fixPlan.note}` : ""));
30892
30895
  async runDependencyChecks(context2) {
30893
30896
  const checks = [];
30894
30897
  const cwd2 = context2.environment?.cwd || process.cwd();
30895
- const nodeModulesPath = path54__namespace.join(cwd2, "node_modules");
30898
+ const nodeModulesPath = path55__namespace.join(cwd2, "node_modules");
30896
30899
  try {
30897
30900
  await fsp__namespace.access(nodeModulesPath);
30898
30901
  const stats = await fsp__namespace.stat(nodeModulesPath);
@@ -31124,7 +31127,7 @@ ${fixPlan.note}` : ""));
31124
31127
  }
31125
31128
  break;
31126
31129
  case "CACHE_CORRUPT":
31127
- const cacheDir = path54__namespace.join(
31130
+ const cacheDir = path55__namespace.join(
31128
31131
  context2.environment?.cwd || process.cwd(),
31129
31132
  ".maria",
31130
31133
  "cache"
@@ -31143,7 +31146,7 @@ ${fixPlan.note}` : ""));
31143
31146
  * Create environment template
31144
31147
  */
31145
31148
  async createEnvTemplate(context2) {
31146
- const envPath = path54__namespace.join(
31149
+ const envPath = path55__namespace.join(
31147
31150
  context2.environment?.cwd || process.cwd(),
31148
31151
  ".env.local"
31149
31152
  );
@@ -31199,7 +31202,7 @@ LOG_LEVEL=info
31199
31202
  async getSystemInfo(context2) {
31200
31203
  let mariaVersion = "Unknown";
31201
31204
  try {
31202
- const packagePath = path54__namespace.join(
31205
+ const packagePath = path55__namespace.join(
31203
31206
  context2.environment?.cwd || process.cwd(),
31204
31207
  "package.json"
31205
31208
  );
@@ -32870,7 +32873,7 @@ var init_TerminalSetupCommand = __esm({
32870
32873
  if (_shell.includes("fish")) return "fish";
32871
32874
  if (_shell.includes("powershell")) return "powershell";
32872
32875
  if (_shell.includes("cmd")) return "cmd";
32873
- return path54__namespace.basename(_shell) || "unknown";
32876
+ return path55__namespace.basename(_shell) || "unknown";
32874
32877
  }
32875
32878
  generateTerminalRecommendations(type, _features, _shell) {
32876
32879
  const _recommendations = [];
@@ -33187,9 +33190,9 @@ function clampInt(v, min, max, name2) {
33187
33190
  return Math.min(max, Math.max(min, Math.floor(n)));
33188
33191
  }
33189
33192
  function sanitizeOut(outDir, root) {
33190
- const full = path54__namespace.default.resolve(root, outDir);
33191
- const rel = path54__namespace.default.relative(root, full);
33192
- if (rel.startsWith("..") || path54__namespace.default.isAbsolute(rel)) throw new Error("out path escapes root");
33193
+ const full = path55__namespace.default.resolve(root, outDir);
33194
+ const rel = path55__namespace.default.relative(root, full);
33195
+ if (rel.startsWith("..") || path55__namespace.default.isAbsolute(rel)) throw new Error("out path escapes root");
33193
33196
  return rel.replace(/\\/g, "/");
33194
33197
  }
33195
33198
  var init_Normalizer = __esm({
@@ -33201,15 +33204,15 @@ function ensureDirSync(p) {
33201
33204
  fs21__namespace.mkdirSync(p, { recursive: true });
33202
33205
  }
33203
33206
  function safeJoin(root, ...segs) {
33204
- const full = path54__namespace.resolve(root, ...segs);
33205
- const rel = path54__namespace.relative(root, full);
33206
- if (rel.startsWith("..") || path54__namespace.isAbsolute(rel)) {
33207
+ const full = path55__namespace.resolve(root, ...segs);
33208
+ const rel = path55__namespace.relative(root, full);
33209
+ if (rel.startsWith("..") || path55__namespace.isAbsolute(rel)) {
33207
33210
  throw new Error(`path escapes root: ${segs.join("/")}`);
33208
33211
  }
33209
33212
  return { full, rel };
33210
33213
  }
33211
33214
  function stageDir(root, trace) {
33212
- return path54__namespace.join(root, `.stage/${trace}`);
33215
+ return path55__namespace.join(root, `.stage/${trace}`);
33213
33216
  }
33214
33217
  async function existsSameHash(destFull) {
33215
33218
  try {
@@ -33274,10 +33277,10 @@ async function saveArtifacts(ctx2, items, manifest) {
33274
33277
  const fname = `${contentHash}${ext2}`;
33275
33278
  const dest = safeJoin(root, `${outDirSeg}/${fname}`);
33276
33279
  validateWinPathEdge(dest.full);
33277
- if (await hasCaseInsensitiveCollision(path54__namespace.dirname(dest.full), path54__namespace.basename(dest.full))) {
33280
+ if (await hasCaseInsensitiveCollision(path55__namespace.dirname(dest.full), path55__namespace.basename(dest.full))) {
33278
33281
  throw new Error("case-insensitive filename collision");
33279
33282
  }
33280
- const stg = path54__namespace.join(stage, `${fname}.part`);
33283
+ const stg = path55__namespace.join(stage, `${fname}.part`);
33281
33284
  if (await existsSameHash(dest.full)) {
33282
33285
  saved.push(dest.rel);
33283
33286
  continue;
@@ -33290,10 +33293,10 @@ async function saveArtifacts(ctx2, items, manifest) {
33290
33293
  manifestVersion: 1,
33291
33294
  ...manifest,
33292
33295
  createdAt: manifest.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
33293
- artifacts: manifest.artifacts && manifest.artifacts.length > 0 ? manifest.artifacts : saved.map((file) => ({ file, hash: `sha256:${path54__namespace.basename(file).split(".")[0]}` }))
33296
+ artifacts: manifest.artifacts && manifest.artifacts.length > 0 ? manifest.artifacts : saved.map((file) => ({ file, hash: `sha256:${path55__namespace.basename(file).split(".")[0]}` }))
33294
33297
  };
33295
33298
  const manifestPathRel = `${outDirSeg}/manifest.json`;
33296
- const manifestStage = path54__namespace.join(stage, "manifest.json.part");
33299
+ const manifestStage = path55__namespace.join(stage, "manifest.json.part");
33297
33300
  const manifestFull = safeJoin(root, manifestPathRel).full;
33298
33301
  await fsp__namespace.writeFile(manifestStage, JSON.stringify(manifestObj, null, 2), "utf8");
33299
33302
  await atomicRename(manifestStage, manifestFull);
@@ -33650,10 +33653,10 @@ var init_session = __esm({
33650
33653
  this.root = root;
33651
33654
  }
33652
33655
  file() {
33653
- return path54__namespace.default.join(this.root, ".maria", "memory", "session.json");
33656
+ return path55__namespace.default.join(this.root, ".maria", "memory", "session.json");
33654
33657
  }
33655
33658
  lockFile() {
33656
- return path54__namespace.default.join(this.root, ".maria", "memory", ".session.lock");
33659
+ return path55__namespace.default.join(this.root, ".maria", "memory", ".session.lock");
33657
33660
  }
33658
33661
  load() {
33659
33662
  try {
@@ -33668,7 +33671,7 @@ var init_session = __esm({
33668
33671
  */
33669
33672
  save(data) {
33670
33673
  const target = this.file();
33671
- const dir = path54__namespace.default.dirname(target);
33674
+ const dir = path55__namespace.default.dirname(target);
33672
33675
  fs21__namespace.default.mkdirSync(dir, { recursive: true });
33673
33676
  try {
33674
33677
  this.rotateIfStale(target, 7 * 24 * 60 * 60 * 1e3);
@@ -33701,7 +33704,7 @@ var init_session = __esm({
33701
33704
  const body = `${pid}
33702
33705
  ${(/* @__PURE__ */ new Date()).toISOString()}`;
33703
33706
  const start = Date.now();
33704
- fs21__namespace.default.mkdirSync(path54__namespace.default.dirname(lockPath), { recursive: true });
33707
+ fs21__namespace.default.mkdirSync(path55__namespace.default.dirname(lockPath), { recursive: true });
33705
33708
  const maxWaitTime = Date.now() + waitMs;
33706
33709
  while (Date.now() < maxWaitTime) {
33707
33710
  try {
@@ -33740,10 +33743,10 @@ ${(/* @__PURE__ */ new Date()).toISOString()}`;
33740
33743
  if (age > ttlMs) {
33741
33744
  const d = new Date(st.mtimeMs);
33742
33745
  const yyyymmdd = `${d.getUTCFullYear()}${String(d.getUTCMonth() + 1).padStart(2, "0")}${String(d.getUTCDate()).padStart(2, "0")}`;
33743
- const archiveDir = path54__namespace.default.join(path54__namespace.default.dirname(filePath), "archive", yyyymmdd);
33746
+ const archiveDir = path55__namespace.default.join(path55__namespace.default.dirname(filePath), "archive", yyyymmdd);
33744
33747
  fs21__namespace.default.mkdirSync(archiveDir, { recursive: true });
33745
33748
  const ts = d.toISOString().replace(/[:]/g, "-");
33746
- const dest = path54__namespace.default.join(archiveDir, `session-${ts}.json`);
33749
+ const dest = path55__namespace.default.join(archiveDir, `session-${ts}.json`);
33747
33750
  fs21__namespace.default.renameSync(filePath, dest);
33748
33751
  }
33749
33752
  } catch {
@@ -33865,7 +33868,7 @@ var init_firestore = __esm({
33865
33868
  return s2.slice(0, limit);
33866
33869
  }
33867
33870
  readLocal() {
33868
- const sessionPath = path54__namespace.default.join(this.cwd, ".maria", "memory", "session.json");
33871
+ const sessionPath = path55__namespace.default.join(this.cwd, ".maria", "memory", "session.json");
33869
33872
  const candidates = [];
33870
33873
  try {
33871
33874
  const raw = JSON.parse(fs21__namespace.default.readFileSync(sessionPath, "utf8"));
@@ -34114,13 +34117,13 @@ async function hasFfmpeg() {
34114
34117
  });
34115
34118
  }
34116
34119
  async function muxFramesToMp4(framesDir, fps) {
34117
- const outFile = path54__namespace.join(framesDir, `out-${Date.now()}.mp4`);
34120
+ const outFile = path55__namespace.join(framesDir, `out-${Date.now()}.mp4`);
34118
34121
  await execFfmpeg([
34119
34122
  "-y",
34120
34123
  "-framerate",
34121
34124
  String(fps),
34122
34125
  "-i",
34123
- path54__namespace.join(framesDir, "%06d.png"),
34126
+ path55__namespace.join(framesDir, "%06d.png"),
34124
34127
  "-pix_fmt",
34125
34128
  "yuv420p",
34126
34129
  "-c:v",
@@ -34186,11 +34189,11 @@ async function runVideoPipeline(params2, opts) {
34186
34189
  let saved;
34187
34190
  let warnFallback = false;
34188
34191
  if (frames.length > 0 && await hasFfmpeg()) {
34189
- const tmpDir = path54__namespace.join(opts.root, ".stage", manifest.trace || "FFMPEG");
34192
+ const tmpDir = path55__namespace.join(opts.root, ".stage", manifest.trace || "FFMPEG");
34190
34193
  await fsp__namespace.mkdir(tmpDir, { recursive: true });
34191
34194
  for (let i2 = 0; i2 < frames.length; i2++) {
34192
34195
  const fname = String(i2 + 1).padStart(6, "0") + ".png";
34193
- await fsp__namespace.writeFile(path54__namespace.join(tmpDir, fname), frames[i2]);
34196
+ await fsp__namespace.writeFile(path55__namespace.join(tmpDir, fname), frames[i2]);
34194
34197
  }
34195
34198
  const outBuf = await muxFramesToMp4(tmpDir, params2.fps);
34196
34199
  saved = await saveArtifacts({ root: opts.root, kind: "video", baseDir: opts.outDir }, [{ bytes: outBuf, ext: ".mp4" }], manifest);
@@ -34878,7 +34881,7 @@ var init_about_command = __esm({
34878
34881
  async execute(args2, context2) {
34879
34882
  const output3 = [];
34880
34883
  output3.push("");
34881
- output3.push(chalk37__default.default.cyan.bold("\u{1F916} About MARIA v4.3.9"));
34884
+ output3.push(chalk37__default.default.cyan.bold("\u{1F916} About MARIA v4.3.10"));
34882
34885
  output3.push(chalk37__default.default.gray("\u2550".repeat(40)));
34883
34886
  output3.push("");
34884
34887
  output3.push(chalk37__default.default.white.bold("MARIA - Minimal API, Maximum Power"));
@@ -36427,11 +36430,11 @@ var init_ConfigPortAdapter = __esm({
36427
36430
  backupCount: 5
36428
36431
  };
36429
36432
  constructor() {
36430
- this.globalConfigPath = path54__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config.json");
36431
- this.userConfigPath = path54__namespace.default.join(os13__namespace.default.homedir(), ".maria", "user-config.json");
36432
- this.projectConfigPath = path54__namespace.default.join(process.cwd(), ".maria-config.json");
36433
- this.historyPath = path54__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config-history.json");
36434
- this.templatesPath = path54__namespace.default.join(os13__namespace.default.homedir(), ".maria", "templates");
36433
+ this.globalConfigPath = path55__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config.json");
36434
+ this.userConfigPath = path55__namespace.default.join(os13__namespace.default.homedir(), ".maria", "user-config.json");
36435
+ this.projectConfigPath = path55__namespace.default.join(process.cwd(), ".maria-config.json");
36436
+ this.historyPath = path55__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config-history.json");
36437
+ this.templatesPath = path55__namespace.default.join(os13__namespace.default.homedir(), ".maria", "templates");
36435
36438
  }
36436
36439
  async get(key) {
36437
36440
  const layered = await this.getLayered(key);
@@ -36688,7 +36691,7 @@ var init_ConfigPortAdapter = __esm({
36688
36691
  for (const file of files) {
36689
36692
  if (file.endsWith(".json")) {
36690
36693
  try {
36691
- const templatePath = path54__namespace.default.join(this.templatesPath, file);
36694
+ const templatePath = path55__namespace.default.join(this.templatesPath, file);
36692
36695
  const content = await fsp__namespace.default.readFile(templatePath, "utf-8");
36693
36696
  const template = JSON.parse(content);
36694
36697
  templates.push(template);
@@ -36770,7 +36773,7 @@ var init_ConfigPortAdapter = __esm({
36770
36773
  }
36771
36774
  async saveLayerConfig(layer, config2) {
36772
36775
  const configPath = this.getLayerConfigPath(layer);
36773
- await fsp__namespace.default.mkdir(path54__namespace.default.dirname(configPath), { recursive: true });
36776
+ await fsp__namespace.default.mkdir(path55__namespace.default.dirname(configPath), { recursive: true });
36774
36777
  await fsp__namespace.default.writeFile(configPath, JSON.stringify(config2, null, 2), "utf-8");
36775
36778
  }
36776
36779
  getLayerConfigPath(layer) {
@@ -36782,7 +36785,7 @@ var init_ConfigPortAdapter = __esm({
36782
36785
  case "project":
36783
36786
  return this.projectConfigPath;
36784
36787
  case "runtime":
36785
- return path54__namespace.default.join(os13__namespace.default.tmpdir(), "maria-runtime-config.json");
36788
+ return path55__namespace.default.join(os13__namespace.default.tmpdir(), "maria-runtime-config.json");
36786
36789
  default:
36787
36790
  return this.userConfigPath;
36788
36791
  }
@@ -36836,7 +36839,7 @@ var init_ConfigPortAdapter = __esm({
36836
36839
  const history = JSON.parse(historyContent);
36837
36840
  history.push(entry);
36838
36841
  const trimmedHistory = history.slice(-1e3);
36839
- await fsp__namespace.default.mkdir(path54__namespace.default.dirname(this.historyPath), { recursive: true });
36842
+ await fsp__namespace.default.mkdir(path55__namespace.default.dirname(this.historyPath), { recursive: true });
36840
36843
  await fsp__namespace.default.writeFile(
36841
36844
  this.historyPath,
36842
36845
  JSON.stringify(trimmedHistory, null, 2),
@@ -36848,7 +36851,7 @@ var init_ConfigPortAdapter = __esm({
36848
36851
  }
36849
36852
  async loadTemplate(templateId) {
36850
36853
  try {
36851
- const templatePath = path54__namespace.default.join(this.templatesPath, `${templateId}.json`);
36854
+ const templatePath = path55__namespace.default.join(this.templatesPath, `${templateId}.json`);
36852
36855
  const content = await fsp__namespace.default.readFile(templatePath, "utf-8");
36853
36856
  return JSON.parse(content);
36854
36857
  } catch (error2) {
@@ -38115,12 +38118,12 @@ ${this.toYamlLike(value, indent + 1)}`;
38115
38118
  }
38116
38119
  static async loadFromFile(configPath) {
38117
38120
  const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
38118
- const fs45 = await importNodeBuiltin2("fs");
38121
+ const fs46 = await importNodeBuiltin2("fs");
38119
38122
  const _path = await importNodeBuiltin2("_path");
38120
38123
  const os24 = await importNodeBuiltin2("os");
38121
38124
  const targetPath = configPath || _path.join(os24.homedir(), ".maria", "config.json");
38122
38125
  try {
38123
- const data = await fs45.promises.readFile(targetPath, "utf-8");
38126
+ const data = await fs46.promises.readFile(targetPath, "utf-8");
38124
38127
  return JSON.parse(data);
38125
38128
  } catch (innerError) {
38126
38129
  if (innerError?.code === "ENOENT") {
@@ -38134,25 +38137,25 @@ ${this.toYamlLike(value, indent + 1)}`;
38134
38137
  }
38135
38138
  async save(configPath, options) {
38136
38139
  const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
38137
- const fs45 = await importNodeBuiltin2("fs");
38140
+ const fs46 = await importNodeBuiltin2("fs");
38138
38141
  const _path = await importNodeBuiltin2("_path");
38139
38142
  const os24 = await importNodeBuiltin2("os");
38140
38143
  const targetPath = configPath || _path.join(os24.homedir(), ".maria", "config.json");
38141
38144
  try {
38142
38145
  if (options?.backup) {
38143
38146
  try {
38144
- await fs45.promises.access(targetPath);
38147
+ await fs46.promises.access(targetPath);
38145
38148
  const backupPath = `${targetPath}.backup.${Date.now()}`;
38146
- await fs45.promises.copyFile(targetPath, backupPath);
38149
+ await fs46.promises.copyFile(targetPath, backupPath);
38147
38150
  } catch {
38148
38151
  }
38149
38152
  }
38150
- await fs45.promises.mkdir(_path.dirname(targetPath), { recursive: true });
38153
+ await fs46.promises.mkdir(_path.dirname(targetPath), { recursive: true });
38151
38154
  const dataToSave = this.getAll({
38152
38155
  maskSensitive: options?.maskSensitive ?? true,
38153
38156
  includeSourceMap: options?.includeSourceMap ?? false
38154
38157
  });
38155
- await fs45.promises.writeFile(
38158
+ await fs46.promises.writeFile(
38156
38159
  targetPath,
38157
38160
  JSON.stringify(dataToSave, null, 2),
38158
38161
  { mode: 384 }
@@ -38196,12 +38199,12 @@ ${this.toYamlLike(value, indent + 1)}`;
38196
38199
  }
38197
38200
  if (outputPath) {
38198
38201
  const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
38199
- const fs45 = await importNodeBuiltin2("fs");
38202
+ const fs46 = await importNodeBuiltin2("fs");
38200
38203
  const _path = await importNodeBuiltin2(
38201
38204
  "_path"
38202
38205
  );
38203
- await fs45.promises.mkdir(_path.dirname(outputPath), { recursive: true });
38204
- await fs45.promises.writeFile(outputPath, content, "utf-8");
38206
+ await fs46.promises.mkdir(_path.dirname(outputPath), { recursive: true });
38207
+ await fs46.promises.writeFile(outputPath, content, "utf-8");
38205
38208
  console.log(`\u2705 Configuration exported to ${outputPath}`);
38206
38209
  }
38207
38210
  return content;
@@ -38673,7 +38676,7 @@ var init_rate_limit_handler = __esm({
38673
38676
  async function scanRepo(cwd2) {
38674
38677
  if (_cache && _cache.root === cwd2) return _cache;
38675
38678
  const root = cwd2;
38676
- const pkgPath = path54.join(root, "package.json");
38679
+ const pkgPath = path55.join(root, "package.json");
38677
38680
  let pkg = {};
38678
38681
  try {
38679
38682
  pkg = JSON.parse(await fsp.readFile(pkgPath, "utf8"));
@@ -38683,17 +38686,17 @@ async function scanRepo(cwd2) {
38683
38686
  const usesReact = !!deps["react"];
38684
38687
  const usesNext = !!deps["next"];
38685
38688
  const jsModuleType = pkg.type === "module" ? "esm" : "cjs";
38686
- const hasSrc = fs21.existsSync(path54.join(root, "src"));
38689
+ const hasSrc = fs21.existsSync(path55.join(root, "src"));
38687
38690
  const srcRoot = hasSrc ? "src" : "";
38688
- const tsconfigPath = path54.join(root, "tsconfig.json");
38691
+ const tsconfigPath = path55.join(root, "tsconfig.json");
38689
38692
  let usesTS = fs21.existsSync(tsconfigPath) || !!deps["typescript"];
38690
38693
  if (!usesTS && hasSrc) {
38691
38694
  const candidates = ["index.ts", "main.ts", "App.tsx"];
38692
- usesTS = candidates.some((f3) => fs21.existsSync(path54.join(root, "src", f3)));
38695
+ usesTS = candidates.some((f3) => fs21.existsSync(path55.join(root, "src", f3)));
38693
38696
  }
38694
- const nextAppDir = usesNext && fs21.existsSync(path54.join(root, "app"));
38697
+ const nextAppDir = usesNext && fs21.existsSync(path55.join(root, "app"));
38695
38698
  const testRunner = deps["vitest"] ? "vitest" : deps["jest"] ? "jest" : null;
38696
- const isMonorepo2 = fs21.existsSync(path54.join(root, "pnpm-workspace.yaml")) || fs21.existsSync(path54.join(root, "packages")) || fs21.existsSync(path54.join(root, "apps"));
38699
+ const isMonorepo2 = fs21.existsSync(path55.join(root, "pnpm-workspace.yaml")) || fs21.existsSync(path55.join(root, "packages")) || fs21.existsSync(path55.join(root, "apps"));
38697
38700
  const packages = [];
38698
38701
  let aliasPaths = {};
38699
38702
  try {
@@ -38703,7 +38706,7 @@ async function scanRepo(cwd2) {
38703
38706
  }
38704
38707
  let eol = "lf";
38705
38708
  try {
38706
- const ec = await fsp.readFile(path54.join(root, ".editorconfig"), "utf8");
38709
+ const ec = await fsp.readFile(path55.join(root, ".editorconfig"), "utf8");
38707
38710
  if (/end_of_line\s*=\s*crlf/i.test(ec)) eol = "crlf";
38708
38711
  if (/end_of_line\s*=\s*lf/i.test(ec)) eol = "lf";
38709
38712
  } catch {
@@ -38722,7 +38725,7 @@ function normalizePlanItem(fp, p) {
38722
38725
  const base = decideBaseDir(fp, p);
38723
38726
  const desired = sanitize(fp.path || suggestName(fp));
38724
38727
  const withExt = ensureExt(desired, ext2, fp.kind);
38725
- const rel = base ? path54.join(base, withExt) : withExt;
38728
+ const rel = base ? path55.join(base, withExt) : withExt;
38726
38729
  return { ...fp, path: rel.replace(/\\/g, "/") };
38727
38730
  }
38728
38731
  function decideExt(fp, p) {
@@ -38762,10 +38765,10 @@ function suggestName(fp, p) {
38762
38765
  const base = (fp.description || "file").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
38763
38766
  return base || "file";
38764
38767
  }
38765
- function guessKindByPath(path55) {
38766
- if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(path55)) return "test";
38767
- if (/^docs\//.test(path55) || /\.md$/.test(path55)) return "doc";
38768
- if (/\.(json|cjs|js|ts)$/.test(path55) && !/src\//.test(path55)) return "config";
38768
+ function guessKindByPath(path56) {
38769
+ if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(path56)) return "test";
38770
+ if (/^docs\//.test(path56) || /\.md$/.test(path56)) return "doc";
38771
+ if (/\.(json|cjs|js|ts)$/.test(path56) && !/src\//.test(path56)) return "config";
38769
38772
  return "source";
38770
38773
  }
38771
38774
  var init_PathInferencer = __esm({
@@ -38827,15 +38830,15 @@ async function validatePlan(plans, opts) {
38827
38830
  skipped.push(fp.path);
38828
38831
  continue;
38829
38832
  }
38830
- const full = path54__namespace.default.join(opts.root, rel);
38831
- if (!full.startsWith(path54__namespace.default.resolve(opts.root))) {
38833
+ const full = path55__namespace.default.join(opts.root, rel);
38834
+ if (!full.startsWith(path55__namespace.default.resolve(opts.root))) {
38832
38835
  warnings.push(`Outside root denied: ${fp.path}`);
38833
38836
  skipped.push(fp.path);
38834
38837
  continue;
38835
38838
  }
38836
38839
  if (process.platform === "win32" || process.env.MOCK_WIN32 === "1") {
38837
38840
  const invalidChars = /[<>:"/\\|?*]/;
38838
- const name2 = path54__namespace.default.basename(rel);
38841
+ const name2 = path55__namespace.default.basename(rel);
38839
38842
  if (invalidChars.test(rel)) {
38840
38843
  warnings.push(`Invalid characters in path (Windows): ${fp.path}`);
38841
38844
  skipped.push(fp.path);
@@ -38874,7 +38877,7 @@ async function validatePlan(plans, opts) {
38874
38877
  }
38875
38878
  }
38876
38879
  for (const fp of clamped) {
38877
- const full = path54__namespace.default.join(opts.root, fp.path);
38880
+ const full = path55__namespace.default.join(opts.root, fp.path);
38878
38881
  const exists = await exists(full);
38879
38882
  const willModify = exists;
38880
38883
  if (willModify) {
@@ -38925,6 +38928,9 @@ function formatPlan(summary, opts) {
38925
38928
  const sep4 = " ".repeat(leftPad);
38926
38929
  const lines = [];
38927
38930
  lines.push(`Plan: ${summary.planned} files`);
38931
+ if (opts.mode === "diff") {
38932
+ return formatPlanAsDiff(summary.files, opts);
38933
+ }
38928
38934
  for (const f3 of summary.files) {
38929
38935
  const kind = f3.action.padEnd(kindCol);
38930
38936
  const p = truncate(f3.path, pathCol);
@@ -38939,7 +38945,7 @@ function formatPlan(summary, opts) {
38939
38945
  return lines.join("\n");
38940
38946
  }
38941
38947
  function nextHintForPlan(requestText) {
38942
- return `Next: /code --apply --yes "${requestText}" (or preview: --output detail --preview-lines 20)`;
38948
+ return `Next: /code --apply --yes "${requestText}" (or preview: --output diff --diff-lines 200)`;
38943
38949
  }
38944
38950
  function okLine(text) {
38945
38951
  return `OK: ${text}`;
@@ -38953,6 +38959,86 @@ function truncate(s2, n) {
38953
38959
  function headLines(s2, n) {
38954
38960
  return s2.split(/\r?\n/).slice(0, n);
38955
38961
  }
38962
+ function formatPlanAsDiff(files, opts) {
38963
+ const budget = normalizeDiffBudget(opts.diffBudget);
38964
+ const lines = [];
38965
+ let bytesUsed = 0;
38966
+ let shownFiles = 0;
38967
+ for (const f3 of files) {
38968
+ if (budget.globalMaxFiles !== void 0 && shownFiles >= budget.globalMaxFiles) break;
38969
+ const before = readCurrentFileSafe(opts.root, f3.path);
38970
+ const after = f3.preview || "";
38971
+ const diff = unifiedSingleHunkDiff(f3.path, before, after, budget);
38972
+ const diffBytes = Buffer.byteLength(diff, "utf8");
38973
+ if (budget.globalMaxBytes !== void 0 && bytesUsed + diffBytes > budget.globalMaxBytes && shownFiles > 0) {
38974
+ lines.push(`
38975
+ [truncated: global diff byte budget reached]`);
38976
+ break;
38977
+ }
38978
+ lines.push(diff);
38979
+ bytesUsed += diffBytes;
38980
+ shownFiles++;
38981
+ }
38982
+ if (files.length > shownFiles) {
38983
+ lines.push(`
38984
+ [${files.length - shownFiles} more file(s) omitted; re-run with --output diff --diff-lines ${budget.diffLines ?? 200}]`);
38985
+ }
38986
+ return lines.join("\n");
38987
+ }
38988
+ function readCurrentFileSafe(root, rel) {
38989
+ if (!root) return "";
38990
+ try {
38991
+ const fs46 = __require("fs");
38992
+ const p = __require("path").join(root, rel);
38993
+ return fs46.existsSync(p) ? fs46.readFileSync(p, "utf8") : "";
38994
+ } catch {
38995
+ return "";
38996
+ }
38997
+ }
38998
+ function normalizeDiffBudget(b) {
38999
+ const envGlobalBytes = Number(process.env.MARIA_DIFF_GLOBAL_MAX_BYTES || "262144");
39000
+ const envGlobalFiles = Number(process.env.MARIA_DIFF_GLOBAL_MAX_FILES || "20");
39001
+ return {
39002
+ diffLines: b?.diffLines && b.diffLines > 0 ? b.diffLines : 200,
39003
+ diffBytes: b?.diffBytes && b.diffBytes > 0 ? b.diffBytes : 64 * 1024,
39004
+ diffHunks: b?.diffHunks && b.diffHunks > 0 ? b.diffHunks : 8,
39005
+ globalMaxBytes: Number.isFinite(b?.globalMaxBytes) ? b.globalMaxBytes : envGlobalBytes,
39006
+ globalMaxFiles: Number.isFinite(b?.globalMaxFiles) ? b.globalMaxFiles : envGlobalFiles
39007
+ };
39008
+ }
39009
+ function unifiedSingleHunkDiff(relPath, before, after, b) {
39010
+ const beforeLines = before.split(/\r?\n/);
39011
+ const afterLines = after.split(/\r?\n/);
39012
+ let i2 = 0;
39013
+ while (i2 < beforeLines.length && i2 < afterLines.length && beforeLines[i2] === afterLines[i2]) i2++;
39014
+ let j = 0;
39015
+ while (j < beforeLines.length - i2 && j < afterLines.length - i2 && beforeLines[beforeLines.length - 1 - j] === afterLines[afterLines.length - 1 - j]) j++;
39016
+ const oldMid = beforeLines.slice(i2, beforeLines.length - j);
39017
+ const newMid = afterLines.slice(i2, afterLines.length - j);
39018
+ const header = [`--- a/${relPath}`, `+++ b/${relPath}`];
39019
+ const body = [];
39020
+ const ctxPrefix = Math.max(0, i2 - 3);
39021
+ Math.min(beforeLines.length, beforeLines.length - j + 3);
39022
+ const preCtx = beforeLines.slice(ctxPrefix, i2).map((l) => ` ${l}`);
39023
+ const postCtx = beforeLines.slice(beforeLines.length - j, Math.min(beforeLines.length - j + 3, beforeLines.length)).map((l) => ` ${l}`);
39024
+ const del = oldMid.map((l) => `-${l}`);
39025
+ const add = newMid.map((l) => `+${l}`);
39026
+ body.push(...preCtx);
39027
+ body.push(...del);
39028
+ body.push(...add);
39029
+ body.push(...postCtx);
39030
+ const maxLines = b.diffLines;
39031
+ let sliced = body.slice(0, maxLines);
39032
+ let out = header.concat(sliced).join("\n");
39033
+ if (sliced.length < body.length) out += `
39034
+ [truncated ${body.length - sliced.length} line(s); re-run with higher --diff-lines]`;
39035
+ if (Buffer.byteLength(out, "utf8") > b.diffBytes) {
39036
+ while (sliced.length > 0 && Buffer.byteLength(header.concat(sliced).join("\n"), "utf8") > b.diffBytes) sliced = sliced.slice(0, Math.max(0, sliced.length - 10));
39037
+ out = header.concat(sliced).join("\n") + `
39038
+ [truncated by byte budget]`;
39039
+ }
39040
+ return out;
39041
+ }
38956
39042
  var init_OutputFormatter = __esm({
38957
39043
  "src/services/code-orchestrator/OutputFormatter.ts"() {
38958
39044
  }
@@ -38963,64 +39049,63 @@ async function interactiveApprovePlan(files, opts = {}) {
38963
39049
  if (!process.stdin.isTTY) {
38964
39050
  return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
38965
39051
  }
38966
- const first = await ask(`Approve entire plan? [a=all / q=cancel] `, timeoutMs);
39052
+ const first = await ask(`Approve all [A] / review [r] / cancel [q]: `, timeoutMs);
38967
39053
  if (!first.ok) {
38968
39054
  return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
38969
39055
  }
38970
- const ans1 = (first.line || "").trim().toLowerCase();
38971
- if (ans1 === "q") return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
38972
- if (ans1 === "a" || autoSelect && ans1 === "") return { approveAll: true, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: false };
39056
+ const a1 = (first.line || "").trim().toLowerCase();
39057
+ if (a1 === "q") return { approveAll: false, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: true };
39058
+ if (a1 === "a" || autoSelect && a1 === "") return { approveAll: true, approved: /* @__PURE__ */ new Set(), skipped: /* @__PURE__ */ new Set(), cancelled: false };
38973
39059
  const approved = /* @__PURE__ */ new Set();
38974
39060
  const skipped = /* @__PURE__ */ new Set();
38975
- for (const f3 of files) {
38976
- const short = `${f3.action} ${f3.path}`;
38977
- const out = await ask(`${short} [a=approve / s=skip / v=view / d=diff / q=cancel] `, timeoutMs);
39061
+ let i2 = 0;
39062
+ const total = files.length;
39063
+ while (i2 >= 0 && i2 < total) {
39064
+ const f3 = files[i2];
39065
+ process.stdout.write(`\rfile ${i2 + 1}/${total}: ${f3.action} ${f3.path}
39066
+ `);
39067
+ const out = await ask(`[n]ext [p]rev [a]pprove [s]kip [v]iew [d]iff [aa] all [ss] skip [q]uit: `, timeoutMs);
38978
39068
  if (!out.ok) {
38979
39069
  console.log("Interactive prompt timed out (15s). Cancelled.");
38980
39070
  return { approveAll: false, approved, skipped, cancelled: true };
38981
39071
  }
38982
39072
  const ans = (out.line || "").trim().toLowerCase();
38983
39073
  if (ans === "q") return { approveAll: false, approved, skipped, cancelled: true };
39074
+ if (ans === "n" || ans === "") {
39075
+ i2++;
39076
+ continue;
39077
+ }
39078
+ if (ans === "p") {
39079
+ i2 = Math.max(0, i2 - 1);
39080
+ continue;
39081
+ }
39082
+ if (ans === "aa") {
39083
+ for (const x2 of files) approved.add(x2.path);
39084
+ break;
39085
+ }
39086
+ if (ans === "ss") {
39087
+ for (const x2 of files) skipped.add(x2.path);
39088
+ break;
39089
+ }
39090
+ if (ans === "a") {
39091
+ approved.add(f3.path);
39092
+ i2++;
39093
+ continue;
39094
+ }
38984
39095
  if (ans === "s") {
38985
39096
  skipped.add(f3.path);
39097
+ i2++;
38986
39098
  continue;
38987
39099
  }
38988
39100
  if (ans === "v") {
38989
- if (f3.preview) console.log(head(f3.preview, 20));
38990
- else console.log("(no preview)");
38991
- const again = await ask(`Approve? [a / s / q] `, timeoutMs);
38992
- if (!again.ok) return { approveAll: false, approved, skipped, cancelled: true };
38993
- const ans2 = (again.line || "").trim().toLowerCase();
38994
- if (ans2 === "q") return { approveAll: false, approved, skipped, cancelled: true };
38995
- if (ans2 === "s") {
38996
- skipped.add(f3.path);
38997
- continue;
38998
- }
38999
- approved.add(f3.path);
39000
- } else if (ans === "d") {
39001
- try {
39002
- const fs45 = await import('fs/promises');
39003
- const p = (opts.root || process.cwd()) + "/" + f3.path;
39004
- const current = await fs45.readFile(p, "utf8").catch(() => "");
39005
- console.log("--- current (head) ---");
39006
- console.log(head(current, 20) || "(file does not exist)");
39007
- console.log("--- proposed (head) ---");
39008
- console.log(head(f3.preview || "", 20) || "(no preview)");
39009
- } catch {
39010
- }
39011
- const again = await ask(`Approve? [a / s / q] `, timeoutMs);
39012
- if (!again.ok) return { approveAll: false, approved, skipped, cancelled: true };
39013
- const ans2 = (again.line || "").trim().toLowerCase();
39014
- if (ans2 === "q") return { approveAll: false, approved, skipped, cancelled: true };
39015
- if (ans2 === "s") {
39016
- skipped.add(f3.path);
39017
- continue;
39018
- }
39019
- approved.add(f3.path);
39020
- } else {
39021
- if (ans === "a" || ans === "") approved.add(f3.path);
39022
- else skipped.add(f3.path);
39101
+ console.log(f3.preview ? head(f3.preview, 20) : "(no preview)");
39102
+ continue;
39023
39103
  }
39104
+ if (ans === "d") {
39105
+ await showHeadDiff(opts.root || process.cwd(), f3.path, f3.preview || "");
39106
+ continue;
39107
+ }
39108
+ i2++;
39024
39109
  }
39025
39110
  return { approveAll: false, approved, skipped, cancelled: false };
39026
39111
  }
@@ -39058,10 +39143,187 @@ function ask(prompt, timeoutMs) {
39058
39143
  function head(s2, n) {
39059
39144
  return s2.split(/\r?\n/).slice(0, n).join("\n");
39060
39145
  }
39146
+ async function showHeadDiff(root, rel, proposal) {
39147
+ try {
39148
+ const fs46 = await import('fs/promises');
39149
+ const p = __require("path").join(root, rel);
39150
+ const current = await fs46.readFile(p, "utf8").catch(() => "");
39151
+ console.log("--- current (head) ---");
39152
+ console.log(head(current, 20) || "(file does not exist)");
39153
+ console.log("--- proposed (head) ---");
39154
+ console.log(head(proposal, 20) || "(no preview)");
39155
+ } catch {
39156
+ }
39157
+ }
39061
39158
  var init_InteractiveController = __esm({
39062
39159
  "src/services/code-orchestrator/InteractiveController.ts"() {
39063
39160
  }
39064
39161
  });
39162
+ async function mapAttachmentsToTargets(attached, opts) {
39163
+ const warnings = [];
39164
+ const mapped = [];
39165
+ const ambiguous = [];
39166
+ const root = path55__namespace.default.resolve(opts.root);
39167
+ const maxN = Math.min(attached.length, Math.max(1, opts.maxAttachments));
39168
+ const pool = attached.slice(0, maxN);
39169
+ if (attached.length > maxN) warnings.push(`Attachments clamped: ${attached.length} \u2192 ${maxN}`);
39170
+ const repoFiles = await listRepoFiles(root);
39171
+ for (const a of pool) {
39172
+ if (!Number.isFinite(a.size) || a.size > PER_FILE_SIZE_CAP) {
39173
+ warnings.push(`Attachment too large (>${PER_FILE_SIZE_CAP} bytes): ${a.originalName}`);
39174
+ continue;
39175
+ }
39176
+ if (looksBinary(a.content, a.mime)) {
39177
+ warnings.push(`Binary/non-text attachment skipped: ${a.originalName}`);
39178
+ continue;
39179
+ }
39180
+ if (a.pathHint) {
39181
+ const safeRel = sanitizeRel(a.pathHint);
39182
+ const full = path55__namespace.default.join(root, safeRel);
39183
+ if (!full.startsWith(root)) {
39184
+ warnings.push(`Path traversal/absolute denied: ${a.pathHint}`);
39185
+ } else if (!opts.allowDotfiles && hasDotSegment(safeRel)) {
39186
+ warnings.push(`Dotfile path denied: ${a.pathHint}`);
39187
+ } else {
39188
+ const exists = repoFiles.has(safeRel);
39189
+ mapped.push({ path: safeRel, exists, reason: "pathHint", attachment: a });
39190
+ continue;
39191
+ }
39192
+ }
39193
+ const name2 = a.originalName.toLowerCase();
39194
+ const matches = Array.from(repoFiles.values()).filter((p) => path55__namespace.default.basename(p).toLowerCase() === name2);
39195
+ if (matches.length === 1) {
39196
+ mapped.push({ path: matches[0], exists: true, reason: "filename", attachment: a });
39197
+ continue;
39198
+ } else if (matches.length > 1) ;
39199
+ const ext2 = extOf(name2);
39200
+ const candidates = Array.from(repoFiles.values()).filter((p) => extOf(p.toLowerCase()) === ext2);
39201
+ let best = null;
39202
+ let second = null;
39203
+ const head2 = headText(a.content, 20);
39204
+ const tail = tailText(a.content, 20);
39205
+ for (const p of candidates.slice(0, 500)) {
39206
+ let score = 0;
39207
+ try {
39208
+ const full = path55__namespace.default.join(root, p);
39209
+ const body = await safeReadHeadTail(full, 20);
39210
+ score = jaccard(tokens(head2), tokens(body.head)) * 0.6 + jaccard(tokens(tail), tokens(body.tail)) * 0.4;
39211
+ } catch {
39212
+ }
39213
+ if (!best || score > best.score) {
39214
+ second = best;
39215
+ best = { p, score };
39216
+ } else if (!second || score > second.score) {
39217
+ second = { p, score };
39218
+ }
39219
+ }
39220
+ if (best && (second ? best.score - second.score >= 0.2 : best.score >= 0.3)) {
39221
+ mapped.push({ path: best.p, exists: true, reason: "fuzzy", attachment: a });
39222
+ continue;
39223
+ }
39224
+ const proposed = proposePath(root, a.originalName);
39225
+ if (!opts.allowDotfiles && hasDotSegment(proposed)) {
39226
+ if (opts.mode === "strict") {
39227
+ warnings.push(`Proposed dotfile denied under strict mode: ${proposed}`);
39228
+ continue;
39229
+ }
39230
+ }
39231
+ if (opts.mode === "strict" && (matches.length > 1 || best && second && best.score - second.score < 0.2)) {
39232
+ ambiguous.push({ attachment: a, candidates: matches, reason: "ambiguous" });
39233
+ continue;
39234
+ }
39235
+ mapped.push({ path: proposed, exists: false, reason: "proposed", attachment: a });
39236
+ }
39237
+ return { mapped, ambiguous, warnings };
39238
+ }
39239
+ function sanitizeRel(rel) {
39240
+ const s2 = rel.replace(/^\/+/, "").replace(/\r|\n/g, "").replace(/\\/g, "/");
39241
+ return s2.replace(/\.\.+/g, "");
39242
+ }
39243
+ function hasDotSegment(p) {
39244
+ return p.split(/\/+|\\+/).some((seg) => seg.startsWith("."));
39245
+ }
39246
+ function looksBinary(content, mime) {
39247
+ if (mime && !/^text\//i.test(mime)) return true;
39248
+ let nul = 0;
39249
+ const len = Math.min(content.length, PER_FILE_SIZE_CAP);
39250
+ for (let i2 = 0; i2 < len; i2++) if (content.charCodeAt(i2) === 0) nul++;
39251
+ return len > 0 && nul / len > 0.1;
39252
+ }
39253
+ async function listRepoFiles(root) {
39254
+ const out = /* @__PURE__ */ new Set();
39255
+ async function walk2(dir, relBase) {
39256
+ let entries = [];
39257
+ try {
39258
+ entries = await fs21.promises.readdir(dir, { withFileTypes: true });
39259
+ } catch {
39260
+ return;
39261
+ }
39262
+ for (const e2 of entries) {
39263
+ const name2 = e2.name;
39264
+ if (name2 === ".git" || name2 === "node_modules" || name2 === "dist" || name2 === ".maria") continue;
39265
+ const full = path55__namespace.default.join(dir, name2);
39266
+ const rel = path55__namespace.default.relative(root, full).replace(/\\/g, "/");
39267
+ if (e2.isDirectory()) {
39268
+ await walk2(full);
39269
+ continue;
39270
+ }
39271
+ out.add(rel);
39272
+ }
39273
+ }
39274
+ await walk2(root);
39275
+ return out;
39276
+ }
39277
+ function extOf(name2) {
39278
+ const i2 = name2.lastIndexOf(".");
39279
+ return i2 >= 0 ? name2.slice(i2 + 1) : "";
39280
+ }
39281
+ function headText(s2, n) {
39282
+ return s2.split(/\r?\n/).slice(0, n).join("\n");
39283
+ }
39284
+ function tailText(s2, n) {
39285
+ const a = s2.split(/\r?\n/);
39286
+ return a.slice(Math.max(0, a.length - n)).join("\n");
39287
+ }
39288
+ async function safeReadHeadTail(full, n) {
39289
+ try {
39290
+ const buf = await fs21.promises.readFile(full, "utf8");
39291
+ return { head: headText(buf, n), tail: tailText(buf, n) };
39292
+ } catch {
39293
+ return { head: "", tail: "" };
39294
+ }
39295
+ }
39296
+ function tokens(s2) {
39297
+ return new Set(s2.toLowerCase().split(/[^a-z0-9_]+/).filter(Boolean));
39298
+ }
39299
+ function jaccard(a, b) {
39300
+ if (a.size === 0 && b.size === 0) return 1;
39301
+ let inter = 0;
39302
+ for (const t2 of a) if (b.has(t2)) inter++;
39303
+ const union = a.size + b.size - inter;
39304
+ return union === 0 ? 0 : inter / union;
39305
+ }
39306
+ function proposePath(root, original) {
39307
+ const base = path55__namespace.default.basename(original).replace(/\s+/g, "-").replace(/[^a-zA-Z0-9._-]/g, "").toLowerCase();
39308
+ const src = path55__namespace.default.join(root, "src");
39309
+ const dir = existsSync8(src) ? "src" : "";
39310
+ const rel = dir ? path55__namespace.default.join(dir, base) : base;
39311
+ return rel.replace(/\\/g, "/");
39312
+ }
39313
+ function existsSync8(p) {
39314
+ try {
39315
+ __require("fs").accessSync(p);
39316
+ return true;
39317
+ } catch {
39318
+ return false;
39319
+ }
39320
+ }
39321
+ var PER_FILE_SIZE_CAP;
39322
+ var init_AttachmentMapper = __esm({
39323
+ "src/services/code-orchestrator/AttachmentMapper.ts"() {
39324
+ PER_FILE_SIZE_CAP = 256 * 1024;
39325
+ }
39326
+ });
39065
39327
 
39066
39328
  // src/services/code-orchestrator/Orchestrator.ts
39067
39329
  var Orchestrator_exports = {};
@@ -39070,26 +39332,92 @@ __export(Orchestrator_exports, {
39070
39332
  });
39071
39333
  async function orchestrate(request, opts) {
39072
39334
  const profile = await scanRepo(opts.root);
39073
- const result = process.env.MARIA_E2E_FAKE_CODE === "1" ? { output: "```ts\nexport const demo=1;\n```" } : await executeCode(request);
39074
- const blocks = extractBlocks(result.output || "");
39075
- const initial = blocks.map((b, i2) => ({
39076
- path: suggestName2(request, b.language, i2),
39077
- kind: "source",
39078
- action: "create",
39079
- description: describe2(b.language, ""),
39080
- language: b.language,
39081
- preview: b.code
39082
- }));
39335
+ const initial = [];
39336
+ let attachWarnings = [];
39337
+ if (opts.attachedFiles && opts.attachedFiles.length > 0) {
39338
+ const mapRes = await mapAttachmentsToTargets(opts.attachedFiles, {
39339
+ root: opts.root,
39340
+ mode: opts.flags.attachMode || "assist",
39341
+ maxAttachments: opts.flags.maxAttachments || 50,
39342
+ allowDotfiles: !!opts.flags.allowDotfiles
39343
+ });
39344
+ attachWarnings = mapRes.warnings.slice();
39345
+ for (const m2 of mapRes.mapped) {
39346
+ initial.push({
39347
+ path: m2.path,
39348
+ kind: "source",
39349
+ action: m2.exists ? "modify" : "create",
39350
+ description: m2.exists ? "Modify (attachment)" : "Create (attachment)",
39351
+ preview: m2.attachment.content
39352
+ });
39353
+ }
39354
+ }
39355
+ const onlyAttached = !!opts.flags.onlyAttached;
39356
+ const explicitFiles = parseExplicitFilenames(request);
39357
+ if (!onlyAttached) {
39358
+ const result = process.env.MARIA_E2E_FAKE_CODE === "1" ? { output: "```ts\nexport const demo=1;\n```" } : await executeCode(request);
39359
+ const blocks = extractBlocks(result.output || "");
39360
+ if (explicitFiles.length > 0) {
39361
+ const mapped = /* @__PURE__ */ new Set();
39362
+ const htmlIdx = blocks.findIndex((b) => /html/i.test(b.language));
39363
+ const htmlFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".html"));
39364
+ if (htmlIdx >= 0 && htmlFile) {
39365
+ initial.push({ path: htmlFile, kind: "source", action: "create", description: "HTML page", language: "html", preview: blocks[htmlIdx].code });
39366
+ mapped.add(htmlFile);
39367
+ }
39368
+ const jsIdx = blocks.findIndex((b) => /(ts|tsx|jsx|javascript|js)/i.test(b.language));
39369
+ const jsFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".js"));
39370
+ if (jsIdx >= 0 && jsFile && !mapped.has(jsFile)) {
39371
+ initial.push({ path: jsFile, kind: "source", action: "create", description: "Script", language: "javascript", preview: blocks[jsIdx].code });
39372
+ mapped.add(jsFile);
39373
+ }
39374
+ const cssIdx = blocks.findIndex((b) => /css/i.test(b.language));
39375
+ const cssFile = explicitFiles.find((f3) => f3.toLowerCase().endsWith(".css"));
39376
+ if (cssIdx >= 0 && cssFile && !mapped.has(cssFile)) {
39377
+ initial.push({ path: cssFile, kind: "source", action: "create", description: "Stylesheet", language: "css", preview: blocks[cssIdx].code });
39378
+ mapped.add(cssFile);
39379
+ }
39380
+ for (const f3 of explicitFiles) {
39381
+ if (mapped.has(f3)) continue;
39382
+ initial.push(scaffoldForFilename(f3, explicitFiles));
39383
+ }
39384
+ } else {
39385
+ for (let i2 = 0; i2 < blocks.length; i2++) {
39386
+ const b = blocks[i2];
39387
+ initial.push({
39388
+ path: suggestName2(request, b.language, i2),
39389
+ kind: "source",
39390
+ action: "create",
39391
+ description: describe2(b.language, ""),
39392
+ language: b.language,
39393
+ preview: b.code
39394
+ });
39395
+ }
39396
+ }
39397
+ }
39398
+ if (explicitFiles.length > 0 && initial.filter((f3) => !!f3.preview).length === 0) {
39399
+ for (const f3 of explicitFiles) {
39400
+ initial.push(scaffoldForFilename(f3, explicitFiles));
39401
+ }
39402
+ }
39083
39403
  const normalized = await normalizePlans(initial, { root: opts.root });
39084
39404
  const validated = await validatePlan(normalized, { root: opts.root, profile, flags: { maxFiles: opts.flags.maxFiles, yes: opts.flags.yes, interactive: !!opts.flags.interactive, ...opts.flags } });
39085
39405
  const outputMode = resolveOutputMode(opts.flags.output, validated.files.length, !!opts.flags.hideCode);
39086
39406
  const summary = summarizePlan(validated.files);
39087
39407
  const lines = [
39088
- formatPlan(summary, { mode: outputMode, previewLines: normalizePreviewLines(opts.flags.previewLines) })
39408
+ formatPlan(summary, {
39409
+ mode: outputMode,
39410
+ previewLines: normalizePreviewLines(opts.flags.previewLines),
39411
+ diffBudget: collectDiffBudget(opts.flags),
39412
+ root: opts.root
39413
+ })
39089
39414
  ];
39090
39415
  if (validated.warnings.length) {
39091
39416
  for (const w of validated.warnings) lines.push(`WARN: ${w}`);
39092
39417
  }
39418
+ if (attachWarnings.length) {
39419
+ for (const w of attachWarnings) lines.push(`WARN: ${w}`);
39420
+ }
39093
39421
  if (opts.flags.planOnly || opts.flags.dryRun || !opts.flags.apply) {
39094
39422
  lines.push("", nextHintForPlan(request));
39095
39423
  return { plan: normalized, validated, summaryLines: lines };
@@ -39111,6 +39439,14 @@ async function orchestrate(request, opts) {
39111
39439
  }
39112
39440
  approved = approved.map((f3) => f3.action === "modify" ? { ...f3, overwritePolicy: "allow" } : f3);
39113
39441
  }
39442
+ const softIssues = scanSoftIssues(approved);
39443
+ if ((softIssues.hasTrailingWhitespace || softIssues.hasConflictMarkers) && !opts.flags.interactive && !opts.flags.yes && opts.flags.apply) {
39444
+ lines.push("");
39445
+ if (softIssues.hasTrailingWhitespace) lines.push(warnLine("Proposed changes contain trailing whitespace"));
39446
+ if (softIssues.hasConflictMarkers) lines.push(warnLine("Proposed changes contain conflict markers"));
39447
+ lines.push("Tip: Re-run with --yes to apply anyway, or use --interactive to review.");
39448
+ return { plan: normalized, validated, summaryLines: lines };
39449
+ }
39114
39450
  let appliedCount = 0;
39115
39451
  let durationMs = 0;
39116
39452
  let rolledBack = false;
@@ -39167,6 +39503,15 @@ function resolveOutputMode(mode, count, hideCode) {
39167
39503
  if (mode) return mode;
39168
39504
  return count >= 5 ? "summary" : "detail";
39169
39505
  }
39506
+ function collectDiffBudget(flags) {
39507
+ return {
39508
+ diffLines: normalizePreviewLines(flags?.diffLines) || void 0,
39509
+ diffBytes: normalizePreviewLines(flags?.diffBytes) || void 0,
39510
+ diffHunks: normalizePreviewLines(flags?.diffHunks) || void 0,
39511
+ globalMaxBytes: typeof flags?.diffGlobalMaxBytes === "number" ? flags.diffGlobalMaxBytes : void 0,
39512
+ globalMaxFiles: typeof flags?.diffGlobalMaxFiles === "number" ? flags.diffGlobalMaxFiles : void 0
39513
+ };
39514
+ }
39170
39515
  function extractBlocks(content) {
39171
39516
  const blocks = [];
39172
39517
  const re = /```(\w*)\n([\s\S]*?)```/g;
@@ -39204,12 +39549,12 @@ function languageExt(lang) {
39204
39549
  }
39205
39550
  async function journalResume(root, request, files) {
39206
39551
  try {
39207
- const fs45 = await import('fs/promises');
39208
- const dir = path54__namespace.default.join(root, ".maria", "memory");
39209
- await fs45.mkdir(dir, { recursive: true });
39210
- const out = path54__namespace.default.join(dir, "resume-plan.json");
39552
+ const fs46 = await import('fs/promises');
39553
+ const dir = path55__namespace.default.join(root, ".maria", "memory");
39554
+ await fs46.mkdir(dir, { recursive: true });
39555
+ const out = path55__namespace.default.join(dir, "resume-plan.json");
39211
39556
  const payload = { request, createdAt: (/* @__PURE__ */ new Date()).toISOString(), files };
39212
- await fs45.writeFile(out, JSON.stringify(payload, null, 2), "utf8");
39557
+ await fs46.writeFile(out, JSON.stringify(payload, null, 2), "utf8");
39213
39558
  } catch {
39214
39559
  }
39215
39560
  }
@@ -39305,6 +39650,72 @@ async function buildAutoTag(prefix) {
39305
39650
  return `${prefix}${Date.now()}`;
39306
39651
  }
39307
39652
  }
39653
+ function scanSoftIssues(files) {
39654
+ let tw = false;
39655
+ let cm = false;
39656
+ for (const f3 of files) {
39657
+ const body = f3.preview || "";
39658
+ if (!tw && /\s+$/.test(body.split(/\r?\n/).find((l) => /\s+$/.test(l)) || "")) tw = true;
39659
+ if (!cm && /(<<<<<<<|=======|>>>>>>>)\s/.test(body)) cm = true;
39660
+ if (tw && cm) break;
39661
+ }
39662
+ return { hasTrailingWhitespace: tw, hasConflictMarkers: cm };
39663
+ }
39664
+ function parseExplicitFilenames(request) {
39665
+ const matches = request.match(/([\w.-]+\.(?:html|css|js|jsx|ts|tsx))/gi);
39666
+ if (!matches) return [];
39667
+ const seen = /* @__PURE__ */ new Set();
39668
+ const out = [];
39669
+ for (const m2 of matches) {
39670
+ const rel = m2.replace(/^\/+/, "").replace(/\r|\n/g, "");
39671
+ if (rel.includes("..")) continue;
39672
+ if (!seen.has(rel)) {
39673
+ seen.add(rel);
39674
+ out.push(rel);
39675
+ }
39676
+ }
39677
+ return out;
39678
+ }
39679
+ function scaffoldForFilename(filename, all) {
39680
+ const lower2 = filename.toLowerCase();
39681
+ if (lower2.endsWith(".html")) {
39682
+ const css = all.find((f3) => f3.toLowerCase().endsWith(".css")) || "style.css";
39683
+ const js = all.find((f3) => f3.toLowerCase().endsWith(".js")) || "script.js";
39684
+ const body = `<!doctype html>
39685
+ <html lang="ja">
39686
+ <head>
39687
+ <meta charset="utf-8"/>
39688
+ <meta name="viewport" content="width=device-width, initial-scale=1"/>
39689
+ <title>Pong</title>
39690
+ <link rel="stylesheet" href="${css}">
39691
+ </head>
39692
+ <body>
39693
+ <canvas id="game" width="640" height="480"></canvas>
39694
+ <script src="${js}"></script>
39695
+ </body>
39696
+ </html>
39697
+ `;
39698
+ return { path: filename, kind: "source", action: "create", description: "HTML page", language: "html", preview: body };
39699
+ }
39700
+ if (lower2.endsWith(".css")) {
39701
+ const body = `html,body{margin:0;height:100%;background:#111;color:#eee;font-family:system-ui,sans-serif}
39702
+ #game{display:block;margin:0 auto;background:#000;border:2px solid #444}`;
39703
+ return { path: filename, kind: "source", action: "create", description: "Stylesheet", language: "css", preview: body };
39704
+ }
39705
+ if (lower2.endsWith(".js")) {
39706
+ const body = `// Minimal Pong scaffold
39707
+ const canvas = document.getElementById('game');
39708
+ const ctx = canvas.getContext('2d');
39709
+ let last = 0;
39710
+ const state = { ball:{x:320,y:240,vx:3,vy:2,r:6}, p1:{y:200}, p2:{y:200} };
39711
+ function step(t){ const dt=(t-last)||16; last=t; update(dt); draw(); requestAnimationFrame(step); }
39712
+ 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; }
39713
+ 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(); }
39714
+ requestAnimationFrame(step);`;
39715
+ return { path: filename, kind: "source", action: "create", description: "Script", language: "javascript", preview: body };
39716
+ }
39717
+ return { path: filename, kind: "source", action: "create", description: "Source file", preview: "" };
39718
+ }
39308
39719
  var init_Orchestrator = __esm({
39309
39720
  "src/services/code-orchestrator/Orchestrator.ts"() {
39310
39721
  init_RepoScanner();
@@ -39316,6 +39727,7 @@ var init_Orchestrator = __esm({
39316
39727
  init_api_caller();
39317
39728
  init_AuthenticationManager();
39318
39729
  init_MariaAPIClient();
39730
+ init_AttachmentMapper();
39319
39731
  }
39320
39732
  });
39321
39733
 
@@ -39353,7 +39765,7 @@ var init_code_command = __esm({
39353
39765
  name = "code";
39354
39766
  category = "code";
39355
39767
  description = "Generate code with AI";
39356
- 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]";
39768
+ 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]";
39357
39769
  aliases = ["c"];
39358
39770
  examples = [
39359
39771
  {
@@ -39376,11 +39788,12 @@ var init_code_command = __esm({
39376
39788
  const opts = this.parseV2Options(commandArgs.raw);
39377
39789
  const root = opts.root || process.cwd();
39378
39790
  const { orchestrate: orchestrate2 } = await Promise.resolve().then(() => (init_Orchestrator(), Orchestrator_exports));
39791
+ const attachments = await this.collectAttachedFiles(context2).catch(() => []);
39379
39792
  const abort = new AbortController();
39380
39793
  const onSigint = () => abort.abort();
39381
39794
  process.once("SIGINT", onSigint);
39382
39795
  try {
39383
- 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 });
39796
+ 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 });
39384
39797
  const out = res.summaryLines.join("\n");
39385
39798
  return this.success(out);
39386
39799
  } finally {
@@ -39429,7 +39842,7 @@ ${pretty}`);
39429
39842
  }
39430
39843
  // v2.0 helpers
39431
39844
  parseV2Options(raw) {
39432
- 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 };
39845
+ 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 };
39433
39846
  const a = raw.slice();
39434
39847
  while (a.length) {
39435
39848
  const x2 = a.shift();
@@ -39484,6 +39897,26 @@ ${pretty}`);
39484
39897
  case "allow-dotfiles":
39485
39898
  opts.allowDotfiles = true;
39486
39899
  break;
39900
+ case "only-attached":
39901
+ opts.onlyAttached = true;
39902
+ break;
39903
+ case "attach-mode": {
39904
+ const val = (v || a.shift() || "").toLowerCase();
39905
+ opts.attachMode = val === "strict" || val === "assist" ? val : "assist";
39906
+ break;
39907
+ }
39908
+ case "max-attachments":
39909
+ opts.maxAttachments = Number(v || a.shift());
39910
+ break;
39911
+ case "diff-lines":
39912
+ opts.diffLines = Number(v || a.shift());
39913
+ break;
39914
+ case "diff-bytes":
39915
+ opts.diffBytes = Number(v || a.shift());
39916
+ break;
39917
+ case "diff-hunks":
39918
+ opts.diffHunks = Number(v || a.shift());
39919
+ break;
39487
39920
  case "confirm-overwrites": {
39488
39921
  const list = (v || a.shift() || "").split(",").map((s2) => s2.trim()).filter(Boolean);
39489
39922
  opts.confirmOverwrites = list;
@@ -39545,7 +39978,7 @@ ${pretty}`);
39545
39978
  const { normalizePlans: normalizePlans2 } = await Promise.resolve().then(() => (init_FilePlanBuilder(), FilePlanBuilder_exports));
39546
39979
  const normalized = await normalizePlans2(plans, { root });
39547
39980
  for (const p of normalized) {
39548
- const exists = await this.pathExists(path54__namespace.join(root, p.path));
39981
+ const exists = await this.pathExists(path55__namespace.join(root, p.path));
39549
39982
  p.action = exists ? "modify" : "create";
39550
39983
  }
39551
39984
  return normalized;
@@ -39560,16 +39993,16 @@ ${pretty}`);
39560
39993
  }
39561
39994
  async persistLastPlan(root, plans) {
39562
39995
  try {
39563
- const fs45 = await import('fs/promises');
39564
- const p = path54__namespace.join(root, ".maria");
39565
- await fs45.mkdir(p, { recursive: true });
39566
- const out = path54__namespace.join(p, "last-plan.json");
39567
- await fs45.writeFile(out, JSON.stringify({ createdAt: (/* @__PURE__ */ new Date()).toISOString(), plans }, null, 2), "utf8");
39996
+ const fs46 = await import('fs/promises');
39997
+ const p = path55__namespace.join(root, ".maria");
39998
+ await fs46.mkdir(p, { recursive: true });
39999
+ const out = path55__namespace.join(p, "last-plan.json");
40000
+ await fs46.writeFile(out, JSON.stringify({ createdAt: (/* @__PURE__ */ new Date()).toISOString(), plans }, null, 2), "utf8");
39568
40001
  } catch {
39569
40002
  }
39570
40003
  }
39571
40004
  async applyPlan(plans, options) {
39572
- const fs45 = await import('fs/promises');
40005
+ const fs46 = await import('fs/promises');
39573
40006
  const created = [];
39574
40007
  const modified = [];
39575
40008
  const skipped = [];
@@ -39579,7 +40012,7 @@ ${pretty}`);
39579
40012
  try {
39580
40013
  for (const plan of plans) {
39581
40014
  if (options.signal?.aborted) throw new Error("INTERRUPTED");
39582
- const full = path54__namespace.join(options.root, plan.path);
40015
+ const full = path55__namespace.join(options.root, plan.path);
39583
40016
  const exists = await this.pathExists(full);
39584
40017
  if (exists && !options.overwriteAllowed) {
39585
40018
  skipped.push(plan.path);
@@ -39588,9 +40021,9 @@ ${pretty}`);
39588
40021
  continue;
39589
40022
  }
39590
40023
  const tmp = full + `.tmp-${process.pid}-${Date.now()}`;
39591
- await fs45.mkdir(path54__namespace.dirname(full), { recursive: true });
39592
- await fs45.writeFile(tmp, plan.preview || "", "utf8");
39593
- await fs45.rename(tmp, full);
40024
+ await fs46.mkdir(path55__namespace.dirname(full), { recursive: true });
40025
+ await fs46.writeFile(tmp, plan.preview || "", "utf8");
40026
+ await fs46.rename(tmp, full);
39594
40027
  if (exists) modified.push(plan.path);
39595
40028
  else created.push(plan.path);
39596
40029
  written++;
@@ -39601,7 +40034,7 @@ ${pretty}`);
39601
40034
  if (options.rollback) {
39602
40035
  for (const p of [...created, ...modified]) {
39603
40036
  try {
39604
- await fs45.unlink(path54__namespace.join(options.root, p));
40037
+ await fs46.unlink(path55__namespace.join(options.root, p));
39605
40038
  } catch {
39606
40039
  }
39607
40040
  }
@@ -39611,8 +40044,8 @@ ${pretty}`);
39611
40044
  }
39612
40045
  async pathExists(p) {
39613
40046
  try {
39614
- const fs45 = await import('fs/promises');
39615
- await fs45.access(p);
40047
+ const fs46 = await import('fs/promises');
40048
+ await fs46.access(p);
39616
40049
  return true;
39617
40050
  } catch {
39618
40051
  return false;
@@ -39681,13 +40114,13 @@ ${pretty}`);
39681
40114
  const extension = LANGUAGE_EXTENSIONS[block.language] || ".txt";
39682
40115
  const timestamp = Date.now().toString(36);
39683
40116
  const filename = index === 0 ? `${baseName}${extension}` : `${baseName}_${index + 1}${extension}`;
39684
- const fullPath = path54__namespace.join(process.cwd(), filename);
40117
+ const fullPath = path55__namespace.join(process.cwd(), filename);
39685
40118
  try {
39686
40119
  await fsp.writeFile(fullPath, block.code, "utf8");
39687
40120
  return fullPath;
39688
40121
  } catch (error2) {
39689
40122
  const fallbackName = `code_${timestamp}${extension}`;
39690
- const fallbackPath = path54__namespace.join(process.cwd(), fallbackName);
40123
+ const fallbackPath = path55__namespace.join(process.cwd(), fallbackName);
39691
40124
  await fsp.writeFile(fallbackPath, block.code, "utf8");
39692
40125
  return fallbackPath;
39693
40126
  }
@@ -39717,6 +40150,28 @@ ${pretty}`);
39717
40150
  }
39718
40151
  return null;
39719
40152
  }
40153
+ // Attempt to collect attached files from context; map to AttachedFileContext
40154
+ async collectAttachedFiles(context2) {
40155
+ const list = [];
40156
+ const fs46 = await import('fs/promises');
40157
+ const path56 = await import('path');
40158
+ const att = context2 && (context2.attachments || context2.input?.attachments) || [];
40159
+ for (const a of att) {
40160
+ try {
40161
+ const p = a.path || a.filePath || a.name || "";
40162
+ const originalName = a.name || path56.basename(p || `attachment_${Date.now().toString(36)}`);
40163
+ let content = a.content;
40164
+ if (!content && p) {
40165
+ const abs = path56.isAbsolute(p) ? p : path56.join(process.cwd(), p);
40166
+ content = await fs46.readFile(abs, "utf8");
40167
+ }
40168
+ if (!content) continue;
40169
+ list.push({ originalName, pathHint: p || void 0, content, size: Buffer.byteLength(content, "utf8"), mime: a.mime || a.type });
40170
+ } catch {
40171
+ }
40172
+ }
40173
+ return list;
40174
+ }
39720
40175
  };
39721
40176
  codeCommand = new CodeCommand();
39722
40177
  metadata4 = {
@@ -39817,7 +40272,7 @@ function getKnowledgeProviderFromEnv(root = process.cwd()) {
39817
40272
  function safeListFiles(dir) {
39818
40273
  try {
39819
40274
  return fs21__namespace.default.readdirSync(dir, { withFileTypes: true }).flatMap((d) => {
39820
- const p = path54__namespace.default.join(dir, d.name);
40275
+ const p = path55__namespace.default.join(dir, d.name);
39821
40276
  if (d.isDirectory()) {
39822
40277
  if (/node_modules|\.git|dist|coverage|artifacts|reports/.test(p)) return [];
39823
40278
  return safeListFiles(p);
@@ -39853,7 +40308,7 @@ var init_KnowledgeProvider = __esm({
39853
40308
  }
39854
40309
  async getPrinciples(_projectId, _taskId) {
39855
40310
  const candidates = [
39856
- path54__namespace.default.join(this.root, "docs"),
40311
+ path55__namespace.default.join(this.root, "docs"),
39857
40312
  this.root
39858
40313
  ];
39859
40314
  const out = [];
@@ -39915,7 +40370,7 @@ function promptLine(timeoutMs = 15e3) {
39915
40370
  }
39916
40371
  async function readLastDebugStatusSafe(cwd2) {
39917
40372
  try {
39918
- const p = path54__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
40373
+ const p = path55__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
39919
40374
  const buf = await fsp__namespace.readFile(p, "utf8");
39920
40375
  const arr = JSON.parse(buf);
39921
40376
  if (Array.isArray(arr) && arr.length) return arr[arr.length - 1];
@@ -39926,7 +40381,7 @@ async function readLastDebugStatusSafe(cwd2) {
39926
40381
  }
39927
40382
  async function readDebugJournalListSafe(cwd2, count) {
39928
40383
  try {
39929
- const p = path54__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
40384
+ const p = path55__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
39930
40385
  const buf = await fsp__namespace.readFile(p, "utf8");
39931
40386
  const arr = JSON.parse(buf);
39932
40387
  if (!Array.isArray(arr) || arr.length === 0) return [];
@@ -40460,11 +40915,11 @@ async function runWithBudget(tasks, totalMs = 6e3, perStepMs = 600) {
40460
40915
  return out;
40461
40916
  }
40462
40917
  function isSensitive(filepath) {
40463
- const basename15 = path54__namespace.basename(filepath);
40918
+ const basename15 = path55__namespace.basename(filepath);
40464
40919
  return SENSITIVE_PATTERNS2.some((pattern) => pattern.test(basename15) || pattern.test(filepath));
40465
40920
  }
40466
40921
  function isBinary(filepath) {
40467
- const ext2 = path54__namespace.extname(filepath).toLowerCase();
40922
+ const ext2 = path55__namespace.extname(filepath).toLowerCase();
40468
40923
  return BINARY_EXTENSIONS.has(ext2);
40469
40924
  }
40470
40925
  async function safeRead(file, maxBytes = 512 * 1024, maxLines = 200, signal) {
@@ -40520,7 +40975,7 @@ async function scanRoot(opts) {
40520
40975
  ];
40521
40976
  for (const { name: name2, maxLines } of rootFiles) {
40522
40977
  if (signal.aborted || remainMs() < 100) break;
40523
- const filepath = path54__namespace.join(cwd2, name2);
40978
+ const filepath = path55__namespace.join(cwd2, name2);
40524
40979
  const result = await safeRead(filepath, 512 * 1024, maxLines, signal);
40525
40980
  if (result.head || result.meta) {
40526
40981
  let meta24 = result.meta || object;
@@ -40576,7 +41031,7 @@ async function scanBuild(opts) {
40576
41031
  ];
40577
41032
  for (const name2 of buildFiles) {
40578
41033
  if (signal.aborted || remainMs() < 100) break;
40579
- const filepath = path54__namespace.join(cwd2, name2);
41034
+ const filepath = path55__namespace.join(cwd2, name2);
40580
41035
  const result = await safeRead(filepath, 512 * 1024, 100, signal);
40581
41036
  if (result.head || result.meta) {
40582
41037
  findings.push({
@@ -40613,7 +41068,7 @@ async function scanQuality(opts) {
40613
41068
  ];
40614
41069
  for (const name2 of qualityFiles) {
40615
41070
  if (signal.aborted || remainMs() < 100) break;
40616
- const filepath = path54__namespace.join(cwd2, name2);
41071
+ const filepath = path55__namespace.join(cwd2, name2);
40617
41072
  const result = await safeRead(filepath, 512 * 1024, 50, signal);
40618
41073
  if (result.head || result.meta) {
40619
41074
  findings.push({
@@ -40658,7 +41113,7 @@ async function scanScripts(opts) {
40658
41113
  const sample = files.slice(0, 5);
40659
41114
  for (const file of sample) {
40660
41115
  if (signal.aborted || remainMs() < 100) break;
40661
- const result = await safeRead(path54__namespace.join(cwd2, file), 512 * 1024, 100, signal);
41116
+ const result = await safeRead(path55__namespace.join(cwd2, file), 512 * 1024, 100, signal);
40662
41117
  if (result.head || result.meta) {
40663
41118
  findings.push({
40664
41119
  file,
@@ -40700,7 +41155,7 @@ async function scanEntries(opts) {
40700
41155
  ];
40701
41156
  for (const name2 of entryFiles) {
40702
41157
  if (signal.aborted || remainMs() < 100) break;
40703
- const filepath = path54__namespace.join(cwd2, name2);
41158
+ const filepath = path55__namespace.join(cwd2, name2);
40704
41159
  const result = await safeRead(filepath, 512 * 1024, 80, signal);
40705
41160
  if (result.head || result.meta) {
40706
41161
  findings.push({
@@ -40781,9 +41236,9 @@ function checkBinAlignment(pkg, cwd2) {
40781
41236
  const bin = typeof pkg.bin === "string" ? { [pkg.name]: pkg.bin } : pkg.bin;
40782
41237
  for (const [name2, rel] of Object.entries(bin)) {
40783
41238
  const binPath = rel;
40784
- const srcPath = path54__namespace.join(cwd2, binPath);
41239
+ const srcPath = path55__namespace.join(cwd2, binPath);
40785
41240
  if (!fs21__namespace.existsSync(srcPath)) {
40786
- const distGuess = path54__namespace.join(
41241
+ const distGuess = path55__namespace.join(
40787
41242
  cwd2,
40788
41243
  "dist",
40789
41244
  binPath.replace(/^src\//, "").replace(/^bin\//, "bin/")
@@ -41292,7 +41747,7 @@ async function detectMonorepoType(root) {
41292
41747
  const files = await fsp__namespace.readdir(root);
41293
41748
  if (files.includes("package.json")) {
41294
41749
  const pkg = JSON.parse(
41295
- await fsp__namespace.readFile(path54__namespace.join(root, "package.json"), "utf8")
41750
+ await fsp__namespace.readFile(path55__namespace.join(root, "package.json"), "utf8")
41296
41751
  );
41297
41752
  if (pkg.workspaces) {
41298
41753
  if (files.includes("pnpm-workspace.yaml")) return "pnpm";
@@ -41315,7 +41770,7 @@ async function findWorkspaces(root, type) {
41315
41770
  try {
41316
41771
  switch (type) {
41317
41772
  case "pnpm": {
41318
- const wsFile = path54__namespace.join(root, "pnpm-workspace.yaml");
41773
+ const wsFile = path55__namespace.join(root, "pnpm-workspace.yaml");
41319
41774
  try {
41320
41775
  const content = await fsp__namespace.readFile(wsFile, "utf8");
41321
41776
  const patterns = content.match(/packages:\s*\n((?:\s+-\s+.+\n?)+)/);
@@ -41337,7 +41792,7 @@ async function findWorkspaces(root, type) {
41337
41792
  }
41338
41793
  case "yarn":
41339
41794
  case "npm": {
41340
- const pkgPath = path54__namespace.join(root, "package.json");
41795
+ const pkgPath = path55__namespace.join(root, "package.json");
41341
41796
  try {
41342
41797
  const pkg = JSON.parse(await fsp__namespace.readFile(pkgPath, "utf8"));
41343
41798
  const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages || [];
@@ -41356,7 +41811,7 @@ async function findWorkspaces(root, type) {
41356
41811
  }
41357
41812
  case "lerna": {
41358
41813
  try {
41359
- const lernaPath = path54__namespace.join(root, "lerna.json");
41814
+ const lernaPath = path55__namespace.join(root, "lerna.json");
41360
41815
  const lerna = JSON.parse(await fsp__namespace.readFile(lernaPath, "utf8"));
41361
41816
  const patterns = lerna.packages || ["packages/*"];
41362
41817
  for (const pattern of patterns) {
@@ -41415,13 +41870,13 @@ async function findWorkspaces(root, type) {
41415
41870
  }
41416
41871
  async function analyzeWorkspace(workspacePath, root) {
41417
41872
  const info = {
41418
- name: path54__namespace.basename(workspacePath),
41873
+ name: path55__namespace.basename(workspacePath),
41419
41874
  path: workspacePath,
41420
41875
  type: "unknown",
41421
41876
  language: "unknown"
41422
41877
  };
41423
41878
  try {
41424
- const pkgPath = path54__namespace.join(root, workspacePath, "package.json");
41879
+ const pkgPath = path55__namespace.join(root, workspacePath, "package.json");
41425
41880
  const pkgContent = await safeRead(pkgPath, 512 * 1024, 1e3);
41426
41881
  if (pkgContent.head) {
41427
41882
  try {
@@ -41464,7 +41919,7 @@ async function analyzeWorkspace(workspacePath, root) {
41464
41919
  }
41465
41920
  const globby = await loadGlobby();
41466
41921
  const files = await globby(["**/*.{ts,tsx,js,jsx,mjs,cjs}"], {
41467
- cwd: path54__namespace.join(root, workspacePath),
41922
+ cwd: path55__namespace.join(root, workspacePath),
41468
41923
  deep: 2,
41469
41924
  ignore: ["node_modules", "dist", "build"],
41470
41925
  stats: false
@@ -42019,12 +42474,12 @@ function getModuleName(filePath) {
42019
42474
  if (srcIndex >= 0 && srcIndex < parts.length - 1) {
42020
42475
  return parts[srcIndex + 1];
42021
42476
  }
42022
- return path54__namespace.dirname(filePath).split("/").pop() || "root";
42477
+ return path55__namespace.dirname(filePath).split("/").pop() || "root";
42023
42478
  }
42024
42479
  function resolveLocalImport(fromFile2, importPath) {
42025
42480
  if (!importPath.startsWith(".")) return null;
42026
- const dir = path54__namespace.dirname(fromFile2);
42027
- const resolved = path54__namespace.resolve(dir, importPath);
42481
+ const dir = path55__namespace.dirname(fromFile2);
42482
+ const resolved = path55__namespace.resolve(dir, importPath);
42028
42483
  return getModuleName(resolved);
42029
42484
  }
42030
42485
  function getMetricStatus(metric, value) {
@@ -42154,7 +42609,7 @@ async function extractCodeSnippets(files, projectRoot, maxSnippets, includeExamp
42154
42609
  }
42155
42610
  async function extractFileSnippet(file, projectRoot, category) {
42156
42611
  try {
42157
- const fullPath = path54__namespace.join(projectRoot, file.path);
42612
+ const fullPath = path55__namespace.join(projectRoot, file.path);
42158
42613
  const content = await safeRead(fullPath, 512 * 1024, 50);
42159
42614
  if (!content.head) return null;
42160
42615
  const lines = content.head.split("\n");
@@ -42165,7 +42620,7 @@ async function extractFileSnippet(file, projectRoot, category) {
42165
42620
  const codeLines = lines.slice(codeStart, codeStart + 30);
42166
42621
  return {
42167
42622
  file: file.path,
42168
- title: `${path54__namespace.basename(file.path)} - ${category}`,
42623
+ title: `${path55__namespace.basename(file.path)} - ${category}`,
42169
42624
  description: getFileDescription(file),
42170
42625
  code: codeLines.join("\n"),
42171
42626
  language: file.language || "javascript",
@@ -42253,7 +42708,7 @@ function extractAPIDocumentation(files) {
42253
42708
  async function extractConfigurationDetails(projectRoot) {
42254
42709
  const details = [];
42255
42710
  try {
42256
- const pkgPath = path54__namespace.join(projectRoot, "package.json");
42711
+ const pkgPath = path55__namespace.join(projectRoot, "package.json");
42257
42712
  const pkgContent = await fsp__namespace.readFile(pkgPath, "utf8");
42258
42713
  const pkg = JSON.parse(pkgContent);
42259
42714
  if (pkg.engines) {
@@ -42286,7 +42741,7 @@ async function extractConfigurationDetails(projectRoot) {
42286
42741
  } catch {
42287
42742
  }
42288
42743
  try {
42289
- const tsconfigPath = path54__namespace.join(projectRoot, "tsconfig.json");
42744
+ const tsconfigPath = path55__namespace.join(projectRoot, "tsconfig.json");
42290
42745
  const tsconfigContent = await fsp__namespace.readFile(tsconfigPath, "utf8");
42291
42746
  const tsconfig = JSON.parse(tsconfigContent);
42292
42747
  if (tsconfig.compilerOptions?.strict !== void 0) {
@@ -42310,7 +42765,7 @@ async function extractConfigurationDetails(projectRoot) {
42310
42765
  } catch {
42311
42766
  }
42312
42767
  try {
42313
- const envExamplePath = path54__namespace.join(projectRoot, ".env.example");
42768
+ const envExamplePath = path55__namespace.join(projectRoot, ".env.example");
42314
42769
  const envContent = await fsp__namespace.readFile(envExamplePath, "utf8");
42315
42770
  const envVars = envContent.match(/^[A-Z_]+=/gm);
42316
42771
  if (envVars) {
@@ -43248,7 +43703,7 @@ function generateFooter3(data) {
43248
43703
  }
43249
43704
  function generateFallbackMariaMd(error2, projectPath) {
43250
43705
  const data = {
43251
- projectName: path54__namespace.basename(projectPath),
43706
+ projectName: path55__namespace.basename(projectPath),
43252
43707
  projectPath,
43253
43708
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
43254
43709
  errors: [error2.message]
@@ -43263,13 +43718,13 @@ var init_maria_template = __esm({
43263
43718
  });
43264
43719
  async function writeAtomic(filePath, content, options = {}) {
43265
43720
  const { encoding = "utf8", mode = 420, fsync = true, tmpDir } = options;
43266
- const dir = path54__namespace.dirname(filePath);
43267
- const basename15 = path54__namespace.basename(filePath);
43721
+ const dir = path55__namespace.dirname(filePath);
43722
+ const basename15 = path55__namespace.basename(filePath);
43268
43723
  const tmpSuffix = `.tmp-${Date.now()}-${crypto4.randomBytes(4).toString("hex")}`;
43269
- const tmpPath = tmpDir ? path54__namespace.join(tmpDir, `${basename15}${tmpSuffix}`) : path54__namespace.join(dir, `${basename15}${tmpSuffix}`);
43724
+ const tmpPath = tmpDir ? path55__namespace.join(tmpDir, `${basename15}${tmpSuffix}`) : path55__namespace.join(dir, `${basename15}${tmpSuffix}`);
43270
43725
  let fileHandle = null;
43271
43726
  try {
43272
- await fsp__namespace.mkdir(path54__namespace.dirname(tmpPath), { recursive: true });
43727
+ await fsp__namespace.mkdir(path55__namespace.dirname(tmpPath), { recursive: true });
43273
43728
  if (Buffer.isBuffer(content)) {
43274
43729
  await fsp__namespace.writeFile(tmpPath, content, { mode });
43275
43730
  } else {
@@ -46570,13 +47025,13 @@ var init_initialization_manager = __esm({
46570
47025
  if (!stats.isDirectory()) {
46571
47026
  this.errors.push(`Working directory is not a directory: ${cwd2}`);
46572
47027
  }
46573
- const packagePath = path54__namespace.join(cwd2, "package.json");
47028
+ const packagePath = path55__namespace.join(cwd2, "package.json");
46574
47029
  try {
46575
47030
  await fsp__namespace.access(packagePath);
46576
47031
  } catch {
46577
47032
  this.warnings.push("No package.json found in working directory");
46578
47033
  }
46579
- const gitPath = path54__namespace.join(cwd2, ".git");
47034
+ const gitPath = path55__namespace.join(cwd2, ".git");
46580
47035
  try {
46581
47036
  await fsp__namespace.access(gitPath);
46582
47037
  } catch {
@@ -46628,7 +47083,7 @@ var init_initialization_manager = __esm({
46628
47083
  }
46629
47084
  async validateMonorepoConfig(cwd2) {
46630
47085
  try {
46631
- const packagePath = path54__namespace.join(cwd2, "package.json");
47086
+ const packagePath = path55__namespace.join(cwd2, "package.json");
46632
47087
  const content = await fsp__namespace.readFile(packagePath, "utf-8");
46633
47088
  const pkg = JSON.parse(content);
46634
47089
  if (pkg.workspaces) {
@@ -47018,7 +47473,7 @@ var init_initialization_manager = __esm({
47018
47473
  async generateEnhancedMariaMd(summary, opts) {
47019
47474
  try {
47020
47475
  return generateMariaMd2({
47021
- projectName: summary.projectName || path54__namespace.basename(opts.cwd || process.cwd()),
47476
+ projectName: summary.projectName || path55__namespace.basename(opts.cwd || process.cwd()),
47022
47477
  projectPath: opts.cwd || process.cwd(),
47023
47478
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
47024
47479
  summary,
@@ -47039,7 +47494,7 @@ var init_initialization_manager = __esm({
47039
47494
  const cwd2 = opts.cwd || process.cwd();
47040
47495
  for (const [filename, content] of Object.entries(artifacts)) {
47041
47496
  if (typeof content === "string") {
47042
- const filePath = path54__namespace.join(cwd2, filename);
47497
+ const filePath = path55__namespace.join(cwd2, filename);
47043
47498
  try {
47044
47499
  await writeAtomic(filePath, content);
47045
47500
  this.progressTracker.addMetric(
@@ -47064,7 +47519,7 @@ var init_initialization_manager = __esm({
47064
47519
  */
47065
47520
  async verifyOutput(opts) {
47066
47521
  const cwd2 = opts.cwd || process.cwd();
47067
- const mariaMdPath = path54__namespace.join(cwd2, "MARIA.md");
47522
+ const mariaMdPath = path55__namespace.join(cwd2, "MARIA.md");
47068
47523
  try {
47069
47524
  const content = await fsp__namespace.readFile(mariaMdPath, "utf-8");
47070
47525
  const minLength = 2e3;
@@ -47097,7 +47552,7 @@ var init_initialization_manager = __esm({
47097
47552
  createMinimalSummary(opts) {
47098
47553
  const cwd2 = opts.cwd || process.cwd();
47099
47554
  return {
47100
- projectName: path54__namespace.basename(cwd2),
47555
+ projectName: path55__namespace.basename(cwd2),
47101
47556
  projectPath: cwd2,
47102
47557
  description: "Project analysis incomplete due to errors",
47103
47558
  techStack: {
@@ -47132,7 +47587,7 @@ var init_initialization_manager = __esm({
47132
47587
  */
47133
47588
  async generateFallbackArtifacts(error2, opts) {
47134
47589
  const cwd2 = opts.cwd || process.cwd();
47135
- path54__namespace.basename(cwd2);
47590
+ path55__namespace.basename(cwd2);
47136
47591
  const mariaMd = generateFallbackMariaMd({
47137
47592
  });
47138
47593
  const initReport = `# Init Report - Error Recovery Mode
@@ -47189,7 +47644,7 @@ async function safeBackup(_filePath) {
47189
47644
  await fsp__namespace.copyFile(_filePath, bakPath);
47190
47645
  if (!process.env.MARIA_INIT_QUIET) {
47191
47646
  console.log(
47192
- chalk37__default.default.gray(` \u21B3 backup: ${path54__namespace.relative(process.cwd(), bakPath)}`)
47647
+ chalk37__default.default.gray(` \u21B3 backup: ${path55__namespace.relative(process.cwd(), bakPath)}`)
47193
47648
  );
47194
47649
  }
47195
47650
  } catch {
@@ -47227,7 +47682,7 @@ async function writeArtifacts(artifacts, opts, cwd2, reporter) {
47227
47682
  { name: "INIT_SUMMARY.txt", content: artifacts.initSummaryTxt }
47228
47683
  ];
47229
47684
  for (const { name: name2, content } of files) {
47230
- const _filePath = path54__namespace.join(cwd2, name2);
47685
+ const _filePath = path55__namespace.join(cwd2, name2);
47231
47686
  if (await fileExists2(_filePath) && !opts.force) {
47232
47687
  await safeBackup(_filePath);
47233
47688
  }
@@ -47337,7 +47792,7 @@ This process will:
47337
47792
  );
47338
47793
  const artifacts = generateArtifacts(summary, findings, startTime);
47339
47794
  const mariaMdContent = generateMariaMd2({
47340
- projectName: summary.projectName || path54__namespace.basename(cwd2),
47795
+ projectName: summary.projectName || path55__namespace.basename(cwd2),
47341
47796
  projectPath: cwd2,
47342
47797
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
47343
47798
  summary,
@@ -47497,7 +47952,7 @@ var init_delta_detector = __esm({
47497
47952
  const changes = stdout2.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => {
47498
47953
  const [status, ...rest] = line.split(/\s+/);
47499
47954
  const file = rest.join(" ");
47500
- return { status, file: path54__namespace.resolve(root, file) };
47955
+ return { status, file: path55__namespace.resolve(root, file) };
47501
47956
  });
47502
47957
  const filtered = await this.filterFiles(
47503
47958
  changes.map((c) => c.file),
@@ -47506,8 +47961,8 @@ var init_delta_detector = __esm({
47506
47961
  );
47507
47962
  const filteredSet = new Set(filtered);
47508
47963
  const filteredChanges = changes.filter((c) => filteredSet.has(c.file));
47509
- const deleted = filteredChanges.filter((c) => c.status === "D").map((c) => path54__namespace.relative(root, c.file));
47510
- const changed = filteredChanges.filter((c) => c.status !== "D").map((c) => path54__namespace.relative(root, c.file));
47964
+ const deleted = filteredChanges.filter((c) => c.status === "D").map((c) => path55__namespace.relative(root, c.file));
47965
+ const changed = filteredChanges.filter((c) => c.status !== "D").map((c) => path55__namespace.relative(root, c.file));
47511
47966
  return {
47512
47967
  mode: "git",
47513
47968
  ref,
@@ -47539,7 +47994,7 @@ var init_delta_detector = __esm({
47539
47994
  break;
47540
47995
  }
47541
47996
  if (entry.mtime && entry.mtime > since) {
47542
- changed.push(path54__namespace.relative(root, entry.file));
47997
+ changed.push(path55__namespace.relative(root, entry.file));
47543
47998
  }
47544
47999
  if (options.maxFiles && changed.length >= options.maxFiles) {
47545
48000
  break;
@@ -47563,7 +48018,7 @@ var init_delta_detector = __esm({
47563
48018
  * Detect changes by comparing with state.json
47564
48019
  */
47565
48020
  async detectByState(root, options) {
47566
- const statePath = path54__namespace.join(root, ".maria", "state.json");
48021
+ const statePath = path55__namespace.join(root, ".maria", "state.json");
47567
48022
  let lastHashes = {};
47568
48023
  try {
47569
48024
  const stateContent = await fsp__namespace.readFile(statePath, "utf-8");
@@ -47579,7 +48034,7 @@ var init_delta_detector = __esm({
47579
48034
  if (options.budgetMs && Date.now() - this.startTime > options.budgetMs) {
47580
48035
  break;
47581
48036
  }
47582
- const relativePath = path54__namespace.relative(root, entry.file);
48037
+ const relativePath = path55__namespace.relative(root, entry.file);
47583
48038
  const hash = entry.hash || await this.hashFile(entry.file);
47584
48039
  nowHashes[relativePath] = hash;
47585
48040
  if (!lastHashes[relativePath] || lastHashes[relativePath] !== hash) {
@@ -47659,7 +48114,7 @@ var init_delta_detector = __esm({
47659
48114
  }
47660
48115
  const patterns = options.include || ["**/*"];
47661
48116
  const ignore = options.exclude || [];
47662
- const relativePaths = files.map((f3) => path54__namespace.relative(root, f3));
48117
+ const relativePaths = files.map((f3) => path55__namespace.relative(root, f3));
47663
48118
  const globby = await loadGlobby();
47664
48119
  const matched = await globby(patterns, {
47665
48120
  cwd: root,
@@ -47684,8 +48139,8 @@ var init_delta_detector = __esm({
47684
48139
  * Update state.json with new hashes
47685
48140
  */
47686
48141
  async updateState(root, delta) {
47687
- const statePath = path54__namespace.join(root, ".maria", "state.json");
47688
- await fsp__namespace.mkdir(path54__namespace.dirname(statePath), { recursive: true });
48142
+ const statePath = path55__namespace.join(root, ".maria", "state.json");
48143
+ await fsp__namespace.mkdir(path55__namespace.dirname(statePath), { recursive: true });
47689
48144
  let state;
47690
48145
  try {
47691
48146
  const content = await fsp__namespace.readFile(statePath, "utf-8");
@@ -47710,7 +48165,7 @@ var init_delta_detector = __esm({
47710
48165
  delete currentHashes[file];
47711
48166
  });
47712
48167
  for (const file of delta.changed) {
47713
- const fullPath = path54__namespace.join(root, file);
48168
+ const fullPath = path55__namespace.join(root, file);
47714
48169
  try {
47715
48170
  const hash = await this.hashFile(fullPath);
47716
48171
  if (hash) {
@@ -48644,8 +49099,8 @@ var init_init_command = __esm({
48644
49099
  async execute(options = {}) {
48645
49100
  const startTime = Date.now();
48646
49101
  const root = options.root || process.cwd();
48647
- const stateDir = path54__namespace.join(root, ".maria");
48648
- const statePath = path54__namespace.join(stateDir, "state.json");
49102
+ const stateDir = path55__namespace.join(root, ".maria");
49103
+ const statePath = path55__namespace.join(stateDir, "state.json");
48649
49104
  this.logger.header("MARIA /init - Enhanced Codebase Analysis");
48650
49105
  const hasExistingState = await this.fileExists(statePath);
48651
49106
  if (hasExistingState && !options.force) {
@@ -48770,7 +49225,7 @@ var init_init_command = __esm({
48770
49225
  nodes.push({
48771
49226
  id: file._path,
48772
49227
  type: "file",
48773
- name: path54__namespace.basename(file._path),
49228
+ name: path55__namespace.basename(file._path),
48774
49229
  language: file.language,
48775
49230
  size: file.size,
48776
49231
  complexity: file.complexity
@@ -48875,7 +49330,7 @@ ${file.summary || ""}`,
48875
49330
  async generateArtifacts(root, scanResult, graphResult) {
48876
49331
  this.logger.start("artifacts", "Generating artifacts...");
48877
49332
  const mariaMd = this.generateMariaMd(scanResult, graphResult);
48878
- const mariaMdPath = path54__namespace.join(root, "MARIA.md");
49333
+ const mariaMdPath = path55__namespace.join(root, "MARIA.md");
48879
49334
  await fsp__namespace.writeFile(mariaMdPath, mariaMd, "utf-8");
48880
49335
  const depMapJson = {
48881
49336
  version: "3.2.2",
@@ -48892,7 +49347,7 @@ ${file.summary || ""}`,
48892
49347
  edges: graphResult.edgesCreated
48893
49348
  }
48894
49349
  };
48895
- const depMapPath = path54__namespace.join(root, "DEPENDENCY_MAP.json");
49350
+ const depMapPath = path55__namespace.join(root, "DEPENDENCY_MAP.json");
48896
49351
  await fsp__namespace.writeFile(
48897
49352
  depMapPath,
48898
49353
  JSON.stringify(depMapJson, null, 2),
@@ -49073,7 +49528,7 @@ Last updated: ${(/* @__PURE__ */ new Date()).toISOString()}
49073
49528
  }
49074
49529
  async saveState(stateDir, state) {
49075
49530
  await fsp__namespace.mkdir(stateDir, { recursive: true });
49076
- const statePath = path54__namespace.join(stateDir, "state.json");
49531
+ const statePath = path55__namespace.join(stateDir, "state.json");
49077
49532
  await fsp__namespace.writeFile(statePath, JSON.stringify(state, null, 2), "utf-8");
49078
49533
  }
49079
49534
  async fileExists(_path) {
@@ -49177,8 +49632,8 @@ var init_GraphEngine = __esm({
49177
49632
  this.nameIndex.get(lname).add(node.id);
49178
49633
  const p = (node.path || node._path || "") + "";
49179
49634
  if (p) this.pathIndex.set(p, node.id);
49180
- const tokens = this.tokenize(`${lname} ${p.toLowerCase()}`);
49181
- for (const tok of tokens) {
49635
+ const tokens2 = this.tokenize(`${lname} ${p.toLowerCase()}`);
49636
+ for (const tok of tokens2) {
49182
49637
  if (!this.tokenIndex.has(tok)) this.tokenIndex.set(tok, /* @__PURE__ */ new Set());
49183
49638
  this.tokenIndex.get(tok).add(node.id);
49184
49639
  this.tokenTrie.insert(tok, node.id);
@@ -49218,8 +49673,8 @@ var init_GraphEngine = __esm({
49218
49673
  }
49219
49674
  const p = (node.path || node._path || "") + "";
49220
49675
  if (p) this.pathIndex.delete(p);
49221
- const tokens = this.tokenize(`${(node.name || "").toLowerCase()} ${p.toLowerCase()}`);
49222
- for (const tok of tokens) {
49676
+ const tokens2 = this.tokenize(`${(node.name || "").toLowerCase()} ${p.toLowerCase()}`);
49677
+ for (const tok of tokens2) {
49223
49678
  const set2 = this.tokenIndex.get(tok);
49224
49679
  if (set2) {
49225
49680
  set2.delete(id);
@@ -49301,17 +49756,17 @@ var init_GraphEngine = __esm({
49301
49756
  const visited = /* @__PURE__ */ new Set();
49302
49757
  const queue = [{ id: from, path: [from] }];
49303
49758
  while (queue.length) {
49304
- const { id, path: path55 } = queue.shift();
49759
+ const { id, path: path56 } = queue.shift();
49305
49760
  if (visited.has(id)) continue;
49306
49761
  visited.add(id);
49307
49762
  const neighbors = this.edges.get(id) || /* @__PURE__ */ new Set();
49308
49763
  for (const e2 of neighbors) {
49309
49764
  if (e2.to === to) {
49310
- const res = [...path55, to];
49765
+ const res = [...path56, to];
49311
49766
  this.recordQueryTime(Date.now() - start);
49312
49767
  return res;
49313
49768
  }
49314
- if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...path55, e2.to] });
49769
+ if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...path56, e2.to] });
49315
49770
  }
49316
49771
  }
49317
49772
  this.recordQueryTime(Date.now() - start);
@@ -49498,8 +49953,8 @@ var init_GraphStore = __esm({
49498
49953
  accessCounter = 0;
49499
49954
  constructor(_maxNodes = 1e4) {
49500
49955
  this._maxNodes = _maxNodes;
49501
- this.storageDir = path54__namespace.default.join(process.cwd(), ".maria", "graph");
49502
- this.graphFile = path54__namespace.default.join(this.storageDir, "knowledge-graph.json");
49956
+ this.storageDir = path55__namespace.default.join(process.cwd(), ".maria", "graph");
49957
+ this.graphFile = path55__namespace.default.join(this.storageDir, "knowledge-graph.json");
49503
49958
  this.startPeriodicSave();
49504
49959
  }
49505
49960
  /**
@@ -50023,8 +50478,8 @@ var init_DependencyAnalyzer = __esm({
50023
50478
  */
50024
50479
  resolveImportPath(_importSource, fromFile2, rootDir) {
50025
50480
  if (_importSource.startsWith("./") || _importSource.startsWith("../")) {
50026
- const _fromDir = path54__namespace.default.dirname(fromFile2);
50027
- const _resolved = path54__namespace.default.resolve(_fromDir, _importSource);
50481
+ const _fromDir = path55__namespace.default.dirname(fromFile2);
50482
+ const _resolved = path55__namespace.default.resolve(_fromDir, _importSource);
50028
50483
  for (const _ext of this.SUPPORTED_EXTENSIONS) {
50029
50484
  if (_resolved.endsWith(_ext)) {
50030
50485
  return _resolved;
@@ -50034,7 +50489,7 @@ var init_DependencyAnalyzer = __esm({
50034
50489
  __require.resolve(_withExt);
50035
50490
  return _withExt;
50036
50491
  } catch {
50037
- const _indexFile = path54__namespace.default.join(_resolved, `index${_ext}`);
50492
+ const _indexFile = path55__namespace.default.join(_resolved, `index${_ext}`);
50038
50493
  try {
50039
50494
  __require.resolve(_indexFile);
50040
50495
  return _indexFile;
@@ -50046,7 +50501,7 @@ var init_DependencyAnalyzer = __esm({
50046
50501
  return _resolved;
50047
50502
  }
50048
50503
  if (!_importSource.startsWith("@") && !_importSource.includes("node_modules")) {
50049
- const _resolved = path54__namespace.default.resolve(rootDir, _importSource);
50504
+ const _resolved = path55__namespace.default.resolve(rootDir, _importSource);
50050
50505
  for (const _ext of this.SUPPORTED_EXTENSIONS) {
50051
50506
  const _withExt = _resolved + _ext;
50052
50507
  try {
@@ -50069,7 +50524,7 @@ var init_DependencyAnalyzer = __esm({
50069
50524
  try {
50070
50525
  const _entries = await fsp__namespace.default.readdir(dir, { withFileTypes: true });
50071
50526
  for (const entry of _entries) {
50072
- const _fullPath = path54__namespace.default.join(dir, entry.name);
50527
+ const _fullPath = path55__namespace.default.join(dir, entry.name);
50073
50528
  if (entry.isDirectory()) {
50074
50529
  if (!["node_modules", ".git", "dist", "build", ".next"].includes(
50075
50530
  entry.name
@@ -50077,7 +50532,7 @@ var init_DependencyAnalyzer = __esm({
50077
50532
  await traverse(_fullPath);
50078
50533
  }
50079
50534
  } else if (entry.isFile()) {
50080
- const _ext = path54__namespace.default.extname(entry.name);
50535
+ const _ext = path55__namespace.default.extname(entry.name);
50081
50536
  if ([".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(_ext)) {
50082
50537
  files.push(_fullPath);
50083
50538
  }
@@ -50233,7 +50688,7 @@ var init_DependencyAnalyzer = __esm({
50233
50688
  return {
50234
50689
  id: this.generateNodeId(_filePath),
50235
50690
  type: "file",
50236
- name: path54__namespace.default.basename(_filePath),
50691
+ name: path55__namespace.default.basename(_filePath),
50237
50692
  _path: _filePath,
50238
50693
  metadata: {
50239
50694
  size: _stats.size,
@@ -50273,7 +50728,7 @@ var init_DependencyAnalyzer = __esm({
50273
50728
  }
50274
50729
  }
50275
50730
  detectLanguage(_filePath) {
50276
- const _ext = path54__namespace.default.extname(_filePath);
50731
+ const _ext = path55__namespace.default.extname(_filePath);
50277
50732
  switch (_ext) {
50278
50733
  case ".ts":
50279
50734
  case ".tsx":
@@ -51071,7 +51526,7 @@ var init_KnowledgeGraphService = __esm({
51071
51526
  _filePath,
51072
51527
  depth
51073
51528
  );
51074
- const _fileName2 = path54__namespace.default.basename(_filePath);
51529
+ const _fileName2 = path55__namespace.default.basename(_filePath);
51075
51530
  const _relatedNodes = this.graphEngine.searchNodes(_fileName2);
51076
51531
  const suggestions = [];
51077
51532
  for (const node of _graphContext.nodes.slice(0, 5)) {
@@ -51385,8 +51840,8 @@ async function legacyInit(args2) {
51385
51840
  const cliCwd = process.cwd();
51386
51841
  console.log(chalk37__default.default.blue("\u{1F680} Initializing MARIA configuration..."));
51387
51842
  const options = parseInitOptions(args2);
51388
- const repoRoot = path54__namespace.resolve(options.root || await findRepoRoot(cliCwd));
51389
- const tomlPath = path54__namespace.join(repoRoot, ".maria-code.toml");
51843
+ const repoRoot = path55__namespace.resolve(options.root || await findRepoRoot(cliCwd));
51844
+ const tomlPath = path55__namespace.join(repoRoot, ".maria-code.toml");
51390
51845
  const existingConfig = await fileExists3(tomlPath);
51391
51846
  if (existingConfig && !args2.includes("--force")) {
51392
51847
  const result = await prompts__default.default({
@@ -51400,7 +51855,7 @@ async function legacyInit(args2) {
51400
51855
  return "exit";
51401
51856
  }
51402
51857
  await safeBackup2(tomlPath);
51403
- const mdPath2 = path54__namespace.join(repoRoot, "MARIA.md");
51858
+ const mdPath2 = path55__namespace.join(repoRoot, "MARIA.md");
51404
51859
  if (await fileExists3(mdPath2)) {
51405
51860
  await safeBackup2(mdPath2);
51406
51861
  }
@@ -51414,35 +51869,35 @@ async function legacyInit(args2) {
51414
51869
  const tomlContent = generateTomlConfig(projectConfig);
51415
51870
  try {
51416
51871
  const tomlStatus = await safeWriteIfChanged(tomlPath, tomlContent);
51417
- const rel = path54__namespace.relative(cliCwd, tomlPath);
51872
+ const rel = path55__namespace.relative(cliCwd, tomlPath);
51418
51873
  if (tomlStatus.status === "up-to-date") {
51419
51874
  console.log(chalk37__default.default.gray(`\u2139\uFE0F Up-to-date: ${rel}`));
51420
51875
  } else if (tomlStatus.status === "created") {
51421
51876
  console.log(chalk37__default.default.green(`\u2705 Created: ${rel}`));
51422
51877
  } else if (tomlStatus.status === "updated") {
51423
- console.log(chalk37__default.default.green(`\u2705 Updated: ${rel}`) + (tomlStatus.backup ? chalk37__default.default.gray(` (backup: ${path54__namespace.relative(cliCwd, tomlStatus.backup)})`) : ""));
51878
+ console.log(chalk37__default.default.green(`\u2705 Updated: ${rel}`) + (tomlStatus.backup ? chalk37__default.default.gray(` (backup: ${path55__namespace.relative(cliCwd, tomlStatus.backup)})`) : ""));
51424
51879
  }
51425
51880
  } catch (e2) {
51426
51881
  console.error(chalk37__default.default.red("\u274C Failed to write .maria-code.toml:"), adviceFromFsError(e2));
51427
51882
  }
51428
- const mdPath = path54__namespace.join(repoRoot, "MARIA.md");
51883
+ const mdPath = path55__namespace.join(repoRoot, "MARIA.md");
51429
51884
  const lang = resolveLang(options.lang);
51430
51885
  const mdContent = generateMariaMd3(projectConfig, lang);
51431
51886
  try {
51432
51887
  const mdStatus = await safeWriteIfChanged(mdPath, mdContent);
51433
- const rel = path54__namespace.relative(cliCwd, mdPath);
51888
+ const rel = path55__namespace.relative(cliCwd, mdPath);
51434
51889
  if (mdStatus.status === "up-to-date") {
51435
51890
  console.log(chalk37__default.default.gray(`Saved: ${rel} (up-to-date)`));
51436
51891
  } else if (mdStatus.status === "created") {
51437
51892
  console.log(chalk37__default.default.green(`Saved: ${rel} (created)`));
51438
51893
  } else if (mdStatus.status === "updated") {
51439
- const bakRel = mdStatus.backup ? path54__namespace.relative(cliCwd, mdStatus.backup) : void 0;
51894
+ const bakRel = mdStatus.backup ? path55__namespace.relative(cliCwd, mdStatus.backup) : void 0;
51440
51895
  console.log(chalk37__default.default.green(`Saved: ${rel} (updated${bakRel ? `, backup: ${bakRel}` : ""})`));
51441
51896
  }
51442
51897
  } catch (e2) {
51443
51898
  console.error(chalk37__default.default.red("\u274C Failed to write MARIA.md:"), adviceFromFsError(e2));
51444
51899
  }
51445
- if (projectConfig.gitInit && !await fileExists3(path54__namespace.join(repoRoot, ".git"))) {
51900
+ if (projectConfig.gitInit && !await fileExists3(path55__namespace.join(repoRoot, ".git"))) {
51446
51901
  try {
51447
51902
  const { execSync } = await import('child_process');
51448
51903
  execSync("git init", { cwd: repoRoot, stdio: "pipe" });
@@ -51476,13 +51931,13 @@ async function safeBackup2(_filePath) {
51476
51931
  const bakPath = `${_filePath}.bak.${stamp}`;
51477
51932
  await fsp__namespace.copyFile(_filePath, bakPath);
51478
51933
  console.log(
51479
- chalk37__default.default.gray(` \u21B3 backup: ${path54__namespace.relative(process.cwd(), bakPath)}`)
51934
+ chalk37__default.default.gray(` \u21B3 backup: ${path55__namespace.relative(process.cwd(), bakPath)}`)
51480
51935
  );
51481
51936
  } catch {
51482
51937
  }
51483
51938
  }
51484
51939
  async function interactiveSetup() {
51485
- const packageJsonPath = path54__namespace.join(process.cwd(), "package.json");
51940
+ const packageJsonPath = path55__namespace.join(process.cwd(), "package.json");
51486
51941
  let packageJson2 = {};
51487
51942
  try {
51488
51943
  const packageData = await fsp__namespace.readFile(packageJsonPath, "utf-8");
@@ -51494,7 +51949,7 @@ async function interactiveSetup() {
51494
51949
  type: "text",
51495
51950
  name: "name",
51496
51951
  message: "Project name:",
51497
- initial: packageJson2.name || path54__namespace.basename(process.cwd())
51952
+ initial: packageJson2.name || path55__namespace.basename(process.cwd())
51498
51953
  },
51499
51954
  {
51500
51955
  type: "select",
@@ -51538,7 +51993,7 @@ async function interactiveSetup() {
51538
51993
  }
51539
51994
  function getDefaultConfig() {
51540
51995
  return {
51541
- name: path54__namespace.basename(process.cwd()),
51996
+ name: path55__namespace.basename(process.cwd()),
51542
51997
  type: "auto",
51543
51998
  description: "AI-powered development project using MARIA",
51544
51999
  author: "",
@@ -51719,13 +52174,13 @@ function resolveLang(input3) {
51719
52174
  return "en";
51720
52175
  }
51721
52176
  async function findRepoRoot(startDir) {
51722
- let dir = path54__namespace.resolve(startDir);
52177
+ let dir = path55__namespace.resolve(startDir);
51723
52178
  let lastGitDir = null;
51724
52179
  while (true) {
51725
- const gitPath = path54__namespace.join(dir, ".git");
52180
+ const gitPath = path55__namespace.join(dir, ".git");
51726
52181
  const hasGit = await fileExists3(gitPath);
51727
52182
  if (hasGit) lastGitDir = dir;
51728
- const parent = path54__namespace.dirname(dir);
52183
+ const parent = path55__namespace.dirname(dir);
51729
52184
  if (parent === dir) break;
51730
52185
  dir = parent;
51731
52186
  }
@@ -51807,8 +52262,8 @@ var init_update_command = __esm({
51807
52262
  async execute(options = {}) {
51808
52263
  const startTime = Date.now();
51809
52264
  const root = options.root || process.cwd();
51810
- const stateDir = path54__namespace.join(root, ".maria");
51811
- const statePath = path54__namespace.join(stateDir, "state.json");
52265
+ const stateDir = path55__namespace.join(root, ".maria");
52266
+ const statePath = path55__namespace.join(stateDir, "state.json");
51812
52267
  this.reporter.thinking(`Performing incremental update to detect and process changes.
51813
52268
  This will:
51814
52269
  - Detect file changes since last update
@@ -51978,12 +52433,12 @@ This will:
51978
52433
  };
51979
52434
  const result = await this.deltaDetector.detectDelta(root, deltaOptions);
51980
52435
  const files = [
51981
- ...result.changed.map((path55) => ({
51982
- _path: path55,
51983
- type: previousState?.fileHashes?.[path55] ? "modified" : "added"
52436
+ ...result.changed.map((path56) => ({
52437
+ _path: path56,
52438
+ type: previousState?.fileHashes?.[path56] ? "modified" : "added"
51984
52439
  })),
51985
- ...result.deleted.map((path55) => ({
51986
- _path: path55,
52440
+ ...result.deleted.map((path56) => ({
52441
+ _path: path56,
51987
52442
  type: "deleted"
51988
52443
  }))
51989
52444
  ];
@@ -52100,7 +52555,7 @@ This will:
52100
52555
  nodeUpdates.push({
52101
52556
  id: file._path,
52102
52557
  type: "file",
52103
- name: path54__namespace.basename(file._path),
52558
+ name: path55__namespace.basename(file._path),
52104
52559
  language: file.language,
52105
52560
  size: file.size,
52106
52561
  complexity: file.complexity,
@@ -52200,7 +52655,7 @@ ${file.summary || ""}`,
52200
52655
  */
52201
52656
  async updateArtifacts(root, deltaResult, processResult) {
52202
52657
  this.logger.start("artifacts", "Updating artifacts...");
52203
- const mariaMdPath = path54__namespace.join(root, "MARIA.md");
52658
+ const mariaMdPath = path55__namespace.join(root, "MARIA.md");
52204
52659
  let existingContent = "";
52205
52660
  try {
52206
52661
  existingContent = await fsp__namespace.readFile(mariaMdPath, "utf-8");
@@ -52214,7 +52669,7 @@ ${file.summary || ""}`,
52214
52669
  );
52215
52670
  await fsp__namespace.writeFile(mariaMdPath, updatedMariaMd, "utf-8");
52216
52671
  this.reporter.write("MARIA.md", updatedMariaMd.length);
52217
- const depMapPath = path54__namespace.join(root, "DEPENDENCY_MAP.json");
52672
+ const depMapPath = path55__namespace.join(root, "DEPENDENCY_MAP.json");
52218
52673
  try {
52219
52674
  const existingDepMap = JSON.parse(await fsp__namespace.readFile(depMapPath, "utf-8"));
52220
52675
  this.reporter.read(
@@ -52333,7 +52788,7 @@ ${delta.modified > 5 ? `... and ${delta.modified - 5} more` : ""}
52333
52788
  }
52334
52789
  }
52335
52790
  async saveState(statePath, state) {
52336
- const dir = path54__namespace.dirname(statePath);
52791
+ const dir = path55__namespace.dirname(statePath);
52337
52792
  await fsp__namespace.mkdir(dir, { recursive: true });
52338
52793
  if (state.fileHashes instanceof Map) {
52339
52794
  state.fileHashes = Object.fromEntries(state.fileHashes);
@@ -52776,7 +53231,7 @@ var init_ResearchCommand = __esm({
52776
53231
  constructor() {
52777
53232
  super();
52778
53233
  this.contentExtractor = new ContentExtractor();
52779
- this.knowledgeBasePath = path54__namespace.default.join(os13__namespace.default.homedir(), ".maria", "knowledge-base");
53234
+ this.knowledgeBasePath = path55__namespace.default.join(os13__namespace.default.homedir(), ".maria", "knowledge-base");
52780
53235
  }
52781
53236
  async initialize() {
52782
53237
  try {
@@ -53307,7 +53762,7 @@ ${JSON.stringify(_result, null, 2)}
53307
53762
  readingTime: _content.metadata.readingTime
53308
53763
  }
53309
53764
  };
53310
- const _entryPath = path54__namespace.default.join(this.knowledgeBasePath, "entries", `${id}.json`);
53765
+ const _entryPath = path55__namespace.default.join(this.knowledgeBasePath, "entries", `${id}.json`);
53311
53766
  await fsp__namespace.default.writeFile(_entryPath, JSON.stringify(_entry, null, 2));
53312
53767
  await this.updateKnowledgeBaseIndex(_entry);
53313
53768
  logger.info(`Saved to knowledge base: ${id}`);
@@ -53318,7 +53773,7 @@ ${JSON.stringify(_result, null, 2)}
53318
53773
  }
53319
53774
  }
53320
53775
  async updateKnowledgeBaseIndex(_entry) {
53321
- const _indexPath = path54__namespace.default.join(this.knowledgeBasePath, "index.json");
53776
+ const _indexPath = path55__namespace.default.join(this.knowledgeBasePath, "index.json");
53322
53777
  try {
53323
53778
  const _indexContent = await fsp__namespace.default.readFile(_indexPath, "utf-8");
53324
53779
  const _index = JSON.parse(_indexContent);
@@ -53338,7 +53793,7 @@ ${JSON.stringify(_result, null, 2)}
53338
53793
  async ensureKnowledgeBaseDirectory() {
53339
53794
  try {
53340
53795
  await fsp__namespace.default.mkdir(this.knowledgeBasePath, { recursive: true });
53341
- await fsp__namespace.default.mkdir(path54__namespace.default.join(this.knowledgeBasePath, "entries"), { recursive: true });
53796
+ await fsp__namespace.default.mkdir(path55__namespace.default.join(this.knowledgeBasePath, "entries"), { recursive: true });
53342
53797
  } catch (innerError) {
53343
53798
  logger.error("Failed to create knowledge base directory:", error);
53344
53799
  }
@@ -53406,7 +53861,7 @@ ${JSON.stringify(_result, null, 2)}
53406
53861
  `;
53407
53862
  }
53408
53863
  try {
53409
- const _indexPath = path54__namespace.default.join(this.knowledgeBasePath, "index.json");
53864
+ const _indexPath = path55__namespace.default.join(this.knowledgeBasePath, "index.json");
53410
53865
  const _indexContent = await fsp__namespace.default.readFile(_indexPath, "utf-8");
53411
53866
  const _index = JSON.parse(_indexContent);
53412
53867
  message += `**Knowledge Base**: \u2705 Available
@@ -55680,13 +56135,13 @@ async function checkShield(commandName, userPlan = "free") {
55680
56135
  }
55681
56136
  async function loadManifest() {
55682
56137
  try {
55683
- const fs45 = await import('fs');
55684
- const path55 = await import('path');
55685
- const manifestPath = path55.join(
56138
+ const fs46 = await import('fs');
56139
+ const path56 = await import('path');
56140
+ const manifestPath = path56.join(
55686
56141
  __dirname,
55687
56142
  "../command-manifest-v2.1.json"
55688
56143
  );
55689
- const content = fs45.readFileSync(manifestPath, "utf-8");
56144
+ const content = fs46.readFileSync(manifestPath, "utf-8");
55690
56145
  return JSON.parse(content);
55691
56146
  } catch {
55692
56147
  return { commands: [] };
@@ -57370,11 +57825,11 @@ var init_ImageCommand = __esm({
57370
57825
  const height = m2 ? parseInt(m2[2], 10) : 1024;
57371
57826
  const format = String(options.format || "png");
57372
57827
  const res = await provider.generateImage({ prompt, width, height, format });
57373
- const path55 = __require("path");
57374
- const fs45 = await import('fs/promises');
57375
- const outPath = path55.join(process.cwd(), "outputs", "images", `image_${Date.now()}.png`);
57376
- await fs45.mkdir(path55.dirname(outPath), { recursive: true });
57377
- await fs45.writeFile(outPath, res.bytes);
57828
+ const path56 = __require("path");
57829
+ const fs46 = await import('fs/promises');
57830
+ const outPath = path56.join(process.cwd(), "outputs", "images", `image_${Date.now()}.png`);
57831
+ await fs46.mkdir(path56.dirname(outPath), { recursive: true });
57832
+ await fs46.writeFile(outPath, res.bytes);
57378
57833
  return { success: true, output: `OK: Saved image \u2192 ${outPath}` };
57379
57834
  } catch (e2) {
57380
57835
  return { success: false, output: `ERROR: Image generation failed. ${e2?.message || e2}` };
@@ -57425,12 +57880,12 @@ var init_VideoCommand = __esm({
57425
57880
  const fps = Math.max(1, parseInt(getVal("fps", "8"), 10) || 8);
57426
57881
  const duration = Math.max(1, parseInt(getVal("duration", "2"), 10) || 2);
57427
57882
  const frames = await provider.generateVideoFrames({ prompt, width: 640, height: 360, fps, duration, format: "mp4" });
57428
- const path55 = __require("path");
57429
- const fs45 = await import('fs/promises');
57430
- const dir = path55.join(process.cwd(), "outputs", "videos", `video_${Date.now()}`);
57431
- await fs45.mkdir(dir, { recursive: true });
57883
+ const path56 = __require("path");
57884
+ const fs46 = await import('fs/promises');
57885
+ const dir = path56.join(process.cwd(), "outputs", "videos", `video_${Date.now()}`);
57886
+ await fs46.mkdir(dir, { recursive: true });
57432
57887
  const framePattern = "frame_%04d.png";
57433
- await Promise.all(frames.frames.map((buf, i2) => fs45.writeFile(path55.join(dir, `frame_${i2.toString().padStart(4, "0")}.png`), buf)));
57888
+ await Promise.all(frames.frames.map((buf, i2) => fs46.writeFile(path56.join(dir, `frame_${i2.toString().padStart(4, "0")}.png`), buf)));
57434
57889
  const wantMerge = has("merge") || has("mp4");
57435
57890
  if (wantMerge && process.env.CI !== "true" && process.env.MARIA_TEST_MODE !== "1") {
57436
57891
  const ok = await this.mergeWithFFmpeg(dir, framePattern, fps).catch(() => false);
@@ -57447,8 +57902,8 @@ var init_VideoCommand = __esm({
57447
57902
  if (!available) return false;
57448
57903
  return new Promise((resolve17) => {
57449
57904
  const { spawn: spawn4 } = __require("child_process");
57450
- const path55 = __require("path");
57451
- const out = path55.join(dir, "video.mp4");
57905
+ const path56 = __require("path");
57906
+ const out = path56.join(dir, "video.mp4");
57452
57907
  const ffmpeg = spawn4("ffmpeg", ["-y", "-framerate", String(fps), "-i", pattern, "-pix_fmt", "yuv420p", out], { cwd: dir, stdio: "ignore" });
57453
57908
  let done = false;
57454
57909
  ffmpeg.on("error", () => {
@@ -58888,14 +59343,14 @@ ${model.description}
58888
59343
  };
58889
59344
  return emojis[provider.toLowerCase()] || "\u{1F52E}";
58890
59345
  }
58891
- formatTokens(tokens) {
58892
- if (tokens >= 1e6) {
58893
- return `${(tokens / 1e6).toFixed(1)}M`;
59346
+ formatTokens(tokens2) {
59347
+ if (tokens2 >= 1e6) {
59348
+ return `${(tokens2 / 1e6).toFixed(1)}M`;
58894
59349
  }
58895
- if (tokens >= 1e3) {
58896
- return `${(tokens / 1e3).toFixed(0)}K`;
59350
+ if (tokens2 >= 1e3) {
59351
+ return `${(tokens2 / 1e3).toFixed(0)}K`;
58897
59352
  }
58898
- return tokens.toString();
59353
+ return tokens2.toString();
58899
59354
  }
58900
59355
  async performModelTest(model) {
58901
59356
  const latency = Math.random() * 1e3 + 100;
@@ -59178,8 +59633,8 @@ var init_ConfigCommand2 = __esm({
59178
59633
  validate: (v) => typeof v === "string"
59179
59634
  }
59180
59635
  };
59181
- globalConfigPath = path54__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config.json");
59182
- localConfigPath = path54__namespace.default.join(process.cwd(), ".maria-config.json");
59636
+ globalConfigPath = path55__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config.json");
59637
+ localConfigPath = path55__namespace.default.join(process.cwd(), ".maria-config.json");
59183
59638
  async execute(_args, context2) {
59184
59639
  try {
59185
59640
  const _startTime = Date.now();
@@ -59565,7 +60020,7 @@ var init_ConfigCommand2 = __esm({
59565
60020
  }
59566
60021
  async saveConfiguration(_config, _scope) {
59567
60022
  const _configPath = _scope === "global" ? this.globalConfigPath : this.localConfigPath;
59568
- await fsp__namespace.default.mkdir(path54__namespace.default.dirname(_configPath), { recursive: true });
60023
+ await fsp__namespace.default.mkdir(path55__namespace.default.dirname(_configPath), { recursive: true });
59569
60024
  await fsp__namespace.default.writeFile(_configPath, JSON.stringify(_config, null, 2), "utf-8");
59570
60025
  this.setCache(`_config:${_scope}`, _config, 300);
59571
60026
  }
@@ -60371,14 +60826,14 @@ var init_NaturalLanguageProcessor = __esm({
60371
60826
  }
60372
60827
  async process(input3, language = "en") {
60373
60828
  const normalized = this.normalize(input3, language);
60374
- const tokens = this.tokenize(normalized, language);
60375
- const stems = this.stem(tokens, language);
60829
+ const tokens2 = this.tokenize(normalized, language);
60830
+ const stems = this.stem(tokens2, language);
60376
60831
  const entities = this.extractEntities(input3);
60377
- const _keywords = this.extractKeywords(tokens, language);
60832
+ const _keywords = this.extractKeywords(tokens2, language);
60378
60833
  return {
60379
60834
  original: input3,
60380
60835
  normalized,
60381
- tokens,
60836
+ tokens: tokens2,
60382
60837
  stems,
60383
60838
  entities,
60384
60839
  language,
@@ -60428,7 +60883,7 @@ var init_NaturalLanguageProcessor = __esm({
60428
60883
  return text.split(/\s+/).filter((token) => token.length > 0);
60429
60884
  }
60430
60885
  tokenizeJapanese(text) {
60431
- const tokens = [];
60886
+ const tokens2 = [];
60432
60887
  const _patterns = [
60433
60888
  /[\u4e00-\u9faf]+/g,
60434
60889
  // Kanji
@@ -60444,24 +60899,24 @@ var init_NaturalLanguageProcessor = __esm({
60444
60899
  _patterns.forEach((pattern) => {
60445
60900
  const _matches = text.match(pattern);
60446
60901
  if (_matches) {
60447
- tokens.push(..._matches);
60902
+ tokens2.push(..._matches);
60448
60903
  }
60449
60904
  });
60450
- return tokens;
60905
+ return tokens2;
60451
60906
  }
60452
60907
  tokenizeChinese(text) {
60453
- const tokens = [];
60908
+ const tokens2 = [];
60454
60909
  for (const char of text) {
60455
60910
  if (/[\u4e00-\u9faf]/.test(char)) {
60456
- tokens.push(char);
60911
+ tokens2.push(char);
60457
60912
  } else if (/[a-zA-Z0-9]+/.test(char)) {
60458
- tokens.push(char);
60913
+ tokens2.push(char);
60459
60914
  }
60460
60915
  }
60461
- return tokens;
60916
+ return tokens2;
60462
60917
  }
60463
60918
  tokenizeKorean(text) {
60464
- const tokens = [];
60919
+ const tokens2 = [];
60465
60920
  const _patterns = [
60466
60921
  /[\uac00-\ud7af]+/g,
60467
60922
  // Hangul
@@ -60473,16 +60928,16 @@ var init_NaturalLanguageProcessor = __esm({
60473
60928
  _patterns.forEach((pattern) => {
60474
60929
  const _matches = text.match(pattern);
60475
60930
  if (_matches) {
60476
- tokens.push(..._matches);
60931
+ tokens2.push(..._matches);
60477
60932
  }
60478
60933
  });
60479
- return tokens;
60934
+ return tokens2;
60480
60935
  }
60481
- stem(tokens, language) {
60936
+ stem(tokens2, language) {
60482
60937
  if (language !== "en") {
60483
- return tokens;
60938
+ return tokens2;
60484
60939
  }
60485
- return tokens.map((token) => {
60940
+ return tokens2.map((token) => {
60486
60941
  let stem = token;
60487
60942
  if (stem.endsWith("ing")) {
60488
60943
  stem = stem.slice(0, -3);
@@ -60578,9 +61033,9 @@ var init_NaturalLanguageProcessor = __esm({
60578
61033
  });
60579
61034
  return entities;
60580
61035
  }
60581
- extractKeywords(tokens, language) {
61036
+ extractKeywords(tokens2, language) {
60582
61037
  const stopWords = this.stopWords.get(language) ?? /* @__PURE__ */ new Set();
60583
- const _keywords = tokens.filter((token) => {
61038
+ const _keywords = tokens2.filter((token) => {
60584
61039
  return token.length > 2 && !stopWords.has(token.toLowerCase());
60585
61040
  });
60586
61041
  const frequency = /* @__PURE__ */ new Map();
@@ -66669,11 +67124,11 @@ var init_ConfigService = __esm({
66669
67124
  _saveDebounceTimer = null;
66670
67125
  _isDirty = false;
66671
67126
  constructor(configDir = process.env.MARIA_CONFIG_DIR || "~/.maria") {
66672
- this._configPath = path54__namespace.join(
67127
+ this._configPath = path55__namespace.join(
66673
67128
  this.expandHome(configDir),
66674
67129
  "session.config.json"
66675
67130
  );
66676
- this._userConfigPath = path54__namespace.join(
67131
+ this._userConfigPath = path55__namespace.join(
66677
67132
  this.expandHome(configDir),
66678
67133
  "user.config.json"
66679
67134
  );
@@ -66748,8 +67203,8 @@ var init_ConfigService = __esm({
66748
67203
  /**
66749
67204
  * ネストされた設定値の取得
66750
67205
  */
66751
- getNestedValue(path55) {
66752
- const keys = path55.split(".");
67206
+ getNestedValue(path56) {
67207
+ const keys = path56.split(".");
66753
67208
  let value = this._config;
66754
67209
  for (const key of keys) {
66755
67210
  if (value && typeof value === "object" && key in value) {
@@ -66779,8 +67234,8 @@ var init_ConfigService = __esm({
66779
67234
  /**
66780
67235
  * ネストされた設定値の更新
66781
67236
  */
66782
- async setNestedValue(path55, value) {
66783
- const keys = path55.split(".");
67237
+ async setNestedValue(path56, value) {
67238
+ const keys = path56.split(".");
66784
67239
  const lastKey = keys.pop();
66785
67240
  let target = this._config;
66786
67241
  for (const key of keys) {
@@ -66793,7 +67248,7 @@ var init_ConfigService = __esm({
66793
67248
  target[lastKey] = value;
66794
67249
  this.validateConfig();
66795
67250
  this.emitChange({
66796
- path: path55,
67251
+ path: path56,
66797
67252
  oldValue,
66798
67253
  newValue: value,
66799
67254
  timestamp: /* @__PURE__ */ new Date()
@@ -66807,7 +67262,7 @@ var init_ConfigService = __esm({
66807
67262
  async save() {
66808
67263
  if (!this._isDirty) return;
66809
67264
  try {
66810
- const configDir = path54__namespace.dirname(this._userConfigPath);
67265
+ const configDir = path55__namespace.dirname(this._userConfigPath);
66811
67266
  await fsp__namespace.mkdir(configDir, { recursive: true });
66812
67267
  await fsp__namespace.writeFile(
66813
67268
  this._userConfigPath,
@@ -66838,8 +67293,8 @@ var init_ConfigService = __esm({
66838
67293
  setupAutoSave() {
66839
67294
  process.on("exit", () => {
66840
67295
  if (this._isDirty) {
66841
- const fs45 = __require("fs");
66842
- fs45.writeFileSync(
67296
+ const fs46 = __require("fs");
67297
+ fs46.writeFileSync(
66843
67298
  this._userConfigPath,
66844
67299
  JSON.stringify(this._config, null, 2),
66845
67300
  "utf-8"
@@ -66850,13 +67305,13 @@ var init_ConfigService = __esm({
66850
67305
  /**
66851
67306
  * 変更リスナーの登録
66852
67307
  */
66853
- onChange(path55, listener) {
66854
- if (!this._listeners.has(path55)) {
66855
- this._listeners.set(path55, []);
67308
+ onChange(path56, listener) {
67309
+ if (!this._listeners.has(path56)) {
67310
+ this._listeners.set(path56, []);
66856
67311
  }
66857
- this._listeners.get(path55).push(listener);
67312
+ this._listeners.get(path56).push(listener);
66858
67313
  return () => {
66859
- const listeners = this._listeners.get(path55);
67314
+ const listeners = this._listeners.get(path56);
66860
67315
  if (listeners) {
66861
67316
  const index = listeners.indexOf(listener);
66862
67317
  if (index !== -1) {
@@ -66907,7 +67362,7 @@ var init_ConfigService = __esm({
66907
67362
  */
66908
67363
  expandHome(filePath) {
66909
67364
  if (filePath.startsWith("~/")) {
66910
- return path54__namespace.join(process.env.HOME || "", filePath.slice(2));
67365
+ return path55__namespace.join(process.env.HOME || "", filePath.slice(2));
66911
67366
  }
66912
67367
  return filePath;
66913
67368
  }
@@ -67345,7 +67800,7 @@ var init_ValidationService = __esm({
67345
67800
  );
67346
67801
  this._schemas.set(
67347
67802
  "filePath",
67348
- zod.z.string().min(1).max(this._config.maxFilePathLength).refine((path55) => !this.containsPathTraversal(path55), {
67803
+ zod.z.string().min(1).max(this._config.maxFilePathLength).refine((path56) => !this.containsPathTraversal(path56), {
67349
67804
  message: "Path traversal detected"
67350
67805
  })
67351
67806
  );
@@ -67484,11 +67939,11 @@ var init_ValidationService = __esm({
67484
67939
  /**
67485
67940
  * ファイルパス検証
67486
67941
  */
67487
- validateFilePath(path55) {
67942
+ validateFilePath(path56) {
67488
67943
  try {
67489
67944
  const schema = this._schemas.get("filePath");
67490
- const result = schema.parse(path55);
67491
- if (this.isSystemPath(path55)) {
67945
+ const result = schema.parse(path56);
67946
+ if (this.isSystemPath(path56)) {
67492
67947
  return {
67493
67948
  valid: false,
67494
67949
  errors: [
@@ -67634,8 +68089,8 @@ var init_ValidationService = __esm({
67634
68089
  /**
67635
68090
  * パストラバーサルの検出
67636
68091
  */
67637
- containsPathTraversal(path55) {
67638
- return /\.\.[/\\]/.test(path55) || path55.includes("..\\") || path55.includes("../");
68092
+ containsPathTraversal(path56) {
68093
+ return /\.\.[/\\]/.test(path56) || path56.includes("..\\") || path56.includes("../");
67639
68094
  }
67640
68095
  /**
67641
68096
  * 危険なコマンドの判定
@@ -67662,7 +68117,7 @@ var init_ValidationService = __esm({
67662
68117
  /**
67663
68118
  * システムパスの判定
67664
68119
  */
67665
- isSystemPath(path55) {
68120
+ isSystemPath(path56) {
67666
68121
  const systemPaths = [
67667
68122
  "/etc",
67668
68123
  "/sys",
@@ -67676,7 +68131,7 @@ var init_ValidationService = __esm({
67676
68131
  "/sbin"
67677
68132
  ];
67678
68133
  return systemPaths.some(
67679
- (sysPath) => path55.toLowerCase().startsWith(sysPath.toLowerCase())
68134
+ (sysPath) => path56.toLowerCase().startsWith(sysPath.toLowerCase())
67680
68135
  );
67681
68136
  }
67682
68137
  /**
@@ -72209,10 +72664,10 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
72209
72664
  const finalize = async (text, data) => {
72210
72665
  if (outputPath) {
72211
72666
  try {
72212
- const fs45 = await import('fs/promises');
72213
- const path55 = await import('path');
72214
- const abs = path55.resolve(outputPath);
72215
- await fs45.writeFile(abs, text, "utf-8");
72667
+ const fs46 = await import('fs/promises');
72668
+ const path56 = await import('path');
72669
+ const abs = path56.resolve(outputPath);
72670
+ await fs46.writeFile(abs, text, "utf-8");
72216
72671
  const msg = `Saved doctor report to ${abs}`;
72217
72672
  return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
72218
72673
  } catch (e2) {
@@ -72302,10 +72757,10 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
72302
72757
  const finalize = async (text, data) => {
72303
72758
  if (outputPath) {
72304
72759
  try {
72305
- const fs45 = await import('fs/promises');
72306
- const path55 = await import('path');
72307
- const abs = path55.resolve(outputPath);
72308
- await fs45.writeFile(abs, text, "utf-8");
72760
+ const fs46 = await import('fs/promises');
72761
+ const path56 = await import('path');
72762
+ const abs = path56.resolve(outputPath);
72763
+ await fs46.writeFile(abs, text, "utf-8");
72309
72764
  const msg = `Saved metrics to ${abs}`;
72310
72765
  return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
72311
72766
  } catch (e2) {
@@ -72688,15 +73143,15 @@ var init_SessionOrchestrator = __esm({
72688
73143
  /**
72689
73144
  * 設定の取得
72690
73145
  */
72691
- getConfig(path55) {
72692
- return this._configService?.getNestedValue(path55);
73146
+ getConfig(path56) {
73147
+ return this._configService?.getNestedValue(path56);
72693
73148
  }
72694
73149
  /**
72695
73150
  * 設定の更新
72696
73151
  */
72697
- async setConfig(path55, value) {
73152
+ async setConfig(path56, value) {
72698
73153
  if (this._configService) {
72699
- await this._configService.setNestedValue(path55, value);
73154
+ await this._configService.setNestedValue(path56, value);
72700
73155
  }
72701
73156
  }
72702
73157
  /**
@@ -72814,11 +73269,11 @@ var init_interactive_session = __esm({
72814
73269
  getStats() {
72815
73270
  return this.orchestrator.getSessionStats();
72816
73271
  }
72817
- getConfig(path55) {
72818
- return this.orchestrator.getConfig(path55);
73272
+ getConfig(path56) {
73273
+ return this.orchestrator.getConfig(path56);
72819
73274
  }
72820
- async setConfig(path55, value) {
72821
- await this.orchestrator.setConfig(path55, value);
73275
+ async setConfig(path56, value) {
73276
+ await this.orchestrator.setConfig(path56, value);
72822
73277
  }
72823
73278
  };
72824
73279
  }
@@ -73196,8 +73651,8 @@ async function enforceAuth(cmd) {
73196
73651
  return true;
73197
73652
  }
73198
73653
  try {
73199
- const tokens = await authManager.getValidTokens();
73200
- if (!tokens) {
73654
+ const tokens2 = await authManager.getValidTokens();
73655
+ if (!tokens2) {
73201
73656
  console.log(chalk37__default.default.red("\u{1F510} Authentication required \xB7 Run: maria /login"));
73202
73657
  return false;
73203
73658
  }
@@ -73996,23 +74451,23 @@ function coerceExtension(ext2, fallback2) {
73996
74451
  return fallback2;
73997
74452
  }
73998
74453
  function safeResolve(root, fname) {
73999
- const abs = path54__namespace.resolve(root, fname);
74000
- const base = path54__namespace.resolve(root);
74001
- if (!(abs + path54__namespace.sep).startsWith(base + path54__namespace.sep) && abs !== base) {
74454
+ const abs = path55__namespace.resolve(root, fname);
74455
+ const base = path55__namespace.resolve(root);
74456
+ if (!(abs + path55__namespace.sep).startsWith(base + path55__namespace.sep) && abs !== base) {
74002
74457
  throw new Error("Path traversal detected");
74003
74458
  }
74004
74459
  return abs;
74005
74460
  }
74006
74461
  async function ensureUniquePath(absPath) {
74007
- const dir = path54__namespace.dirname(absPath);
74008
- const ext2 = path54__namespace.extname(absPath);
74009
- const base = path54__namespace.basename(absPath, ext2);
74462
+ const dir = path55__namespace.dirname(absPath);
74463
+ const ext2 = path55__namespace.extname(absPath);
74464
+ const base = path55__namespace.basename(absPath, ext2);
74010
74465
  let candidate = absPath;
74011
74466
  let i2 = 1;
74012
74467
  while (true) {
74013
74468
  try {
74014
74469
  await fsp__namespace.access(candidate);
74015
- candidate = path54__namespace.join(dir, `${base}(${i2})${ext2}`);
74470
+ candidate = path55__namespace.join(dir, `${base}(${i2})${ext2}`);
74016
74471
  i2++;
74017
74472
  } catch {
74018
74473
  return candidate;
@@ -74091,7 +74546,7 @@ async function handleCodeCommand(prompt) {
74091
74546
  for (const { language, code, extension, filename: suggested } of artifacts) {
74092
74547
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74093
74548
  filename = sanitizeFilenameStrict(filename);
74094
- const ext2 = path54__namespace.extname(filename).slice(1);
74549
+ const ext2 = path55__namespace.extname(filename).slice(1);
74095
74550
  const isBinary2 = isLikelyBinary(code);
74096
74551
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74097
74552
  const finalExt = coerceExtension(ext2, inferred);
@@ -74104,15 +74559,13 @@ async function handleCodeCommand(prompt) {
74104
74559
  files += 1;
74105
74560
  if (progress) clearInterval(progress);
74106
74561
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74107
- console.log(chalk37__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74108
- console.log(chalk37__default.default.gray(`\u{1F4CD} ${filepath}`));
74109
- console.log(chalk37__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74562
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74563
+ console.log(`\u{1F4CD} ${filepath}`);
74110
74564
  const pm = getProviderManager();
74111
74565
  const provider = pm.getLastUsedProvider() || "fallback";
74112
74566
  const model = pm.getLastUsedModel() || "n/a";
74113
74567
  const source = pm.getConfigSource();
74114
- 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 };
74115
- console.log(chalk37__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74568
+ 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 };
74116
74569
  try {
74117
74570
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74118
74571
  } catch {
@@ -74120,7 +74573,6 @@ async function handleCodeCommand(prompt) {
74120
74573
  }
74121
74574
  const pmBatch = getProviderManager();
74122
74575
  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 };
74123
- console.log(chalk37__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74124
74576
  try {
74125
74577
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74126
74578
  } catch {
@@ -74151,7 +74603,7 @@ async function handleCodeCommand(prompt) {
74151
74603
  for (const { language, code, extension, filename: suggested } of artifacts) {
74152
74604
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74153
74605
  filename = sanitizeFilenameStrict(filename);
74154
- const ext2 = path54__namespace.extname(filename).slice(1);
74606
+ const ext2 = path55__namespace.extname(filename).slice(1);
74155
74607
  const isBinary2 = isLikelyBinary(code);
74156
74608
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74157
74609
  const finalExt = coerceExtension(ext2, inferred);
@@ -74164,15 +74616,13 @@ async function handleCodeCommand(prompt) {
74164
74616
  files += 1;
74165
74617
  if (progress) clearInterval(progress);
74166
74618
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74167
- console.log(chalk37__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74168
- console.log(chalk37__default.default.gray(`\u{1F4CD} ${filepath}`));
74169
- console.log(chalk37__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74619
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74620
+ console.log(`\u{1F4CD} ${filepath}`);
74170
74621
  const pm = getProviderManager();
74171
74622
  const provider = pm.getLastUsedProvider() || "unknown";
74172
74623
  const model = pm.getLastUsedModel() || "auto";
74173
74624
  const source = pm.getConfigSource();
74174
- 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 };
74175
- console.log(chalk37__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74625
+ 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 };
74176
74626
  try {
74177
74627
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74178
74628
  } catch {
@@ -74180,7 +74630,6 @@ async function handleCodeCommand(prompt) {
74180
74630
  }
74181
74631
  const pmBatch = getProviderManager();
74182
74632
  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 };
74183
- console.log(chalk37__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74184
74633
  try {
74185
74634
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74186
74635
  } catch {
@@ -74205,7 +74654,7 @@ async function handleCodeCommand(prompt) {
74205
74654
  for (const { language, code, extension, filename: suggested } of artifacts) {
74206
74655
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74207
74656
  filename = sanitizeFilenameStrict(filename);
74208
- const ext2 = path54__namespace.extname(filename).slice(1);
74657
+ const ext2 = path55__namespace.extname(filename).slice(1);
74209
74658
  const isBinary2 = isLikelyBinary(code);
74210
74659
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74211
74660
  const finalExt = coerceExtension(ext2, inferred);
@@ -74218,15 +74667,13 @@ async function handleCodeCommand(prompt) {
74218
74667
  files += 1;
74219
74668
  if (progress) clearInterval(progress);
74220
74669
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74221
- console.log(chalk37__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74222
- console.log(chalk37__default.default.gray(`\u{1F4CD} ${filepath}`));
74223
- console.log(chalk37__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74670
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74671
+ console.log(`\u{1F4CD} ${filepath}`);
74224
74672
  const pm = getProviderManager();
74225
74673
  const provider = pm.getLastUsedProvider() || "fallback";
74226
74674
  const model = pm.getLastUsedModel() || "n/a";
74227
74675
  const source = pm.getConfigSource();
74228
- 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 };
74229
- console.log(chalk37__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74676
+ 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 };
74230
74677
  try {
74231
74678
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74232
74679
  } catch {
@@ -74234,7 +74681,6 @@ async function handleCodeCommand(prompt) {
74234
74681
  }
74235
74682
  const pmBatch = getProviderManager();
74236
74683
  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 };
74237
- console.log(chalk37__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74238
74684
  try {
74239
74685
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74240
74686
  } catch {
@@ -74292,7 +74738,7 @@ ${e2.stack}`));
74292
74738
  for (const { language, code, extension, filename: suggested } of artifacts) {
74293
74739
  let filename = generateCodeFilename(prompt, language, extension, code, suggested);
74294
74740
  filename = sanitizeFilenameStrict(filename);
74295
- const ext2 = path54__namespace.extname(filename).slice(1);
74741
+ const ext2 = path55__namespace.extname(filename).slice(1);
74296
74742
  const isBinary2 = isLikelyBinary(code);
74297
74743
  const inferred = isBinary2 ? "bin" : inferExtensionFromContent(language, code) || "txt";
74298
74744
  const finalExt = coerceExtension(ext2, inferred);
@@ -74305,15 +74751,13 @@ ${e2.stack}`));
74305
74751
  files += 1;
74306
74752
  if (progress) clearInterval(progress);
74307
74753
  if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
74308
- console.log(chalk37__default.default.green(`\u2705 Saved 1 file: ${path54__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`));
74309
- console.log(chalk37__default.default.gray(`\u{1F4CD} ${filepath}`));
74310
- console.log(chalk37__default.default.gray(`\u2139\uFE0F Generated from: ${prompt.slice(0, 80)}`));
74754
+ console.log(`Saved 1 file: ${path55__namespace.basename(filepath)} (${language}${isBinary2 ? ", binary-like" : ""})`);
74755
+ console.log(`\u{1F4CD} ${filepath}`);
74311
74756
  const pm = getProviderManager();
74312
74757
  const provider = pm.getLastUsedProvider() || "fallback";
74313
74758
  const model = pm.getLastUsedModel() || "n/a";
74314
74759
  const source = pm.getConfigSource();
74315
- 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 };
74316
- console.log(chalk37__default.default.gray(`telemetry: code.saved ${JSON.stringify(summary)}`));
74760
+ 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 };
74317
74761
  try {
74318
74762
  TelemetryCollector.getInstance().trackCodeSaved(summary);
74319
74763
  } catch {
@@ -74321,7 +74765,6 @@ ${e2.stack}`));
74321
74765
  }
74322
74766
  const pmBatch = getProviderManager();
74323
74767
  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 };
74324
- console.log(chalk37__default.default.gray(`telemetry: code.saved_batch ${JSON.stringify(batch)}`));
74325
74768
  try {
74326
74769
  TelemetryCollector.getInstance().trackCodeSavedBatch(batch);
74327
74770
  } catch {
@@ -74871,24 +75314,24 @@ function createCLI2() {
74871
75314
  if (options.server) {
74872
75315
  console.log(chalk37__default.default.green("\u{1F680} Starting MARIA server mode..."));
74873
75316
  try {
74874
- const distDir = path54__namespace.dirname(process.argv[1] || process.cwd());
75317
+ const distDir = path55__namespace.dirname(process.argv[1] || process.cwd());
74875
75318
  const candidateNames = [
74876
75319
  "server-express.mjs",
74877
75320
  "server-express.cjs",
74878
75321
  "server-express.js",
74879
75322
  // tsup emits CJS for server entry as dist/server/express-server.js
74880
- path54__namespace.join("server", "express-server.js"),
74881
- path54__namespace.join("server", "express-server.cjs")
75323
+ path55__namespace.join("server", "express-server.js"),
75324
+ path55__namespace.join("server", "express-server.cjs")
74882
75325
  ];
74883
75326
  const candidateDirs = [
74884
75327
  distDir,
74885
- path54__namespace.resolve(distDir, ".."),
75328
+ path55__namespace.resolve(distDir, ".."),
74886
75329
  process.cwd()
74887
75330
  ];
74888
75331
  let serverPath = null;
74889
75332
  for (const dir of candidateDirs) {
74890
75333
  for (const name2 of candidateNames) {
74891
- const p = path54__namespace.join(dir, name2);
75334
+ const p = path55__namespace.join(dir, name2);
74892
75335
  try {
74893
75336
  await fsp__namespace.access(p);
74894
75337
  serverPath = p;
@@ -74908,7 +75351,7 @@ function createCLI2() {
74908
75351
  const serverProcess = spawn4("node", [serverPath], {
74909
75352
  stdio: "inherit",
74910
75353
  env: process.env,
74911
- cwd: path54__namespace.dirname(serverPath)
75354
+ cwd: path55__namespace.dirname(serverPath)
74912
75355
  });
74913
75356
  let shutdownTimer = null;
74914
75357
  const forceExit = (defaultCode) => {