@bonginkan/maria 4.3.13 → 4.3.14
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/READY.manifest.json +1 -1
- package/dist/bin/maria.cjs +1267 -520
- package/dist/bin/maria.cjs.map +1 -1
- package/dist/cli.cjs +1254 -507
- package/dist/cli.cjs.map +1 -1
- package/package.json +2 -2
- package/src/slash-commands/READY.manifest.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var fs23 = require('fs');
|
|
5
|
-
var
|
|
5
|
+
var path58 = require('path');
|
|
6
6
|
var dotenv = require('dotenv');
|
|
7
7
|
var chalk38 = require('chalk');
|
|
8
8
|
var crypto4 = require('crypto');
|
|
@@ -54,7 +54,7 @@ function _interopNamespace(e) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
var fs23__namespace = /*#__PURE__*/_interopNamespace(fs23);
|
|
57
|
-
var
|
|
57
|
+
var path58__namespace = /*#__PURE__*/_interopNamespace(path58);
|
|
58
58
|
var dotenv__namespace = /*#__PURE__*/_interopNamespace(dotenv);
|
|
59
59
|
var chalk38__default = /*#__PURE__*/_interopDefault(chalk38);
|
|
60
60
|
var crypto4__namespace = /*#__PURE__*/_interopNamespace(crypto4);
|
|
@@ -112,21 +112,21 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
112
112
|
mod
|
|
113
113
|
));
|
|
114
114
|
function loadEnvironmentVariables() {
|
|
115
|
-
const _envPath =
|
|
115
|
+
const _envPath = path58__namespace.join(process.cwd(), ".env");
|
|
116
116
|
if (fs23__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 =
|
|
122
|
+
const _envLocalPath = path58__namespace.join(process.cwd(), ".env.local");
|
|
123
123
|
if (fs23__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 =
|
|
129
|
+
const _lmstudioEnvPath = path58__namespace.join(process.cwd(), ".env.lmstudio");
|
|
130
130
|
if (fs23__namespace.existsSync(_lmstudioEnvPath)) {
|
|
131
131
|
const _result = dotenv__namespace.config({ path: _lmstudioEnvPath, override: false });
|
|
132
132
|
if (_result.error) {
|
|
@@ -231,25 +231,25 @@ function getPackageJson() {
|
|
|
231
231
|
try {
|
|
232
232
|
const possiblePaths = [
|
|
233
233
|
// When running from built dist/
|
|
234
|
-
|
|
234
|
+
path58.join(__dirname, "../../package.json"),
|
|
235
235
|
// When running from source
|
|
236
|
-
|
|
236
|
+
path58.join(__dirname, "../../../package.json"),
|
|
237
237
|
// Current working directory
|
|
238
|
-
|
|
238
|
+
path58.join(process.cwd(), "package.json"),
|
|
239
239
|
// One level up from current working directory
|
|
240
|
-
|
|
240
|
+
path58.join(process.cwd(), "../package.json"),
|
|
241
241
|
// For globally installed packages
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
path58.join(__dirname, "../../../../package.json"),
|
|
243
|
+
path58.join(__dirname, "../../../../../package.json"),
|
|
244
244
|
// npm global install locations
|
|
245
245
|
"/usr/local/lib/node_modules/@bonginkan/maria/package.json",
|
|
246
246
|
"/usr/lib/node_modules/@bonginkan/maria/package.json",
|
|
247
247
|
// User home npm global
|
|
248
|
-
|
|
248
|
+
path58.join(
|
|
249
249
|
process.env.HOME || "",
|
|
250
250
|
".npm-global/lib/node_modules/@bonginkan/maria/package.json"
|
|
251
251
|
),
|
|
252
|
-
|
|
252
|
+
path58.join(
|
|
253
253
|
process.env.HOME || "",
|
|
254
254
|
".nvm/versions/node",
|
|
255
255
|
process.version,
|
|
@@ -257,13 +257,13 @@ function getPackageJson() {
|
|
|
257
257
|
)
|
|
258
258
|
];
|
|
259
259
|
let packageJsonPath = null;
|
|
260
|
-
for (const
|
|
261
|
-
if (fs23.existsSync(
|
|
260
|
+
for (const path59 of possiblePaths) {
|
|
261
|
+
if (fs23.existsSync(path59)) {
|
|
262
262
|
try {
|
|
263
|
-
const content = fs23.readFileSync(
|
|
263
|
+
const content = fs23.readFileSync(path59, "utf-8");
|
|
264
264
|
const parsed = JSON.parse(content);
|
|
265
265
|
if (parsed.name === "@bonginkan/maria") {
|
|
266
|
-
packageJsonPath =
|
|
266
|
+
packageJsonPath = path59;
|
|
267
267
|
break;
|
|
268
268
|
}
|
|
269
269
|
} catch {
|
|
@@ -602,11 +602,11 @@ var init_OAuth2PKCEClient = __esm({
|
|
|
602
602
|
redirectUri: config2.redirectUri || "http://127.0.0.1:9876/callback",
|
|
603
603
|
authServerUrl: config2.authServerUrl || "https://maria-code.ai"
|
|
604
604
|
};
|
|
605
|
-
const configDir =
|
|
605
|
+
const configDir = path58__namespace.join(os13__namespace.homedir(), ".maria");
|
|
606
606
|
if (!fs23__namespace.existsSync(configDir)) {
|
|
607
607
|
fs23__namespace.mkdirSync(configDir, { recursive: true });
|
|
608
608
|
}
|
|
609
|
-
this.tokenStoragePath =
|
|
609
|
+
this.tokenStoragePath = path58__namespace.join(configDir, "auth-tokens.json");
|
|
610
610
|
}
|
|
611
611
|
/**
|
|
612
612
|
* Generate cryptographically secure random string
|
|
@@ -1184,11 +1184,11 @@ var init_CLIAuthService = __esm({
|
|
|
1184
1184
|
configPath;
|
|
1185
1185
|
config;
|
|
1186
1186
|
constructor(config2) {
|
|
1187
|
-
const configDir =
|
|
1187
|
+
const configDir = path58__namespace.join(os13__namespace.homedir(), ".maria");
|
|
1188
1188
|
if (!fs23__namespace.existsSync(configDir)) {
|
|
1189
1189
|
fs23__namespace.mkdirSync(configDir, { recursive: true });
|
|
1190
1190
|
}
|
|
1191
|
-
this.configPath =
|
|
1191
|
+
this.configPath = path58__namespace.join(configDir, "cli-config.json");
|
|
1192
1192
|
this.config = this.loadConfig(config2);
|
|
1193
1193
|
this.authClient = new OAuth2PKCEClient({
|
|
1194
1194
|
authorizationEndpoint: `${this.config.authServerUrl}/oauth/authorize`,
|
|
@@ -1510,8 +1510,8 @@ var init_TokenStorage = __esm({
|
|
|
1510
1510
|
TokenStorage = class {
|
|
1511
1511
|
SERVICE_NAME = "maria-cli";
|
|
1512
1512
|
ACCOUNT_NAME = "default";
|
|
1513
|
-
CONFIG_DIR =
|
|
1514
|
-
TOKEN_FILE =
|
|
1513
|
+
CONFIG_DIR = path58__namespace.default.join(os13__namespace.default.homedir(), ".maria");
|
|
1514
|
+
TOKEN_FILE = path58__namespace.default.join(this.CONFIG_DIR, "auth-tokens.json");
|
|
1515
1515
|
/**
|
|
1516
1516
|
* Save tokens securely
|
|
1517
1517
|
*/
|
|
@@ -2671,9 +2671,9 @@ function getDeviceId() {
|
|
|
2671
2671
|
function getSessionId() {
|
|
2672
2672
|
return global.MARIA_SESSION_ID;
|
|
2673
2673
|
}
|
|
2674
|
-
async function callApi(
|
|
2674
|
+
async function callApi(path59, init2 = {}) {
|
|
2675
2675
|
const apiBase = process.env.MARIA_API_BASE || "http://localhost:3001";
|
|
2676
|
-
const fullUrl = `${apiBase}${
|
|
2676
|
+
const fullUrl = `${apiBase}${path59}`;
|
|
2677
2677
|
let tokens2 = await authManager.getValidTokens();
|
|
2678
2678
|
if (!tokens2) {
|
|
2679
2679
|
console.log(chalk38__default.default.red(ERR.AUTH_REQUIRED.msg));
|
|
@@ -2742,8 +2742,8 @@ async function callApi(path58, init2 = {}) {
|
|
|
2742
2742
|
}
|
|
2743
2743
|
return response;
|
|
2744
2744
|
}
|
|
2745
|
-
async function callApiJson(
|
|
2746
|
-
const response = await callApi(
|
|
2745
|
+
async function callApiJson(path59, init2 = {}) {
|
|
2746
|
+
const response = await callApi(path59, init2);
|
|
2747
2747
|
if (!response.ok) {
|
|
2748
2748
|
const error2 = await response.json().catch(() => ({
|
|
2749
2749
|
message: `API error: ${response.status} ${response.statusText}`
|
|
@@ -2798,22 +2798,22 @@ function dataUriToBuffer(uri) {
|
|
|
2798
2798
|
if (firstComma === -1 || firstComma <= 4) {
|
|
2799
2799
|
throw new TypeError("malformed data: URI");
|
|
2800
2800
|
}
|
|
2801
|
-
const
|
|
2801
|
+
const meta25 = uri.substring(5, firstComma).split(";");
|
|
2802
2802
|
let charset = "";
|
|
2803
2803
|
let base64 = false;
|
|
2804
|
-
const type2 =
|
|
2804
|
+
const type2 = meta25[0] || "text/plain";
|
|
2805
2805
|
let typeFull = type2;
|
|
2806
|
-
for (let i2 = 1; i2 <
|
|
2807
|
-
if (
|
|
2806
|
+
for (let i2 = 1; i2 < meta25.length; i2++) {
|
|
2807
|
+
if (meta25[i2] === "base64") {
|
|
2808
2808
|
base64 = true;
|
|
2809
|
-
} else if (
|
|
2810
|
-
typeFull += `;${
|
|
2811
|
-
if (
|
|
2812
|
-
charset =
|
|
2809
|
+
} else if (meta25[i2]) {
|
|
2810
|
+
typeFull += `;${meta25[i2]}`;
|
|
2811
|
+
if (meta25[i2].indexOf("charset=") === 0) {
|
|
2812
|
+
charset = meta25[i2].substring(8);
|
|
2813
2813
|
}
|
|
2814
2814
|
}
|
|
2815
2815
|
}
|
|
2816
|
-
if (!
|
|
2816
|
+
if (!meta25[0] && !charset.length) {
|
|
2817
2817
|
typeFull += ";charset=US-ASCII";
|
|
2818
2818
|
charset = "US-ASCII";
|
|
2819
2819
|
}
|
|
@@ -7587,22 +7587,22 @@ var init_from = __esm({
|
|
|
7587
7587
|
init_file();
|
|
7588
7588
|
init_fetch_blob();
|
|
7589
7589
|
({ stat } = fs23.promises);
|
|
7590
|
-
blobFromSync = (
|
|
7591
|
-
blobFrom = (
|
|
7592
|
-
fileFrom = (
|
|
7593
|
-
fileFromSync = (
|
|
7594
|
-
fromBlob = (stat13,
|
|
7595
|
-
path:
|
|
7590
|
+
blobFromSync = (path59, type2) => fromBlob(fs23.statSync(path59), path59, type2);
|
|
7591
|
+
blobFrom = (path59, type2) => stat(path59).then((stat13) => fromBlob(stat13, path59, type2));
|
|
7592
|
+
fileFrom = (path59, type2) => stat(path59).then((stat13) => fromFile(stat13, path59, type2));
|
|
7593
|
+
fileFromSync = (path59, type2) => fromFile(fs23.statSync(path59), path59, type2);
|
|
7594
|
+
fromBlob = (stat13, path59, type2 = "") => new fetch_blob_default([new BlobDataItem({
|
|
7595
|
+
path: path59,
|
|
7596
7596
|
size: stat13.size,
|
|
7597
7597
|
lastModified: stat13.mtimeMs,
|
|
7598
7598
|
start: 0
|
|
7599
7599
|
})], { type: type2 });
|
|
7600
|
-
fromFile = (stat13,
|
|
7601
|
-
path:
|
|
7600
|
+
fromFile = (stat13, path59, type2 = "") => new file_default([new BlobDataItem({
|
|
7601
|
+
path: path59,
|
|
7602
7602
|
size: stat13.size,
|
|
7603
7603
|
lastModified: stat13.mtimeMs,
|
|
7604
7604
|
start: 0
|
|
7605
|
-
})],
|
|
7605
|
+
})], path58.basename(path59), { type: type2, lastModified: stat13.mtimeMs });
|
|
7606
7606
|
BlobDataItem = class _BlobDataItem {
|
|
7607
7607
|
#path;
|
|
7608
7608
|
#start;
|
|
@@ -11575,7 +11575,7 @@ var init_chat_context_service = __esm({
|
|
|
11575
11575
|
// 400K session window
|
|
11576
11576
|
compressionThreshold: config2?.compressionThreshold || 0.8,
|
|
11577
11577
|
summaryTokenLimit: config2?.summaryTokenLimit || 2e3,
|
|
11578
|
-
persistPath: config2?.persistPath ||
|
|
11578
|
+
persistPath: config2?.persistPath || path58__namespace.join(process.env["HOME"] || "", ".maria", "context")
|
|
11579
11579
|
};
|
|
11580
11580
|
this.sessionId = this.generateSessionId();
|
|
11581
11581
|
}
|
|
@@ -11699,7 +11699,7 @@ var init_chat_context_service = __esm({
|
|
|
11699
11699
|
if (!this.config.persistPath) return;
|
|
11700
11700
|
try {
|
|
11701
11701
|
await fsp__namespace.mkdir(this.config.persistPath, { recursive: true });
|
|
11702
|
-
const sessionFile =
|
|
11702
|
+
const sessionFile = path58__namespace.join(
|
|
11703
11703
|
this.config.persistPath,
|
|
11704
11704
|
`${this.sessionId}.json`
|
|
11705
11705
|
);
|
|
@@ -11770,8 +11770,8 @@ var init_conversation_persistence = __esm({
|
|
|
11770
11770
|
autoSaveInterval = null;
|
|
11771
11771
|
pendingWrites = [];
|
|
11772
11772
|
constructor(maxHistorySize = 100) {
|
|
11773
|
-
const configDir =
|
|
11774
|
-
this.sessionFile =
|
|
11773
|
+
const configDir = path58__namespace.join(os13__namespace.homedir(), ".maria");
|
|
11774
|
+
this.sessionFile = path58__namespace.join(configDir, "conversation-history.json");
|
|
11775
11775
|
this.maxHistorySize = maxHistorySize;
|
|
11776
11776
|
this.ensureConfigDir();
|
|
11777
11777
|
this.startAutoSave();
|
|
@@ -11781,7 +11781,7 @@ var init_conversation_persistence = __esm({
|
|
|
11781
11781
|
*/
|
|
11782
11782
|
async ensureConfigDir() {
|
|
11783
11783
|
try {
|
|
11784
|
-
const configDir =
|
|
11784
|
+
const configDir = path58__namespace.dirname(this.sessionFile);
|
|
11785
11785
|
await fs23.promises.mkdir(configDir, { recursive: true });
|
|
11786
11786
|
} catch (error2) {
|
|
11787
11787
|
console.warn("Failed to create config directory:", error2);
|
|
@@ -13249,9 +13249,9 @@ var FallbackManager;
|
|
|
13249
13249
|
var init_FallbackManager = __esm({
|
|
13250
13250
|
"src/services/fallback/FallbackManager.ts"() {
|
|
13251
13251
|
FallbackManager = class {
|
|
13252
|
-
constructor(policy,
|
|
13252
|
+
constructor(policy, telemetry2) {
|
|
13253
13253
|
this.policy = policy;
|
|
13254
|
-
this.telemetry =
|
|
13254
|
+
this.telemetry = telemetry2;
|
|
13255
13255
|
}
|
|
13256
13256
|
async run(attempt, opts = {}) {
|
|
13257
13257
|
const primary = await attempt();
|
|
@@ -15935,9 +15935,9 @@ function applyEnvOverrides(policy) {
|
|
|
15935
15935
|
function resolvePolicyPath(customPath) {
|
|
15936
15936
|
const envPath = process.env.MARIA_FALLBACK_POLICY_PATH;
|
|
15937
15937
|
if (envPath && envPath.trim().length > 0) {
|
|
15938
|
-
return
|
|
15938
|
+
return path58__namespace.default.resolve(envPath);
|
|
15939
15939
|
}
|
|
15940
|
-
return
|
|
15940
|
+
return path58__namespace.default.resolve(process.cwd(), "config", "fallback-policy.yaml");
|
|
15941
15941
|
}
|
|
15942
15942
|
async function loadFallbackPolicy(customPath) {
|
|
15943
15943
|
const policyPath = resolvePolicyPath();
|
|
@@ -16260,7 +16260,7 @@ var ai_response_service_exports = {};
|
|
|
16260
16260
|
__export(ai_response_service_exports, {
|
|
16261
16261
|
AIResponseService: () => AIResponseService
|
|
16262
16262
|
});
|
|
16263
|
-
var PLAIN_OUTPUT, DISABLE_SAFETY_GUARD, AIResponseService;
|
|
16263
|
+
var PLAIN_OUTPUT, DISABLE_SAFETY_GUARD, TEMPLATE_FALLBACK_ENABLED, AIResponseService;
|
|
16264
16264
|
var init_ai_response_service = __esm({
|
|
16265
16265
|
"src/services/ai-response.service.ts"() {
|
|
16266
16266
|
init_chat_context_service();
|
|
@@ -16278,6 +16278,7 @@ var init_ai_response_service = __esm({
|
|
|
16278
16278
|
init_safety();
|
|
16279
16279
|
PLAIN_OUTPUT = process.env.MARIA_PLAIN_OUTPUT === "1" || process.env.MARIA_DISABLE_GUIDED_FLOW === "1";
|
|
16280
16280
|
DISABLE_SAFETY_GUARD = process.env.MARIA_DISABLE_SAFETY_GUARD === "1";
|
|
16281
|
+
TEMPLATE_FALLBACK_ENABLED = process.env.MARIA_ENABLE_TEMPLATE_FALLBACK === "1";
|
|
16281
16282
|
AIResponseService = class {
|
|
16282
16283
|
chatContext;
|
|
16283
16284
|
_conversationPersistence;
|
|
@@ -16615,6 +16616,7 @@ ${fallbackMessage}` : fallbackMessage : finalResponse;
|
|
|
16615
16616
|
if (PLAIN_OUTPUT) {
|
|
16616
16617
|
switch (intent.type) {
|
|
16617
16618
|
case "CODE_REQUEST":
|
|
16619
|
+
if (!TEMPLATE_FALLBACK_ENABLED) return "";
|
|
16618
16620
|
if (/\bcli\b/i.test(userInput)) return generateCLITemplate(isJapanese);
|
|
16619
16621
|
if (/\b(api|rest)\b/i.test(userInput))
|
|
16620
16622
|
return generateNextAPITemplate(isJapanese);
|
|
@@ -16627,8 +16629,10 @@ ${fallbackMessage}` : fallbackMessage : finalResponse;
|
|
|
16627
16629
|
}
|
|
16628
16630
|
switch (intent.type) {
|
|
16629
16631
|
case "TETRIS_REQUEST":
|
|
16632
|
+
if (!TEMPLATE_FALLBACK_ENABLED) return "";
|
|
16630
16633
|
return isExplicitContentAllowed(userInput, "tetris") ? generateTetrisGameTemplate(userInput) : this.generateDefaultResponse(userInput);
|
|
16631
16634
|
case "CODE_REQUEST":
|
|
16635
|
+
if (!TEMPLATE_FALLBACK_ENABLED) return "";
|
|
16632
16636
|
if (/\bcli\b/i.test(userInput)) return generateCLITemplate(isJapanese);
|
|
16633
16637
|
if (/\b(api|next|rest)\b/i.test(userInput))
|
|
16634
16638
|
return generateNextAPITemplate(isJapanese);
|
|
@@ -17402,14 +17406,14 @@ var init_ReadyCommandsService = __esm({
|
|
|
17402
17406
|
} else {
|
|
17403
17407
|
const possiblePaths = [
|
|
17404
17408
|
// For bundled dist version
|
|
17405
|
-
|
|
17406
|
-
|
|
17407
|
-
|
|
17409
|
+
path58__namespace.join(__dirname, "READY.manifest.json"),
|
|
17410
|
+
path58__namespace.join(__dirname, "../READY.manifest.json"),
|
|
17411
|
+
path58__namespace.join(process.cwd(), "dist/READY.manifest.json"),
|
|
17408
17412
|
// For development/source version
|
|
17409
|
-
|
|
17410
|
-
|
|
17411
|
-
|
|
17412
|
-
|
|
17413
|
+
path58__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
|
|
17414
|
+
path58__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
|
|
17415
|
+
path58__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
|
|
17416
|
+
path58__namespace.join(process.cwd(), "READY.manifest.json")
|
|
17413
17417
|
];
|
|
17414
17418
|
this.manifestPath = possiblePaths[0];
|
|
17415
17419
|
}
|
|
@@ -17420,17 +17424,17 @@ var init_ReadyCommandsService = __esm({
|
|
|
17420
17424
|
async findManifestPath() {
|
|
17421
17425
|
const possiblePaths = [
|
|
17422
17426
|
// For bundled dist version
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
|
|
17427
|
+
path58__namespace.join(__dirname, "READY.manifest.json"),
|
|
17428
|
+
path58__namespace.join(__dirname, "../READY.manifest.json"),
|
|
17429
|
+
path58__namespace.join(process.cwd(), "dist/READY.manifest.json"),
|
|
17426
17430
|
// For development/source version
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
|
|
17431
|
+
path58__namespace.join(__dirname, "../../../src/slash-commands/READY.manifest.json"),
|
|
17432
|
+
path58__namespace.join(__dirname, "../../slash-commands/READY.manifest.json"),
|
|
17433
|
+
path58__namespace.join(process.cwd(), "src/slash-commands/READY.manifest.json"),
|
|
17434
|
+
path58__namespace.join(process.cwd(), "READY.manifest.json"),
|
|
17431
17435
|
// Additional paths for different build scenarios
|
|
17432
|
-
|
|
17433
|
-
|
|
17436
|
+
path58__namespace.resolve(__dirname, "../../../src/slash-commands/READY.manifest.json"),
|
|
17437
|
+
path58__namespace.resolve(process.cwd(), "src/slash-commands/READY.manifest.json")
|
|
17434
17438
|
];
|
|
17435
17439
|
for (const testPath of possiblePaths) {
|
|
17436
17440
|
try {
|
|
@@ -17998,7 +18002,7 @@ async function loadFirebaseAdmin() {
|
|
|
17998
18002
|
try {
|
|
17999
18003
|
const firebaseAdminModule = await import('firebase-admin/app');
|
|
18000
18004
|
const firestoreModule = await import('firebase-admin/firestore');
|
|
18001
|
-
const keyPath =
|
|
18005
|
+
const keyPath = path58__namespace.join(process.cwd(), "config", "maria-cli-firestore-key.json");
|
|
18002
18006
|
if (!adminApp && firebaseAdminModule.getApps().length === 0) {
|
|
18003
18007
|
adminApp = firebaseAdminModule.initializeApp({
|
|
18004
18008
|
credential: firebaseAdminModule.cert(keyPath),
|
|
@@ -18370,8 +18374,8 @@ var init_bigquery_telemetry = __esm({
|
|
|
18370
18374
|
});
|
|
18371
18375
|
async function getUserContext() {
|
|
18372
18376
|
try {
|
|
18373
|
-
const configDir =
|
|
18374
|
-
const authFile =
|
|
18377
|
+
const configDir = path58__namespace.join(process.env.HOME || process.env.USERPROFILE || "", ".maria");
|
|
18378
|
+
const authFile = path58__namespace.join(configDir, "auth.json");
|
|
18375
18379
|
if (await fs10__namespace.pathExists(authFile)) {
|
|
18376
18380
|
const authData = await fs10__namespace.readJson(authFile);
|
|
18377
18381
|
return {
|
|
@@ -19539,7 +19543,7 @@ var init_setup_command = __esm({
|
|
|
19539
19543
|
if (_setupRecord.filesGenerated) {
|
|
19540
19544
|
for (const file of _setupRecord.filesGenerated) {
|
|
19541
19545
|
try {
|
|
19542
|
-
const _filePath =
|
|
19546
|
+
const _filePath = path58__namespace.default.join(context2.environment.cwd, file);
|
|
19543
19547
|
await fsp__namespace.default.unlink(_filePath);
|
|
19544
19548
|
restoredFiles.push(file);
|
|
19545
19549
|
} catch (innerError) {
|
|
@@ -19549,7 +19553,7 @@ var init_setup_command = __esm({
|
|
|
19549
19553
|
}
|
|
19550
19554
|
}
|
|
19551
19555
|
}
|
|
19552
|
-
const _setupRecordPath =
|
|
19556
|
+
const _setupRecordPath = path58__namespace.default.join(
|
|
19553
19557
|
context2.environment.cwd,
|
|
19554
19558
|
".maria",
|
|
19555
19559
|
"setup.json"
|
|
@@ -19617,7 +19621,7 @@ var init_setup_command = __esm({
|
|
|
19617
19621
|
}
|
|
19618
19622
|
}
|
|
19619
19623
|
async recordSetupCompletion(_context, result) {
|
|
19620
|
-
const _mariaDir =
|
|
19624
|
+
const _mariaDir = path58__namespace.default.join(_context.environment.cwd, ".maria");
|
|
19621
19625
|
await fsp__namespace.default.mkdir(_mariaDir, { recursive: true });
|
|
19622
19626
|
const _setupRecord = {
|
|
19623
19627
|
...result,
|
|
@@ -19625,7 +19629,7 @@ var init_setup_command = __esm({
|
|
|
19625
19629
|
version: "1.0.0",
|
|
19626
19630
|
environment: _context.environment
|
|
19627
19631
|
};
|
|
19628
|
-
const _recordPath =
|
|
19632
|
+
const _recordPath = path58__namespace.default.join(_mariaDir, "setup.json");
|
|
19629
19633
|
await fsp__namespace.default.writeFile(
|
|
19630
19634
|
_recordPath,
|
|
19631
19635
|
JSON.stringify(_setupRecord, null, 2),
|
|
@@ -19724,14 +19728,14 @@ Estimated time: 3-5 minutes
|
|
|
19724
19728
|
}
|
|
19725
19729
|
async detectConfigurationIssues(context2) {
|
|
19726
19730
|
const _issues = [];
|
|
19727
|
-
if (!await this.fileExists(
|
|
19731
|
+
if (!await this.fileExists(path58__namespace.default.join(context2.environment.cwd, ".env.local"))) {
|
|
19728
19732
|
_issues.push({
|
|
19729
19733
|
description: "Missing .env.local file",
|
|
19730
19734
|
severity: "error"
|
|
19731
19735
|
});
|
|
19732
19736
|
}
|
|
19733
19737
|
if (!await this.fileExists(
|
|
19734
|
-
|
|
19738
|
+
path58__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
|
|
19735
19739
|
)) {
|
|
19736
19740
|
_issues.push({
|
|
19737
19741
|
description: "Missing .maria-code.toml file",
|
|
@@ -19747,7 +19751,7 @@ Estimated time: 3-5 minutes
|
|
|
19747
19751
|
}
|
|
19748
19752
|
async getSetupRecord(context2) {
|
|
19749
19753
|
try {
|
|
19750
|
-
const _recordPath =
|
|
19754
|
+
const _recordPath = path58__namespace.default.join(
|
|
19751
19755
|
context2.environment.cwd,
|
|
19752
19756
|
".maria",
|
|
19753
19757
|
"setup.json"
|
|
@@ -19759,11 +19763,11 @@ Estimated time: 3-5 minutes
|
|
|
19759
19763
|
}
|
|
19760
19764
|
}
|
|
19761
19765
|
async validateEnvironmentFile(context2) {
|
|
19762
|
-
return this.fileExists(
|
|
19766
|
+
return this.fileExists(path58__namespace.default.join(context2.environment.cwd, ".env.local"));
|
|
19763
19767
|
}
|
|
19764
19768
|
async validateConfigFile(context2) {
|
|
19765
19769
|
return this.fileExists(
|
|
19766
|
-
|
|
19770
|
+
path58__namespace.default.join(context2.environment.cwd, ".maria-code.toml")
|
|
19767
19771
|
);
|
|
19768
19772
|
}
|
|
19769
19773
|
async validateProviderConnections(_context) {
|
|
@@ -19790,7 +19794,7 @@ VLLM_API_URL=http://localhost:8000
|
|
|
19790
19794
|
DEBUG=false
|
|
19791
19795
|
LOG_LEVEL=info
|
|
19792
19796
|
`;
|
|
19793
|
-
const _envPath =
|
|
19797
|
+
const _envPath = path58__namespace.default.join(process.cwd(), ".env.local");
|
|
19794
19798
|
await fsp__namespace.default.writeFile(_envPath, _envContent, "utf-8");
|
|
19795
19799
|
return this.success("Environment template generated successfully", {
|
|
19796
19800
|
files: [".env.local"],
|
|
@@ -19864,8 +19868,8 @@ var init_ConfigurationCommandService = __esm({
|
|
|
19864
19868
|
var DIR, FILE, QuickPersistence;
|
|
19865
19869
|
var init_quick_persistence = __esm({
|
|
19866
19870
|
"src/services/memory-system/quick-persistence.ts"() {
|
|
19867
|
-
DIR =
|
|
19868
|
-
FILE =
|
|
19871
|
+
DIR = path58__namespace.join(os13__namespace.homedir(), ".maria", "memory");
|
|
19872
|
+
FILE = path58__namespace.join(DIR, "memories.jsonl");
|
|
19869
19873
|
QuickPersistence = class {
|
|
19870
19874
|
static async init() {
|
|
19871
19875
|
await fsp__namespace.mkdir(DIR, { recursive: true });
|
|
@@ -19987,8 +19991,8 @@ var init_quick_persistence = __esm({
|
|
|
19987
19991
|
const mine = rows.filter((r2) => r2.userId === userId);
|
|
19988
19992
|
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
19989
19993
|
const filename = `maria-memory-export-${timestamp2}.${format}`;
|
|
19990
|
-
const exportDir =
|
|
19991
|
-
const exportPath =
|
|
19994
|
+
const exportDir = path58__namespace.join(os13__namespace.homedir(), ".maria", "exports");
|
|
19995
|
+
const exportPath = path58__namespace.join(exportDir, filename);
|
|
19992
19996
|
await fsp__namespace.mkdir(exportDir, { recursive: true });
|
|
19993
19997
|
if (format === "jsonl") {
|
|
19994
19998
|
await fsp__namespace.writeFile(
|
|
@@ -22622,7 +22626,7 @@ var init_StateManager = __esm({
|
|
|
22622
22626
|
maxCheckpointAge = 7 * 24 * 60 * 60 * 1e3;
|
|
22623
22627
|
// 7 days
|
|
22624
22628
|
constructor() {
|
|
22625
|
-
this.checkpointsDir =
|
|
22629
|
+
this.checkpointsDir = path58__namespace.join(os13__namespace.homedir(), ".maria", "checkpoints");
|
|
22626
22630
|
}
|
|
22627
22631
|
/**
|
|
22628
22632
|
* Initialize checkpoints directory
|
|
@@ -22648,7 +22652,7 @@ var init_StateManager = __esm({
|
|
|
22648
22652
|
const checkpointId = `${planId}_${Date.now()}`;
|
|
22649
22653
|
const timestamp2 = Date.now();
|
|
22650
22654
|
try {
|
|
22651
|
-
const checkpointPath =
|
|
22655
|
+
const checkpointPath = path58__namespace.join(this.checkpointsDir, checkpointId);
|
|
22652
22656
|
await fsp__namespace.mkdir(checkpointPath, { recursive: true });
|
|
22653
22657
|
const backups = await this.createBackups(actions, checkpointPath);
|
|
22654
22658
|
const configSnapshots = await this.createConfigSnapshots(
|
|
@@ -22667,7 +22671,7 @@ var init_StateManager = __esm({
|
|
|
22667
22671
|
riskScore
|
|
22668
22672
|
}
|
|
22669
22673
|
};
|
|
22670
|
-
const metadataPath =
|
|
22674
|
+
const metadataPath = path58__namespace.join(checkpointPath, "checkpoint.json");
|
|
22671
22675
|
await fsp__namespace.writeFile(
|
|
22672
22676
|
metadataPath,
|
|
22673
22677
|
JSON.stringify(checkpoint, null, 2),
|
|
@@ -22839,7 +22843,7 @@ var init_StateManager = __esm({
|
|
|
22839
22843
|
*/
|
|
22840
22844
|
async removeCheckpoint(checkpointId) {
|
|
22841
22845
|
try {
|
|
22842
|
-
const checkpointPath =
|
|
22846
|
+
const checkpointPath = path58__namespace.join(this.checkpointsDir, checkpointId);
|
|
22843
22847
|
await fsp__namespace.rm(checkpointPath, { recursive: true, force: true });
|
|
22844
22848
|
logger.info(`StateManager: Removed checkpoint ${checkpointId}`);
|
|
22845
22849
|
return true;
|
|
@@ -22870,7 +22874,7 @@ var init_StateManager = __esm({
|
|
|
22870
22874
|
*/
|
|
22871
22875
|
async createBackups(actions, checkpointPath) {
|
|
22872
22876
|
const backups = [];
|
|
22873
|
-
const backupDir =
|
|
22877
|
+
const backupDir = path58__namespace.join(checkpointPath, "backups");
|
|
22874
22878
|
await fsp__namespace.mkdir(backupDir, { recursive: true });
|
|
22875
22879
|
for (const action of actions) {
|
|
22876
22880
|
const filesToBackup = this.extractFilePathsFromAction(action);
|
|
@@ -22879,7 +22883,7 @@ var init_StateManager = __esm({
|
|
|
22879
22883
|
const resolvedPath = this.resolvePath(filePath);
|
|
22880
22884
|
const stats = await fsp__namespace.stat(resolvedPath);
|
|
22881
22885
|
const backupFileName = this.sanitizeFileName(resolvedPath);
|
|
22882
|
-
const backupPath =
|
|
22886
|
+
const backupPath = path58__namespace.join(backupDir, backupFileName);
|
|
22883
22887
|
await fsp__namespace.copyFile(resolvedPath, backupPath);
|
|
22884
22888
|
backups.push({
|
|
22885
22889
|
originalPath: resolvedPath,
|
|
@@ -22902,7 +22906,7 @@ var init_StateManager = __esm({
|
|
|
22902
22906
|
*/
|
|
22903
22907
|
async createConfigSnapshots(actions, checkpointPath) {
|
|
22904
22908
|
const snapshots = [];
|
|
22905
|
-
const configDir =
|
|
22909
|
+
const configDir = path58__namespace.join(checkpointPath, "configs");
|
|
22906
22910
|
await fsp__namespace.mkdir(configDir, { recursive: true });
|
|
22907
22911
|
const configPaths = /* @__PURE__ */ new Set();
|
|
22908
22912
|
for (const action of actions) {
|
|
@@ -22935,7 +22939,7 @@ var init_StateManager = __esm({
|
|
|
22935
22939
|
* Load checkpoint from disk
|
|
22936
22940
|
*/
|
|
22937
22941
|
async loadCheckpoint(checkpointId) {
|
|
22938
|
-
const metadataPath =
|
|
22942
|
+
const metadataPath = path58__namespace.join(
|
|
22939
22943
|
this.checkpointsDir,
|
|
22940
22944
|
checkpointId,
|
|
22941
22945
|
"checkpoint.json"
|
|
@@ -22961,9 +22965,9 @@ var init_StateManager = __esm({
|
|
|
22961
22965
|
*/
|
|
22962
22966
|
resolvePath(filePath) {
|
|
22963
22967
|
if (filePath.startsWith("~/")) {
|
|
22964
|
-
return
|
|
22968
|
+
return path58__namespace.join(os13__namespace.homedir(), filePath.slice(2));
|
|
22965
22969
|
}
|
|
22966
|
-
return
|
|
22970
|
+
return path58__namespace.resolve(filePath);
|
|
22967
22971
|
}
|
|
22968
22972
|
/**
|
|
22969
22973
|
* Sanitize filename for backup storage
|
|
@@ -23027,7 +23031,7 @@ var init_StateManager = __esm({
|
|
|
23027
23031
|
} catch {
|
|
23028
23032
|
}
|
|
23029
23033
|
} else {
|
|
23030
|
-
await fsp__namespace.mkdir(
|
|
23034
|
+
await fsp__namespace.mkdir(path58__namespace.dirname(config2.configPath), { recursive: true });
|
|
23031
23035
|
await fsp__namespace.writeFile(config2.configPath, config2.content, "utf-8");
|
|
23032
23036
|
}
|
|
23033
23037
|
logger.debug(`StateManager: Restored config ${config2.configPath}`);
|
|
@@ -23145,9 +23149,9 @@ var init_SafetyGuard = __esm({
|
|
|
23145
23149
|
}
|
|
23146
23150
|
}
|
|
23147
23151
|
if (action.args.paths && Array.isArray(action.args.paths)) {
|
|
23148
|
-
for (const
|
|
23149
|
-
if (!this.validatePath(
|
|
23150
|
-
violations.push(`Invalid path: ${
|
|
23152
|
+
for (const path59 of action.args.paths) {
|
|
23153
|
+
if (!this.validatePath(path59)) {
|
|
23154
|
+
violations.push(`Invalid path: ${path59}`);
|
|
23151
23155
|
}
|
|
23152
23156
|
}
|
|
23153
23157
|
}
|
|
@@ -23203,15 +23207,15 @@ var init_SafetyGuard = __esm({
|
|
|
23203
23207
|
* Validate file path against allowed/blocked lists
|
|
23204
23208
|
*/
|
|
23205
23209
|
validatePath(filePath) {
|
|
23206
|
-
const
|
|
23207
|
-
const resolvedPath =
|
|
23210
|
+
const path59 = __require("path");
|
|
23211
|
+
const resolvedPath = path59.resolve(filePath);
|
|
23208
23212
|
for (const blockedPath of this.constraints.blockedPaths) {
|
|
23209
|
-
if (resolvedPath.startsWith(
|
|
23213
|
+
if (resolvedPath.startsWith(path59.resolve(blockedPath))) {
|
|
23210
23214
|
return false;
|
|
23211
23215
|
}
|
|
23212
23216
|
}
|
|
23213
23217
|
for (const allowedPath of this.constraints.allowedPaths) {
|
|
23214
|
-
if (resolvedPath.startsWith(
|
|
23218
|
+
if (resolvedPath.startsWith(path59.resolve(allowedPath))) {
|
|
23215
23219
|
return true;
|
|
23216
23220
|
}
|
|
23217
23221
|
}
|
|
@@ -23240,9 +23244,9 @@ var init_SafetyGuard = __esm({
|
|
|
23240
23244
|
violations.push(`Invalid path in ${action.type}: ${action.args.path}`);
|
|
23241
23245
|
}
|
|
23242
23246
|
if (action.args.paths && Array.isArray(action.args.paths)) {
|
|
23243
|
-
for (const
|
|
23244
|
-
if (!this.validatePath(
|
|
23245
|
-
violations.push(`Invalid path in ${action.type}: ${
|
|
23247
|
+
for (const path59 of action.args.paths) {
|
|
23248
|
+
if (!this.validatePath(path59)) {
|
|
23249
|
+
violations.push(`Invalid path in ${action.type}: ${path59}`);
|
|
23246
23250
|
}
|
|
23247
23251
|
}
|
|
23248
23252
|
}
|
|
@@ -23302,8 +23306,8 @@ var require_package = __commonJS({
|
|
|
23302
23306
|
"package.json"(exports, module) {
|
|
23303
23307
|
module.exports = {
|
|
23304
23308
|
name: "@bonginkan/maria",
|
|
23305
|
-
version: "4.3.
|
|
23306
|
-
description: "\u{1F680} MARIA v4.3.
|
|
23309
|
+
version: "4.3.14",
|
|
23310
|
+
description: "\u{1F680} MARIA v4.3.14 - Enterprise AI Development Platform with identity system and character voice implementation. Features 74 production-ready commands with comprehensive fallback implementation, local LLM support, and zero external dependencies. Includes natural language coding, AI safety evaluation, intelligent evolution system, episodic memory with PII masking, and real-time monitoring dashboard. Built with TypeScript AST-powered code generation, OAuth2.0 + PKCE authentication, quantum-resistant cryptography, and enterprise-grade performance.",
|
|
23307
23311
|
keywords: [
|
|
23308
23312
|
"ai",
|
|
23309
23313
|
"cli",
|
|
@@ -23866,7 +23870,7 @@ var init_AuditLogger = __esm({
|
|
|
23866
23870
|
constructor(sessionId, options = {}) {
|
|
23867
23871
|
this.sessionId = sessionId;
|
|
23868
23872
|
this.options = {
|
|
23869
|
-
logDir:
|
|
23873
|
+
logDir: path58__namespace.join(os13__namespace.homedir(), ".maria", "audit"),
|
|
23870
23874
|
maxLogSize: 10 * 1024 * 1024,
|
|
23871
23875
|
// 10MB
|
|
23872
23876
|
maxLogFiles: 30,
|
|
@@ -23876,7 +23880,7 @@ var init_AuditLogger = __esm({
|
|
|
23876
23880
|
...options
|
|
23877
23881
|
};
|
|
23878
23882
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
23879
|
-
this.logFilePath =
|
|
23883
|
+
this.logFilePath = path58__namespace.join(this.options.logDir, `audit-${date}.jsonl`);
|
|
23880
23884
|
}
|
|
23881
23885
|
/**
|
|
23882
23886
|
* Initialize audit logging
|
|
@@ -24165,7 +24169,7 @@ var init_AuditLogger = __esm({
|
|
|
24165
24169
|
try {
|
|
24166
24170
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
24167
24171
|
const timestamp2 = Date.now();
|
|
24168
|
-
const archivePath =
|
|
24172
|
+
const archivePath = path58__namespace.join(
|
|
24169
24173
|
this.options.logDir,
|
|
24170
24174
|
`audit-${date}-${timestamp2}.jsonl`
|
|
24171
24175
|
);
|
|
@@ -24205,7 +24209,7 @@ var init_AuditLogger = __esm({
|
|
|
24205
24209
|
if (logFiles.length > this.options.maxLogFiles) {
|
|
24206
24210
|
const toRemove = logFiles.slice(this.options.maxLogFiles);
|
|
24207
24211
|
for (const file of toRemove) {
|
|
24208
|
-
const filePath =
|
|
24212
|
+
const filePath = path58__namespace.join(this.options.logDir, file);
|
|
24209
24213
|
await fsp__namespace.unlink(filePath);
|
|
24210
24214
|
logger.debug(`AuditLogger: Removed old log file ${file}`);
|
|
24211
24215
|
}
|
|
@@ -24247,7 +24251,7 @@ var init_FileActionExecutor = __esm({
|
|
|
24247
24251
|
FileActionExecutor = class {
|
|
24248
24252
|
ALLOWED_PATHS = [
|
|
24249
24253
|
process.cwd(),
|
|
24250
|
-
|
|
24254
|
+
path58__namespace.join(os13__namespace.homedir(), ".maria")
|
|
24251
24255
|
];
|
|
24252
24256
|
/**
|
|
24253
24257
|
* Execute file action
|
|
@@ -24309,7 +24313,7 @@ var init_FileActionExecutor = __esm({
|
|
|
24309
24313
|
await fsp__namespace.access(resolvedPath);
|
|
24310
24314
|
return { action: "already_exists", path: resolvedPath };
|
|
24311
24315
|
} catch {
|
|
24312
|
-
await fsp__namespace.mkdir(
|
|
24316
|
+
await fsp__namespace.mkdir(path58__namespace.dirname(resolvedPath), { recursive: true });
|
|
24313
24317
|
await fsp__namespace.writeFile(resolvedPath, "", "utf-8");
|
|
24314
24318
|
logger.info(`Created file: ${resolvedPath}`);
|
|
24315
24319
|
return { action: "created", path: resolvedPath };
|
|
@@ -24526,20 +24530,20 @@ var init_FileActionExecutor = __esm({
|
|
|
24526
24530
|
*/
|
|
24527
24531
|
resolvePath(filePath) {
|
|
24528
24532
|
if (filePath.startsWith("~/")) {
|
|
24529
|
-
return
|
|
24533
|
+
return path58__namespace.join(os13__namespace.homedir(), filePath.slice(2));
|
|
24530
24534
|
}
|
|
24531
|
-
if (
|
|
24535
|
+
if (path58__namespace.isAbsolute(filePath)) {
|
|
24532
24536
|
return filePath;
|
|
24533
24537
|
}
|
|
24534
|
-
return
|
|
24538
|
+
return path58__namespace.resolve(process.cwd(), filePath);
|
|
24535
24539
|
}
|
|
24536
24540
|
/**
|
|
24537
24541
|
* Validate path is within allowed directories
|
|
24538
24542
|
*/
|
|
24539
24543
|
validatePath(filePath) {
|
|
24540
|
-
const resolvedPath =
|
|
24544
|
+
const resolvedPath = path58__namespace.resolve(filePath);
|
|
24541
24545
|
for (const allowedPath of this.ALLOWED_PATHS) {
|
|
24542
|
-
const allowedResolved =
|
|
24546
|
+
const allowedResolved = path58__namespace.resolve(allowedPath);
|
|
24543
24547
|
if (resolvedPath.startsWith(allowedResolved)) {
|
|
24544
24548
|
return;
|
|
24545
24549
|
}
|
|
@@ -24554,7 +24558,7 @@ var init_ConfigActionExecutor = __esm({
|
|
|
24554
24558
|
"src/services/self-healing/executors/ConfigActionExecutor.ts"() {
|
|
24555
24559
|
init_logger();
|
|
24556
24560
|
ConfigActionExecutor = class {
|
|
24557
|
-
DEFAULT_CONFIG_PATH =
|
|
24561
|
+
DEFAULT_CONFIG_PATH = path58__namespace.join(
|
|
24558
24562
|
os13__namespace.homedir(),
|
|
24559
24563
|
".maria",
|
|
24560
24564
|
"config.json"
|
|
@@ -24601,7 +24605,7 @@ var init_ConfigActionExecutor = __esm({
|
|
|
24601
24605
|
};
|
|
24602
24606
|
}
|
|
24603
24607
|
try {
|
|
24604
|
-
await fsp__namespace.mkdir(
|
|
24608
|
+
await fsp__namespace.mkdir(path58__namespace.dirname(resolvedPath), { recursive: true });
|
|
24605
24609
|
let config2 = {};
|
|
24606
24610
|
try {
|
|
24607
24611
|
const content = await fsp__namespace.readFile(resolvedPath, "utf-8");
|
|
@@ -24636,7 +24640,7 @@ var init_ConfigActionExecutor = __esm({
|
|
|
24636
24640
|
};
|
|
24637
24641
|
}
|
|
24638
24642
|
try {
|
|
24639
|
-
await fsp__namespace.mkdir(
|
|
24643
|
+
await fsp__namespace.mkdir(path58__namespace.dirname(resolvedPath), { recursive: true });
|
|
24640
24644
|
let config2 = {};
|
|
24641
24645
|
try {
|
|
24642
24646
|
const content = await fsp__namespace.readFile(resolvedPath, "utf-8");
|
|
@@ -24736,8 +24740,8 @@ var init_ConfigActionExecutor = __esm({
|
|
|
24736
24740
|
/**
|
|
24737
24741
|
* Set nested configuration value using dot notation
|
|
24738
24742
|
*/
|
|
24739
|
-
setNestedValue(obj,
|
|
24740
|
-
const keys =
|
|
24743
|
+
setNestedValue(obj, path59, value) {
|
|
24744
|
+
const keys = path59.split(".");
|
|
24741
24745
|
let current = obj;
|
|
24742
24746
|
for (let i2 = 0; i2 < keys.length - 1; i2++) {
|
|
24743
24747
|
const key = keys[i2];
|
|
@@ -24754,9 +24758,9 @@ var init_ConfigActionExecutor = __esm({
|
|
|
24754
24758
|
resolveConfigPath(configPath) {
|
|
24755
24759
|
if (configPath) {
|
|
24756
24760
|
if (configPath.startsWith("~/")) {
|
|
24757
|
-
return
|
|
24761
|
+
return path58__namespace.join(os13__namespace.homedir(), configPath.slice(2));
|
|
24758
24762
|
}
|
|
24759
|
-
return
|
|
24763
|
+
return path58__namespace.resolve(configPath);
|
|
24760
24764
|
}
|
|
24761
24765
|
return this.DEFAULT_CONFIG_PATH;
|
|
24762
24766
|
}
|
|
@@ -24769,10 +24773,10 @@ var init_CacheActionExecutor = __esm({
|
|
|
24769
24773
|
init_logger();
|
|
24770
24774
|
CacheActionExecutor = class {
|
|
24771
24775
|
CACHE_PATHS = [
|
|
24772
|
-
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
+
path58__namespace.join(os13__namespace.homedir(), ".maria", "cache"),
|
|
24777
|
+
path58__namespace.join(process.cwd(), ".turbo"),
|
|
24778
|
+
path58__namespace.join(process.cwd(), ".cache", "maria"),
|
|
24779
|
+
path58__namespace.join(process.cwd(), "node_modules", ".cache")
|
|
24776
24780
|
];
|
|
24777
24781
|
/**
|
|
24778
24782
|
* Execute cache action
|
|
@@ -24953,10 +24957,10 @@ var init_CacheActionExecutor = __esm({
|
|
|
24953
24957
|
* Warmup specific target
|
|
24954
24958
|
*/
|
|
24955
24959
|
async warmupTarget(target) {
|
|
24956
|
-
const cacheDir =
|
|
24960
|
+
const cacheDir = path58__namespace.join(os13__namespace.homedir(), ".maria", "cache");
|
|
24957
24961
|
switch (target) {
|
|
24958
24962
|
case "models:list":
|
|
24959
|
-
const modelsDir =
|
|
24963
|
+
const modelsDir = path58__namespace.join(cacheDir, "models");
|
|
24960
24964
|
await fsp__namespace.mkdir(modelsDir, { recursive: true });
|
|
24961
24965
|
const modelsData = {
|
|
24962
24966
|
timestamp: Date.now(),
|
|
@@ -24967,12 +24971,12 @@ var init_CacheActionExecutor = __esm({
|
|
|
24967
24971
|
]
|
|
24968
24972
|
};
|
|
24969
24973
|
await fsp__namespace.writeFile(
|
|
24970
|
-
|
|
24974
|
+
path58__namespace.join(modelsDir, "available.json"),
|
|
24971
24975
|
JSON.stringify(modelsData, null, 2)
|
|
24972
24976
|
);
|
|
24973
24977
|
return { itemsCreated: 1, size: JSON.stringify(modelsData).length };
|
|
24974
24978
|
case "aliases":
|
|
24975
|
-
const aliasesDir =
|
|
24979
|
+
const aliasesDir = path58__namespace.join(cacheDir, "aliases");
|
|
24976
24980
|
await fsp__namespace.mkdir(aliasesDir, { recursive: true });
|
|
24977
24981
|
const aliasesData = {
|
|
24978
24982
|
timestamp: Date.now(),
|
|
@@ -24983,12 +24987,12 @@ var init_CacheActionExecutor = __esm({
|
|
|
24983
24987
|
}
|
|
24984
24988
|
};
|
|
24985
24989
|
await fsp__namespace.writeFile(
|
|
24986
|
-
|
|
24990
|
+
path58__namespace.join(aliasesDir, "model-aliases.json"),
|
|
24987
24991
|
JSON.stringify(aliasesData, null, 2)
|
|
24988
24992
|
);
|
|
24989
24993
|
return { itemsCreated: 1, size: JSON.stringify(aliasesData).length };
|
|
24990
24994
|
case "templates":
|
|
24991
|
-
const templatesDir =
|
|
24995
|
+
const templatesDir = path58__namespace.join(cacheDir, "templates");
|
|
24992
24996
|
await fsp__namespace.mkdir(templatesDir, { recursive: true });
|
|
24993
24997
|
const templatesData = {
|
|
24994
24998
|
timestamp: Date.now(),
|
|
@@ -24999,7 +25003,7 @@ var init_CacheActionExecutor = __esm({
|
|
|
24999
25003
|
}
|
|
25000
25004
|
};
|
|
25001
25005
|
await fsp__namespace.writeFile(
|
|
25002
|
-
|
|
25006
|
+
path58__namespace.join(templatesDir, "prompt-templates.json"),
|
|
25003
25007
|
JSON.stringify(templatesData, null, 2)
|
|
25004
25008
|
);
|
|
25005
25009
|
return { itemsCreated: 1, size: JSON.stringify(templatesData).length };
|
|
@@ -25045,7 +25049,7 @@ var init_CacheActionExecutor = __esm({
|
|
|
25045
25049
|
try {
|
|
25046
25050
|
const entries = await fsp__namespace.readdir(dirPath, { withFileTypes: true });
|
|
25047
25051
|
for (const entry of entries) {
|
|
25048
|
-
const entryPath =
|
|
25052
|
+
const entryPath = path58__namespace.join(dirPath, entry.name);
|
|
25049
25053
|
if (entry.isDirectory()) {
|
|
25050
25054
|
totalSize += await this.getDirectorySize(entryPath);
|
|
25051
25055
|
} else {
|
|
@@ -25066,7 +25070,7 @@ var init_CacheActionExecutor = __esm({
|
|
|
25066
25070
|
const entries = await fsp__namespace.readdir(dirPath, { withFileTypes: true });
|
|
25067
25071
|
for (const entry of entries) {
|
|
25068
25072
|
if (entry.isDirectory()) {
|
|
25069
|
-
const entryPath =
|
|
25073
|
+
const entryPath = path58__namespace.join(dirPath, entry.name);
|
|
25070
25074
|
count += await this.countFiles(entryPath);
|
|
25071
25075
|
} else {
|
|
25072
25076
|
count++;
|
|
@@ -25094,12 +25098,12 @@ var init_CacheActionExecutor = __esm({
|
|
|
25094
25098
|
*/
|
|
25095
25099
|
resolvePath(cachePath) {
|
|
25096
25100
|
if (cachePath.startsWith("~/")) {
|
|
25097
|
-
return
|
|
25101
|
+
return path58__namespace.join(os13__namespace.homedir(), cachePath.slice(2));
|
|
25098
25102
|
}
|
|
25099
|
-
if (
|
|
25103
|
+
if (path58__namespace.isAbsolute(cachePath)) {
|
|
25100
25104
|
return cachePath;
|
|
25101
25105
|
}
|
|
25102
|
-
return
|
|
25106
|
+
return path58__namespace.resolve(process.cwd(), cachePath);
|
|
25103
25107
|
}
|
|
25104
25108
|
};
|
|
25105
25109
|
}
|
|
@@ -25372,7 +25376,7 @@ var init_SelfHealingService = __esm({
|
|
|
25372
25376
|
const timestamp2 = /* @__PURE__ */ new Date();
|
|
25373
25377
|
await this.auditLogger.logDiagnosis("started", { diagnostics: context2 });
|
|
25374
25378
|
try {
|
|
25375
|
-
const envPath =
|
|
25379
|
+
const envPath = path58__namespace.join(context2.cwd, ".env.local");
|
|
25376
25380
|
try {
|
|
25377
25381
|
await fsp__namespace.access(envPath);
|
|
25378
25382
|
} catch {
|
|
@@ -25387,7 +25391,7 @@ var init_SelfHealingService = __esm({
|
|
|
25387
25391
|
suggestion: "Create .env.local with API keys template"
|
|
25388
25392
|
});
|
|
25389
25393
|
}
|
|
25390
|
-
const nodeModulesPath =
|
|
25394
|
+
const nodeModulesPath = path58__namespace.join(context2.cwd, "node_modules");
|
|
25391
25395
|
try {
|
|
25392
25396
|
await fsp__namespace.access(nodeModulesPath);
|
|
25393
25397
|
} catch {
|
|
@@ -25402,7 +25406,7 @@ var init_SelfHealingService = __esm({
|
|
|
25402
25406
|
suggestion: "Run package manager install command"
|
|
25403
25407
|
});
|
|
25404
25408
|
}
|
|
25405
|
-
const cachePath =
|
|
25409
|
+
const cachePath = path58__namespace.join(process.env.HOME || "", ".maria", "cache");
|
|
25406
25410
|
try {
|
|
25407
25411
|
const stats = await fsp__namespace.stat(cachePath);
|
|
25408
25412
|
if (stats.size > 100 * 1024 * 1024) {
|
|
@@ -25784,7 +25788,7 @@ __export(cli_style_exports, {
|
|
|
25784
25788
|
});
|
|
25785
25789
|
async function tryReadModelFromManifest(root, manifestRel) {
|
|
25786
25790
|
try {
|
|
25787
|
-
const full =
|
|
25791
|
+
const full = path58__namespace.resolve(root, manifestRel);
|
|
25788
25792
|
const text = await fsp__namespace.readFile(full, "utf8");
|
|
25789
25793
|
const json2 = JSON.parse(text);
|
|
25790
25794
|
const model = json2?.request?.model;
|
|
@@ -25801,7 +25805,7 @@ function formatArtifacts(files, limit = 10) {
|
|
|
25801
25805
|
return lines;
|
|
25802
25806
|
}
|
|
25803
25807
|
function artifactsRootDir(manifestPath) {
|
|
25804
|
-
return
|
|
25808
|
+
return path58__namespace.posix.dirname(manifestPath);
|
|
25805
25809
|
}
|
|
25806
25810
|
async function formatImageOutput(root, opts) {
|
|
25807
25811
|
const model = opts.model || await tryReadModelFromManifest(root, opts.manifestPath) || "auto";
|
|
@@ -26141,7 +26145,7 @@ function createConfigCheck() {
|
|
|
26141
26145
|
runsIn: "read-only",
|
|
26142
26146
|
estimateMs: 20,
|
|
26143
26147
|
async run(ctx2) {
|
|
26144
|
-
const pkgPath =
|
|
26148
|
+
const pkgPath = path58.resolve(ctx2.cwd, "package.json");
|
|
26145
26149
|
try {
|
|
26146
26150
|
const raw = await fsp.readFile(pkgPath, "utf-8");
|
|
26147
26151
|
const pkg = JSON.parse(raw);
|
|
@@ -26210,7 +26214,7 @@ function createDependenciesCheck() {
|
|
|
26210
26214
|
runsIn: "read-only",
|
|
26211
26215
|
estimateMs: 25,
|
|
26212
26216
|
async run(ctx2) {
|
|
26213
|
-
const nm =
|
|
26217
|
+
const nm = path58.resolve(ctx2.cwd, "node_modules");
|
|
26214
26218
|
try {
|
|
26215
26219
|
const s2 = await fsp.stat(nm);
|
|
26216
26220
|
if (!s2.isDirectory()) {
|
|
@@ -26305,7 +26309,7 @@ function createGitRepoCheck() {
|
|
|
26305
26309
|
runsIn: "read-only",
|
|
26306
26310
|
estimateMs: 10,
|
|
26307
26311
|
async run(ctx2) {
|
|
26308
|
-
const dotgit =
|
|
26312
|
+
const dotgit = path58.resolve(ctx2.cwd, ".git");
|
|
26309
26313
|
try {
|
|
26310
26314
|
await fsp.access(dotgit);
|
|
26311
26315
|
return { name: "Git Repository", category: "config", status: "pass", message: "Git repo detected" };
|
|
@@ -26391,9 +26395,9 @@ function createProvidersSecretConfigCheck() {
|
|
|
26391
26395
|
groq: !!process.env.GROQ_API_KEY
|
|
26392
26396
|
};
|
|
26393
26397
|
const candidates = [
|
|
26394
|
-
|
|
26395
|
-
|
|
26396
|
-
|
|
26398
|
+
path58.resolve(ctx2.cwd, ".maria/secrets.local.json"),
|
|
26399
|
+
path58.resolve(ctx2.cwd, "secrets/local.json"),
|
|
26400
|
+
path58.resolve(ctx2.cwd, ".secrets.local.json")
|
|
26397
26401
|
];
|
|
26398
26402
|
let fileCfg = null;
|
|
26399
26403
|
for (const p of candidates) {
|
|
@@ -26465,8 +26469,8 @@ async function applyPlans(plans, opts) {
|
|
|
26465
26469
|
try {
|
|
26466
26470
|
for (const plan of plans) {
|
|
26467
26471
|
if (opts.signal?.aborted) throw abortErr();
|
|
26468
|
-
const target =
|
|
26469
|
-
const dir =
|
|
26472
|
+
const target = path58__namespace.default.join(opts.root, plan.path);
|
|
26473
|
+
const dir = path58__namespace.default.dirname(target);
|
|
26470
26474
|
await fs23.promises.mkdir(dir, { recursive: true });
|
|
26471
26475
|
const exists = await fileExists(target);
|
|
26472
26476
|
const perFileAllowed = plan.overwritePolicy === "allow";
|
|
@@ -26495,7 +26499,7 @@ async function applyPlans(plans, opts) {
|
|
|
26495
26499
|
if (opts.rollback) {
|
|
26496
26500
|
for (const rel of created) {
|
|
26497
26501
|
try {
|
|
26498
|
-
await fs23.promises.unlink(
|
|
26502
|
+
await fs23.promises.unlink(path58__namespace.default.join(opts.root, rel));
|
|
26499
26503
|
} catch {
|
|
26500
26504
|
}
|
|
26501
26505
|
}
|
|
@@ -26616,7 +26620,7 @@ async function applyFixes(plans, opts) {
|
|
|
26616
26620
|
continue;
|
|
26617
26621
|
}
|
|
26618
26622
|
if (plan.action === "file.create") {
|
|
26619
|
-
const full =
|
|
26623
|
+
const full = path58.resolve(opts.cwd, plan.path);
|
|
26620
26624
|
try {
|
|
26621
26625
|
await fsp.access(full);
|
|
26622
26626
|
results.push({ plan, status: "skipped", message: "File exists" });
|
|
@@ -26629,7 +26633,7 @@ async function applyFixes(plans, opts) {
|
|
|
26629
26633
|
continue;
|
|
26630
26634
|
}
|
|
26631
26635
|
if (plan.action === "file.modify") {
|
|
26632
|
-
const full =
|
|
26636
|
+
const full = path58.resolve(opts.cwd, plan.path);
|
|
26633
26637
|
const st = await fsp.stat(full).catch(() => null);
|
|
26634
26638
|
if (!st) {
|
|
26635
26639
|
await ensureDir(full);
|
|
@@ -26646,7 +26650,7 @@ ${plan.diff ?? plan.content ?? ""}`;
|
|
|
26646
26650
|
continue;
|
|
26647
26651
|
}
|
|
26648
26652
|
if (plan.action === "file.json-merge") {
|
|
26649
|
-
const full =
|
|
26653
|
+
const full = path58.resolve(opts.cwd, plan.path);
|
|
26650
26654
|
const raw = await readFileSafe(full);
|
|
26651
26655
|
let json2 = {};
|
|
26652
26656
|
if (raw) {
|
|
@@ -26681,14 +26685,14 @@ function validatePath2(rel, cwd2) {
|
|
|
26681
26685
|
if (rel.includes("..")) return { valid: false, reason: "path traversal" };
|
|
26682
26686
|
if (rel.startsWith("/") || rel.includes("\\")) return { valid: false, reason: "absolute or backslashes not allowed" };
|
|
26683
26687
|
if (rel.startsWith(".env") || rel.endsWith(".pem") || rel.endsWith("id_rsa")) return { valid: false, reason: "sensitive path" };
|
|
26684
|
-
const full =
|
|
26685
|
-
const normCwd =
|
|
26686
|
-
const normFull =
|
|
26688
|
+
const full = path58.resolve(cwd2, rel);
|
|
26689
|
+
const normCwd = path58.normalize(cwd2) + path58.sep;
|
|
26690
|
+
const normFull = path58.normalize(full);
|
|
26687
26691
|
if (!normFull.startsWith(normCwd)) return { valid: false, reason: "outside cwd" };
|
|
26688
26692
|
return { valid: true };
|
|
26689
26693
|
}
|
|
26690
26694
|
async function ensureDir(fullPath) {
|
|
26691
|
-
const i2 = fullPath.lastIndexOf(
|
|
26695
|
+
const i2 = fullPath.lastIndexOf(path58.sep);
|
|
26692
26696
|
if (i2 <= 0) return;
|
|
26693
26697
|
const dir = fullPath.slice(0, i2);
|
|
26694
26698
|
try {
|
|
@@ -30810,12 +30814,12 @@ var init_esm4 = __esm({
|
|
|
30810
30814
|
/**
|
|
30811
30815
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
30812
30816
|
*/
|
|
30813
|
-
resolve(
|
|
30814
|
-
if (!
|
|
30817
|
+
resolve(path59) {
|
|
30818
|
+
if (!path59) {
|
|
30815
30819
|
return this;
|
|
30816
30820
|
}
|
|
30817
|
-
const rootPath = this.getRootString(
|
|
30818
|
-
const dir =
|
|
30821
|
+
const rootPath = this.getRootString(path59);
|
|
30822
|
+
const dir = path59.substring(rootPath.length);
|
|
30819
30823
|
const dirParts = dir.split(this.splitSep);
|
|
30820
30824
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
30821
30825
|
return result;
|
|
@@ -31567,8 +31571,8 @@ var init_esm4 = __esm({
|
|
|
31567
31571
|
/**
|
|
31568
31572
|
* @internal
|
|
31569
31573
|
*/
|
|
31570
|
-
getRootString(
|
|
31571
|
-
return
|
|
31574
|
+
getRootString(path59) {
|
|
31575
|
+
return path58.win32.parse(path59).root;
|
|
31572
31576
|
}
|
|
31573
31577
|
/**
|
|
31574
31578
|
* @internal
|
|
@@ -31614,8 +31618,8 @@ var init_esm4 = __esm({
|
|
|
31614
31618
|
/**
|
|
31615
31619
|
* @internal
|
|
31616
31620
|
*/
|
|
31617
|
-
getRootString(
|
|
31618
|
-
return
|
|
31621
|
+
getRootString(path59) {
|
|
31622
|
+
return path59.startsWith("/") ? "/" : "";
|
|
31619
31623
|
}
|
|
31620
31624
|
/**
|
|
31621
31625
|
* @internal
|
|
@@ -31704,11 +31708,11 @@ var init_esm4 = __esm({
|
|
|
31704
31708
|
/**
|
|
31705
31709
|
* Get the depth of a provided path, string, or the cwd
|
|
31706
31710
|
*/
|
|
31707
|
-
depth(
|
|
31708
|
-
if (typeof
|
|
31709
|
-
|
|
31711
|
+
depth(path59 = this.cwd) {
|
|
31712
|
+
if (typeof path59 === "string") {
|
|
31713
|
+
path59 = this.cwd.resolve(path59);
|
|
31710
31714
|
}
|
|
31711
|
-
return
|
|
31715
|
+
return path59.depth();
|
|
31712
31716
|
}
|
|
31713
31717
|
/**
|
|
31714
31718
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -32195,9 +32199,9 @@ var init_esm4 = __esm({
|
|
|
32195
32199
|
process11();
|
|
32196
32200
|
return results;
|
|
32197
32201
|
}
|
|
32198
|
-
chdir(
|
|
32202
|
+
chdir(path59 = this.cwd) {
|
|
32199
32203
|
const oldCwd = this.cwd;
|
|
32200
|
-
this.cwd = typeof
|
|
32204
|
+
this.cwd = typeof path59 === "string" ? this.cwd.resolve(path59) : path59;
|
|
32201
32205
|
this.cwd[setAsCwd](oldCwd);
|
|
32202
32206
|
}
|
|
32203
32207
|
};
|
|
@@ -32208,7 +32212,7 @@ var init_esm4 = __esm({
|
|
|
32208
32212
|
sep = "\\";
|
|
32209
32213
|
constructor(cwd2 = process.cwd(), opts = {}) {
|
|
32210
32214
|
const { nocase = true } = opts;
|
|
32211
|
-
super(cwd2,
|
|
32215
|
+
super(cwd2, path58.win32, "\\", { ...opts, nocase });
|
|
32212
32216
|
this.nocase = nocase;
|
|
32213
32217
|
for (let p = this.cwd; p; p = p.parent) {
|
|
32214
32218
|
p.nocase = this.nocase;
|
|
@@ -32218,7 +32222,7 @@ var init_esm4 = __esm({
|
|
|
32218
32222
|
* @internal
|
|
32219
32223
|
*/
|
|
32220
32224
|
parseRootPath(dir) {
|
|
32221
|
-
return
|
|
32225
|
+
return path58.win32.parse(dir).root.toUpperCase();
|
|
32222
32226
|
}
|
|
32223
32227
|
/**
|
|
32224
32228
|
* @internal
|
|
@@ -32240,7 +32244,7 @@ var init_esm4 = __esm({
|
|
|
32240
32244
|
sep = "/";
|
|
32241
32245
|
constructor(cwd2 = process.cwd(), opts = {}) {
|
|
32242
32246
|
const { nocase = false } = opts;
|
|
32243
|
-
super(cwd2,
|
|
32247
|
+
super(cwd2, path58.posix, "/", { ...opts, nocase });
|
|
32244
32248
|
this.nocase = nocase;
|
|
32245
32249
|
}
|
|
32246
32250
|
/**
|
|
@@ -32572,8 +32576,8 @@ var init_processor = __esm({
|
|
|
32572
32576
|
}
|
|
32573
32577
|
// match, absolute, ifdir
|
|
32574
32578
|
entries() {
|
|
32575
|
-
return [...this.store.entries()].map(([
|
|
32576
|
-
|
|
32579
|
+
return [...this.store.entries()].map(([path59, n]) => [
|
|
32580
|
+
path59,
|
|
32577
32581
|
!!(n & 2),
|
|
32578
32582
|
!!(n & 1)
|
|
32579
32583
|
]);
|
|
@@ -32786,9 +32790,9 @@ var init_walker = __esm({
|
|
|
32786
32790
|
signal;
|
|
32787
32791
|
maxDepth;
|
|
32788
32792
|
includeChildMatches;
|
|
32789
|
-
constructor(patterns,
|
|
32793
|
+
constructor(patterns, path59, opts) {
|
|
32790
32794
|
this.patterns = patterns;
|
|
32791
|
-
this.path =
|
|
32795
|
+
this.path = path59;
|
|
32792
32796
|
this.opts = opts;
|
|
32793
32797
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
32794
32798
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -32807,11 +32811,11 @@ var init_walker = __esm({
|
|
|
32807
32811
|
});
|
|
32808
32812
|
}
|
|
32809
32813
|
}
|
|
32810
|
-
#ignored(
|
|
32811
|
-
return this.seen.has(
|
|
32814
|
+
#ignored(path59) {
|
|
32815
|
+
return this.seen.has(path59) || !!this.#ignore?.ignored?.(path59);
|
|
32812
32816
|
}
|
|
32813
|
-
#childrenIgnored(
|
|
32814
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
32817
|
+
#childrenIgnored(path59) {
|
|
32818
|
+
return !!this.#ignore?.childrenIgnored?.(path59);
|
|
32815
32819
|
}
|
|
32816
32820
|
// backpressure mechanism
|
|
32817
32821
|
pause() {
|
|
@@ -33026,8 +33030,8 @@ var init_walker = __esm({
|
|
|
33026
33030
|
};
|
|
33027
33031
|
GlobWalker = class extends GlobUtil {
|
|
33028
33032
|
matches = /* @__PURE__ */ new Set();
|
|
33029
|
-
constructor(patterns,
|
|
33030
|
-
super(patterns,
|
|
33033
|
+
constructor(patterns, path59, opts) {
|
|
33034
|
+
super(patterns, path59, opts);
|
|
33031
33035
|
}
|
|
33032
33036
|
matchEmit(e2) {
|
|
33033
33037
|
this.matches.add(e2);
|
|
@@ -33064,8 +33068,8 @@ var init_walker = __esm({
|
|
|
33064
33068
|
};
|
|
33065
33069
|
GlobStream = class extends GlobUtil {
|
|
33066
33070
|
results;
|
|
33067
|
-
constructor(patterns,
|
|
33068
|
-
super(patterns,
|
|
33071
|
+
constructor(patterns, path59, opts) {
|
|
33072
|
+
super(patterns, path59, opts);
|
|
33069
33073
|
this.results = new Minipass({
|
|
33070
33074
|
signal: this.signal,
|
|
33071
33075
|
objectMode: true
|
|
@@ -33614,7 +33618,7 @@ ${usageLine}`;
|
|
|
33614
33618
|
async autoRegister(directory) {
|
|
33615
33619
|
logger.info(`Auto-registering commands from ${directory}`);
|
|
33616
33620
|
try {
|
|
33617
|
-
const pattern =
|
|
33621
|
+
const pattern = path58__namespace.join(directory, "**/*.command.{ts,js}");
|
|
33618
33622
|
const files = await glob(pattern);
|
|
33619
33623
|
logger.info(`Found ${files.length} command files`);
|
|
33620
33624
|
for (const file of files) {
|
|
@@ -34319,7 +34323,7 @@ ${fixPlan.note}` : ""));
|
|
|
34319
34323
|
async runConfigurationChecks(context2) {
|
|
34320
34324
|
const checks = [];
|
|
34321
34325
|
const cwd2 = context2.environment?.cwd || process.cwd();
|
|
34322
|
-
const packageJsonPath =
|
|
34326
|
+
const packageJsonPath = path58__namespace.join(cwd2, "package.json");
|
|
34323
34327
|
try {
|
|
34324
34328
|
await fsp__namespace.access(packageJsonPath);
|
|
34325
34329
|
const content = await fsp__namespace.readFile(packageJsonPath, "utf-8");
|
|
@@ -34345,7 +34349,7 @@ ${fixPlan.note}` : ""));
|
|
|
34345
34349
|
fixable: true
|
|
34346
34350
|
});
|
|
34347
34351
|
}
|
|
34348
|
-
const envPath =
|
|
34352
|
+
const envPath = path58__namespace.join(cwd2, ".env.local");
|
|
34349
34353
|
try {
|
|
34350
34354
|
await fsp__namespace.access(envPath);
|
|
34351
34355
|
checks.push({
|
|
@@ -34363,7 +34367,7 @@ ${fixPlan.note}` : ""));
|
|
|
34363
34367
|
fixable: true
|
|
34364
34368
|
});
|
|
34365
34369
|
}
|
|
34366
|
-
const gitPath =
|
|
34370
|
+
const gitPath = path58__namespace.join(cwd2, ".git");
|
|
34367
34371
|
try {
|
|
34368
34372
|
await fsp__namespace.access(gitPath);
|
|
34369
34373
|
checks.push({
|
|
@@ -34387,7 +34391,7 @@ ${fixPlan.note}` : ""));
|
|
|
34387
34391
|
async runDependencyChecks(context2) {
|
|
34388
34392
|
const checks = [];
|
|
34389
34393
|
const cwd2 = context2.environment?.cwd || process.cwd();
|
|
34390
|
-
const nodeModulesPath =
|
|
34394
|
+
const nodeModulesPath = path58__namespace.join(cwd2, "node_modules");
|
|
34391
34395
|
try {
|
|
34392
34396
|
await fsp__namespace.access(nodeModulesPath);
|
|
34393
34397
|
const stats = await fsp__namespace.stat(nodeModulesPath);
|
|
@@ -34619,7 +34623,7 @@ ${fixPlan.note}` : ""));
|
|
|
34619
34623
|
}
|
|
34620
34624
|
break;
|
|
34621
34625
|
case "CACHE_CORRUPT":
|
|
34622
|
-
const cacheDir =
|
|
34626
|
+
const cacheDir = path58__namespace.join(
|
|
34623
34627
|
context2.environment?.cwd || process.cwd(),
|
|
34624
34628
|
".maria",
|
|
34625
34629
|
"cache"
|
|
@@ -34638,7 +34642,7 @@ ${fixPlan.note}` : ""));
|
|
|
34638
34642
|
* Create environment template
|
|
34639
34643
|
*/
|
|
34640
34644
|
async createEnvTemplate(context2) {
|
|
34641
|
-
const envPath =
|
|
34645
|
+
const envPath = path58__namespace.join(
|
|
34642
34646
|
context2.environment?.cwd || process.cwd(),
|
|
34643
34647
|
".env.local"
|
|
34644
34648
|
);
|
|
@@ -34694,7 +34698,7 @@ LOG_LEVEL=info
|
|
|
34694
34698
|
async getSystemInfo(context2) {
|
|
34695
34699
|
let mariaVersion = "Unknown";
|
|
34696
34700
|
try {
|
|
34697
|
-
const packagePath =
|
|
34701
|
+
const packagePath = path58__namespace.join(
|
|
34698
34702
|
context2.environment?.cwd || process.cwd(),
|
|
34699
34703
|
"package.json"
|
|
34700
34704
|
);
|
|
@@ -36294,7 +36298,7 @@ var init_TerminalSetupCommand = __esm({
|
|
|
36294
36298
|
if (_shell.includes("fish")) return "fish";
|
|
36295
36299
|
if (_shell.includes("powershell")) return "powershell";
|
|
36296
36300
|
if (_shell.includes("cmd")) return "cmd";
|
|
36297
|
-
return
|
|
36301
|
+
return path58__namespace.basename(_shell) || "unknown";
|
|
36298
36302
|
}
|
|
36299
36303
|
generateTerminalRecommendations(type2, _features, _shell) {
|
|
36300
36304
|
const _recommendations = [];
|
|
@@ -36611,9 +36615,9 @@ function clampInt(v, min, max, name2) {
|
|
|
36611
36615
|
return Math.min(max, Math.max(min, Math.floor(n)));
|
|
36612
36616
|
}
|
|
36613
36617
|
function sanitizeOut(outDir, root) {
|
|
36614
|
-
const full =
|
|
36615
|
-
const rel =
|
|
36616
|
-
if (rel.startsWith("..") ||
|
|
36618
|
+
const full = path58__namespace.default.resolve(root, outDir);
|
|
36619
|
+
const rel = path58__namespace.default.relative(root, full);
|
|
36620
|
+
if (rel.startsWith("..") || path58__namespace.default.isAbsolute(rel)) throw new Error("out path escapes root");
|
|
36617
36621
|
return rel.replace(/\\/g, "/");
|
|
36618
36622
|
}
|
|
36619
36623
|
var init_Normalizer = __esm({
|
|
@@ -36625,15 +36629,15 @@ function ensureDirSync(p) {
|
|
|
36625
36629
|
fs23__namespace.mkdirSync(p, { recursive: true });
|
|
36626
36630
|
}
|
|
36627
36631
|
function safeJoin(root, ...segs) {
|
|
36628
|
-
const full =
|
|
36629
|
-
const rel =
|
|
36630
|
-
if (rel.startsWith("..") ||
|
|
36632
|
+
const full = path58__namespace.resolve(root, ...segs);
|
|
36633
|
+
const rel = path58__namespace.relative(root, full);
|
|
36634
|
+
if (rel.startsWith("..") || path58__namespace.isAbsolute(rel)) {
|
|
36631
36635
|
throw new Error(`path escapes root: ${segs.join("/")}`);
|
|
36632
36636
|
}
|
|
36633
36637
|
return { full, rel };
|
|
36634
36638
|
}
|
|
36635
36639
|
function stageDir(root, trace) {
|
|
36636
|
-
return
|
|
36640
|
+
return path58__namespace.join(root, `.stage/${trace}`);
|
|
36637
36641
|
}
|
|
36638
36642
|
async function existsSameHash(destFull) {
|
|
36639
36643
|
try {
|
|
@@ -36698,10 +36702,10 @@ async function saveArtifacts(ctx2, items, manifest) {
|
|
|
36698
36702
|
const fname = `${contentHash}${ext2}`;
|
|
36699
36703
|
const dest = safeJoin(root, `${outDirSeg}/${fname}`);
|
|
36700
36704
|
validateWinPathEdge(dest.full);
|
|
36701
|
-
if (await hasCaseInsensitiveCollision(
|
|
36705
|
+
if (await hasCaseInsensitiveCollision(path58__namespace.dirname(dest.full), path58__namespace.basename(dest.full))) {
|
|
36702
36706
|
throw new Error("case-insensitive filename collision");
|
|
36703
36707
|
}
|
|
36704
|
-
const stg =
|
|
36708
|
+
const stg = path58__namespace.join(stage, `${fname}.part`);
|
|
36705
36709
|
if (await existsSameHash(dest.full)) {
|
|
36706
36710
|
saved.push(dest.rel);
|
|
36707
36711
|
continue;
|
|
@@ -36714,10 +36718,10 @@ async function saveArtifacts(ctx2, items, manifest) {
|
|
|
36714
36718
|
manifestVersion: 1,
|
|
36715
36719
|
...manifest,
|
|
36716
36720
|
createdAt: manifest.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
36717
|
-
artifacts: manifest.artifacts && manifest.artifacts.length > 0 ? manifest.artifacts : saved.map((file) => ({ file, hash: `sha256:${
|
|
36721
|
+
artifacts: manifest.artifacts && manifest.artifacts.length > 0 ? manifest.artifacts : saved.map((file) => ({ file, hash: `sha256:${path58__namespace.basename(file).split(".")[0]}` }))
|
|
36718
36722
|
};
|
|
36719
36723
|
const manifestPathRel = `${outDirSeg}/manifest.json`;
|
|
36720
|
-
const manifestStage =
|
|
36724
|
+
const manifestStage = path58__namespace.join(stage, "manifest.json.part");
|
|
36721
36725
|
const manifestFull = safeJoin(root, manifestPathRel).full;
|
|
36722
36726
|
await fsp__namespace.writeFile(manifestStage, JSON.stringify(manifestObj, null, 2), "utf8");
|
|
36723
36727
|
await atomicRename(manifestStage, manifestFull);
|
|
@@ -37074,10 +37078,10 @@ var init_session = __esm({
|
|
|
37074
37078
|
this.root = root;
|
|
37075
37079
|
}
|
|
37076
37080
|
file() {
|
|
37077
|
-
return
|
|
37081
|
+
return path58__namespace.default.join(this.root, ".maria", "memory", "session.json");
|
|
37078
37082
|
}
|
|
37079
37083
|
lockFile() {
|
|
37080
|
-
return
|
|
37084
|
+
return path58__namespace.default.join(this.root, ".maria", "memory", ".session.lock");
|
|
37081
37085
|
}
|
|
37082
37086
|
load() {
|
|
37083
37087
|
try {
|
|
@@ -37092,7 +37096,7 @@ var init_session = __esm({
|
|
|
37092
37096
|
*/
|
|
37093
37097
|
save(data) {
|
|
37094
37098
|
const target = this.file();
|
|
37095
|
-
const dir =
|
|
37099
|
+
const dir = path58__namespace.default.dirname(target);
|
|
37096
37100
|
fs23__namespace.default.mkdirSync(dir, { recursive: true });
|
|
37097
37101
|
try {
|
|
37098
37102
|
this.rotateIfStale(target, 7 * 24 * 60 * 60 * 1e3);
|
|
@@ -37125,7 +37129,7 @@ var init_session = __esm({
|
|
|
37125
37129
|
const body = `${pid}
|
|
37126
37130
|
${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
37127
37131
|
const start = Date.now();
|
|
37128
|
-
fs23__namespace.default.mkdirSync(
|
|
37132
|
+
fs23__namespace.default.mkdirSync(path58__namespace.default.dirname(lockPath), { recursive: true });
|
|
37129
37133
|
const maxWaitTime = Date.now() + waitMs;
|
|
37130
37134
|
while (Date.now() < maxWaitTime) {
|
|
37131
37135
|
try {
|
|
@@ -37164,10 +37168,10 @@ ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
|
37164
37168
|
if (age > ttlMs) {
|
|
37165
37169
|
const d = new Date(st.mtimeMs);
|
|
37166
37170
|
const yyyymmdd = `${d.getUTCFullYear()}${String(d.getUTCMonth() + 1).padStart(2, "0")}${String(d.getUTCDate()).padStart(2, "0")}`;
|
|
37167
|
-
const archiveDir =
|
|
37171
|
+
const archiveDir = path58__namespace.default.join(path58__namespace.default.dirname(filePath), "archive", yyyymmdd);
|
|
37168
37172
|
fs23__namespace.default.mkdirSync(archiveDir, { recursive: true });
|
|
37169
37173
|
const ts = d.toISOString().replace(/[:]/g, "-");
|
|
37170
|
-
const dest =
|
|
37174
|
+
const dest = path58__namespace.default.join(archiveDir, `session-${ts}.json`);
|
|
37171
37175
|
fs23__namespace.default.renameSync(filePath, dest);
|
|
37172
37176
|
}
|
|
37173
37177
|
} catch {
|
|
@@ -37289,7 +37293,7 @@ var init_firestore = __esm({
|
|
|
37289
37293
|
return s2.slice(0, limit);
|
|
37290
37294
|
}
|
|
37291
37295
|
readLocal() {
|
|
37292
|
-
const sessionPath =
|
|
37296
|
+
const sessionPath = path58__namespace.default.join(this.cwd, ".maria", "memory", "session.json");
|
|
37293
37297
|
const candidates = [];
|
|
37294
37298
|
try {
|
|
37295
37299
|
const raw = JSON.parse(fs23__namespace.default.readFileSync(sessionPath, "utf8"));
|
|
@@ -37568,13 +37572,13 @@ async function hasFfmpeg() {
|
|
|
37568
37572
|
});
|
|
37569
37573
|
}
|
|
37570
37574
|
async function muxFramesToMp4(framesDir, fps) {
|
|
37571
|
-
const outFile =
|
|
37575
|
+
const outFile = path58__namespace.join(framesDir, `out-${Date.now()}.mp4`);
|
|
37572
37576
|
await execFfmpeg([
|
|
37573
37577
|
"-y",
|
|
37574
37578
|
"-framerate",
|
|
37575
37579
|
String(fps),
|
|
37576
37580
|
"-i",
|
|
37577
|
-
|
|
37581
|
+
path58__namespace.join(framesDir, "%06d.png"),
|
|
37578
37582
|
"-pix_fmt",
|
|
37579
37583
|
"yuv420p",
|
|
37580
37584
|
"-c:v",
|
|
@@ -37640,11 +37644,11 @@ async function runVideoPipeline(params2, opts) {
|
|
|
37640
37644
|
let saved;
|
|
37641
37645
|
let warnFallback = false;
|
|
37642
37646
|
if (frames.length > 0 && await hasFfmpeg()) {
|
|
37643
|
-
const tmpDir =
|
|
37647
|
+
const tmpDir = path58__namespace.join(opts.root, ".stage", manifest.trace || "FFMPEG");
|
|
37644
37648
|
await fsp__namespace.mkdir(tmpDir, { recursive: true });
|
|
37645
37649
|
for (let i2 = 0; i2 < frames.length; i2++) {
|
|
37646
37650
|
const fname = String(i2 + 1).padStart(6, "0") + ".png";
|
|
37647
|
-
await fsp__namespace.writeFile(
|
|
37651
|
+
await fsp__namespace.writeFile(path58__namespace.join(tmpDir, fname), frames[i2]);
|
|
37648
37652
|
}
|
|
37649
37653
|
const outBuf = await muxFramesToMp4(tmpDir, params2.fps);
|
|
37650
37654
|
saved = await saveArtifacts({ root: opts.root, kind: "video", baseDir: opts.outDir }, [{ bytes: outBuf, ext: ".mp4" }], manifest);
|
|
@@ -38348,13 +38352,746 @@ var init_WhoAmICommand = __esm({
|
|
|
38348
38352
|
}
|
|
38349
38353
|
});
|
|
38350
38354
|
|
|
38355
|
+
// src/services/base/TelemetryCollector.ts
|
|
38356
|
+
var TelemetryCollector2, telemetry;
|
|
38357
|
+
var init_TelemetryCollector = __esm({
|
|
38358
|
+
"src/services/base/TelemetryCollector.ts"() {
|
|
38359
|
+
TelemetryCollector2 = class _TelemetryCollector {
|
|
38360
|
+
_events = [];
|
|
38361
|
+
maxEvents = 1e4;
|
|
38362
|
+
_listeners = /* @__PURE__ */ new Map();
|
|
38363
|
+
metricsCache = /* @__PURE__ */ new Map();
|
|
38364
|
+
cacheExpiry = 6e4;
|
|
38365
|
+
// 1 minute cache
|
|
38366
|
+
lastCacheUpdate = 0;
|
|
38367
|
+
eventCounters = /* @__PURE__ */ new Map();
|
|
38368
|
+
static instance;
|
|
38369
|
+
constructor() {
|
|
38370
|
+
}
|
|
38371
|
+
/**
|
|
38372
|
+
* Get singleton instance
|
|
38373
|
+
*/
|
|
38374
|
+
static getInstance() {
|
|
38375
|
+
if (!_TelemetryCollector.instance) {
|
|
38376
|
+
_TelemetryCollector.instance = new _TelemetryCollector();
|
|
38377
|
+
}
|
|
38378
|
+
return _TelemetryCollector.instance;
|
|
38379
|
+
}
|
|
38380
|
+
/**
|
|
38381
|
+
* Emit a telemetry event
|
|
38382
|
+
*/
|
|
38383
|
+
emit(event) {
|
|
38384
|
+
const _telemetryEvent = {
|
|
38385
|
+
...event,
|
|
38386
|
+
ts: Date.now()
|
|
38387
|
+
};
|
|
38388
|
+
this._events.push(_telemetryEvent);
|
|
38389
|
+
if (this._events.length > this.maxEvents) {
|
|
38390
|
+
this._events = this._events.slice(-this.maxEvents);
|
|
38391
|
+
}
|
|
38392
|
+
const _counterKey = `${event.event}:${event.tags.comp}`;
|
|
38393
|
+
this.eventCounters.set(
|
|
38394
|
+
_counterKey,
|
|
38395
|
+
(this.eventCounters.get(_counterKey) ?? 0) + 1
|
|
38396
|
+
);
|
|
38397
|
+
this.lastCacheUpdate = 0;
|
|
38398
|
+
this.notifyListeners(_telemetryEvent);
|
|
38399
|
+
if (process.env.DEBUG_TELEMETRY === "true") {
|
|
38400
|
+
this.logEvent(_telemetryEvent);
|
|
38401
|
+
}
|
|
38402
|
+
}
|
|
38403
|
+
/**
|
|
38404
|
+
* Start a timed operation
|
|
38405
|
+
*/
|
|
38406
|
+
startTimer(event, tags) {
|
|
38407
|
+
const _startTime = Date.now();
|
|
38408
|
+
this.emit({
|
|
38409
|
+
event,
|
|
38410
|
+
tags
|
|
38411
|
+
});
|
|
38412
|
+
return () => {
|
|
38413
|
+
const _duration = Date.now() - _startTime;
|
|
38414
|
+
this.emit({
|
|
38415
|
+
event: event.replace(".start", ".end"),
|
|
38416
|
+
dur: _duration,
|
|
38417
|
+
tags
|
|
38418
|
+
});
|
|
38419
|
+
};
|
|
38420
|
+
}
|
|
38421
|
+
/**
|
|
38422
|
+
* Record an _error
|
|
38423
|
+
*/
|
|
38424
|
+
recordError(component, _error, context2) {
|
|
38425
|
+
const _errorData = this.extractErrorData(_error);
|
|
38426
|
+
this.emit({
|
|
38427
|
+
event: "system.error" /* SYSTEM_ERROR */,
|
|
38428
|
+
tags: { _comp: component },
|
|
38429
|
+
meta: context2,
|
|
38430
|
+
_error: _errorData
|
|
38431
|
+
});
|
|
38432
|
+
}
|
|
38433
|
+
/**
|
|
38434
|
+
* Subscribe to _events
|
|
38435
|
+
*/
|
|
38436
|
+
subscribe(pattern, _listener) {
|
|
38437
|
+
const _key = pattern.toString();
|
|
38438
|
+
if (!this._listeners.has(_key)) {
|
|
38439
|
+
this._listeners.set(_key, /* @__PURE__ */ new Set());
|
|
38440
|
+
}
|
|
38441
|
+
this._listeners.get(_key).add(_listener);
|
|
38442
|
+
return () => {
|
|
38443
|
+
const _listeners = this._listeners.get(_key);
|
|
38444
|
+
if (_listeners) {
|
|
38445
|
+
_listeners.delete(_listener);
|
|
38446
|
+
if (_listeners.size === 0) {
|
|
38447
|
+
this._listeners.delete(_key);
|
|
38448
|
+
}
|
|
38449
|
+
}
|
|
38450
|
+
};
|
|
38451
|
+
}
|
|
38452
|
+
/**
|
|
38453
|
+
* Get _metrics for a component
|
|
38454
|
+
*/
|
|
38455
|
+
getMetrics(component, window = 6e4) {
|
|
38456
|
+
const _now = Date._now();
|
|
38457
|
+
const _cacheKey = `${component ?? "all"}:${window}`;
|
|
38458
|
+
if (_now - this.lastCacheUpdate < this.cacheExpiry) {
|
|
38459
|
+
const _cached = this.metricsCache.get(_cacheKey);
|
|
38460
|
+
if (_cached) {
|
|
38461
|
+
return _cached;
|
|
38462
|
+
}
|
|
38463
|
+
}
|
|
38464
|
+
const _metrics = component ? this.calculateMetrics(component, window) : this.calculateAllMetrics(window);
|
|
38465
|
+
this.metricsCache.set(_cacheKey, _metrics);
|
|
38466
|
+
this.lastCacheUpdate = _now;
|
|
38467
|
+
return _metrics;
|
|
38468
|
+
}
|
|
38469
|
+
/**
|
|
38470
|
+
* Calculate _metrics for a component
|
|
38471
|
+
*/
|
|
38472
|
+
calculateMetrics(component, window) {
|
|
38473
|
+
const _now = Date._now();
|
|
38474
|
+
const _relevant = this._events.filter(
|
|
38475
|
+
(e2) => _now - e2.ts < window && e2.tags.comp === component
|
|
38476
|
+
);
|
|
38477
|
+
const _durations = _relevant.filter((e2) => e2.dur !== void 0).map((e2) => e2.dur).sort((a, b) => a - b);
|
|
38478
|
+
const _errors = _relevant.filter((e2) => e2._error !== void 0);
|
|
38479
|
+
return {
|
|
38480
|
+
eventCount: _relevant.length,
|
|
38481
|
+
errorCount: _errors.length,
|
|
38482
|
+
avgDuration: this.calculateAverage(_durations),
|
|
38483
|
+
p50Duration: this.calculatePercentile(_durations, 0.5),
|
|
38484
|
+
p95Duration: this.calculatePercentile(_durations, 0.95),
|
|
38485
|
+
p99Duration: this.calculatePercentile(_durations, 0.99),
|
|
38486
|
+
errorRate: _relevant.length > 0 ? _errors.length / _relevant.length : 0,
|
|
38487
|
+
throughput: _relevant.length / (window / 1e3)
|
|
38488
|
+
// _events per second
|
|
38489
|
+
};
|
|
38490
|
+
}
|
|
38491
|
+
/**
|
|
38492
|
+
* Calculate _metrics for all _components
|
|
38493
|
+
*/
|
|
38494
|
+
calculateAllMetrics(window) {
|
|
38495
|
+
const _components = ["memory", "kg", "conv", "learn", "system"];
|
|
38496
|
+
const _metrics = {};
|
|
38497
|
+
for (const _comp of _components) {
|
|
38498
|
+
_metrics[_comp] = this.calculateMetrics(_comp, window);
|
|
38499
|
+
}
|
|
38500
|
+
return _metrics;
|
|
38501
|
+
}
|
|
38502
|
+
/**
|
|
38503
|
+
* Calculate average
|
|
38504
|
+
*/
|
|
38505
|
+
calculateAverage(values) {
|
|
38506
|
+
if (values.length === 0) return 0;
|
|
38507
|
+
const _sum = values.reduce((a, b) => a + b, 0);
|
|
38508
|
+
return _sum / values.length;
|
|
38509
|
+
}
|
|
38510
|
+
/**
|
|
38511
|
+
* Calculate percentile
|
|
38512
|
+
*/
|
|
38513
|
+
calculatePercentile(sortedValues, percentile) {
|
|
38514
|
+
if (sortedValues.length === 0) return 0;
|
|
38515
|
+
const _index = Math.floor(sortedValues.length * percentile);
|
|
38516
|
+
return sortedValues[Math.min(_index, sortedValues.length - 1)];
|
|
38517
|
+
}
|
|
38518
|
+
/**
|
|
38519
|
+
* Extract _error data
|
|
38520
|
+
*/
|
|
38521
|
+
extractErrorData(_error) {
|
|
38522
|
+
if (_error instanceof Error) {
|
|
38523
|
+
return {
|
|
38524
|
+
message: _error.message,
|
|
38525
|
+
stack: _error.stack,
|
|
38526
|
+
code: _error.code
|
|
38527
|
+
};
|
|
38528
|
+
}
|
|
38529
|
+
return {
|
|
38530
|
+
message: String(_error)
|
|
38531
|
+
};
|
|
38532
|
+
}
|
|
38533
|
+
/**
|
|
38534
|
+
* Notify _listeners
|
|
38535
|
+
*/
|
|
38536
|
+
notifyListeners(event) {
|
|
38537
|
+
for (const [_pattern, _listeners] of this._listeners.entries()) {
|
|
38538
|
+
const _regex = _pattern.startsWith("/") ? new RegExp(_pattern.slice(1, -1)) : new RegExp(_pattern);
|
|
38539
|
+
if (_regex.test(event.event)) {
|
|
38540
|
+
for (const _listener of _listeners) {
|
|
38541
|
+
try {
|
|
38542
|
+
_listener(event);
|
|
38543
|
+
} catch (_error) {
|
|
38544
|
+
console._error("Telemetry _listener _error:", _error);
|
|
38545
|
+
}
|
|
38546
|
+
}
|
|
38547
|
+
}
|
|
38548
|
+
}
|
|
38549
|
+
}
|
|
38550
|
+
/**
|
|
38551
|
+
* Log event for debugging
|
|
38552
|
+
*/
|
|
38553
|
+
logEvent(event) {
|
|
38554
|
+
const _formatted = {
|
|
38555
|
+
event: event.event,
|
|
38556
|
+
component: event.tags.comp,
|
|
38557
|
+
_duration: event.dur,
|
|
38558
|
+
tags: Object.entries(event.tags).filter(([k]) => k !== "_comp").map(([k, v]) => `${k}=${v}`).join(" "),
|
|
38559
|
+
meta: event.meta ? JSON.stringify(event.meta) : void 0,
|
|
38560
|
+
_error: event._error?.message
|
|
38561
|
+
};
|
|
38562
|
+
console.log("[TEL]", JSON.stringify(_formatted));
|
|
38563
|
+
}
|
|
38564
|
+
/**
|
|
38565
|
+
* Export _events for analysis
|
|
38566
|
+
*/
|
|
38567
|
+
exportEvents(filter2) {
|
|
38568
|
+
let _events = [...this._events];
|
|
38569
|
+
if (filter2) {
|
|
38570
|
+
if (filter2.component) {
|
|
38571
|
+
_events = _events.filter((e2) => e2.tags.comp === filter2.component);
|
|
38572
|
+
}
|
|
38573
|
+
if (filter2._startTime) {
|
|
38574
|
+
_events = _events.filter((e2) => e2.ts >= filter2._startTime);
|
|
38575
|
+
}
|
|
38576
|
+
if (filter2.endTime) {
|
|
38577
|
+
_events = _events.filter((e2) => e2.ts <= filter2.endTime);
|
|
38578
|
+
}
|
|
38579
|
+
if (filter2.event) {
|
|
38580
|
+
const _regex = filter2.event instanceof RegExp ? filter2.event : new RegExp(filter2.event);
|
|
38581
|
+
_events = _events.filter((e2) => _regex.test(e2.event));
|
|
38582
|
+
}
|
|
38583
|
+
}
|
|
38584
|
+
return _events;
|
|
38585
|
+
}
|
|
38586
|
+
/**
|
|
38587
|
+
* Clear all _events
|
|
38588
|
+
*/
|
|
38589
|
+
clear() {
|
|
38590
|
+
this._events = [];
|
|
38591
|
+
this.metricsCache.clear();
|
|
38592
|
+
this.eventCounters.clear();
|
|
38593
|
+
this.lastCacheUpdate = 0;
|
|
38594
|
+
}
|
|
38595
|
+
/**
|
|
38596
|
+
* Get event _counts by type
|
|
38597
|
+
*/
|
|
38598
|
+
getEventCounts() {
|
|
38599
|
+
return new Map(this.eventCounters);
|
|
38600
|
+
}
|
|
38601
|
+
/**
|
|
38602
|
+
* Generate summary _report
|
|
38603
|
+
*/
|
|
38604
|
+
generateReport(window = 3e5) {
|
|
38605
|
+
const _metrics = this.getMetrics(void 0, window);
|
|
38606
|
+
const _counts = this.getEventCounts();
|
|
38607
|
+
let _report = "=".repeat(80) + "\n";
|
|
38608
|
+
_report += "TELEMETRY REPORT\n";
|
|
38609
|
+
_report += "=".repeat(80) + "\n\n";
|
|
38610
|
+
for (const [_comp, _met] of Object.entries(_metrics)) {
|
|
38611
|
+
_report += `Component: ${_comp.toUpperCase()}
|
|
38612
|
+
`;
|
|
38613
|
+
_report += "-".repeat(40) + "\n";
|
|
38614
|
+
_report += ` Events: ${_met.eventCount}
|
|
38615
|
+
`;
|
|
38616
|
+
_report += ` Errors: ${_met.errorCount} (${(_met.errorRate * 100).toFixed(2)}%)
|
|
38617
|
+
`;
|
|
38618
|
+
_report += ` Avg Duration: ${_met.avgDuration.toFixed(2)}ms
|
|
38619
|
+
`;
|
|
38620
|
+
_report += ` P95 Duration: ${_met.p95Duration.toFixed(2)}ms
|
|
38621
|
+
`;
|
|
38622
|
+
_report += ` Throughput: ${_met.throughput.toFixed(2)} _events/sec
|
|
38623
|
+
`;
|
|
38624
|
+
_report += "\n";
|
|
38625
|
+
}
|
|
38626
|
+
_report += "TOP EVENTS\n";
|
|
38627
|
+
_report += "-".repeat(40) + "\n";
|
|
38628
|
+
const _topEvents = Array.from(_counts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 10);
|
|
38629
|
+
for (const [_event, _count] of _topEvents) {
|
|
38630
|
+
_report += ` ${_event}: ${_count}
|
|
38631
|
+
`;
|
|
38632
|
+
}
|
|
38633
|
+
_report += "\n" + "=".repeat(80);
|
|
38634
|
+
return _report;
|
|
38635
|
+
}
|
|
38636
|
+
};
|
|
38637
|
+
telemetry = TelemetryCollector2.getInstance();
|
|
38638
|
+
}
|
|
38639
|
+
});
|
|
38640
|
+
function resolveArtifactRoot() {
|
|
38641
|
+
return process.env.MARIA_IDENTITY_ROOT ? path58__namespace.default.resolve(process.env.MARIA_IDENTITY_ROOT) : process.cwd();
|
|
38642
|
+
}
|
|
38643
|
+
function normalizeLocale(locale) {
|
|
38644
|
+
if (!locale) return DEFAULT_LOCALE;
|
|
38645
|
+
const normalized = locale.toLowerCase();
|
|
38646
|
+
if (normalized.startsWith("ja")) return "ja";
|
|
38647
|
+
if (normalized.startsWith("zh")) return "zh";
|
|
38648
|
+
if (normalized.startsWith("ko")) return "ko";
|
|
38649
|
+
if (normalized.startsWith("vi")) return "vi";
|
|
38650
|
+
if (normalized.startsWith("en")) return "en";
|
|
38651
|
+
return DEFAULT_LOCALE;
|
|
38652
|
+
}
|
|
38653
|
+
function formatList2(items, locale) {
|
|
38654
|
+
if (items.length === 0) {
|
|
38655
|
+
return "";
|
|
38656
|
+
}
|
|
38657
|
+
const limited = items.slice(0, DEFAULT_COMMAND_LIMIT);
|
|
38658
|
+
const ellipsis = items.length > DEFAULT_COMMAND_LIMIT;
|
|
38659
|
+
switch (locale) {
|
|
38660
|
+
case "ja":
|
|
38661
|
+
return `${limited.join("\u3001")}\u306A\u3069`;
|
|
38662
|
+
case "zh":
|
|
38663
|
+
return `${limited.join("\u3001")}\u7B49`;
|
|
38664
|
+
case "ko":
|
|
38665
|
+
return `${limited.join(", ")} \uB4F1`;
|
|
38666
|
+
case "vi":
|
|
38667
|
+
return ellipsis ? `${limited.join(", ")} ...` : limited.join(", ");
|
|
38668
|
+
default:
|
|
38669
|
+
if (limited.length === 1) {
|
|
38670
|
+
return limited[0];
|
|
38671
|
+
}
|
|
38672
|
+
if (limited.length === 2) {
|
|
38673
|
+
return `${limited[0]} and ${limited[1]}` + (ellipsis ? " etc." : "");
|
|
38674
|
+
}
|
|
38675
|
+
const rest = limited.slice(0, -1).join(", ");
|
|
38676
|
+
const last = limited[limited.length - 1];
|
|
38677
|
+
return `${rest}, and ${last}` + (ellipsis ? " etc." : "");
|
|
38678
|
+
}
|
|
38679
|
+
}
|
|
38680
|
+
function buildSentence(locale, commands) {
|
|
38681
|
+
const list = formatList2(commands, locale);
|
|
38682
|
+
switch (locale) {
|
|
38683
|
+
case "ja":
|
|
38684
|
+
return `READY\u30B3\u30DE\u30F3\u30C9\uFF08\u4F8B\uFF1A${list}\uFF09\u3092\u4E2D\u5FC3\u306B\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002`;
|
|
38685
|
+
case "zh":
|
|
38686
|
+
return `\u6211\u4E3B\u8981\u652F\u6301 READY \u547D\u4EE4\uFF0C\u4F8B\u5982\uFF1A${list}\u3002`;
|
|
38687
|
+
case "ko":
|
|
38688
|
+
return `READY\uB85C \uD45C\uAE30\uB41C \uBA85\uB839(${list})\uC744 \uC911\uC2EC\uC73C\uB85C \uC9C0\uC6D0\uD569\uB2C8\uB2E4.`;
|
|
38689
|
+
case "vi":
|
|
38690
|
+
return `T\xF4i h\u1ED7 tr\u1EE3 c\xE1c l\u1EC7nh READY nh\u01B0: ${list}.`;
|
|
38691
|
+
default:
|
|
38692
|
+
return `I focus on READY commands like ${list}.`;
|
|
38693
|
+
}
|
|
38694
|
+
}
|
|
38695
|
+
var DEFAULT_TEMPLATE_VERSION, ARTIFACT_CACHE_TTL, DEFAULT_COMMAND_LIMIT, DEFAULT_TEMPLATES, HELP_LINES, NEXT_STEPS, DEGRADED_HEADER, DEGRADED_BODY, DEFAULT_NEXT_STEPS, DEFAULT_LOCALE, IdentityRenderer, identityRenderer;
|
|
38696
|
+
var init_identity_renderer = __esm({
|
|
38697
|
+
"src/services/identity/identity-renderer.ts"() {
|
|
38698
|
+
init_logger();
|
|
38699
|
+
init_TelemetryCollector();
|
|
38700
|
+
DEFAULT_TEMPLATE_VERSION = "v1.0.0";
|
|
38701
|
+
ARTIFACT_CACHE_TTL = 6e4;
|
|
38702
|
+
DEFAULT_COMMAND_LIMIT = 16;
|
|
38703
|
+
DEFAULT_TEMPLATES = {
|
|
38704
|
+
en: "I'm Maria Code \u2014 a large language model fully trained by Bonginkan. I support this workspace as a developer partner. I focus on the READY commands listed in `/help`, including <skills>. If you need something outside the READY set, I'll confirm what's supported first.",
|
|
38705
|
+
ja: "\u79C1\u306FMaria Code\uFF08Bonginkan\u306B\u3088\u3063\u3066\u5B8C\u5168\u306B\u8A13\u7DF4\u3055\u308C\u305F\u5927\u898F\u6A21\u8A00\u8A9E\u30E2\u30C7\u30EB\uFF09\u3067\u3059\u3002\u958B\u767A\u30D1\u30FC\u30C8\u30CA\u30FC\u3068\u3057\u3066\u3053\u306E\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3092\u652F\u63F4\u3057\u307E\u3059\u3002`/help`\u3067\u78BA\u8A8D\u3067\u304D\u308BREADY\u30B3\u30DE\u30F3\u30C9\uFF08\u4F8B\uFF1A<skills>\uFF09\u3092\u4E2D\u5FC3\u306B\u5BFE\u5FDC\u3057\u307E\u3059\u3002\u7BC4\u56F2\u5916\u306E\u4F9D\u983C\u306F\u3001\u307E\u305A\u5BFE\u5FDC\u53EF\u5426\u3092\u4E00\u7DD2\u306B\u78BA\u8A8D\u3057\u307E\u3059\u3002",
|
|
38706
|
+
zh: "\u6211\u662F Maria Code\uFF08\u7531 Bonginkan \u5B8C\u6574\u8BAD\u7EC3\u7684\u5927\u578B\u8BED\u8A00\u6A21\u578B\uFF09\u3002\u6211\u5728\u6B64\u5DE5\u4F5C\u533A\u4EE5\u5F00\u53D1\u4F19\u4F34\u7684\u8EAB\u4EFD\u63D0\u4F9B\u534F\u52A9\u3002\u6211\u4E3B\u8981\u652F\u6301 `/help` \u4E2D\u5217\u51FA\u7684 READY \u547D\u4EE4\uFF08\u5982\uFF1A<skills>\uFF09\u3002\u5982\u679C\u9700\u6C42\u8D85\u51FA\u8303\u56F4\uFF0C\u6211\u4EEC\u4F1A\u5148\u786E\u8BA4\u662F\u5426\u53D7\u652F\u6301\u3002",
|
|
38707
|
+
ko: "\uC800\uB294 Maria Code(\uBD09\uAE34\uCE78\uC774 \uC644\uC804\uD788 \uD559\uC2B5\uD55C \uB300\uADDC\uBAA8 \uC5B8\uC5B4 \uBAA8\uB378)\uC785\uB2C8\uB2E4. \uC774 \uC6CC\uD06C\uC2A4\uD398\uC774\uC2A4\uC5D0\uC11C \uAC1C\uBC1C \uD30C\uD2B8\uB108\uB85C \uC9C0\uC6D0\uD569\uB2C8\uB2E4. `/help`\uC5D0 READY\uB85C \uD45C\uC2DC\uB41C \uBA85\uB839(\uC608: <skills>)\uC744 \uC911\uC2EC\uC73C\uB85C \uB3C4\uC640\uB4DC\uB9BD\uB2C8\uB2E4. \uBC94\uC704\uB97C \uBC97\uC5B4\uB098\uB294 \uC694\uCCAD\uC740 \uAC00\uB2A5 \uC5EC\uBD80\uBD80\uD130 \uD568\uAED8 \uD655\uC778\uD569\uB2C8\uB2E4.",
|
|
38708
|
+
vi: "T\xF4i l\xE0 Maria Code \u2014 m\xF4 h\xECnh ng\xF4n ng\u1EEF l\u1EDBn \u0111\u01B0\u1EE3c Bonginkan hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7. T\xF4i h\u1ED7 tr\u1EE3 workspace n\xE0y nh\u01B0 m\u1ED9t c\u1ED9ng s\u1EF1 ph\xE1t tri\u1EC3n. T\xF4i t\u1EADp trung v\xE0o c\xE1c l\u1EC7nh READY trong `/help`, ch\u1EB3ng h\u1EA1n nh\u01B0 <skills>. N\u1EBFu y\xEAu c\u1EA7u n\u1EB1m ngo\xE0i ph\u1EA1m vi, ch\xFAng ta s\u1EBD ki\u1EC3m tra tr\u01B0\u1EDBc kh\u1EA3 n\u0103ng h\u1ED7 tr\u1EE3 nh\xE9."
|
|
38709
|
+
};
|
|
38710
|
+
HELP_LINES = {
|
|
38711
|
+
en: "See available skills with /help",
|
|
38712
|
+
ja: "\u5229\u7528\u53EF\u80FD\u306A\u30B3\u30DE\u30F3\u30C9\u306F /help \u3067\u78BA\u8A8D\u3067\u304D\u307E\u3059",
|
|
38713
|
+
zh: "\u53EF\u901A\u8FC7 /help \u67E5\u770B\u6240\u6709\u53EF\u7528\u547D\u4EE4",
|
|
38714
|
+
ko: "/help \uB85C \uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uBA85\uB839\uC744 \uD655\uC778\uD558\uC138\uC694",
|
|
38715
|
+
vi: "Xem c\xE1c l\u1EC7nh h\u1ED7 tr\u1EE3 t\u1EA1i /help"
|
|
38716
|
+
};
|
|
38717
|
+
NEXT_STEPS = {
|
|
38718
|
+
en: [
|
|
38719
|
+
"See available skills with /help",
|
|
38720
|
+
"Describe your goal in one line; I'll route you to the right workflow"
|
|
38721
|
+
],
|
|
38722
|
+
ja: [
|
|
38723
|
+
"/help \u3067\u5229\u7528\u53EF\u80FD\u306A\u30B3\u30DE\u30F3\u30C9\u3092\u78BA\u8A8D",
|
|
38724
|
+
"\u3084\u308A\u305F\u3044\u3053\u3068\u3092\u4E00\u884C\u3067\u6559\u3048\u3066\u304F\u3060\u3055\u3044\u3002\u6700\u9069\u306A\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC\u306B\u6848\u5185\u3057\u307E\u3059"
|
|
38725
|
+
],
|
|
38726
|
+
zh: [
|
|
38727
|
+
"\u4F7F\u7528 /help \u67E5\u770B\u53EF\u7528\u547D\u4EE4",
|
|
38728
|
+
"\u7528\u4E00\u53E5\u8BDD\u63CF\u8FF0\u76EE\u6807\uFF0C\u6211\u4F1A\u5F15\u5BFC\u4F60\u8FDB\u5165\u5408\u9002\u7684\u6D41\u7A0B"
|
|
38729
|
+
],
|
|
38730
|
+
ko: [
|
|
38731
|
+
"/help \uB85C \uC0AC\uC6A9 \uAC00\uB2A5\uD55C \uBA85\uB839 \uD655\uC778",
|
|
38732
|
+
"\uC6D0\uD558\uB294 \uBAA9\uD45C\uB97C \uD55C \uC904\uB85C \uC54C\uB824\uC8FC\uC138\uC694. \uB9DE\uB294 \uC6CC\uD06C\uD50C\uB85C\uB85C \uC548\uB0B4\uD569\uB2C8\uB2E4"
|
|
38733
|
+
],
|
|
38734
|
+
vi: [
|
|
38735
|
+
"Xem c\xE1c l\u1EC7nh h\u1ED7 tr\u1EE3 b\u1EB1ng /help",
|
|
38736
|
+
"M\xF4 t\u1EA3 m\u1EE5c ti\xEAu trong m\u1ED9t c\xE2u, t\xF4i s\u1EBD h\u01B0\u1EDBng b\u1EA1n t\u1EDBi quy tr\xECnh ph\xF9 h\u1EE3p"
|
|
38737
|
+
]
|
|
38738
|
+
};
|
|
38739
|
+
DEGRADED_HEADER = {
|
|
38740
|
+
en: "WARN: Identity service degraded",
|
|
38741
|
+
ja: "WARN: Identity\u30B5\u30FC\u30D3\u30B9\u306E\u5229\u7528\u306B\u5236\u9650\u304C\u3042\u308A\u307E\u3059",
|
|
38742
|
+
zh: "WARN: \u8EAB\u4EFD\u670D\u52A1\u5904\u4E8E\u964D\u7EA7\u6A21\u5F0F",
|
|
38743
|
+
ko: "WARN: ID \uC11C\uBE44\uC2A4\uAC00 \uCD95\uC18C \uBAA8\uB4DC\uC785\uB2C8\uB2E4",
|
|
38744
|
+
vi: "WARN: D\u1ECBch v\u1EE5 nh\u1EADn di\u1EC7n \u0111ang b\u1ECB suy gi\u1EA3m"
|
|
38745
|
+
};
|
|
38746
|
+
DEGRADED_BODY = {
|
|
38747
|
+
en: "I'm Maria Code \u2014 a large language model fully trained by Bonginkan.",
|
|
38748
|
+
ja: "\u79C1\u306FMaria Code\uFF08Bonginkan\u306B\u3088\u3063\u3066\u5B8C\u5168\u306B\u8A13\u7DF4\u3055\u308C\u305F\u5927\u898F\u6A21\u8A00\u8A9E\u30E2\u30C7\u30EB\uFF09\u3067\u3059\u3002",
|
|
38749
|
+
zh: "\u6211\u662F Maria Code\uFF08\u7531 Bonginkan \u5B8C\u6574\u8BAD\u7EC3\u7684\u5927\u578B\u8BED\u8A00\u6A21\u578B\uFF09\u3002",
|
|
38750
|
+
ko: "\uC800\uB294 Maria Code(\uBD09\uAE34\uCE78\uC774 \uC644\uC804\uD788 \uD559\uC2B5\uD55C \uB300\uADDC\uBAA8 \uC5B8\uC5B4 \uBAA8\uB378)\uC785\uB2C8\uB2E4.",
|
|
38751
|
+
vi: "T\xF4i l\xE0 Maria Code \u2014 m\xF4 h\xECnh ng\xF4n ng\u1EEF l\u1EDBn \u0111\u01B0\u1EE3c Bonginkan hu\u1EA5n luy\u1EC7n \u0111\u1EA7y \u0111\u1EE7."
|
|
38752
|
+
};
|
|
38753
|
+
DEFAULT_NEXT_STEPS = [
|
|
38754
|
+
"See available skills with /help",
|
|
38755
|
+
"Describe your goal in one line; I'll route you to the right workflow"
|
|
38756
|
+
];
|
|
38757
|
+
DEFAULT_LOCALE = "en";
|
|
38758
|
+
IdentityRenderer = class _IdentityRenderer {
|
|
38759
|
+
static instance;
|
|
38760
|
+
skillsCache = null;
|
|
38761
|
+
templateCache = null;
|
|
38762
|
+
lastHashes = /* @__PURE__ */ new Map();
|
|
38763
|
+
static getInstance() {
|
|
38764
|
+
if (!_IdentityRenderer.instance) {
|
|
38765
|
+
_IdentityRenderer.instance = new _IdentityRenderer();
|
|
38766
|
+
}
|
|
38767
|
+
return _IdentityRenderer.instance;
|
|
38768
|
+
}
|
|
38769
|
+
async render(options = {}) {
|
|
38770
|
+
const startedAt = Date.now();
|
|
38771
|
+
const locale = normalizeLocale(options.locale);
|
|
38772
|
+
const format = options.format ?? "text";
|
|
38773
|
+
const isTTY = options.isTTY ?? Boolean(process.stdout?.isTTY);
|
|
38774
|
+
const timer = telemetry.startTimer("identity.answer_rendered.start", {
|
|
38775
|
+
_comp: "system",
|
|
38776
|
+
locale,
|
|
38777
|
+
format,
|
|
38778
|
+
source: options.source ?? "cli"
|
|
38779
|
+
});
|
|
38780
|
+
const skills = await this.resolveSkills(locale);
|
|
38781
|
+
const template = await this.resolveTemplate(locale);
|
|
38782
|
+
const degraded = skills.degraded || template.degraded;
|
|
38783
|
+
const degradationReason = skills.reason ?? template.reason;
|
|
38784
|
+
const previousHash = this.lastHashes.get(locale);
|
|
38785
|
+
this.lastHashes.set(locale, skills.hash);
|
|
38786
|
+
const templateVersion = template.version || DEFAULT_TEMPLATE_VERSION;
|
|
38787
|
+
const identityVersion = templateVersion;
|
|
38788
|
+
const persona = template.template.replace("<skills>", skills.sentence);
|
|
38789
|
+
const message = this.composeMessage({
|
|
38790
|
+
locale,
|
|
38791
|
+
persona,
|
|
38792
|
+
skillsSentence: skills.sentence,
|
|
38793
|
+
isTTY,
|
|
38794
|
+
degraded,
|
|
38795
|
+
includeWarningHeader: options.includeWarningHeader ?? degraded,
|
|
38796
|
+
reason: degradationReason
|
|
38797
|
+
});
|
|
38798
|
+
const jsonPayload = format === "json" ? {
|
|
38799
|
+
locale,
|
|
38800
|
+
identityVersion,
|
|
38801
|
+
skillsSentence: skills.sentence,
|
|
38802
|
+
skillsHash: skills.hash,
|
|
38803
|
+
degraded,
|
|
38804
|
+
previousSkillsHash: previousHash,
|
|
38805
|
+
templateVersion,
|
|
38806
|
+
degradationReason
|
|
38807
|
+
} : void 0;
|
|
38808
|
+
const latency = Date.now() - startedAt;
|
|
38809
|
+
telemetry.emit({
|
|
38810
|
+
event: "identity.answer_rendered",
|
|
38811
|
+
tags: {
|
|
38812
|
+
_comp: "system",
|
|
38813
|
+
locale,
|
|
38814
|
+
format,
|
|
38815
|
+
source: options.source ?? "cli"
|
|
38816
|
+
},
|
|
38817
|
+
meta: {
|
|
38818
|
+
templateVersion,
|
|
38819
|
+
skillsHash: skills.hash,
|
|
38820
|
+
previousSkillsHash: previousHash,
|
|
38821
|
+
degraded,
|
|
38822
|
+
latencyMs: latency,
|
|
38823
|
+
reason: degradationReason
|
|
38824
|
+
}
|
|
38825
|
+
});
|
|
38826
|
+
timer();
|
|
38827
|
+
return {
|
|
38828
|
+
message: format === "json" && jsonPayload ? JSON.stringify(jsonPayload, null, 2) : message,
|
|
38829
|
+
json: jsonPayload,
|
|
38830
|
+
metadata: {
|
|
38831
|
+
locale,
|
|
38832
|
+
templateVersion,
|
|
38833
|
+
skillsHash: skills.hash,
|
|
38834
|
+
previousSkillsHash: previousHash,
|
|
38835
|
+
degraded,
|
|
38836
|
+
degradationReason,
|
|
38837
|
+
latencyMs: latency
|
|
38838
|
+
}
|
|
38839
|
+
};
|
|
38840
|
+
}
|
|
38841
|
+
/**
|
|
38842
|
+
* Testing helper to reset caches.
|
|
38843
|
+
*/
|
|
38844
|
+
__resetForTests() {
|
|
38845
|
+
this.skillsCache = null;
|
|
38846
|
+
this.templateCache = null;
|
|
38847
|
+
this.lastHashes.clear();
|
|
38848
|
+
}
|
|
38849
|
+
async resolveSkills(locale) {
|
|
38850
|
+
const artifact = await this.loadSkillsArtifact();
|
|
38851
|
+
const root = resolveArtifactRoot();
|
|
38852
|
+
if (artifact && artifact.locales && artifact.locales[locale]) {
|
|
38853
|
+
const entry = artifact.locales[locale];
|
|
38854
|
+
if (entry?.sentence && entry?.hash) {
|
|
38855
|
+
return {
|
|
38856
|
+
sentence: entry.sentence,
|
|
38857
|
+
hash: entry.hash,
|
|
38858
|
+
degraded: false
|
|
38859
|
+
};
|
|
38860
|
+
}
|
|
38861
|
+
}
|
|
38862
|
+
const readyCommands = await this.loadReadyCommands(root);
|
|
38863
|
+
if (readyCommands.length === 0) {
|
|
38864
|
+
const hash2 = this.hashData(`${locale}:degraded`);
|
|
38865
|
+
return {
|
|
38866
|
+
sentence: this.buildDegradedSentence(locale),
|
|
38867
|
+
hash: hash2,
|
|
38868
|
+
degraded: true,
|
|
38869
|
+
reason: "ready-manifest-missing"
|
|
38870
|
+
};
|
|
38871
|
+
}
|
|
38872
|
+
const slashCommands = readyCommands.map((cmd) => `/${cmd.name}`);
|
|
38873
|
+
const sentence = buildSentence(locale, slashCommands);
|
|
38874
|
+
const hash = this.hashData(JSON.stringify({ locale, commands: slashCommands }));
|
|
38875
|
+
return {
|
|
38876
|
+
sentence,
|
|
38877
|
+
hash,
|
|
38878
|
+
degraded: false
|
|
38879
|
+
};
|
|
38880
|
+
}
|
|
38881
|
+
async resolveTemplate(locale) {
|
|
38882
|
+
const artifact = await this.loadTemplateArtifact();
|
|
38883
|
+
if (artifact && artifact.templates && artifact.templates[locale]) {
|
|
38884
|
+
return {
|
|
38885
|
+
template: artifact.templates[locale],
|
|
38886
|
+
version: artifact.templateVersion ?? DEFAULT_TEMPLATE_VERSION,
|
|
38887
|
+
degraded: false
|
|
38888
|
+
};
|
|
38889
|
+
}
|
|
38890
|
+
if (artifact && artifact.templates && artifact.templates[DEFAULT_LOCALE]) {
|
|
38891
|
+
return {
|
|
38892
|
+
template: artifact.templates[DEFAULT_LOCALE],
|
|
38893
|
+
version: artifact.templateVersion ?? DEFAULT_TEMPLATE_VERSION,
|
|
38894
|
+
degraded: false
|
|
38895
|
+
};
|
|
38896
|
+
}
|
|
38897
|
+
const template = DEFAULT_TEMPLATES[locale] ?? DEFAULT_TEMPLATES[DEFAULT_LOCALE];
|
|
38898
|
+
return {
|
|
38899
|
+
template,
|
|
38900
|
+
version: DEFAULT_TEMPLATE_VERSION,
|
|
38901
|
+
degraded: !DEFAULT_TEMPLATES[locale],
|
|
38902
|
+
reason: DEFAULT_TEMPLATES[locale] ? void 0 : "template-missing"
|
|
38903
|
+
};
|
|
38904
|
+
}
|
|
38905
|
+
composeMessage(args2) {
|
|
38906
|
+
const locale = args2.locale;
|
|
38907
|
+
const lines = [];
|
|
38908
|
+
if (args2.includeWarningHeader || args2.degraded) {
|
|
38909
|
+
const header = DEGRADED_HEADER[locale] ?? DEGRADED_HEADER[DEFAULT_LOCALE];
|
|
38910
|
+
lines.push(header);
|
|
38911
|
+
}
|
|
38912
|
+
if (args2.degraded) {
|
|
38913
|
+
const degradedBody = DEGRADED_BODY[locale] ?? DEGRADED_BODY[DEFAULT_LOCALE];
|
|
38914
|
+
const steps = NEXT_STEPS[locale] ?? DEFAULT_NEXT_STEPS;
|
|
38915
|
+
const helpLine2 = HELP_LINES[locale] ?? HELP_LINES[DEFAULT_LOCALE] ?? steps[0];
|
|
38916
|
+
lines.push(degradedBody);
|
|
38917
|
+
lines.push(helpLine2);
|
|
38918
|
+
lines.push(steps[1] ?? DEFAULT_NEXT_STEPS[1]);
|
|
38919
|
+
return lines.join("\n");
|
|
38920
|
+
}
|
|
38921
|
+
const helpLine = HELP_LINES[locale] ?? HELP_LINES[DEFAULT_LOCALE];
|
|
38922
|
+
const personaLines = this.normalizePersonaOutput(args2.persona);
|
|
38923
|
+
lines.push(...personaLines);
|
|
38924
|
+
if (args2.isTTY) {
|
|
38925
|
+
lines.push("Next steps:");
|
|
38926
|
+
const steps = NEXT_STEPS[locale] ?? DEFAULT_NEXT_STEPS;
|
|
38927
|
+
for (const step of steps) {
|
|
38928
|
+
lines.push(`- ${step}`);
|
|
38929
|
+
}
|
|
38930
|
+
} else {
|
|
38931
|
+
lines.push(helpLine);
|
|
38932
|
+
}
|
|
38933
|
+
return lines.join("\n");
|
|
38934
|
+
}
|
|
38935
|
+
normalizePersonaOutput(persona) {
|
|
38936
|
+
const sanitized = persona.replace(/\s+/g, " ").trim();
|
|
38937
|
+
const segments = sanitized.split(/(?<=[.!?。!?])/u).map((seg) => seg.trim());
|
|
38938
|
+
return segments.filter(Boolean);
|
|
38939
|
+
}
|
|
38940
|
+
async loadSkillsArtifact() {
|
|
38941
|
+
if (this.skillsCache && Date.now() - this.skillsCache.loadedAt < ARTIFACT_CACHE_TTL) {
|
|
38942
|
+
return this.skillsCache.data;
|
|
38943
|
+
}
|
|
38944
|
+
const root = resolveArtifactRoot();
|
|
38945
|
+
const artifactPath = path58__namespace.default.join(root, "reports", "identity-skills.json");
|
|
38946
|
+
const data = await this.readJsonFile(artifactPath);
|
|
38947
|
+
this.skillsCache = {
|
|
38948
|
+
data,
|
|
38949
|
+
loadedAt: Date.now()
|
|
38950
|
+
};
|
|
38951
|
+
return data;
|
|
38952
|
+
}
|
|
38953
|
+
async loadTemplateArtifact() {
|
|
38954
|
+
if (this.templateCache && Date.now() - this.templateCache.loadedAt < ARTIFACT_CACHE_TTL) {
|
|
38955
|
+
return this.templateCache.data;
|
|
38956
|
+
}
|
|
38957
|
+
const root = resolveArtifactRoot();
|
|
38958
|
+
const templatePath = path58__namespace.default.join(root, "MARIA_CHARACTER_RESPONSES.json");
|
|
38959
|
+
const data = await this.readJsonFile(templatePath);
|
|
38960
|
+
this.templateCache = {
|
|
38961
|
+
data,
|
|
38962
|
+
loadedAt: Date.now()
|
|
38963
|
+
};
|
|
38964
|
+
return data;
|
|
38965
|
+
}
|
|
38966
|
+
async loadReadyCommands(root) {
|
|
38967
|
+
const manifestPath = path58__namespace.default.join(root, "commands.ready.json");
|
|
38968
|
+
const manifest = await this.readJsonFile(manifestPath);
|
|
38969
|
+
if (!manifest?.commands) {
|
|
38970
|
+
return [];
|
|
38971
|
+
}
|
|
38972
|
+
return manifest.commands.filter((entry) => entry.status === "READY").map((entry) => ({
|
|
38973
|
+
name: String(entry.name ?? ""),
|
|
38974
|
+
category: entry.category ? String(entry.category) : void 0
|
|
38975
|
+
})).filter((entry) => entry.name?.length > 0);
|
|
38976
|
+
}
|
|
38977
|
+
buildDegradedSentence(locale) {
|
|
38978
|
+
switch (locale) {
|
|
38979
|
+
case "ja":
|
|
38980
|
+
return "`/help`\u3067\u516C\u958B\u3055\u308C\u3066\u3044\u308BREADY\u30B3\u30DE\u30F3\u30C9\u306B\u57FA\u3065\u3044\u3066\u5BFE\u5FDC\u3057\u307E\u3059\u3002";
|
|
38981
|
+
case "zh":
|
|
38982
|
+
return "\u6211\u4F1A\u4F9D\u636E /help \u4E2D\u516C\u5F00\u7684 READY \u547D\u4EE4\u63D0\u4F9B\u652F\u6301\u3002";
|
|
38983
|
+
case "ko":
|
|
38984
|
+
return "\uACF5\uAC1C\uB41C /help READY \uBA85\uB839\uC5D0 \uAE30\uBC18\uD558\uC5EC \uC9C0\uC6D0\uD569\uB2C8\uB2E4.";
|
|
38985
|
+
case "vi":
|
|
38986
|
+
return "T\xF4i s\u1EBD h\u1ED7 tr\u1EE3 d\u1EF1a tr\xEAn c\xE1c l\u1EC7nh READY \u0111\u01B0\u1EE3c li\u1EC7t k\xEA trong /help.";
|
|
38987
|
+
default:
|
|
38988
|
+
return "I will rely on the READY commands published in /help.";
|
|
38989
|
+
}
|
|
38990
|
+
}
|
|
38991
|
+
hashData(data) {
|
|
38992
|
+
return crypto4.createHash("sha256").update(data).digest("hex");
|
|
38993
|
+
}
|
|
38994
|
+
async readJsonFile(filePath) {
|
|
38995
|
+
try {
|
|
38996
|
+
const raw = await fsp.readFile(filePath, "utf8");
|
|
38997
|
+
return JSON.parse(raw);
|
|
38998
|
+
} catch (error2) {
|
|
38999
|
+
if (error2.code !== "ENOENT") {
|
|
39000
|
+
logger.warn(`Failed to read JSON artifact at ${filePath}:`, error2);
|
|
39001
|
+
}
|
|
39002
|
+
return null;
|
|
39003
|
+
}
|
|
39004
|
+
}
|
|
39005
|
+
};
|
|
39006
|
+
identityRenderer = IdentityRenderer.getInstance();
|
|
39007
|
+
}
|
|
39008
|
+
});
|
|
39009
|
+
|
|
39010
|
+
// src/slash-commands/categories/core/identity.command.ts
|
|
39011
|
+
var identity_command_exports = {};
|
|
39012
|
+
__export(identity_command_exports, {
|
|
39013
|
+
IdentityCommand: () => IdentityCommand,
|
|
39014
|
+
meta: () => meta14
|
|
39015
|
+
});
|
|
39016
|
+
var IdentityCommand, meta14;
|
|
39017
|
+
var init_identity_command = __esm({
|
|
39018
|
+
"src/slash-commands/categories/core/identity.command.ts"() {
|
|
39019
|
+
init_base_command();
|
|
39020
|
+
init_identity_renderer();
|
|
39021
|
+
init_logger();
|
|
39022
|
+
IdentityCommand = class extends BaseCommand {
|
|
39023
|
+
name = "identity";
|
|
39024
|
+
description = "Show Maria Code identity and supported READY skills";
|
|
39025
|
+
category = "core";
|
|
39026
|
+
aliases = ["whois", "persona"];
|
|
39027
|
+
usage = "/identity [--json] [--locale <tag>]";
|
|
39028
|
+
examples = [
|
|
39029
|
+
{
|
|
39030
|
+
input: "/identity",
|
|
39031
|
+
description: "Display identity message in current locale"
|
|
39032
|
+
},
|
|
39033
|
+
{
|
|
39034
|
+
input: "/identity --json",
|
|
39035
|
+
description: "Return structured JSON payload"
|
|
39036
|
+
}
|
|
39037
|
+
];
|
|
39038
|
+
async execute(args2, _context) {
|
|
39039
|
+
const positional = args2.parsed["_positional"] ?? [];
|
|
39040
|
+
if (positional.length > 0) {
|
|
39041
|
+
return this.error(
|
|
39042
|
+
"Usage: /identity [--json] [--locale <tag>]",
|
|
39043
|
+
"INVALID_ARGUMENTS"
|
|
39044
|
+
);
|
|
39045
|
+
}
|
|
39046
|
+
const wantsJson = Boolean(args2.flags["json"] || args2.options["json"]);
|
|
39047
|
+
const explicitLocale = typeof args2.options["locale"] === "string" ? args2.options["locale"] : void 0;
|
|
39048
|
+
try {
|
|
39049
|
+
const result = await identityRenderer.render({
|
|
39050
|
+
locale: explicitLocale,
|
|
39051
|
+
format: wantsJson ? "json" : "text",
|
|
39052
|
+
isTTY: Boolean(process.stdout?.isTTY),
|
|
39053
|
+
source: "cli"
|
|
39054
|
+
});
|
|
39055
|
+
const payload = wantsJson ? result.json : {
|
|
39056
|
+
locale: result.metadata.locale,
|
|
39057
|
+
degraded: result.metadata.degraded,
|
|
39058
|
+
templateVersion: result.metadata.templateVersion,
|
|
39059
|
+
skillsHash: result.metadata.skillsHash,
|
|
39060
|
+
previousSkillsHash: result.metadata.previousSkillsHash
|
|
39061
|
+
};
|
|
39062
|
+
return this.success(result.message, payload);
|
|
39063
|
+
} catch (error2) {
|
|
39064
|
+
logger.error("/identity execution failed", error2);
|
|
39065
|
+
return this.error(
|
|
39066
|
+
"Unable to render identity information. Run /help for support.",
|
|
39067
|
+
"IDENTITY_RENDER_ERROR",
|
|
39068
|
+
{ error: error2?.message }
|
|
39069
|
+
);
|
|
39070
|
+
}
|
|
39071
|
+
}
|
|
39072
|
+
};
|
|
39073
|
+
meta14 = {
|
|
39074
|
+
name: "identity",
|
|
39075
|
+
category: "core",
|
|
39076
|
+
description: "Show Maria Code identity and supported READY skills",
|
|
39077
|
+
aliases: ["whois", "persona"],
|
|
39078
|
+
usage: "/identity [--json] [--locale <tag>]",
|
|
39079
|
+
examples: [
|
|
39080
|
+
"/identity",
|
|
39081
|
+
"/identity --json"
|
|
39082
|
+
],
|
|
39083
|
+
deps: ["commands.ready.json"]
|
|
39084
|
+
};
|
|
39085
|
+
}
|
|
39086
|
+
});
|
|
39087
|
+
|
|
38351
39088
|
// src/slash-commands/categories/core/about.command.ts
|
|
38352
39089
|
var about_command_exports = {};
|
|
38353
39090
|
__export(about_command_exports, {
|
|
38354
39091
|
AboutCommand: () => AboutCommand,
|
|
38355
|
-
meta: () =>
|
|
39092
|
+
meta: () => meta15
|
|
38356
39093
|
});
|
|
38357
|
-
var AboutCommand,
|
|
39094
|
+
var AboutCommand, meta15;
|
|
38358
39095
|
var init_about_command = __esm({
|
|
38359
39096
|
"src/slash-commands/categories/core/about.command.ts"() {
|
|
38360
39097
|
init_base_command();
|
|
@@ -38409,7 +39146,7 @@ var init_about_command = __esm({
|
|
|
38409
39146
|
};
|
|
38410
39147
|
}
|
|
38411
39148
|
};
|
|
38412
|
-
|
|
39149
|
+
meta15 = {
|
|
38413
39150
|
name: "about",
|
|
38414
39151
|
category: "core",
|
|
38415
39152
|
description: "Display information about MARIA and the team",
|
|
@@ -39915,11 +40652,11 @@ var init_ConfigPortAdapter = __esm({
|
|
|
39915
40652
|
backupCount: 5
|
|
39916
40653
|
};
|
|
39917
40654
|
constructor() {
|
|
39918
|
-
this.globalConfigPath =
|
|
39919
|
-
this.userConfigPath =
|
|
39920
|
-
this.projectConfigPath =
|
|
39921
|
-
this.historyPath =
|
|
39922
|
-
this.templatesPath =
|
|
40655
|
+
this.globalConfigPath = path58__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config.json");
|
|
40656
|
+
this.userConfigPath = path58__namespace.default.join(os13__namespace.default.homedir(), ".maria", "user-config.json");
|
|
40657
|
+
this.projectConfigPath = path58__namespace.default.join(process.cwd(), ".maria-config.json");
|
|
40658
|
+
this.historyPath = path58__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config-history.json");
|
|
40659
|
+
this.templatesPath = path58__namespace.default.join(os13__namespace.default.homedir(), ".maria", "templates");
|
|
39923
40660
|
}
|
|
39924
40661
|
async get(key) {
|
|
39925
40662
|
const layered = await this.getLayered(key);
|
|
@@ -40176,7 +40913,7 @@ var init_ConfigPortAdapter = __esm({
|
|
|
40176
40913
|
for (const file of files) {
|
|
40177
40914
|
if (file.endsWith(".json")) {
|
|
40178
40915
|
try {
|
|
40179
|
-
const templatePath =
|
|
40916
|
+
const templatePath = path58__namespace.default.join(this.templatesPath, file);
|
|
40180
40917
|
const content = await fsp__namespace.default.readFile(templatePath, "utf-8");
|
|
40181
40918
|
const template = JSON.parse(content);
|
|
40182
40919
|
templates.push(template);
|
|
@@ -40258,7 +40995,7 @@ var init_ConfigPortAdapter = __esm({
|
|
|
40258
40995
|
}
|
|
40259
40996
|
async saveLayerConfig(layer, config2) {
|
|
40260
40997
|
const configPath = this.getLayerConfigPath(layer);
|
|
40261
|
-
await fsp__namespace.default.mkdir(
|
|
40998
|
+
await fsp__namespace.default.mkdir(path58__namespace.default.dirname(configPath), { recursive: true });
|
|
40262
40999
|
await fsp__namespace.default.writeFile(configPath, JSON.stringify(config2, null, 2), "utf-8");
|
|
40263
41000
|
}
|
|
40264
41001
|
getLayerConfigPath(layer) {
|
|
@@ -40270,7 +41007,7 @@ var init_ConfigPortAdapter = __esm({
|
|
|
40270
41007
|
case "project":
|
|
40271
41008
|
return this.projectConfigPath;
|
|
40272
41009
|
case "runtime":
|
|
40273
|
-
return
|
|
41010
|
+
return path58__namespace.default.join(os13__namespace.default.tmpdir(), "maria-runtime-config.json");
|
|
40274
41011
|
default:
|
|
40275
41012
|
return this.userConfigPath;
|
|
40276
41013
|
}
|
|
@@ -40324,7 +41061,7 @@ var init_ConfigPortAdapter = __esm({
|
|
|
40324
41061
|
const history = JSON.parse(historyContent);
|
|
40325
41062
|
history.push(entry);
|
|
40326
41063
|
const trimmedHistory = history.slice(-1e3);
|
|
40327
|
-
await fsp__namespace.default.mkdir(
|
|
41064
|
+
await fsp__namespace.default.mkdir(path58__namespace.default.dirname(this.historyPath), { recursive: true });
|
|
40328
41065
|
await fsp__namespace.default.writeFile(
|
|
40329
41066
|
this.historyPath,
|
|
40330
41067
|
JSON.stringify(trimmedHistory, null, 2),
|
|
@@ -40336,7 +41073,7 @@ var init_ConfigPortAdapter = __esm({
|
|
|
40336
41073
|
}
|
|
40337
41074
|
async loadTemplate(templateId) {
|
|
40338
41075
|
try {
|
|
40339
|
-
const templatePath =
|
|
41076
|
+
const templatePath = path58__namespace.default.join(this.templatesPath, `${templateId}.json`);
|
|
40340
41077
|
const content = await fsp__namespace.default.readFile(templatePath, "utf-8");
|
|
40341
41078
|
return JSON.parse(content);
|
|
40342
41079
|
} catch (error2) {
|
|
@@ -42161,7 +42898,7 @@ var init_rate_limit_handler = __esm({
|
|
|
42161
42898
|
async function scanRepo(cwd2) {
|
|
42162
42899
|
if (_cache && _cache.root === cwd2) return _cache;
|
|
42163
42900
|
const root = cwd2;
|
|
42164
|
-
const pkgPath =
|
|
42901
|
+
const pkgPath = path58.join(root, "package.json");
|
|
42165
42902
|
let pkg = {};
|
|
42166
42903
|
try {
|
|
42167
42904
|
pkg = JSON.parse(await fsp.readFile(pkgPath, "utf8"));
|
|
@@ -42171,17 +42908,17 @@ async function scanRepo(cwd2) {
|
|
|
42171
42908
|
const usesReact = !!deps["react"];
|
|
42172
42909
|
const usesNext = !!deps["next"];
|
|
42173
42910
|
const jsModuleType = pkg.type === "module" ? "esm" : "cjs";
|
|
42174
|
-
const hasSrc = fs23.existsSync(
|
|
42911
|
+
const hasSrc = fs23.existsSync(path58.join(root, "src"));
|
|
42175
42912
|
const srcRoot = hasSrc ? "src" : "";
|
|
42176
|
-
const tsconfigPath =
|
|
42913
|
+
const tsconfigPath = path58.join(root, "tsconfig.json");
|
|
42177
42914
|
let usesTS = fs23.existsSync(tsconfigPath) || !!deps["typescript"];
|
|
42178
42915
|
if (!usesTS && hasSrc) {
|
|
42179
42916
|
const candidates = ["index.ts", "main.ts", "App.tsx"];
|
|
42180
|
-
usesTS = candidates.some((f3) => fs23.existsSync(
|
|
42917
|
+
usesTS = candidates.some((f3) => fs23.existsSync(path58.join(root, "src", f3)));
|
|
42181
42918
|
}
|
|
42182
|
-
const nextAppDir = usesNext && fs23.existsSync(
|
|
42919
|
+
const nextAppDir = usesNext && fs23.existsSync(path58.join(root, "app"));
|
|
42183
42920
|
const testRunner = deps["vitest"] ? "vitest" : deps["jest"] ? "jest" : null;
|
|
42184
|
-
const isMonorepo2 = fs23.existsSync(
|
|
42921
|
+
const isMonorepo2 = fs23.existsSync(path58.join(root, "pnpm-workspace.yaml")) || fs23.existsSync(path58.join(root, "packages")) || fs23.existsSync(path58.join(root, "apps"));
|
|
42185
42922
|
const packages = [];
|
|
42186
42923
|
let aliasPaths = {};
|
|
42187
42924
|
try {
|
|
@@ -42191,7 +42928,7 @@ async function scanRepo(cwd2) {
|
|
|
42191
42928
|
}
|
|
42192
42929
|
let eol = "lf";
|
|
42193
42930
|
try {
|
|
42194
|
-
const ec = await fsp.readFile(
|
|
42931
|
+
const ec = await fsp.readFile(path58.join(root, ".editorconfig"), "utf8");
|
|
42195
42932
|
if (/end_of_line\s*=\s*crlf/i.test(ec)) eol = "crlf";
|
|
42196
42933
|
if (/end_of_line\s*=\s*lf/i.test(ec)) eol = "lf";
|
|
42197
42934
|
} catch {
|
|
@@ -42210,7 +42947,7 @@ function normalizePlanItem(fp, p) {
|
|
|
42210
42947
|
const base = decideBaseDir(fp, p);
|
|
42211
42948
|
const desired = sanitize(fp.path || suggestName(fp));
|
|
42212
42949
|
const withExt = ensureExt(desired, ext2, fp.kind);
|
|
42213
|
-
const rel = base ?
|
|
42950
|
+
const rel = base ? path58.join(base, withExt) : withExt;
|
|
42214
42951
|
return { ...fp, path: rel.replace(/\\/g, "/") };
|
|
42215
42952
|
}
|
|
42216
42953
|
function decideExt(fp, p) {
|
|
@@ -42250,10 +42987,10 @@ function suggestName(fp, p) {
|
|
|
42250
42987
|
const base = (fp.description || "file").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
42251
42988
|
return base || "file";
|
|
42252
42989
|
}
|
|
42253
|
-
function guessKindByPath(
|
|
42254
|
-
if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(
|
|
42255
|
-
if (/^docs\//.test(
|
|
42256
|
-
if (/\.(json|cjs|js|ts)$/.test(
|
|
42990
|
+
function guessKindByPath(path59) {
|
|
42991
|
+
if (/__tests__|\.spec\.(t|j)sx?$|^tests\//.test(path59)) return "test";
|
|
42992
|
+
if (/^docs\//.test(path59) || /\.md$/.test(path59)) return "doc";
|
|
42993
|
+
if (/\.(json|cjs|js|ts)$/.test(path59) && !/src\//.test(path59)) return "config";
|
|
42257
42994
|
return "source";
|
|
42258
42995
|
}
|
|
42259
42996
|
var init_PathInferencer = __esm({
|
|
@@ -42315,15 +43052,15 @@ async function validatePlan(plans, opts) {
|
|
|
42315
43052
|
skipped.push(fp.path);
|
|
42316
43053
|
continue;
|
|
42317
43054
|
}
|
|
42318
|
-
const full =
|
|
42319
|
-
if (!full.startsWith(
|
|
43055
|
+
const full = path58__namespace.default.join(opts.root, rel);
|
|
43056
|
+
if (!full.startsWith(path58__namespace.default.resolve(opts.root))) {
|
|
42320
43057
|
warnings.push(`Outside root denied: ${fp.path}`);
|
|
42321
43058
|
skipped.push(fp.path);
|
|
42322
43059
|
continue;
|
|
42323
43060
|
}
|
|
42324
43061
|
if (process.platform === "win32" || process.env.MOCK_WIN32 === "1") {
|
|
42325
43062
|
const invalidChars = /[<>:"/\\|?*]/;
|
|
42326
|
-
const name2 =
|
|
43063
|
+
const name2 = path58__namespace.default.basename(rel);
|
|
42327
43064
|
if (invalidChars.test(rel)) {
|
|
42328
43065
|
warnings.push(`Invalid characters in path (Windows): ${fp.path}`);
|
|
42329
43066
|
skipped.push(fp.path);
|
|
@@ -42362,7 +43099,7 @@ async function validatePlan(plans, opts) {
|
|
|
42362
43099
|
}
|
|
42363
43100
|
}
|
|
42364
43101
|
for (const fp of clamped) {
|
|
42365
|
-
const full =
|
|
43102
|
+
const full = path58__namespace.default.join(opts.root, fp.path);
|
|
42366
43103
|
const exists = await exists(full);
|
|
42367
43104
|
const willModify = exists;
|
|
42368
43105
|
if (willModify) {
|
|
@@ -42722,7 +43459,7 @@ async function mapAttachmentsToTargets(attached, opts) {
|
|
|
42722
43459
|
const warnings = [];
|
|
42723
43460
|
const mapped = [];
|
|
42724
43461
|
const ambiguous = [];
|
|
42725
|
-
const root =
|
|
43462
|
+
const root = path58__namespace.default.resolve(opts.root);
|
|
42726
43463
|
const maxN = Math.min(attached.length, Math.max(1, opts.maxAttachments));
|
|
42727
43464
|
const pool = attached.slice(0, maxN);
|
|
42728
43465
|
if (attached.length > maxN) warnings.push(`Attachments clamped: ${attached.length} \u2192 ${maxN}`);
|
|
@@ -42738,7 +43475,7 @@ async function mapAttachmentsToTargets(attached, opts) {
|
|
|
42738
43475
|
}
|
|
42739
43476
|
if (a.pathHint) {
|
|
42740
43477
|
const safeRel = sanitizeRel(a.pathHint);
|
|
42741
|
-
const full =
|
|
43478
|
+
const full = path58__namespace.default.join(root, safeRel);
|
|
42742
43479
|
if (!full.startsWith(root)) {
|
|
42743
43480
|
warnings.push(`Path traversal/absolute denied: ${a.pathHint}`);
|
|
42744
43481
|
} else if (!opts.allowDotfiles && hasDotSegment(safeRel)) {
|
|
@@ -42750,7 +43487,7 @@ async function mapAttachmentsToTargets(attached, opts) {
|
|
|
42750
43487
|
}
|
|
42751
43488
|
}
|
|
42752
43489
|
const name2 = a.originalName.toLowerCase();
|
|
42753
|
-
const matches = Array.from(repoFiles.values()).filter((p) =>
|
|
43490
|
+
const matches = Array.from(repoFiles.values()).filter((p) => path58__namespace.default.basename(p).toLowerCase() === name2);
|
|
42754
43491
|
if (matches.length === 1) {
|
|
42755
43492
|
mapped.push({ path: matches[0], exists: true, reason: "filename", attachment: a });
|
|
42756
43493
|
continue;
|
|
@@ -42764,7 +43501,7 @@ async function mapAttachmentsToTargets(attached, opts) {
|
|
|
42764
43501
|
for (const p of candidates.slice(0, 500)) {
|
|
42765
43502
|
let score = 0;
|
|
42766
43503
|
try {
|
|
42767
|
-
const full =
|
|
43504
|
+
const full = path58__namespace.default.join(root, p);
|
|
42768
43505
|
const body = await safeReadHeadTail(full, 20);
|
|
42769
43506
|
score = jaccard(tokens(head2), tokens(body.head)) * 0.6 + jaccard(tokens(tail), tokens(body.tail)) * 0.4;
|
|
42770
43507
|
} catch {
|
|
@@ -42821,8 +43558,8 @@ async function listRepoFiles(root) {
|
|
|
42821
43558
|
for (const e2 of entries) {
|
|
42822
43559
|
const name2 = e2.name;
|
|
42823
43560
|
if (name2 === ".git" || name2 === "node_modules" || name2 === "dist" || name2 === ".maria") continue;
|
|
42824
|
-
const full =
|
|
42825
|
-
const rel =
|
|
43561
|
+
const full = path58__namespace.default.join(dir, name2);
|
|
43562
|
+
const rel = path58__namespace.default.relative(root, full).replace(/\\/g, "/");
|
|
42826
43563
|
if (e2.isDirectory()) {
|
|
42827
43564
|
await walk2(full);
|
|
42828
43565
|
continue;
|
|
@@ -42863,10 +43600,10 @@ function jaccard(a, b) {
|
|
|
42863
43600
|
return union === 0 ? 0 : inter / union;
|
|
42864
43601
|
}
|
|
42865
43602
|
function proposePath(root, original) {
|
|
42866
|
-
const base =
|
|
42867
|
-
const src =
|
|
43603
|
+
const base = path58__namespace.default.basename(original).replace(/\s+/g, "-").replace(/[^a-zA-Z0-9._-]/g, "").toLowerCase();
|
|
43604
|
+
const src = path58__namespace.default.join(root, "src");
|
|
42868
43605
|
const dir = existsSync8(src) ? "src" : "";
|
|
42869
|
-
const rel = dir ?
|
|
43606
|
+
const rel = dir ? path58__namespace.default.join(dir, base) : base;
|
|
42870
43607
|
return rel.replace(/\\/g, "/");
|
|
42871
43608
|
}
|
|
42872
43609
|
function existsSync8(p) {
|
|
@@ -43196,9 +43933,9 @@ function languageExt(lang) {
|
|
|
43196
43933
|
async function journalResume(root, request, files) {
|
|
43197
43934
|
try {
|
|
43198
43935
|
const fs48 = await import('fs/promises');
|
|
43199
|
-
const dir =
|
|
43936
|
+
const dir = path58__namespace.default.join(root, ".maria", "memory");
|
|
43200
43937
|
await fs48.mkdir(dir, { recursive: true });
|
|
43201
|
-
const out =
|
|
43938
|
+
const out = path58__namespace.default.join(dir, "resume-plan.json");
|
|
43202
43939
|
const payload = { request, createdAt: (/* @__PURE__ */ new Date()).toISOString(), files };
|
|
43203
43940
|
await fs48.writeFile(out, JSON.stringify(payload, null, 2), "utf8");
|
|
43204
43941
|
} catch {
|
|
@@ -43629,7 +44366,7 @@ ${pretty}`);
|
|
|
43629
44366
|
const { normalizePlans: normalizePlans2 } = await Promise.resolve().then(() => (init_FilePlanBuilder(), FilePlanBuilder_exports));
|
|
43630
44367
|
const normalized = await normalizePlans2(plans, { root });
|
|
43631
44368
|
for (const p of normalized) {
|
|
43632
|
-
const exists = await this.pathExists(
|
|
44369
|
+
const exists = await this.pathExists(path58__namespace.join(root, p.path));
|
|
43633
44370
|
p.action = exists ? "modify" : "create";
|
|
43634
44371
|
}
|
|
43635
44372
|
return normalized;
|
|
@@ -43645,9 +44382,9 @@ ${pretty}`);
|
|
|
43645
44382
|
async persistLastPlan(root, plans) {
|
|
43646
44383
|
try {
|
|
43647
44384
|
const fs48 = await import('fs/promises');
|
|
43648
|
-
const p =
|
|
44385
|
+
const p = path58__namespace.join(root, ".maria");
|
|
43649
44386
|
await fs48.mkdir(p, { recursive: true });
|
|
43650
|
-
const out =
|
|
44387
|
+
const out = path58__namespace.join(p, "last-plan.json");
|
|
43651
44388
|
await fs48.writeFile(out, JSON.stringify({ createdAt: (/* @__PURE__ */ new Date()).toISOString(), plans }, null, 2), "utf8");
|
|
43652
44389
|
} catch {
|
|
43653
44390
|
}
|
|
@@ -43663,7 +44400,7 @@ ${pretty}`);
|
|
|
43663
44400
|
try {
|
|
43664
44401
|
for (const plan of plans) {
|
|
43665
44402
|
if (options.signal?.aborted) throw new Error("INTERRUPTED");
|
|
43666
|
-
const full =
|
|
44403
|
+
const full = path58__namespace.join(options.root, plan.path);
|
|
43667
44404
|
const exists = await this.pathExists(full);
|
|
43668
44405
|
if (exists && !options.overwriteAllowed) {
|
|
43669
44406
|
skipped.push(plan.path);
|
|
@@ -43672,7 +44409,7 @@ ${pretty}`);
|
|
|
43672
44409
|
continue;
|
|
43673
44410
|
}
|
|
43674
44411
|
const tmp = full + `.tmp-${process.pid}-${Date.now()}`;
|
|
43675
|
-
await fs48.mkdir(
|
|
44412
|
+
await fs48.mkdir(path58__namespace.dirname(full), { recursive: true });
|
|
43676
44413
|
await fs48.writeFile(tmp, plan.preview || "", "utf8");
|
|
43677
44414
|
await fs48.rename(tmp, full);
|
|
43678
44415
|
if (exists) modified.push(plan.path);
|
|
@@ -43685,7 +44422,7 @@ ${pretty}`);
|
|
|
43685
44422
|
if (options.rollback) {
|
|
43686
44423
|
for (const p of [...created, ...modified]) {
|
|
43687
44424
|
try {
|
|
43688
|
-
await fs48.unlink(
|
|
44425
|
+
await fs48.unlink(path58__namespace.join(options.root, p));
|
|
43689
44426
|
} catch {
|
|
43690
44427
|
}
|
|
43691
44428
|
}
|
|
@@ -43765,13 +44502,13 @@ ${pretty}`);
|
|
|
43765
44502
|
const extension = LANGUAGE_EXTENSIONS[block.language] || ".txt";
|
|
43766
44503
|
const timestamp2 = Date.now().toString(36);
|
|
43767
44504
|
const filename = index === 0 ? `${baseName}${extension}` : `${baseName}_${index + 1}${extension}`;
|
|
43768
|
-
const fullPath =
|
|
44505
|
+
const fullPath = path58__namespace.join(process.cwd(), filename);
|
|
43769
44506
|
try {
|
|
43770
44507
|
await fsp.writeFile(fullPath, block.code, "utf8");
|
|
43771
44508
|
return fullPath;
|
|
43772
44509
|
} catch (error2) {
|
|
43773
44510
|
const fallbackName = `code_${timestamp2}${extension}`;
|
|
43774
|
-
const fallbackPath =
|
|
44511
|
+
const fallbackPath = path58__namespace.join(process.cwd(), fallbackName);
|
|
43775
44512
|
await fsp.writeFile(fallbackPath, block.code, "utf8");
|
|
43776
44513
|
return fallbackPath;
|
|
43777
44514
|
}
|
|
@@ -43805,15 +44542,15 @@ ${pretty}`);
|
|
|
43805
44542
|
async collectAttachedFiles(context2) {
|
|
43806
44543
|
const list = [];
|
|
43807
44544
|
const fs48 = await import('fs/promises');
|
|
43808
|
-
const
|
|
44545
|
+
const path59 = await import('path');
|
|
43809
44546
|
const att = context2 && (context2.attachments || context2.input?.attachments) || [];
|
|
43810
44547
|
for (const a of att) {
|
|
43811
44548
|
try {
|
|
43812
44549
|
const p = a.path || a.filePath || a.name || "";
|
|
43813
|
-
const originalName = a.name ||
|
|
44550
|
+
const originalName = a.name || path59.basename(p || `attachment_${Date.now().toString(36)}`);
|
|
43814
44551
|
let content = a.content;
|
|
43815
44552
|
if (!content && p) {
|
|
43816
|
-
const abs =
|
|
44553
|
+
const abs = path59.isAbsolute(p) ? p : path59.join(process.cwd(), p);
|
|
43817
44554
|
content = await fs48.readFile(abs, "utf8");
|
|
43818
44555
|
}
|
|
43819
44556
|
if (!content) continue;
|
|
@@ -43923,7 +44660,7 @@ function getKnowledgeProviderFromEnv(root = process.cwd()) {
|
|
|
43923
44660
|
function safeListFiles(dir) {
|
|
43924
44661
|
try {
|
|
43925
44662
|
return fs23__namespace.default.readdirSync(dir, { withFileTypes: true }).flatMap((d) => {
|
|
43926
|
-
const p =
|
|
44663
|
+
const p = path58__namespace.default.join(dir, d.name);
|
|
43927
44664
|
if (d.isDirectory()) {
|
|
43928
44665
|
if (/node_modules|\.git|dist|coverage|artifacts|reports/.test(p)) return [];
|
|
43929
44666
|
return safeListFiles(p);
|
|
@@ -43959,7 +44696,7 @@ var init_KnowledgeProvider = __esm({
|
|
|
43959
44696
|
}
|
|
43960
44697
|
async getPrinciples(_projectId, _taskId) {
|
|
43961
44698
|
const candidates = [
|
|
43962
|
-
|
|
44699
|
+
path58__namespace.default.join(this.root, "docs"),
|
|
43963
44700
|
this.root
|
|
43964
44701
|
];
|
|
43965
44702
|
const out = [];
|
|
@@ -43989,7 +44726,7 @@ var init_KnowledgeProvider = __esm({
|
|
|
43989
44726
|
var resume_command_exports = {};
|
|
43990
44727
|
__export(resume_command_exports, {
|
|
43991
44728
|
ResumeCommand: () => ResumeCommand,
|
|
43992
|
-
meta: () =>
|
|
44729
|
+
meta: () => meta16
|
|
43993
44730
|
});
|
|
43994
44731
|
function truncate2(s2, n) {
|
|
43995
44732
|
return s2.length <= n ? s2 : s2.slice(0, n) + "\u2026";
|
|
@@ -44021,7 +44758,7 @@ function promptLine(timeoutMs = 15e3) {
|
|
|
44021
44758
|
}
|
|
44022
44759
|
async function readLastDebugStatusSafe(cwd2) {
|
|
44023
44760
|
try {
|
|
44024
|
-
const p =
|
|
44761
|
+
const p = path58__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
|
|
44025
44762
|
const buf = await fsp__namespace.readFile(p, "utf8");
|
|
44026
44763
|
const arr = JSON.parse(buf);
|
|
44027
44764
|
if (Array.isArray(arr) && arr.length) return arr[arr.length - 1];
|
|
@@ -44032,7 +44769,7 @@ async function readLastDebugStatusSafe(cwd2) {
|
|
|
44032
44769
|
}
|
|
44033
44770
|
async function readDebugJournalListSafe(cwd2, count) {
|
|
44034
44771
|
try {
|
|
44035
|
-
const p =
|
|
44772
|
+
const p = path58__namespace.join(cwd2, ".maria", "memory", "debug-resume.json");
|
|
44036
44773
|
const buf = await fsp__namespace.readFile(p, "utf8");
|
|
44037
44774
|
const arr = JSON.parse(buf);
|
|
44038
44775
|
if (!Array.isArray(arr) || arr.length === 0) return [];
|
|
@@ -44041,7 +44778,7 @@ async function readDebugJournalListSafe(cwd2, count) {
|
|
|
44041
44778
|
return [];
|
|
44042
44779
|
}
|
|
44043
44780
|
}
|
|
44044
|
-
var ResumeCommand,
|
|
44781
|
+
var ResumeCommand, meta16;
|
|
44045
44782
|
var init_resume_command = __esm({
|
|
44046
44783
|
"src/slash-commands/categories/workflow/resume.command.ts"() {
|
|
44047
44784
|
init_base_command();
|
|
@@ -44252,7 +44989,7 @@ var init_resume_command = __esm({
|
|
|
44252
44989
|
return cands[n - 1];
|
|
44253
44990
|
}
|
|
44254
44991
|
};
|
|
44255
|
-
|
|
44992
|
+
meta16 = {
|
|
44256
44993
|
name: "workflow/resume",
|
|
44257
44994
|
category: "implementation",
|
|
44258
44995
|
description: "Resume previous task context and propose next /code step",
|
|
@@ -44566,11 +45303,11 @@ async function runWithBudget(tasks, totalMs = 6e3, perStepMs = 600) {
|
|
|
44566
45303
|
return out;
|
|
44567
45304
|
}
|
|
44568
45305
|
function isSensitive(filepath) {
|
|
44569
|
-
const basename15 =
|
|
45306
|
+
const basename15 = path58__namespace.basename(filepath);
|
|
44570
45307
|
return SENSITIVE_PATTERNS2.some((pattern) => pattern.test(basename15) || pattern.test(filepath));
|
|
44571
45308
|
}
|
|
44572
45309
|
function isBinary2(filepath) {
|
|
44573
|
-
const ext2 =
|
|
45310
|
+
const ext2 = path58__namespace.extname(filepath).toLowerCase();
|
|
44574
45311
|
return BINARY_EXTENSIONS.has(ext2);
|
|
44575
45312
|
}
|
|
44576
45313
|
async function safeRead(file, maxBytes = 512 * 1024, maxLines = 200, signal) {
|
|
@@ -44626,15 +45363,15 @@ async function scanRoot(opts) {
|
|
|
44626
45363
|
];
|
|
44627
45364
|
for (const { name: name2, maxLines } of rootFiles) {
|
|
44628
45365
|
if (signal.aborted || remainMs() < 100) break;
|
|
44629
|
-
const filepath =
|
|
45366
|
+
const filepath = path58__namespace.join(cwd2, name2);
|
|
44630
45367
|
const result = await safeRead(filepath, 512 * 1024, maxLines, signal);
|
|
44631
45368
|
if (result.head || result.meta) {
|
|
44632
|
-
let
|
|
45369
|
+
let meta25 = result.meta || object;
|
|
44633
45370
|
if (name2 === "package.json" && result.head) {
|
|
44634
45371
|
try {
|
|
44635
45372
|
const pkg = JSON.parse(result.head);
|
|
44636
|
-
|
|
44637
|
-
...
|
|
45373
|
+
meta25 = {
|
|
45374
|
+
...meta25,
|
|
44638
45375
|
name: pkg.name,
|
|
44639
45376
|
version: pkg.version,
|
|
44640
45377
|
type: pkg.type,
|
|
@@ -44647,14 +45384,14 @@ async function scanRoot(opts) {
|
|
|
44647
45384
|
workspaces: pkg.workspaces
|
|
44648
45385
|
};
|
|
44649
45386
|
} catch (e2) {
|
|
44650
|
-
|
|
45387
|
+
meta25.parseError = true;
|
|
44651
45388
|
}
|
|
44652
45389
|
}
|
|
44653
45390
|
findings.push({
|
|
44654
45391
|
file: name2,
|
|
44655
45392
|
kind: "read",
|
|
44656
45393
|
head: result.head,
|
|
44657
|
-
meta:
|
|
45394
|
+
meta: meta25,
|
|
44658
45395
|
truncated: result.truncated
|
|
44659
45396
|
});
|
|
44660
45397
|
}
|
|
@@ -44682,7 +45419,7 @@ async function scanBuild(opts) {
|
|
|
44682
45419
|
];
|
|
44683
45420
|
for (const name2 of buildFiles) {
|
|
44684
45421
|
if (signal.aborted || remainMs() < 100) break;
|
|
44685
|
-
const filepath =
|
|
45422
|
+
const filepath = path58__namespace.join(cwd2, name2);
|
|
44686
45423
|
const result = await safeRead(filepath, 512 * 1024, 100, signal);
|
|
44687
45424
|
if (result.head || result.meta) {
|
|
44688
45425
|
findings.push({
|
|
@@ -44719,7 +45456,7 @@ async function scanQuality(opts) {
|
|
|
44719
45456
|
];
|
|
44720
45457
|
for (const name2 of qualityFiles) {
|
|
44721
45458
|
if (signal.aborted || remainMs() < 100) break;
|
|
44722
|
-
const filepath =
|
|
45459
|
+
const filepath = path58__namespace.join(cwd2, name2);
|
|
44723
45460
|
const result = await safeRead(filepath, 512 * 1024, 50, signal);
|
|
44724
45461
|
if (result.head || result.meta) {
|
|
44725
45462
|
findings.push({
|
|
@@ -44764,7 +45501,7 @@ async function scanScripts(opts) {
|
|
|
44764
45501
|
const sample = files.slice(0, 5);
|
|
44765
45502
|
for (const file of sample) {
|
|
44766
45503
|
if (signal.aborted || remainMs() < 100) break;
|
|
44767
|
-
const result = await safeRead(
|
|
45504
|
+
const result = await safeRead(path58__namespace.join(cwd2, file), 512 * 1024, 100, signal);
|
|
44768
45505
|
if (result.head || result.meta) {
|
|
44769
45506
|
findings.push({
|
|
44770
45507
|
file,
|
|
@@ -44806,7 +45543,7 @@ async function scanEntries(opts) {
|
|
|
44806
45543
|
];
|
|
44807
45544
|
for (const name2 of entryFiles) {
|
|
44808
45545
|
if (signal.aborted || remainMs() < 100) break;
|
|
44809
|
-
const filepath =
|
|
45546
|
+
const filepath = path58__namespace.join(cwd2, name2);
|
|
44810
45547
|
const result = await safeRead(filepath, 512 * 1024, 80, signal);
|
|
44811
45548
|
if (result.head || result.meta) {
|
|
44812
45549
|
findings.push({
|
|
@@ -44887,9 +45624,9 @@ function checkBinAlignment(pkg, cwd2) {
|
|
|
44887
45624
|
const bin = typeof pkg.bin === "string" ? { [pkg.name]: pkg.bin } : pkg.bin;
|
|
44888
45625
|
for (const [name2, rel] of Object.entries(bin)) {
|
|
44889
45626
|
const binPath = rel;
|
|
44890
|
-
const srcPath =
|
|
45627
|
+
const srcPath = path58__namespace.join(cwd2, binPath);
|
|
44891
45628
|
if (!fs23__namespace.existsSync(srcPath)) {
|
|
44892
|
-
const distGuess =
|
|
45629
|
+
const distGuess = path58__namespace.join(
|
|
44893
45630
|
cwd2,
|
|
44894
45631
|
"dist",
|
|
44895
45632
|
binPath.replace(/^src\//, "").replace(/^bin\//, "bin/")
|
|
@@ -44992,19 +45729,19 @@ function extractPackageInfo(findings) {
|
|
|
44992
45729
|
hasPostinstall: false
|
|
44993
45730
|
};
|
|
44994
45731
|
}
|
|
44995
|
-
const
|
|
45732
|
+
const meta25 = pkgFinding.meta;
|
|
44996
45733
|
return {
|
|
44997
|
-
name:
|
|
44998
|
-
version:
|
|
44999
|
-
type:
|
|
45000
|
-
scripts:
|
|
45001
|
-
hasPostinstall: !!
|
|
45002
|
-
bin:
|
|
45003
|
-
main:
|
|
45004
|
-
exports:
|
|
45005
|
-
dependencies:
|
|
45006
|
-
devDependencies:
|
|
45007
|
-
workspaces:
|
|
45734
|
+
name: meta25.name,
|
|
45735
|
+
version: meta25.version,
|
|
45736
|
+
type: meta25.type,
|
|
45737
|
+
scripts: meta25.scripts ? Object.keys(meta25.scripts) : [],
|
|
45738
|
+
hasPostinstall: !!meta25.scripts?.postinstall,
|
|
45739
|
+
bin: meta25.bin,
|
|
45740
|
+
main: meta25.main,
|
|
45741
|
+
exports: meta25.exports,
|
|
45742
|
+
dependencies: meta25.dependencies || [],
|
|
45743
|
+
devDependencies: meta25.devDependencies || [],
|
|
45744
|
+
workspaces: meta25.workspaces
|
|
45008
45745
|
};
|
|
45009
45746
|
}
|
|
45010
45747
|
function collectWarnings(pkg, findings, cwd2) {
|
|
@@ -45155,9 +45892,9 @@ function calculateMetrics(findings, startTime) {
|
|
|
45155
45892
|
}
|
|
45156
45893
|
function renderFinding(f3) {
|
|
45157
45894
|
const title = `### ${f3.kind.toUpperCase()} \u2014 ${f3.file}`;
|
|
45158
|
-
let
|
|
45895
|
+
let meta25 = "";
|
|
45159
45896
|
if (f3.meta && Object.keys(f3.meta).length > 0) {
|
|
45160
|
-
|
|
45897
|
+
meta25 = `
|
|
45161
45898
|
<details><summary>meta</summary>
|
|
45162
45899
|
|
|
45163
45900
|
\`\`\`json
|
|
@@ -45178,7 +45915,7 @@ ${f3.head.trim()}
|
|
|
45178
45915
|
}
|
|
45179
45916
|
const truncInfo = f3.truncated ? `
|
|
45180
45917
|
> _truncated preview_` : "";
|
|
45181
|
-
return [title,
|
|
45918
|
+
return [title, meta25, content, truncInfo, ""].join("\n");
|
|
45182
45919
|
}
|
|
45183
45920
|
function safeJsonStringify(obj) {
|
|
45184
45921
|
try {
|
|
@@ -45398,7 +46135,7 @@ async function detectMonorepoType(root) {
|
|
|
45398
46135
|
const files = await fsp__namespace.readdir(root);
|
|
45399
46136
|
if (files.includes("package.json")) {
|
|
45400
46137
|
const pkg = JSON.parse(
|
|
45401
|
-
await fsp__namespace.readFile(
|
|
46138
|
+
await fsp__namespace.readFile(path58__namespace.join(root, "package.json"), "utf8")
|
|
45402
46139
|
);
|
|
45403
46140
|
if (pkg.workspaces) {
|
|
45404
46141
|
if (files.includes("pnpm-workspace.yaml")) return "pnpm";
|
|
@@ -45421,7 +46158,7 @@ async function findWorkspaces(root, type2) {
|
|
|
45421
46158
|
try {
|
|
45422
46159
|
switch (type2) {
|
|
45423
46160
|
case "pnpm": {
|
|
45424
|
-
const wsFile =
|
|
46161
|
+
const wsFile = path58__namespace.join(root, "pnpm-workspace.yaml");
|
|
45425
46162
|
try {
|
|
45426
46163
|
const content = await fsp__namespace.readFile(wsFile, "utf8");
|
|
45427
46164
|
const patterns = content.match(/packages:\s*\n((?:\s+-\s+.+\n?)+)/);
|
|
@@ -45443,7 +46180,7 @@ async function findWorkspaces(root, type2) {
|
|
|
45443
46180
|
}
|
|
45444
46181
|
case "yarn":
|
|
45445
46182
|
case "npm": {
|
|
45446
|
-
const pkgPath =
|
|
46183
|
+
const pkgPath = path58__namespace.join(root, "package.json");
|
|
45447
46184
|
try {
|
|
45448
46185
|
const pkg = JSON.parse(await fsp__namespace.readFile(pkgPath, "utf8"));
|
|
45449
46186
|
const patterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages || [];
|
|
@@ -45462,7 +46199,7 @@ async function findWorkspaces(root, type2) {
|
|
|
45462
46199
|
}
|
|
45463
46200
|
case "lerna": {
|
|
45464
46201
|
try {
|
|
45465
|
-
const lernaPath =
|
|
46202
|
+
const lernaPath = path58__namespace.join(root, "lerna.json");
|
|
45466
46203
|
const lerna = JSON.parse(await fsp__namespace.readFile(lernaPath, "utf8"));
|
|
45467
46204
|
const patterns = lerna.packages || ["packages/*"];
|
|
45468
46205
|
for (const pattern of patterns) {
|
|
@@ -45521,13 +46258,13 @@ async function findWorkspaces(root, type2) {
|
|
|
45521
46258
|
}
|
|
45522
46259
|
async function analyzeWorkspace(workspacePath, root) {
|
|
45523
46260
|
const info = {
|
|
45524
|
-
name:
|
|
46261
|
+
name: path58__namespace.basename(workspacePath),
|
|
45525
46262
|
path: workspacePath,
|
|
45526
46263
|
type: "unknown",
|
|
45527
46264
|
language: "unknown"
|
|
45528
46265
|
};
|
|
45529
46266
|
try {
|
|
45530
|
-
const pkgPath =
|
|
46267
|
+
const pkgPath = path58__namespace.join(root, workspacePath, "package.json");
|
|
45531
46268
|
const pkgContent = await safeRead(pkgPath, 512 * 1024, 1e3);
|
|
45532
46269
|
if (pkgContent.head) {
|
|
45533
46270
|
try {
|
|
@@ -45570,7 +46307,7 @@ async function analyzeWorkspace(workspacePath, root) {
|
|
|
45570
46307
|
}
|
|
45571
46308
|
const globby = await loadGlobby();
|
|
45572
46309
|
const files = await globby(["**/*.{ts,tsx,js,jsx,mjs,cjs}"], {
|
|
45573
|
-
cwd:
|
|
46310
|
+
cwd: path58__namespace.join(root, workspacePath),
|
|
45574
46311
|
deep: 2,
|
|
45575
46312
|
ignore: ["node_modules", "dist", "build"],
|
|
45576
46313
|
stats: false
|
|
@@ -46125,12 +46862,12 @@ function getModuleName(filePath) {
|
|
|
46125
46862
|
if (srcIndex >= 0 && srcIndex < parts.length - 1) {
|
|
46126
46863
|
return parts[srcIndex + 1];
|
|
46127
46864
|
}
|
|
46128
|
-
return
|
|
46865
|
+
return path58__namespace.dirname(filePath).split("/").pop() || "root";
|
|
46129
46866
|
}
|
|
46130
46867
|
function resolveLocalImport(fromFile2, importPath) {
|
|
46131
46868
|
if (!importPath.startsWith(".")) return null;
|
|
46132
|
-
const dir =
|
|
46133
|
-
const resolved =
|
|
46869
|
+
const dir = path58__namespace.dirname(fromFile2);
|
|
46870
|
+
const resolved = path58__namespace.resolve(dir, importPath);
|
|
46134
46871
|
return getModuleName(resolved);
|
|
46135
46872
|
}
|
|
46136
46873
|
function getMetricStatus(metric, value) {
|
|
@@ -46260,7 +46997,7 @@ async function extractCodeSnippets(files, projectRoot, maxSnippets, includeExamp
|
|
|
46260
46997
|
}
|
|
46261
46998
|
async function extractFileSnippet(file, projectRoot, category) {
|
|
46262
46999
|
try {
|
|
46263
|
-
const fullPath =
|
|
47000
|
+
const fullPath = path58__namespace.join(projectRoot, file.path);
|
|
46264
47001
|
const content = await safeRead(fullPath, 512 * 1024, 50);
|
|
46265
47002
|
if (!content.head) return null;
|
|
46266
47003
|
const lines = content.head.split("\n");
|
|
@@ -46271,7 +47008,7 @@ async function extractFileSnippet(file, projectRoot, category) {
|
|
|
46271
47008
|
const codeLines = lines.slice(codeStart, codeStart + 30);
|
|
46272
47009
|
return {
|
|
46273
47010
|
file: file.path,
|
|
46274
|
-
title: `${
|
|
47011
|
+
title: `${path58__namespace.basename(file.path)} - ${category}`,
|
|
46275
47012
|
description: getFileDescription(file),
|
|
46276
47013
|
code: codeLines.join("\n"),
|
|
46277
47014
|
language: file.language || "javascript",
|
|
@@ -46359,7 +47096,7 @@ function extractAPIDocumentation(files) {
|
|
|
46359
47096
|
async function extractConfigurationDetails(projectRoot) {
|
|
46360
47097
|
const details = [];
|
|
46361
47098
|
try {
|
|
46362
|
-
const pkgPath =
|
|
47099
|
+
const pkgPath = path58__namespace.join(projectRoot, "package.json");
|
|
46363
47100
|
const pkgContent = await fsp__namespace.readFile(pkgPath, "utf8");
|
|
46364
47101
|
const pkg = JSON.parse(pkgContent);
|
|
46365
47102
|
if (pkg.engines) {
|
|
@@ -46392,7 +47129,7 @@ async function extractConfigurationDetails(projectRoot) {
|
|
|
46392
47129
|
} catch {
|
|
46393
47130
|
}
|
|
46394
47131
|
try {
|
|
46395
|
-
const tsconfigPath =
|
|
47132
|
+
const tsconfigPath = path58__namespace.join(projectRoot, "tsconfig.json");
|
|
46396
47133
|
const tsconfigContent = await fsp__namespace.readFile(tsconfigPath, "utf8");
|
|
46397
47134
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
46398
47135
|
if (tsconfig.compilerOptions?.strict !== void 0) {
|
|
@@ -46416,7 +47153,7 @@ async function extractConfigurationDetails(projectRoot) {
|
|
|
46416
47153
|
} catch {
|
|
46417
47154
|
}
|
|
46418
47155
|
try {
|
|
46419
|
-
const envExamplePath =
|
|
47156
|
+
const envExamplePath = path58__namespace.join(projectRoot, ".env.example");
|
|
46420
47157
|
const envContent = await fsp__namespace.readFile(envExamplePath, "utf8");
|
|
46421
47158
|
const envVars = envContent.match(/^[A-Z_]+=/gm);
|
|
46422
47159
|
if (envVars) {
|
|
@@ -47354,7 +48091,7 @@ function generateFooter3(data) {
|
|
|
47354
48091
|
}
|
|
47355
48092
|
function generateFallbackMariaMd(error2, projectPath) {
|
|
47356
48093
|
const data = {
|
|
47357
|
-
projectName:
|
|
48094
|
+
projectName: path58__namespace.basename(projectPath),
|
|
47358
48095
|
projectPath,
|
|
47359
48096
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
47360
48097
|
errors: [error2.message]
|
|
@@ -47369,13 +48106,13 @@ var init_maria_template = __esm({
|
|
|
47369
48106
|
});
|
|
47370
48107
|
async function writeAtomic(filePath, content, options = {}) {
|
|
47371
48108
|
const { encoding = "utf8", mode = 420, fsync = true, tmpDir } = options;
|
|
47372
|
-
const dir =
|
|
47373
|
-
const basename15 =
|
|
48109
|
+
const dir = path58__namespace.dirname(filePath);
|
|
48110
|
+
const basename15 = path58__namespace.basename(filePath);
|
|
47374
48111
|
const tmpSuffix = `.tmp-${Date.now()}-${crypto4.randomBytes(4).toString("hex")}`;
|
|
47375
|
-
const tmpPath = tmpDir ?
|
|
48112
|
+
const tmpPath = tmpDir ? path58__namespace.join(tmpDir, `${basename15}${tmpSuffix}`) : path58__namespace.join(dir, `${basename15}${tmpSuffix}`);
|
|
47376
48113
|
let fileHandle = null;
|
|
47377
48114
|
try {
|
|
47378
|
-
await fsp__namespace.mkdir(
|
|
48115
|
+
await fsp__namespace.mkdir(path58__namespace.dirname(tmpPath), { recursive: true });
|
|
47379
48116
|
if (Buffer.isBuffer(content)) {
|
|
47380
48117
|
await fsp__namespace.writeFile(tmpPath, content, { mode });
|
|
47381
48118
|
} else {
|
|
@@ -50676,13 +51413,13 @@ var init_initialization_manager = __esm({
|
|
|
50676
51413
|
if (!stats.isDirectory()) {
|
|
50677
51414
|
this.errors.push(`Working directory is not a directory: ${cwd2}`);
|
|
50678
51415
|
}
|
|
50679
|
-
const packagePath =
|
|
51416
|
+
const packagePath = path58__namespace.join(cwd2, "package.json");
|
|
50680
51417
|
try {
|
|
50681
51418
|
await fsp__namespace.access(packagePath);
|
|
50682
51419
|
} catch {
|
|
50683
51420
|
this.warnings.push("No package.json found in working directory");
|
|
50684
51421
|
}
|
|
50685
|
-
const gitPath =
|
|
51422
|
+
const gitPath = path58__namespace.join(cwd2, ".git");
|
|
50686
51423
|
try {
|
|
50687
51424
|
await fsp__namespace.access(gitPath);
|
|
50688
51425
|
} catch {
|
|
@@ -50734,7 +51471,7 @@ var init_initialization_manager = __esm({
|
|
|
50734
51471
|
}
|
|
50735
51472
|
async validateMonorepoConfig(cwd2) {
|
|
50736
51473
|
try {
|
|
50737
|
-
const packagePath =
|
|
51474
|
+
const packagePath = path58__namespace.join(cwd2, "package.json");
|
|
50738
51475
|
const content = await fsp__namespace.readFile(packagePath, "utf-8");
|
|
50739
51476
|
const pkg = JSON.parse(content);
|
|
50740
51477
|
if (pkg.workspaces) {
|
|
@@ -51124,7 +51861,7 @@ var init_initialization_manager = __esm({
|
|
|
51124
51861
|
async generateEnhancedMariaMd(summary, opts) {
|
|
51125
51862
|
try {
|
|
51126
51863
|
return generateMariaMd2({
|
|
51127
|
-
projectName: summary.projectName ||
|
|
51864
|
+
projectName: summary.projectName || path58__namespace.basename(opts.cwd || process.cwd()),
|
|
51128
51865
|
projectPath: opts.cwd || process.cwd(),
|
|
51129
51866
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51130
51867
|
summary,
|
|
@@ -51145,7 +51882,7 @@ var init_initialization_manager = __esm({
|
|
|
51145
51882
|
const cwd2 = opts.cwd || process.cwd();
|
|
51146
51883
|
for (const [filename, content] of Object.entries(artifacts)) {
|
|
51147
51884
|
if (typeof content === "string") {
|
|
51148
|
-
const filePath =
|
|
51885
|
+
const filePath = path58__namespace.join(cwd2, filename);
|
|
51149
51886
|
try {
|
|
51150
51887
|
await writeAtomic(filePath, content);
|
|
51151
51888
|
this.progressTracker.addMetric(
|
|
@@ -51170,7 +51907,7 @@ var init_initialization_manager = __esm({
|
|
|
51170
51907
|
*/
|
|
51171
51908
|
async verifyOutput(opts) {
|
|
51172
51909
|
const cwd2 = opts.cwd || process.cwd();
|
|
51173
|
-
const mariaMdPath =
|
|
51910
|
+
const mariaMdPath = path58__namespace.join(cwd2, "MARIA.md");
|
|
51174
51911
|
try {
|
|
51175
51912
|
const content = await fsp__namespace.readFile(mariaMdPath, "utf-8");
|
|
51176
51913
|
const minLength = 2e3;
|
|
@@ -51203,7 +51940,7 @@ var init_initialization_manager = __esm({
|
|
|
51203
51940
|
createMinimalSummary(opts) {
|
|
51204
51941
|
const cwd2 = opts.cwd || process.cwd();
|
|
51205
51942
|
return {
|
|
51206
|
-
projectName:
|
|
51943
|
+
projectName: path58__namespace.basename(cwd2),
|
|
51207
51944
|
projectPath: cwd2,
|
|
51208
51945
|
description: "Project analysis incomplete due to errors",
|
|
51209
51946
|
techStack: {
|
|
@@ -51238,7 +51975,7 @@ var init_initialization_manager = __esm({
|
|
|
51238
51975
|
*/
|
|
51239
51976
|
async generateFallbackArtifacts(error2, opts) {
|
|
51240
51977
|
const cwd2 = opts.cwd || process.cwd();
|
|
51241
|
-
|
|
51978
|
+
path58__namespace.basename(cwd2);
|
|
51242
51979
|
const mariaMd = generateFallbackMariaMd({
|
|
51243
51980
|
});
|
|
51244
51981
|
const initReport = `# Init Report - Error Recovery Mode
|
|
@@ -51295,7 +52032,7 @@ async function safeBackup(_filePath) {
|
|
|
51295
52032
|
await fsp__namespace.copyFile(_filePath, bakPath);
|
|
51296
52033
|
if (!process.env.MARIA_INIT_QUIET) {
|
|
51297
52034
|
console.log(
|
|
51298
|
-
chalk38__default.default.gray(` \u21B3 backup: ${
|
|
52035
|
+
chalk38__default.default.gray(` \u21B3 backup: ${path58__namespace.relative(process.cwd(), bakPath)}`)
|
|
51299
52036
|
);
|
|
51300
52037
|
}
|
|
51301
52038
|
} catch {
|
|
@@ -51333,7 +52070,7 @@ async function writeArtifacts(artifacts, opts, cwd2, reporter) {
|
|
|
51333
52070
|
{ name: "INIT_SUMMARY.txt", content: artifacts.initSummaryTxt }
|
|
51334
52071
|
];
|
|
51335
52072
|
for (const { name: name2, content } of files) {
|
|
51336
|
-
const _filePath =
|
|
52073
|
+
const _filePath = path58__namespace.join(cwd2, name2);
|
|
51337
52074
|
if (await fileExists2(_filePath) && !opts.force) {
|
|
51338
52075
|
await safeBackup(_filePath);
|
|
51339
52076
|
}
|
|
@@ -51443,7 +52180,7 @@ This process will:
|
|
|
51443
52180
|
);
|
|
51444
52181
|
const artifacts = generateArtifacts(summary, findings, startTime);
|
|
51445
52182
|
const mariaMdContent = generateMariaMd2({
|
|
51446
|
-
projectName: summary.projectName ||
|
|
52183
|
+
projectName: summary.projectName || path58__namespace.basename(cwd2),
|
|
51447
52184
|
projectPath: cwd2,
|
|
51448
52185
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51449
52186
|
summary,
|
|
@@ -51603,7 +52340,7 @@ var init_delta_detector = __esm({
|
|
|
51603
52340
|
const changes = stdout2.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => {
|
|
51604
52341
|
const [status, ...rest] = line.split(/\s+/);
|
|
51605
52342
|
const file = rest.join(" ");
|
|
51606
|
-
return { status, file:
|
|
52343
|
+
return { status, file: path58__namespace.resolve(root, file) };
|
|
51607
52344
|
});
|
|
51608
52345
|
const filtered = await this.filterFiles(
|
|
51609
52346
|
changes.map((c) => c.file),
|
|
@@ -51612,8 +52349,8 @@ var init_delta_detector = __esm({
|
|
|
51612
52349
|
);
|
|
51613
52350
|
const filteredSet = new Set(filtered);
|
|
51614
52351
|
const filteredChanges = changes.filter((c) => filteredSet.has(c.file));
|
|
51615
|
-
const deleted = filteredChanges.filter((c) => c.status === "D").map((c) =>
|
|
51616
|
-
const changed = filteredChanges.filter((c) => c.status !== "D").map((c) =>
|
|
52352
|
+
const deleted = filteredChanges.filter((c) => c.status === "D").map((c) => path58__namespace.relative(root, c.file));
|
|
52353
|
+
const changed = filteredChanges.filter((c) => c.status !== "D").map((c) => path58__namespace.relative(root, c.file));
|
|
51617
52354
|
return {
|
|
51618
52355
|
mode: "git",
|
|
51619
52356
|
ref,
|
|
@@ -51645,7 +52382,7 @@ var init_delta_detector = __esm({
|
|
|
51645
52382
|
break;
|
|
51646
52383
|
}
|
|
51647
52384
|
if (entry.mtime && entry.mtime > since) {
|
|
51648
|
-
changed.push(
|
|
52385
|
+
changed.push(path58__namespace.relative(root, entry.file));
|
|
51649
52386
|
}
|
|
51650
52387
|
if (options.maxFiles && changed.length >= options.maxFiles) {
|
|
51651
52388
|
break;
|
|
@@ -51669,7 +52406,7 @@ var init_delta_detector = __esm({
|
|
|
51669
52406
|
* Detect changes by comparing with state.json
|
|
51670
52407
|
*/
|
|
51671
52408
|
async detectByState(root, options) {
|
|
51672
|
-
const statePath =
|
|
52409
|
+
const statePath = path58__namespace.join(root, ".maria", "state.json");
|
|
51673
52410
|
let lastHashes = {};
|
|
51674
52411
|
try {
|
|
51675
52412
|
const stateContent = await fsp__namespace.readFile(statePath, "utf-8");
|
|
@@ -51685,7 +52422,7 @@ var init_delta_detector = __esm({
|
|
|
51685
52422
|
if (options.budgetMs && Date.now() - this.startTime > options.budgetMs) {
|
|
51686
52423
|
break;
|
|
51687
52424
|
}
|
|
51688
|
-
const relativePath =
|
|
52425
|
+
const relativePath = path58__namespace.relative(root, entry.file);
|
|
51689
52426
|
const hash = entry.hash || await this.hashFile(entry.file);
|
|
51690
52427
|
nowHashes[relativePath] = hash;
|
|
51691
52428
|
if (!lastHashes[relativePath] || lastHashes[relativePath] !== hash) {
|
|
@@ -51765,7 +52502,7 @@ var init_delta_detector = __esm({
|
|
|
51765
52502
|
}
|
|
51766
52503
|
const patterns = options.include || ["**/*"];
|
|
51767
52504
|
const ignore = options.exclude || [];
|
|
51768
|
-
const relativePaths = files.map((f3) =>
|
|
52505
|
+
const relativePaths = files.map((f3) => path58__namespace.relative(root, f3));
|
|
51769
52506
|
const globby = await loadGlobby();
|
|
51770
52507
|
const matched = await globby(patterns, {
|
|
51771
52508
|
cwd: root,
|
|
@@ -51790,8 +52527,8 @@ var init_delta_detector = __esm({
|
|
|
51790
52527
|
* Update state.json with new hashes
|
|
51791
52528
|
*/
|
|
51792
52529
|
async updateState(root, delta) {
|
|
51793
|
-
const statePath =
|
|
51794
|
-
await fsp__namespace.mkdir(
|
|
52530
|
+
const statePath = path58__namespace.join(root, ".maria", "state.json");
|
|
52531
|
+
await fsp__namespace.mkdir(path58__namespace.dirname(statePath), { recursive: true });
|
|
51795
52532
|
let state;
|
|
51796
52533
|
try {
|
|
51797
52534
|
const content = await fsp__namespace.readFile(statePath, "utf-8");
|
|
@@ -51816,7 +52553,7 @@ var init_delta_detector = __esm({
|
|
|
51816
52553
|
delete currentHashes[file];
|
|
51817
52554
|
});
|
|
51818
52555
|
for (const file of delta.changed) {
|
|
51819
|
-
const fullPath =
|
|
52556
|
+
const fullPath = path58__namespace.join(root, file);
|
|
51820
52557
|
try {
|
|
51821
52558
|
const hash = await this.hashFile(fullPath);
|
|
51822
52559
|
if (hash) {
|
|
@@ -52750,8 +53487,8 @@ var init_init_command = __esm({
|
|
|
52750
53487
|
async execute(options = {}) {
|
|
52751
53488
|
const startTime = Date.now();
|
|
52752
53489
|
const root = options.root || process.cwd();
|
|
52753
|
-
const stateDir =
|
|
52754
|
-
const statePath =
|
|
53490
|
+
const stateDir = path58__namespace.join(root, ".maria");
|
|
53491
|
+
const statePath = path58__namespace.join(stateDir, "state.json");
|
|
52755
53492
|
this.logger.header("MARIA /init - Enhanced Codebase Analysis");
|
|
52756
53493
|
const hasExistingState = await this.fileExists(statePath);
|
|
52757
53494
|
if (hasExistingState && !options.force) {
|
|
@@ -52876,7 +53613,7 @@ var init_init_command = __esm({
|
|
|
52876
53613
|
nodes.push({
|
|
52877
53614
|
id: file._path,
|
|
52878
53615
|
type: "file",
|
|
52879
|
-
name:
|
|
53616
|
+
name: path58__namespace.basename(file._path),
|
|
52880
53617
|
language: file.language,
|
|
52881
53618
|
size: file.size,
|
|
52882
53619
|
complexity: file.complexity
|
|
@@ -52981,7 +53718,7 @@ ${file.summary || ""}`,
|
|
|
52981
53718
|
async generateArtifacts(root, scanResult, graphResult) {
|
|
52982
53719
|
this.logger.start("artifacts", "Generating artifacts...");
|
|
52983
53720
|
const mariaMd = this.generateMariaMd(scanResult, graphResult);
|
|
52984
|
-
const mariaMdPath =
|
|
53721
|
+
const mariaMdPath = path58__namespace.join(root, "MARIA.md");
|
|
52985
53722
|
await fsp__namespace.writeFile(mariaMdPath, mariaMd, "utf-8");
|
|
52986
53723
|
const depMapJson = {
|
|
52987
53724
|
version: "3.2.2",
|
|
@@ -52998,7 +53735,7 @@ ${file.summary || ""}`,
|
|
|
52998
53735
|
edges: graphResult.edgesCreated
|
|
52999
53736
|
}
|
|
53000
53737
|
};
|
|
53001
|
-
const depMapPath =
|
|
53738
|
+
const depMapPath = path58__namespace.join(root, "DEPENDENCY_MAP.json");
|
|
53002
53739
|
await fsp__namespace.writeFile(
|
|
53003
53740
|
depMapPath,
|
|
53004
53741
|
JSON.stringify(depMapJson, null, 2),
|
|
@@ -53179,7 +53916,7 @@ Last updated: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
|
53179
53916
|
}
|
|
53180
53917
|
async saveState(stateDir, state) {
|
|
53181
53918
|
await fsp__namespace.mkdir(stateDir, { recursive: true });
|
|
53182
|
-
const statePath =
|
|
53919
|
+
const statePath = path58__namespace.join(stateDir, "state.json");
|
|
53183
53920
|
await fsp__namespace.writeFile(statePath, JSON.stringify(state, null, 2), "utf-8");
|
|
53184
53921
|
}
|
|
53185
53922
|
async fileExists(_path) {
|
|
@@ -53407,17 +54144,17 @@ var init_GraphEngine = __esm({
|
|
|
53407
54144
|
const visited = /* @__PURE__ */ new Set();
|
|
53408
54145
|
const queue = [{ id: from, path: [from] }];
|
|
53409
54146
|
while (queue.length) {
|
|
53410
|
-
const { id, path:
|
|
54147
|
+
const { id, path: path59 } = queue.shift();
|
|
53411
54148
|
if (visited.has(id)) continue;
|
|
53412
54149
|
visited.add(id);
|
|
53413
54150
|
const neighbors = this.edges.get(id) || /* @__PURE__ */ new Set();
|
|
53414
54151
|
for (const e2 of neighbors) {
|
|
53415
54152
|
if (e2.to === to) {
|
|
53416
|
-
const res = [...
|
|
54153
|
+
const res = [...path59, to];
|
|
53417
54154
|
this.recordQueryTime(Date.now() - start);
|
|
53418
54155
|
return res;
|
|
53419
54156
|
}
|
|
53420
|
-
if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...
|
|
54157
|
+
if (!visited.has(e2.to)) queue.push({ id: e2.to, path: [...path59, e2.to] });
|
|
53421
54158
|
}
|
|
53422
54159
|
}
|
|
53423
54160
|
this.recordQueryTime(Date.now() - start);
|
|
@@ -53604,8 +54341,8 @@ var init_GraphStore = __esm({
|
|
|
53604
54341
|
accessCounter = 0;
|
|
53605
54342
|
constructor(_maxNodes = 1e4) {
|
|
53606
54343
|
this._maxNodes = _maxNodes;
|
|
53607
|
-
this.storageDir =
|
|
53608
|
-
this.graphFile =
|
|
54344
|
+
this.storageDir = path58__namespace.default.join(process.cwd(), ".maria", "graph");
|
|
54345
|
+
this.graphFile = path58__namespace.default.join(this.storageDir, "knowledge-graph.json");
|
|
53609
54346
|
this.startPeriodicSave();
|
|
53610
54347
|
}
|
|
53611
54348
|
/**
|
|
@@ -54129,8 +54866,8 @@ var init_DependencyAnalyzer = __esm({
|
|
|
54129
54866
|
*/
|
|
54130
54867
|
resolveImportPath(_importSource, fromFile2, rootDir) {
|
|
54131
54868
|
if (_importSource.startsWith("./") || _importSource.startsWith("../")) {
|
|
54132
|
-
const _fromDir =
|
|
54133
|
-
const _resolved =
|
|
54869
|
+
const _fromDir = path58__namespace.default.dirname(fromFile2);
|
|
54870
|
+
const _resolved = path58__namespace.default.resolve(_fromDir, _importSource);
|
|
54134
54871
|
for (const _ext of this.SUPPORTED_EXTENSIONS) {
|
|
54135
54872
|
if (_resolved.endsWith(_ext)) {
|
|
54136
54873
|
return _resolved;
|
|
@@ -54140,7 +54877,7 @@ var init_DependencyAnalyzer = __esm({
|
|
|
54140
54877
|
__require.resolve(_withExt);
|
|
54141
54878
|
return _withExt;
|
|
54142
54879
|
} catch {
|
|
54143
|
-
const _indexFile =
|
|
54880
|
+
const _indexFile = path58__namespace.default.join(_resolved, `index${_ext}`);
|
|
54144
54881
|
try {
|
|
54145
54882
|
__require.resolve(_indexFile);
|
|
54146
54883
|
return _indexFile;
|
|
@@ -54152,7 +54889,7 @@ var init_DependencyAnalyzer = __esm({
|
|
|
54152
54889
|
return _resolved;
|
|
54153
54890
|
}
|
|
54154
54891
|
if (!_importSource.startsWith("@") && !_importSource.includes("node_modules")) {
|
|
54155
|
-
const _resolved =
|
|
54892
|
+
const _resolved = path58__namespace.default.resolve(rootDir, _importSource);
|
|
54156
54893
|
for (const _ext of this.SUPPORTED_EXTENSIONS) {
|
|
54157
54894
|
const _withExt = _resolved + _ext;
|
|
54158
54895
|
try {
|
|
@@ -54175,7 +54912,7 @@ var init_DependencyAnalyzer = __esm({
|
|
|
54175
54912
|
try {
|
|
54176
54913
|
const _entries = await fsp__namespace.default.readdir(dir, { withFileTypes: true });
|
|
54177
54914
|
for (const entry of _entries) {
|
|
54178
|
-
const _fullPath =
|
|
54915
|
+
const _fullPath = path58__namespace.default.join(dir, entry.name);
|
|
54179
54916
|
if (entry.isDirectory()) {
|
|
54180
54917
|
if (!["node_modules", ".git", "dist", "build", ".next"].includes(
|
|
54181
54918
|
entry.name
|
|
@@ -54183,7 +54920,7 @@ var init_DependencyAnalyzer = __esm({
|
|
|
54183
54920
|
await traverse(_fullPath);
|
|
54184
54921
|
}
|
|
54185
54922
|
} else if (entry.isFile()) {
|
|
54186
|
-
const _ext =
|
|
54923
|
+
const _ext = path58__namespace.default.extname(entry.name);
|
|
54187
54924
|
if ([".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(_ext)) {
|
|
54188
54925
|
files.push(_fullPath);
|
|
54189
54926
|
}
|
|
@@ -54339,7 +55076,7 @@ var init_DependencyAnalyzer = __esm({
|
|
|
54339
55076
|
return {
|
|
54340
55077
|
id: this.generateNodeId(_filePath),
|
|
54341
55078
|
type: "file",
|
|
54342
|
-
name:
|
|
55079
|
+
name: path58__namespace.default.basename(_filePath),
|
|
54343
55080
|
_path: _filePath,
|
|
54344
55081
|
metadata: {
|
|
54345
55082
|
size: _stats.size,
|
|
@@ -54379,7 +55116,7 @@ var init_DependencyAnalyzer = __esm({
|
|
|
54379
55116
|
}
|
|
54380
55117
|
}
|
|
54381
55118
|
detectLanguage(_filePath) {
|
|
54382
|
-
const _ext =
|
|
55119
|
+
const _ext = path58__namespace.default.extname(_filePath);
|
|
54383
55120
|
switch (_ext) {
|
|
54384
55121
|
case ".ts":
|
|
54385
55122
|
case ".tsx":
|
|
@@ -55177,7 +55914,7 @@ var init_KnowledgeGraphService = __esm({
|
|
|
55177
55914
|
_filePath,
|
|
55178
55915
|
depth
|
|
55179
55916
|
);
|
|
55180
|
-
const _fileName2 =
|
|
55917
|
+
const _fileName2 = path58__namespace.default.basename(_filePath);
|
|
55181
55918
|
const _relatedNodes = this.graphEngine.searchNodes(_fileName2);
|
|
55182
55919
|
const suggestions = [];
|
|
55183
55920
|
for (const node of _graphContext.nodes.slice(0, 5)) {
|
|
@@ -55491,8 +56228,8 @@ async function legacyInit(args2) {
|
|
|
55491
56228
|
const cliCwd = process.cwd();
|
|
55492
56229
|
console.log(chalk38__default.default.blue("\u{1F680} Initializing MARIA configuration..."));
|
|
55493
56230
|
const options = parseInitOptions(args2);
|
|
55494
|
-
const repoRoot =
|
|
55495
|
-
const tomlPath =
|
|
56231
|
+
const repoRoot = path58__namespace.resolve(options.root || await findRepoRoot(cliCwd));
|
|
56232
|
+
const tomlPath = path58__namespace.join(repoRoot, ".maria-code.toml");
|
|
55496
56233
|
const existingConfig = await fileExists3(tomlPath);
|
|
55497
56234
|
if (existingConfig && !args2.includes("--force")) {
|
|
55498
56235
|
const result = await prompts__default.default({
|
|
@@ -55506,7 +56243,7 @@ async function legacyInit(args2) {
|
|
|
55506
56243
|
return "exit";
|
|
55507
56244
|
}
|
|
55508
56245
|
await safeBackup2(tomlPath);
|
|
55509
|
-
const mdPath2 =
|
|
56246
|
+
const mdPath2 = path58__namespace.join(repoRoot, "MARIA.md");
|
|
55510
56247
|
if (await fileExists3(mdPath2)) {
|
|
55511
56248
|
await safeBackup2(mdPath2);
|
|
55512
56249
|
}
|
|
@@ -55520,35 +56257,35 @@ async function legacyInit(args2) {
|
|
|
55520
56257
|
const tomlContent = generateTomlConfig(projectConfig);
|
|
55521
56258
|
try {
|
|
55522
56259
|
const tomlStatus = await safeWriteIfChanged(tomlPath, tomlContent);
|
|
55523
|
-
const rel =
|
|
56260
|
+
const rel = path58__namespace.relative(cliCwd, tomlPath);
|
|
55524
56261
|
if (tomlStatus.status === "up-to-date") {
|
|
55525
56262
|
console.log(chalk38__default.default.gray(`\u2139\uFE0F Up-to-date: ${rel}`));
|
|
55526
56263
|
} else if (tomlStatus.status === "created") {
|
|
55527
56264
|
console.log(chalk38__default.default.green(`\u2705 Created: ${rel}`));
|
|
55528
56265
|
} else if (tomlStatus.status === "updated") {
|
|
55529
|
-
console.log(chalk38__default.default.green(`\u2705 Updated: ${rel}`) + (tomlStatus.backup ? chalk38__default.default.gray(` (backup: ${
|
|
56266
|
+
console.log(chalk38__default.default.green(`\u2705 Updated: ${rel}`) + (tomlStatus.backup ? chalk38__default.default.gray(` (backup: ${path58__namespace.relative(cliCwd, tomlStatus.backup)})`) : ""));
|
|
55530
56267
|
}
|
|
55531
56268
|
} catch (e2) {
|
|
55532
56269
|
console.error(chalk38__default.default.red("\u274C Failed to write .maria-code.toml:"), adviceFromFsError(e2));
|
|
55533
56270
|
}
|
|
55534
|
-
const mdPath =
|
|
56271
|
+
const mdPath = path58__namespace.join(repoRoot, "MARIA.md");
|
|
55535
56272
|
const lang = resolveLang(options.lang);
|
|
55536
56273
|
const mdContent = generateMariaMd3(projectConfig, lang);
|
|
55537
56274
|
try {
|
|
55538
56275
|
const mdStatus = await safeWriteIfChanged(mdPath, mdContent);
|
|
55539
|
-
const rel =
|
|
56276
|
+
const rel = path58__namespace.relative(cliCwd, mdPath);
|
|
55540
56277
|
if (mdStatus.status === "up-to-date") {
|
|
55541
56278
|
console.log(chalk38__default.default.gray(`Saved: ${rel} (up-to-date)`));
|
|
55542
56279
|
} else if (mdStatus.status === "created") {
|
|
55543
56280
|
console.log(chalk38__default.default.green(`Saved: ${rel} (created)`));
|
|
55544
56281
|
} else if (mdStatus.status === "updated") {
|
|
55545
|
-
const bakRel = mdStatus.backup ?
|
|
56282
|
+
const bakRel = mdStatus.backup ? path58__namespace.relative(cliCwd, mdStatus.backup) : void 0;
|
|
55546
56283
|
console.log(chalk38__default.default.green(`Saved: ${rel} (updated${bakRel ? `, backup: ${bakRel}` : ""})`));
|
|
55547
56284
|
}
|
|
55548
56285
|
} catch (e2) {
|
|
55549
56286
|
console.error(chalk38__default.default.red("\u274C Failed to write MARIA.md:"), adviceFromFsError(e2));
|
|
55550
56287
|
}
|
|
55551
|
-
if (projectConfig.gitInit && !await fileExists3(
|
|
56288
|
+
if (projectConfig.gitInit && !await fileExists3(path58__namespace.join(repoRoot, ".git"))) {
|
|
55552
56289
|
try {
|
|
55553
56290
|
const { execSync } = await import('child_process');
|
|
55554
56291
|
execSync("git init", { cwd: repoRoot, stdio: "pipe" });
|
|
@@ -55582,13 +56319,13 @@ async function safeBackup2(_filePath) {
|
|
|
55582
56319
|
const bakPath = `${_filePath}.bak.${stamp}`;
|
|
55583
56320
|
await fsp__namespace.copyFile(_filePath, bakPath);
|
|
55584
56321
|
console.log(
|
|
55585
|
-
chalk38__default.default.gray(` \u21B3 backup: ${
|
|
56322
|
+
chalk38__default.default.gray(` \u21B3 backup: ${path58__namespace.relative(process.cwd(), bakPath)}`)
|
|
55586
56323
|
);
|
|
55587
56324
|
} catch {
|
|
55588
56325
|
}
|
|
55589
56326
|
}
|
|
55590
56327
|
async function interactiveSetup() {
|
|
55591
|
-
const packageJsonPath =
|
|
56328
|
+
const packageJsonPath = path58__namespace.join(process.cwd(), "package.json");
|
|
55592
56329
|
let packageJson2 = {};
|
|
55593
56330
|
try {
|
|
55594
56331
|
const packageData = await fsp__namespace.readFile(packageJsonPath, "utf-8");
|
|
@@ -55600,7 +56337,7 @@ async function interactiveSetup() {
|
|
|
55600
56337
|
type: "text",
|
|
55601
56338
|
name: "name",
|
|
55602
56339
|
message: "Project name:",
|
|
55603
|
-
initial: packageJson2.name ||
|
|
56340
|
+
initial: packageJson2.name || path58__namespace.basename(process.cwd())
|
|
55604
56341
|
},
|
|
55605
56342
|
{
|
|
55606
56343
|
type: "select",
|
|
@@ -55644,7 +56381,7 @@ async function interactiveSetup() {
|
|
|
55644
56381
|
}
|
|
55645
56382
|
function getDefaultConfig() {
|
|
55646
56383
|
return {
|
|
55647
|
-
name:
|
|
56384
|
+
name: path58__namespace.basename(process.cwd()),
|
|
55648
56385
|
type: "auto",
|
|
55649
56386
|
description: "AI-powered development project using MARIA",
|
|
55650
56387
|
author: "",
|
|
@@ -55825,13 +56562,13 @@ function resolveLang(input3) {
|
|
|
55825
56562
|
return "en";
|
|
55826
56563
|
}
|
|
55827
56564
|
async function findRepoRoot(startDir) {
|
|
55828
|
-
let dir =
|
|
56565
|
+
let dir = path58__namespace.resolve(startDir);
|
|
55829
56566
|
let lastGitDir = null;
|
|
55830
56567
|
while (true) {
|
|
55831
|
-
const gitPath =
|
|
56568
|
+
const gitPath = path58__namespace.join(dir, ".git");
|
|
55832
56569
|
const hasGit = await fileExists3(gitPath);
|
|
55833
56570
|
if (hasGit) lastGitDir = dir;
|
|
55834
|
-
const parent =
|
|
56571
|
+
const parent = path58__namespace.dirname(dir);
|
|
55835
56572
|
if (parent === dir) break;
|
|
55836
56573
|
dir = parent;
|
|
55837
56574
|
}
|
|
@@ -55913,8 +56650,8 @@ var init_update_command = __esm({
|
|
|
55913
56650
|
async execute(options = {}) {
|
|
55914
56651
|
const startTime = Date.now();
|
|
55915
56652
|
const root = options.root || process.cwd();
|
|
55916
|
-
const stateDir =
|
|
55917
|
-
const statePath =
|
|
56653
|
+
const stateDir = path58__namespace.join(root, ".maria");
|
|
56654
|
+
const statePath = path58__namespace.join(stateDir, "state.json");
|
|
55918
56655
|
this.reporter.thinking(`Performing incremental update to detect and process changes.
|
|
55919
56656
|
This will:
|
|
55920
56657
|
- Detect file changes since last update
|
|
@@ -56084,12 +56821,12 @@ This will:
|
|
|
56084
56821
|
};
|
|
56085
56822
|
const result = await this.deltaDetector.detectDelta(root, deltaOptions);
|
|
56086
56823
|
const files = [
|
|
56087
|
-
...result.changed.map((
|
|
56088
|
-
_path:
|
|
56089
|
-
type: previousState?.fileHashes?.[
|
|
56824
|
+
...result.changed.map((path59) => ({
|
|
56825
|
+
_path: path59,
|
|
56826
|
+
type: previousState?.fileHashes?.[path59] ? "modified" : "added"
|
|
56090
56827
|
})),
|
|
56091
|
-
...result.deleted.map((
|
|
56092
|
-
_path:
|
|
56828
|
+
...result.deleted.map((path59) => ({
|
|
56829
|
+
_path: path59,
|
|
56093
56830
|
type: "deleted"
|
|
56094
56831
|
}))
|
|
56095
56832
|
];
|
|
@@ -56206,7 +56943,7 @@ This will:
|
|
|
56206
56943
|
nodeUpdates.push({
|
|
56207
56944
|
id: file._path,
|
|
56208
56945
|
type: "file",
|
|
56209
|
-
name:
|
|
56946
|
+
name: path58__namespace.basename(file._path),
|
|
56210
56947
|
language: file.language,
|
|
56211
56948
|
size: file.size,
|
|
56212
56949
|
complexity: file.complexity,
|
|
@@ -56306,7 +57043,7 @@ ${file.summary || ""}`,
|
|
|
56306
57043
|
*/
|
|
56307
57044
|
async updateArtifacts(root, deltaResult, processResult) {
|
|
56308
57045
|
this.logger.start("artifacts", "Updating artifacts...");
|
|
56309
|
-
const mariaMdPath =
|
|
57046
|
+
const mariaMdPath = path58__namespace.join(root, "MARIA.md");
|
|
56310
57047
|
let existingContent = "";
|
|
56311
57048
|
try {
|
|
56312
57049
|
existingContent = await fsp__namespace.readFile(mariaMdPath, "utf-8");
|
|
@@ -56320,7 +57057,7 @@ ${file.summary || ""}`,
|
|
|
56320
57057
|
);
|
|
56321
57058
|
await fsp__namespace.writeFile(mariaMdPath, updatedMariaMd, "utf-8");
|
|
56322
57059
|
this.reporter.write("MARIA.md", updatedMariaMd.length);
|
|
56323
|
-
const depMapPath =
|
|
57060
|
+
const depMapPath = path58__namespace.join(root, "DEPENDENCY_MAP.json");
|
|
56324
57061
|
try {
|
|
56325
57062
|
const existingDepMap = JSON.parse(await fsp__namespace.readFile(depMapPath, "utf-8"));
|
|
56326
57063
|
this.reporter.read(
|
|
@@ -56439,7 +57176,7 @@ ${delta.modified > 5 ? `... and ${delta.modified - 5} more` : ""}
|
|
|
56439
57176
|
}
|
|
56440
57177
|
}
|
|
56441
57178
|
async saveState(statePath, state) {
|
|
56442
|
-
const dir =
|
|
57179
|
+
const dir = path58__namespace.dirname(statePath);
|
|
56443
57180
|
await fsp__namespace.mkdir(dir, { recursive: true });
|
|
56444
57181
|
if (state.fileHashes instanceof Map) {
|
|
56445
57182
|
state.fileHashes = Object.fromEntries(state.fileHashes);
|
|
@@ -56593,9 +57330,9 @@ var init_update = __esm({
|
|
|
56593
57330
|
var UpdateCommand_exports = {};
|
|
56594
57331
|
__export(UpdateCommand_exports, {
|
|
56595
57332
|
UpdateCommand: () => UpdateCommand2,
|
|
56596
|
-
meta: () =>
|
|
57333
|
+
meta: () => meta17
|
|
56597
57334
|
});
|
|
56598
|
-
var UpdateCommand2,
|
|
57335
|
+
var UpdateCommand2, meta17;
|
|
56599
57336
|
var init_UpdateCommand = __esm({
|
|
56600
57337
|
"src/slash-commands/categories/core/handlers/UpdateCommand.ts"() {
|
|
56601
57338
|
init_base_command();
|
|
@@ -56746,7 +57483,7 @@ var init_UpdateCommand = __esm({
|
|
|
56746
57483
|
return errors;
|
|
56747
57484
|
}
|
|
56748
57485
|
};
|
|
56749
|
-
|
|
57486
|
+
meta17 = {
|
|
56750
57487
|
name: "update",
|
|
56751
57488
|
category: "core",
|
|
56752
57489
|
description: "Update project dependencies, configurations, and system components",
|
|
@@ -56860,7 +57597,7 @@ var init_ResearchCommand = __esm({
|
|
|
56860
57597
|
constructor() {
|
|
56861
57598
|
super();
|
|
56862
57599
|
this.contentExtractor = new ContentExtractor();
|
|
56863
|
-
this.knowledgeBasePath =
|
|
57600
|
+
this.knowledgeBasePath = path58__namespace.default.join(os13__namespace.default.homedir(), ".maria", "knowledge-base");
|
|
56864
57601
|
}
|
|
56865
57602
|
async initialize() {
|
|
56866
57603
|
try {
|
|
@@ -57391,7 +58128,7 @@ ${JSON.stringify(_result, null, 2)}
|
|
|
57391
58128
|
readingTime: _content.metadata.readingTime
|
|
57392
58129
|
}
|
|
57393
58130
|
};
|
|
57394
|
-
const _entryPath =
|
|
58131
|
+
const _entryPath = path58__namespace.default.join(this.knowledgeBasePath, "entries", `${id}.json`);
|
|
57395
58132
|
await fsp__namespace.default.writeFile(_entryPath, JSON.stringify(_entry, null, 2));
|
|
57396
58133
|
await this.updateKnowledgeBaseIndex(_entry);
|
|
57397
58134
|
logger.info(`Saved to knowledge base: ${id}`);
|
|
@@ -57402,7 +58139,7 @@ ${JSON.stringify(_result, null, 2)}
|
|
|
57402
58139
|
}
|
|
57403
58140
|
}
|
|
57404
58141
|
async updateKnowledgeBaseIndex(_entry) {
|
|
57405
|
-
const _indexPath =
|
|
58142
|
+
const _indexPath = path58__namespace.default.join(this.knowledgeBasePath, "index.json");
|
|
57406
58143
|
try {
|
|
57407
58144
|
const _indexContent = await fsp__namespace.default.readFile(_indexPath, "utf-8");
|
|
57408
58145
|
const _index = JSON.parse(_indexContent);
|
|
@@ -57422,7 +58159,7 @@ ${JSON.stringify(_result, null, 2)}
|
|
|
57422
58159
|
async ensureKnowledgeBaseDirectory() {
|
|
57423
58160
|
try {
|
|
57424
58161
|
await fsp__namespace.default.mkdir(this.knowledgeBasePath, { recursive: true });
|
|
57425
|
-
await fsp__namespace.default.mkdir(
|
|
58162
|
+
await fsp__namespace.default.mkdir(path58__namespace.default.join(this.knowledgeBasePath, "entries"), { recursive: true });
|
|
57426
58163
|
} catch (innerError) {
|
|
57427
58164
|
logger.error("Failed to create knowledge base directory:", error);
|
|
57428
58165
|
}
|
|
@@ -57490,7 +58227,7 @@ ${JSON.stringify(_result, null, 2)}
|
|
|
57490
58227
|
`;
|
|
57491
58228
|
}
|
|
57492
58229
|
try {
|
|
57493
|
-
const _indexPath =
|
|
58230
|
+
const _indexPath = path58__namespace.default.join(this.knowledgeBasePath, "index.json");
|
|
57494
58231
|
const _indexContent = await fsp__namespace.default.readFile(_indexPath, "utf-8");
|
|
57495
58232
|
const _index = JSON.parse(_indexContent);
|
|
57496
58233
|
message += `**Knowledge Base**: \u2705 Available
|
|
@@ -57555,9 +58292,9 @@ var l2r_command_exports = {};
|
|
|
57555
58292
|
__export(l2r_command_exports, {
|
|
57556
58293
|
L2RCommand: () => L2RCommand,
|
|
57557
58294
|
default: () => l2r_command_default,
|
|
57558
|
-
meta: () =>
|
|
58295
|
+
meta: () => meta18
|
|
57559
58296
|
});
|
|
57560
|
-
var L2RCommand,
|
|
58297
|
+
var L2RCommand, meta18, l2r_command_default;
|
|
57561
58298
|
var init_l2r_command = __esm({
|
|
57562
58299
|
"src/slash-commands/categories/learning/l2r.command.ts"() {
|
|
57563
58300
|
init_base_command();
|
|
@@ -58554,7 +59291,7 @@ var init_l2r_command = __esm({
|
|
|
58554
59291
|
return { success: true };
|
|
58555
59292
|
}
|
|
58556
59293
|
};
|
|
58557
|
-
|
|
59294
|
+
meta18 = {
|
|
58558
59295
|
name: "l2r",
|
|
58559
59296
|
category: "learning",
|
|
58560
59297
|
description: "\u{1F3AF} Learning-to-Rank system with 44-dimension features and model training *GPU needed - Local LLM only (Pro+ members only)",
|
|
@@ -58578,9 +59315,9 @@ var search_command_exports = {};
|
|
|
58578
59315
|
__export(search_command_exports, {
|
|
58579
59316
|
GraphRAGSearchCommand: () => GraphRAGSearchCommand,
|
|
58580
59317
|
default: () => search_command_default,
|
|
58581
|
-
meta: () =>
|
|
59318
|
+
meta: () => meta19
|
|
58582
59319
|
});
|
|
58583
|
-
var GraphRAGSearchCommand,
|
|
59320
|
+
var GraphRAGSearchCommand, meta19, search_command_default;
|
|
58584
59321
|
var init_search_command = __esm({
|
|
58585
59322
|
"src/slash-commands/categories/graphrag/search.command.ts"() {
|
|
58586
59323
|
init_base_command();
|
|
@@ -58993,7 +59730,7 @@ var init_search_command = __esm({
|
|
|
58993
59730
|
return { success: true };
|
|
58994
59731
|
}
|
|
58995
59732
|
};
|
|
58996
|
-
|
|
59733
|
+
meta19 = {
|
|
58997
59734
|
name: "search",
|
|
58998
59735
|
category: "graphrag",
|
|
58999
59736
|
description: "\u{1F50D} Graph RAG search with BM25, vector, and knowledge graph hybrid search *GPU needed - Local LLM only (Pro+ members only)",
|
|
@@ -59016,9 +59753,9 @@ var language_command_exports = {};
|
|
|
59016
59753
|
__export(language_command_exports, {
|
|
59017
59754
|
LanguageCommand: () => LanguageCommand,
|
|
59018
59755
|
default: () => language_command_default,
|
|
59019
|
-
meta: () =>
|
|
59756
|
+
meta: () => meta20
|
|
59020
59757
|
});
|
|
59021
|
-
var LanguageCommand,
|
|
59758
|
+
var LanguageCommand, meta20, language_command_default;
|
|
59022
59759
|
var init_language_command = __esm({
|
|
59023
59760
|
"src/slash-commands/categories/multilingual/language.command.ts"() {
|
|
59024
59761
|
init_base_command();
|
|
@@ -59708,7 +60445,7 @@ var init_language_command = __esm({
|
|
|
59708
60445
|
return { success: true };
|
|
59709
60446
|
}
|
|
59710
60447
|
};
|
|
59711
|
-
|
|
60448
|
+
meta20 = {
|
|
59712
60449
|
name: "language",
|
|
59713
60450
|
category: "multilingual",
|
|
59714
60451
|
description: "\u{1F30D} Language detection, weights configuration, and multilingual processing",
|
|
@@ -59765,8 +60502,8 @@ async function checkShield(commandName, userPlan = "free") {
|
|
|
59765
60502
|
async function loadManifest() {
|
|
59766
60503
|
try {
|
|
59767
60504
|
const fs48 = await import('fs');
|
|
59768
|
-
const
|
|
59769
|
-
const manifestPath =
|
|
60505
|
+
const path59 = await import('path');
|
|
60506
|
+
const manifestPath = path59.join(
|
|
59770
60507
|
__dirname,
|
|
59771
60508
|
"../command-manifest-v2.1.json"
|
|
59772
60509
|
);
|
|
@@ -59989,14 +60726,14 @@ var sales_dashboard_command_exports = {};
|
|
|
59989
60726
|
__export(sales_dashboard_command_exports, {
|
|
59990
60727
|
SalesDashboardCommand: () => SalesDashboardCommand,
|
|
59991
60728
|
default: () => sales_dashboard_command_default,
|
|
59992
|
-
meta: () =>
|
|
60729
|
+
meta: () => meta21
|
|
59993
60730
|
});
|
|
59994
|
-
var
|
|
60731
|
+
var meta21, SalesDashboardCommand, sales_dashboard_command_default;
|
|
59995
60732
|
var init_sales_dashboard_command = __esm({
|
|
59996
60733
|
"src/slash-commands/categories/business/sales-dashboard.command.ts"() {
|
|
59997
60734
|
init_BaseCommand();
|
|
59998
60735
|
init_deps();
|
|
59999
|
-
|
|
60736
|
+
meta21 = {
|
|
60000
60737
|
name: "sales-dashboard",
|
|
60001
60738
|
category: "business",
|
|
60002
60739
|
description: "Interactive TUI sales dashboard with real-time updates",
|
|
@@ -60005,11 +60742,11 @@ var init_sales_dashboard_command = __esm({
|
|
|
60005
60742
|
status: "stable"
|
|
60006
60743
|
};
|
|
60007
60744
|
SalesDashboardCommand = class extends BaseCommand2 {
|
|
60008
|
-
meta =
|
|
60745
|
+
meta = meta21;
|
|
60009
60746
|
async execute(args2, context2) {
|
|
60010
60747
|
const options = this.parseOptions(args2);
|
|
60011
60748
|
return withDependencyGuard(
|
|
60012
|
-
|
|
60749
|
+
meta21.deps || [],
|
|
60013
60750
|
async () => this.executeWithRealData(options, context2),
|
|
60014
60751
|
() => this.executeWithMockData(options)
|
|
60015
60752
|
);
|
|
@@ -60283,9 +61020,9 @@ var gpu_command_exports = {};
|
|
|
60283
61020
|
__export(gpu_command_exports, {
|
|
60284
61021
|
GPUCommand: () => GPUCommand,
|
|
60285
61022
|
default: () => gpu_command_default,
|
|
60286
|
-
meta: () =>
|
|
61023
|
+
meta: () => meta22
|
|
60287
61024
|
});
|
|
60288
|
-
var GPUCommand,
|
|
61025
|
+
var GPUCommand, meta22, gpu_command_default;
|
|
60289
61026
|
var init_gpu_command = __esm({
|
|
60290
61027
|
"src/slash-commands/categories/ai/gpu.command.ts"() {
|
|
60291
61028
|
init_base_command();
|
|
@@ -60847,7 +61584,7 @@ var init_gpu_command = __esm({
|
|
|
60847
61584
|
return { success: true };
|
|
60848
61585
|
}
|
|
60849
61586
|
};
|
|
60850
|
-
|
|
61587
|
+
meta22 = {
|
|
60851
61588
|
name: "gpu",
|
|
60852
61589
|
category: "ai",
|
|
60853
61590
|
description: "GPU status, benchmarking, and management capabilities *GPU needed - Local LLM only (Pro+ members only)",
|
|
@@ -60878,6 +61615,7 @@ __export(slash_commands_exports, {
|
|
|
60878
61615
|
ExitCommand: () => ExitCommand,
|
|
60879
61616
|
ForgetCommand: () => ForgetCommand,
|
|
60880
61617
|
HelpCommand: () => HelpCommand,
|
|
61618
|
+
IdentityCommand: () => IdentityCommand,
|
|
60881
61619
|
ImageCommand: () => ImageCommand,
|
|
60882
61620
|
LoggingMiddleware: () => LoggingMiddleware,
|
|
60883
61621
|
LogoutCommand: () => LogoutCommand,
|
|
@@ -60958,6 +61696,14 @@ async function registerBuiltInCommands() {
|
|
|
60958
61696
|
} catch (aboutError) {
|
|
60959
61697
|
console.error("Failed to register about command:", aboutError);
|
|
60960
61698
|
}
|
|
61699
|
+
try {
|
|
61700
|
+
const { IdentityCommand: IdentityCommand2 } = await Promise.resolve().then(() => (init_identity_command(), identity_command_exports));
|
|
61701
|
+
const identityCommand = new IdentityCommand2();
|
|
61702
|
+
if (identityCommand.initialize) await identityCommand.initialize();
|
|
61703
|
+
commandRegistry.register(identityCommand);
|
|
61704
|
+
} catch (identityError) {
|
|
61705
|
+
console.error("Failed to register identity command:", identityError);
|
|
61706
|
+
}
|
|
60961
61707
|
const { StatusCommandV2: StatusCommandV22 } = await Promise.resolve().then(() => (init_StatusCommand(), StatusCommand_exports));
|
|
60962
61708
|
const { DoctorCommand: DoctorCommand2 } = await Promise.resolve().then(() => (init_DoctorCommand(), DoctorCommand_exports));
|
|
60963
61709
|
const { TerminalSetupCommand: TerminalSetupCommand2 } = await Promise.resolve().then(() => (init_TerminalSetupCommand(), TerminalSetupCommand_exports));
|
|
@@ -61410,6 +62156,7 @@ var init_slash_commands = __esm({
|
|
|
61410
62156
|
init_UsageCommand();
|
|
61411
62157
|
init_PlanCommand();
|
|
61412
62158
|
init_WhoAmICommand();
|
|
62159
|
+
init_identity_command();
|
|
61413
62160
|
init_registry();
|
|
61414
62161
|
}
|
|
61415
62162
|
});
|
|
@@ -61454,10 +62201,10 @@ var init_ImageCommand = __esm({
|
|
|
61454
62201
|
const height = m2 ? parseInt(m2[2], 10) : 1024;
|
|
61455
62202
|
const format = String(options.format || "png");
|
|
61456
62203
|
const res = await provider.generateImage({ prompt, width, height, format });
|
|
61457
|
-
const
|
|
62204
|
+
const path59 = __require("path");
|
|
61458
62205
|
const fs48 = await import('fs/promises');
|
|
61459
|
-
const outPath =
|
|
61460
|
-
await fs48.mkdir(
|
|
62206
|
+
const outPath = path59.join(process.cwd(), "outputs", "images", `image_${Date.now()}.png`);
|
|
62207
|
+
await fs48.mkdir(path59.dirname(outPath), { recursive: true });
|
|
61461
62208
|
await fs48.writeFile(outPath, res.bytes);
|
|
61462
62209
|
return { success: true, output: `OK: Saved image \u2192 ${outPath}` };
|
|
61463
62210
|
} catch (e2) {
|
|
@@ -61509,12 +62256,12 @@ var init_VideoCommand = __esm({
|
|
|
61509
62256
|
const fps = Math.max(1, parseInt(getVal("fps", "8"), 10) || 8);
|
|
61510
62257
|
const duration = Math.max(1, parseInt(getVal("duration", "2"), 10) || 2);
|
|
61511
62258
|
const frames = await provider.generateVideoFrames({ prompt, width: 640, height: 360, fps, duration, format: "mp4" });
|
|
61512
|
-
const
|
|
62259
|
+
const path59 = __require("path");
|
|
61513
62260
|
const fs48 = await import('fs/promises');
|
|
61514
|
-
const dir =
|
|
62261
|
+
const dir = path59.join(process.cwd(), "outputs", "videos", `video_${Date.now()}`);
|
|
61515
62262
|
await fs48.mkdir(dir, { recursive: true });
|
|
61516
62263
|
const framePattern = "frame_%04d.png";
|
|
61517
|
-
await Promise.all(frames.frames.map((buf, i2) => fs48.writeFile(
|
|
62264
|
+
await Promise.all(frames.frames.map((buf, i2) => fs48.writeFile(path59.join(dir, `frame_${i2.toString().padStart(4, "0")}.png`), buf)));
|
|
61518
62265
|
const wantMerge = has("merge") || has("mp4");
|
|
61519
62266
|
if (wantMerge && process.env.CI !== "true" && process.env.MARIA_TEST_MODE !== "1") {
|
|
61520
62267
|
const ok = await this.mergeWithFFmpeg(dir, framePattern, fps).catch(() => false);
|
|
@@ -61531,8 +62278,8 @@ var init_VideoCommand = __esm({
|
|
|
61531
62278
|
if (!available) return false;
|
|
61532
62279
|
return new Promise((resolve18) => {
|
|
61533
62280
|
const { spawn: spawn4 } = __require("child_process");
|
|
61534
|
-
const
|
|
61535
|
-
const out =
|
|
62281
|
+
const path59 = __require("path");
|
|
62282
|
+
const out = path59.join(dir, "video.mp4");
|
|
61536
62283
|
const ffmpeg = spawn4("ffmpeg", ["-y", "-framerate", String(fps), "-i", pattern, "-pix_fmt", "yuv420p", out], { cwd: dir, stdio: "ignore" });
|
|
61537
62284
|
let done = false;
|
|
61538
62285
|
ffmpeg.on("error", () => {
|
|
@@ -61787,9 +62534,9 @@ var init_model_selector_ui = __esm({
|
|
|
61787
62534
|
var ModelCommand_exports = {};
|
|
61788
62535
|
__export(ModelCommand_exports, {
|
|
61789
62536
|
ModelCommand: () => ModelCommand,
|
|
61790
|
-
meta: () =>
|
|
62537
|
+
meta: () => meta23
|
|
61791
62538
|
});
|
|
61792
|
-
var ModelCommand,
|
|
62539
|
+
var ModelCommand, meta23;
|
|
61793
62540
|
var init_ModelCommand = __esm({
|
|
61794
62541
|
"src/slash-commands/categories/configuration/handlers/ModelCommand.ts"() {
|
|
61795
62542
|
init_base_command();
|
|
@@ -63050,7 +63797,7 @@ ${model.description}
|
|
|
63050
63797
|
}
|
|
63051
63798
|
}
|
|
63052
63799
|
};
|
|
63053
|
-
|
|
63800
|
+
meta23 = {
|
|
63054
63801
|
name: "model",
|
|
63055
63802
|
category: "configuration",
|
|
63056
63803
|
description: "Manages AI model configuration and selection",
|
|
@@ -63071,9 +63818,9 @@ ${model.description}
|
|
|
63071
63818
|
var ConfigCommand_exports = {};
|
|
63072
63819
|
__export(ConfigCommand_exports, {
|
|
63073
63820
|
ConfigCommand: () => ConfigCommand2,
|
|
63074
|
-
meta: () =>
|
|
63821
|
+
meta: () => meta24
|
|
63075
63822
|
});
|
|
63076
|
-
var ConfigCommand2,
|
|
63823
|
+
var ConfigCommand2, meta24;
|
|
63077
63824
|
var init_ConfigCommand2 = __esm({
|
|
63078
63825
|
"src/slash-commands/categories/configuration/handlers/ConfigCommand.ts"() {
|
|
63079
63826
|
init_BaseCommand();
|
|
@@ -63262,8 +64009,8 @@ var init_ConfigCommand2 = __esm({
|
|
|
63262
64009
|
validate: (v) => typeof v === "string"
|
|
63263
64010
|
}
|
|
63264
64011
|
};
|
|
63265
|
-
globalConfigPath =
|
|
63266
|
-
localConfigPath =
|
|
64012
|
+
globalConfigPath = path58__namespace.default.join(os13__namespace.default.homedir(), ".maria", "config.json");
|
|
64013
|
+
localConfigPath = path58__namespace.default.join(process.cwd(), ".maria-config.json");
|
|
63267
64014
|
async execute(_args, context2) {
|
|
63268
64015
|
try {
|
|
63269
64016
|
const _startTime = Date.now();
|
|
@@ -63649,7 +64396,7 @@ var init_ConfigCommand2 = __esm({
|
|
|
63649
64396
|
}
|
|
63650
64397
|
async saveConfiguration(_config, _scope) {
|
|
63651
64398
|
const _configPath = _scope === "global" ? this.globalConfigPath : this.localConfigPath;
|
|
63652
|
-
await fsp__namespace.default.mkdir(
|
|
64399
|
+
await fsp__namespace.default.mkdir(path58__namespace.default.dirname(_configPath), { recursive: true });
|
|
63653
64400
|
await fsp__namespace.default.writeFile(_configPath, JSON.stringify(_config, null, 2), "utf-8");
|
|
63654
64401
|
this.setCache(`_config:${_scope}`, _config, 300);
|
|
63655
64402
|
}
|
|
@@ -63773,7 +64520,7 @@ var init_ConfigCommand2 = __esm({
|
|
|
63773
64520
|
};
|
|
63774
64521
|
}
|
|
63775
64522
|
};
|
|
63776
|
-
|
|
64523
|
+
meta24 = {
|
|
63777
64524
|
name: "_config",
|
|
63778
64525
|
_category: "configuration",
|
|
63779
64526
|
_description: "Manages MARIA configuration settings",
|
|
@@ -70749,11 +71496,11 @@ var init_ConfigService = __esm({
|
|
|
70749
71496
|
_saveDebounceTimer = null;
|
|
70750
71497
|
_isDirty = false;
|
|
70751
71498
|
constructor(configDir = process.env.MARIA_CONFIG_DIR || "~/.maria") {
|
|
70752
|
-
this._configPath =
|
|
71499
|
+
this._configPath = path58__namespace.join(
|
|
70753
71500
|
this.expandHome(configDir),
|
|
70754
71501
|
"session.config.json"
|
|
70755
71502
|
);
|
|
70756
|
-
this._userConfigPath =
|
|
71503
|
+
this._userConfigPath = path58__namespace.join(
|
|
70757
71504
|
this.expandHome(configDir),
|
|
70758
71505
|
"user.config.json"
|
|
70759
71506
|
);
|
|
@@ -70828,8 +71575,8 @@ var init_ConfigService = __esm({
|
|
|
70828
71575
|
/**
|
|
70829
71576
|
* ネストされた設定値の取得
|
|
70830
71577
|
*/
|
|
70831
|
-
getNestedValue(
|
|
70832
|
-
const keys =
|
|
71578
|
+
getNestedValue(path59) {
|
|
71579
|
+
const keys = path59.split(".");
|
|
70833
71580
|
let value = this._config;
|
|
70834
71581
|
for (const key of keys) {
|
|
70835
71582
|
if (value && typeof value === "object" && key in value) {
|
|
@@ -70859,8 +71606,8 @@ var init_ConfigService = __esm({
|
|
|
70859
71606
|
/**
|
|
70860
71607
|
* ネストされた設定値の更新
|
|
70861
71608
|
*/
|
|
70862
|
-
async setNestedValue(
|
|
70863
|
-
const keys =
|
|
71609
|
+
async setNestedValue(path59, value) {
|
|
71610
|
+
const keys = path59.split(".");
|
|
70864
71611
|
const lastKey = keys.pop();
|
|
70865
71612
|
let target = this._config;
|
|
70866
71613
|
for (const key of keys) {
|
|
@@ -70873,7 +71620,7 @@ var init_ConfigService = __esm({
|
|
|
70873
71620
|
target[lastKey] = value;
|
|
70874
71621
|
this.validateConfig();
|
|
70875
71622
|
this.emitChange({
|
|
70876
|
-
path:
|
|
71623
|
+
path: path59,
|
|
70877
71624
|
oldValue,
|
|
70878
71625
|
newValue: value,
|
|
70879
71626
|
timestamp: /* @__PURE__ */ new Date()
|
|
@@ -70887,7 +71634,7 @@ var init_ConfigService = __esm({
|
|
|
70887
71634
|
async save() {
|
|
70888
71635
|
if (!this._isDirty) return;
|
|
70889
71636
|
try {
|
|
70890
|
-
const configDir =
|
|
71637
|
+
const configDir = path58__namespace.dirname(this._userConfigPath);
|
|
70891
71638
|
await fsp__namespace.mkdir(configDir, { recursive: true });
|
|
70892
71639
|
await fsp__namespace.writeFile(
|
|
70893
71640
|
this._userConfigPath,
|
|
@@ -70930,13 +71677,13 @@ var init_ConfigService = __esm({
|
|
|
70930
71677
|
/**
|
|
70931
71678
|
* 変更リスナーの登録
|
|
70932
71679
|
*/
|
|
70933
|
-
onChange(
|
|
70934
|
-
if (!this._listeners.has(
|
|
70935
|
-
this._listeners.set(
|
|
71680
|
+
onChange(path59, listener) {
|
|
71681
|
+
if (!this._listeners.has(path59)) {
|
|
71682
|
+
this._listeners.set(path59, []);
|
|
70936
71683
|
}
|
|
70937
|
-
this._listeners.get(
|
|
71684
|
+
this._listeners.get(path59).push(listener);
|
|
70938
71685
|
return () => {
|
|
70939
|
-
const listeners = this._listeners.get(
|
|
71686
|
+
const listeners = this._listeners.get(path59);
|
|
70940
71687
|
if (listeners) {
|
|
70941
71688
|
const index = listeners.indexOf(listener);
|
|
70942
71689
|
if (index !== -1) {
|
|
@@ -70987,7 +71734,7 @@ var init_ConfigService = __esm({
|
|
|
70987
71734
|
*/
|
|
70988
71735
|
expandHome(filePath) {
|
|
70989
71736
|
if (filePath.startsWith("~/")) {
|
|
70990
|
-
return
|
|
71737
|
+
return path58__namespace.join(process.env.HOME || "", filePath.slice(2));
|
|
70991
71738
|
}
|
|
70992
71739
|
return filePath;
|
|
70993
71740
|
}
|
|
@@ -71425,7 +72172,7 @@ var init_ValidationService = __esm({
|
|
|
71425
72172
|
);
|
|
71426
72173
|
this._schemas.set(
|
|
71427
72174
|
"filePath",
|
|
71428
|
-
zod.z.string().min(1).max(this._config.maxFilePathLength).refine((
|
|
72175
|
+
zod.z.string().min(1).max(this._config.maxFilePathLength).refine((path59) => !this.containsPathTraversal(path59), {
|
|
71429
72176
|
message: "Path traversal detected"
|
|
71430
72177
|
})
|
|
71431
72178
|
);
|
|
@@ -71564,11 +72311,11 @@ var init_ValidationService = __esm({
|
|
|
71564
72311
|
/**
|
|
71565
72312
|
* ファイルパス検証
|
|
71566
72313
|
*/
|
|
71567
|
-
validateFilePath(
|
|
72314
|
+
validateFilePath(path59) {
|
|
71568
72315
|
try {
|
|
71569
72316
|
const schema2 = this._schemas.get("filePath");
|
|
71570
|
-
const result = schema2.parse(
|
|
71571
|
-
if (this.isSystemPath(
|
|
72317
|
+
const result = schema2.parse(path59);
|
|
72318
|
+
if (this.isSystemPath(path59)) {
|
|
71572
72319
|
return {
|
|
71573
72320
|
valid: false,
|
|
71574
72321
|
errors: [
|
|
@@ -71714,8 +72461,8 @@ var init_ValidationService = __esm({
|
|
|
71714
72461
|
/**
|
|
71715
72462
|
* パストラバーサルの検出
|
|
71716
72463
|
*/
|
|
71717
|
-
containsPathTraversal(
|
|
71718
|
-
return /\.\.[/\\]/.test(
|
|
72464
|
+
containsPathTraversal(path59) {
|
|
72465
|
+
return /\.\.[/\\]/.test(path59) || path59.includes("..\\") || path59.includes("../");
|
|
71719
72466
|
}
|
|
71720
72467
|
/**
|
|
71721
72468
|
* 危険なコマンドの判定
|
|
@@ -71742,7 +72489,7 @@ var init_ValidationService = __esm({
|
|
|
71742
72489
|
/**
|
|
71743
72490
|
* システムパスの判定
|
|
71744
72491
|
*/
|
|
71745
|
-
isSystemPath(
|
|
72492
|
+
isSystemPath(path59) {
|
|
71746
72493
|
const systemPaths = [
|
|
71747
72494
|
"/etc",
|
|
71748
72495
|
"/sys",
|
|
@@ -71756,7 +72503,7 @@ var init_ValidationService = __esm({
|
|
|
71756
72503
|
"/sbin"
|
|
71757
72504
|
];
|
|
71758
72505
|
return systemPaths.some(
|
|
71759
|
-
(sysPath) =>
|
|
72506
|
+
(sysPath) => path59.toLowerCase().startsWith(sysPath.toLowerCase())
|
|
71760
72507
|
);
|
|
71761
72508
|
}
|
|
71762
72509
|
/**
|
|
@@ -76290,8 +77037,8 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
|
|
|
76290
77037
|
if (outputPath) {
|
|
76291
77038
|
try {
|
|
76292
77039
|
const fs48 = await import('fs/promises');
|
|
76293
|
-
const
|
|
76294
|
-
const abs =
|
|
77040
|
+
const path59 = await import('path');
|
|
77041
|
+
const abs = path59.resolve(outputPath);
|
|
76295
77042
|
await fs48.writeFile(abs, text, "utf-8");
|
|
76296
77043
|
const msg = `Saved doctor report to ${abs}`;
|
|
76297
77044
|
return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
|
|
@@ -76383,8 +77130,8 @@ Run /doctor --fix to automatically fix ${fixableCount} issue(s)`
|
|
|
76383
77130
|
if (outputPath) {
|
|
76384
77131
|
try {
|
|
76385
77132
|
const fs48 = await import('fs/promises');
|
|
76386
|
-
const
|
|
76387
|
-
const abs =
|
|
77133
|
+
const path59 = await import('path');
|
|
77134
|
+
const abs = path59.resolve(outputPath);
|
|
76388
77135
|
await fs48.writeFile(abs, text, "utf-8");
|
|
76389
77136
|
const msg = `Saved metrics to ${abs}`;
|
|
76390
77137
|
return { ok: true, message: msg, data: { path: abs, bytes: Buffer.byteLength(text, "utf-8") } };
|
|
@@ -76774,15 +77521,15 @@ var init_SessionOrchestrator = __esm({
|
|
|
76774
77521
|
/**
|
|
76775
77522
|
* 設定の取得
|
|
76776
77523
|
*/
|
|
76777
|
-
getConfig(
|
|
76778
|
-
return this._configService?.getNestedValue(
|
|
77524
|
+
getConfig(path59) {
|
|
77525
|
+
return this._configService?.getNestedValue(path59);
|
|
76779
77526
|
}
|
|
76780
77527
|
/**
|
|
76781
77528
|
* 設定の更新
|
|
76782
77529
|
*/
|
|
76783
|
-
async setConfig(
|
|
77530
|
+
async setConfig(path59, value) {
|
|
76784
77531
|
if (this._configService) {
|
|
76785
|
-
await this._configService.setNestedValue(
|
|
77532
|
+
await this._configService.setNestedValue(path59, value);
|
|
76786
77533
|
}
|
|
76787
77534
|
}
|
|
76788
77535
|
/**
|
|
@@ -76900,11 +77647,11 @@ var init_interactive_session = __esm({
|
|
|
76900
77647
|
getStats() {
|
|
76901
77648
|
return this.orchestrator.getSessionStats();
|
|
76902
77649
|
}
|
|
76903
|
-
getConfig(
|
|
76904
|
-
return this.orchestrator.getConfig(
|
|
77650
|
+
getConfig(path59) {
|
|
77651
|
+
return this.orchestrator.getConfig(path59);
|
|
76905
77652
|
}
|
|
76906
|
-
async setConfig(
|
|
76907
|
-
await this.orchestrator.setConfig(
|
|
77653
|
+
async setConfig(path59, value) {
|
|
77654
|
+
await this.orchestrator.setConfig(path59, value);
|
|
76908
77655
|
}
|
|
76909
77656
|
};
|
|
76910
77657
|
}
|
|
@@ -78130,23 +78877,23 @@ function coerceExtension(ext2, fallback2) {
|
|
|
78130
78877
|
return fallback2;
|
|
78131
78878
|
}
|
|
78132
78879
|
function safeResolve(root, fname) {
|
|
78133
|
-
const abs =
|
|
78134
|
-
const base =
|
|
78135
|
-
if (!(abs +
|
|
78880
|
+
const abs = path58__namespace.resolve(root, fname);
|
|
78881
|
+
const base = path58__namespace.resolve(root);
|
|
78882
|
+
if (!(abs + path58__namespace.sep).startsWith(base + path58__namespace.sep) && abs !== base) {
|
|
78136
78883
|
throw new Error("Path traversal detected");
|
|
78137
78884
|
}
|
|
78138
78885
|
return abs;
|
|
78139
78886
|
}
|
|
78140
78887
|
async function ensureUniquePath(absPath) {
|
|
78141
|
-
const dir =
|
|
78142
|
-
const ext2 =
|
|
78143
|
-
const base =
|
|
78888
|
+
const dir = path58__namespace.dirname(absPath);
|
|
78889
|
+
const ext2 = path58__namespace.extname(absPath);
|
|
78890
|
+
const base = path58__namespace.basename(absPath, ext2);
|
|
78144
78891
|
let candidate = absPath;
|
|
78145
78892
|
let i2 = 1;
|
|
78146
78893
|
while (true) {
|
|
78147
78894
|
try {
|
|
78148
78895
|
await fsp__namespace.access(candidate);
|
|
78149
|
-
candidate =
|
|
78896
|
+
candidate = path58__namespace.join(dir, `${base}(${i2})${ext2}`);
|
|
78150
78897
|
i2++;
|
|
78151
78898
|
} catch {
|
|
78152
78899
|
return candidate;
|
|
@@ -78225,7 +78972,7 @@ async function handleCodeCommand(prompt) {
|
|
|
78225
78972
|
for (const { language, code, extension, filename: suggested } of artifacts) {
|
|
78226
78973
|
let filename = generateCodeFilename(prompt, language, extension, code, suggested);
|
|
78227
78974
|
filename = sanitizeFilenameStrict(filename);
|
|
78228
|
-
const ext2 =
|
|
78975
|
+
const ext2 = path58__namespace.extname(filename).slice(1);
|
|
78229
78976
|
const isBinary3 = isLikelyBinary(code);
|
|
78230
78977
|
const inferred = isBinary3 ? "bin" : inferExtensionFromContent(language, code) || "txt";
|
|
78231
78978
|
const finalExt = coerceExtension(ext2, inferred);
|
|
@@ -78238,13 +78985,13 @@ async function handleCodeCommand(prompt) {
|
|
|
78238
78985
|
files += 1;
|
|
78239
78986
|
if (progress) clearInterval(progress);
|
|
78240
78987
|
if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
|
|
78241
|
-
console.log(`Saved 1 file: ${
|
|
78988
|
+
console.log(`Saved 1 file: ${path58__namespace.basename(filepath)} (${language}${isBinary3 ? ", binary-like" : ""})`);
|
|
78242
78989
|
textLog.path(filepath);
|
|
78243
78990
|
const pm = getProviderManager();
|
|
78244
78991
|
const provider = pm.getLastUsedProvider() || "fallback";
|
|
78245
78992
|
const model = pm.getLastUsedModel() || "n/a";
|
|
78246
78993
|
const source = pm.getConfigSource();
|
|
78247
|
-
const summary = { filename:
|
|
78994
|
+
const summary = { filename: path58__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 };
|
|
78248
78995
|
try {
|
|
78249
78996
|
TelemetryCollector.getInstance().trackCodeSaved(summary);
|
|
78250
78997
|
} catch {
|
|
@@ -78282,7 +79029,7 @@ async function handleCodeCommand(prompt) {
|
|
|
78282
79029
|
for (const { language, code, extension, filename: suggested } of artifacts) {
|
|
78283
79030
|
let filename = generateCodeFilename(prompt, language, extension, code, suggested);
|
|
78284
79031
|
filename = sanitizeFilenameStrict(filename);
|
|
78285
|
-
const ext2 =
|
|
79032
|
+
const ext2 = path58__namespace.extname(filename).slice(1);
|
|
78286
79033
|
const isBinary3 = isLikelyBinary(code);
|
|
78287
79034
|
const inferred = isBinary3 ? "bin" : inferExtensionFromContent(language, code) || "txt";
|
|
78288
79035
|
const finalExt = coerceExtension(ext2, inferred);
|
|
@@ -78295,13 +79042,13 @@ async function handleCodeCommand(prompt) {
|
|
|
78295
79042
|
files += 1;
|
|
78296
79043
|
if (progress) clearInterval(progress);
|
|
78297
79044
|
if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
|
|
78298
|
-
console.log(`Saved 1 file: ${
|
|
79045
|
+
console.log(`Saved 1 file: ${path58__namespace.basename(filepath)} (${language}${isBinary3 ? ", binary-like" : ""})`);
|
|
78299
79046
|
textLog.path(filepath);
|
|
78300
79047
|
const pm = getProviderManager();
|
|
78301
79048
|
const provider = pm.getLastUsedProvider() || "unknown";
|
|
78302
79049
|
const model = pm.getLastUsedModel() || "auto";
|
|
78303
79050
|
const source = pm.getConfigSource();
|
|
78304
|
-
const summary = { filename:
|
|
79051
|
+
const summary = { filename: path58__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 };
|
|
78305
79052
|
try {
|
|
78306
79053
|
TelemetryCollector.getInstance().trackCodeSaved(summary);
|
|
78307
79054
|
} catch {
|
|
@@ -78333,7 +79080,7 @@ async function handleCodeCommand(prompt) {
|
|
|
78333
79080
|
for (const { language, code, extension, filename: suggested } of artifacts) {
|
|
78334
79081
|
let filename = generateCodeFilename(prompt, language, extension, code, suggested);
|
|
78335
79082
|
filename = sanitizeFilenameStrict(filename);
|
|
78336
|
-
const ext2 =
|
|
79083
|
+
const ext2 = path58__namespace.extname(filename).slice(1);
|
|
78337
79084
|
const isBinary3 = isLikelyBinary(code);
|
|
78338
79085
|
const inferred = isBinary3 ? "bin" : inferExtensionFromContent(language, code) || "txt";
|
|
78339
79086
|
const finalExt = coerceExtension(ext2, inferred);
|
|
@@ -78346,13 +79093,13 @@ async function handleCodeCommand(prompt) {
|
|
|
78346
79093
|
files += 1;
|
|
78347
79094
|
if (progress) clearInterval(progress);
|
|
78348
79095
|
if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
|
|
78349
|
-
console.log(`Saved 1 file: ${
|
|
79096
|
+
console.log(`Saved 1 file: ${path58__namespace.basename(filepath)} (${language}${isBinary3 ? ", binary-like" : ""})`);
|
|
78350
79097
|
textLog.path(filepath);
|
|
78351
79098
|
const pm = getProviderManager();
|
|
78352
79099
|
const provider = pm.getLastUsedProvider() || "fallback";
|
|
78353
79100
|
const model = pm.getLastUsedModel() || "n/a";
|
|
78354
79101
|
const source = pm.getConfigSource();
|
|
78355
|
-
const summary = { filename:
|
|
79102
|
+
const summary = { filename: path58__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 };
|
|
78356
79103
|
try {
|
|
78357
79104
|
TelemetryCollector.getInstance().trackCodeSaved(summary);
|
|
78358
79105
|
} catch {
|
|
@@ -78417,7 +79164,7 @@ ${e2.stack}`));
|
|
|
78417
79164
|
for (const { language, code, extension, filename: suggested } of artifacts) {
|
|
78418
79165
|
let filename = generateCodeFilename(prompt, language, extension, code, suggested);
|
|
78419
79166
|
filename = sanitizeFilenameStrict(filename);
|
|
78420
|
-
const ext2 =
|
|
79167
|
+
const ext2 = path58__namespace.extname(filename).slice(1);
|
|
78421
79168
|
const isBinary3 = isLikelyBinary(code);
|
|
78422
79169
|
const inferred = isBinary3 ? "bin" : inferExtensionFromContent(language, code) || "txt";
|
|
78423
79170
|
const finalExt = coerceExtension(ext2, inferred);
|
|
@@ -78430,13 +79177,13 @@ ${e2.stack}`));
|
|
|
78430
79177
|
files += 1;
|
|
78431
79178
|
if (progress) clearInterval(progress);
|
|
78432
79179
|
if (isTTY) rl__namespace.cursorTo(process.stdout, 0);
|
|
78433
|
-
console.log(`Saved 1 file: ${
|
|
79180
|
+
console.log(`Saved 1 file: ${path58__namespace.basename(filepath)} (${language}${isBinary3 ? ", binary-like" : ""})`);
|
|
78434
79181
|
textLog.path(filepath);
|
|
78435
79182
|
const pm = getProviderManager();
|
|
78436
79183
|
const provider = pm.getLastUsedProvider() || "fallback";
|
|
78437
79184
|
const model = pm.getLastUsedModel() || "n/a";
|
|
78438
79185
|
const source = pm.getConfigSource();
|
|
78439
|
-
const summary = { filename:
|
|
79186
|
+
const summary = { filename: path58__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 };
|
|
78440
79187
|
try {
|
|
78441
79188
|
TelemetryCollector.getInstance().trackCodeSaved(summary);
|
|
78442
79189
|
} catch {
|
|
@@ -78894,7 +79641,7 @@ async function streamAnswer(text, opts = {}) {
|
|
|
78894
79641
|
for (const { language, code, extension, filename: suggested } of artifacts) {
|
|
78895
79642
|
let filename = generateCodeFilename(text, language, extension, code, suggested);
|
|
78896
79643
|
filename = sanitizeFilenameStrict(filename);
|
|
78897
|
-
const ext2 =
|
|
79644
|
+
const ext2 = path58__namespace.extname(filename).slice(1);
|
|
78898
79645
|
const isBinary3 = isLikelyBinary(code);
|
|
78899
79646
|
const inferred = isBinary3 ? "bin" : inferExtensionFromContent(language, code) || "txt";
|
|
78900
79647
|
const finalExt = coerceExtension(ext2, inferred);
|
|
@@ -78903,13 +79650,13 @@ async function streamAnswer(text, opts = {}) {
|
|
|
78903
79650
|
filepath = await ensureUniquePath(filepath);
|
|
78904
79651
|
try {
|
|
78905
79652
|
await fsp__namespace.writeFile(filepath, code, "utf-8");
|
|
78906
|
-
savedFiles.push({ filepath, filename:
|
|
79653
|
+
savedFiles.push({ filepath, filename: path58__namespace.basename(filepath), language, code, ok: true, isBinary: isBinary3 });
|
|
78907
79654
|
okCount++;
|
|
78908
79655
|
console.log(chalk38__default.default.white(`OK: saved ${filepath} (${language}${isBinary3 ? ", binary-like" : ""})`));
|
|
78909
79656
|
} catch (e2) {
|
|
78910
79657
|
errCount++;
|
|
78911
79658
|
const msg2 = e2?.message || "failed to write";
|
|
78912
|
-
savedFiles.push({ filepath, filename:
|
|
79659
|
+
savedFiles.push({ filepath, filename: path58__namespace.basename(filepath), language, code, ok: false, error: msg2, isBinary: isBinary3 });
|
|
78913
79660
|
console.log(chalk38__default.default.white(`ERROR: failed ${filepath} (${language}) - ${msg2}`));
|
|
78914
79661
|
}
|
|
78915
79662
|
}
|
|
@@ -79243,24 +79990,24 @@ function createCLI2() {
|
|
|
79243
79990
|
if (options.server) {
|
|
79244
79991
|
console.log(chalk38__default.default.white("Starting MARIA server mode..."));
|
|
79245
79992
|
try {
|
|
79246
|
-
const distDir =
|
|
79993
|
+
const distDir = path58__namespace.dirname(process.argv[1] || process.cwd());
|
|
79247
79994
|
const candidateNames = [
|
|
79248
79995
|
"server-express.mjs",
|
|
79249
79996
|
"server-express.cjs",
|
|
79250
79997
|
"server-express.js",
|
|
79251
79998
|
// tsup emits CJS for server entry as dist/server/express-server.js
|
|
79252
|
-
|
|
79253
|
-
|
|
79999
|
+
path58__namespace.join("server", "express-server.js"),
|
|
80000
|
+
path58__namespace.join("server", "express-server.cjs")
|
|
79254
80001
|
];
|
|
79255
80002
|
const candidateDirs = [
|
|
79256
80003
|
distDir,
|
|
79257
|
-
|
|
80004
|
+
path58__namespace.resolve(distDir, ".."),
|
|
79258
80005
|
process.cwd()
|
|
79259
80006
|
];
|
|
79260
80007
|
let serverPath = null;
|
|
79261
80008
|
for (const dir of candidateDirs) {
|
|
79262
80009
|
for (const name2 of candidateNames) {
|
|
79263
|
-
const p =
|
|
80010
|
+
const p = path58__namespace.join(dir, name2);
|
|
79264
80011
|
try {
|
|
79265
80012
|
await fsp__namespace.access(p);
|
|
79266
80013
|
serverPath = p;
|
|
@@ -79280,7 +80027,7 @@ function createCLI2() {
|
|
|
79280
80027
|
const serverProcess = spawn4("node", [serverPath], {
|
|
79281
80028
|
stdio: "inherit",
|
|
79282
80029
|
env: process.env,
|
|
79283
|
-
cwd:
|
|
80030
|
+
cwd: path58__namespace.dirname(serverPath)
|
|
79284
80031
|
});
|
|
79285
80032
|
let shutdownTimer = null;
|
|
79286
80033
|
const forceExit = (defaultCode) => {
|