micro-models-agent 0.28.1 → 0.28.2
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/main.js +517 -447
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2210,7 +2210,7 @@ var init_defaults = __esm(() => {
|
|
|
2210
2210
|
maxDelay: 30000
|
|
2211
2211
|
},
|
|
2212
2212
|
maxToolIterations: 1000,
|
|
2213
|
-
stuckThreshold:
|
|
2213
|
+
stuckThreshold: 6,
|
|
2214
2214
|
autoPlan: true,
|
|
2215
2215
|
showReasoning: false,
|
|
2216
2216
|
logLevel: "info",
|
|
@@ -3921,14 +3921,88 @@ var init_data_sanitizer = __esm(() => {
|
|
|
3921
3921
|
];
|
|
3922
3922
|
});
|
|
3923
3923
|
|
|
3924
|
+
// node_modules/picocolors/picocolors.js
|
|
3925
|
+
var require_picocolors = __commonJS((exports, module) => {
|
|
3926
|
+
var p = process || {};
|
|
3927
|
+
var argv = p.argv || [];
|
|
3928
|
+
var env = p.env || {};
|
|
3929
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
3930
|
+
var formatter = (open, close, replace = open) => (input) => {
|
|
3931
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
3932
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
3933
|
+
};
|
|
3934
|
+
var replaceClose = (string, close, replace, index) => {
|
|
3935
|
+
let result = "", cursor = 0;
|
|
3936
|
+
do {
|
|
3937
|
+
result += string.substring(cursor, index) + replace;
|
|
3938
|
+
cursor = index + close.length;
|
|
3939
|
+
index = string.indexOf(close, cursor);
|
|
3940
|
+
} while (~index);
|
|
3941
|
+
return result + string.substring(cursor);
|
|
3942
|
+
};
|
|
3943
|
+
var createColors = (enabled = isColorSupported) => {
|
|
3944
|
+
let f = enabled ? formatter : () => String;
|
|
3945
|
+
return {
|
|
3946
|
+
isColorSupported: enabled,
|
|
3947
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
3948
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
3949
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
3950
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
3951
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
3952
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
3953
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
3954
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
3955
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
3956
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
3957
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
3958
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
3959
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
3960
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
3961
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
3962
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
3963
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
3964
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
3965
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
3966
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
3967
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
3968
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
3969
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
3970
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
3971
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
3972
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
3973
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
3974
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
3975
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
3976
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
3977
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
3978
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
3979
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
3980
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
3981
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
3982
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
3983
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
3984
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
3985
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
3986
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
3987
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
3988
|
+
};
|
|
3989
|
+
};
|
|
3990
|
+
module.exports = createColors();
|
|
3991
|
+
module.exports.createColors = createColors;
|
|
3992
|
+
});
|
|
3993
|
+
|
|
3924
3994
|
// src/logger/app-logger.ts
|
|
3925
3995
|
import { appendFileSync, mkdirSync as mkdirSync3, existsSync as existsSync5 } from "fs";
|
|
3926
3996
|
import { join as join5 } from "path";
|
|
3997
|
+
function isColorEnabled() {
|
|
3998
|
+
return !process.env.NO_COLOR && !process.env.CI && process.stdout.isTTY === true;
|
|
3999
|
+
}
|
|
3927
4000
|
|
|
3928
4001
|
class Logger {
|
|
3929
4002
|
level;
|
|
3930
4003
|
prefix;
|
|
3931
4004
|
logDir = null;
|
|
4005
|
+
sessionDir = null;
|
|
3932
4006
|
constructor(level = "info", prefix = "") {
|
|
3933
4007
|
this.level = level;
|
|
3934
4008
|
this.prefix = prefix;
|
|
@@ -3942,10 +4016,21 @@ class Logger {
|
|
|
3942
4016
|
mkdirSync3(dir, { recursive: true });
|
|
3943
4017
|
}
|
|
3944
4018
|
}
|
|
4019
|
+
setSessionDir(dir) {
|
|
4020
|
+
this.sessionDir = dir;
|
|
4021
|
+
if (!existsSync5(dir)) {
|
|
4022
|
+
mkdirSync3(dir, { recursive: true });
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
clearSessionDir() {
|
|
4026
|
+
this.sessionDir = null;
|
|
4027
|
+
}
|
|
3945
4028
|
child(prefix) {
|
|
3946
4029
|
const childLogger = new Logger(this.level, this.prefix ? `${this.prefix}:${prefix}` : prefix);
|
|
3947
4030
|
if (this.logDir)
|
|
3948
4031
|
childLogger.setLogDir(this.logDir);
|
|
4032
|
+
if (this.sessionDir)
|
|
4033
|
+
childLogger.setSessionDir(this.sessionDir);
|
|
3949
4034
|
return childLogger;
|
|
3950
4035
|
}
|
|
3951
4036
|
debug(msg, meta) {
|
|
@@ -3969,10 +4054,17 @@ class Logger {
|
|
|
3969
4054
|
const prefix = this.prefix ? ` [${this.prefix}]` : "";
|
|
3970
4055
|
const metaStr = sanitizedMeta ? ` ${JSON.stringify(sanitizedMeta)}` : "";
|
|
3971
4056
|
const line = `[${level.toUpperCase()}]${prefix} ${ts} — ${sanitizedMsg}${metaStr}`;
|
|
3972
|
-
console.log(line);
|
|
3973
|
-
|
|
4057
|
+
console.log(isColorEnabled() ? LEVEL_COLORS[level](line) : line);
|
|
4058
|
+
const logTarget = this.sessionDir ?? this.logDir;
|
|
4059
|
+
if (logTarget) {
|
|
3974
4060
|
try {
|
|
3975
|
-
appendFileSync(join5(
|
|
4061
|
+
appendFileSync(join5(logTarget, "app.jsonl"), JSON.stringify({
|
|
4062
|
+
level,
|
|
4063
|
+
ts,
|
|
4064
|
+
prefix: this.prefix,
|
|
4065
|
+
msg: sanitizedMsg,
|
|
4066
|
+
meta: sanitizedMeta ?? null
|
|
4067
|
+
}) + `
|
|
3976
4068
|
`, "utf-8");
|
|
3977
4069
|
} catch {}
|
|
3978
4070
|
}
|
|
@@ -3991,10 +4083,17 @@ class Logger {
|
|
|
3991
4083
|
return sanitized;
|
|
3992
4084
|
}
|
|
3993
4085
|
}
|
|
3994
|
-
var LEVELS;
|
|
4086
|
+
var import_picocolors, LEVELS, LEVEL_COLORS;
|
|
3995
4087
|
var init_app_logger = __esm(() => {
|
|
3996
4088
|
init_data_sanitizer();
|
|
4089
|
+
import_picocolors = __toESM(require_picocolors(), 1);
|
|
3997
4090
|
LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
4091
|
+
LEVEL_COLORS = {
|
|
4092
|
+
debug: (s) => import_picocolors.default.dim(s),
|
|
4093
|
+
info: (s) => s,
|
|
4094
|
+
warn: (s) => import_picocolors.default.yellow(s),
|
|
4095
|
+
error: (s) => import_picocolors.default.red(s)
|
|
4096
|
+
};
|
|
3998
4097
|
});
|
|
3999
4098
|
|
|
4000
4099
|
// node_modules/base64-js/index.js
|
|
@@ -5533,18 +5632,25 @@ var init_audit_notifier = __esm(() => {
|
|
|
5533
5632
|
|
|
5534
5633
|
// src/modules/security/audit-log.ts
|
|
5535
5634
|
import { existsSync as existsSync7, mkdirSync as mkdirSync5, appendFileSync as appendFileSync3 } from "fs";
|
|
5536
|
-
import { resolve as resolve2 } from "path";
|
|
5635
|
+
import { resolve as resolve2, join as join7 } from "path";
|
|
5537
5636
|
import { homedir as homedir3 } from "os";
|
|
5538
|
-
function
|
|
5539
|
-
|
|
5540
|
-
|
|
5637
|
+
function getAuditDir() {
|
|
5638
|
+
return _sessionAuditDir ?? _globalAuditDir;
|
|
5639
|
+
}
|
|
5640
|
+
function setAuditSessionDir(dir) {
|
|
5641
|
+
_sessionAuditDir = dir;
|
|
5642
|
+
if (!existsSync7(dir)) {
|
|
5643
|
+
mkdirSync5(dir, { recursive: true, mode: 448 });
|
|
5541
5644
|
}
|
|
5542
5645
|
}
|
|
5543
5646
|
function logAudit(entry) {
|
|
5544
|
-
|
|
5647
|
+
const dir = getAuditDir();
|
|
5648
|
+
if (!existsSync7(dir)) {
|
|
5649
|
+
mkdirSync5(dir, { recursive: true, mode: 448 });
|
|
5650
|
+
}
|
|
5545
5651
|
try {
|
|
5546
5652
|
const logEntry = JSON.stringify(entry);
|
|
5547
|
-
appendFileSync3(
|
|
5653
|
+
appendFileSync3(join7(dir, "audit.jsonl"), logEntry + `
|
|
5548
5654
|
`, "utf8");
|
|
5549
5655
|
} catch {}
|
|
5550
5656
|
try {
|
|
@@ -5601,11 +5707,10 @@ function logSecurityBlock(sessionId, action, reason, details) {
|
|
|
5601
5707
|
details
|
|
5602
5708
|
});
|
|
5603
5709
|
}
|
|
5604
|
-
var
|
|
5710
|
+
var _globalAuditDir, _sessionAuditDir = null;
|
|
5605
5711
|
var init_audit_log = __esm(() => {
|
|
5606
5712
|
init_audit_notifier();
|
|
5607
|
-
|
|
5608
|
-
AUDIT_LOG_PATH = resolve2(AUDIT_LOG_DIR, "audit.jsonl");
|
|
5713
|
+
_globalAuditDir = resolve2(homedir3(), ".mma", "logs");
|
|
5609
5714
|
});
|
|
5610
5715
|
|
|
5611
5716
|
// src/tools/path-utils.ts
|
|
@@ -5781,13 +5886,13 @@ var init_content_scanner = __esm(() => {
|
|
|
5781
5886
|
});
|
|
5782
5887
|
|
|
5783
5888
|
// src/modules/security/session-isolation.ts
|
|
5784
|
-
import { join as
|
|
5889
|
+
import { join as join8, resolve as resolve5 } from "path";
|
|
5785
5890
|
import { homedir as homedir4 } from "os";
|
|
5786
5891
|
import { mkdirSync as mkdirSync6, existsSync as existsSync10 } from "fs";
|
|
5787
5892
|
function createSessionContext(sessionId, projectDir, isolationConfig, securityOverrides) {
|
|
5788
5893
|
const config = { ...DEFAULT_SESSION_ISOLATION, ...isolationConfig };
|
|
5789
|
-
const baseDir = config.baseDir ||
|
|
5790
|
-
const tempDir =
|
|
5894
|
+
const baseDir = config.baseDir || join8(homedir4(), ".mma", "sessions", sessionId);
|
|
5895
|
+
const tempDir = join8(baseDir, "temp");
|
|
5791
5896
|
if (config.isolateTempFiles && !existsSync10(tempDir)) {
|
|
5792
5897
|
try {
|
|
5793
5898
|
mkdirSync6(tempDir, { recursive: true, mode: 448 });
|
|
@@ -5826,82 +5931,12 @@ var init_session_isolation = __esm(() => {
|
|
|
5826
5931
|
};
|
|
5827
5932
|
});
|
|
5828
5933
|
|
|
5829
|
-
// node_modules/picocolors/picocolors.js
|
|
5830
|
-
var require_picocolors = __commonJS((exports, module) => {
|
|
5831
|
-
var p = process || {};
|
|
5832
|
-
var argv = p.argv || [];
|
|
5833
|
-
var env = p.env || {};
|
|
5834
|
-
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
5835
|
-
var formatter = (open, close, replace = open) => (input) => {
|
|
5836
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
5837
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
5838
|
-
};
|
|
5839
|
-
var replaceClose = (string, close, replace, index) => {
|
|
5840
|
-
let result = "", cursor = 0;
|
|
5841
|
-
do {
|
|
5842
|
-
result += string.substring(cursor, index) + replace;
|
|
5843
|
-
cursor = index + close.length;
|
|
5844
|
-
index = string.indexOf(close, cursor);
|
|
5845
|
-
} while (~index);
|
|
5846
|
-
return result + string.substring(cursor);
|
|
5847
|
-
};
|
|
5848
|
-
var createColors = (enabled = isColorSupported) => {
|
|
5849
|
-
let f = enabled ? formatter : () => String;
|
|
5850
|
-
return {
|
|
5851
|
-
isColorSupported: enabled,
|
|
5852
|
-
reset: f("\x1B[0m", "\x1B[0m"),
|
|
5853
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
5854
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
5855
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
5856
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
5857
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
5858
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
5859
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
5860
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
5861
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
5862
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
5863
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
5864
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
5865
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
5866
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
5867
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
5868
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
5869
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
5870
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
5871
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
5872
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
5873
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
5874
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
5875
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
5876
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
5877
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
5878
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
5879
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
5880
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
5881
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
5882
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
5883
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
5884
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
5885
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
5886
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
5887
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
5888
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
5889
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
5890
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
5891
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
5892
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
5893
|
-
};
|
|
5894
|
-
};
|
|
5895
|
-
module.exports = createColors();
|
|
5896
|
-
module.exports.createColors = createColors;
|
|
5897
|
-
});
|
|
5898
|
-
|
|
5899
5934
|
// src/ui/colors.ts
|
|
5900
|
-
var
|
|
5935
|
+
var import_picocolors2, isTty = () => process.stdout.isTTY === true, enabled, pc2;
|
|
5901
5936
|
var init_colors = __esm(() => {
|
|
5902
|
-
|
|
5937
|
+
import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
5903
5938
|
enabled = isTty() && !process.env.CI && !process.env.NO_COLOR;
|
|
5904
|
-
|
|
5939
|
+
pc2 = import_picocolors2.createColors(enabled);
|
|
5905
5940
|
});
|
|
5906
5941
|
|
|
5907
5942
|
// src/ui/diff.ts
|
|
@@ -6011,11 +6046,11 @@ function formatLine(line, maxNumWidth) {
|
|
|
6011
6046
|
const num = line.type === "remove" ? line.oldNum : line.newNum;
|
|
6012
6047
|
const numStr = num !== null ? String(num).padStart(maxNumWidth) : " ".repeat(maxNumWidth);
|
|
6013
6048
|
if (line.type === "remove") {
|
|
6014
|
-
return `${numStr} ${
|
|
6049
|
+
return `${numStr} ${pc2.red("-")} ${line.content}`;
|
|
6015
6050
|
} else if (line.type === "add") {
|
|
6016
|
-
return `${numStr} ${
|
|
6051
|
+
return `${numStr} ${pc2.green("+")} ${line.content}`;
|
|
6017
6052
|
} else if (line.content === "...") {
|
|
6018
|
-
return
|
|
6053
|
+
return pc2.dim(` ${" ".repeat(maxNumWidth)}...`);
|
|
6019
6054
|
} else {
|
|
6020
6055
|
return ` ${numStr} ${line.content}`;
|
|
6021
6056
|
}
|
|
@@ -6038,7 +6073,7 @@ function generateDiff(oldContent, newContent) {
|
|
|
6038
6073
|
let lines = diff.map((l) => formatLine(l, maxNumWidth));
|
|
6039
6074
|
if (lines.length > MAX_DIFF_LINES) {
|
|
6040
6075
|
const truncated = lines.slice(0, MAX_DIFF_LINES);
|
|
6041
|
-
truncated.push(
|
|
6076
|
+
truncated.push(pc2.dim(` ... (${lines.length - MAX_DIFF_LINES} more lines)`));
|
|
6042
6077
|
lines = truncated;
|
|
6043
6078
|
}
|
|
6044
6079
|
return lines.join(`
|
|
@@ -6051,11 +6086,11 @@ function generateNewFileDiff(content) {
|
|
|
6051
6086
|
const diffLines = [];
|
|
6052
6087
|
for (let i = 0;i < lines.length; i++) {
|
|
6053
6088
|
const numStr = String(i + 1).padStart(maxNumWidth);
|
|
6054
|
-
diffLines.push(`${numStr} ${
|
|
6089
|
+
diffLines.push(`${numStr} ${pc2.green("+")} ${lines[i]}`);
|
|
6055
6090
|
}
|
|
6056
6091
|
if (diffLines.length > MAX_DIFF_LINES) {
|
|
6057
6092
|
const truncated = diffLines.slice(0, MAX_DIFF_LINES);
|
|
6058
|
-
truncated.push(
|
|
6093
|
+
truncated.push(pc2.dim(` ... (${diffLines.length - MAX_DIFF_LINES} more lines)`));
|
|
6059
6094
|
return truncated.join(`
|
|
6060
6095
|
`);
|
|
6061
6096
|
}
|
|
@@ -6069,11 +6104,11 @@ function generateDeleteDiff(content) {
|
|
|
6069
6104
|
const diffLines = [];
|
|
6070
6105
|
for (let i = 0;i < lines.length; i++) {
|
|
6071
6106
|
const numStr = String(i + 1).padStart(maxNumWidth);
|
|
6072
|
-
diffLines.push(`${numStr} ${
|
|
6107
|
+
diffLines.push(`${numStr} ${pc2.red("-")} ${lines[i]}`);
|
|
6073
6108
|
}
|
|
6074
6109
|
if (diffLines.length > MAX_DIFF_LINES) {
|
|
6075
6110
|
const truncated = diffLines.slice(0, MAX_DIFF_LINES);
|
|
6076
|
-
truncated.push(
|
|
6111
|
+
truncated.push(pc2.dim(` ... (${diffLines.length - MAX_DIFF_LINES} more lines)`));
|
|
6077
6112
|
return truncated.join(`
|
|
6078
6113
|
`);
|
|
6079
6114
|
}
|
|
@@ -6081,7 +6116,7 @@ function generateDeleteDiff(content) {
|
|
|
6081
6116
|
`);
|
|
6082
6117
|
}
|
|
6083
6118
|
function generateMoveDiff(fromPath, toPath) {
|
|
6084
|
-
return [
|
|
6119
|
+
return [pc2.red(` - ${fromPath}`), pc2.green(` + ${toPath}`)].join(`
|
|
6085
6120
|
`);
|
|
6086
6121
|
}
|
|
6087
6122
|
var CONTEXT_LINES = 3, MAX_DIFF_LINES = 100;
|
|
@@ -6090,7 +6125,7 @@ var init_diff = __esm(() => {
|
|
|
6090
6125
|
});
|
|
6091
6126
|
|
|
6092
6127
|
// src/tools/write-file.ts
|
|
6093
|
-
import { writeFileSync as
|
|
6128
|
+
import { writeFileSync as writeFileSync5, mkdirSync as mkdirSync7, existsSync as existsSync11, readFileSync as readFileSync6 } from "fs";
|
|
6094
6129
|
import { dirname as dirname4 } from "path";
|
|
6095
6130
|
var writeFileTool;
|
|
6096
6131
|
var init_write_file = __esm(() => {
|
|
@@ -6154,7 +6189,7 @@ var init_write_file = __esm(() => {
|
|
|
6154
6189
|
if (fileExists) {
|
|
6155
6190
|
oldContent = readFileSync6(resolved, "utf-8");
|
|
6156
6191
|
}
|
|
6157
|
-
|
|
6192
|
+
writeFileSync5(resolved, content, "utf-8");
|
|
6158
6193
|
const diff = fileExists ? generateDiff(oldContent, content) : generateNewFileDiff(content);
|
|
6159
6194
|
ctx.fileOperationsCount = currentCount + 1;
|
|
6160
6195
|
logFileWrite(ctx.sessionId, path, true, `File ${fileExists ? "updated" : "created"}`);
|
|
@@ -6164,7 +6199,7 @@ var init_write_file = __esm(() => {
|
|
|
6164
6199
|
});
|
|
6165
6200
|
|
|
6166
6201
|
// src/tools/edit-file.ts
|
|
6167
|
-
import { readFileSync as readFileSync7, writeFileSync as
|
|
6202
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
|
|
6168
6203
|
var editFileTool;
|
|
6169
6204
|
var init_edit_file = __esm(() => {
|
|
6170
6205
|
init_i18n();
|
|
@@ -6228,7 +6263,7 @@ var init_edit_file = __esm(() => {
|
|
|
6228
6263
|
output: `[SECURITY BLOCKED] ${scanResult.reason}`
|
|
6229
6264
|
};
|
|
6230
6265
|
}
|
|
6231
|
-
|
|
6266
|
+
writeFileSync6(resolved, updated, "utf-8");
|
|
6232
6267
|
const diff = generateDiff(content, updated);
|
|
6233
6268
|
ctx.fileOperationsCount = currentCount + 1;
|
|
6234
6269
|
logFileWrite(ctx.sessionId, path, true, "File edited");
|
|
@@ -7073,30 +7108,30 @@ var init_bash = __esm(() => {
|
|
|
7073
7108
|
init_i18n();
|
|
7074
7109
|
bashGraceMs = BASH_GRACE_MS;
|
|
7075
7110
|
UNIX_TO_WIN_HINTS = {
|
|
7076
|
-
ls:
|
|
7077
|
-
pwd:
|
|
7078
|
-
cat:
|
|
7079
|
-
cp:
|
|
7080
|
-
mv:
|
|
7081
|
-
rm:
|
|
7082
|
-
grep:
|
|
7083
|
-
chmod: "Use
|
|
7084
|
-
touch: "Use
|
|
7085
|
-
find:
|
|
7111
|
+
ls: "Use the list_dir tool instead.",
|
|
7112
|
+
pwd: "Use the file_info tool instead.",
|
|
7113
|
+
cat: "Use the read_file tool instead.",
|
|
7114
|
+
cp: "Use the move_file tool instead.",
|
|
7115
|
+
mv: "Use the move_file tool instead.",
|
|
7116
|
+
rm: "Use the delete_file tool instead.",
|
|
7117
|
+
grep: "Use the grep tool instead.",
|
|
7118
|
+
chmod: "Use the chmod tool instead.",
|
|
7119
|
+
touch: "Use the write_file tool instead.",
|
|
7120
|
+
find: "Use the glob tool instead.",
|
|
7086
7121
|
head: "Use the read_file tool with offset/limit instead.",
|
|
7087
7122
|
tail: "Use the read_file tool instead.",
|
|
7088
7123
|
wc: "Use the read_file tool instead.",
|
|
7089
7124
|
diff: "Use the diff tool instead.",
|
|
7090
7125
|
which: 'Use "where" instead.',
|
|
7091
7126
|
echo: "echo works on Windows, but avoid pipes (|).",
|
|
7092
|
-
"Get-Content":
|
|
7093
|
-
"Select-Object": "
|
|
7127
|
+
"Get-Content": "Use the read_file tool instead.",
|
|
7128
|
+
"Select-Object": "Use the read_file tool with offset/limit instead."
|
|
7094
7129
|
};
|
|
7095
7130
|
UNIX_TO_WIN_TRANSLATE = {
|
|
7096
|
-
ls: "
|
|
7097
|
-
pwd: "
|
|
7098
|
-
cat: "
|
|
7099
|
-
wc:
|
|
7131
|
+
ls: "Get-ChildItem",
|
|
7132
|
+
pwd: "Get-Location",
|
|
7133
|
+
cat: "Get-Content",
|
|
7134
|
+
wc: "@(Get-Content).Count"
|
|
7100
7135
|
};
|
|
7101
7136
|
bashTool = {
|
|
7102
7137
|
name: "bash",
|
|
@@ -7106,8 +7141,14 @@ var init_bash = __esm(() => {
|
|
|
7106
7141
|
type: "object",
|
|
7107
7142
|
properties: {
|
|
7108
7143
|
command: { type: "string", description: "Shell command to execute" },
|
|
7109
|
-
workdir: {
|
|
7110
|
-
|
|
7144
|
+
workdir: {
|
|
7145
|
+
type: "string",
|
|
7146
|
+
description: "Working directory (default: baseDir)"
|
|
7147
|
+
},
|
|
7148
|
+
background: {
|
|
7149
|
+
type: "boolean",
|
|
7150
|
+
description: "Return a process id immediately without waiting (default: commands still running after a few seconds are auto-promoted to the background)"
|
|
7151
|
+
}
|
|
7111
7152
|
},
|
|
7112
7153
|
required: ["command"]
|
|
7113
7154
|
},
|
|
@@ -7387,8 +7428,21 @@ var init_prompt_builder = __esm(() => {
|
|
|
7387
7428
|
// src/core/session-logger.ts
|
|
7388
7429
|
class SessionLogger {
|
|
7389
7430
|
session;
|
|
7390
|
-
|
|
7431
|
+
logger;
|
|
7432
|
+
constructor(session, logger) {
|
|
7391
7433
|
this.session = session;
|
|
7434
|
+
this.logger = logger;
|
|
7435
|
+
this.bindSessionDir();
|
|
7436
|
+
}
|
|
7437
|
+
bindSessionDir() {
|
|
7438
|
+
const meta = this.session?.getActiveMeta();
|
|
7439
|
+
if (!meta)
|
|
7440
|
+
return;
|
|
7441
|
+
const dir = this.session.getSessionDirectory(meta.id);
|
|
7442
|
+
if (this.logger) {
|
|
7443
|
+
this.logger.setSessionDir(dir);
|
|
7444
|
+
}
|
|
7445
|
+
setAuditSessionDir(dir);
|
|
7392
7446
|
}
|
|
7393
7447
|
get active() {
|
|
7394
7448
|
return !!this.session?.getActive();
|
|
@@ -7425,7 +7479,13 @@ class SessionLogger {
|
|
|
7425
7479
|
ts: new Date().toISOString(),
|
|
7426
7480
|
type: "assistant",
|
|
7427
7481
|
content,
|
|
7428
|
-
...toolCalls ? {
|
|
7482
|
+
...toolCalls ? {
|
|
7483
|
+
tool_calls: toolCalls.map((tc) => ({
|
|
7484
|
+
id: tc.id,
|
|
7485
|
+
name: tc.name,
|
|
7486
|
+
arguments: tc.arguments
|
|
7487
|
+
}))
|
|
7488
|
+
} : {},
|
|
7429
7489
|
iteration
|
|
7430
7490
|
});
|
|
7431
7491
|
}
|
|
@@ -7509,6 +7569,9 @@ class SessionLogger {
|
|
|
7509
7569
|
});
|
|
7510
7570
|
}
|
|
7511
7571
|
}
|
|
7572
|
+
var init_session_logger = __esm(() => {
|
|
7573
|
+
init_audit_log();
|
|
7574
|
+
});
|
|
7512
7575
|
|
|
7513
7576
|
// node_modules/jsonrepair/lib/esm/utils/JSONRepairError.js
|
|
7514
7577
|
var JSONRepairError;
|
|
@@ -8651,7 +8714,7 @@ class StuckDetector {
|
|
|
8651
8714
|
escalationThreshold = 3;
|
|
8652
8715
|
fileRewriteCount = new Map;
|
|
8653
8716
|
fileRewriteThreshold = 3;
|
|
8654
|
-
constructor(threshold =
|
|
8717
|
+
constructor(threshold = 6, errorThreshold = 3) {
|
|
8655
8718
|
this.threshold = threshold;
|
|
8656
8719
|
this.errorThreshold = errorThreshold;
|
|
8657
8720
|
}
|
|
@@ -9497,7 +9560,7 @@ var init_agent_moe = __esm(() => {
|
|
|
9497
9560
|
|
|
9498
9561
|
// src/modules/memory/search.ts
|
|
9499
9562
|
import { readFileSync as readFileSync9, existsSync as existsSync18 } from "fs";
|
|
9500
|
-
import { join as
|
|
9563
|
+
import { join as join9 } from "path";
|
|
9501
9564
|
|
|
9502
9565
|
class MemorySearch {
|
|
9503
9566
|
memoryDir;
|
|
@@ -9508,7 +9571,7 @@ class MemorySearch {
|
|
|
9508
9571
|
const results = [];
|
|
9509
9572
|
const lowerQuery = query.toLowerCase();
|
|
9510
9573
|
for (const name of MEMORY_FILES) {
|
|
9511
|
-
const path =
|
|
9574
|
+
const path = join9(this.memoryDir, `${name}.md`);
|
|
9512
9575
|
if (!existsSync18(path))
|
|
9513
9576
|
continue;
|
|
9514
9577
|
const content = readFileSync9(path, "utf-8");
|
|
@@ -9520,7 +9583,7 @@ class MemorySearch {
|
|
|
9520
9583
|
}
|
|
9521
9584
|
}
|
|
9522
9585
|
}
|
|
9523
|
-
const prefsPath =
|
|
9586
|
+
const prefsPath = join9(this.memoryDir, "preferences.json");
|
|
9524
9587
|
if (existsSync18(prefsPath)) {
|
|
9525
9588
|
try {
|
|
9526
9589
|
const prefs = JSON.parse(readFileSync9(prefsPath, "utf-8"));
|
|
@@ -9541,8 +9604,8 @@ var init_search = __esm(() => {
|
|
|
9541
9604
|
});
|
|
9542
9605
|
|
|
9543
9606
|
// src/modules/memory/store.ts
|
|
9544
|
-
import { readFileSync as readFileSync10, writeFileSync as
|
|
9545
|
-
import { join as
|
|
9607
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, appendFileSync as appendFileSync4, existsSync as existsSync19, mkdirSync as mkdirSync10 } from "fs";
|
|
9608
|
+
import { join as join10 } from "path";
|
|
9546
9609
|
|
|
9547
9610
|
class MemoryStore {
|
|
9548
9611
|
memoryDir;
|
|
@@ -9550,9 +9613,9 @@ class MemoryStore {
|
|
|
9550
9613
|
this.memoryDir = memoryDir;
|
|
9551
9614
|
this.ensureDir();
|
|
9552
9615
|
for (const name of MEMORY_FILES2) {
|
|
9553
|
-
const path =
|
|
9616
|
+
const path = join10(this.memoryDir, `${name}.md`);
|
|
9554
9617
|
if (!existsSync19(path)) {
|
|
9555
|
-
|
|
9618
|
+
writeFileSync7(path, `# ${name.charAt(0).toUpperCase() + name.slice(1)}
|
|
9556
9619
|
|
|
9557
9620
|
`, "utf-8");
|
|
9558
9621
|
}
|
|
@@ -9564,13 +9627,13 @@ class MemoryStore {
|
|
|
9564
9627
|
}
|
|
9565
9628
|
}
|
|
9566
9629
|
read(name) {
|
|
9567
|
-
const path =
|
|
9630
|
+
const path = join10(this.memoryDir, `${name}.md`);
|
|
9568
9631
|
if (!existsSync19(path))
|
|
9569
9632
|
return "";
|
|
9570
9633
|
return readFileSync10(path, "utf-8");
|
|
9571
9634
|
}
|
|
9572
9635
|
append(name, entry) {
|
|
9573
|
-
const path =
|
|
9636
|
+
const path = join10(this.memoryDir, `${name}.md`);
|
|
9574
9637
|
const timestamp = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
9575
9638
|
const formatted = `- **${timestamp}** — ${entry}
|
|
9576
9639
|
`;
|
|
@@ -9581,7 +9644,7 @@ class MemoryStore {
|
|
|
9581
9644
|
return searchModule.query(query);
|
|
9582
9645
|
}
|
|
9583
9646
|
prefsPath() {
|
|
9584
|
-
return
|
|
9647
|
+
return join10(this.memoryDir, "preferences.json");
|
|
9585
9648
|
}
|
|
9586
9649
|
getPreferences() {
|
|
9587
9650
|
const path = this.prefsPath();
|
|
@@ -9596,14 +9659,14 @@ class MemoryStore {
|
|
|
9596
9659
|
setPreference(key, value) {
|
|
9597
9660
|
const prefs = this.getPreferences();
|
|
9598
9661
|
prefs[key] = value;
|
|
9599
|
-
|
|
9662
|
+
writeFileSync7(this.prefsPath(), JSON.stringify(prefs, null, 2), "utf-8");
|
|
9600
9663
|
}
|
|
9601
9664
|
deletePreference(key) {
|
|
9602
9665
|
const prefs = this.getPreferences();
|
|
9603
9666
|
if (!(key in prefs))
|
|
9604
9667
|
return false;
|
|
9605
9668
|
delete prefs[key];
|
|
9606
|
-
|
|
9669
|
+
writeFileSync7(this.prefsPath(), JSON.stringify(prefs, null, 2), "utf-8");
|
|
9607
9670
|
return true;
|
|
9608
9671
|
}
|
|
9609
9672
|
appendRule(category, pattern, cause, solution) {
|
|
@@ -9620,7 +9683,7 @@ var init_store = __esm(() => {
|
|
|
9620
9683
|
});
|
|
9621
9684
|
|
|
9622
9685
|
// src/core/agent.ts
|
|
9623
|
-
import { join as
|
|
9686
|
+
import { join as join11 } from "path";
|
|
9624
9687
|
function isToolCallJson(text) {
|
|
9625
9688
|
const trimmed = text.trim();
|
|
9626
9689
|
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
@@ -9710,7 +9773,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9710
9773
|
sessionManager,
|
|
9711
9774
|
baseDir
|
|
9712
9775
|
} = this.deps;
|
|
9713
|
-
const slog = new SessionLogger(sessionManager);
|
|
9776
|
+
const slog = new SessionLogger(sessionManager, logger);
|
|
9714
9777
|
if (sessionManager && !sessionManager.getActive()) {
|
|
9715
9778
|
sessionManager.create();
|
|
9716
9779
|
logger.debug(`Session started: ${sessionManager.getActive()}`);
|
|
@@ -9732,7 +9795,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9732
9795
|
verifier.runTypeCheck().then((tc) => {
|
|
9733
9796
|
if (!tc.passed) {
|
|
9734
9797
|
logger.warn(`Baseline typecheck has issues: ${tc.message?.slice(0, 500)}`);
|
|
9735
|
-
onMeta?.(
|
|
9798
|
+
onMeta?.(pc2.yellow(`
|
|
9736
9799
|
⚠ Baseline typecheck has issues
|
|
9737
9800
|
`));
|
|
9738
9801
|
}
|
|
@@ -9764,7 +9827,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9764
9827
|
sessionManager,
|
|
9765
9828
|
baseDir
|
|
9766
9829
|
} = this.deps;
|
|
9767
|
-
const slog = new SessionLogger(sessionManager);
|
|
9830
|
+
const slog = new SessionLogger(sessionManager, logger);
|
|
9768
9831
|
this.abortController = new AbortController;
|
|
9769
9832
|
let iteration = 0;
|
|
9770
9833
|
let lastText = "";
|
|
@@ -9837,7 +9900,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9837
9900
|
if (config.showReasoning) {
|
|
9838
9901
|
const metaOut = pluginManager.runOnMeta({ iteration, logger }, chunk.content);
|
|
9839
9902
|
if (metaOut) {
|
|
9840
|
-
onMeta?.(
|
|
9903
|
+
onMeta?.(pc2.dim(metaOut));
|
|
9841
9904
|
}
|
|
9842
9905
|
emittedReasoning = true;
|
|
9843
9906
|
}
|
|
@@ -9955,7 +10018,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9955
10018
|
} else {
|
|
9956
10019
|
const metaOut = pluginManager.runOnMeta({ iteration, logger }, result.output);
|
|
9957
10020
|
onMeta?.(`
|
|
9958
|
-
` +
|
|
10021
|
+
` + pc2.dim(metaOut) + `
|
|
9959
10022
|
`);
|
|
9960
10023
|
}
|
|
9961
10024
|
if (result.diff) {
|
|
@@ -10012,7 +10075,7 @@ ${taskReminder}</system-summary>`
|
|
|
10012
10075
|
if (sessionManager) {
|
|
10013
10076
|
const activeSession = sessionManager.getActiveMeta();
|
|
10014
10077
|
if (activeSession) {
|
|
10015
|
-
const memDir =
|
|
10078
|
+
const memDir = join11(baseDir, ".mma", "memory");
|
|
10016
10079
|
const memStore = new MemoryStore(memDir);
|
|
10017
10080
|
memStore.appendRule("errors", `${consecutiveToolFailures} consecutive tool failures`, "Multiple tools failing suggests environment or configuration issue", "Check dependencies, verify file paths, try write_file directly instead of shell commands");
|
|
10018
10081
|
}
|
|
@@ -10028,13 +10091,13 @@ ${taskReminder}</system-summary>`
|
|
|
10028
10091
|
const ctxPct = Math.min(100, Math.round(ctxTokens / ctxBudget.history * 100));
|
|
10029
10092
|
const barLen = 10;
|
|
10030
10093
|
const filled = Math.round(ctxPct / 100 * barLen);
|
|
10031
|
-
const ctxBar =
|
|
10032
|
-
const pctColor = ctxPct >= 75 ?
|
|
10094
|
+
const ctxBar = pc2.green("█".repeat(filled)) + pc2.dim("░".repeat(barLen - filled));
|
|
10095
|
+
const pctColor = ctxPct >= 75 ? pc2.yellow : pc2.dim;
|
|
10033
10096
|
const compCount = contextManager.getCompactionCount();
|
|
10034
10097
|
const quality2 = contextManager.getQuality();
|
|
10035
|
-
const qualityColor = quality2 >= 70 ?
|
|
10098
|
+
const qualityColor = quality2 >= 70 ? pc2.green : quality2 >= 40 ? pc2.yellow : pc2.red;
|
|
10036
10099
|
onMeta?.(`
|
|
10037
|
-
${ctxBar} ${pctColor(`${ctxPct}%`)} ${
|
|
10100
|
+
${ctxBar} ${pctColor(`${ctxPct}%`)} ${pc2.dim(`ctx: ${ctxTokens}/${ctxBudget.history}`)} ${pc2.dim(`compactions: ${compCount}`)} ${qualityColor(`quality: ${quality2}%`)}
|
|
10038
10101
|
`);
|
|
10039
10102
|
continue;
|
|
10040
10103
|
}
|
|
@@ -10217,6 +10280,7 @@ var init_agent = __esm(() => {
|
|
|
10217
10280
|
init_colors();
|
|
10218
10281
|
init_prompt_builder();
|
|
10219
10282
|
init_processes();
|
|
10283
|
+
init_session_logger();
|
|
10220
10284
|
init_agent_moe();
|
|
10221
10285
|
init_store();
|
|
10222
10286
|
init_verifier();
|
|
@@ -12193,7 +12257,7 @@ ${JSON.stringify(result, null, 2)}`
|
|
|
12193
12257
|
|
|
12194
12258
|
// src/tools/search-history.ts
|
|
12195
12259
|
import * as fs from "fs";
|
|
12196
|
-
import { join as
|
|
12260
|
+
import { join as join12 } from "path";
|
|
12197
12261
|
import { homedir as homedir5 } from "os";
|
|
12198
12262
|
function searchFile(filePath, query, maxResults, results) {
|
|
12199
12263
|
if (!fs.existsSync(filePath))
|
|
@@ -12237,7 +12301,7 @@ var init_search_history = __esm(() => {
|
|
|
12237
12301
|
const query = String(args.query || "").toLowerCase();
|
|
12238
12302
|
const maxResults = Number(args.maxResults) || 5;
|
|
12239
12303
|
const sessionId = args.sessionId ? String(args.sessionId) : null;
|
|
12240
|
-
const sessionDir =
|
|
12304
|
+
const sessionDir = join12(homedir5(), ".mma", "sessions");
|
|
12241
12305
|
const results = [];
|
|
12242
12306
|
try {
|
|
12243
12307
|
if (!fs.existsSync(sessionDir)) {
|
|
@@ -12252,7 +12316,7 @@ var init_search_history = __esm(() => {
|
|
|
12252
12316
|
continue;
|
|
12253
12317
|
if (sessionId && entry.name !== sessionId)
|
|
12254
12318
|
continue;
|
|
12255
|
-
const historyFile =
|
|
12319
|
+
const historyFile = join12(sessionDir, entry.name, "history.jsonl");
|
|
12256
12320
|
searchFile(historyFile, query, maxResults, results);
|
|
12257
12321
|
if (results.length >= maxResults)
|
|
12258
12322
|
break;
|
|
@@ -12280,7 +12344,7 @@ var init_search_history = __esm(() => {
|
|
|
12280
12344
|
|
|
12281
12345
|
// src/tools/remember.ts
|
|
12282
12346
|
import { homedir as homedir6 } from "os";
|
|
12283
|
-
import { join as
|
|
12347
|
+
import { join as join13 } from "path";
|
|
12284
12348
|
var CATEGORIES, rememberTool;
|
|
12285
12349
|
var init_remember = __esm(() => {
|
|
12286
12350
|
init_i18n();
|
|
@@ -12318,7 +12382,7 @@ var init_remember = __esm(() => {
|
|
|
12318
12382
|
if (!CATEGORIES.includes(category)) {
|
|
12319
12383
|
return { success: false, output: t("tool.invalid_params") };
|
|
12320
12384
|
}
|
|
12321
|
-
const memoryDir =
|
|
12385
|
+
const memoryDir = join13(homedir6(), ".mma", "memory");
|
|
12322
12386
|
const store = new MemoryStore(memoryDir);
|
|
12323
12387
|
try {
|
|
12324
12388
|
if (category === "preferences") {
|
|
@@ -12351,7 +12415,7 @@ var init_remember = __esm(() => {
|
|
|
12351
12415
|
|
|
12352
12416
|
// src/tools/recall.ts
|
|
12353
12417
|
import { homedir as homedir7 } from "os";
|
|
12354
|
-
import { join as
|
|
12418
|
+
import { join as join14 } from "path";
|
|
12355
12419
|
function formatAll(store) {
|
|
12356
12420
|
const parts = [];
|
|
12357
12421
|
const prefs = store.getPreferences();
|
|
@@ -12434,7 +12498,7 @@ var init_recall = __esm(() => {
|
|
|
12434
12498
|
handler: async (_ctx, args) => {
|
|
12435
12499
|
const query = args.query ? String(args.query) : "";
|
|
12436
12500
|
const category = args.category ? String(args.category) : "";
|
|
12437
|
-
const memoryDir =
|
|
12501
|
+
const memoryDir = join14(homedir7(), ".mma", "memory");
|
|
12438
12502
|
const store = new MemoryStore(memoryDir);
|
|
12439
12503
|
try {
|
|
12440
12504
|
if (!query && !category) {
|
|
@@ -12630,15 +12694,15 @@ function buildIndexInjectionScript() {
|
|
|
12630
12694
|
|
|
12631
12695
|
// src/modules/browser/cookie-store.ts
|
|
12632
12696
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
12633
|
-
import { join as
|
|
12697
|
+
import { join as join15 } from "path";
|
|
12634
12698
|
|
|
12635
12699
|
class CookieStore {
|
|
12636
12700
|
filePath;
|
|
12637
12701
|
constructor(cookieDir) {
|
|
12638
|
-
this.filePath =
|
|
12702
|
+
this.filePath = join15(cookieDir, "cookies.json");
|
|
12639
12703
|
}
|
|
12640
12704
|
async save(cookies) {
|
|
12641
|
-
await mkdir(
|
|
12705
|
+
await mkdir(join15(this.filePath, ".."), { recursive: true });
|
|
12642
12706
|
await writeFile(this.filePath, JSON.stringify(cookies, null, 2), "utf-8");
|
|
12643
12707
|
}
|
|
12644
12708
|
async load() {
|
|
@@ -12958,10 +13022,10 @@ var init_types = __esm(() => {
|
|
|
12958
13022
|
});
|
|
12959
13023
|
|
|
12960
13024
|
// src/tools/browser.ts
|
|
12961
|
-
import { join as
|
|
13025
|
+
import { join as join16 } from "path";
|
|
12962
13026
|
function getSession(ctx) {
|
|
12963
13027
|
if (!session) {
|
|
12964
|
-
const cookieDir =
|
|
13028
|
+
const cookieDir = join16(ctx.baseDir, ".mma", "browser");
|
|
12965
13029
|
session = new BrowserSession({
|
|
12966
13030
|
...DEFAULT_BROWSER_CONFIG,
|
|
12967
13031
|
headless: ctx.config.browser?.headless ?? true,
|
|
@@ -13091,8 +13155,8 @@ async function readClipboardFallback() {
|
|
|
13091
13155
|
const { platform: platform3 } = await import("os");
|
|
13092
13156
|
const { execSync } = await import("child_process");
|
|
13093
13157
|
const { readFileSync: readFileSync13, unlinkSync: unlinkSync3 } = await import("fs");
|
|
13094
|
-
const { join:
|
|
13095
|
-
const tmpPath =
|
|
13158
|
+
const { join: join17 } = await import("path");
|
|
13159
|
+
const tmpPath = join17(process.env.TEMP || process.env.TMP || "/tmp", `mma-clip-${Date.now()}.png`);
|
|
13096
13160
|
try {
|
|
13097
13161
|
if (platform3() === "linux") {
|
|
13098
13162
|
execSync(`xclip -selection clipboard -t image/png -o > "${tmpPath}" 2>/dev/null`, { timeout: 5000 });
|
|
@@ -13370,7 +13434,7 @@ class ModuleRegistry {
|
|
|
13370
13434
|
|
|
13371
13435
|
// src/modules/plugins/loader.ts
|
|
13372
13436
|
import { readdirSync as readdirSync5, existsSync as existsSync23, statSync as statSync4 } from "fs";
|
|
13373
|
-
import { join as
|
|
13437
|
+
import { join as join17 } from "path";
|
|
13374
13438
|
|
|
13375
13439
|
class PluginLoader {
|
|
13376
13440
|
loadFromDir(dirPath, pluginManager, logger) {
|
|
@@ -13378,7 +13442,7 @@ class PluginLoader {
|
|
|
13378
13442
|
return;
|
|
13379
13443
|
const entries = readdirSync5(dirPath);
|
|
13380
13444
|
for (const entry of entries) {
|
|
13381
|
-
const fullPath =
|
|
13445
|
+
const fullPath = join17(dirPath, entry);
|
|
13382
13446
|
if (!statSync4(fullPath).isFile())
|
|
13383
13447
|
continue;
|
|
13384
13448
|
if (!entry.endsWith(".ts") && !entry.endsWith(".js"))
|
|
@@ -13403,7 +13467,7 @@ var init_loader = __esm(() => {
|
|
|
13403
13467
|
// src/modules/plugins/builtin/lint-on-write.ts
|
|
13404
13468
|
import { spawn as spawn4 } from "child_process";
|
|
13405
13469
|
import { existsSync as existsSync24, readFileSync as readFileSync13 } from "fs";
|
|
13406
|
-
import { resolve as resolve13, extname as extname4, join as
|
|
13470
|
+
import { resolve as resolve13, extname as extname4, join as join18 } from "path";
|
|
13407
13471
|
|
|
13408
13472
|
class LintOnWritePlugin {
|
|
13409
13473
|
name = "lint-on-write";
|
|
@@ -13467,7 +13531,7 @@ class LintOnWritePlugin {
|
|
|
13467
13531
|
}
|
|
13468
13532
|
async runProjectLint(ctx, result) {
|
|
13469
13533
|
try {
|
|
13470
|
-
const packageJsonPath =
|
|
13534
|
+
const packageJsonPath = join18(ctx.baseDir, "package.json");
|
|
13471
13535
|
if (!existsSync24(packageJsonPath)) {
|
|
13472
13536
|
return;
|
|
13473
13537
|
}
|
|
@@ -13487,7 +13551,7 @@ class LintOnWritePlugin {
|
|
|
13487
13551
|
}
|
|
13488
13552
|
}
|
|
13489
13553
|
async runProjectTypeCheck(ctx, result) {
|
|
13490
|
-
const tsconfigPath =
|
|
13554
|
+
const tsconfigPath = join18(ctx.baseDir, "tsconfig.json");
|
|
13491
13555
|
if (!existsSync24(tsconfigPath)) {
|
|
13492
13556
|
return;
|
|
13493
13557
|
}
|
|
@@ -13758,17 +13822,17 @@ var init_auditor = __esm(() => {
|
|
|
13758
13822
|
});
|
|
13759
13823
|
|
|
13760
13824
|
// src/modules/execution/plan-persister.ts
|
|
13761
|
-
import { readFileSync as readFileSync14, writeFileSync as
|
|
13762
|
-
import { join as
|
|
13825
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync8, mkdirSync as mkdirSync11, existsSync as existsSync26 } from "fs";
|
|
13826
|
+
import { join as join19 } from "path";
|
|
13763
13827
|
|
|
13764
13828
|
class PlanPersister {
|
|
13765
13829
|
filePath;
|
|
13766
13830
|
constructor(baseDir) {
|
|
13767
|
-
const mmaDir =
|
|
13831
|
+
const mmaDir = join19(baseDir, ".mma");
|
|
13768
13832
|
if (!existsSync26(mmaDir)) {
|
|
13769
13833
|
mkdirSync11(mmaDir, { recursive: true });
|
|
13770
13834
|
}
|
|
13771
|
-
this.filePath =
|
|
13835
|
+
this.filePath = join19(mmaDir, "plan.json");
|
|
13772
13836
|
}
|
|
13773
13837
|
save(plan) {
|
|
13774
13838
|
const file = {
|
|
@@ -13779,7 +13843,7 @@ class PlanPersister {
|
|
|
13779
13843
|
updatedAt: new Date().toISOString(),
|
|
13780
13844
|
baseDir: plan.baseDir
|
|
13781
13845
|
};
|
|
13782
|
-
|
|
13846
|
+
writeFileSync8(this.filePath, JSON.stringify(file, null, 2), "utf-8");
|
|
13783
13847
|
}
|
|
13784
13848
|
load() {
|
|
13785
13849
|
if (!existsSync26(this.filePath))
|
|
@@ -13800,7 +13864,7 @@ class PlanPersister {
|
|
|
13800
13864
|
}
|
|
13801
13865
|
clear() {
|
|
13802
13866
|
if (existsSync26(this.filePath)) {
|
|
13803
|
-
|
|
13867
|
+
writeFileSync8(this.filePath, "", "utf-8");
|
|
13804
13868
|
}
|
|
13805
13869
|
}
|
|
13806
13870
|
}
|
|
@@ -13885,7 +13949,7 @@ class ExecutionModule {
|
|
|
13885
13949
|
consecutivePlanWarnings = 0;
|
|
13886
13950
|
lastStepId = -1;
|
|
13887
13951
|
_auditSkipsRemaining = 0;
|
|
13888
|
-
constructor(baseDir, stuckThreshold =
|
|
13952
|
+
constructor(baseDir, stuckThreshold = 6) {
|
|
13889
13953
|
this.baseDir = baseDir;
|
|
13890
13954
|
this.verifier = new StepVerifier(baseDir);
|
|
13891
13955
|
this.stuckDetector = new StuckDetector(stuckThreshold);
|
|
@@ -14219,7 +14283,7 @@ Tool "${this.stuckDetector.getLastFailedTool()}" is failing. Try "${alternative}
|
|
|
14219
14283
|
const step2 = this.tracker?.getCurrentStep();
|
|
14220
14284
|
ctx.contextManager.addMessage({
|
|
14221
14285
|
role: "user",
|
|
14222
|
-
content: `<system-summary>
|
|
14286
|
+
content: `<system-summary>STOP. Step ${step2?.id ?? "?"} ("${step2?.description ?? ""}") took ${this.stuckDetector.getIterationsOnCurrentStep()} iterations with no progress. DO NOT continue this step. Immediately call: plan update step=${step2?.id ?? "?"} status=done (if code works despite warnings) OR plan update step=${step2?.id ?? "?"} status=skipped note="reason". Do NOT make any other tool calls before updating the plan.</system-summary>`
|
|
14223
14287
|
});
|
|
14224
14288
|
}
|
|
14225
14289
|
}
|
|
@@ -14417,7 +14481,7 @@ Tool "${this.stuckDetector.getLastFailedTool()}" is failing. Try "${alternative}
|
|
|
14417
14481
|
return getMessageText(firstUser.content).trim();
|
|
14418
14482
|
}
|
|
14419
14483
|
}
|
|
14420
|
-
var STUCK_RECOVERY_COOLDOWN = 5, MAX_PLAN_WARNINGS_BEFORE_BLOCK = 3, FORCE_SKIP_THRESHOLD =
|
|
14484
|
+
var STUCK_RECOVERY_COOLDOWN = 5, MAX_PLAN_WARNINGS_BEFORE_BLOCK = 3, FORCE_SKIP_THRESHOLD = 10;
|
|
14421
14485
|
var init_module = __esm(() => {
|
|
14422
14486
|
init_i18n();
|
|
14423
14487
|
init_tracker();
|
|
@@ -14430,8 +14494,8 @@ var init_module = __esm(() => {
|
|
|
14430
14494
|
});
|
|
14431
14495
|
|
|
14432
14496
|
// src/modules/security/session-encryption.ts
|
|
14433
|
-
import { readFileSync as readFileSync16, writeFileSync as
|
|
14434
|
-
import { join as
|
|
14497
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync9, existsSync as existsSync28, readdirSync as readdirSync6, unlinkSync as unlinkSync3 } from "fs";
|
|
14498
|
+
import { join as join20 } from "path";
|
|
14435
14499
|
import { homedir as homedir8 } from "os";
|
|
14436
14500
|
|
|
14437
14501
|
class SessionFileEncryptor {
|
|
@@ -14440,7 +14504,7 @@ class SessionFileEncryptor {
|
|
|
14440
14504
|
constructor(config) {
|
|
14441
14505
|
this.config = { ...DEFAULT_SESSION_ENCRYPTION, ...config };
|
|
14442
14506
|
this.encryptor = new ConfigEncryptor({
|
|
14443
|
-
keyPath: config?.keyPath ||
|
|
14507
|
+
keyPath: config?.keyPath || join20(homedir8(), ".mma", ".session-encryption-key")
|
|
14444
14508
|
});
|
|
14445
14509
|
}
|
|
14446
14510
|
isEnabled() {
|
|
@@ -14485,7 +14549,7 @@ class SessionFileEncryptor {
|
|
|
14485
14549
|
}
|
|
14486
14550
|
writeSessionFile(filePath, content) {
|
|
14487
14551
|
const encrypted = this.encryptFileContent(content);
|
|
14488
|
-
|
|
14552
|
+
writeFileSync9(filePath, encrypted, "utf8");
|
|
14489
14553
|
}
|
|
14490
14554
|
readSessionJSON(filePath) {
|
|
14491
14555
|
const content = readFileSync16(filePath, "utf8");
|
|
@@ -14493,7 +14557,7 @@ class SessionFileEncryptor {
|
|
|
14493
14557
|
}
|
|
14494
14558
|
writeSessionJSON(filePath, obj) {
|
|
14495
14559
|
const content = this.encryptJSON(obj);
|
|
14496
|
-
|
|
14560
|
+
writeFileSync9(filePath, content, "utf8");
|
|
14497
14561
|
}
|
|
14498
14562
|
readSessionJSONL(filePath) {
|
|
14499
14563
|
const content = readFileSync16(filePath, "utf8");
|
|
@@ -14504,7 +14568,7 @@ class SessionFileEncryptor {
|
|
|
14504
14568
|
}
|
|
14505
14569
|
appendToSessionJSONL(filePath, obj) {
|
|
14506
14570
|
const encryptedLine = this.encryptFileContent(JSON.stringify(obj));
|
|
14507
|
-
|
|
14571
|
+
writeFileSync9(filePath, encryptedLine + `
|
|
14508
14572
|
`, { flag: "a", encoding: "utf8" });
|
|
14509
14573
|
}
|
|
14510
14574
|
encryptSessionDirectory(sessionDir) {
|
|
@@ -14512,12 +14576,12 @@ class SessionFileEncryptor {
|
|
|
14512
14576
|
return;
|
|
14513
14577
|
const files = readdirSync6(sessionDir);
|
|
14514
14578
|
for (const file of files) {
|
|
14515
|
-
const filePath =
|
|
14579
|
+
const filePath = join20(sessionDir, file);
|
|
14516
14580
|
if (existsSync28(filePath) && !file.endsWith(".enc")) {
|
|
14517
14581
|
try {
|
|
14518
14582
|
const content = readFileSync16(filePath, "utf8");
|
|
14519
14583
|
const encrypted = this.encryptFileContent(content);
|
|
14520
|
-
|
|
14584
|
+
writeFileSync9(filePath + ".enc", encrypted, "utf8");
|
|
14521
14585
|
unlinkSync3(filePath);
|
|
14522
14586
|
} catch {}
|
|
14523
14587
|
}
|
|
@@ -14529,12 +14593,12 @@ class SessionFileEncryptor {
|
|
|
14529
14593
|
const files = readdirSync6(sessionDir);
|
|
14530
14594
|
for (const file of files) {
|
|
14531
14595
|
if (file.endsWith(".enc")) {
|
|
14532
|
-
const encFilePath =
|
|
14596
|
+
const encFilePath = join20(sessionDir, file);
|
|
14533
14597
|
const decFilePath = encFilePath.slice(0, -4);
|
|
14534
14598
|
try {
|
|
14535
14599
|
const content = readFileSync16(encFilePath, "utf8");
|
|
14536
14600
|
const decrypted = this.decryptFileContent(content);
|
|
14537
|
-
|
|
14601
|
+
writeFileSync9(decFilePath, decrypted, "utf8");
|
|
14538
14602
|
unlinkSync3(encFilePath);
|
|
14539
14603
|
} catch {}
|
|
14540
14604
|
}
|
|
@@ -14559,10 +14623,10 @@ import {
|
|
|
14559
14623
|
readdirSync as readdirSync7,
|
|
14560
14624
|
readFileSync as readFileSync17,
|
|
14561
14625
|
rmSync,
|
|
14562
|
-
writeFileSync as
|
|
14626
|
+
writeFileSync as writeFileSync10,
|
|
14563
14627
|
appendFileSync as appendFileSync5
|
|
14564
14628
|
} from "fs";
|
|
14565
|
-
import { join as
|
|
14629
|
+
import { join as join21 } from "path";
|
|
14566
14630
|
import { gzipSync } from "zlib";
|
|
14567
14631
|
|
|
14568
14632
|
class SessionStore {
|
|
@@ -14575,6 +14639,9 @@ class SessionStore {
|
|
|
14575
14639
|
this.encryptor = new SessionFileEncryptor(encryptionConfig);
|
|
14576
14640
|
}
|
|
14577
14641
|
}
|
|
14642
|
+
getSessionDir(id) {
|
|
14643
|
+
return join21(this.baseDir, id);
|
|
14644
|
+
}
|
|
14578
14645
|
updateEncryption(config) {
|
|
14579
14646
|
if (config?.enabled) {
|
|
14580
14647
|
this.encryptor = new SessionFileEncryptor(config);
|
|
@@ -14589,16 +14656,16 @@ class SessionStore {
|
|
|
14589
14656
|
mkdirSync12(this.baseDir, { recursive: true });
|
|
14590
14657
|
}
|
|
14591
14658
|
sessionDir(id) {
|
|
14592
|
-
return
|
|
14659
|
+
return join21(this.baseDir, id);
|
|
14593
14660
|
}
|
|
14594
14661
|
metaPath(id) {
|
|
14595
|
-
return
|
|
14662
|
+
return join21(this.sessionDir(id), "meta.json");
|
|
14596
14663
|
}
|
|
14597
14664
|
historyPath(id) {
|
|
14598
|
-
return
|
|
14665
|
+
return join21(this.sessionDir(id), "history.jsonl");
|
|
14599
14666
|
}
|
|
14600
14667
|
sessionLogPath(id) {
|
|
14601
|
-
return
|
|
14668
|
+
return join21(this.sessionDir(id), "session.jsonl");
|
|
14602
14669
|
}
|
|
14603
14670
|
sessionExists(id) {
|
|
14604
14671
|
return existsSync29(this.metaPath(id));
|
|
@@ -14609,9 +14676,9 @@ class SessionStore {
|
|
|
14609
14676
|
mkdirSync12(dir, { recursive: true });
|
|
14610
14677
|
const content = JSON.stringify(meta, null, 2);
|
|
14611
14678
|
if (this.encryptor) {
|
|
14612
|
-
|
|
14679
|
+
writeFileSync10(this.metaPath(id), this.encryptor.encryptFileContent(content), "utf-8");
|
|
14613
14680
|
} else {
|
|
14614
|
-
|
|
14681
|
+
writeFileSync10(this.metaPath(id), content, "utf-8");
|
|
14615
14682
|
}
|
|
14616
14683
|
}
|
|
14617
14684
|
loadMeta(id) {
|
|
@@ -14752,8 +14819,8 @@ class SessionStore {
|
|
|
14752
14819
|
if (existsSync29(historyPath)) {
|
|
14753
14820
|
const content = readFileSync17(historyPath, "utf-8");
|
|
14754
14821
|
const compressed = gzipSync(content);
|
|
14755
|
-
const gzPath =
|
|
14756
|
-
|
|
14822
|
+
const gzPath = join21(this.baseDir, `${session2.id}.jsonl.gz`);
|
|
14823
|
+
writeFileSync10(gzPath, compressed);
|
|
14757
14824
|
rmSync(historyPath);
|
|
14758
14825
|
}
|
|
14759
14826
|
}
|
|
@@ -14863,6 +14930,9 @@ class SessionManager {
|
|
|
14863
14930
|
return;
|
|
14864
14931
|
return this.getSessionContextById(this.activeId);
|
|
14865
14932
|
}
|
|
14933
|
+
getSessionDirectory(id) {
|
|
14934
|
+
return this.store.getSessionDir(id);
|
|
14935
|
+
}
|
|
14866
14936
|
getSessionContextById(sessionId) {
|
|
14867
14937
|
if (!this.sessionContexts.has(sessionId)) {
|
|
14868
14938
|
const meta = this.store.loadMeta(sessionId);
|
|
@@ -14959,8 +15029,8 @@ class ProfileCompressor {
|
|
|
14959
15029
|
}
|
|
14960
15030
|
|
|
14961
15031
|
// src/modules/user-profile/profile.ts
|
|
14962
|
-
import { readFileSync as readFileSync18, writeFileSync as
|
|
14963
|
-
import { join as
|
|
15032
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync11, existsSync as existsSync30, mkdirSync as mkdirSync13 } from "fs";
|
|
15033
|
+
import { join as join22 } from "path";
|
|
14964
15034
|
import { homedir as homedir9, hostname, platform as platform3, type } from "os";
|
|
14965
15035
|
import { env } from "process";
|
|
14966
15036
|
|
|
@@ -14987,10 +15057,10 @@ class UserProfile {
|
|
|
14987
15057
|
if (!existsSync30(this.profileDir)) {
|
|
14988
15058
|
mkdirSync13(this.profileDir, { recursive: true });
|
|
14989
15059
|
}
|
|
14990
|
-
|
|
15060
|
+
writeFileSync11(join22(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
|
|
14991
15061
|
}
|
|
14992
15062
|
load() {
|
|
14993
|
-
const path =
|
|
15063
|
+
const path = join22(this.profileDir, "profile.json");
|
|
14994
15064
|
if (!existsSync30(path))
|
|
14995
15065
|
return null;
|
|
14996
15066
|
try {
|
|
@@ -15030,7 +15100,7 @@ var init_profile = () => {};
|
|
|
15030
15100
|
|
|
15031
15101
|
// src/modules/skills/loader.ts
|
|
15032
15102
|
import { readdirSync as readdirSync8, readFileSync as readFileSync19, existsSync as existsSync31, statSync as statSync5 } from "fs";
|
|
15033
|
-
import { join as
|
|
15103
|
+
import { join as join23 } from "path";
|
|
15034
15104
|
|
|
15035
15105
|
class SkillsLoader {
|
|
15036
15106
|
loadFromDir(dirPath) {
|
|
@@ -15043,7 +15113,7 @@ class SkillsLoader {
|
|
|
15043
15113
|
scanDir(dirPath, skills) {
|
|
15044
15114
|
const entries = readdirSync8(dirPath);
|
|
15045
15115
|
for (const entry of entries) {
|
|
15046
|
-
const fullPath =
|
|
15116
|
+
const fullPath = join23(dirPath, entry);
|
|
15047
15117
|
const stat = statSync5(fullPath);
|
|
15048
15118
|
if (stat.isDirectory()) {
|
|
15049
15119
|
this.scanDir(fullPath, skills);
|
|
@@ -15640,7 +15710,7 @@ var init_lsp = __esm(() => {
|
|
|
15640
15710
|
|
|
15641
15711
|
// src/modules/indexer/walker.ts
|
|
15642
15712
|
import { readdirSync as readdirSync9, readFileSync as readFileSync20, statSync as statSync6, existsSync as existsSync33, watch } from "fs";
|
|
15643
|
-
import { join as
|
|
15713
|
+
import { join as join24, relative, extname as extname5 } from "path";
|
|
15644
15714
|
|
|
15645
15715
|
class Indexer {
|
|
15646
15716
|
baseDir;
|
|
@@ -15678,7 +15748,7 @@ class Indexer {
|
|
|
15678
15748
|
for (const entry of entries) {
|
|
15679
15749
|
if (count >= this.MAX_FILES)
|
|
15680
15750
|
return;
|
|
15681
|
-
const fullPath =
|
|
15751
|
+
const fullPath = join24(dir, entry);
|
|
15682
15752
|
const relPath = relative(this.baseDir, fullPath);
|
|
15683
15753
|
const stat = statSync6(fullPath);
|
|
15684
15754
|
if (stat.isDirectory()) {
|
|
@@ -15741,14 +15811,14 @@ var init_walker = __esm(() => {
|
|
|
15741
15811
|
});
|
|
15742
15812
|
|
|
15743
15813
|
// src/modules/indexer/cache.ts
|
|
15744
|
-
import { readFileSync as readFileSync21, writeFileSync as
|
|
15745
|
-
import { join as
|
|
15814
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync12, existsSync as existsSync34, mkdirSync as mkdirSync14, rmSync as rmSync2 } from "fs";
|
|
15815
|
+
import { join as join25 } from "path";
|
|
15746
15816
|
|
|
15747
15817
|
class IndexCache {
|
|
15748
15818
|
cachePath;
|
|
15749
15819
|
cache = null;
|
|
15750
15820
|
constructor(cacheDir) {
|
|
15751
|
-
this.cachePath =
|
|
15821
|
+
this.cachePath = join25(cacheDir, "index-cache.json");
|
|
15752
15822
|
}
|
|
15753
15823
|
load() {
|
|
15754
15824
|
if (this.cache)
|
|
@@ -15764,10 +15834,10 @@ class IndexCache {
|
|
|
15764
15834
|
}
|
|
15765
15835
|
save(result) {
|
|
15766
15836
|
this.cache = result;
|
|
15767
|
-
const dir =
|
|
15837
|
+
const dir = join25(this.cachePath, "..");
|
|
15768
15838
|
if (!existsSync34(dir))
|
|
15769
15839
|
mkdirSync14(dir, { recursive: true });
|
|
15770
|
-
|
|
15840
|
+
writeFileSync12(this.cachePath, JSON.stringify(result), "utf-8");
|
|
15771
15841
|
}
|
|
15772
15842
|
invalidate() {
|
|
15773
15843
|
this.cache = null;
|
|
@@ -16129,13 +16199,13 @@ var init_mcp = __esm(() => {
|
|
|
16129
16199
|
|
|
16130
16200
|
// src/modules/memory/module.ts
|
|
16131
16201
|
import { homedir as homedir10 } from "os";
|
|
16132
|
-
import { join as
|
|
16202
|
+
import { join as join26 } from "path";
|
|
16133
16203
|
|
|
16134
16204
|
class MemoryModule {
|
|
16135
16205
|
name = "memory";
|
|
16136
16206
|
store;
|
|
16137
16207
|
constructor(memoryDir) {
|
|
16138
|
-
const dir = memoryDir ||
|
|
16208
|
+
const dir = memoryDir || join26(homedir10(), ".mma", "memory");
|
|
16139
16209
|
this.store = new MemoryStore(dir);
|
|
16140
16210
|
}
|
|
16141
16211
|
getSystemPromptBlock() {
|
|
@@ -16182,8 +16252,8 @@ __export(exports_bootstrap, {
|
|
|
16182
16252
|
bootstrap: () => bootstrap
|
|
16183
16253
|
});
|
|
16184
16254
|
import { homedir as homedir11 } from "os";
|
|
16185
|
-
import { join as
|
|
16186
|
-
import { existsSync as existsSync35, readFileSync as readFileSync22, writeFileSync as
|
|
16255
|
+
import { join as join27, resolve as resolve18 } from "path";
|
|
16256
|
+
import { existsSync as existsSync35, readFileSync as readFileSync22, writeFileSync as writeFileSync13 } from "fs";
|
|
16187
16257
|
function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
16188
16258
|
const now = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
16189
16259
|
const isWin = profileCompressed.toLowerCase().includes("win32");
|
|
@@ -16202,7 +16272,7 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
16202
16272
|
`- DRY: Do not duplicate code, logic, or configuration — reuse existing utilities and patterns.`
|
|
16203
16273
|
];
|
|
16204
16274
|
if (isWin) {
|
|
16205
|
-
lines.push(``, `Windows environment —
|
|
16275
|
+
lines.push(``, `Windows environment — the shell is PowerShell. Use these rules:`, `- For file listings, prefer the list_dir tool over "dir".`, `- For reading files, prefer the read_file tool over "type".`, `- For deleting files, prefer the delete_file tool over "del".`, `- For creating directories, prefer the create_dir tool over "mkdir".`, `- Do NOT use PowerShell cmdlets (Get-Content, Select-Object, Write-Output) — use dedicated tools instead.`, `- Do not use "head", "tail", "grep", "cat" — they are Unix commands. Use the read_file and grep tools instead.`, `- Use forward slashes (/) or escaped backslashes (\\\\) in file paths.`, `- Your working directory is: ${baseDir}`);
|
|
16206
16276
|
}
|
|
16207
16277
|
lines.push(``, `Bash tool rules:`, `- Use the "workdir" parameter to run commands in a specific directory. Prefer workdir over "cd dir && cmd" chaining.`, `- Run one command per tool call. Split multi-step shell operations into separate bash calls.`, `- Dev servers, watchers and other long-running processes: pass "background: true" to get a process id immediately. Without it, any command still running after a few seconds is automatically moved to the background — check output with process_log.`);
|
|
16208
16278
|
lines.push(``, `=== DEVELOPMENT RULES — follow these strictly ===`, ``, `1. DEPENDENCIES FIRST: Before writing any source code, ALWAYS install project dependencies (e.g., "npm install", "pip install -r requirements.txt", "cargo build", "go mod tidy"). Verify the package manager's lock file or dependency directory exists. Never write code that imports/uses packages that aren't installed yet.`, `2. TOOLKIT/FWK FIRST: If the task specifies a framework or UI library, initialize and configure it BEFORE writing application code. Run its project init command first, then add components/modules. Never write your own version of what the framework already provides.`, `3. ONE STEP AT A TIME: Follow the plan sequentially. Complete step N before starting step N+1. When a step is done: verify the deliverables exist and have real content (not empty), then call "plan update step=N status=done". Do not redo completed work.`, `4. VERIFY YOUR WORK: After creating/modifying files, verify they exist on disk. After installing dependencies, verify the package manager completed successfully. After any command, check its output for errors. Don't assume operations succeeded.`, `5. NO PREMATURE WORK: Do not create files for future steps. Do not add imports/references to packages or modules that haven't been installed yet. Do not reference files or components that don't exist yet. Build incrementally — one layer at a time.`, `6. WHEN STUCK: If a command fails 2+ times, STOP and try a different approach. Write files directly instead of using commands. Ask the user for help. Never repeat the same failing command more than twice.`, ``, `=== PLAN QUALITY RULES — your plan MUST follow these ===`, ``, `- Each step must describe CONCRETE deliverables: exact filenames with paths, exact packages to install, exact CLI commands to run. Avoid vague steps — be specific.`, `- A step like "Настройка проекта" or "Setup the project" is too vague — describe what exactly needs to be configured or set up.`, `- A step like "Создать src/components/Header.tsx с навигацией и логотипом, добавить в src/App.tsx импорт <Header />" is GOOD.`, `- Include file extensions (.tsx, .css, .json) and directory paths. Every step must mention at least one file or command.`, `- The plan must cover EVERYTHING needed: init → deps → framework setup → code → verification.`, `- Number of steps: 5-8 for a typical task. Too few means you're being vague. Too many means you're over-splitting.`);
|
|
@@ -16217,8 +16287,8 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
16217
16287
|
`);
|
|
16218
16288
|
}
|
|
16219
16289
|
async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
16220
|
-
const dir = configDir ||
|
|
16221
|
-
const projectConfigPath = projectDir ?
|
|
16290
|
+
const dir = configDir || join27(homedir11(), ".mma");
|
|
16291
|
+
const projectConfigPath = projectDir ? join27(projectDir, ".mmrc") : join27(process.cwd(), ".mmrc");
|
|
16222
16292
|
const config = loadConfig({ configDir: dir, projectConfigPath });
|
|
16223
16293
|
setLocale(config.locale);
|
|
16224
16294
|
try {
|
|
@@ -16228,7 +16298,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16228
16298
|
}
|
|
16229
16299
|
} catch {}
|
|
16230
16300
|
const logger = new Logger(config.logLevel);
|
|
16231
|
-
logger.setLogDir(
|
|
16301
|
+
logger.setLogDir(join27(dir, "logs"));
|
|
16232
16302
|
logger.debug("MMA bootstrap", {
|
|
16233
16303
|
version: config.version,
|
|
16234
16304
|
model: config.model
|
|
@@ -16250,7 +16320,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16250
16320
|
logger.info(`Model ${config.model} loaded in ${loadResult.loadTime}s`);
|
|
16251
16321
|
}
|
|
16252
16322
|
}
|
|
16253
|
-
const profile = new UserProfile(
|
|
16323
|
+
const profile = new UserProfile(join27(dir));
|
|
16254
16324
|
profile.load() || profile.collect();
|
|
16255
16325
|
profile.save();
|
|
16256
16326
|
const llmProvider = new OpenAICompatProvider({
|
|
@@ -16262,7 +16332,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16262
16332
|
rateLimits: config.security?.rateLimits
|
|
16263
16333
|
});
|
|
16264
16334
|
const baseDir = projectDir ? resolve18(projectDir) : process.cwd();
|
|
16265
|
-
const projectMapCacheDir =
|
|
16335
|
+
const projectMapCacheDir = join27(baseDir, ".mma");
|
|
16266
16336
|
const indexerModule = new IndexerModule({
|
|
16267
16337
|
baseDir,
|
|
16268
16338
|
cacheDir: projectMapCacheDir
|
|
@@ -16273,9 +16343,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16273
16343
|
logger.warn(`Project indexing failed: ${err.message}`);
|
|
16274
16344
|
}
|
|
16275
16345
|
const skillsLoader = new SkillsLoader;
|
|
16276
|
-
const builtinDir =
|
|
16277
|
-
const globalDir =
|
|
16278
|
-
const projectSkillsDir =
|
|
16346
|
+
const builtinDir = join27(import.meta.dirname, "skills", "builtin");
|
|
16347
|
+
const globalDir = join27(homedir11(), ".agents", "skills");
|
|
16348
|
+
const projectSkillsDir = join27(baseDir, ".mma", "skills");
|
|
16279
16349
|
const availableSkills = skillsLoader.loadFromAllSources(builtinDir, globalDir, projectSkillsDir);
|
|
16280
16350
|
const skillsMatcher = new SkillsMatcher;
|
|
16281
16351
|
const skillsBudget = Math.floor(config.contextWindow * 0.1);
|
|
@@ -16289,11 +16359,11 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16289
16359
|
essential: true,
|
|
16290
16360
|
estimatedTokens: 250
|
|
16291
16361
|
};
|
|
16292
|
-
const agentsMdGlobal =
|
|
16362
|
+
const agentsMdGlobal = join27(dir, "AGENTS.md");
|
|
16293
16363
|
if (!existsSync35(agentsMdGlobal)) {
|
|
16294
|
-
|
|
16364
|
+
writeFileSync13(agentsMdGlobal, "", "utf-8");
|
|
16295
16365
|
}
|
|
16296
|
-
const sessionDir =
|
|
16366
|
+
const sessionDir = join27(dir, "sessions");
|
|
16297
16367
|
const sessionStore = new SessionStore(sessionDir);
|
|
16298
16368
|
sessionStore.init();
|
|
16299
16369
|
const sessionManager = new SessionManager(sessionStore, {
|
|
@@ -16361,7 +16431,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16361
16431
|
const mcpModule = new MCPModule(config);
|
|
16362
16432
|
await mcpModule.initialize();
|
|
16363
16433
|
moduleRegistry.register(mcpModule);
|
|
16364
|
-
const memoryModule = new MemoryModule(
|
|
16434
|
+
const memoryModule = new MemoryModule(join27(dir, "memory"));
|
|
16365
16435
|
moduleRegistry.register(memoryModule);
|
|
16366
16436
|
if (config.browser.enabled) {
|
|
16367
16437
|
const browserModule = new BrowserModule;
|
|
@@ -16411,8 +16481,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16411
16481
|
pluginManager.register(plugin);
|
|
16412
16482
|
pluginManager.register(plugin2);
|
|
16413
16483
|
const pluginLoader = new PluginLoader;
|
|
16414
|
-
const globalPluginsDir =
|
|
16415
|
-
const projectPluginsDir =
|
|
16484
|
+
const globalPluginsDir = join27(homedir11(), ".mma", "plugins");
|
|
16485
|
+
const projectPluginsDir = join27(baseDir, ".mma", "plugins");
|
|
16416
16486
|
pluginLoader.loadFromDir(globalPluginsDir, pluginManager, logger);
|
|
16417
16487
|
pluginLoader.loadFromDir(projectPluginsDir, pluginManager, logger);
|
|
16418
16488
|
contextManager.onCompact = (summary) => {
|
|
@@ -16430,9 +16500,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
16430
16500
|
const skipAgentsMd = noAgentsMd === true;
|
|
16431
16501
|
if (!skipAgentsMd) {
|
|
16432
16502
|
const agentsMdCandidates = [
|
|
16433
|
-
|
|
16434
|
-
|
|
16435
|
-
|
|
16503
|
+
join27(baseDir, "AGENTS.md"),
|
|
16504
|
+
join27(baseDir, ".mma", "AGENTS.md"),
|
|
16505
|
+
join27(dir, "AGENTS.md")
|
|
16436
16506
|
];
|
|
16437
16507
|
for (const p of agentsMdCandidates) {
|
|
16438
16508
|
if (existsSync35(p)) {
|
|
@@ -16780,12 +16850,12 @@ function formatTable(tableLines, opts = {}) {
|
|
|
16780
16850
|
const a = isHeader && align[c] === undefined ? "center" : align[c] ?? "left";
|
|
16781
16851
|
cells.push(pad(cell, widths[c], a));
|
|
16782
16852
|
}
|
|
16783
|
-
const content = cells.map((c) =>
|
|
16784
|
-
return isHeader ?
|
|
16853
|
+
const content = cells.map((c) => pc2.dim("│ ") + c).join("") + pc2.dim("│");
|
|
16854
|
+
return isHeader ? pc2.bold(content) : content;
|
|
16785
16855
|
};
|
|
16786
16856
|
const border = (l, m, r) => {
|
|
16787
16857
|
const seg = widths.map((w) => "─".repeat(w + 2)).join(m);
|
|
16788
|
-
return
|
|
16858
|
+
return pc2.dim(l + seg + r);
|
|
16789
16859
|
};
|
|
16790
16860
|
const out = [];
|
|
16791
16861
|
out.push(border("┌", "┬", "┐"));
|
|
@@ -16883,7 +16953,7 @@ class Spinner {
|
|
|
16883
16953
|
return;
|
|
16884
16954
|
const frame = FRAMES[this.frame % FRAMES.length];
|
|
16885
16955
|
this.frame++;
|
|
16886
|
-
this.stream.write("\r" +
|
|
16956
|
+
this.stream.write("\r" + pc2.cyan(frame) + " " + this.message + "\x1B[K");
|
|
16887
16957
|
}
|
|
16888
16958
|
}
|
|
16889
16959
|
var FRAMES;
|
|
@@ -16950,19 +17020,19 @@ function box(lines, opts = {}) {
|
|
|
16950
17020
|
const title = opts.title ?? "";
|
|
16951
17021
|
if (title) {
|
|
16952
17022
|
const head = `─ ${title} `;
|
|
16953
|
-
out.push(
|
|
17023
|
+
out.push(pc2.dim(`┌${head}${"─".repeat(Math.max(0, width - 2 - stringWidth(head)))}┐`));
|
|
16954
17024
|
} else {
|
|
16955
|
-
out.push(
|
|
17025
|
+
out.push(pc2.dim(`┌${"─".repeat(width - 2)}┐`));
|
|
16956
17026
|
}
|
|
16957
17027
|
for (const line of wrapped) {
|
|
16958
|
-
out.push(
|
|
17028
|
+
out.push(pc2.dim("│") + " ".repeat(pad2) + padTo(line, inner) + " ".repeat(pad2) + pc2.dim("│"));
|
|
16959
17029
|
}
|
|
16960
|
-
out.push(
|
|
17030
|
+
out.push(pc2.dim(`└${"─".repeat(width - 2)}┘`));
|
|
16961
17031
|
return out;
|
|
16962
17032
|
}
|
|
16963
17033
|
function divider(width) {
|
|
16964
17034
|
const w = Math.min(width ?? getTerminalWidth(), 60);
|
|
16965
|
-
return
|
|
17035
|
+
return pc2.dim("─".repeat(w));
|
|
16966
17036
|
}
|
|
16967
17037
|
var init_box = __esm(() => {
|
|
16968
17038
|
init_string_width();
|
|
@@ -16982,7 +17052,7 @@ async function withSpinner(message, fn) {
|
|
|
16982
17052
|
}
|
|
16983
17053
|
}
|
|
16984
17054
|
function menuList(items) {
|
|
16985
|
-
const lines = items.map((it, i) => ` ${
|
|
17055
|
+
const lines = items.map((it, i) => ` ${pc2.cyan(`[${i + 1}]`)} ${it.label}${it.url ? ` ${pc2.dim(it.url)}` : ""}`);
|
|
16986
17056
|
for (const l of box(lines, { width: 72 }))
|
|
16987
17057
|
console.log(l);
|
|
16988
17058
|
}
|
|
@@ -17117,15 +17187,15 @@ async function runSetup(externalRl) {
|
|
|
17117
17187
|
}
|
|
17118
17188
|
const connected = await withSpinner(t("setup.testing_spinner", { model }), () => testChat(apiBase, apiKey, model));
|
|
17119
17189
|
if (connected) {
|
|
17120
|
-
console.log(
|
|
17190
|
+
console.log(pc2.green(t("setup.ok")));
|
|
17121
17191
|
} else {
|
|
17122
|
-
console.log(
|
|
17192
|
+
console.log(pc2.yellow(t("setup.warning")));
|
|
17123
17193
|
}
|
|
17124
17194
|
console.log(t("setup.agent_settings"));
|
|
17125
17195
|
const contextWindow = parseInt(await ask(rl, t("setup.context_window"), "32768"));
|
|
17126
17196
|
const maxIterations = parseInt(await ask(rl, t("setup.max_iters"), "1000"));
|
|
17127
17197
|
console.log(t("setup.security_header"));
|
|
17128
|
-
console.log(
|
|
17198
|
+
console.log(pc2.dim(t("setup.security_status_off")));
|
|
17129
17199
|
const configureSecurity = await ask(rl, t("setup.security_configure"), "n");
|
|
17130
17200
|
let securityBashBlock = false;
|
|
17131
17201
|
let securityFlagsBlock = false;
|
|
@@ -17149,7 +17219,7 @@ async function runSetup(externalRl) {
|
|
|
17149
17219
|
securityFlagsBlock,
|
|
17150
17220
|
securityPathsDeny
|
|
17151
17221
|
};
|
|
17152
|
-
console.log(
|
|
17222
|
+
console.log(pc2.green(pc2.bold(t("setup.complete"))));
|
|
17153
17223
|
const summary = renderTable([
|
|
17154
17224
|
t("setup.summary_setting"),
|
|
17155
17225
|
t("setup.summary_value"),
|
|
@@ -17209,9 +17279,9 @@ __export(exports_manifest, {
|
|
|
17209
17279
|
getCertMark: () => getCertMark,
|
|
17210
17280
|
MANIFEST_PATH: () => MANIFEST_PATH
|
|
17211
17281
|
});
|
|
17212
|
-
import { existsSync as existsSync36, readFileSync as readFileSync23, mkdirSync as mkdirSync15, writeFileSync as
|
|
17282
|
+
import { existsSync as existsSync36, readFileSync as readFileSync23, mkdirSync as mkdirSync15, writeFileSync as writeFileSync14 } from "fs";
|
|
17213
17283
|
import { homedir as homedir13 } from "os";
|
|
17214
|
-
import { join as
|
|
17284
|
+
import { join as join29 } from "path";
|
|
17215
17285
|
function readManifest(path = MANIFEST_PATH) {
|
|
17216
17286
|
try {
|
|
17217
17287
|
if (existsSync36(path)) {
|
|
@@ -17222,8 +17292,8 @@ function readManifest(path = MANIFEST_PATH) {
|
|
|
17222
17292
|
return { version: 1, certifications: [] };
|
|
17223
17293
|
}
|
|
17224
17294
|
function saveManifest(m, path = MANIFEST_PATH) {
|
|
17225
|
-
mkdirSync15(
|
|
17226
|
-
|
|
17295
|
+
mkdirSync15(join29(homedir13(), ".mma"), { recursive: true });
|
|
17296
|
+
writeFileSync14(path, JSON.stringify(m, null, 2), "utf-8");
|
|
17227
17297
|
}
|
|
17228
17298
|
function upsertCertification(entry, path = MANIFEST_PATH) {
|
|
17229
17299
|
const m = readManifest(path);
|
|
@@ -17257,7 +17327,7 @@ function getCertMark(model, providerUrl, currentVersion, path = MANIFEST_PATH) {
|
|
|
17257
17327
|
}
|
|
17258
17328
|
var MANIFEST_PATH;
|
|
17259
17329
|
var init_manifest = __esm(() => {
|
|
17260
|
-
MANIFEST_PATH =
|
|
17330
|
+
MANIFEST_PATH = join29(homedir13(), ".mma", "certifications.json");
|
|
17261
17331
|
});
|
|
17262
17332
|
|
|
17263
17333
|
// node_modules/yaml/dist/nodes/identity.js
|
|
@@ -24381,7 +24451,7 @@ var init_scenarios = __esm(() => {
|
|
|
24381
24451
|
|
|
24382
24452
|
// src/modules/certification/loader.ts
|
|
24383
24453
|
import { existsSync as existsSync37, readdirSync as readdirSync10, readFileSync as readFileSync24 } from "fs";
|
|
24384
|
-
import { join as
|
|
24454
|
+
import { join as join30 } from "path";
|
|
24385
24455
|
function validateScenario(s) {
|
|
24386
24456
|
const errors2 = [];
|
|
24387
24457
|
const isSkip = s.mode === "skip";
|
|
@@ -24435,7 +24505,7 @@ function loadScenarios(userDir) {
|
|
|
24435
24505
|
if (!file.endsWith(".yaml") && !file.endsWith(".yml"))
|
|
24436
24506
|
continue;
|
|
24437
24507
|
try {
|
|
24438
|
-
const raw = readFileSync24(
|
|
24508
|
+
const raw = readFileSync24(join30(userDir, file), "utf-8");
|
|
24439
24509
|
const data = $parse(raw);
|
|
24440
24510
|
const parsed = normalizeScenario(data, file);
|
|
24441
24511
|
const errs = validateScenario(parsed);
|
|
@@ -24489,7 +24559,7 @@ var init_loader3 = __esm(() => {
|
|
|
24489
24559
|
|
|
24490
24560
|
// src/modules/certification/fact-checker.ts
|
|
24491
24561
|
import { existsSync as existsSync38, readFileSync as readFileSync25, statSync as statSync7 } from "fs";
|
|
24492
|
-
import { join as
|
|
24562
|
+
import { join as join31 } from "path";
|
|
24493
24563
|
function checkSandbox(sandboxDir, checks, exitCode, output) {
|
|
24494
24564
|
const failures = [];
|
|
24495
24565
|
for (const check of checks) {
|
|
@@ -24506,13 +24576,13 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
24506
24576
|
case "outputContains":
|
|
24507
24577
|
return output.includes(check.text);
|
|
24508
24578
|
case "fileExists":
|
|
24509
|
-
return isFile(
|
|
24579
|
+
return isFile(join31(sandboxDir, check.path));
|
|
24510
24580
|
case "fileNotExists":
|
|
24511
|
-
return !existsSync38(
|
|
24581
|
+
return !existsSync38(join31(sandboxDir, check.path));
|
|
24512
24582
|
case "dirExists":
|
|
24513
|
-
return isDir(
|
|
24583
|
+
return isDir(join31(sandboxDir, check.path));
|
|
24514
24584
|
case "fileContent": {
|
|
24515
|
-
const abs =
|
|
24585
|
+
const abs = join31(sandboxDir, check.path);
|
|
24516
24586
|
if (!isFile(abs))
|
|
24517
24587
|
return false;
|
|
24518
24588
|
const content = readFileSync25(abs, "utf-8");
|
|
@@ -24523,7 +24593,7 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
24523
24593
|
return false;
|
|
24524
24594
|
}
|
|
24525
24595
|
case "fileRegex": {
|
|
24526
|
-
const abs =
|
|
24596
|
+
const abs = join31(sandboxDir, check.path);
|
|
24527
24597
|
if (!isFile(abs))
|
|
24528
24598
|
return false;
|
|
24529
24599
|
return new RegExp(check.pattern).test(readFileSync25(abs, "utf-8"));
|
|
@@ -24574,7 +24644,7 @@ var init_fact_checker = () => {};
|
|
|
24574
24644
|
import { spawn as spawn6 } from "child_process";
|
|
24575
24645
|
import { existsSync as existsSync39, mkdirSync as mkdirSync16, rmSync as rmSync3, cpSync as cpSync2 } from "fs";
|
|
24576
24646
|
import { platform as platform4 } from "os";
|
|
24577
|
-
import { join as
|
|
24647
|
+
import { join as join32, resolve as resolve19, dirname as dirname9 } from "path";
|
|
24578
24648
|
async function runScenario(scenario, opts) {
|
|
24579
24649
|
if (scenario.mode === "skip") {
|
|
24580
24650
|
return {
|
|
@@ -24593,7 +24663,7 @@ async function runScenario(scenario, opts) {
|
|
|
24593
24663
|
let passed = 0;
|
|
24594
24664
|
let firstError;
|
|
24595
24665
|
for (let i = 1;i <= reps; i++) {
|
|
24596
|
-
const sandbox =
|
|
24666
|
+
const sandbox = join32(opts.sandboxBase, `run-${scenario.id}-${i}`);
|
|
24597
24667
|
let failures = [];
|
|
24598
24668
|
let exitCode = -1;
|
|
24599
24669
|
let output = "";
|
|
@@ -24654,20 +24724,20 @@ function prepareSandbox(sandbox, scenario, mmaRoot) {
|
|
|
24654
24724
|
rmSync3(sandbox, { recursive: true, force: true });
|
|
24655
24725
|
mkdirSync16(sandbox, { recursive: true });
|
|
24656
24726
|
for (const f of scenario.fixtures ?? []) {
|
|
24657
|
-
const src =
|
|
24727
|
+
const src = join32(mmaRoot, f.source);
|
|
24658
24728
|
if (!existsSync39(src)) {
|
|
24659
24729
|
throw new Error(`fixture missing: ${f.source}`);
|
|
24660
24730
|
}
|
|
24661
|
-
const dest =
|
|
24731
|
+
const dest = join32(sandbox, f.dest);
|
|
24662
24732
|
mkdirSync16(dirname9(dest), { recursive: true });
|
|
24663
24733
|
cpSync2(src, dest);
|
|
24664
24734
|
}
|
|
24665
24735
|
}
|
|
24666
24736
|
function resolveMmaEntry(mmaRoot) {
|
|
24667
|
-
const dev =
|
|
24737
|
+
const dev = join32(mmaRoot, "src", "cli", "main.ts");
|
|
24668
24738
|
if (existsSync39(dev))
|
|
24669
24739
|
return dev;
|
|
24670
|
-
return
|
|
24740
|
+
return join32(mmaRoot, "dist", "main.js");
|
|
24671
24741
|
}
|
|
24672
24742
|
function findMmaRoot(fromDir) {
|
|
24673
24743
|
const candidates = [
|
|
@@ -24675,7 +24745,7 @@ function findMmaRoot(fromDir) {
|
|
|
24675
24745
|
resolve19(fromDir, "..")
|
|
24676
24746
|
];
|
|
24677
24747
|
for (const c of candidates) {
|
|
24678
|
-
if (existsSync39(
|
|
24748
|
+
if (existsSync39(join32(c, "package.json")))
|
|
24679
24749
|
return c;
|
|
24680
24750
|
}
|
|
24681
24751
|
return process.cwd();
|
|
@@ -24743,12 +24813,12 @@ __export(exports_cli, {
|
|
|
24743
24813
|
});
|
|
24744
24814
|
import { rmSync as rmSync4 } from "fs";
|
|
24745
24815
|
import { homedir as homedir14 } from "os";
|
|
24746
|
-
import { join as
|
|
24816
|
+
import { join as join33, dirname as dirname10 } from "path";
|
|
24747
24817
|
import { fileURLToPath } from "url";
|
|
24748
24818
|
import { existsSync as existsSync40, readFileSync as readFileSync26 } from "fs";
|
|
24749
24819
|
function readVersion() {
|
|
24750
24820
|
const candidates = [
|
|
24751
|
-
|
|
24821
|
+
join33(MMA_ROOT, "package.json")
|
|
24752
24822
|
];
|
|
24753
24823
|
for (const p of candidates) {
|
|
24754
24824
|
if (existsSync40(p)) {
|
|
@@ -24765,36 +24835,36 @@ function parseTags(s) {
|
|
|
24765
24835
|
async function certify(opts) {
|
|
24766
24836
|
const providerUrl = opts.providerUrl || opts.config.provider.baseUrl;
|
|
24767
24837
|
if (opts.tags.includes("security") && !opts.config.security?.enabled) {
|
|
24768
|
-
console.error(
|
|
24838
|
+
console.error(pc2.red(t("cli.cert_security_required")));
|
|
24769
24839
|
process.exitCode = 1;
|
|
24770
24840
|
return;
|
|
24771
24841
|
}
|
|
24772
24842
|
const { scenarios, errors: errors2 } = loadScenarios(USER_SCENARIO_DIR);
|
|
24773
24843
|
for (const e of errors2)
|
|
24774
|
-
console.error(
|
|
24844
|
+
console.error(pc2.yellow(` ${e}`));
|
|
24775
24845
|
const selected = filterByTags(scenarios, opts.tags);
|
|
24776
24846
|
if (selected.length === 0) {
|
|
24777
|
-
console.error(
|
|
24847
|
+
console.error(pc2.red(t("cli.cert_no_scenarios", { tags: opts.tags.join(",") })));
|
|
24778
24848
|
process.exitCode = 1;
|
|
24779
24849
|
return;
|
|
24780
24850
|
}
|
|
24781
24851
|
const manifest = readManifest();
|
|
24782
24852
|
const existing = manifest.certifications.find((e) => e.model === opts.name && e.providerUrl === providerUrl);
|
|
24783
24853
|
if (existing && !opts.force) {
|
|
24784
|
-
console.error(
|
|
24785
|
-
console.error(
|
|
24854
|
+
console.error(pc2.yellow(t("cli.cert_exists", { model: opts.name })));
|
|
24855
|
+
console.error(pc2.yellow(t("cli.cert_exists_hint")));
|
|
24786
24856
|
process.exitCode = 1;
|
|
24787
24857
|
return;
|
|
24788
24858
|
}
|
|
24789
24859
|
console.log(t("cli.cert_started", { model: opts.name, provider: providerUrl }));
|
|
24790
|
-
const sandboxBase =
|
|
24860
|
+
const sandboxBase = join33(process.cwd(), ".mma", "certification");
|
|
24791
24861
|
const results = [];
|
|
24792
24862
|
const total = selected.length;
|
|
24793
24863
|
let idx = 0;
|
|
24794
24864
|
for (const scenario of selected) {
|
|
24795
24865
|
idx++;
|
|
24796
24866
|
if (scenario.mode === "skip") {
|
|
24797
|
-
console.log(
|
|
24867
|
+
console.log(pc2.dim(`[${idx}/${total}] ${scenario.id} ... skipped`));
|
|
24798
24868
|
results.push({ id: scenario.id, title: scenario.title, status: "skipped", passed: 0, of: 0 });
|
|
24799
24869
|
continue;
|
|
24800
24870
|
}
|
|
@@ -24808,10 +24878,10 @@ async function certify(opts) {
|
|
|
24808
24878
|
defaultReps: opts.reps,
|
|
24809
24879
|
defaultThreshold: 2,
|
|
24810
24880
|
onRep: (id, rep, reps, passed, failures) => {
|
|
24811
|
-
const word = passed ?
|
|
24881
|
+
const word = passed ? pc2.green(t("cli.cert_rep_pass")) : pc2.red(t("cli.cert_rep_fail"));
|
|
24812
24882
|
console.log(`[${idx}/${total}] ${id} (${rep}/${reps})... ${word}`);
|
|
24813
24883
|
if (!passed)
|
|
24814
|
-
console.log(` ${
|
|
24884
|
+
console.log(` ${pc2.dim(failures.join("; "))}`);
|
|
24815
24885
|
}
|
|
24816
24886
|
});
|
|
24817
24887
|
results.push(res);
|
|
@@ -24859,7 +24929,7 @@ async function certList() {
|
|
|
24859
24929
|
return;
|
|
24860
24930
|
}
|
|
24861
24931
|
for (const e of m.certifications) {
|
|
24862
|
-
console.log(` ${
|
|
24932
|
+
console.log(` ${pc2.green("✔")} ${e.model} ${pc2.dim(e.providerUrl)} ${e.mmaVersion} ${e.certifiedAt.slice(0, 10)} ${e.suite.passed}/${e.suite.total} pass`);
|
|
24863
24933
|
}
|
|
24864
24934
|
}
|
|
24865
24935
|
async function uncertify(name, config) {
|
|
@@ -24879,11 +24949,11 @@ function summarize(results) {
|
|
|
24879
24949
|
}
|
|
24880
24950
|
function printResults(results) {
|
|
24881
24951
|
for (const r of results) {
|
|
24882
|
-
const icon = r.status === "pass" ?
|
|
24883
|
-
const detail = r.status === "skipped" ?
|
|
24952
|
+
const icon = r.status === "pass" ? pc2.green("✔") : r.status === "fail" ? pc2.red("✘") : r.status === "skipped" ? pc2.dim("–") : pc2.yellow("!");
|
|
24953
|
+
const detail = r.status === "skipped" ? pc2.dim(r.title) : `${r.passed}/${r.of}`;
|
|
24884
24954
|
console.log(` ${icon} ${r.id} ${detail}`);
|
|
24885
24955
|
if (r.error)
|
|
24886
|
-
console.log(` ${
|
|
24956
|
+
console.log(` ${pc2.dim(r.error)}`);
|
|
24887
24957
|
}
|
|
24888
24958
|
}
|
|
24889
24959
|
var HERE, MMA_ROOT, USER_SCENARIO_DIR;
|
|
@@ -24895,7 +24965,7 @@ var init_cli = __esm(() => {
|
|
|
24895
24965
|
init_manifest();
|
|
24896
24966
|
HERE = dirname10(fileURLToPath(import.meta.url));
|
|
24897
24967
|
MMA_ROOT = findMmaRoot(HERE);
|
|
24898
|
-
USER_SCENARIO_DIR =
|
|
24968
|
+
USER_SCENARIO_DIR = join33(homedir14(), ".mma", "certification", "scenarios");
|
|
24899
24969
|
});
|
|
24900
24970
|
|
|
24901
24971
|
// src/cli/repl-commands.ts
|
|
@@ -24904,15 +24974,15 @@ __export(exports_repl_commands, {
|
|
|
24904
24974
|
registerAllCommands: () => registerAllCommands,
|
|
24905
24975
|
COMMAND_GROUPS: () => COMMAND_GROUPS
|
|
24906
24976
|
});
|
|
24907
|
-
import { join as
|
|
24977
|
+
import { join as join35, dirname as dirname12 } from "path";
|
|
24908
24978
|
import { homedir as homedir16 } from "os";
|
|
24909
24979
|
import { existsSync as existsSync42, readFileSync as readFileSync28 } from "fs";
|
|
24910
24980
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
24911
24981
|
function readVersion3() {
|
|
24912
24982
|
const here = dirname12(fileURLToPath3(import.meta.url));
|
|
24913
24983
|
const candidates = [
|
|
24914
|
-
|
|
24915
|
-
|
|
24984
|
+
join35(here, "..", "..", "package.json"),
|
|
24985
|
+
join35(here, "..", "package.json")
|
|
24916
24986
|
];
|
|
24917
24987
|
for (const p of candidates) {
|
|
24918
24988
|
if (existsSync42(p)) {
|
|
@@ -24986,7 +25056,7 @@ function registerMmaCommands(ctx) {
|
|
|
24986
25056
|
if (source.toLowerCase() === "clipboard") {
|
|
24987
25057
|
const clipBuf = await readClipboardImage2();
|
|
24988
25058
|
if (!clipBuf) {
|
|
24989
|
-
console.log(
|
|
25059
|
+
console.log(pc2.yellow(t("image.clipboard_empty")));
|
|
24990
25060
|
return;
|
|
24991
25061
|
}
|
|
24992
25062
|
const { bufferToDataUrl: bufferToDataUrl2 } = await Promise.resolve().then(() => (init_image_utils(), exports_image_utils));
|
|
@@ -25000,7 +25070,7 @@ function registerMmaCommands(ctx) {
|
|
|
25000
25070
|
} else {
|
|
25001
25071
|
const absPath = resolve20(process.cwd(), source);
|
|
25002
25072
|
if (!existsSync43(absPath)) {
|
|
25003
|
-
console.log(
|
|
25073
|
+
console.log(pc2.red(t("image.not_found", { path: source })));
|
|
25004
25074
|
return;
|
|
25005
25075
|
}
|
|
25006
25076
|
const result = await loadFileAsDataUrl2(absPath);
|
|
@@ -25009,7 +25079,7 @@ function registerMmaCommands(ctx) {
|
|
|
25009
25079
|
}
|
|
25010
25080
|
const contextManager = ctx.agent.contextManager;
|
|
25011
25081
|
if (!contextManager) {
|
|
25012
|
-
console.log(
|
|
25082
|
+
console.log(pc2.red(t("image.no_context")));
|
|
25013
25083
|
return;
|
|
25014
25084
|
}
|
|
25015
25085
|
contextManager.addPendingImage({
|
|
@@ -25017,9 +25087,9 @@ function registerMmaCommands(ctx) {
|
|
|
25017
25087
|
image_url: { url: dataUrl }
|
|
25018
25088
|
});
|
|
25019
25089
|
const sizeKb = Math.round(dataUrl.length * 3 / 4 / 1024);
|
|
25020
|
-
console.log(
|
|
25090
|
+
console.log(pc2.green(t("image.attached", { source: label, size: `${sizeKb} KB` })));
|
|
25021
25091
|
} catch (err) {
|
|
25022
|
-
console.log(
|
|
25092
|
+
console.log(pc2.red(t("image.error", { message: err.message })));
|
|
25023
25093
|
}
|
|
25024
25094
|
}
|
|
25025
25095
|
});
|
|
@@ -25037,7 +25107,7 @@ function registerMmaCommands(ctx) {
|
|
|
25037
25107
|
console.log(`${t("repl.context")} ${ctxW} (sys:${sys} res:${res} hist:${ctxW - sys - res})`);
|
|
25038
25108
|
console.log(`${t("repl.max_iters")} ${cfg.maxToolIterations}`);
|
|
25039
25109
|
console.log(`${t("repl.stuck_thresh")} ${cfg.stuckThreshold}`);
|
|
25040
|
-
console.log(`${t("repl.reasoning_label")} ${cfg.showReasoning ?
|
|
25110
|
+
console.log(`${t("repl.reasoning_label")} ${cfg.showReasoning ? pc2.green(t("repl.show")) : pc2.dim(t("repl.hide"))}`);
|
|
25041
25111
|
console.log(`${t("repl.log_level")} ${cfg.logLevel}`);
|
|
25042
25112
|
console.log(`${t("repl.locale")} ${cfg.locale}`);
|
|
25043
25113
|
const meta = ctx.sessionManager?.getActiveMeta();
|
|
@@ -25052,7 +25122,7 @@ function registerMmaCommands(ctx) {
|
|
|
25052
25122
|
usage: t("repl.reasoning_usage"),
|
|
25053
25123
|
action: () => {
|
|
25054
25124
|
ctx.config.showReasoning = !ctx.config.showReasoning;
|
|
25055
|
-
const status = ctx.config.showReasoning ?
|
|
25125
|
+
const status = ctx.config.showReasoning ? pc2.green(t("repl.show")) : pc2.dim(t("repl.hide"));
|
|
25056
25126
|
console.log(t("repl.reasoning_status", { status }));
|
|
25057
25127
|
}
|
|
25058
25128
|
});
|
|
@@ -25075,10 +25145,10 @@ function registerMmaCommands(ctx) {
|
|
|
25075
25145
|
aliases: ["setup"],
|
|
25076
25146
|
usage: t("repl.wizard_usage"),
|
|
25077
25147
|
action: async () => {
|
|
25078
|
-
console.log(
|
|
25148
|
+
console.log(pc2.yellow(t("repl.wizard_running")));
|
|
25079
25149
|
await ctx.withExclusiveInput(async () => {
|
|
25080
25150
|
const answers = await runSetup(ctx.rl);
|
|
25081
|
-
const configPath =
|
|
25151
|
+
const configPath = join35(homedir16(), ".mma", "config.json");
|
|
25082
25152
|
ctx.config.provider.type = answers.provider;
|
|
25083
25153
|
ctx.config.provider.baseUrl = answers.apiBase;
|
|
25084
25154
|
ctx.config.provider.apiKey = answers.apiKey;
|
|
@@ -25088,7 +25158,7 @@ function registerMmaCommands(ctx) {
|
|
|
25088
25158
|
ctx.config.locale = answers.locale;
|
|
25089
25159
|
saveConfig(ctx.config, configPath);
|
|
25090
25160
|
await ctx.agent.reconfigure(ctx.config);
|
|
25091
|
-
console.log(
|
|
25161
|
+
console.log(pc2.green(t("cli.config_saved")));
|
|
25092
25162
|
});
|
|
25093
25163
|
}
|
|
25094
25164
|
});
|
|
@@ -25098,18 +25168,18 @@ function registerMmaCommands(ctx) {
|
|
|
25098
25168
|
usage: t("repl.sysprompt_desc"),
|
|
25099
25169
|
action: () => {
|
|
25100
25170
|
const info = ctx.agent.getSystemPromptInfo();
|
|
25101
|
-
console.log(
|
|
25102
|
-
console.log(
|
|
25171
|
+
console.log(pc2.bold(`System prompt (${info.tokenCount} tokens):`));
|
|
25172
|
+
console.log(pc2.dim("─".repeat(60)));
|
|
25103
25173
|
for (const line of info.text.split(`
|
|
25104
25174
|
`)) {
|
|
25105
25175
|
console.log(line);
|
|
25106
25176
|
}
|
|
25107
|
-
console.log(
|
|
25177
|
+
console.log(pc2.dim("─".repeat(60)));
|
|
25108
25178
|
if (info.excluded.length > 0) {
|
|
25109
|
-
console.log(
|
|
25179
|
+
console.log(pc2.yellow(`
|
|
25110
25180
|
Excluded blocks: ${info.excluded.length}`));
|
|
25111
25181
|
for (const e of info.excluded) {
|
|
25112
|
-
console.log(
|
|
25182
|
+
console.log(pc2.dim(` - ${e.slice(0, 80)}${e.length > 80 ? "..." : ""}`));
|
|
25113
25183
|
}
|
|
25114
25184
|
}
|
|
25115
25185
|
}
|
|
@@ -25132,10 +25202,10 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
25132
25202
|
return;
|
|
25133
25203
|
}
|
|
25134
25204
|
ctx.config.provider.type = name;
|
|
25135
|
-
const configPath =
|
|
25205
|
+
const configPath = join35(homedir16(), ".mma", "config.json");
|
|
25136
25206
|
saveConfig(ctx.config, configPath);
|
|
25137
25207
|
await ctx.agent.reconfigure(ctx.config);
|
|
25138
|
-
console.log(
|
|
25208
|
+
console.log(pc2.green(t("repl.provider_set", { name })));
|
|
25139
25209
|
return;
|
|
25140
25210
|
}
|
|
25141
25211
|
console.log(t("repl.provider_usage"));
|
|
@@ -25166,9 +25236,9 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
25166
25236
|
console.log(t("cli.available_models"));
|
|
25167
25237
|
const { getCertMark: getCertMark2 } = await Promise.resolve().then(() => (init_manifest(), exports_manifest));
|
|
25168
25238
|
for (const m of models) {
|
|
25169
|
-
const marker = m === ctx.config.model ?
|
|
25239
|
+
const marker = m === ctx.config.model ? pc2.green("* ") : " ";
|
|
25170
25240
|
const mark = getCertMark2(m, ctx.config.provider.baseUrl, version2);
|
|
25171
|
-
const cert = mark === "certified" ?
|
|
25241
|
+
const cert = mark === "certified" ? pc2.green("✔") : mark === "stale" ? pc2.yellow("○") : pc2.dim("·");
|
|
25172
25242
|
console.log(` ${marker}${cert} ${m}`);
|
|
25173
25243
|
}
|
|
25174
25244
|
} else {
|
|
@@ -25188,10 +25258,10 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
25188
25258
|
return;
|
|
25189
25259
|
}
|
|
25190
25260
|
ctx.config.model = name;
|
|
25191
|
-
const configPath =
|
|
25261
|
+
const configPath = join35(homedir16(), ".mma", "config.json");
|
|
25192
25262
|
saveConfig(ctx.config, configPath);
|
|
25193
25263
|
await ctx.agent.reconfigure(ctx.config);
|
|
25194
|
-
console.log(
|
|
25264
|
+
console.log(pc2.green(t("repl.model_set", { name })));
|
|
25195
25265
|
return;
|
|
25196
25266
|
}
|
|
25197
25267
|
console.log(t("repl.model_usage"));
|
|
@@ -25213,10 +25283,10 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
25213
25283
|
return;
|
|
25214
25284
|
}
|
|
25215
25285
|
ctx.config.contextWindow = size;
|
|
25216
|
-
const configPath =
|
|
25286
|
+
const configPath = join35(homedir16(), ".mma", "config.json");
|
|
25217
25287
|
saveConfig(ctx.config, configPath);
|
|
25218
25288
|
await ctx.agent.reconfigure(ctx.config);
|
|
25219
|
-
console.log(
|
|
25289
|
+
console.log(pc2.green(t("cli.context_set", { size })));
|
|
25220
25290
|
}
|
|
25221
25291
|
});
|
|
25222
25292
|
ctx.registerCommand({
|
|
@@ -25224,7 +25294,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
25224
25294
|
description: t("repl.reload"),
|
|
25225
25295
|
usage: t("repl.reload_usage"),
|
|
25226
25296
|
action: async () => {
|
|
25227
|
-
console.log(
|
|
25297
|
+
console.log(pc2.yellow(t("repl.reloading")));
|
|
25228
25298
|
if (ctx.sessionManager && ctx.config.session.autoSave) {
|
|
25229
25299
|
const active = ctx.sessionManager.getActiveMeta();
|
|
25230
25300
|
if (active) {}
|
|
@@ -25232,10 +25302,10 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
25232
25302
|
ctx.agent.shutdown();
|
|
25233
25303
|
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config2(), exports_config));
|
|
25234
25304
|
const { homedir: homedir17 } = await import("os");
|
|
25235
|
-
const { join:
|
|
25305
|
+
const { join: join36 } = await import("path");
|
|
25236
25306
|
const configDir = ctx.configDir;
|
|
25237
25307
|
const baseDir = ctx.baseDir;
|
|
25238
|
-
const projectConfigPath =
|
|
25308
|
+
const projectConfigPath = join36(baseDir, ".mmrc");
|
|
25239
25309
|
const freshConfig = loadConfig2({ configDir, projectConfigPath });
|
|
25240
25310
|
Object.assign(ctx.config, freshConfig);
|
|
25241
25311
|
const { bootstrap: bootstrap2 } = await Promise.resolve().then(() => (init_bootstrap(), exports_bootstrap));
|
|
@@ -25245,7 +25315,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
25245
25315
|
ctx.skillsModule = result.skillsModule;
|
|
25246
25316
|
ctx.pluginManager = result.pluginManager;
|
|
25247
25317
|
ctx.setupCompleter();
|
|
25248
|
-
console.log(
|
|
25318
|
+
console.log(pc2.green(t("repl.reloaded")));
|
|
25249
25319
|
console.log(`${t("repl.model")} ${ctx.config.model}`);
|
|
25250
25320
|
console.log(`${t("repl.context")} ${ctx.config.contextWindow}`);
|
|
25251
25321
|
console.log(`${t("repl.provider")} ${ctx.config.provider.type} @ ${ctx.config.provider.baseUrl}`);
|
|
@@ -25268,7 +25338,7 @@ function registerSessionCommands(ctx) {
|
|
|
25268
25338
|
return;
|
|
25269
25339
|
}
|
|
25270
25340
|
const rows = sessions.map((s) => [
|
|
25271
|
-
s.id === active ?
|
|
25341
|
+
s.id === active ? pc2.green("●") : "",
|
|
25272
25342
|
s.id.slice(0, 12),
|
|
25273
25343
|
s.name,
|
|
25274
25344
|
s.updatedAt.slice(0, 19).replace("T", " "),
|
|
@@ -25283,7 +25353,7 @@ function registerSessionCommands(ctx) {
|
|
|
25283
25353
|
], rows)) {
|
|
25284
25354
|
console.log(line);
|
|
25285
25355
|
}
|
|
25286
|
-
console.log(
|
|
25356
|
+
console.log(pc2.dim(`
|
|
25287
25357
|
${t("repl.resume_hint")}`));
|
|
25288
25358
|
}
|
|
25289
25359
|
});
|
|
@@ -25297,8 +25367,8 @@ function registerSessionCommands(ctx) {
|
|
|
25297
25367
|
const meta = ctx.sessionManager.create(name);
|
|
25298
25368
|
ctx.agent.clearContext();
|
|
25299
25369
|
console.clear();
|
|
25300
|
-
console.log(`${t("session.created", { name: meta.name })} (${
|
|
25301
|
-
console.log(
|
|
25370
|
+
console.log(`${t("session.created", { name: meta.name })} (${pc2.dim(meta.id.slice(0, 12))})`);
|
|
25371
|
+
console.log(pc2.dim(` ${t("session.chat_cleared")}
|
|
25302
25372
|
`));
|
|
25303
25373
|
}
|
|
25304
25374
|
});
|
|
@@ -25311,13 +25381,13 @@ function registerSessionCommands(ctx) {
|
|
|
25311
25381
|
const query = args.join(" ");
|
|
25312
25382
|
const sessions = ctx.sessionManager.list();
|
|
25313
25383
|
if (!query) {
|
|
25314
|
-
console.log(
|
|
25384
|
+
console.log(pc2.dim(t("session.available")));
|
|
25315
25385
|
const active = ctx.sessionManager.getActive();
|
|
25316
25386
|
for (const s of sessions) {
|
|
25317
|
-
const marker = s.id === active ?
|
|
25318
|
-
console.log(
|
|
25387
|
+
const marker = s.id === active ? pc2.green(" *") : " ";
|
|
25388
|
+
console.log(pc2.dim(` ${marker} ${s.id.slice(0, 12)} ${s.name}`));
|
|
25319
25389
|
}
|
|
25320
|
-
console.log(
|
|
25390
|
+
console.log(pc2.dim(`
|
|
25321
25391
|
${t("repl.resume_usage")}`));
|
|
25322
25392
|
return;
|
|
25323
25393
|
}
|
|
@@ -25330,27 +25400,27 @@ function registerSessionCommands(ctx) {
|
|
|
25330
25400
|
const history = ctx.sessionManager.loadHistory();
|
|
25331
25401
|
ctx.agent.setContext(history);
|
|
25332
25402
|
console.clear();
|
|
25333
|
-
console.log(
|
|
25334
|
-
console.log(
|
|
25403
|
+
console.log(pc2.bold(pc2.green(t("session.resumed", { name: match.name }))) + " " + pc2.dim(`(${match.id.slice(0, 12)})`) + " — " + match.messageCount + " msgs");
|
|
25404
|
+
console.log(pc2.dim("─".repeat(50)));
|
|
25335
25405
|
if (history.length === 0) {
|
|
25336
|
-
console.log(
|
|
25406
|
+
console.log(pc2.dim(t("session.no_history")));
|
|
25337
25407
|
} else {
|
|
25338
|
-
console.log(
|
|
25408
|
+
console.log(pc2.dim(t("session.chat_history")));
|
|
25339
25409
|
console.log();
|
|
25340
25410
|
for (const msg of history) {
|
|
25341
25411
|
if (msg.role === "user") {
|
|
25342
|
-
console.log(
|
|
25412
|
+
console.log(pc2.cyan(t("session.user_label") + ":"));
|
|
25343
25413
|
console.log(getMessageText(msg.content));
|
|
25344
25414
|
console.log();
|
|
25345
25415
|
} else if (msg.role === "assistant") {
|
|
25346
|
-
console.log(
|
|
25416
|
+
console.log(pc2.green(t("session.assistant_label") + ":"));
|
|
25347
25417
|
console.log(getMessageText(msg.content));
|
|
25348
25418
|
console.log();
|
|
25349
25419
|
}
|
|
25350
25420
|
}
|
|
25351
25421
|
}
|
|
25352
|
-
console.log(
|
|
25353
|
-
console.log(
|
|
25422
|
+
console.log(pc2.dim("─".repeat(50)));
|
|
25423
|
+
console.log(pc2.dim(` ${t("session.chat_loaded")}`));
|
|
25354
25424
|
}
|
|
25355
25425
|
});
|
|
25356
25426
|
ctx.registerCommand({
|
|
@@ -25410,12 +25480,12 @@ function registerSkillCommands(ctx) {
|
|
|
25410
25480
|
console.log(t("repl.no_skills"));
|
|
25411
25481
|
return;
|
|
25412
25482
|
}
|
|
25413
|
-
console.log(
|
|
25483
|
+
console.log(pc2.bold(t("repl.available_skills")));
|
|
25414
25484
|
for (const skill of available) {
|
|
25415
25485
|
const tokens = Math.ceil(skill.content.length / 4);
|
|
25416
25486
|
const loaded = ctx.skillsModule.getLoaded().some((s) => s.name === skill.name);
|
|
25417
|
-
const marker = loaded ?
|
|
25418
|
-
console.log(` ${
|
|
25487
|
+
const marker = loaded ? pc2.green(" [loaded]") : "";
|
|
25488
|
+
console.log(` ${pc2.cyan(skill.name)}${marker} ${pc2.dim(`(${tokens} tokens)`)} ${skill.description.slice(0, 60)}`);
|
|
25419
25489
|
}
|
|
25420
25490
|
return;
|
|
25421
25491
|
}
|
|
@@ -25426,12 +25496,12 @@ function registerSkillCommands(ctx) {
|
|
|
25426
25496
|
console.log(t("repl.no_loaded"));
|
|
25427
25497
|
return;
|
|
25428
25498
|
}
|
|
25429
|
-
console.log(
|
|
25499
|
+
console.log(pc2.bold(t("repl.loaded_skills")));
|
|
25430
25500
|
for (const skill of loaded) {
|
|
25431
25501
|
const tokens = Math.ceil(skill.content.length / 4);
|
|
25432
|
-
console.log(` ${
|
|
25502
|
+
console.log(` ${pc2.cyan(skill.name)} ${pc2.dim(`(${tokens} tokens)`)} ${skill.description.slice(0, 60)}`);
|
|
25433
25503
|
}
|
|
25434
|
-
console.log(
|
|
25504
|
+
console.log(pc2.dim(`
|
|
25435
25505
|
${t("repl.budget", { used: budget.used, total: budget.total, remaining: budget.remaining })}`));
|
|
25436
25506
|
return;
|
|
25437
25507
|
}
|
|
@@ -25442,9 +25512,9 @@ function registerSkillCommands(ctx) {
|
|
|
25442
25512
|
}
|
|
25443
25513
|
const result = ctx.skillsModule.loadByName(arg);
|
|
25444
25514
|
if (result.success) {
|
|
25445
|
-
console.log(
|
|
25515
|
+
console.log(pc2.green(result.message));
|
|
25446
25516
|
} else {
|
|
25447
|
-
console.log(
|
|
25517
|
+
console.log(pc2.red(result.message));
|
|
25448
25518
|
}
|
|
25449
25519
|
return;
|
|
25450
25520
|
}
|
|
@@ -25454,9 +25524,9 @@ function registerSkillCommands(ctx) {
|
|
|
25454
25524
|
return;
|
|
25455
25525
|
}
|
|
25456
25526
|
if (ctx.skillsModule.unload(arg)) {
|
|
25457
|
-
console.log(
|
|
25527
|
+
console.log(pc2.green(t("repl.skill_unloaded", { name: arg })));
|
|
25458
25528
|
} else {
|
|
25459
|
-
console.log(
|
|
25529
|
+
console.log(pc2.red(t("repl.skill_not_loaded", { name: arg })));
|
|
25460
25530
|
}
|
|
25461
25531
|
return;
|
|
25462
25532
|
}
|
|
@@ -25470,14 +25540,14 @@ function registerSkillCommands(ctx) {
|
|
|
25470
25540
|
console.log(t("repl.no_skill_match", { query: arg }));
|
|
25471
25541
|
return;
|
|
25472
25542
|
}
|
|
25473
|
-
console.log(
|
|
25543
|
+
console.log(pc2.bold(t("repl.skills_matching", { query: arg })));
|
|
25474
25544
|
for (const skill of results) {
|
|
25475
25545
|
const tokens = Math.ceil(skill.content.length / 4);
|
|
25476
|
-
console.log(` ${
|
|
25546
|
+
console.log(` ${pc2.cyan(skill.name)} ${pc2.dim(`(${tokens} tokens)`)} ${skill.description.slice(0, 60)}`);
|
|
25477
25547
|
}
|
|
25478
25548
|
return;
|
|
25479
25549
|
}
|
|
25480
|
-
console.log(
|
|
25550
|
+
console.log(pc2.red(t("repl.skill_unknown_sub", { subcmd })));
|
|
25481
25551
|
console.log(t("repl.skill_usage"));
|
|
25482
25552
|
}
|
|
25483
25553
|
});
|
|
@@ -25535,14 +25605,14 @@ init_bootstrap();
|
|
|
25535
25605
|
init_config2();
|
|
25536
25606
|
init_setup();
|
|
25537
25607
|
init_i18n();
|
|
25538
|
-
import { join as
|
|
25608
|
+
import { join as join34, dirname as dirname11 } from "path";
|
|
25539
25609
|
import { homedir as homedir15 } from "os";
|
|
25540
25610
|
import { existsSync as existsSync41, readFileSync as readFileSync27 } from "fs";
|
|
25541
25611
|
|
|
25542
25612
|
// src/cli/security-commands.ts
|
|
25543
25613
|
init_bootstrap();
|
|
25544
25614
|
init_config2();
|
|
25545
|
-
import { join as
|
|
25615
|
+
import { join as join28 } from "path";
|
|
25546
25616
|
import { homedir as homedir12 } from "os";
|
|
25547
25617
|
|
|
25548
25618
|
// src/modules/security/security-policies.ts
|
|
@@ -26072,7 +26142,7 @@ function createSecurityCommand(program2) {
|
|
|
26072
26142
|
}
|
|
26073
26143
|
});
|
|
26074
26144
|
securityCmd.command("set-policy").argument("<preset>", t("cli.security.preset")).description(t("cli.security.set_policy")).action(async (preset) => {
|
|
26075
|
-
const configPath =
|
|
26145
|
+
const configPath = join28(homedir12(), ".mma", "config.json");
|
|
26076
26146
|
const { config: appConfig } = await bootstrap();
|
|
26077
26147
|
const validPresets = ["strict", "balanced", "permissive"];
|
|
26078
26148
|
if (!validPresets.includes(preset)) {
|
|
@@ -26087,7 +26157,7 @@ function createSecurityCommand(program2) {
|
|
|
26087
26157
|
console.log(t("cli.security.policy_description", { description: policy.description }));
|
|
26088
26158
|
});
|
|
26089
26159
|
securityCmd.command("enable-encryption").description(t("cli.security.enable_encryption")).action(async () => {
|
|
26090
|
-
const configPath =
|
|
26160
|
+
const configPath = join28(homedir12(), ".mma", "config.json");
|
|
26091
26161
|
const { config: appConfig } = await bootstrap();
|
|
26092
26162
|
appConfig.security = appConfig.security || {};
|
|
26093
26163
|
appConfig.security.sessionEncryption = {
|
|
@@ -26099,7 +26169,7 @@ function createSecurityCommand(program2) {
|
|
|
26099
26169
|
console.log(t("cli.security.encryption_enabled"));
|
|
26100
26170
|
});
|
|
26101
26171
|
securityCmd.command("disable-encryption").description(t("cli.security.disable_encryption")).action(async () => {
|
|
26102
|
-
const configPath =
|
|
26172
|
+
const configPath = join28(homedir12(), ".mma", "config.json");
|
|
26103
26173
|
const { config: appConfig } = await bootstrap();
|
|
26104
26174
|
appConfig.security = appConfig.security || {};
|
|
26105
26175
|
appConfig.security.sessionEncryption = {
|
|
@@ -26111,7 +26181,7 @@ function createSecurityCommand(program2) {
|
|
|
26111
26181
|
console.log(t("cli.security.encryption_disabled"));
|
|
26112
26182
|
});
|
|
26113
26183
|
securityCmd.command("enable-audit").description(t("cli.security.enable_audit")).action(async () => {
|
|
26114
|
-
const configPath =
|
|
26184
|
+
const configPath = join28(homedir12(), ".mma", "config.json");
|
|
26115
26185
|
const { config: appConfig } = await bootstrap();
|
|
26116
26186
|
appConfig.security = appConfig.security || {};
|
|
26117
26187
|
appConfig.security.auditNotifier = {
|
|
@@ -26125,7 +26195,7 @@ function createSecurityCommand(program2) {
|
|
|
26125
26195
|
console.log(t("cli.security.audit_enabled"));
|
|
26126
26196
|
});
|
|
26127
26197
|
securityCmd.command("disable-audit").description(t("cli.security.disable_audit")).action(async () => {
|
|
26128
|
-
const configPath =
|
|
26198
|
+
const configPath = join28(homedir12(), ".mma", "config.json");
|
|
26129
26199
|
const { config: appConfig } = await bootstrap();
|
|
26130
26200
|
appConfig.security = appConfig.security || {};
|
|
26131
26201
|
appConfig.security.auditNotifier = {
|
|
@@ -26161,8 +26231,8 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
26161
26231
|
function readVersion2() {
|
|
26162
26232
|
const here = dirname11(fileURLToPath2(import.meta.url));
|
|
26163
26233
|
const candidates = [
|
|
26164
|
-
|
|
26165
|
-
|
|
26234
|
+
join34(here, "..", "..", "package.json"),
|
|
26235
|
+
join34(here, "..", "package.json")
|
|
26166
26236
|
];
|
|
26167
26237
|
for (const p of candidates) {
|
|
26168
26238
|
if (existsSync41(p)) {
|
|
@@ -26178,7 +26248,7 @@ function createProgram() {
|
|
|
26178
26248
|
const program2 = new Command().name("mma").description(t("cli.description")).version(version).option("--no-agents-md", t("cli.no_agents_md")).option("-d, --dir <path>", t("cli.dir")).option("-e, --exit-on-complete", t("cli.exit_on_complete")).option("-j, --json", t("cli.json"));
|
|
26179
26249
|
program2.command("init").description(t("cli.init")).action(async () => {
|
|
26180
26250
|
const answers = await runSetup();
|
|
26181
|
-
const configPath =
|
|
26251
|
+
const configPath = join34(homedir15(), ".mma", "config.json");
|
|
26182
26252
|
const { config } = await bootstrap();
|
|
26183
26253
|
config.provider.type = answers.provider;
|
|
26184
26254
|
config.provider.baseUrl = answers.apiBase;
|
|
@@ -26223,7 +26293,7 @@ function createProgram() {
|
|
|
26223
26293
|
});
|
|
26224
26294
|
const configCmd = program2.command("config").description(t("cli.manage_config"));
|
|
26225
26295
|
configCmd.command("set").argument("<key>", t("cli.config_key")).argument("<value>", "Config value").description(t("cli.set_value")).action(async (key, value) => {
|
|
26226
|
-
const configPath =
|
|
26296
|
+
const configPath = join34(homedir15(), ".mma", "config.json");
|
|
26227
26297
|
const { config } = await bootstrap();
|
|
26228
26298
|
const keys = key.split(".");
|
|
26229
26299
|
let obj = config;
|
|
@@ -26286,7 +26356,7 @@ function createProgram() {
|
|
|
26286
26356
|
console.log(t("cli.model_hint"));
|
|
26287
26357
|
});
|
|
26288
26358
|
model.command("use").argument("<name>", "Model name").description(t("cli.set_model")).action(async (name) => {
|
|
26289
|
-
const configPath =
|
|
26359
|
+
const configPath = join34(homedir15(), ".mma", "config.json");
|
|
26290
26360
|
const { config } = await bootstrap();
|
|
26291
26361
|
config.model = name;
|
|
26292
26362
|
saveConfig(config, configPath);
|
|
@@ -26322,7 +26392,7 @@ function createProgram() {
|
|
|
26322
26392
|
await uncertify2(name, config);
|
|
26323
26393
|
});
|
|
26324
26394
|
program2.command("context").description(t("cli.manage_context")).argument("<size>", "Context window size in tokens").action(async (size) => {
|
|
26325
|
-
const configPath =
|
|
26395
|
+
const configPath = join34(homedir15(), ".mma", "config.json");
|
|
26326
26396
|
const { config } = await bootstrap();
|
|
26327
26397
|
const contextWindow = parseInt(size, 10);
|
|
26328
26398
|
if (isNaN(contextWindow) || contextWindow < 1024) {
|
|
@@ -26340,7 +26410,7 @@ function createProgram() {
|
|
|
26340
26410
|
console.log(t("cli.base_url"), config.provider.baseUrl);
|
|
26341
26411
|
});
|
|
26342
26412
|
provider.command("use").argument("<name>", "Provider name").description(t("cli.set_provider")).action(async (name) => {
|
|
26343
|
-
const configPath =
|
|
26413
|
+
const configPath = join34(homedir15(), ".mma", "config.json");
|
|
26344
26414
|
const { config } = await bootstrap();
|
|
26345
26415
|
config.provider.type = name;
|
|
26346
26416
|
saveConfig(config, configPath);
|
|
@@ -26392,8 +26462,8 @@ init_bootstrap();
|
|
|
26392
26462
|
// src/cli/repl.ts
|
|
26393
26463
|
init_colors();
|
|
26394
26464
|
import * as readline2 from "readline";
|
|
26395
|
-
import { existsSync as existsSync43, readFileSync as readFileSync29, writeFileSync as
|
|
26396
|
-
import { join as
|
|
26465
|
+
import { existsSync as existsSync43, readFileSync as readFileSync29, writeFileSync as writeFileSync15 } from "fs";
|
|
26466
|
+
import { join as join36, dirname as dirname13 } from "path";
|
|
26397
26467
|
import { homedir as homedir17 } from "os";
|
|
26398
26468
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
26399
26469
|
|
|
@@ -26511,24 +26581,24 @@ var TAG = /<\/?([A-Z][a-zA-Z0-9]*|[a-z][a-zA-Z0-9-]*)/g;
|
|
|
26511
26581
|
var ATTR = /\b([a-zA-Z-]+=)"([^"]*)"/g;
|
|
26512
26582
|
function highlight(code, lang) {
|
|
26513
26583
|
if (lang === "html" || lang === "xml" || lang === "svg") {
|
|
26514
|
-
code = code.replace(COMMENT, (m) =>
|
|
26515
|
-
code = code.replace(ATTR, (_m, attr, val) =>
|
|
26516
|
-
code = code.replace(TAG, (_m, tag) => "<" +
|
|
26584
|
+
code = code.replace(COMMENT, (m) => pc2.dim(pc2.green(m)));
|
|
26585
|
+
code = code.replace(ATTR, (_m, attr, val) => pc2.yellow(attr) + "=" + pc2.green('"' + val + '"'));
|
|
26586
|
+
code = code.replace(TAG, (_m, tag) => "<" + pc2.cyan(tag));
|
|
26517
26587
|
} else if (lang === "css" || lang === "scss" || lang === "less") {
|
|
26518
|
-
code = code.replace(COMMENT, (m) =>
|
|
26519
|
-
code = code.replace(STRING, (m) =>
|
|
26520
|
-
code = code.replace(NUMBER, (m) =>
|
|
26588
|
+
code = code.replace(COMMENT, (m) => pc2.dim(pc2.green(m)));
|
|
26589
|
+
code = code.replace(STRING, (m) => pc2.green(m));
|
|
26590
|
+
code = code.replace(NUMBER, (m) => pc2.yellow(m));
|
|
26521
26591
|
} else if (lang === "bash" || lang === "sh" || lang === "shell" || lang === "zsh") {
|
|
26522
|
-
code = code.replace(COMMENT, (m) =>
|
|
26523
|
-
code = code.replace(STRING, (m) =>
|
|
26592
|
+
code = code.replace(COMMENT, (m) => pc2.dim(pc2.green(m)));
|
|
26593
|
+
code = code.replace(STRING, (m) => pc2.green(m));
|
|
26524
26594
|
} else if (lang === "json") {
|
|
26525
|
-
code = code.replace(STRING, (m) =>
|
|
26526
|
-
code = code.replace(NUMBER, (m) =>
|
|
26595
|
+
code = code.replace(STRING, (m) => pc2.green(m));
|
|
26596
|
+
code = code.replace(NUMBER, (m) => pc2.yellow(m));
|
|
26527
26597
|
} else {
|
|
26528
|
-
code = code.replace(COMMENT, (m) =>
|
|
26529
|
-
code = code.replace(STRING, (m) =>
|
|
26530
|
-
code = code.replace(KW, (m) =>
|
|
26531
|
-
code = code.replace(NUMBER, (m) =>
|
|
26598
|
+
code = code.replace(COMMENT, (m) => pc2.dim(pc2.green(m)));
|
|
26599
|
+
code = code.replace(STRING, (m) => pc2.green(m));
|
|
26600
|
+
code = code.replace(KW, (m) => pc2.magenta(m));
|
|
26601
|
+
code = code.replace(NUMBER, (m) => pc2.yellow(m));
|
|
26532
26602
|
}
|
|
26533
26603
|
return code;
|
|
26534
26604
|
}
|
|
@@ -26629,13 +26699,13 @@ class FormattingStream {
|
|
|
26629
26699
|
`);
|
|
26630
26700
|
const highlighted = highlight(code, this.codeLang);
|
|
26631
26701
|
const lang = this.codeLang ? ` ${this.codeLang} ` : " ";
|
|
26632
|
-
const top =
|
|
26702
|
+
const top = pc2.dim(`┌─${lang}${"─".repeat(Math.max(0, this.width - 3 - lang.length))}┐`);
|
|
26633
26703
|
this.onWrite(top);
|
|
26634
26704
|
for (const l of highlighted.split(`
|
|
26635
26705
|
`)) {
|
|
26636
|
-
this.onWrite(
|
|
26706
|
+
this.onWrite(pc2.dim("│ ") + l);
|
|
26637
26707
|
}
|
|
26638
|
-
this.onWrite(
|
|
26708
|
+
this.onWrite(pc2.dim(`└${"─".repeat(Math.max(0, this.width - 1))}┘`));
|
|
26639
26709
|
}
|
|
26640
26710
|
this.codeLines = [];
|
|
26641
26711
|
this.codeLang = "";
|
|
@@ -26647,47 +26717,47 @@ class FormattingStream {
|
|
|
26647
26717
|
const level = heading[1].length;
|
|
26648
26718
|
const content = this.formatInline(heading[2]);
|
|
26649
26719
|
if (level === 1)
|
|
26650
|
-
return
|
|
26651
|
-
return
|
|
26720
|
+
return pc2.cyan(pc2.bold(pc2.underline(content)));
|
|
26721
|
+
return pc2.cyan(pc2.bold(content));
|
|
26652
26722
|
}
|
|
26653
26723
|
if (isHorizontalRule(result)) {
|
|
26654
|
-
return
|
|
26724
|
+
return pc2.dim("─".repeat(Math.max(0, Math.min(this.width, 60))));
|
|
26655
26725
|
}
|
|
26656
26726
|
const quote = result.match(/^(>+)\s?(.*)$/);
|
|
26657
26727
|
if (quote) {
|
|
26658
26728
|
const depth = Math.min(quote[1].length, 4);
|
|
26659
|
-
const marker =
|
|
26729
|
+
const marker = pc2.dim("▍".repeat(depth));
|
|
26660
26730
|
return `${marker} ${this.formatInline(quote[2])}`;
|
|
26661
26731
|
}
|
|
26662
26732
|
const checkbox = result.match(/^[-*]\s+\[([ xX])\]\s+(.+)$/);
|
|
26663
26733
|
if (checkbox) {
|
|
26664
26734
|
const checked = checkbox[1].toLowerCase() === "x";
|
|
26665
|
-
const mark = checked ?
|
|
26735
|
+
const mark = checked ? pc2.green("✓") : pc2.dim("☐");
|
|
26666
26736
|
return ` ${mark} ${this.formatInline(checkbox[2])}`;
|
|
26667
26737
|
}
|
|
26668
26738
|
const ordered = result.match(/^(\d+)[.)]\s+(.+)$/);
|
|
26669
26739
|
if (ordered) {
|
|
26670
|
-
return ` ${
|
|
26740
|
+
return ` ${pc2.yellow(ordered[1])}. ${this.formatInline(ordered[2])}`;
|
|
26671
26741
|
}
|
|
26672
26742
|
const bullet = result.match(/^[-*]\s+(.+)$/);
|
|
26673
26743
|
if (bullet) {
|
|
26674
|
-
return ` ${
|
|
26744
|
+
return ` ${pc2.dim("•")} ${this.formatInline(bullet[1])}`;
|
|
26675
26745
|
}
|
|
26676
26746
|
return this.formatInline(result);
|
|
26677
26747
|
}
|
|
26678
26748
|
formatInline(text) {
|
|
26679
26749
|
const codeSpans = [];
|
|
26680
26750
|
let result = text.replace(/`([^`]+)`/g, (_m, c) => {
|
|
26681
|
-
codeSpans.push(
|
|
26751
|
+
codeSpans.push(pc2.yellow(c));
|
|
26682
26752
|
return `\x00${codeSpans.length - 1}\x00`;
|
|
26683
26753
|
});
|
|
26684
|
-
result = result.replace(/\*\*(.+?)\*\*/g, (_, s) =>
|
|
26685
|
-
result = result.replace(/~~(.+?)~~/g, (_, s) =>
|
|
26686
|
-
result = result.replace(/\*([^*]+)\*/g, (_, s) =>
|
|
26687
|
-
result = result.replace(/(^|\s)_([^_\n]+)_(?=\s|$)/g, (_m, pre, s) => pre +
|
|
26754
|
+
result = result.replace(/\*\*(.+?)\*\*/g, (_, s) => pc2.bold(s));
|
|
26755
|
+
result = result.replace(/~~(.+?)~~/g, (_, s) => pc2.strikethrough(s));
|
|
26756
|
+
result = result.replace(/\*([^*]+)\*/g, (_, s) => pc2.italic(s));
|
|
26757
|
+
result = result.replace(/(^|\s)_([^_\n]+)_(?=\s|$)/g, (_m, pre, s) => pre + pc2.italic(s));
|
|
26688
26758
|
result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, label, url) => {
|
|
26689
26759
|
const short = url.length > 80 ? url.slice(0, 77) + "…" : url;
|
|
26690
|
-
return `${
|
|
26760
|
+
return `${pc2.cyan(label)} ${pc2.dim(`(${short})`)}`;
|
|
26691
26761
|
});
|
|
26692
26762
|
result = result.replace(/\u0000(\d+)\u0000/g, (_m, i) => codeSpans[Number(i)]);
|
|
26693
26763
|
return result;
|
|
@@ -26802,7 +26872,7 @@ class Renderer {
|
|
|
26802
26872
|
}
|
|
26803
26873
|
reasoning(chunk) {
|
|
26804
26874
|
this.spinner.stop();
|
|
26805
|
-
this.out.write(
|
|
26875
|
+
this.out.write(pc2.dim(chunk));
|
|
26806
26876
|
}
|
|
26807
26877
|
thinkingStart() {
|
|
26808
26878
|
this.spinner.start(t("ui.thinking"));
|
|
@@ -26816,7 +26886,7 @@ class Renderer {
|
|
|
26816
26886
|
const summary = summarizeArgs2(args);
|
|
26817
26887
|
if (!this.rich) {
|
|
26818
26888
|
this.out.write(`
|
|
26819
|
-
${
|
|
26889
|
+
${pc2.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc2.dim(summary)}` : ""}
|
|
26820
26890
|
`);
|
|
26821
26891
|
return;
|
|
26822
26892
|
}
|
|
@@ -26824,18 +26894,18 @@ ${pc.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}
|
|
|
26824
26894
|
if (this.toolStyle === "inline") {
|
|
26825
26895
|
const marker = toolMarker(tool);
|
|
26826
26896
|
this.out.write(`
|
|
26827
|
-
${
|
|
26897
|
+
${pc2.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc2.dim(summary)}` : ""}
|
|
26828
26898
|
`);
|
|
26829
26899
|
return;
|
|
26830
26900
|
}
|
|
26831
|
-
this.spinner.start(`${
|
|
26901
|
+
this.spinner.start(`${pc2.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc2.dim(summary)}` : ""}`);
|
|
26832
26902
|
}
|
|
26833
26903
|
toolEnd(_tool, duration, error, ctxDelta) {
|
|
26834
26904
|
this.spinner.stop();
|
|
26835
26905
|
if (!this.rich) {
|
|
26836
26906
|
if (ctxDelta !== undefined && ctxDelta !== 0) {
|
|
26837
|
-
const deltaStr = ctxDelta > 0 ?
|
|
26838
|
-
this.out.write(`${
|
|
26907
|
+
const deltaStr = ctxDelta > 0 ? pc2.green(`+${ctxDelta}`) : pc2.yellow(`${ctxDelta} ↓`);
|
|
26908
|
+
this.out.write(`${pc2.dim("ctx")} ${deltaStr}
|
|
26839
26909
|
`);
|
|
26840
26910
|
}
|
|
26841
26911
|
return;
|
|
@@ -26843,11 +26913,11 @@ ${pc.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}
|
|
|
26843
26913
|
if (!this.card)
|
|
26844
26914
|
return;
|
|
26845
26915
|
const { tool, args, body } = this.card;
|
|
26846
|
-
const marker = error ?
|
|
26847
|
-
let footer = `${marker} ${
|
|
26916
|
+
const marker = error ? pc2.red("✗") : pc2.green("✓");
|
|
26917
|
+
let footer = `${marker} ${pc2.dim(`${duration}ms`)}`;
|
|
26848
26918
|
if (ctxDelta !== undefined && ctxDelta !== 0) {
|
|
26849
|
-
const deltaStr = ctxDelta > 0 ?
|
|
26850
|
-
footer += ` ${
|
|
26919
|
+
const deltaStr = ctxDelta > 0 ? pc2.green(`+${ctxDelta}`) : pc2.yellow(`${ctxDelta} ↓`);
|
|
26920
|
+
footer += ` ${pc2.dim("ctx")} ${deltaStr}`;
|
|
26851
26921
|
}
|
|
26852
26922
|
if (this.toolStyle === "inline") {
|
|
26853
26923
|
this.out.write(`${GUTTER}${footer}
|
|
@@ -26860,7 +26930,7 @@ ${pc.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}
|
|
|
26860
26930
|
const lines = [];
|
|
26861
26931
|
const summary = summarizeArgs2(args);
|
|
26862
26932
|
if (summary)
|
|
26863
|
-
lines.push(
|
|
26933
|
+
lines.push(pc2.dim(summary));
|
|
26864
26934
|
for (const chunk of body) {
|
|
26865
26935
|
for (const line of chunk.split(`
|
|
26866
26936
|
`)) {
|
|
@@ -26884,7 +26954,7 @@ ${pc.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}
|
|
|
26884
26954
|
error(text) {
|
|
26885
26955
|
this.endCard();
|
|
26886
26956
|
this.spinner.stop();
|
|
26887
|
-
this.err.write(`${
|
|
26957
|
+
this.err.write(`${pc2.red(text)}
|
|
26888
26958
|
`);
|
|
26889
26959
|
}
|
|
26890
26960
|
flush() {
|
|
@@ -26907,8 +26977,8 @@ init_repl_commands();
|
|
|
26907
26977
|
function readVersion4() {
|
|
26908
26978
|
const here = dirname13(fileURLToPath4(import.meta.url));
|
|
26909
26979
|
const candidates = [
|
|
26910
|
-
|
|
26911
|
-
|
|
26980
|
+
join36(here, "..", "..", "package.json"),
|
|
26981
|
+
join36(here, "..", "package.json")
|
|
26912
26982
|
];
|
|
26913
26983
|
for (const p of candidates) {
|
|
26914
26984
|
if (existsSync43(p)) {
|
|
@@ -26924,14 +26994,14 @@ function formatContextBar(used, limit, compactions, quality) {
|
|
|
26924
26994
|
const pct = Math.min(100, Math.round(used / limit * 100));
|
|
26925
26995
|
const barLen = 20;
|
|
26926
26996
|
const filled = Math.round(pct / 100 * barLen);
|
|
26927
|
-
const bar =
|
|
26928
|
-
const pctStr = pct >= 75 ?
|
|
26929
|
-
let line = ` ${bar} ${pctStr} ${
|
|
26997
|
+
const bar = pc2.green("█".repeat(filled)) + pc2.dim("░".repeat(barLen - filled));
|
|
26998
|
+
const pctStr = pct >= 75 ? pc2.yellow(`${pct}%`) : pc2.dim(`${pct}%`);
|
|
26999
|
+
let line = ` ${bar} ${pctStr} ${pc2.dim(`(${used} / ${limit} tokens)`)}`;
|
|
26930
27000
|
if (compactions !== undefined) {
|
|
26931
|
-
line +=
|
|
27001
|
+
line += pc2.dim(` compactions: ${compactions}`);
|
|
26932
27002
|
}
|
|
26933
27003
|
if (quality !== undefined) {
|
|
26934
|
-
const qColor = quality >= 70 ?
|
|
27004
|
+
const qColor = quality >= 70 ? pc2.green : quality >= 40 ? pc2.yellow : pc2.red;
|
|
26935
27005
|
line += ` ${qColor(`quality: ${quality}%`)}`;
|
|
26936
27006
|
}
|
|
26937
27007
|
return line;
|
|
@@ -26963,15 +27033,15 @@ class Repl {
|
|
|
26963
27033
|
this.sessionManager = sessionManager;
|
|
26964
27034
|
this.skillsModule = skillsModule;
|
|
26965
27035
|
this.pluginManager = pluginManager;
|
|
26966
|
-
this.configDir = configDir ||
|
|
27036
|
+
this.configDir = configDir || join36(homedir17(), ".mma");
|
|
26967
27037
|
this.baseDir = baseDir || process.cwd();
|
|
26968
27038
|
this.noAgentsMd = noAgentsMd === true;
|
|
26969
|
-
this.historyPath =
|
|
27039
|
+
this.historyPath = join36(homedir17(), ".mma", "repl-history");
|
|
26970
27040
|
this.loadHistory();
|
|
26971
27041
|
this.rl = readline2.createInterface({
|
|
26972
27042
|
input: process.stdin,
|
|
26973
27043
|
output: process.stdout,
|
|
26974
|
-
prompt:
|
|
27044
|
+
prompt: pc2.cyan("> "),
|
|
26975
27045
|
history: this.history,
|
|
26976
27046
|
historySize: this.maxHistory,
|
|
26977
27047
|
tabSize: 2,
|
|
@@ -26999,7 +27069,7 @@ class Repl {
|
|
|
26999
27069
|
}
|
|
27000
27070
|
saveHistory() {
|
|
27001
27071
|
const allHistory = this.history.slice(-this.maxHistory);
|
|
27002
|
-
|
|
27072
|
+
writeFileSync15(this.historyPath, allHistory.join(`
|
|
27003
27073
|
`), "utf-8");
|
|
27004
27074
|
}
|
|
27005
27075
|
setupCompleter() {
|
|
@@ -27054,11 +27124,11 @@ class Repl {
|
|
|
27054
27124
|
}
|
|
27055
27125
|
}
|
|
27056
27126
|
if (this.running) {
|
|
27057
|
-
this.rl.setPrompt(
|
|
27127
|
+
this.rl.setPrompt(pc2.cyan("> "));
|
|
27058
27128
|
this.rl.prompt();
|
|
27059
27129
|
}
|
|
27060
27130
|
} else {
|
|
27061
|
-
this.rl.setPrompt(
|
|
27131
|
+
this.rl.setPrompt(pc2.cyan("... "));
|
|
27062
27132
|
this.rl.prompt();
|
|
27063
27133
|
}
|
|
27064
27134
|
return;
|
|
@@ -27066,7 +27136,7 @@ class Repl {
|
|
|
27066
27136
|
if (this.isMultiLineInput(trimmed)) {
|
|
27067
27137
|
inMultiLine = true;
|
|
27068
27138
|
multiLineBuffer = trimmed;
|
|
27069
|
-
this.rl.setPrompt(
|
|
27139
|
+
this.rl.setPrompt(pc2.cyan("... "));
|
|
27070
27140
|
this.rl.prompt();
|
|
27071
27141
|
return;
|
|
27072
27142
|
}
|
|
@@ -27097,7 +27167,7 @@ class Repl {
|
|
|
27097
27167
|
if (escBytes >= 2 || withinWindow) {
|
|
27098
27168
|
this.lastEscTime = 0;
|
|
27099
27169
|
if (this.agentRunning) {
|
|
27100
|
-
process.stdout.write(
|
|
27170
|
+
process.stdout.write(pc2.yellow(`
|
|
27101
27171
|
${t("repl.interrupt")}
|
|
27102
27172
|
`));
|
|
27103
27173
|
this.agent.shutdown();
|
|
@@ -27113,11 +27183,11 @@ ${t("repl.interrupt")}
|
|
|
27113
27183
|
const { dataUrl } = await bufferToDataUrl2(clipBuf);
|
|
27114
27184
|
this.pendingClipboardImage = dataUrl;
|
|
27115
27185
|
const sizeKb = Math.round(dataUrl.length * 3 / 4 / 1024);
|
|
27116
|
-
console.log(
|
|
27186
|
+
console.log(pc2.green(`
|
|
27117
27187
|
${t("image.attached", { source: "clipboard", size: `${sizeKb} KB` })}`));
|
|
27118
27188
|
this.rl.prompt();
|
|
27119
27189
|
} else {
|
|
27120
|
-
console.log(
|
|
27190
|
+
console.log(pc2.yellow(`
|
|
27121
27191
|
${t("image.clipboard_empty")}`));
|
|
27122
27192
|
this.rl.prompt();
|
|
27123
27193
|
}
|
|
@@ -27128,7 +27198,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
27128
27198
|
let forceExitTimer = null;
|
|
27129
27199
|
process.on("SIGINT", () => {
|
|
27130
27200
|
if (this.agentRunning) {
|
|
27131
|
-
console.log(
|
|
27201
|
+
console.log(pc2.yellow(`
|
|
27132
27202
|
[Ctrl+C] Остановка агента... (ещё раз — принудительно)`));
|
|
27133
27203
|
this.agent.shutdown();
|
|
27134
27204
|
this.agentRunning = false;
|
|
@@ -27165,7 +27235,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
27165
27235
|
this.pendingClipboardImage = null;
|
|
27166
27236
|
}
|
|
27167
27237
|
process.stdout.write(`
|
|
27168
|
-
` +
|
|
27238
|
+
` + pc2.green(t("repl.agent")));
|
|
27169
27239
|
const renderer = new Renderer({
|
|
27170
27240
|
spinner: this.config.ui?.spinner ?? true,
|
|
27171
27241
|
toolStyle: this.config.ui?.toolStyle ?? "inline"
|
|
@@ -27187,7 +27257,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
27187
27257
|
process.stdout.write(`
|
|
27188
27258
|
`);
|
|
27189
27259
|
if (!result.success) {
|
|
27190
|
-
console.error(
|
|
27260
|
+
console.error(pc2.red(`${t("error.prefix")}${result.error}`));
|
|
27191
27261
|
}
|
|
27192
27262
|
this.showContextBar(result);
|
|
27193
27263
|
} finally {
|
|
@@ -27217,13 +27287,13 @@ ${t("image.clipboard_empty")}`));
|
|
|
27217
27287
|
const args = parts.slice(1);
|
|
27218
27288
|
const cmd = this.commands.get(name);
|
|
27219
27289
|
if (!cmd) {
|
|
27220
|
-
console.log(
|
|
27290
|
+
console.log(pc2.red(t("cli.unknown_cmd", { name })), t("cli.help_hint"));
|
|
27221
27291
|
return;
|
|
27222
27292
|
}
|
|
27223
27293
|
try {
|
|
27224
27294
|
await cmd.action(args);
|
|
27225
27295
|
} catch (err) {
|
|
27226
|
-
console.error(
|
|
27296
|
+
console.error(pc2.red(t("error.command_error", {
|
|
27227
27297
|
message: err instanceof Error ? err.message : String(err)
|
|
27228
27298
|
})));
|
|
27229
27299
|
}
|
|
@@ -27247,12 +27317,12 @@ ${t("image.clipboard_empty")}`));
|
|
|
27247
27317
|
}
|
|
27248
27318
|
if (cmds.length === 0)
|
|
27249
27319
|
continue;
|
|
27250
|
-
console.log(
|
|
27320
|
+
console.log(pc2.bold(t(`repl.group.${groupKey}`)));
|
|
27251
27321
|
for (const cmd of cmds) {
|
|
27252
|
-
const aliases = cmd.aliases?.length ? ` (${
|
|
27253
|
-
console.log(` ${
|
|
27322
|
+
const aliases = cmd.aliases?.length ? ` (${pc2.dim(cmd.aliases.join(", "))})` : "";
|
|
27323
|
+
console.log(` ${pc2.cyan("/" + cmd.name)}${aliases} ${pc2.dim(cmd.description)}`);
|
|
27254
27324
|
if (cmd.usage) {
|
|
27255
|
-
console.log(` ${
|
|
27325
|
+
console.log(` ${pc2.dim(cmd.usage)}`);
|
|
27256
27326
|
}
|
|
27257
27327
|
}
|
|
27258
27328
|
console.log();
|
|
@@ -27264,7 +27334,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
27264
27334
|
const ctxLine = formatContextBar(result.contextUsed, result.contextLimit, result.compactionCount, result.contextQuality);
|
|
27265
27335
|
console.log(ctxLine);
|
|
27266
27336
|
if (result.totalTokens !== undefined && result.totalTokens > 0) {
|
|
27267
|
-
const apiLine =
|
|
27337
|
+
const apiLine = pc2.dim(` API: ${result.promptTokens} prompt + ${result.completionTokens} completion = ${result.totalTokens} total`);
|
|
27268
27338
|
console.log(apiLine);
|
|
27269
27339
|
}
|
|
27270
27340
|
}
|
|
@@ -27273,57 +27343,57 @@ ${t("image.clipboard_empty")}`));
|
|
|
27273
27343
|
this.running = true;
|
|
27274
27344
|
const info = [];
|
|
27275
27345
|
const row = (label, value) => {
|
|
27276
|
-
info.push(` ${
|
|
27346
|
+
info.push(` ${pc2.yellow(label)} ${value}`);
|
|
27277
27347
|
};
|
|
27278
27348
|
const ctx = this.config.contextWindow;
|
|
27279
27349
|
const sysBudget = Math.floor(ctx * this.config.contextBudget.systemPrompt);
|
|
27280
27350
|
const resBudget = Math.floor(ctx * this.config.contextBudget.responseReserve);
|
|
27281
27351
|
const histBudget = ctx - sysBudget - resBudget;
|
|
27282
|
-
row(t("repl.model"),
|
|
27283
|
-
row(t("repl.provider"), `${this.config.provider.type} → ${
|
|
27284
|
-
row(t("repl.context"), `${
|
|
27352
|
+
row(t("repl.model"), pc2.white(this.config.model));
|
|
27353
|
+
row(t("repl.provider"), `${this.config.provider.type} → ${pc2.dim(this.config.provider.baseUrl)}`);
|
|
27354
|
+
row(t("repl.context"), `${pc2.white(String(ctx))} ${pc2.dim(`(sys:${sysBudget} res:${resBudget} hist:${histBudget})`)}`);
|
|
27285
27355
|
const si = this.agent.getSystemPromptInfo();
|
|
27286
|
-
row(t("repl.sysprompt_label"),
|
|
27356
|
+
row(t("repl.sysprompt_label"), pc2.dim(t("repl.sysprompt_size", { used: si.tokenCount, budget: sysBudget })));
|
|
27287
27357
|
if (this.skillsModule) {
|
|
27288
27358
|
const budget = this.skillsModule.getBudget();
|
|
27289
|
-
row(t("repl.skills_label"), `${
|
|
27359
|
+
row(t("repl.skills_label"), `${pc2.white(String(this.skillsModule.getAvailable().length))} available, ${pc2.dim(`budget: ${budget.total} tokens`)}`);
|
|
27290
27360
|
}
|
|
27291
27361
|
if (this.pluginManager) {
|
|
27292
27362
|
const plugins = this.pluginManager.getAllPlugins().filter((p) => !p.isBuiltin);
|
|
27293
27363
|
if (plugins.length > 0) {
|
|
27294
27364
|
const pluginNames = plugins.map((p) => p.name).join(", ");
|
|
27295
|
-
row(t("repl.plugins_label"), `${
|
|
27365
|
+
row(t("repl.plugins_label"), `${pc2.white(String(plugins.length))} active ${pc2.dim(`(${pluginNames})`)}`);
|
|
27296
27366
|
}
|
|
27297
27367
|
}
|
|
27298
27368
|
const mcpServers = this.config.mcpServers || {};
|
|
27299
27369
|
const enabledServers = Object.entries(mcpServers).filter(([, s]) => s.enabled !== false);
|
|
27300
27370
|
if (enabledServers.length > 0) {
|
|
27301
27371
|
const names = enabledServers.map(([name]) => name).join(", ");
|
|
27302
|
-
row(t("repl.mcp_label"), `${
|
|
27372
|
+
row(t("repl.mcp_label"), `${pc2.white(String(enabledServers.length))} ${pc2.dim(`(${names})`)}`);
|
|
27303
27373
|
}
|
|
27304
27374
|
const cwd = process.cwd();
|
|
27305
|
-
row(t("repl.work_dir"),
|
|
27375
|
+
row(t("repl.work_dir"), pc2.dim(cwd));
|
|
27306
27376
|
if (this.noAgentsMd) {
|
|
27307
|
-
row(t("repl.agents_label"),
|
|
27377
|
+
row(t("repl.agents_label"), pc2.red(t("repl.disabled")));
|
|
27308
27378
|
} else {
|
|
27309
27379
|
const agentsMdCandidates = [
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
|
|
27380
|
+
join36(this.baseDir, "AGENTS.md"),
|
|
27381
|
+
join36(this.baseDir, ".mma", "AGENTS.md"),
|
|
27382
|
+
join36(this.configDir, "AGENTS.md")
|
|
27313
27383
|
];
|
|
27314
27384
|
const foundAgents = agentsMdCandidates.filter((p) => existsSync43(p));
|
|
27315
27385
|
if (foundAgents.length > 0) {
|
|
27316
27386
|
for (const p of foundAgents) {
|
|
27317
|
-
row(t("repl.agents_label"),
|
|
27387
|
+
row(t("repl.agents_label"), pc2.dim(p));
|
|
27318
27388
|
}
|
|
27319
27389
|
} else {
|
|
27320
|
-
row(t("repl.agents_label"),
|
|
27390
|
+
row(t("repl.agents_label"), pc2.dim(t("repl.not_found")));
|
|
27321
27391
|
}
|
|
27322
27392
|
}
|
|
27323
27393
|
const meta = this.sessionManager?.getActiveMeta();
|
|
27324
27394
|
if (meta) {
|
|
27325
|
-
const sessionPath =
|
|
27326
|
-
row(t("repl.session_label"), `${
|
|
27395
|
+
const sessionPath = join36(this.configDir, "sessions", meta.id);
|
|
27396
|
+
row(t("repl.session_label"), `${pc2.cyan(meta.name)} ${pc2.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc2.dim(sessionPath)}`);
|
|
27327
27397
|
}
|
|
27328
27398
|
const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
|
|
27329
27399
|
for (const line of box(info, {
|
|
@@ -27349,7 +27419,7 @@ init_config2();
|
|
|
27349
27419
|
init_i18n();
|
|
27350
27420
|
init_colors();
|
|
27351
27421
|
import { existsSync as existsSync44 } from "fs";
|
|
27352
|
-
import { join as
|
|
27422
|
+
import { join as join37 } from "path";
|
|
27353
27423
|
import { homedir as homedir18 } from "os";
|
|
27354
27424
|
async function main() {
|
|
27355
27425
|
const program2 = createProgram();
|
|
@@ -27405,7 +27475,7 @@ async function main() {
|
|
|
27405
27475
|
renderer.flush();
|
|
27406
27476
|
if (result.success) {
|
|
27407
27477
|
if (!result.text) {
|
|
27408
|
-
console.log(
|
|
27478
|
+
console.log(pc2.yellow(t("cli.no_output")));
|
|
27409
27479
|
}
|
|
27410
27480
|
} else {
|
|
27411
27481
|
console.error(`${t("error.prefix")}${result.error}`);
|
|
@@ -27416,15 +27486,15 @@ async function main() {
|
|
|
27416
27486
|
}
|
|
27417
27487
|
agent.shutdown();
|
|
27418
27488
|
} else {
|
|
27419
|
-
const configPath =
|
|
27489
|
+
const configPath = join37(homedir18(), ".mma", "config.json");
|
|
27420
27490
|
if (!existsSync44(configPath)) {
|
|
27421
|
-
console.log(
|
|
27491
|
+
console.log(pc2.yellow(`
|
|
27422
27492
|
` + t("cli.first_run") + `
|
|
27423
27493
|
`));
|
|
27424
27494
|
const answers = await runSetup();
|
|
27425
27495
|
const config2 = loadConfig({
|
|
27426
|
-
configDir:
|
|
27427
|
-
projectConfigPath: projectDir ?
|
|
27496
|
+
configDir: join37(homedir18(), ".mma"),
|
|
27497
|
+
projectConfigPath: projectDir ? join37(projectDir, ".mmrc") : join37(process.cwd(), ".mmrc")
|
|
27428
27498
|
});
|
|
27429
27499
|
config2.provider.type = answers.provider;
|
|
27430
27500
|
config2.provider.baseUrl = answers.apiBase;
|