micro-models-agent 0.48.2 → 0.49.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 +57 -75
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -13298,19 +13298,34 @@ class FactualCheck {
|
|
|
13298
13298
|
return existsSync24(fp);
|
|
13299
13299
|
if (this.knownFiles.has(fp))
|
|
13300
13300
|
return true;
|
|
13301
|
+
for (const cand of this.dotfileVariants(fp)) {
|
|
13302
|
+
if (this.knownFiles.has(cand))
|
|
13303
|
+
return true;
|
|
13304
|
+
if (existsSync24(resolve14(this.baseDir, cand)))
|
|
13305
|
+
return true;
|
|
13306
|
+
}
|
|
13301
13307
|
if (!fp.includes("/") && !fp.includes("\\")) {
|
|
13302
13308
|
return this.bareNameExists(fp);
|
|
13303
13309
|
}
|
|
13304
|
-
return
|
|
13310
|
+
return false;
|
|
13311
|
+
}
|
|
13312
|
+
dotfileVariants(fp) {
|
|
13313
|
+
const idx = Math.max(fp.lastIndexOf("/"), fp.lastIndexOf("\\"));
|
|
13314
|
+
const base = idx >= 0 ? fp.slice(idx + 1) : fp;
|
|
13315
|
+
if (base.startsWith("."))
|
|
13316
|
+
return [fp];
|
|
13317
|
+
return idx >= 0 ? [fp, `${fp.slice(0, idx + 1)}.${base}`] : [fp, `.${fp}`];
|
|
13305
13318
|
}
|
|
13306
13319
|
bareNameExists(name) {
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
for (const known of this.knownFiles) {
|
|
13312
|
-
if (known.endsWith(`/${name}`) || known.endsWith(`\\${name}`) || known === name) {
|
|
13320
|
+
for (const cand of this.dotfileVariants(name)) {
|
|
13321
|
+
if (existsSync24(resolve14(this.baseDir, cand)))
|
|
13322
|
+
return true;
|
|
13323
|
+
if (this.indexHas(cand))
|
|
13313
13324
|
return true;
|
|
13325
|
+
for (const known of this.knownFiles) {
|
|
13326
|
+
if (known.endsWith(`/${cand}`) || known.endsWith(`\\${cand}`) || known === cand) {
|
|
13327
|
+
return true;
|
|
13328
|
+
}
|
|
13314
13329
|
}
|
|
13315
13330
|
}
|
|
13316
13331
|
const now = Date.now();
|
|
@@ -19124,6 +19139,9 @@ class ExecutionModule {
|
|
|
19124
19139
|
getTracker() {
|
|
19125
19140
|
return this.tracker;
|
|
19126
19141
|
}
|
|
19142
|
+
getActivePlan() {
|
|
19143
|
+
return this.tracker?.getPlan() ?? null;
|
|
19144
|
+
}
|
|
19127
19145
|
getStore() {
|
|
19128
19146
|
return this.store;
|
|
19129
19147
|
}
|
|
@@ -22518,6 +22536,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
22518
22536
|
sessionManager,
|
|
22519
22537
|
skillsModule,
|
|
22520
22538
|
pluginManager,
|
|
22539
|
+
execModule,
|
|
22521
22540
|
toolCtx,
|
|
22522
22541
|
configDir: dir,
|
|
22523
22542
|
baseDir,
|
|
@@ -33353,8 +33372,8 @@ class LineEditor {
|
|
|
33353
33372
|
}
|
|
33354
33373
|
|
|
33355
33374
|
// src/cli/repl.ts
|
|
33356
|
-
import { existsSync as
|
|
33357
|
-
import { join as
|
|
33375
|
+
import { existsSync as existsSync52, readFileSync as readFileSync34, writeFileSync as writeFileSync17 } from "fs";
|
|
33376
|
+
import { join as join48 } from "path";
|
|
33358
33377
|
import { homedir as homedir18 } from "os";
|
|
33359
33378
|
|
|
33360
33379
|
// src/cli/completer.ts
|
|
@@ -33966,31 +33985,6 @@ init_session_logger();
|
|
|
33966
33985
|
init_colors();
|
|
33967
33986
|
init_js_identifiers();
|
|
33968
33987
|
init_i18n();
|
|
33969
|
-
import { existsSync as existsSync52, readFileSync as readFileSync34 } from "fs";
|
|
33970
|
-
import { join as join48 } from "path";
|
|
33971
|
-
function readActivePlan(baseDir) {
|
|
33972
|
-
const p = join48(baseDir, ".mma", "plans", "active.json");
|
|
33973
|
-
if (!existsSync52(p))
|
|
33974
|
-
return null;
|
|
33975
|
-
try {
|
|
33976
|
-
const raw = readFileSync34(p, "utf-8");
|
|
33977
|
-
if (!raw.trim())
|
|
33978
|
-
return null;
|
|
33979
|
-
const parsed = JSON.parse(raw);
|
|
33980
|
-
if (!parsed || !Array.isArray(parsed.steps))
|
|
33981
|
-
return null;
|
|
33982
|
-
return {
|
|
33983
|
-
id: parsed.id || "plan",
|
|
33984
|
-
title: parsed.title || "Plan",
|
|
33985
|
-
steps: parsed.steps,
|
|
33986
|
-
createdAt: parsed.createdAt || new Date().toISOString(),
|
|
33987
|
-
baseDir: parsed.baseDir || baseDir,
|
|
33988
|
-
name: parsed.name
|
|
33989
|
-
};
|
|
33990
|
-
} catch {
|
|
33991
|
-
return null;
|
|
33992
|
-
}
|
|
33993
|
-
}
|
|
33994
33988
|
function currentStepIndex(plan) {
|
|
33995
33989
|
const idx = plan.steps.findIndex((s) => s.status !== "done" && s.status !== "skipped");
|
|
33996
33990
|
return idx === -1 ? 0 : idx;
|
|
@@ -34099,8 +34093,7 @@ class Repl {
|
|
|
34099
34093
|
noAgentsMd;
|
|
34100
34094
|
pendingClipboardImage = null;
|
|
34101
34095
|
exitOnClose = false;
|
|
34102
|
-
|
|
34103
|
-
lastPlanSig = null;
|
|
34096
|
+
execModule;
|
|
34104
34097
|
rl;
|
|
34105
34098
|
agent;
|
|
34106
34099
|
config;
|
|
@@ -34110,7 +34103,7 @@ class Repl {
|
|
|
34110
34103
|
logger;
|
|
34111
34104
|
slog;
|
|
34112
34105
|
envReport;
|
|
34113
|
-
constructor(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, exitOnClose, envReport, historyPath) {
|
|
34106
|
+
constructor(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, exitOnClose, envReport, historyPath, execModule) {
|
|
34114
34107
|
this.agent = agent;
|
|
34115
34108
|
this.config = config;
|
|
34116
34109
|
this.exitOnClose = exitOnClose === true;
|
|
@@ -34119,11 +34112,12 @@ class Repl {
|
|
|
34119
34112
|
this.pluginManager = pluginManager;
|
|
34120
34113
|
this.logger = logger;
|
|
34121
34114
|
this.envReport = envReport;
|
|
34115
|
+
this.execModule = execModule;
|
|
34122
34116
|
this.slog = new SessionLogger(sessionManager, logger);
|
|
34123
|
-
this.configDir = configDir ||
|
|
34117
|
+
this.configDir = configDir || join48(homedir18(), ".mma");
|
|
34124
34118
|
this.baseDir = baseDir || process.cwd();
|
|
34125
34119
|
this.noAgentsMd = noAgentsMd === true;
|
|
34126
|
-
this.historyPath = historyPath ??
|
|
34120
|
+
this.historyPath = historyPath ?? join48(homedir18(), ".mma", "repl-history");
|
|
34127
34121
|
this.loadHistory();
|
|
34128
34122
|
this.rl = process.stdin.isTTY ? new LineEditor({
|
|
34129
34123
|
input: process.stdin,
|
|
@@ -34156,9 +34150,9 @@ class Repl {
|
|
|
34156
34150
|
this.setupListeners();
|
|
34157
34151
|
}
|
|
34158
34152
|
loadHistory() {
|
|
34159
|
-
if (
|
|
34153
|
+
if (existsSync52(this.historyPath)) {
|
|
34160
34154
|
try {
|
|
34161
|
-
const raw =
|
|
34155
|
+
const raw = readFileSync34(this.historyPath, "utf-8");
|
|
34162
34156
|
this.history = raw.split(`
|
|
34163
34157
|
`).filter(Boolean).slice(-this.maxHistory);
|
|
34164
34158
|
} catch {
|
|
@@ -34360,14 +34354,13 @@ ${t("image.clipboard_empty")}`));
|
|
|
34360
34354
|
spinner: this.config.ui?.spinner ?? true,
|
|
34361
34355
|
toolStyle: this.config.ui?.toolStyle ?? "inline"
|
|
34362
34356
|
});
|
|
34363
|
-
this.refreshActivePlan(renderer);
|
|
34364
34357
|
const result = await this.agent.run(input, (c) => renderer.text(c), (m) => renderer.meta(m), (ev) => {
|
|
34365
34358
|
if (ev.type === "start") {
|
|
34366
|
-
renderer.toolStart(ev.tool, ev.args, stepContextForTool(this.
|
|
34359
|
+
renderer.toolStart(ev.tool, ev.args, stepContextForTool(this.execModule?.getActivePlan() ?? null, ev.tool, ev.args), ev.icon);
|
|
34367
34360
|
} else {
|
|
34368
34361
|
renderer.toolEnd(ev.tool, ev.duration ?? 0, ev.error, ev.ctxDelta, ev.costUsd);
|
|
34369
34362
|
if (ev.tool === "plan" || ev.tool === "todo") {
|
|
34370
|
-
this.
|
|
34363
|
+
this.renderPlan(renderer);
|
|
34371
34364
|
}
|
|
34372
34365
|
}
|
|
34373
34366
|
}, (phase) => {
|
|
@@ -34392,23 +34385,11 @@ ${t("image.clipboard_empty")}`));
|
|
|
34392
34385
|
this.agentRunning = false;
|
|
34393
34386
|
}
|
|
34394
34387
|
}
|
|
34395
|
-
|
|
34396
|
-
const plan =
|
|
34397
|
-
|
|
34398
|
-
if (!plan) {
|
|
34399
|
-
this.activePlan = null;
|
|
34400
|
-
this.lastPlanSig = "";
|
|
34401
|
-
return;
|
|
34402
|
-
}
|
|
34403
|
-
this.activePlan = plan;
|
|
34404
|
-
if (this.lastPlanSig === null) {
|
|
34405
|
-
this.lastPlanSig = sig;
|
|
34388
|
+
renderPlan(renderer) {
|
|
34389
|
+
const plan = this.execModule?.getActivePlan();
|
|
34390
|
+
if (!plan)
|
|
34406
34391
|
return;
|
|
34407
|
-
|
|
34408
|
-
if (sig !== this.lastPlanSig) {
|
|
34409
|
-
this.lastPlanSig = sig;
|
|
34410
|
-
renderer.planBlock(formatPlanChecklist(plan));
|
|
34411
|
-
}
|
|
34392
|
+
renderer.planBlock(formatPlanChecklist(plan));
|
|
34412
34393
|
}
|
|
34413
34394
|
commands = new Map;
|
|
34414
34395
|
registerCommand(cmd) {
|
|
@@ -34541,11 +34522,11 @@ ${t("image.clipboard_empty")}`));
|
|
|
34541
34522
|
row(t("repl.agents_label"), pc2.red(t("repl.disabled")));
|
|
34542
34523
|
} else {
|
|
34543
34524
|
const agentsMdCandidates = [
|
|
34544
|
-
|
|
34545
|
-
|
|
34546
|
-
|
|
34525
|
+
join48(this.baseDir, "AGENTS.md"),
|
|
34526
|
+
join48(this.baseDir, ".mma", "AGENTS.md"),
|
|
34527
|
+
join48(this.configDir, "AGENTS.md")
|
|
34547
34528
|
];
|
|
34548
|
-
const foundAgents = agentsMdCandidates.filter((p) =>
|
|
34529
|
+
const foundAgents = agentsMdCandidates.filter((p) => existsSync52(p));
|
|
34549
34530
|
if (foundAgents.length > 0) {
|
|
34550
34531
|
for (const p of foundAgents) {
|
|
34551
34532
|
row(t("repl.agents_label"), pc2.dim(p));
|
|
@@ -34556,7 +34537,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
34556
34537
|
}
|
|
34557
34538
|
const meta = this.sessionManager?.getActiveMeta();
|
|
34558
34539
|
if (meta) {
|
|
34559
|
-
const sessionPath =
|
|
34540
|
+
const sessionPath = join48(this.configDir, "sessions", meta.id);
|
|
34560
34541
|
row(t("repl.session_label"), `${pc2.cyan(meta.name)} ${pc2.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc2.dim(sessionPath)}`);
|
|
34561
34542
|
}
|
|
34562
34543
|
const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
|
|
@@ -34655,8 +34636,8 @@ init_setup();
|
|
|
34655
34636
|
init_config2();
|
|
34656
34637
|
init_i18n();
|
|
34657
34638
|
init_colors();
|
|
34658
|
-
import { existsSync as
|
|
34659
|
-
import { join as
|
|
34639
|
+
import { existsSync as existsSync53 } from "fs";
|
|
34640
|
+
import { join as join50 } from "path";
|
|
34660
34641
|
import { homedir as homedir20 } from "os";
|
|
34661
34642
|
|
|
34662
34643
|
// src/modules/updater/index.ts
|
|
@@ -34761,9 +34742,9 @@ init_environment();
|
|
|
34761
34742
|
init_data_sanitizer();
|
|
34762
34743
|
init_i18n();
|
|
34763
34744
|
import { appendFileSync as appendFileSync7, mkdirSync as mkdirSync20 } from "fs";
|
|
34764
|
-
import { join as
|
|
34745
|
+
import { join as join49 } from "path";
|
|
34765
34746
|
import { homedir as homedir19 } from "os";
|
|
34766
|
-
var CRASH_LOG_DIR =
|
|
34747
|
+
var CRASH_LOG_DIR = join49(homedir19(), ".mma", "logs");
|
|
34767
34748
|
var CRASH_LOG_FILE = "crash.jsonl";
|
|
34768
34749
|
function formatCrashEntry(type2, err) {
|
|
34769
34750
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -34779,7 +34760,7 @@ function formatCrashEntry(type2, err) {
|
|
|
34779
34760
|
function writeCrashEntry(dir, entry) {
|
|
34780
34761
|
try {
|
|
34781
34762
|
mkdirSync20(dir, { recursive: true });
|
|
34782
|
-
appendFileSync7(
|
|
34763
|
+
appendFileSync7(join49(dir, CRASH_LOG_FILE), JSON.stringify(entry) + `
|
|
34783
34764
|
`, "utf-8");
|
|
34784
34765
|
} catch {}
|
|
34785
34766
|
}
|
|
@@ -34882,15 +34863,15 @@ async function main() {
|
|
|
34882
34863
|
await updater?.waitForIdle();
|
|
34883
34864
|
process.exit(exitCode);
|
|
34884
34865
|
} else {
|
|
34885
|
-
const configPath =
|
|
34886
|
-
if (!
|
|
34866
|
+
const configPath = join50(homedir20(), ".mma", "config.json");
|
|
34867
|
+
if (!existsSync53(configPath)) {
|
|
34887
34868
|
console.log(pc2.yellow(`
|
|
34888
34869
|
` + t("cli.first_run") + `
|
|
34889
34870
|
`));
|
|
34890
34871
|
const answers = await runSetup();
|
|
34891
34872
|
const config2 = loadConfig({
|
|
34892
|
-
configDir:
|
|
34893
|
-
projectConfigPath: projectDir ?
|
|
34873
|
+
configDir: join50(homedir20(), ".mma"),
|
|
34874
|
+
projectConfigPath: projectDir ? join50(projectDir, ".mmrc") : join50(process.cwd(), ".mmrc")
|
|
34894
34875
|
});
|
|
34895
34876
|
config2.provider.type = answers.provider;
|
|
34896
34877
|
config2.provider.baseUrl = answers.apiBase;
|
|
@@ -34938,13 +34919,14 @@ async function main() {
|
|
|
34938
34919
|
sessionManager,
|
|
34939
34920
|
skillsModule,
|
|
34940
34921
|
pluginManager,
|
|
34922
|
+
execModule,
|
|
34941
34923
|
configDir,
|
|
34942
34924
|
baseDir,
|
|
34943
34925
|
logger,
|
|
34944
34926
|
envReport
|
|
34945
34927
|
} = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
|
|
34946
34928
|
startAutoUpdate(config);
|
|
34947
|
-
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true, envReport);
|
|
34929
|
+
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true, envReport, undefined, execModule);
|
|
34948
34930
|
await repl.start();
|
|
34949
34931
|
}
|
|
34950
34932
|
}
|