micro-models-agent 0.33.4 → 0.34.0
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 +321 -124
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2825,6 +2825,9 @@ Use this knowledge to answer the user's question.`,
|
|
|
2825
2825
|
"indexer.find_results": `Found {count} matching files:
|
|
2826
2826
|
{results}`,
|
|
2827
2827
|
"indexer.no_matches": 'No matching files for "{query}"',
|
|
2828
|
+
"indexer.stack_deps": "deps",
|
|
2829
|
+
"indexer.stack_dev": "dev",
|
|
2830
|
+
"indexer.stack_scripts": "scripts",
|
|
2828
2831
|
"tool.friendly.project_map": "Project map",
|
|
2829
2832
|
"config.decryption_warning": "Warning: Failed to decrypt config: {error}",
|
|
2830
2833
|
"config.encryption_warning": "Warning: Failed to encrypt config: {error}",
|
|
@@ -3407,6 +3410,9 @@ var init_ru = __esm(() => {
|
|
|
3407
3410
|
"indexer.find_results": `Найдено {count} совпадающих файлов:
|
|
3408
3411
|
{results}`,
|
|
3409
3412
|
"indexer.no_matches": 'Нет совпадающих файлов для "{query}"',
|
|
3413
|
+
"indexer.stack_deps": "зависимости",
|
|
3414
|
+
"indexer.stack_dev": "dev",
|
|
3415
|
+
"indexer.stack_scripts": "скрипты",
|
|
3410
3416
|
"tool.friendly.project_map": "Карта проекта",
|
|
3411
3417
|
"config.decryption_warning": "Предупреждение: не удалось расшифровать конфигурацию: {error}",
|
|
3412
3418
|
"config.encryption_warning": "Предупреждение: не удалось зашифровать конфигурацию: {error}",
|
|
@@ -15194,9 +15200,11 @@ class ModuleRegistry {
|
|
|
15194
15200
|
listModules() {
|
|
15195
15201
|
return Array.from(this.modules.keys()).sort();
|
|
15196
15202
|
}
|
|
15197
|
-
collectPromptBlocks() {
|
|
15203
|
+
collectPromptBlocks(exclude = []) {
|
|
15198
15204
|
const blocks = [];
|
|
15199
|
-
for (const mod of this.modules
|
|
15205
|
+
for (const [name, mod] of this.modules) {
|
|
15206
|
+
if (exclude.includes(name))
|
|
15207
|
+
continue;
|
|
15200
15208
|
if (mod.getSystemPromptBlock) {
|
|
15201
15209
|
const block = mod.getSystemPromptBlock();
|
|
15202
15210
|
if (block)
|
|
@@ -18241,6 +18249,174 @@ class IndexCache {
|
|
|
18241
18249
|
}
|
|
18242
18250
|
var init_cache = () => {};
|
|
18243
18251
|
|
|
18252
|
+
// src/modules/indexer/project-profile.ts
|
|
18253
|
+
import { readFileSync as readFileSync24, existsSync as existsSync38 } from "fs";
|
|
18254
|
+
import { join as join31 } from "path";
|
|
18255
|
+
function detectManifest(baseDir) {
|
|
18256
|
+
for (const manifest of MANIFEST_ORDER) {
|
|
18257
|
+
if (existsSync38(join31(baseDir, manifest)))
|
|
18258
|
+
return manifest;
|
|
18259
|
+
}
|
|
18260
|
+
return null;
|
|
18261
|
+
}
|
|
18262
|
+
function cleanDependency(entry) {
|
|
18263
|
+
let name = entry.trim();
|
|
18264
|
+
const eq = name.indexOf("=");
|
|
18265
|
+
if (eq > 0)
|
|
18266
|
+
name = name.slice(0, eq);
|
|
18267
|
+
const ineq = name.search(/[<>=!~^]/);
|
|
18268
|
+
if (ineq > 0)
|
|
18269
|
+
name = name.slice(0, ineq);
|
|
18270
|
+
return name.replace(/["',]/g, "").trim();
|
|
18271
|
+
}
|
|
18272
|
+
function readPackageJson(baseDir) {
|
|
18273
|
+
try {
|
|
18274
|
+
const raw = JSON.parse(readFileSync24(join31(baseDir, "package.json"), "utf-8"));
|
|
18275
|
+
if (!raw || typeof raw !== "object")
|
|
18276
|
+
return null;
|
|
18277
|
+
const profile = {
|
|
18278
|
+
runtime: "node",
|
|
18279
|
+
deps: Object.keys(raw.dependencies || {}),
|
|
18280
|
+
devDeps: Object.keys(raw.devDependencies || {}),
|
|
18281
|
+
scripts: {}
|
|
18282
|
+
};
|
|
18283
|
+
if (typeof raw.name === "string" && raw.name)
|
|
18284
|
+
profile.name = raw.name;
|
|
18285
|
+
if (raw.scripts && typeof raw.scripts === "object") {
|
|
18286
|
+
for (const [key, val] of Object.entries(raw.scripts)) {
|
|
18287
|
+
if (typeof val === "string" && val)
|
|
18288
|
+
profile.scripts[key] = val;
|
|
18289
|
+
}
|
|
18290
|
+
}
|
|
18291
|
+
return profile;
|
|
18292
|
+
} catch {
|
|
18293
|
+
return null;
|
|
18294
|
+
}
|
|
18295
|
+
}
|
|
18296
|
+
function readPyproject(baseDir) {
|
|
18297
|
+
try {
|
|
18298
|
+
const content = readFileSync24(join31(baseDir, "pyproject.toml"), "utf-8");
|
|
18299
|
+
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
18300
|
+
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
18301
|
+
if (nameMatch)
|
|
18302
|
+
profile.name = nameMatch[1];
|
|
18303
|
+
const depsBlock = content.match(/dependencies\s*=\s*\[([\s\S]*?)\]/);
|
|
18304
|
+
if (depsBlock) {
|
|
18305
|
+
profile.deps = [...depsBlock[1].matchAll(/"([^"]+)"/g)].map((m) => cleanDependency(m[1])).filter(Boolean);
|
|
18306
|
+
}
|
|
18307
|
+
return profile;
|
|
18308
|
+
} catch {
|
|
18309
|
+
return null;
|
|
18310
|
+
}
|
|
18311
|
+
}
|
|
18312
|
+
function readCargo(baseDir) {
|
|
18313
|
+
try {
|
|
18314
|
+
const content = readFileSync24(join31(baseDir, "Cargo.toml"), "utf-8");
|
|
18315
|
+
const profile = { runtime: "rust", deps: [], devDeps: [], scripts: {} };
|
|
18316
|
+
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
18317
|
+
if (nameMatch)
|
|
18318
|
+
profile.name = nameMatch[1];
|
|
18319
|
+
let inDeps = false;
|
|
18320
|
+
for (const line of content.split(`
|
|
18321
|
+
`)) {
|
|
18322
|
+
const trimmed = line.trim();
|
|
18323
|
+
if (/^\[.*\]$/.test(trimmed)) {
|
|
18324
|
+
inDeps = trimmed === "[dependencies]";
|
|
18325
|
+
continue;
|
|
18326
|
+
}
|
|
18327
|
+
if (inDeps && /^[A-Za-z0-9_-]+\s*=/.test(trimmed)) {
|
|
18328
|
+
profile.deps.push(trimmed.split("=")[0].trim());
|
|
18329
|
+
}
|
|
18330
|
+
}
|
|
18331
|
+
return profile;
|
|
18332
|
+
} catch {
|
|
18333
|
+
return null;
|
|
18334
|
+
}
|
|
18335
|
+
}
|
|
18336
|
+
function readGoMod(baseDir) {
|
|
18337
|
+
try {
|
|
18338
|
+
const content = readFileSync24(join31(baseDir, "go.mod"), "utf-8");
|
|
18339
|
+
const profile = { runtime: "go", deps: [], devDeps: [], scripts: {} };
|
|
18340
|
+
const moduleMatch = content.match(/^module\s+(\S+)/m);
|
|
18341
|
+
if (moduleMatch)
|
|
18342
|
+
profile.name = moduleMatch[1];
|
|
18343
|
+
for (const line of content.split(`
|
|
18344
|
+
`)) {
|
|
18345
|
+
const m = line.match(/^\s*(\S+)\s+v[\d.]+/);
|
|
18346
|
+
if (m && !line.startsWith("//"))
|
|
18347
|
+
profile.deps.push(m[1]);
|
|
18348
|
+
}
|
|
18349
|
+
return profile;
|
|
18350
|
+
} catch {
|
|
18351
|
+
return null;
|
|
18352
|
+
}
|
|
18353
|
+
}
|
|
18354
|
+
function readRequirements(baseDir) {
|
|
18355
|
+
try {
|
|
18356
|
+
const content = readFileSync24(join31(baseDir, "requirements.txt"), "utf-8");
|
|
18357
|
+
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
18358
|
+
for (const line of content.split(`
|
|
18359
|
+
`)) {
|
|
18360
|
+
const trimmed = line.trim();
|
|
18361
|
+
if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("-"))
|
|
18362
|
+
continue;
|
|
18363
|
+
profile.deps.push(cleanDependency(trimmed));
|
|
18364
|
+
}
|
|
18365
|
+
return profile;
|
|
18366
|
+
} catch {
|
|
18367
|
+
return null;
|
|
18368
|
+
}
|
|
18369
|
+
}
|
|
18370
|
+
function readProjectProfile(baseDir) {
|
|
18371
|
+
const manifest = detectManifest(baseDir);
|
|
18372
|
+
if (!manifest)
|
|
18373
|
+
return null;
|
|
18374
|
+
switch (manifest) {
|
|
18375
|
+
case "package.json":
|
|
18376
|
+
return readPackageJson(baseDir);
|
|
18377
|
+
case "pyproject.toml":
|
|
18378
|
+
return readPyproject(baseDir);
|
|
18379
|
+
case "Cargo.toml":
|
|
18380
|
+
return readCargo(baseDir);
|
|
18381
|
+
case "go.mod":
|
|
18382
|
+
return readGoMod(baseDir);
|
|
18383
|
+
case "requirements.txt":
|
|
18384
|
+
return readRequirements(baseDir);
|
|
18385
|
+
default:
|
|
18386
|
+
return null;
|
|
18387
|
+
}
|
|
18388
|
+
}
|
|
18389
|
+
function formatProjectProfile(profile) {
|
|
18390
|
+
const parts = [];
|
|
18391
|
+
if (profile.deps.length > 0) {
|
|
18392
|
+
parts.push(`${t("indexer.stack_deps")}: ${profile.deps.slice(0, MAX_DEPS).join(", ")}`);
|
|
18393
|
+
}
|
|
18394
|
+
if (profile.devDeps.length > 0) {
|
|
18395
|
+
parts.push(`${t("indexer.stack_dev")}: ${profile.devDeps.slice(0, MAX_DEV_DEPS).join(", ")}`);
|
|
18396
|
+
}
|
|
18397
|
+
const scripts = Object.entries(profile.scripts).slice(0, MAX_SCRIPTS);
|
|
18398
|
+
if (scripts.length > 0) {
|
|
18399
|
+
parts.push(`${t("indexer.stack_scripts")}: ${scripts.map(([k, v]) => `${k}=${v}`).join(", ")}`);
|
|
18400
|
+
}
|
|
18401
|
+
const name = profile.name ? ` ${profile.name}` : "";
|
|
18402
|
+
return `[Stack: ${profile.runtime}${name} — ${parts.join(" | ")}]`;
|
|
18403
|
+
}
|
|
18404
|
+
function buildProjectProfileLine(baseDir) {
|
|
18405
|
+
const profile = readProjectProfile(baseDir);
|
|
18406
|
+
return profile ? formatProjectProfile(profile) : null;
|
|
18407
|
+
}
|
|
18408
|
+
var MANIFEST_ORDER, MAX_DEPS = 5, MAX_DEV_DEPS = 3, MAX_SCRIPTS = 3;
|
|
18409
|
+
var init_project_profile = __esm(() => {
|
|
18410
|
+
init_i18n();
|
|
18411
|
+
MANIFEST_ORDER = [
|
|
18412
|
+
"package.json",
|
|
18413
|
+
"pyproject.toml",
|
|
18414
|
+
"Cargo.toml",
|
|
18415
|
+
"go.mod",
|
|
18416
|
+
"requirements.txt"
|
|
18417
|
+
];
|
|
18418
|
+
});
|
|
18419
|
+
|
|
18244
18420
|
// src/modules/indexer/module.ts
|
|
18245
18421
|
import { dirname as dirname8 } from "path";
|
|
18246
18422
|
|
|
@@ -18336,6 +18512,7 @@ class IndexerModule {
|
|
|
18336
18512
|
}
|
|
18337
18513
|
formatMap(result) {
|
|
18338
18514
|
const summary = this.indexer.summarize(result);
|
|
18515
|
+
const stackLine = buildProjectProfileLine(this.baseDir);
|
|
18339
18516
|
const dirCounts = this.getDirectoryCounts(result);
|
|
18340
18517
|
const topDirs = Object.entries(dirCounts).sort((a, b) => b[1] - a[1]).slice(0, 10).map(([dir, count]) => `${dir} (${count})`).join(", ") || "-";
|
|
18341
18518
|
const fileLines = result.files.slice(0, 100).map((f) => {
|
|
@@ -18348,6 +18525,7 @@ ${t("indexer.and_more", { count: result.files.length - 100 })}` : "";
|
|
|
18348
18525
|
return [
|
|
18349
18526
|
`${t("indexer.map_header")} (${this.baseDir})`,
|
|
18350
18527
|
summary,
|
|
18528
|
+
...stackLine ? [stackLine] : [],
|
|
18351
18529
|
`${t("indexer.top_directories")}: ${topDirs}`,
|
|
18352
18530
|
`${t("indexer.files")}:` + (fileLines.length > 0 ? "" : " " + t("indexer.empty")),
|
|
18353
18531
|
...fileLines,
|
|
@@ -18392,7 +18570,10 @@ ${t("indexer.and_more", { count: result.files.length - 100 })}` : "";
|
|
|
18392
18570
|
if (action === "refresh") {
|
|
18393
18571
|
const result = await this.refresh();
|
|
18394
18572
|
const summary2 = result ? this.indexer.summarize(result) : t("indexer.empty");
|
|
18395
|
-
|
|
18573
|
+
const stackLine2 = result ? buildProjectProfileLine(this.baseDir) : null;
|
|
18574
|
+
const output2 = summary2 && stackLine2 ? `${summary2}
|
|
18575
|
+
${stackLine2}` : summary2;
|
|
18576
|
+
return this.makeResult(t("indexer.refreshed", { summary: output2 }));
|
|
18396
18577
|
}
|
|
18397
18578
|
if (action === "find") {
|
|
18398
18579
|
const query = String(args.query || "").toLowerCase();
|
|
@@ -18417,7 +18598,10 @@ ${t("indexer.and_more", { count: result.files.length - 100 })}` : "";
|
|
|
18417
18598
|
return this.makeResult(t("indexer.not_indexed"));
|
|
18418
18599
|
}
|
|
18419
18600
|
const summary = this.indexer.summarize(this.index);
|
|
18420
|
-
|
|
18601
|
+
const stackLine = buildProjectProfileLine(this.baseDir);
|
|
18602
|
+
const output = summary && stackLine ? `${summary}
|
|
18603
|
+
${stackLine}` : summary;
|
|
18604
|
+
return this.makeResult(t("indexer.summary", { summary: output }));
|
|
18421
18605
|
}
|
|
18422
18606
|
};
|
|
18423
18607
|
}
|
|
@@ -18428,6 +18612,7 @@ ${t("indexer.and_more", { count: result.files.length - 100 })}` : "";
|
|
|
18428
18612
|
var init_module6 = __esm(() => {
|
|
18429
18613
|
init_walker();
|
|
18430
18614
|
init_cache();
|
|
18615
|
+
init_project_profile();
|
|
18431
18616
|
init_i18n();
|
|
18432
18617
|
});
|
|
18433
18618
|
|
|
@@ -18590,13 +18775,13 @@ var init_mcp = __esm(() => {
|
|
|
18590
18775
|
|
|
18591
18776
|
// src/modules/memory/module.ts
|
|
18592
18777
|
import { homedir as homedir10 } from "os";
|
|
18593
|
-
import { join as
|
|
18778
|
+
import { join as join32 } from "path";
|
|
18594
18779
|
|
|
18595
18780
|
class MemoryModule {
|
|
18596
18781
|
name = "memory";
|
|
18597
18782
|
store;
|
|
18598
18783
|
constructor(memoryDir) {
|
|
18599
|
-
const dir = memoryDir ||
|
|
18784
|
+
const dir = memoryDir || join32(homedir10(), ".mma", "memory");
|
|
18600
18785
|
this.store = new MemoryStore(dir);
|
|
18601
18786
|
}
|
|
18602
18787
|
getSystemPromptBlock() {
|
|
@@ -18644,8 +18829,8 @@ __export(exports_bootstrap, {
|
|
|
18644
18829
|
bootstrap: () => bootstrap
|
|
18645
18830
|
});
|
|
18646
18831
|
import { homedir as homedir11 } from "os";
|
|
18647
|
-
import { join as
|
|
18648
|
-
import { existsSync as
|
|
18832
|
+
import { join as join33, resolve as resolve21 } from "path";
|
|
18833
|
+
import { existsSync as existsSync39, readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "fs";
|
|
18649
18834
|
function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
18650
18835
|
const now = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
18651
18836
|
const isWin = profileCompressed.toLowerCase().includes("win32");
|
|
@@ -18670,8 +18855,8 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
18670
18855
|
`);
|
|
18671
18856
|
}
|
|
18672
18857
|
async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
18673
|
-
const dir = configDir ||
|
|
18674
|
-
const projectConfigPath = projectDir ?
|
|
18858
|
+
const dir = configDir || join33(homedir11(), ".mma");
|
|
18859
|
+
const projectConfigPath = projectDir ? join33(projectDir, ".mmrc") : join33(process.cwd(), ".mmrc");
|
|
18675
18860
|
const config = loadConfig({ configDir: dir, projectConfigPath });
|
|
18676
18861
|
setLocale(config.locale);
|
|
18677
18862
|
try {
|
|
@@ -18681,7 +18866,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18681
18866
|
}
|
|
18682
18867
|
} catch {}
|
|
18683
18868
|
const logger = new Logger(config.logLevel);
|
|
18684
|
-
logger.setLogDir(
|
|
18869
|
+
logger.setLogDir(join33(dir, "logs"));
|
|
18685
18870
|
logger.debug("MMA bootstrap", {
|
|
18686
18871
|
version: config.version,
|
|
18687
18872
|
model: config.model
|
|
@@ -18703,7 +18888,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18703
18888
|
logger.info(`Model ${config.model} loaded in ${loadResult.loadTime}s`);
|
|
18704
18889
|
}
|
|
18705
18890
|
}
|
|
18706
|
-
const profile = new UserProfile(
|
|
18891
|
+
const profile = new UserProfile(join33(dir));
|
|
18707
18892
|
profile.load() || profile.collect();
|
|
18708
18893
|
profile.save();
|
|
18709
18894
|
const llmProvider = new OpenAICompatProvider({
|
|
@@ -18715,7 +18900,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18715
18900
|
rateLimits: config.security?.rateLimits
|
|
18716
18901
|
});
|
|
18717
18902
|
const baseDir = projectDir ? resolve21(projectDir) : process.cwd();
|
|
18718
|
-
const projectMapCacheDir =
|
|
18903
|
+
const projectMapCacheDir = join33(baseDir, ".mma");
|
|
18719
18904
|
const indexerModule = new IndexerModule({
|
|
18720
18905
|
baseDir,
|
|
18721
18906
|
cacheDir: projectMapCacheDir
|
|
@@ -18726,9 +18911,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18726
18911
|
logger.warn(`Project indexing failed: ${err.message}`);
|
|
18727
18912
|
}
|
|
18728
18913
|
const skillsLoader = new SkillsLoader;
|
|
18729
|
-
const builtinDir =
|
|
18730
|
-
const globalDir =
|
|
18731
|
-
const projectSkillsDir =
|
|
18914
|
+
const builtinDir = join33(import.meta.dirname, "skills", "builtin");
|
|
18915
|
+
const globalDir = join33(homedir11(), ".agents", "skills");
|
|
18916
|
+
const projectSkillsDir = join33(baseDir, ".mma", "skills");
|
|
18732
18917
|
const availableSkills = skillsLoader.loadFromAllSources(builtinDir, globalDir, projectSkillsDir);
|
|
18733
18918
|
const skillsBudget = Math.floor(config.contextWindow * config.skills.budget);
|
|
18734
18919
|
const skillsModule = new SkillsModule(availableSkills, skillsBudget);
|
|
@@ -18742,11 +18927,11 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18742
18927
|
essential: true,
|
|
18743
18928
|
estimatedTokens: Math.ceil(systemInfoContent.length / 4)
|
|
18744
18929
|
};
|
|
18745
|
-
const agentsMdGlobal =
|
|
18746
|
-
if (!
|
|
18930
|
+
const agentsMdGlobal = join33(dir, "AGENTS.md");
|
|
18931
|
+
if (!existsSync39(agentsMdGlobal)) {
|
|
18747
18932
|
writeFileSync14(agentsMdGlobal, "", "utf-8");
|
|
18748
18933
|
}
|
|
18749
|
-
const sessionDir =
|
|
18934
|
+
const sessionDir = join33(dir, "sessions");
|
|
18750
18935
|
const sessionStore = new SessionStore(sessionDir);
|
|
18751
18936
|
sessionStore.init();
|
|
18752
18937
|
const sessionManager = new SessionManager(sessionStore, {
|
|
@@ -18813,7 +18998,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18813
18998
|
const mcpModule = new MCPModule(config);
|
|
18814
18999
|
await mcpModule.initialize();
|
|
18815
19000
|
moduleRegistry.register(mcpModule);
|
|
18816
|
-
const memoryModule = new MemoryModule(
|
|
19001
|
+
const memoryModule = new MemoryModule(join33(dir, "memory"));
|
|
18817
19002
|
moduleRegistry.register(memoryModule);
|
|
18818
19003
|
if (config.browser.enabled) {
|
|
18819
19004
|
const browserModule = new BrowserModule;
|
|
@@ -18863,8 +19048,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18863
19048
|
pluginManager.register(plugin);
|
|
18864
19049
|
pluginManager.register(plugin2);
|
|
18865
19050
|
const pluginLoader = new PluginLoader;
|
|
18866
|
-
const globalPluginsDir =
|
|
18867
|
-
const projectPluginsDir =
|
|
19051
|
+
const globalPluginsDir = join33(homedir11(), ".mma", "plugins");
|
|
19052
|
+
const projectPluginsDir = join33(baseDir, ".mma", "plugins");
|
|
18868
19053
|
pluginLoader.loadFromDir(globalPluginsDir, pluginManager, logger);
|
|
18869
19054
|
pluginLoader.loadFromDir(projectPluginsDir, pluginManager, logger);
|
|
18870
19055
|
contextManager.onCompact = (summary) => {
|
|
@@ -18882,13 +19067,13 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18882
19067
|
const skipAgentsMd = noAgentsMd === true;
|
|
18883
19068
|
if (!skipAgentsMd) {
|
|
18884
19069
|
const agentsMdCandidates = [
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
19070
|
+
join33(baseDir, "AGENTS.md"),
|
|
19071
|
+
join33(baseDir, ".mma", "AGENTS.md"),
|
|
19072
|
+
join33(dir, "AGENTS.md")
|
|
18888
19073
|
];
|
|
18889
19074
|
for (const p of agentsMdCandidates) {
|
|
18890
|
-
if (
|
|
18891
|
-
const content =
|
|
19075
|
+
if (existsSync39(p)) {
|
|
19076
|
+
const content = readFileSync25(p, "utf-8").trim();
|
|
18892
19077
|
if (content) {
|
|
18893
19078
|
agentsMdBlocks.push({
|
|
18894
19079
|
content,
|
|
@@ -18902,7 +19087,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18902
19087
|
}
|
|
18903
19088
|
const promptBlocks = [
|
|
18904
19089
|
systemInfoPrompt,
|
|
18905
|
-
...moduleRegistry.collectPromptBlocks(),
|
|
19090
|
+
...moduleRegistry.collectPromptBlocks(["indexer"]),
|
|
18906
19091
|
...agentsMdBlocks
|
|
18907
19092
|
];
|
|
18908
19093
|
const agentDeps = {
|
|
@@ -18923,6 +19108,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
18923
19108
|
const skillsBlock = skillsModule.getSystemPromptBlock();
|
|
18924
19109
|
if (skillsBlock)
|
|
18925
19110
|
blocks.push(skillsBlock);
|
|
19111
|
+
const mapBlock = indexerModule.getSystemPromptBlock();
|
|
19112
|
+
if (mapBlock)
|
|
19113
|
+
blocks.push(mapBlock);
|
|
18926
19114
|
return blocks;
|
|
18927
19115
|
},
|
|
18928
19116
|
finalAudit: () => execModule.runFinalAudit(),
|
|
@@ -19737,20 +19925,20 @@ __export(exports_manifest, {
|
|
|
19737
19925
|
getCertMark: () => getCertMark,
|
|
19738
19926
|
MANIFEST_PATH: () => MANIFEST_PATH
|
|
19739
19927
|
});
|
|
19740
|
-
import { existsSync as
|
|
19928
|
+
import { existsSync as existsSync40, readFileSync as readFileSync26, mkdirSync as mkdirSync17, writeFileSync as writeFileSync15 } from "fs";
|
|
19741
19929
|
import { homedir as homedir13 } from "os";
|
|
19742
|
-
import { join as
|
|
19930
|
+
import { join as join35 } from "path";
|
|
19743
19931
|
function readManifest(path = MANIFEST_PATH) {
|
|
19744
19932
|
try {
|
|
19745
|
-
if (
|
|
19746
|
-
const raw = JSON.parse(
|
|
19933
|
+
if (existsSync40(path)) {
|
|
19934
|
+
const raw = JSON.parse(readFileSync26(path, "utf-8"));
|
|
19747
19935
|
return { version: 1, certifications: raw.certifications ?? [] };
|
|
19748
19936
|
}
|
|
19749
19937
|
} catch {}
|
|
19750
19938
|
return { version: 1, certifications: [] };
|
|
19751
19939
|
}
|
|
19752
19940
|
function saveManifest(m, path = MANIFEST_PATH) {
|
|
19753
|
-
mkdirSync17(
|
|
19941
|
+
mkdirSync17(join35(homedir13(), ".mma"), { recursive: true });
|
|
19754
19942
|
writeFileSync15(path, JSON.stringify(m, null, 2), "utf-8");
|
|
19755
19943
|
}
|
|
19756
19944
|
function upsertCertification(entry, path = MANIFEST_PATH) {
|
|
@@ -19785,7 +19973,7 @@ function getCertMark(model, providerUrl, currentVersion, path = MANIFEST_PATH) {
|
|
|
19785
19973
|
}
|
|
19786
19974
|
var MANIFEST_PATH;
|
|
19787
19975
|
var init_manifest = __esm(() => {
|
|
19788
|
-
MANIFEST_PATH =
|
|
19976
|
+
MANIFEST_PATH = join35(homedir13(), ".mma", "certifications.json");
|
|
19789
19977
|
});
|
|
19790
19978
|
|
|
19791
19979
|
// node_modules/yaml/dist/nodes/identity.js
|
|
@@ -26908,8 +27096,8 @@ var init_scenarios = __esm(() => {
|
|
|
26908
27096
|
});
|
|
26909
27097
|
|
|
26910
27098
|
// src/modules/certification/loader.ts
|
|
26911
|
-
import { existsSync as
|
|
26912
|
-
import { join as
|
|
27099
|
+
import { existsSync as existsSync41, readdirSync as readdirSync14, readFileSync as readFileSync27 } from "fs";
|
|
27100
|
+
import { join as join36 } from "path";
|
|
26913
27101
|
function validateScenario(s) {
|
|
26914
27102
|
const errors2 = [];
|
|
26915
27103
|
const isSkip = s.mode === "skip";
|
|
@@ -26958,12 +27146,12 @@ function loadScenarios(userDir) {
|
|
|
26958
27146
|
else
|
|
26959
27147
|
scenarios.push(s);
|
|
26960
27148
|
}
|
|
26961
|
-
if (userDir &&
|
|
27149
|
+
if (userDir && existsSync41(userDir)) {
|
|
26962
27150
|
for (const file of readdirSync14(userDir)) {
|
|
26963
27151
|
if (!file.endsWith(".yaml") && !file.endsWith(".yml"))
|
|
26964
27152
|
continue;
|
|
26965
27153
|
try {
|
|
26966
|
-
const raw =
|
|
27154
|
+
const raw = readFileSync27(join36(userDir, file), "utf-8");
|
|
26967
27155
|
const data = $parse(raw);
|
|
26968
27156
|
const parsed = normalizeScenario(data, file);
|
|
26969
27157
|
const errs = validateScenario(parsed);
|
|
@@ -27016,8 +27204,8 @@ var init_loader3 = __esm(() => {
|
|
|
27016
27204
|
});
|
|
27017
27205
|
|
|
27018
27206
|
// src/modules/certification/fact-checker.ts
|
|
27019
|
-
import { existsSync as
|
|
27020
|
-
import { join as
|
|
27207
|
+
import { existsSync as existsSync42, readFileSync as readFileSync28, statSync as statSync8 } from "fs";
|
|
27208
|
+
import { join as join37 } from "path";
|
|
27021
27209
|
function checkSandbox(sandboxDir, checks, exitCode, output) {
|
|
27022
27210
|
const failures = [];
|
|
27023
27211
|
for (const check of checks) {
|
|
@@ -27034,16 +27222,16 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
27034
27222
|
case "outputContains":
|
|
27035
27223
|
return output.includes(check.text);
|
|
27036
27224
|
case "fileExists":
|
|
27037
|
-
return isFile(
|
|
27225
|
+
return isFile(join37(sandboxDir, check.path));
|
|
27038
27226
|
case "fileNotExists":
|
|
27039
|
-
return !
|
|
27227
|
+
return !existsSync42(join37(sandboxDir, check.path));
|
|
27040
27228
|
case "dirExists":
|
|
27041
|
-
return isDir(
|
|
27229
|
+
return isDir(join37(sandboxDir, check.path));
|
|
27042
27230
|
case "fileContent": {
|
|
27043
|
-
const abs =
|
|
27231
|
+
const abs = join37(sandboxDir, check.path);
|
|
27044
27232
|
if (!isFile(abs))
|
|
27045
27233
|
return false;
|
|
27046
|
-
const content =
|
|
27234
|
+
const content = readFileSync28(abs, "utf-8");
|
|
27047
27235
|
if (check.contains !== undefined)
|
|
27048
27236
|
return content.includes(check.contains);
|
|
27049
27237
|
if (check.equals !== undefined)
|
|
@@ -27051,10 +27239,10 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
27051
27239
|
return false;
|
|
27052
27240
|
}
|
|
27053
27241
|
case "fileRegex": {
|
|
27054
|
-
const abs =
|
|
27242
|
+
const abs = join37(sandboxDir, check.path);
|
|
27055
27243
|
if (!isFile(abs))
|
|
27056
27244
|
return false;
|
|
27057
|
-
return new RegExp(check.pattern).test(
|
|
27245
|
+
return new RegExp(check.pattern).test(readFileSync28(abs, "utf-8"));
|
|
27058
27246
|
}
|
|
27059
27247
|
default:
|
|
27060
27248
|
return false;
|
|
@@ -27062,14 +27250,14 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
27062
27250
|
}
|
|
27063
27251
|
function isFile(p) {
|
|
27064
27252
|
try {
|
|
27065
|
-
return
|
|
27253
|
+
return existsSync42(p) && statSync8(p).isFile();
|
|
27066
27254
|
} catch {
|
|
27067
27255
|
return false;
|
|
27068
27256
|
}
|
|
27069
27257
|
}
|
|
27070
27258
|
function isDir(p) {
|
|
27071
27259
|
try {
|
|
27072
|
-
return
|
|
27260
|
+
return existsSync42(p) && statSync8(p).isDirectory();
|
|
27073
27261
|
} catch {
|
|
27074
27262
|
return false;
|
|
27075
27263
|
}
|
|
@@ -27100,9 +27288,9 @@ var init_fact_checker = () => {};
|
|
|
27100
27288
|
|
|
27101
27289
|
// src/modules/certification/runner.ts
|
|
27102
27290
|
import { spawn as spawn7 } from "child_process";
|
|
27103
|
-
import { existsSync as
|
|
27291
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync18, rmSync as rmSync4, cpSync as cpSync2 } from "fs";
|
|
27104
27292
|
import { platform as platform6 } from "os";
|
|
27105
|
-
import { join as
|
|
27293
|
+
import { join as join38, resolve as resolve22, dirname as dirname9 } from "path";
|
|
27106
27294
|
async function runScenario(scenario, opts) {
|
|
27107
27295
|
if (scenario.mode === "skip") {
|
|
27108
27296
|
return {
|
|
@@ -27121,7 +27309,7 @@ async function runScenario(scenario, opts) {
|
|
|
27121
27309
|
let passed = 0;
|
|
27122
27310
|
let firstError;
|
|
27123
27311
|
for (let i = 1;i <= reps; i++) {
|
|
27124
|
-
const sandbox =
|
|
27312
|
+
const sandbox = join38(opts.sandboxBase, `run-${scenario.id}-${i}`);
|
|
27125
27313
|
let failures = [];
|
|
27126
27314
|
let exitCode = -1;
|
|
27127
27315
|
let output = "";
|
|
@@ -27182,20 +27370,20 @@ function prepareSandbox(sandbox, scenario, mmaRoot) {
|
|
|
27182
27370
|
rmSync4(sandbox, { recursive: true, force: true });
|
|
27183
27371
|
mkdirSync18(sandbox, { recursive: true });
|
|
27184
27372
|
for (const f of scenario.fixtures ?? []) {
|
|
27185
|
-
const src =
|
|
27186
|
-
if (!
|
|
27373
|
+
const src = join38(mmaRoot, f.source);
|
|
27374
|
+
if (!existsSync43(src)) {
|
|
27187
27375
|
throw new Error(`fixture missing: ${f.source}`);
|
|
27188
27376
|
}
|
|
27189
|
-
const dest =
|
|
27377
|
+
const dest = join38(sandbox, f.dest);
|
|
27190
27378
|
mkdirSync18(dirname9(dest), { recursive: true });
|
|
27191
27379
|
cpSync2(src, dest);
|
|
27192
27380
|
}
|
|
27193
27381
|
}
|
|
27194
27382
|
function resolveMmaEntry(mmaRoot) {
|
|
27195
|
-
const dev =
|
|
27196
|
-
if (
|
|
27383
|
+
const dev = join38(mmaRoot, "src", "cli", "main.ts");
|
|
27384
|
+
if (existsSync43(dev))
|
|
27197
27385
|
return dev;
|
|
27198
|
-
return
|
|
27386
|
+
return join38(mmaRoot, "dist", "main.js");
|
|
27199
27387
|
}
|
|
27200
27388
|
function findMmaRoot(fromDir) {
|
|
27201
27389
|
const candidates = [
|
|
@@ -27203,7 +27391,7 @@ function findMmaRoot(fromDir) {
|
|
|
27203
27391
|
resolve22(fromDir, "..")
|
|
27204
27392
|
];
|
|
27205
27393
|
for (const c of candidates) {
|
|
27206
|
-
if (
|
|
27394
|
+
if (existsSync43(join38(c, "package.json")))
|
|
27207
27395
|
return c;
|
|
27208
27396
|
}
|
|
27209
27397
|
return process.cwd();
|
|
@@ -27271,15 +27459,15 @@ __export(exports_cli, {
|
|
|
27271
27459
|
});
|
|
27272
27460
|
import { rmSync as rmSync5 } from "fs";
|
|
27273
27461
|
import { homedir as homedir14 } from "os";
|
|
27274
|
-
import { join as
|
|
27462
|
+
import { join as join39, dirname as dirname10 } from "path";
|
|
27275
27463
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
27276
|
-
import { existsSync as
|
|
27464
|
+
import { existsSync as existsSync44, readFileSync as readFileSync29 } from "fs";
|
|
27277
27465
|
function readVersion() {
|
|
27278
|
-
const candidates = [
|
|
27466
|
+
const candidates = [join39(MMA_ROOT, "package.json")];
|
|
27279
27467
|
for (const p of candidates) {
|
|
27280
|
-
if (
|
|
27468
|
+
if (existsSync44(p)) {
|
|
27281
27469
|
try {
|
|
27282
|
-
const raw = JSON.parse(
|
|
27470
|
+
const raw = JSON.parse(readFileSync29(p, "utf-8"));
|
|
27283
27471
|
if (raw.version)
|
|
27284
27472
|
return raw.version;
|
|
27285
27473
|
} catch {}
|
|
@@ -27315,7 +27503,7 @@ async function certify(opts) {
|
|
|
27315
27503
|
return;
|
|
27316
27504
|
}
|
|
27317
27505
|
console.log(t("cli.cert_started", { model: opts.name, provider: providerUrl }));
|
|
27318
|
-
const sandboxBase =
|
|
27506
|
+
const sandboxBase = join39(process.cwd(), ".mma", "certification");
|
|
27319
27507
|
const results = [];
|
|
27320
27508
|
const total = selected.length;
|
|
27321
27509
|
let idx = 0;
|
|
@@ -27429,7 +27617,7 @@ var init_cli = __esm(() => {
|
|
|
27429
27617
|
init_manifest();
|
|
27430
27618
|
HERE = dirname10(fileURLToPath2(import.meta.url));
|
|
27431
27619
|
MMA_ROOT = findMmaRoot(HERE);
|
|
27432
|
-
USER_SCENARIO_DIR =
|
|
27620
|
+
USER_SCENARIO_DIR = join39(homedir14(), ".mma", "certification", "scenarios");
|
|
27433
27621
|
});
|
|
27434
27622
|
|
|
27435
27623
|
// src/cli/repl-commands.ts
|
|
@@ -27438,20 +27626,20 @@ __export(exports_repl_commands, {
|
|
|
27438
27626
|
registerAllCommands: () => registerAllCommands,
|
|
27439
27627
|
COMMAND_GROUPS: () => COMMAND_GROUPS
|
|
27440
27628
|
});
|
|
27441
|
-
import { join as
|
|
27629
|
+
import { join as join41, dirname as dirname12 } from "path";
|
|
27442
27630
|
import { homedir as homedir16 } from "os";
|
|
27443
|
-
import { existsSync as
|
|
27631
|
+
import { existsSync as existsSync46, readFileSync as readFileSync31 } from "fs";
|
|
27444
27632
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
27445
27633
|
function readVersion3() {
|
|
27446
27634
|
const here = dirname12(fileURLToPath4(import.meta.url));
|
|
27447
27635
|
const candidates = [
|
|
27448
|
-
|
|
27449
|
-
|
|
27636
|
+
join41(here, "..", "..", "package.json"),
|
|
27637
|
+
join41(here, "..", "package.json")
|
|
27450
27638
|
];
|
|
27451
27639
|
for (const p of candidates) {
|
|
27452
|
-
if (
|
|
27640
|
+
if (existsSync46(p)) {
|
|
27453
27641
|
try {
|
|
27454
|
-
const raw = JSON.parse(
|
|
27642
|
+
const raw = JSON.parse(readFileSync31(p, "utf8"));
|
|
27455
27643
|
if (raw.version)
|
|
27456
27644
|
return raw.version;
|
|
27457
27645
|
} catch {}
|
|
@@ -27515,7 +27703,7 @@ function registerMmaCommands(ctx) {
|
|
|
27515
27703
|
}
|
|
27516
27704
|
try {
|
|
27517
27705
|
const { loadFileAsDataUrl: loadFileAsDataUrl2, loadUrlAsDataUrl: loadUrlAsDataUrl2, readClipboardImage: readClipboardImage2 } = await Promise.resolve().then(() => (init_image_utils(), exports_image_utils));
|
|
27518
|
-
const { existsSync:
|
|
27706
|
+
const { existsSync: existsSync47 } = await import("fs");
|
|
27519
27707
|
const { resolve: resolve23 } = await import("path");
|
|
27520
27708
|
let dataUrl;
|
|
27521
27709
|
let label;
|
|
@@ -27535,7 +27723,7 @@ function registerMmaCommands(ctx) {
|
|
|
27535
27723
|
label = source;
|
|
27536
27724
|
} else {
|
|
27537
27725
|
const absPath = resolve23(process.cwd(), source);
|
|
27538
|
-
if (!
|
|
27726
|
+
if (!existsSync47(absPath)) {
|
|
27539
27727
|
console.log(pc2.red(t("image.not_found", { path: source })));
|
|
27540
27728
|
return;
|
|
27541
27729
|
}
|
|
@@ -27614,7 +27802,7 @@ function registerMmaCommands(ctx) {
|
|
|
27614
27802
|
console.log(pc2.yellow(t("repl.wizard_running")));
|
|
27615
27803
|
await ctx.withExclusiveInput(async () => {
|
|
27616
27804
|
const answers = await runSetup(ctx.rl);
|
|
27617
|
-
const configPath =
|
|
27805
|
+
const configPath = join41(homedir16(), ".mma", "config.json");
|
|
27618
27806
|
ctx.config.provider.type = answers.provider;
|
|
27619
27807
|
ctx.config.provider.baseUrl = answers.apiBase;
|
|
27620
27808
|
ctx.config.provider.apiKey = answers.apiKey;
|
|
@@ -27668,7 +27856,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
27668
27856
|
return;
|
|
27669
27857
|
}
|
|
27670
27858
|
ctx.config.provider.type = name;
|
|
27671
|
-
const configPath =
|
|
27859
|
+
const configPath = join41(homedir16(), ".mma", "config.json");
|
|
27672
27860
|
saveConfig(ctx.config, configPath);
|
|
27673
27861
|
await ctx.agent.reconfigure(ctx.config);
|
|
27674
27862
|
console.log(pc2.green(t("repl.provider_set", { name })));
|
|
@@ -27724,7 +27912,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
27724
27912
|
return;
|
|
27725
27913
|
}
|
|
27726
27914
|
ctx.config.model = name;
|
|
27727
|
-
const configPath =
|
|
27915
|
+
const configPath = join41(homedir16(), ".mma", "config.json");
|
|
27728
27916
|
saveConfig(ctx.config, configPath);
|
|
27729
27917
|
await ctx.agent.reconfigure(ctx.config);
|
|
27730
27918
|
console.log(pc2.green(t("repl.model_set", { name })));
|
|
@@ -27749,7 +27937,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
27749
27937
|
return;
|
|
27750
27938
|
}
|
|
27751
27939
|
ctx.config.contextWindow = size;
|
|
27752
|
-
const configPath =
|
|
27940
|
+
const configPath = join41(homedir16(), ".mma", "config.json");
|
|
27753
27941
|
saveConfig(ctx.config, configPath);
|
|
27754
27942
|
await ctx.agent.reconfigure(ctx.config);
|
|
27755
27943
|
console.log(pc2.green(t("cli.context_set", { size })));
|
|
@@ -27768,10 +27956,10 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
27768
27956
|
ctx.agent.shutdown();
|
|
27769
27957
|
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config2(), exports_config));
|
|
27770
27958
|
const { homedir: homedir17 } = await import("os");
|
|
27771
|
-
const { join:
|
|
27959
|
+
const { join: join42 } = await import("path");
|
|
27772
27960
|
const configDir = ctx.configDir;
|
|
27773
27961
|
const baseDir = ctx.baseDir;
|
|
27774
|
-
const projectConfigPath =
|
|
27962
|
+
const projectConfigPath = join42(baseDir, ".mmrc");
|
|
27775
27963
|
const freshConfig = loadConfig2({ configDir, projectConfigPath });
|
|
27776
27964
|
Object.assign(ctx.config, freshConfig);
|
|
27777
27965
|
const { bootstrap: bootstrap2 } = await Promise.resolve().then(() => (init_bootstrap(), exports_bootstrap));
|
|
@@ -28071,14 +28259,14 @@ init_bootstrap();
|
|
|
28071
28259
|
init_config2();
|
|
28072
28260
|
init_setup();
|
|
28073
28261
|
init_i18n();
|
|
28074
|
-
import { join as
|
|
28262
|
+
import { join as join40, dirname as dirname11 } from "path";
|
|
28075
28263
|
import { homedir as homedir15 } from "os";
|
|
28076
|
-
import { existsSync as
|
|
28264
|
+
import { existsSync as existsSync45, readFileSync as readFileSync30 } from "fs";
|
|
28077
28265
|
|
|
28078
28266
|
// src/cli/security-commands.ts
|
|
28079
28267
|
init_bootstrap();
|
|
28080
28268
|
init_config2();
|
|
28081
|
-
import { join as
|
|
28269
|
+
import { join as join34 } from "path";
|
|
28082
28270
|
import { homedir as homedir12 } from "os";
|
|
28083
28271
|
|
|
28084
28272
|
// src/modules/security/security-policies.ts
|
|
@@ -28608,7 +28796,7 @@ function createSecurityCommand(program2) {
|
|
|
28608
28796
|
}
|
|
28609
28797
|
});
|
|
28610
28798
|
securityCmd.command("set-policy").argument("<preset>", t("cli.security.preset")).description(t("cli.security.set_policy")).action(async (preset) => {
|
|
28611
|
-
const configPath =
|
|
28799
|
+
const configPath = join34(homedir12(), ".mma", "config.json");
|
|
28612
28800
|
const { config: appConfig } = await bootstrap();
|
|
28613
28801
|
const validPresets = ["strict", "balanced", "permissive"];
|
|
28614
28802
|
if (!validPresets.includes(preset)) {
|
|
@@ -28623,7 +28811,7 @@ function createSecurityCommand(program2) {
|
|
|
28623
28811
|
console.log(t("cli.security.policy_description", { description: policy.description }));
|
|
28624
28812
|
});
|
|
28625
28813
|
securityCmd.command("enable-encryption").description(t("cli.security.enable_encryption")).action(async () => {
|
|
28626
|
-
const configPath =
|
|
28814
|
+
const configPath = join34(homedir12(), ".mma", "config.json");
|
|
28627
28815
|
const { config: appConfig } = await bootstrap();
|
|
28628
28816
|
appConfig.security = appConfig.security || {};
|
|
28629
28817
|
appConfig.security.sessionEncryption = {
|
|
@@ -28635,7 +28823,7 @@ function createSecurityCommand(program2) {
|
|
|
28635
28823
|
console.log(t("cli.security.encryption_enabled"));
|
|
28636
28824
|
});
|
|
28637
28825
|
securityCmd.command("disable-encryption").description(t("cli.security.disable_encryption")).action(async () => {
|
|
28638
|
-
const configPath =
|
|
28826
|
+
const configPath = join34(homedir12(), ".mma", "config.json");
|
|
28639
28827
|
const { config: appConfig } = await bootstrap();
|
|
28640
28828
|
appConfig.security = appConfig.security || {};
|
|
28641
28829
|
appConfig.security.sessionEncryption = {
|
|
@@ -28647,7 +28835,7 @@ function createSecurityCommand(program2) {
|
|
|
28647
28835
|
console.log(t("cli.security.encryption_disabled"));
|
|
28648
28836
|
});
|
|
28649
28837
|
securityCmd.command("enable-audit").description(t("cli.security.enable_audit")).action(async () => {
|
|
28650
|
-
const configPath =
|
|
28838
|
+
const configPath = join34(homedir12(), ".mma", "config.json");
|
|
28651
28839
|
const { config: appConfig } = await bootstrap();
|
|
28652
28840
|
appConfig.security = appConfig.security || {};
|
|
28653
28841
|
appConfig.security.auditNotifier = {
|
|
@@ -28661,7 +28849,7 @@ function createSecurityCommand(program2) {
|
|
|
28661
28849
|
console.log(t("cli.security.audit_enabled"));
|
|
28662
28850
|
});
|
|
28663
28851
|
securityCmd.command("disable-audit").description(t("cli.security.disable_audit")).action(async () => {
|
|
28664
|
-
const configPath =
|
|
28852
|
+
const configPath = join34(homedir12(), ".mma", "config.json");
|
|
28665
28853
|
const { config: appConfig } = await bootstrap();
|
|
28666
28854
|
appConfig.security = appConfig.security || {};
|
|
28667
28855
|
appConfig.security.auditNotifier = {
|
|
@@ -28697,13 +28885,13 @@ import { fileURLToPath as fileURLToPath3 } from "url";
|
|
|
28697
28885
|
function readVersion2() {
|
|
28698
28886
|
const here = dirname11(fileURLToPath3(import.meta.url));
|
|
28699
28887
|
const candidates = [
|
|
28700
|
-
|
|
28701
|
-
|
|
28888
|
+
join40(here, "..", "..", "package.json"),
|
|
28889
|
+
join40(here, "..", "package.json")
|
|
28702
28890
|
];
|
|
28703
28891
|
for (const p of candidates) {
|
|
28704
|
-
if (
|
|
28892
|
+
if (existsSync45(p)) {
|
|
28705
28893
|
try {
|
|
28706
|
-
const raw = JSON.parse(
|
|
28894
|
+
const raw = JSON.parse(readFileSync30(p, "utf8"));
|
|
28707
28895
|
if (raw.version)
|
|
28708
28896
|
return raw.version;
|
|
28709
28897
|
} catch {}
|
|
@@ -28716,7 +28904,7 @@ function createProgram() {
|
|
|
28716
28904
|
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"));
|
|
28717
28905
|
program2.command("init").description(t("cli.init")).action(async () => {
|
|
28718
28906
|
const answers = await runSetup();
|
|
28719
|
-
const configPath =
|
|
28907
|
+
const configPath = join40(homedir15(), ".mma", "config.json");
|
|
28720
28908
|
const { config } = await bootstrap();
|
|
28721
28909
|
config.provider.type = answers.provider;
|
|
28722
28910
|
config.provider.baseUrl = answers.apiBase;
|
|
@@ -28761,7 +28949,7 @@ function createProgram() {
|
|
|
28761
28949
|
});
|
|
28762
28950
|
const configCmd = program2.command("config").description(t("cli.manage_config"));
|
|
28763
28951
|
configCmd.command("set").argument("<key>", t("cli.config_key")).argument("<value>", "Config value").description(t("cli.set_value")).action(async (key, value) => {
|
|
28764
|
-
const configPath =
|
|
28952
|
+
const configPath = join40(homedir15(), ".mma", "config.json");
|
|
28765
28953
|
const { config } = await bootstrap();
|
|
28766
28954
|
const keys = key.split(".");
|
|
28767
28955
|
let obj = config;
|
|
@@ -28824,7 +29012,7 @@ function createProgram() {
|
|
|
28824
29012
|
console.log(t("cli.model_hint"));
|
|
28825
29013
|
});
|
|
28826
29014
|
model.command("use").argument("<name>", "Model name").description(t("cli.set_model")).action(async (name) => {
|
|
28827
|
-
const configPath =
|
|
29015
|
+
const configPath = join40(homedir15(), ".mma", "config.json");
|
|
28828
29016
|
const { config } = await bootstrap();
|
|
28829
29017
|
config.model = name;
|
|
28830
29018
|
saveConfig(config, configPath);
|
|
@@ -28860,7 +29048,7 @@ function createProgram() {
|
|
|
28860
29048
|
await uncertify2(name, config);
|
|
28861
29049
|
});
|
|
28862
29050
|
program2.command("context").description(t("cli.manage_context")).argument("<size>", "Context window size in tokens").action(async (size) => {
|
|
28863
|
-
const configPath =
|
|
29051
|
+
const configPath = join40(homedir15(), ".mma", "config.json");
|
|
28864
29052
|
const { config } = await bootstrap();
|
|
28865
29053
|
const contextWindow = parseInt(size, 10);
|
|
28866
29054
|
if (isNaN(contextWindow) || contextWindow < 1024) {
|
|
@@ -28878,7 +29066,7 @@ function createProgram() {
|
|
|
28878
29066
|
console.log(t("cli.base_url"), config.provider.baseUrl);
|
|
28879
29067
|
});
|
|
28880
29068
|
provider.command("use").argument("<name>", "Provider name").description(t("cli.set_provider")).action(async (name) => {
|
|
28881
|
-
const configPath =
|
|
29069
|
+
const configPath = join40(homedir15(), ".mma", "config.json");
|
|
28882
29070
|
const { config } = await bootstrap();
|
|
28883
29071
|
config.provider.type = name;
|
|
28884
29072
|
saveConfig(config, configPath);
|
|
@@ -29648,8 +29836,8 @@ class LineEditor {
|
|
|
29648
29836
|
}
|
|
29649
29837
|
|
|
29650
29838
|
// src/cli/repl.ts
|
|
29651
|
-
import { existsSync as
|
|
29652
|
-
import { join as
|
|
29839
|
+
import { existsSync as existsSync47, readFileSync as readFileSync32, writeFileSync as writeFileSync16 } from "fs";
|
|
29840
|
+
import { join as join42, dirname as dirname13 } from "path";
|
|
29653
29841
|
import { homedir as homedir17 } from "os";
|
|
29654
29842
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
29655
29843
|
|
|
@@ -30155,13 +30343,13 @@ init_repl_commands();
|
|
|
30155
30343
|
function readVersion4() {
|
|
30156
30344
|
const here = dirname13(fileURLToPath5(import.meta.url));
|
|
30157
30345
|
const candidates = [
|
|
30158
|
-
|
|
30159
|
-
|
|
30346
|
+
join42(here, "..", "..", "package.json"),
|
|
30347
|
+
join42(here, "..", "package.json")
|
|
30160
30348
|
];
|
|
30161
30349
|
for (const p of candidates) {
|
|
30162
|
-
if (
|
|
30350
|
+
if (existsSync47(p)) {
|
|
30163
30351
|
try {
|
|
30164
|
-
const raw = JSON.parse(
|
|
30352
|
+
const raw = JSON.parse(readFileSync32(p, "utf8"));
|
|
30165
30353
|
if (raw.version)
|
|
30166
30354
|
return raw.version;
|
|
30167
30355
|
} catch {}
|
|
@@ -30217,10 +30405,10 @@ class Repl {
|
|
|
30217
30405
|
this.skillsModule = skillsModule;
|
|
30218
30406
|
this.pluginManager = pluginManager;
|
|
30219
30407
|
this.logger = logger;
|
|
30220
|
-
this.configDir = configDir ||
|
|
30408
|
+
this.configDir = configDir || join42(homedir17(), ".mma");
|
|
30221
30409
|
this.baseDir = baseDir || process.cwd();
|
|
30222
30410
|
this.noAgentsMd = noAgentsMd === true;
|
|
30223
|
-
this.historyPath =
|
|
30411
|
+
this.historyPath = join42(homedir17(), ".mma", "repl-history");
|
|
30224
30412
|
this.loadHistory();
|
|
30225
30413
|
this.rl = process.stdin.isTTY ? new LineEditor({
|
|
30226
30414
|
input: process.stdin,
|
|
@@ -30253,9 +30441,9 @@ class Repl {
|
|
|
30253
30441
|
this.setupListeners();
|
|
30254
30442
|
}
|
|
30255
30443
|
loadHistory() {
|
|
30256
|
-
if (
|
|
30444
|
+
if (existsSync47(this.historyPath)) {
|
|
30257
30445
|
try {
|
|
30258
|
-
const raw =
|
|
30446
|
+
const raw = readFileSync32(this.historyPath, "utf-8");
|
|
30259
30447
|
this.history = raw.split(`
|
|
30260
30448
|
`).filter(Boolean).slice(-this.maxHistory);
|
|
30261
30449
|
} catch {
|
|
@@ -30612,11 +30800,11 @@ ${t("image.clipboard_empty")}`));
|
|
|
30612
30800
|
row(t("repl.agents_label"), pc2.red(t("repl.disabled")));
|
|
30613
30801
|
} else {
|
|
30614
30802
|
const agentsMdCandidates = [
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
|
|
30803
|
+
join42(this.baseDir, "AGENTS.md"),
|
|
30804
|
+
join42(this.baseDir, ".mma", "AGENTS.md"),
|
|
30805
|
+
join42(this.configDir, "AGENTS.md")
|
|
30618
30806
|
];
|
|
30619
|
-
const foundAgents = agentsMdCandidates.filter((p) =>
|
|
30807
|
+
const foundAgents = agentsMdCandidates.filter((p) => existsSync47(p));
|
|
30620
30808
|
if (foundAgents.length > 0) {
|
|
30621
30809
|
for (const p of foundAgents) {
|
|
30622
30810
|
row(t("repl.agents_label"), pc2.dim(p));
|
|
@@ -30627,7 +30815,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
30627
30815
|
}
|
|
30628
30816
|
const meta = this.sessionManager?.getActiveMeta();
|
|
30629
30817
|
if (meta) {
|
|
30630
|
-
const sessionPath =
|
|
30818
|
+
const sessionPath = join42(this.configDir, "sessions", meta.id);
|
|
30631
30819
|
row(t("repl.session_label"), `${pc2.cyan(meta.name)} ${pc2.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc2.dim(sessionPath)}`);
|
|
30632
30820
|
}
|
|
30633
30821
|
const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
|
|
@@ -30668,13 +30856,14 @@ init_setup();
|
|
|
30668
30856
|
init_config2();
|
|
30669
30857
|
init_i18n();
|
|
30670
30858
|
init_colors();
|
|
30671
|
-
import { existsSync as
|
|
30672
|
-
import { join as
|
|
30859
|
+
import { existsSync as existsSync48, readFileSync as readFileSync33 } from "fs";
|
|
30860
|
+
import { join as join43, dirname as dirname14 } from "path";
|
|
30673
30861
|
import { homedir as homedir18 } from "os";
|
|
30674
30862
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
30675
30863
|
|
|
30676
30864
|
// src/modules/updater/checker.ts
|
|
30677
30865
|
init_command();
|
|
30866
|
+
import { platform as platform7 } from "os";
|
|
30678
30867
|
var defaultRunner2 = async (command, args, options) => {
|
|
30679
30868
|
const { execFile } = await import("child_process");
|
|
30680
30869
|
return new Promise((resolve23) => {
|
|
@@ -30719,8 +30908,8 @@ class Updater {
|
|
|
30719
30908
|
}
|
|
30720
30909
|
async install(latest) {
|
|
30721
30910
|
try {
|
|
30722
|
-
const command =
|
|
30723
|
-
const res = await this.runner(command,
|
|
30911
|
+
const { command, args } = this.buildInstallCommand(latest);
|
|
30912
|
+
const res = await this.runner(command, args, {
|
|
30724
30913
|
timeout: 120000,
|
|
30725
30914
|
windowsHide: true
|
|
30726
30915
|
});
|
|
@@ -30733,6 +30922,14 @@ class Updater {
|
|
|
30733
30922
|
`)[0] };
|
|
30734
30923
|
}
|
|
30735
30924
|
}
|
|
30925
|
+
buildInstallCommand(latest) {
|
|
30926
|
+
const npmArgs = ["install", "-g", `${this.packageName}@${latest}`];
|
|
30927
|
+
const command = resolveSpawnCommand("npm");
|
|
30928
|
+
if (platform7() === "win32" && /\.(cmd|bat)$/i.test(command)) {
|
|
30929
|
+
return { command: "cmd.exe", args: ["/c", command, ...npmArgs] };
|
|
30930
|
+
}
|
|
30931
|
+
return { command, args: npmArgs };
|
|
30932
|
+
}
|
|
30736
30933
|
}
|
|
30737
30934
|
// src/modules/updater/module.ts
|
|
30738
30935
|
init_i18n();
|
|
@@ -30824,13 +31021,13 @@ class UpdaterModule {
|
|
|
30824
31021
|
function readVersion5() {
|
|
30825
31022
|
const here = dirname14(fileURLToPath6(import.meta.url));
|
|
30826
31023
|
const candidates = [
|
|
30827
|
-
|
|
30828
|
-
|
|
31024
|
+
join43(here, "..", "..", "package.json"),
|
|
31025
|
+
join43(here, "..", "package.json")
|
|
30829
31026
|
];
|
|
30830
31027
|
for (const p of candidates) {
|
|
30831
|
-
if (
|
|
31028
|
+
if (existsSync48(p)) {
|
|
30832
31029
|
try {
|
|
30833
|
-
const raw = JSON.parse(
|
|
31030
|
+
const raw = JSON.parse(readFileSync33(p, "utf8"));
|
|
30834
31031
|
if (raw.version)
|
|
30835
31032
|
return raw.version;
|
|
30836
31033
|
} catch {}
|
|
@@ -30901,15 +31098,15 @@ async function main() {
|
|
|
30901
31098
|
agent.shutdown();
|
|
30902
31099
|
process.exit(exitCode);
|
|
30903
31100
|
} else {
|
|
30904
|
-
const configPath =
|
|
30905
|
-
if (!
|
|
31101
|
+
const configPath = join43(homedir18(), ".mma", "config.json");
|
|
31102
|
+
if (!existsSync48(configPath)) {
|
|
30906
31103
|
console.log(pc2.yellow(`
|
|
30907
31104
|
` + t("cli.first_run") + `
|
|
30908
31105
|
`));
|
|
30909
31106
|
const answers = await runSetup();
|
|
30910
31107
|
const config2 = loadConfig({
|
|
30911
|
-
configDir:
|
|
30912
|
-
projectConfigPath: projectDir ?
|
|
31108
|
+
configDir: join43(homedir18(), ".mma"),
|
|
31109
|
+
projectConfigPath: projectDir ? join43(projectDir, ".mmrc") : join43(process.cwd(), ".mmrc")
|
|
30913
31110
|
});
|
|
30914
31111
|
config2.provider.type = answers.provider;
|
|
30915
31112
|
config2.provider.baseUrl = answers.apiBase;
|