micro-models-agent 0.46.2 → 0.47.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/README.md +312 -312
- package/dist/main.js +397 -353
- package/dist/modules/browser/bridge-server.mjs +202 -202
- package/dist/skills/builtin/git.md +36 -36
- package/dist/skills/builtin/typescript.md +35 -35
- package/package.json +48 -48
- package/dist/cli/commands.js +0 -323
- package/dist/cli/completer.js +0 -167
- package/dist/cli/index.js +0 -2
- package/dist/cli/main.js +0 -165
- package/dist/cli/plugin-commands.js +0 -36
- package/dist/cli/repl-commands.js +0 -661
- package/dist/cli/repl.js +0 -616
- package/dist/cli/run-result.js +0 -22
- package/dist/cli/security-commands.js +0 -164
- package/dist/cli/setup.js +0 -231
- package/dist/config/config.js +0 -249
- package/dist/config/defaults.js +0 -124
- package/dist/config/experts.js +0 -15
- package/dist/config/index.js +0 -3
- package/dist/config/security.js +0 -193
- package/dist/config/types.js +0 -1
- package/dist/core/agent-moe.js +0 -102
- package/dist/core/agent.js +0 -886
- package/dist/core/bootstrap.js +0 -404
- package/dist/core/index.js +0 -2
- package/dist/core/prompt-builder.js +0 -76
- package/dist/core/session-logger.js +0 -197
- package/dist/core/types.js +0 -1
- package/dist/core/version.js +0 -24
- package/dist/core/workspace.js +0 -76
- package/dist/i18n/en.json +0 -598
- package/dist/i18n/index.js +0 -46
- package/dist/i18n/ru.json +0 -598
- package/dist/index.js +0 -22
- package/dist/llm/image-utils.js +0 -143
- package/dist/llm/index.js +0 -4
- package/dist/llm/model-loader.js +0 -78
- package/dist/llm/openai-compat.js +0 -359
- package/dist/llm/orchestrator.js +0 -198
- package/dist/llm/provider.js +0 -10
- package/dist/llm/response.js +0 -39
- package/dist/llm/token-counter.js +0 -39
- package/dist/llm/types.js +0 -1
- package/dist/logger/app-logger.js +0 -143
- package/dist/logger/file-log.js +0 -151
- package/dist/logger/index.js +0 -1
- package/dist/migration/backup.js +0 -45
- package/dist/migration/detect.js +0 -50
- package/dist/migration/index.js +0 -2
- package/dist/modules/artifacts/store.js +0 -61
- package/dist/modules/browser/actions.js +0 -76
- package/dist/modules/browser/bridge-client.js +0 -199
- package/dist/modules/browser/bridge-path.js +0 -10
- package/dist/modules/browser/cookie-store.js +0 -24
- package/dist/modules/browser/driver.js +0 -136
- package/dist/modules/browser/index.js +0 -7
- package/dist/modules/browser/module.js +0 -29
- package/dist/modules/browser/session.js +0 -338
- package/dist/modules/browser/snapshot.js +0 -148
- package/dist/modules/browser/types.js +0 -12
- package/dist/modules/certification/cli.js +0 -174
- package/dist/modules/certification/fact-checker.js +0 -82
- package/dist/modules/certification/loader.js +0 -105
- package/dist/modules/certification/manifest.js +0 -50
- package/dist/modules/certification/runner.js +0 -159
- package/dist/modules/certification/scenarios.js +0 -124
- package/dist/modules/certification/types.js +0 -1
- package/dist/modules/context/chunk-query.js +0 -100
- package/dist/modules/context/fact-extractor.js +0 -162
- package/dist/modules/context/history.js +0 -15
- package/dist/modules/context/index.js +0 -1
- package/dist/modules/context/manager.js +0 -423
- package/dist/modules/execution/audit-runners.js +0 -152
- package/dist/modules/execution/auditor.js +0 -218
- package/dist/modules/execution/execution-plugin.js +0 -272
- package/dist/modules/execution/index.js +0 -8
- package/dist/modules/execution/module.js +0 -436
- package/dist/modules/execution/moe-executor.js +0 -291
- package/dist/modules/execution/plan-coverage.js +0 -68
- package/dist/modules/execution/plan-persister.js +0 -46
- package/dist/modules/execution/plan-store.js +0 -157
- package/dist/modules/execution/plan-tool.js +0 -508
- package/dist/modules/execution/plan-validator.js +0 -153
- package/dist/modules/execution/planner.js +0 -90
- package/dist/modules/execution/stuck-detector.js +0 -510
- package/dist/modules/execution/tracker.js +0 -67
- package/dist/modules/execution/types.js +0 -1
- package/dist/modules/execution/verifier.js +0 -222
- package/dist/modules/execution/windows-commands.js +0 -41
- package/dist/modules/hallucination/confidence.js +0 -66
- package/dist/modules/hallucination/consistency.js +0 -26
- package/dist/modules/hallucination/detector.js +0 -43
- package/dist/modules/hallucination/factual.js +0 -129
- package/dist/modules/hallucination/index.js +0 -5
- package/dist/modules/hallucination/js-identifiers.js +0 -262
- package/dist/modules/hallucination/llm-judge.js +0 -101
- package/dist/modules/index.js +0 -5
- package/dist/modules/indexer/cache.js +0 -40
- package/dist/modules/indexer/index.js +0 -3
- package/dist/modules/indexer/module.js +0 -245
- package/dist/modules/indexer/project-profile.js +0 -183
- package/dist/modules/indexer/walker.js +0 -101
- package/dist/modules/lsp/check-tool.js +0 -58
- package/dist/modules/lsp/client.js +0 -278
- package/dist/modules/lsp/command.js +0 -60
- package/dist/modules/lsp/config.js +0 -135
- package/dist/modules/lsp/index.js +0 -3
- package/dist/modules/lsp/module.js +0 -232
- package/dist/modules/lsp/probe.js +0 -76
- package/dist/modules/lsp/project-root.js +0 -32
- package/dist/modules/lsp/startup-check.js +0 -141
- package/dist/modules/lsp/types.js +0 -1
- package/dist/modules/mcp/client.js +0 -399
- package/dist/modules/mcp/index.js +0 -3
- package/dist/modules/mcp/module.js +0 -142
- package/dist/modules/mcp/registry.js +0 -15
- package/dist/modules/memory/index.js +0 -1
- package/dist/modules/memory/module.js +0 -96
- package/dist/modules/memory/search.js +0 -42
- package/dist/modules/memory/store.js +0 -69
- package/dist/modules/pipelines/engine.js +0 -60
- package/dist/modules/pipelines/index.js +0 -3
- package/dist/modules/pipelines/parser.js +0 -56
- package/dist/modules/pipelines/template.js +0 -14
- package/dist/modules/plugins/builtin/lint-on-write.js +0 -231
- package/dist/modules/plugins/builtin/notify.js +0 -9
- package/dist/modules/plugins/index.js +0 -1
- package/dist/modules/plugins/loader.js +0 -70
- package/dist/modules/plugins/manager.js +0 -217
- package/dist/modules/plugins/types.js +0 -1
- package/dist/modules/processes/detect.js +0 -34
- package/dist/modules/processes/index.js +0 -2
- package/dist/modules/processes/registry.js +0 -327
- package/dist/modules/processes/runner.js +0 -23
- package/dist/modules/registry.js +0 -47
- package/dist/modules/security/audit-log.js +0 -136
- package/dist/modules/security/audit-notifier.js +0 -292
- package/dist/modules/security/command-validator.js +0 -205
- package/dist/modules/security/content-scanner.js +0 -53
- package/dist/modules/security/data-sanitizer.js +0 -89
- package/dist/modules/security/encryption.js +0 -242
- package/dist/modules/security/index.js +0 -14
- package/dist/modules/security/network-validator.js +0 -71
- package/dist/modules/security/path-validator.js +0 -207
- package/dist/modules/security/rate-limiter.js +0 -119
- package/dist/modules/security/security-policies.js +0 -531
- package/dist/modules/security/session-encryption.js +0 -210
- package/dist/modules/security/session-isolation.js +0 -95
- package/dist/modules/session/index.js +0 -3
- package/dist/modules/session/manager.js +0 -172
- package/dist/modules/session/module.js +0 -24
- package/dist/modules/session/store.js +0 -222
- package/dist/modules/session/types.js +0 -1
- package/dist/modules/skills/index.js +0 -2
- package/dist/modules/skills/loader.js +0 -72
- package/dist/modules/skills/matcher.js +0 -27
- package/dist/modules/skills/module.js +0 -129
- package/dist/modules/types.js +0 -1
- package/dist/modules/updater/checker.js +0 -96
- package/dist/modules/updater/index.js +0 -2
- package/dist/modules/updater/module.js +0 -116
- package/dist/modules/user-profile/compressor.js +0 -16
- package/dist/modules/user-profile/index.js +0 -1
- package/dist/modules/user-profile/profile.js +0 -68
- package/dist/tools/approve.js +0 -32
- package/dist/tools/attach-image.js +0 -89
- package/dist/tools/bash.js +0 -496
- package/dist/tools/browser.js +0 -114
- package/dist/tools/chunk-query.js +0 -99
- package/dist/tools/create-dir.js +0 -55
- package/dist/tools/delete-file.js +0 -62
- package/dist/tools/download-file.js +0 -116
- package/dist/tools/edit-file.js +0 -79
- package/dist/tools/enable-tools.js +0 -58
- package/dist/tools/executor.js +0 -144
- package/dist/tools/file-info.js +0 -46
- package/dist/tools/filter-tools.js +0 -17
- package/dist/tools/glob-tool.js +0 -26
- package/dist/tools/grep-tool.js +0 -84
- package/dist/tools/hidden-tools-block.js +0 -37
- package/dist/tools/index.js +0 -78
- package/dist/tools/list-dir.js +0 -48
- package/dist/tools/load-skill.js +0 -42
- package/dist/tools/mcp-call.js +0 -68
- package/dist/tools/move-file.js +0 -85
- package/dist/tools/path-utils.js +0 -51
- package/dist/tools/pipeline-run.js +0 -144
- package/dist/tools/preview.js +0 -2
- package/dist/tools/process-kill.js +0 -29
- package/dist/tools/process-list.js +0 -36
- package/dist/tools/process-log.js +0 -45
- package/dist/tools/question.js +0 -140
- package/dist/tools/read-file.js +0 -91
- package/dist/tools/recall.js +0 -117
- package/dist/tools/registry.js +0 -47
- package/dist/tools/remember.js +0 -67
- package/dist/tools/scope-check.js +0 -30
- package/dist/tools/search-history.js +0 -84
- package/dist/tools/subagent.js +0 -196
- package/dist/tools/types.js +0 -1
- package/dist/tools/user-input.js +0 -123
- package/dist/tools/web-browse.js +0 -86
- package/dist/tools/web-fetch.js +0 -98
- package/dist/tools/web-search.js +0 -78
- package/dist/tools/write-file.js +0 -81
- package/dist/ui/box.js +0 -77
- package/dist/ui/colors.js +0 -4
- package/dist/ui/diff.js +0 -178
- package/dist/ui/index.js +0 -6
- package/dist/ui/line-editor.js +0 -703
- package/dist/ui/line-math.js +0 -69
- package/dist/ui/md-formatter.js +0 -212
- package/dist/ui/output.js +0 -13
- package/dist/ui/plan-view.js +0 -103
- package/dist/ui/renderer.js +0 -209
- package/dist/ui/spinner.js +0 -70
- package/dist/ui/table.js +0 -144
package/dist/main.js
CHANGED
|
@@ -8399,6 +8399,9 @@ var init_prompt_builder = __esm(() => {
|
|
|
8399
8399
|
});
|
|
8400
8400
|
|
|
8401
8401
|
// src/core/session-logger.ts
|
|
8402
|
+
import { join as join10 } from "path";
|
|
8403
|
+
import { readFileSync as readFileSync9, existsSync as existsSync18 } from "fs";
|
|
8404
|
+
|
|
8402
8405
|
class SessionLogger {
|
|
8403
8406
|
session;
|
|
8404
8407
|
logger;
|
|
@@ -8582,6 +8585,28 @@ class SessionLogger {
|
|
|
8582
8585
|
...iteration !== undefined ? { iteration } : {}
|
|
8583
8586
|
});
|
|
8584
8587
|
}
|
|
8588
|
+
logSessionStart(data) {
|
|
8589
|
+
const meta = this.session?.getActiveMeta();
|
|
8590
|
+
if (meta) {
|
|
8591
|
+
const logPath = join10(this.session.getSessionDirectory(meta.id), "session.jsonl");
|
|
8592
|
+
try {
|
|
8593
|
+
if (existsSync18(logPath)) {
|
|
8594
|
+
const content = readFileSync9(logPath, "utf-8");
|
|
8595
|
+
if (content.includes('"type":"session_start"'))
|
|
8596
|
+
return;
|
|
8597
|
+
}
|
|
8598
|
+
} catch {}
|
|
8599
|
+
}
|
|
8600
|
+
this.session?.appendLog({
|
|
8601
|
+
ts: new Date().toISOString(),
|
|
8602
|
+
type: "session_start",
|
|
8603
|
+
content: "session started",
|
|
8604
|
+
environment: data.environment,
|
|
8605
|
+
lspProbe: data.lspProbe,
|
|
8606
|
+
plugins: data.plugins,
|
|
8607
|
+
skills: data.skills
|
|
8608
|
+
});
|
|
8609
|
+
}
|
|
8585
8610
|
}
|
|
8586
8611
|
var init_session_logger = __esm(() => {
|
|
8587
8612
|
init_audit_log();
|
|
@@ -10238,7 +10263,7 @@ var init_stuck_detector = __esm(() => {
|
|
|
10238
10263
|
});
|
|
10239
10264
|
|
|
10240
10265
|
// src/modules/artifacts/store.ts
|
|
10241
|
-
import { existsSync as
|
|
10266
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync7 } from "node:fs";
|
|
10242
10267
|
import { resolve as resolve10, relative, isAbsolute } from "node:path";
|
|
10243
10268
|
|
|
10244
10269
|
class ArtifactStore {
|
|
@@ -10276,9 +10301,9 @@ class ArtifactStore {
|
|
|
10276
10301
|
const abs = resolve10(this.root, path);
|
|
10277
10302
|
if (!ArtifactStore.isInside(this.root, abs))
|
|
10278
10303
|
return null;
|
|
10279
|
-
if (!
|
|
10304
|
+
if (!existsSync19(abs))
|
|
10280
10305
|
return null;
|
|
10281
|
-
return
|
|
10306
|
+
return readFileSync10(abs, "utf8");
|
|
10282
10307
|
}
|
|
10283
10308
|
summary(content, maxChars) {
|
|
10284
10309
|
if (content.length <= maxChars)
|
|
@@ -10592,15 +10617,15 @@ var init_moe_executor = __esm(() => {
|
|
|
10592
10617
|
});
|
|
10593
10618
|
|
|
10594
10619
|
// src/modules/lsp/project-root.ts
|
|
10595
|
-
import { existsSync as
|
|
10596
|
-
import { dirname as dirname6, join as
|
|
10620
|
+
import { existsSync as existsSync20 } from "fs";
|
|
10621
|
+
import { dirname as dirname6, join as join11 } from "path";
|
|
10597
10622
|
function findProjectRoot(filePath, baseDir, markers) {
|
|
10598
10623
|
if (!markers || markers.length === 0)
|
|
10599
10624
|
return baseDir;
|
|
10600
10625
|
let dir = dirname6(filePath);
|
|
10601
10626
|
const root = baseDir.replace(/[\\/]+$/, "");
|
|
10602
10627
|
while (true) {
|
|
10603
|
-
if (markers.some((m) =>
|
|
10628
|
+
if (markers.some((m) => existsSync20(join11(dir, m)))) {
|
|
10604
10629
|
return dir;
|
|
10605
10630
|
}
|
|
10606
10631
|
if (dir === root)
|
|
@@ -10823,13 +10848,13 @@ var init_js_identifiers = __esm(() => {
|
|
|
10823
10848
|
});
|
|
10824
10849
|
|
|
10825
10850
|
// src/modules/execution/audit-runners.ts
|
|
10826
|
-
import { existsSync as
|
|
10827
|
-
import { dirname as dirname7, join as
|
|
10851
|
+
import { existsSync as existsSync21, readdirSync as readdirSync5, readFileSync as readFileSync11 } from "fs";
|
|
10852
|
+
import { dirname as dirname7, join as join12, resolve as resolve11 } from "path";
|
|
10828
10853
|
function resolveTestCommand(dir) {
|
|
10829
|
-
const pkgPath =
|
|
10830
|
-
if (
|
|
10854
|
+
const pkgPath = join12(dir, "package.json");
|
|
10855
|
+
if (existsSync21(pkgPath)) {
|
|
10831
10856
|
try {
|
|
10832
|
-
const pkg = JSON.parse(
|
|
10857
|
+
const pkg = JSON.parse(readFileSync11(pkgPath, "utf-8"));
|
|
10833
10858
|
const script = pkg?.scripts?.test;
|
|
10834
10859
|
if (typeof script === "string" && script.trim())
|
|
10835
10860
|
return script.trim();
|
|
@@ -10845,7 +10870,7 @@ function resolveTestCommand(dir) {
|
|
|
10845
10870
|
"jest.config.cjs",
|
|
10846
10871
|
"bunfig.toml"
|
|
10847
10872
|
]) {
|
|
10848
|
-
if (
|
|
10873
|
+
if (existsSync21(join12(dir, f))) {
|
|
10849
10874
|
if (f.startsWith("vitest"))
|
|
10850
10875
|
return "bunx vitest run";
|
|
10851
10876
|
if (f.startsWith("jest"))
|
|
@@ -10854,12 +10879,12 @@ function resolveTestCommand(dir) {
|
|
|
10854
10879
|
return "bun test";
|
|
10855
10880
|
}
|
|
10856
10881
|
}
|
|
10857
|
-
if (
|
|
10882
|
+
if (existsSync21(join12(dir, "pyproject.toml")) || existsSync21(join12(dir, "pytest.ini")) || existsSync21(join12(dir, "conftest.py"))) {
|
|
10858
10883
|
return "python -m pytest -q";
|
|
10859
10884
|
}
|
|
10860
|
-
if (
|
|
10885
|
+
if (existsSync21(join12(dir, "go.mod")))
|
|
10861
10886
|
return "go test ./...";
|
|
10862
|
-
if (
|
|
10887
|
+
if (existsSync21(join12(dir, "Cargo.toml")))
|
|
10863
10888
|
return "cargo test";
|
|
10864
10889
|
return "bun test";
|
|
10865
10890
|
}
|
|
@@ -10873,7 +10898,7 @@ function findTestFile(dir, depth = 0) {
|
|
|
10873
10898
|
return null;
|
|
10874
10899
|
}
|
|
10875
10900
|
for (const e of entries) {
|
|
10876
|
-
const full =
|
|
10901
|
+
const full = join12(dir, e.name);
|
|
10877
10902
|
if (e.isDirectory()) {
|
|
10878
10903
|
if (SKIP_DIRS.has(e.name))
|
|
10879
10904
|
continue;
|
|
@@ -10949,7 +10974,7 @@ function findTypecheckRoot(baseDir, existingFiles = []) {
|
|
|
10949
10974
|
for (const start of candidates) {
|
|
10950
10975
|
let dir = resolve11(start);
|
|
10951
10976
|
for (let depth = 0;depth <= 10; depth++) {
|
|
10952
|
-
if (
|
|
10977
|
+
if (existsSync21(join12(dir, "tsconfig.json"))) {
|
|
10953
10978
|
if (!best || depth < best.depth)
|
|
10954
10979
|
best = { depth, root: dir };
|
|
10955
10980
|
break;
|
|
@@ -10993,11 +11018,11 @@ var init_audit_runners = __esm(() => {
|
|
|
10993
11018
|
});
|
|
10994
11019
|
|
|
10995
11020
|
// src/modules/execution/auditor.ts
|
|
10996
|
-
import { existsSync as
|
|
10997
|
-
import { resolve as resolve12, join as
|
|
11021
|
+
import { existsSync as existsSync22, readdirSync as readdirSync6 } from "fs";
|
|
11022
|
+
import { resolve as resolve12, join as join13, basename as basename2 } from "path";
|
|
10998
11023
|
function findExistingFile(baseDir, filePath) {
|
|
10999
11024
|
const direct = resolve12(baseDir, filePath);
|
|
11000
|
-
if (
|
|
11025
|
+
if (existsSync22(direct))
|
|
11001
11026
|
return direct;
|
|
11002
11027
|
const name = basename2(filePath).toLowerCase();
|
|
11003
11028
|
const suffix = filePath.replace(/\\/g, "/").toLowerCase();
|
|
@@ -11014,7 +11039,7 @@ function findExistingFile(baseDir, filePath) {
|
|
|
11014
11039
|
for (const e of entries) {
|
|
11015
11040
|
if (found)
|
|
11016
11041
|
return;
|
|
11017
|
-
const full =
|
|
11042
|
+
const full = join13(dir, e.name);
|
|
11018
11043
|
if (e.isDirectory()) {
|
|
11019
11044
|
if (SKIP_DIRS.has(e.name))
|
|
11020
11045
|
continue;
|
|
@@ -11152,8 +11177,8 @@ var init_auditor = __esm(() => {
|
|
|
11152
11177
|
});
|
|
11153
11178
|
|
|
11154
11179
|
// src/modules/execution/verifier.ts
|
|
11155
|
-
import { existsSync as
|
|
11156
|
-
import { resolve as resolve13, extname as extname2, join as
|
|
11180
|
+
import { existsSync as existsSync23 } from "fs";
|
|
11181
|
+
import { resolve as resolve13, extname as extname2, join as join14 } from "path";
|
|
11157
11182
|
import { spawn as spawn2 } from "child_process";
|
|
11158
11183
|
|
|
11159
11184
|
class StepVerifier {
|
|
@@ -11163,7 +11188,7 @@ class StepVerifier {
|
|
|
11163
11188
|
}
|
|
11164
11189
|
async checkFileExists(path) {
|
|
11165
11190
|
const resolved = resolve13(this.baseDir, path);
|
|
11166
|
-
const exists =
|
|
11191
|
+
const exists = existsSync23(resolved);
|
|
11167
11192
|
return {
|
|
11168
11193
|
passed: exists,
|
|
11169
11194
|
message: exists ? t("verify.file_exists", { path }) : t("verify.file_not_found", { path })
|
|
@@ -11182,7 +11207,7 @@ class StepVerifier {
|
|
|
11182
11207
|
}
|
|
11183
11208
|
async runTypeCheck() {
|
|
11184
11209
|
const tsconfigPath = resolve13(this.baseDir, "tsconfig.json");
|
|
11185
|
-
if (!
|
|
11210
|
+
if (!existsSync23(tsconfigPath)) {
|
|
11186
11211
|
return { passed: true, message: "No tsconfig.json found — skipping type check" };
|
|
11187
11212
|
}
|
|
11188
11213
|
try {
|
|
@@ -11195,8 +11220,8 @@ class StepVerifier {
|
|
|
11195
11220
|
}
|
|
11196
11221
|
async runTypeCheckForFile(filePath) {
|
|
11197
11222
|
const projectRoot = findProjectRoot(filePath, this.baseDir, ["tsconfig.json", "package.json"]);
|
|
11198
|
-
const tsconfigPath =
|
|
11199
|
-
if (!
|
|
11223
|
+
const tsconfigPath = join14(projectRoot, "tsconfig.json");
|
|
11224
|
+
if (!existsSync23(tsconfigPath)) {
|
|
11200
11225
|
return { passed: true, message: "No tsconfig.json found — skipping type check" };
|
|
11201
11226
|
}
|
|
11202
11227
|
try {
|
|
@@ -11209,7 +11234,7 @@ class StepVerifier {
|
|
|
11209
11234
|
}
|
|
11210
11235
|
async runTests() {
|
|
11211
11236
|
const pkgPath = resolve13(this.baseDir, "package.json");
|
|
11212
|
-
if (!
|
|
11237
|
+
if (!existsSync23(pkgPath)) {
|
|
11213
11238
|
return { passed: true, message: "No package.json found — skipping tests" };
|
|
11214
11239
|
}
|
|
11215
11240
|
try {
|
|
@@ -11756,6 +11781,9 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
11756
11781
|
logger.debug(`Session started: ${sessionManager.getActive()}`);
|
|
11757
11782
|
}
|
|
11758
11783
|
if (!this.systemPromptAdded && !contextManager.getActiveHistory().some((m) => m.role === "system")) {
|
|
11784
|
+
slog.logSessionStart({
|
|
11785
|
+
environment: this.deps.envReport
|
|
11786
|
+
});
|
|
11759
11787
|
const lazy = this.deps.lazyPromptBlocks ? await this.deps.lazyPromptBlocks() : [];
|
|
11760
11788
|
if (lazy.length > 0) {
|
|
11761
11789
|
this.deps.promptBlocks.push(...lazy);
|
|
@@ -11772,17 +11800,6 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
11772
11800
|
sessionManager: sessionManager?.getActiveMeta(),
|
|
11773
11801
|
contextManager
|
|
11774
11802
|
});
|
|
11775
|
-
if (config.session?.baselineCheck !== false) {
|
|
11776
|
-
const verifier = new StepVerifier(baseDir);
|
|
11777
|
-
verifier.runTypeCheck().then((tc) => {
|
|
11778
|
-
if (!tc.passed) {
|
|
11779
|
-
logger.warn(`Baseline typecheck has issues: ${tc.message?.slice(0, 500)}`);
|
|
11780
|
-
onMeta?.(pc2.yellow(`
|
|
11781
|
-
⚠ Baseline typecheck has issues
|
|
11782
|
-
`));
|
|
11783
|
-
}
|
|
11784
|
-
}).catch(() => {});
|
|
11785
|
-
}
|
|
11786
11803
|
}
|
|
11787
11804
|
if (typeof contextManager.resetUserTurn === "function") {
|
|
11788
11805
|
contextManager.resetUserTurn();
|
|
@@ -12426,7 +12443,6 @@ var init_agent = __esm(() => {
|
|
|
12426
12443
|
init_processes();
|
|
12427
12444
|
init_session_logger();
|
|
12428
12445
|
init_agent_moe();
|
|
12429
|
-
init_verifier();
|
|
12430
12446
|
init_pricing();
|
|
12431
12447
|
});
|
|
12432
12448
|
|
|
@@ -12983,8 +12999,8 @@ var init_confidence = __esm(() => {
|
|
|
12983
12999
|
});
|
|
12984
13000
|
|
|
12985
13001
|
// src/modules/hallucination/factual.ts
|
|
12986
|
-
import { existsSync as
|
|
12987
|
-
import { resolve as resolve14, isAbsolute as isAbsolute2, join as
|
|
13002
|
+
import { existsSync as existsSync24, readdirSync as readdirSync7 } from "fs";
|
|
13003
|
+
import { resolve as resolve14, isAbsolute as isAbsolute2, join as join15 } from "path";
|
|
12988
13004
|
|
|
12989
13005
|
class FactualCheck {
|
|
12990
13006
|
baseDir;
|
|
@@ -13024,16 +13040,16 @@ class FactualCheck {
|
|
|
13024
13040
|
}
|
|
13025
13041
|
pathExists(fp) {
|
|
13026
13042
|
if (isAbsolute2(fp))
|
|
13027
|
-
return
|
|
13043
|
+
return existsSync24(fp);
|
|
13028
13044
|
if (this.knownFiles.has(fp))
|
|
13029
13045
|
return true;
|
|
13030
13046
|
if (!fp.includes("/") && !fp.includes("\\")) {
|
|
13031
13047
|
return this.bareNameExists(fp);
|
|
13032
13048
|
}
|
|
13033
|
-
return
|
|
13049
|
+
return existsSync24(resolve14(this.baseDir, fp));
|
|
13034
13050
|
}
|
|
13035
13051
|
bareNameExists(name) {
|
|
13036
|
-
if (
|
|
13052
|
+
if (existsSync24(resolve14(this.baseDir, name)))
|
|
13037
13053
|
return true;
|
|
13038
13054
|
if (this.indexHas(name))
|
|
13039
13055
|
return true;
|
|
@@ -13078,7 +13094,7 @@ class FactualCheck {
|
|
|
13078
13094
|
for (const entry of entries) {
|
|
13079
13095
|
if (count >= FactualCheck.MAX_INDEXED_FILES)
|
|
13080
13096
|
break;
|
|
13081
|
-
const full =
|
|
13097
|
+
const full = join15(dir, entry.name);
|
|
13082
13098
|
if (entry.isDirectory()) {
|
|
13083
13099
|
if (!IGNORED_DIRS.has(entry.name)) {
|
|
13084
13100
|
count = this.scanDir(full, index, count);
|
|
@@ -13252,8 +13268,8 @@ var init_detector = __esm(() => {
|
|
|
13252
13268
|
});
|
|
13253
13269
|
|
|
13254
13270
|
// src/modules/lsp/command.ts
|
|
13255
|
-
import { delimiter, join as
|
|
13256
|
-
import { existsSync as
|
|
13271
|
+
import { delimiter, join as join16 } from "path";
|
|
13272
|
+
import { existsSync as existsSync25 } from "fs";
|
|
13257
13273
|
import { platform as platform3 } from "os";
|
|
13258
13274
|
function resolveSpawnCommand(command, platformName = platform3(), pathEnv = process.env.PATH ?? "") {
|
|
13259
13275
|
if (platformName !== "win32")
|
|
@@ -13264,8 +13280,8 @@ function resolveSpawnCommand(command, platformName = platform3(), pathEnv = proc
|
|
|
13264
13280
|
const dirs = pathEnv.split(delimiter).filter(Boolean);
|
|
13265
13281
|
for (const dir of dirs) {
|
|
13266
13282
|
for (const ext of WIN_EXTS) {
|
|
13267
|
-
const candidate =
|
|
13268
|
-
if (
|
|
13283
|
+
const candidate = join16(dir, `${command}${ext}`);
|
|
13284
|
+
if (existsSync25(candidate))
|
|
13269
13285
|
return `${command}${ext}`;
|
|
13270
13286
|
}
|
|
13271
13287
|
}
|
|
@@ -13861,7 +13877,7 @@ ${joined}` }
|
|
|
13861
13877
|
var DEFAULT_CHUNK_SYSTEM_PROMPT = 'Answer the query using ONLY the provided text. Be concise. If the text does not contain the answer, say "NO_EVIDENCE".', DEFAULT_SYNTHESIS_SYSTEM_PROMPT = "You are given a query and per-chunk answers over a large text. Produce the final answer to the query, combining evidence from the chunks. If no chunk had evidence, say so.";
|
|
13862
13878
|
|
|
13863
13879
|
// src/tools/chunk-query.ts
|
|
13864
|
-
import { readFileSync as
|
|
13880
|
+
import { readFileSync as readFileSync12 } from "node:fs";
|
|
13865
13881
|
import { resolve as resolve16 } from "node:path";
|
|
13866
13882
|
var chunkQueryTool;
|
|
13867
13883
|
var init_chunk_query = __esm(() => {
|
|
@@ -13931,7 +13947,7 @@ var init_chunk_query = __esm(() => {
|
|
|
13931
13947
|
return { success: false, output: `[SCOPE] ${check.reason || "Path not allowed"}` };
|
|
13932
13948
|
}
|
|
13933
13949
|
try {
|
|
13934
|
-
content =
|
|
13950
|
+
content = readFileSync12(resolve16(ctx.baseDir, inputPath), "utf8");
|
|
13935
13951
|
} catch (e) {
|
|
13936
13952
|
return { success: false, output: `Cannot read ${inputPath}: ${e.message}` };
|
|
13937
13953
|
}
|
|
@@ -15224,7 +15240,7 @@ ${JSON.stringify(result, null, 2)}`
|
|
|
15224
15240
|
|
|
15225
15241
|
// src/tools/search-history.ts
|
|
15226
15242
|
import * as fs from "fs";
|
|
15227
|
-
import { join as
|
|
15243
|
+
import { join as join17 } from "path";
|
|
15228
15244
|
import { homedir as homedir5 } from "os";
|
|
15229
15245
|
function searchFile(filePath, query, maxResults, results) {
|
|
15230
15246
|
if (!fs.existsSync(filePath))
|
|
@@ -15269,7 +15285,7 @@ var init_search_history = __esm(() => {
|
|
|
15269
15285
|
const query = String(args.query || "").toLowerCase();
|
|
15270
15286
|
const maxResults = Number(args.maxResults) || 5;
|
|
15271
15287
|
const sessionId = args.sessionId ? String(args.sessionId) : null;
|
|
15272
|
-
const sessionDir =
|
|
15288
|
+
const sessionDir = join17(homedir5(), ".mma", "sessions");
|
|
15273
15289
|
const results = [];
|
|
15274
15290
|
try {
|
|
15275
15291
|
if (!fs.existsSync(sessionDir)) {
|
|
@@ -15284,7 +15300,7 @@ var init_search_history = __esm(() => {
|
|
|
15284
15300
|
continue;
|
|
15285
15301
|
if (sessionId && entry.name !== sessionId)
|
|
15286
15302
|
continue;
|
|
15287
|
-
const historyFile =
|
|
15303
|
+
const historyFile = join17(sessionDir, entry.name, "history.jsonl");
|
|
15288
15304
|
searchFile(historyFile, query, maxResults, results);
|
|
15289
15305
|
if (results.length >= maxResults)
|
|
15290
15306
|
break;
|
|
@@ -15311,8 +15327,8 @@ var init_search_history = __esm(() => {
|
|
|
15311
15327
|
});
|
|
15312
15328
|
|
|
15313
15329
|
// src/modules/memory/search.ts
|
|
15314
|
-
import { readFileSync as
|
|
15315
|
-
import { join as
|
|
15330
|
+
import { readFileSync as readFileSync14, existsSync as existsSync27 } from "fs";
|
|
15331
|
+
import { join as join18 } from "path";
|
|
15316
15332
|
|
|
15317
15333
|
class MemorySearch {
|
|
15318
15334
|
memoryDir;
|
|
@@ -15323,10 +15339,10 @@ class MemorySearch {
|
|
|
15323
15339
|
const results = [];
|
|
15324
15340
|
const lowerQuery = query.toLowerCase();
|
|
15325
15341
|
for (const name of MEMORY_FILES) {
|
|
15326
|
-
const path =
|
|
15327
|
-
if (!
|
|
15342
|
+
const path = join18(this.memoryDir, `${name}.md`);
|
|
15343
|
+
if (!existsSync27(path))
|
|
15328
15344
|
continue;
|
|
15329
|
-
const content =
|
|
15345
|
+
const content = readFileSync14(path, "utf-8");
|
|
15330
15346
|
const lines = content.split(`
|
|
15331
15347
|
`);
|
|
15332
15348
|
for (const line of lines) {
|
|
@@ -15335,10 +15351,10 @@ class MemorySearch {
|
|
|
15335
15351
|
}
|
|
15336
15352
|
}
|
|
15337
15353
|
}
|
|
15338
|
-
const prefsPath =
|
|
15339
|
-
if (
|
|
15354
|
+
const prefsPath = join18(this.memoryDir, "preferences.json");
|
|
15355
|
+
if (existsSync27(prefsPath)) {
|
|
15340
15356
|
try {
|
|
15341
|
-
const prefs = JSON.parse(
|
|
15357
|
+
const prefs = JSON.parse(readFileSync14(prefsPath, "utf-8"));
|
|
15342
15358
|
for (const [key, value] of Object.entries(prefs)) {
|
|
15343
15359
|
const searchStr = `${key}=${value}`;
|
|
15344
15360
|
if (searchStr.toLowerCase().includes(lowerQuery)) {
|
|
@@ -15356,8 +15372,8 @@ var init_search = __esm(() => {
|
|
|
15356
15372
|
});
|
|
15357
15373
|
|
|
15358
15374
|
// src/modules/memory/store.ts
|
|
15359
|
-
import { readFileSync as
|
|
15360
|
-
import { join as
|
|
15375
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync9, appendFileSync as appendFileSync5, existsSync as existsSync28, mkdirSync as mkdirSync13 } from "fs";
|
|
15376
|
+
import { join as join19 } from "path";
|
|
15361
15377
|
|
|
15362
15378
|
class MemoryStore {
|
|
15363
15379
|
memoryDir;
|
|
@@ -15365,8 +15381,8 @@ class MemoryStore {
|
|
|
15365
15381
|
this.memoryDir = memoryDir;
|
|
15366
15382
|
this.ensureDir();
|
|
15367
15383
|
for (const name of MEMORY_FILES2) {
|
|
15368
|
-
const path =
|
|
15369
|
-
if (!
|
|
15384
|
+
const path = join19(this.memoryDir, `${name}.md`);
|
|
15385
|
+
if (!existsSync28(path)) {
|
|
15370
15386
|
writeFileSync9(path, `# ${name.charAt(0).toUpperCase() + name.slice(1)}
|
|
15371
15387
|
|
|
15372
15388
|
`, "utf-8");
|
|
@@ -15374,18 +15390,18 @@ class MemoryStore {
|
|
|
15374
15390
|
}
|
|
15375
15391
|
}
|
|
15376
15392
|
ensureDir() {
|
|
15377
|
-
if (!
|
|
15393
|
+
if (!existsSync28(this.memoryDir)) {
|
|
15378
15394
|
mkdirSync13(this.memoryDir, { recursive: true });
|
|
15379
15395
|
}
|
|
15380
15396
|
}
|
|
15381
15397
|
read(name) {
|
|
15382
|
-
const path =
|
|
15383
|
-
if (!
|
|
15398
|
+
const path = join19(this.memoryDir, `${name}.md`);
|
|
15399
|
+
if (!existsSync28(path))
|
|
15384
15400
|
return "";
|
|
15385
|
-
return
|
|
15401
|
+
return readFileSync15(path, "utf-8");
|
|
15386
15402
|
}
|
|
15387
15403
|
append(name, entry) {
|
|
15388
|
-
const path =
|
|
15404
|
+
const path = join19(this.memoryDir, `${name}.md`);
|
|
15389
15405
|
const timestamp = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
15390
15406
|
const formatted = `- **${timestamp}** — ${entry}
|
|
15391
15407
|
`;
|
|
@@ -15396,14 +15412,14 @@ class MemoryStore {
|
|
|
15396
15412
|
return searchModule.query(query);
|
|
15397
15413
|
}
|
|
15398
15414
|
prefsPath() {
|
|
15399
|
-
return
|
|
15415
|
+
return join19(this.memoryDir, "preferences.json");
|
|
15400
15416
|
}
|
|
15401
15417
|
getPreferences() {
|
|
15402
15418
|
const path = this.prefsPath();
|
|
15403
|
-
if (!
|
|
15419
|
+
if (!existsSync28(path))
|
|
15404
15420
|
return {};
|
|
15405
15421
|
try {
|
|
15406
|
-
return JSON.parse(
|
|
15422
|
+
return JSON.parse(readFileSync15(path, "utf-8"));
|
|
15407
15423
|
} catch {
|
|
15408
15424
|
return {};
|
|
15409
15425
|
}
|
|
@@ -15436,7 +15452,7 @@ var init_store2 = __esm(() => {
|
|
|
15436
15452
|
|
|
15437
15453
|
// src/tools/remember.ts
|
|
15438
15454
|
import { homedir as homedir6 } from "os";
|
|
15439
|
-
import { join as
|
|
15455
|
+
import { join as join20 } from "path";
|
|
15440
15456
|
var CATEGORIES, rememberTool;
|
|
15441
15457
|
var init_remember = __esm(() => {
|
|
15442
15458
|
init_i18n();
|
|
@@ -15475,7 +15491,7 @@ var init_remember = __esm(() => {
|
|
|
15475
15491
|
if (!CATEGORIES.includes(category)) {
|
|
15476
15492
|
return { success: false, output: t("tool.invalid_params") };
|
|
15477
15493
|
}
|
|
15478
|
-
const memoryDir =
|
|
15494
|
+
const memoryDir = join20(homedir6(), ".mma", "memory");
|
|
15479
15495
|
const store = new MemoryStore(memoryDir);
|
|
15480
15496
|
try {
|
|
15481
15497
|
if (category === "preferences") {
|
|
@@ -15508,7 +15524,7 @@ var init_remember = __esm(() => {
|
|
|
15508
15524
|
|
|
15509
15525
|
// src/tools/recall.ts
|
|
15510
15526
|
import { homedir as homedir7 } from "os";
|
|
15511
|
-
import { join as
|
|
15527
|
+
import { join as join21 } from "path";
|
|
15512
15528
|
function formatAll(store) {
|
|
15513
15529
|
const parts = [];
|
|
15514
15530
|
const prefs = store.getPreferences();
|
|
@@ -15592,7 +15608,7 @@ var init_recall = __esm(() => {
|
|
|
15592
15608
|
handler: async (_ctx, args) => {
|
|
15593
15609
|
const query = args.query ? String(args.query) : "";
|
|
15594
15610
|
const category = args.category ? String(args.category) : "";
|
|
15595
|
-
const memoryDir =
|
|
15611
|
+
const memoryDir = join21(homedir7(), ".mma", "memory");
|
|
15596
15612
|
const store = new MemoryStore(memoryDir);
|
|
15597
15613
|
try {
|
|
15598
15614
|
if (!query && !category) {
|
|
@@ -15630,9 +15646,9 @@ var init_recall = __esm(() => {
|
|
|
15630
15646
|
});
|
|
15631
15647
|
|
|
15632
15648
|
// src/modules/browser/bridge-path.ts
|
|
15633
|
-
import { existsSync as
|
|
15649
|
+
import { existsSync as existsSync29 } from "fs";
|
|
15634
15650
|
function pickExistingPath(candidates, fallback = candidates[0]) {
|
|
15635
|
-
return candidates.find((p) =>
|
|
15651
|
+
return candidates.find((p) => existsSync29(p)) ?? fallback;
|
|
15636
15652
|
}
|
|
15637
15653
|
var init_bridge_path = () => {};
|
|
15638
15654
|
|
|
@@ -15643,13 +15659,13 @@ __export(exports_bridge_client, {
|
|
|
15643
15659
|
});
|
|
15644
15660
|
import { spawn as spawn4 } from "child_process";
|
|
15645
15661
|
import { createInterface } from "readline";
|
|
15646
|
-
import { dirname as dirname10, join as
|
|
15662
|
+
import { dirname as dirname10, join as join22 } from "path";
|
|
15647
15663
|
import { fileURLToPath } from "url";
|
|
15648
15664
|
function bridgeScriptPath() {
|
|
15649
15665
|
const dir = dirname10(fileURLToPath(import.meta.url));
|
|
15650
15666
|
const candidates = [
|
|
15651
|
-
|
|
15652
|
-
|
|
15667
|
+
join22(dir, "bridge-server.mjs"),
|
|
15668
|
+
join22(dir, "modules", "browser", "bridge-server.mjs")
|
|
15653
15669
|
];
|
|
15654
15670
|
return pickExistingPath(candidates);
|
|
15655
15671
|
}
|
|
@@ -16203,15 +16219,15 @@ function buildTextExtractionScript() {
|
|
|
16203
16219
|
|
|
16204
16220
|
// src/modules/browser/cookie-store.ts
|
|
16205
16221
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
16206
|
-
import { join as
|
|
16222
|
+
import { join as join23 } from "path";
|
|
16207
16223
|
|
|
16208
16224
|
class CookieStore {
|
|
16209
16225
|
filePath;
|
|
16210
16226
|
constructor(cookieDir) {
|
|
16211
|
-
this.filePath =
|
|
16227
|
+
this.filePath = join23(cookieDir, "cookies.json");
|
|
16212
16228
|
}
|
|
16213
16229
|
async save(cookies) {
|
|
16214
|
-
await mkdir(
|
|
16230
|
+
await mkdir(join23(this.filePath, ".."), { recursive: true });
|
|
16215
16231
|
await writeFile(this.filePath, JSON.stringify(cookies, null, 2), "utf-8");
|
|
16216
16232
|
}
|
|
16217
16233
|
async load() {
|
|
@@ -16566,10 +16582,10 @@ var init_session = __esm(() => {
|
|
|
16566
16582
|
});
|
|
16567
16583
|
|
|
16568
16584
|
// src/tools/browser.ts
|
|
16569
|
-
import { join as
|
|
16585
|
+
import { join as join24 } from "path";
|
|
16570
16586
|
function getSession(ctx) {
|
|
16571
16587
|
if (!session) {
|
|
16572
|
-
const cookieDir =
|
|
16588
|
+
const cookieDir = join24(ctx.baseDir, ".mma", "browser");
|
|
16573
16589
|
session = new BrowserSession({
|
|
16574
16590
|
...DEFAULT_BROWSER_CONFIG,
|
|
16575
16591
|
headless: ctx.config.browser?.headless ?? true,
|
|
@@ -16695,7 +16711,7 @@ __export(exports_image_utils, {
|
|
|
16695
16711
|
detectMime: () => detectMime,
|
|
16696
16712
|
bufferToDataUrl: () => bufferToDataUrl
|
|
16697
16713
|
});
|
|
16698
|
-
import { readFileSync as
|
|
16714
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
16699
16715
|
import { extname as extname3 } from "path";
|
|
16700
16716
|
function detectMime(filePath) {
|
|
16701
16717
|
const ext = extname3(filePath).toLowerCase();
|
|
@@ -16716,9 +16732,9 @@ async function readClipboardImage() {
|
|
|
16716
16732
|
async function readClipboardFallback() {
|
|
16717
16733
|
const { platform: platform5 } = await import("os");
|
|
16718
16734
|
const { execSync } = await import("child_process");
|
|
16719
|
-
const { readFileSync:
|
|
16720
|
-
const { join:
|
|
16721
|
-
const tmpPath =
|
|
16735
|
+
const { readFileSync: readFileSync17, unlinkSync: unlinkSync4 } = await import("fs");
|
|
16736
|
+
const { join: join25 } = await import("path");
|
|
16737
|
+
const tmpPath = join25(process.env.TEMP || process.env.TMP || "/tmp", `mma-clip-${Date.now()}.png`);
|
|
16722
16738
|
try {
|
|
16723
16739
|
if (platform5() === "linux") {
|
|
16724
16740
|
execSync(`xclip -selection clipboard -t image/png -o > "${tmpPath}" 2>/dev/null`, {
|
|
@@ -16727,7 +16743,7 @@ async function readClipboardFallback() {
|
|
|
16727
16743
|
} else {
|
|
16728
16744
|
return null;
|
|
16729
16745
|
}
|
|
16730
|
-
const buf =
|
|
16746
|
+
const buf = readFileSync17(tmpPath);
|
|
16731
16747
|
unlinkSync4(tmpPath);
|
|
16732
16748
|
return buf.length > 0 ? buf : null;
|
|
16733
16749
|
} catch {
|
|
@@ -16738,7 +16754,7 @@ async function readClipboardFallback() {
|
|
|
16738
16754
|
}
|
|
16739
16755
|
}
|
|
16740
16756
|
async function loadFileAsDataUrl(filePath) {
|
|
16741
|
-
const buf =
|
|
16757
|
+
const buf = readFileSync16(filePath);
|
|
16742
16758
|
if (typeof Bun !== "undefined" && typeof Bun.Image !== "undefined") {
|
|
16743
16759
|
try {
|
|
16744
16760
|
const img = new Bun.Image(buf);
|
|
@@ -16798,7 +16814,7 @@ var init_image_utils = __esm(() => {
|
|
|
16798
16814
|
});
|
|
16799
16815
|
|
|
16800
16816
|
// src/tools/attach-image.ts
|
|
16801
|
-
import { existsSync as
|
|
16817
|
+
import { existsSync as existsSync30 } from "fs";
|
|
16802
16818
|
import { resolve as resolve17 } from "path";
|
|
16803
16819
|
var attachImageTool;
|
|
16804
16820
|
var init_attach_image = __esm(() => {
|
|
@@ -16842,7 +16858,7 @@ var init_attach_image = __esm(() => {
|
|
|
16842
16858
|
dataUrl = result.dataUrl;
|
|
16843
16859
|
} else {
|
|
16844
16860
|
const absPath = resolve17(ctx.baseDir, source);
|
|
16845
|
-
if (!
|
|
16861
|
+
if (!existsSync30(absPath)) {
|
|
16846
16862
|
return {
|
|
16847
16863
|
success: false,
|
|
16848
16864
|
output: t("image.not_found", { path: source })
|
|
@@ -17099,16 +17115,16 @@ class ModuleRegistry {
|
|
|
17099
17115
|
}
|
|
17100
17116
|
|
|
17101
17117
|
// src/modules/plugins/loader.ts
|
|
17102
|
-
import { readdirSync as readdirSync9, existsSync as
|
|
17103
|
-
import { join as
|
|
17118
|
+
import { readdirSync as readdirSync9, existsSync as existsSync31, statSync as statSync5 } from "fs";
|
|
17119
|
+
import { join as join25, basename as basename3 } from "path";
|
|
17104
17120
|
|
|
17105
17121
|
class PluginLoader {
|
|
17106
17122
|
loadFromDir(dirPath, pluginManager, logger, options) {
|
|
17107
|
-
if (!
|
|
17123
|
+
if (!existsSync31(dirPath))
|
|
17108
17124
|
return;
|
|
17109
17125
|
const entries = readdirSync9(dirPath).sort();
|
|
17110
17126
|
for (const entry of entries) {
|
|
17111
|
-
const fullPath =
|
|
17127
|
+
const fullPath = join25(dirPath, entry);
|
|
17112
17128
|
const stat = statSync5(fullPath);
|
|
17113
17129
|
if (stat.isFile()) {
|
|
17114
17130
|
if (!entry.endsWith(".ts") && !entry.endsWith(".js"))
|
|
@@ -17124,8 +17140,8 @@ class PluginLoader {
|
|
|
17124
17140
|
}
|
|
17125
17141
|
findEntryFile(dir) {
|
|
17126
17142
|
for (const name of FOLDER_ENTRY_NAMES) {
|
|
17127
|
-
const candidate =
|
|
17128
|
-
if (
|
|
17143
|
+
const candidate = join25(dir, name);
|
|
17144
|
+
if (existsSync31(candidate))
|
|
17129
17145
|
return candidate;
|
|
17130
17146
|
}
|
|
17131
17147
|
return null;
|
|
@@ -17167,8 +17183,8 @@ var init_loader = __esm(() => {
|
|
|
17167
17183
|
|
|
17168
17184
|
// src/modules/plugins/builtin/lint-on-write.ts
|
|
17169
17185
|
import { spawn as spawn5, execSync } from "child_process";
|
|
17170
|
-
import { existsSync as
|
|
17171
|
-
import { resolve as resolve18, extname as extname4, join as
|
|
17186
|
+
import { existsSync as existsSync32, readFileSync as readFileSync17 } from "fs";
|
|
17187
|
+
import { resolve as resolve18, extname as extname4, join as join26 } from "path";
|
|
17172
17188
|
import { platform as platform5 } from "os";
|
|
17173
17189
|
function contentHash(content) {
|
|
17174
17190
|
let h = 5381;
|
|
@@ -17215,7 +17231,7 @@ class LintOnWritePlugin {
|
|
|
17215
17231
|
if (!path)
|
|
17216
17232
|
return;
|
|
17217
17233
|
const fullPath = resolve18(ctx.baseDir, path);
|
|
17218
|
-
if (!
|
|
17234
|
+
if (!existsSync32(fullPath))
|
|
17219
17235
|
return;
|
|
17220
17236
|
const signal = ctx.signal;
|
|
17221
17237
|
if (signal?.aborted)
|
|
@@ -17239,7 +17255,7 @@ class LintOnWritePlugin {
|
|
|
17239
17255
|
if (ext === ".ts" || ext === ".tsx" || ext === ".cts" || ext === ".mts") {
|
|
17240
17256
|
let content = "";
|
|
17241
17257
|
try {
|
|
17242
|
-
content =
|
|
17258
|
+
content = readFileSync17(filePath, "utf-8");
|
|
17243
17259
|
} catch {
|
|
17244
17260
|
return null;
|
|
17245
17261
|
}
|
|
@@ -17280,11 +17296,11 @@ class LintOnWritePlugin {
|
|
|
17280
17296
|
}
|
|
17281
17297
|
async runProjectLint(ctx, result, signal) {
|
|
17282
17298
|
try {
|
|
17283
|
-
const packageJsonPath =
|
|
17284
|
-
if (!
|
|
17299
|
+
const packageJsonPath = join26(ctx.baseDir, "package.json");
|
|
17300
|
+
if (!existsSync32(packageJsonPath)) {
|
|
17285
17301
|
return;
|
|
17286
17302
|
}
|
|
17287
|
-
const packageJson = JSON.parse(
|
|
17303
|
+
const packageJson = JSON.parse(readFileSync17(packageJsonPath, "utf-8"));
|
|
17288
17304
|
const lintScript = packageJson.scripts?.lint;
|
|
17289
17305
|
if (!lintScript) {
|
|
17290
17306
|
return;
|
|
@@ -17306,8 +17322,8 @@ class LintOnWritePlugin {
|
|
|
17306
17322
|
}
|
|
17307
17323
|
async runProjectTypeCheck(filePath, baseDir, result, signal) {
|
|
17308
17324
|
const projectRoot = findProjectRoot(filePath, baseDir, ["tsconfig.json", "package.json"]);
|
|
17309
|
-
const tsconfigPath =
|
|
17310
|
-
if (!
|
|
17325
|
+
const tsconfigPath = join26(projectRoot, "tsconfig.json");
|
|
17326
|
+
if (!existsSync32(tsconfigPath)) {
|
|
17311
17327
|
return;
|
|
17312
17328
|
}
|
|
17313
17329
|
const now = Date.now();
|
|
@@ -17553,11 +17569,11 @@ class PlanTracker {
|
|
|
17553
17569
|
var init_tracker = () => {};
|
|
17554
17570
|
|
|
17555
17571
|
// src/modules/execution/plan-store.ts
|
|
17556
|
-
import { readFileSync as
|
|
17557
|
-
import { join as
|
|
17572
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync10, mkdirSync as mkdirSync14, existsSync as existsSync33, readdirSync as readdirSync10, rmSync } from "fs";
|
|
17573
|
+
import { join as join27 } from "path";
|
|
17558
17574
|
function readPlanFile(path, fallbackBaseDir) {
|
|
17559
17575
|
try {
|
|
17560
|
-
const raw =
|
|
17576
|
+
const raw = readFileSync18(path, "utf-8");
|
|
17561
17577
|
if (!raw.trim())
|
|
17562
17578
|
return null;
|
|
17563
17579
|
const parsed = JSON.parse(raw);
|
|
@@ -17579,10 +17595,10 @@ function writePlanFile(path, plan) {
|
|
|
17579
17595
|
writeFileSync10(path, JSON.stringify(plan, null, 2), "utf-8");
|
|
17580
17596
|
}
|
|
17581
17597
|
function listDir(dir, baseDir) {
|
|
17582
|
-
if (!
|
|
17598
|
+
if (!existsSync33(dir))
|
|
17583
17599
|
return [];
|
|
17584
17600
|
const files = readdirSync10(dir).filter((f) => f.endsWith(".json"));
|
|
17585
|
-
return files.map((f) => readPlanFile(
|
|
17601
|
+
return files.map((f) => readPlanFile(join27(dir, f), baseDir)).filter((p) => p !== null);
|
|
17586
17602
|
}
|
|
17587
17603
|
function toMeta(plan, status) {
|
|
17588
17604
|
return {
|
|
@@ -17603,33 +17619,33 @@ class PlanStore {
|
|
|
17603
17619
|
archiveDir;
|
|
17604
17620
|
legacyPath;
|
|
17605
17621
|
constructor(baseDir) {
|
|
17606
|
-
const mmaDir =
|
|
17607
|
-
if (!
|
|
17622
|
+
const mmaDir = join27(baseDir, ".mma");
|
|
17623
|
+
if (!existsSync33(mmaDir))
|
|
17608
17624
|
mkdirSync14(mmaDir, { recursive: true });
|
|
17609
17625
|
this.baseDir = baseDir;
|
|
17610
|
-
this.plansDir =
|
|
17611
|
-
this.draftsDir =
|
|
17612
|
-
this.archiveDir =
|
|
17613
|
-
this.legacyPath =
|
|
17626
|
+
this.plansDir = join27(mmaDir, "plans");
|
|
17627
|
+
this.draftsDir = join27(this.plansDir, "drafts");
|
|
17628
|
+
this.archiveDir = join27(this.plansDir, "archive");
|
|
17629
|
+
this.legacyPath = join27(mmaDir, LEGACY_FILE);
|
|
17614
17630
|
for (const dir of [this.plansDir, this.draftsDir, this.archiveDir]) {
|
|
17615
|
-
if (!
|
|
17631
|
+
if (!existsSync33(dir))
|
|
17616
17632
|
mkdirSync14(dir, { recursive: true });
|
|
17617
17633
|
}
|
|
17618
17634
|
}
|
|
17619
17635
|
activePath() {
|
|
17620
|
-
return
|
|
17636
|
+
return join27(this.plansDir, "active.json");
|
|
17621
17637
|
}
|
|
17622
17638
|
saveActive(plan) {
|
|
17623
17639
|
writePlanFile(this.activePath(), plan);
|
|
17624
17640
|
}
|
|
17625
17641
|
loadActive() {
|
|
17626
17642
|
const activePath = this.activePath();
|
|
17627
|
-
if (
|
|
17643
|
+
if (existsSync33(activePath)) {
|
|
17628
17644
|
const plan = readPlanFile(activePath, this.baseDir);
|
|
17629
17645
|
if (plan)
|
|
17630
17646
|
return plan;
|
|
17631
17647
|
}
|
|
17632
|
-
if (
|
|
17648
|
+
if (existsSync33(this.legacyPath)) {
|
|
17633
17649
|
const legacy = readPlanFile(this.legacyPath, this.baseDir);
|
|
17634
17650
|
if (legacy) {
|
|
17635
17651
|
this.saveActive(legacy);
|
|
@@ -17643,26 +17659,26 @@ class PlanStore {
|
|
|
17643
17659
|
}
|
|
17644
17660
|
clearActive() {
|
|
17645
17661
|
const p = this.activePath();
|
|
17646
|
-
if (
|
|
17662
|
+
if (existsSync33(p))
|
|
17647
17663
|
rmSync(p, { force: true });
|
|
17648
17664
|
}
|
|
17649
17665
|
saveDraft(plan) {
|
|
17650
|
-
writePlanFile(
|
|
17666
|
+
writePlanFile(join27(this.draftsDir, `${plan.id}.json`), plan);
|
|
17651
17667
|
}
|
|
17652
17668
|
loadDraft(id) {
|
|
17653
|
-
const p =
|
|
17654
|
-
return
|
|
17669
|
+
const p = join27(this.draftsDir, `${id}.json`);
|
|
17670
|
+
return existsSync33(p) ? readPlanFile(p, this.baseDir) : null;
|
|
17655
17671
|
}
|
|
17656
17672
|
removeDraft(id) {
|
|
17657
|
-
const p =
|
|
17658
|
-
if (
|
|
17673
|
+
const p = join27(this.draftsDir, `${id}.json`);
|
|
17674
|
+
if (existsSync33(p))
|
|
17659
17675
|
rmSync(p, { force: true });
|
|
17660
17676
|
}
|
|
17661
17677
|
listDrafts() {
|
|
17662
17678
|
return listDir(this.draftsDir, this.baseDir);
|
|
17663
17679
|
}
|
|
17664
17680
|
archivePlan(plan) {
|
|
17665
|
-
writePlanFile(
|
|
17681
|
+
writePlanFile(join27(this.archiveDir, `${plan.id}.json`), plan);
|
|
17666
17682
|
this.removeDraft(plan.id);
|
|
17667
17683
|
const active = this.loadActive();
|
|
17668
17684
|
if (active && active.id === plan.id) {
|
|
@@ -17673,8 +17689,8 @@ class PlanStore {
|
|
|
17673
17689
|
return listDir(this.archiveDir, this.baseDir);
|
|
17674
17690
|
}
|
|
17675
17691
|
removeArchived(id) {
|
|
17676
|
-
const p =
|
|
17677
|
-
if (
|
|
17692
|
+
const p = join27(this.archiveDir, `${id}.json`);
|
|
17693
|
+
if (existsSync33(p))
|
|
17678
17694
|
rmSync(p, { force: true });
|
|
17679
17695
|
}
|
|
17680
17696
|
listAll() {
|
|
@@ -17706,13 +17722,13 @@ class PlanStore {
|
|
|
17706
17722
|
this.clearActive();
|
|
17707
17723
|
return "active";
|
|
17708
17724
|
}
|
|
17709
|
-
const draftPath =
|
|
17710
|
-
if (
|
|
17725
|
+
const draftPath = join27(this.draftsDir, `${id}.json`);
|
|
17726
|
+
if (existsSync33(draftPath)) {
|
|
17711
17727
|
rmSync(draftPath, { force: true });
|
|
17712
17728
|
return "draft";
|
|
17713
17729
|
}
|
|
17714
|
-
const archivedPath =
|
|
17715
|
-
if (
|
|
17730
|
+
const archivedPath = join27(this.archiveDir, `${id}.json`);
|
|
17731
|
+
if (existsSync33(archivedPath)) {
|
|
17716
17732
|
rmSync(archivedPath, { force: true });
|
|
17717
17733
|
return "archived";
|
|
17718
17734
|
}
|
|
@@ -18715,7 +18731,7 @@ var init_plan_tool = __esm(() => {
|
|
|
18715
18731
|
});
|
|
18716
18732
|
|
|
18717
18733
|
// src/modules/execution/module.ts
|
|
18718
|
-
import { existsSync as
|
|
18734
|
+
import { existsSync as existsSync34, readFileSync as readFileSync19 } from "fs";
|
|
18719
18735
|
import { resolve as resolve19 } from "path";
|
|
18720
18736
|
|
|
18721
18737
|
class ExecutionModule {
|
|
@@ -19044,7 +19060,7 @@ class ExecutionModule {
|
|
|
19044
19060
|
"poetry.lock",
|
|
19045
19061
|
"requirements.txt"
|
|
19046
19062
|
];
|
|
19047
|
-
const hasLockFile = lockFiles.some((f) =>
|
|
19063
|
+
const hasLockFile = lockFiles.some((f) => existsSync34(resolve19(this.baseDir, f)));
|
|
19048
19064
|
if (!hasLockFile) {
|
|
19049
19065
|
if (contextManager) {
|
|
19050
19066
|
const hints = this.state.depsGateHints.get(step.id) || 0;
|
|
@@ -19076,7 +19092,7 @@ class ExecutionModule {
|
|
|
19076
19092
|
if (!r)
|
|
19077
19093
|
continue;
|
|
19078
19094
|
try {
|
|
19079
|
-
const content =
|
|
19095
|
+
const content = readFileSync19(r, "utf-8");
|
|
19080
19096
|
if (content.trim().length < 10) {
|
|
19081
19097
|
emptyFiles.push(r);
|
|
19082
19098
|
}
|
|
@@ -19184,8 +19200,8 @@ var init_module = __esm(() => {
|
|
|
19184
19200
|
});
|
|
19185
19201
|
|
|
19186
19202
|
// src/modules/security/session-encryption.ts
|
|
19187
|
-
import { readFileSync as
|
|
19188
|
-
import { join as
|
|
19203
|
+
import { readFileSync as readFileSync20, writeFileSync as writeFileSync11, existsSync as existsSync35, readdirSync as readdirSync11, unlinkSync as unlinkSync4 } from "fs";
|
|
19204
|
+
import { join as join28 } from "path";
|
|
19189
19205
|
import { homedir as homedir8 } from "os";
|
|
19190
19206
|
|
|
19191
19207
|
class SessionFileEncryptor {
|
|
@@ -19194,7 +19210,7 @@ class SessionFileEncryptor {
|
|
|
19194
19210
|
constructor(config) {
|
|
19195
19211
|
this.config = { ...DEFAULT_SESSION_ENCRYPTION, ...config };
|
|
19196
19212
|
this.encryptor = new ConfigEncryptor({
|
|
19197
|
-
keyPath: config?.keyPath ||
|
|
19213
|
+
keyPath: config?.keyPath || join28(homedir8(), ".mma", ".session-encryption-key")
|
|
19198
19214
|
});
|
|
19199
19215
|
}
|
|
19200
19216
|
isEnabled() {
|
|
@@ -19239,7 +19255,7 @@ class SessionFileEncryptor {
|
|
|
19239
19255
|
return lines.map((line) => this.decryptFileContent(line));
|
|
19240
19256
|
}
|
|
19241
19257
|
readSessionFile(filePath) {
|
|
19242
|
-
const content =
|
|
19258
|
+
const content = readFileSync20(filePath, "utf8");
|
|
19243
19259
|
return this.decryptFileContent(content);
|
|
19244
19260
|
}
|
|
19245
19261
|
writeSessionFile(filePath, content) {
|
|
@@ -19247,7 +19263,7 @@ class SessionFileEncryptor {
|
|
|
19247
19263
|
writeFileSync11(filePath, encrypted, "utf8");
|
|
19248
19264
|
}
|
|
19249
19265
|
readSessionJSON(filePath) {
|
|
19250
|
-
const content =
|
|
19266
|
+
const content = readFileSync20(filePath, "utf8");
|
|
19251
19267
|
return this.decryptJSON(content);
|
|
19252
19268
|
}
|
|
19253
19269
|
writeSessionJSON(filePath, obj) {
|
|
@@ -19255,7 +19271,7 @@ class SessionFileEncryptor {
|
|
|
19255
19271
|
writeFileSync11(filePath, content, "utf8");
|
|
19256
19272
|
}
|
|
19257
19273
|
readSessionJSONL(filePath) {
|
|
19258
|
-
const content =
|
|
19274
|
+
const content = readFileSync20(filePath, "utf8");
|
|
19259
19275
|
const lines = content.split(`
|
|
19260
19276
|
`).filter((line) => line.trim());
|
|
19261
19277
|
const decryptedLines = this.decryptJSONL(lines);
|
|
@@ -19280,10 +19296,10 @@ class SessionFileEncryptor {
|
|
|
19280
19296
|
return;
|
|
19281
19297
|
const files = readdirSync11(sessionDir);
|
|
19282
19298
|
for (const file of files) {
|
|
19283
|
-
const filePath =
|
|
19284
|
-
if (
|
|
19299
|
+
const filePath = join28(sessionDir, file);
|
|
19300
|
+
if (existsSync35(filePath) && !file.endsWith(".enc")) {
|
|
19285
19301
|
try {
|
|
19286
|
-
const content =
|
|
19302
|
+
const content = readFileSync20(filePath, "utf8");
|
|
19287
19303
|
const encrypted = this.encryptFileContent(content);
|
|
19288
19304
|
writeFileSync11(filePath + ".enc", encrypted, "utf8");
|
|
19289
19305
|
unlinkSync4(filePath);
|
|
@@ -19297,10 +19313,10 @@ class SessionFileEncryptor {
|
|
|
19297
19313
|
const files = readdirSync11(sessionDir);
|
|
19298
19314
|
for (const file of files) {
|
|
19299
19315
|
if (file.endsWith(".enc")) {
|
|
19300
|
-
const encFilePath =
|
|
19316
|
+
const encFilePath = join28(sessionDir, file);
|
|
19301
19317
|
const decFilePath = encFilePath.slice(0, -4);
|
|
19302
19318
|
try {
|
|
19303
|
-
const content =
|
|
19319
|
+
const content = readFileSync20(encFilePath, "utf8");
|
|
19304
19320
|
const decrypted = this.decryptFileContent(content);
|
|
19305
19321
|
writeFileSync11(decFilePath, decrypted, "utf8");
|
|
19306
19322
|
unlinkSync4(encFilePath);
|
|
@@ -19322,15 +19338,15 @@ var init_session_encryption = __esm(() => {
|
|
|
19322
19338
|
|
|
19323
19339
|
// src/modules/session/store.ts
|
|
19324
19340
|
import {
|
|
19325
|
-
existsSync as
|
|
19341
|
+
existsSync as existsSync36,
|
|
19326
19342
|
mkdirSync as mkdirSync15,
|
|
19327
19343
|
readdirSync as readdirSync12,
|
|
19328
|
-
readFileSync as
|
|
19344
|
+
readFileSync as readFileSync21,
|
|
19329
19345
|
rmSync as rmSync2,
|
|
19330
19346
|
writeFileSync as writeFileSync12,
|
|
19331
19347
|
appendFileSync as appendFileSync6
|
|
19332
19348
|
} from "fs";
|
|
19333
|
-
import { join as
|
|
19349
|
+
import { join as join29 } from "path";
|
|
19334
19350
|
import { gzipSync } from "zlib";
|
|
19335
19351
|
|
|
19336
19352
|
class SessionStore {
|
|
@@ -19344,7 +19360,7 @@ class SessionStore {
|
|
|
19344
19360
|
}
|
|
19345
19361
|
}
|
|
19346
19362
|
getSessionDir(id) {
|
|
19347
|
-
return
|
|
19363
|
+
return join29(this.baseDir, id);
|
|
19348
19364
|
}
|
|
19349
19365
|
updateEncryption(config) {
|
|
19350
19366
|
if (config?.enabled) {
|
|
@@ -19360,19 +19376,19 @@ class SessionStore {
|
|
|
19360
19376
|
mkdirSync15(this.baseDir, { recursive: true });
|
|
19361
19377
|
}
|
|
19362
19378
|
sessionDir(id) {
|
|
19363
|
-
return
|
|
19379
|
+
return join29(this.baseDir, id);
|
|
19364
19380
|
}
|
|
19365
19381
|
metaPath(id) {
|
|
19366
|
-
return
|
|
19382
|
+
return join29(this.sessionDir(id), "meta.json");
|
|
19367
19383
|
}
|
|
19368
19384
|
historyPath(id) {
|
|
19369
|
-
return
|
|
19385
|
+
return join29(this.sessionDir(id), "history.jsonl");
|
|
19370
19386
|
}
|
|
19371
19387
|
sessionLogPath(id) {
|
|
19372
|
-
return
|
|
19388
|
+
return join29(this.sessionDir(id), "session.jsonl");
|
|
19373
19389
|
}
|
|
19374
19390
|
sessionExists(id) {
|
|
19375
|
-
return
|
|
19391
|
+
return existsSync36(this.metaPath(id));
|
|
19376
19392
|
}
|
|
19377
19393
|
saveMeta(id, meta) {
|
|
19378
19394
|
this._metaCache.set(id, meta);
|
|
@@ -19390,10 +19406,10 @@ class SessionStore {
|
|
|
19390
19406
|
if (cached)
|
|
19391
19407
|
return cached;
|
|
19392
19408
|
const path = this.metaPath(id);
|
|
19393
|
-
if (!
|
|
19409
|
+
if (!existsSync36(path))
|
|
19394
19410
|
return null;
|
|
19395
19411
|
try {
|
|
19396
|
-
const raw =
|
|
19412
|
+
const raw = readFileSync21(path, "utf-8");
|
|
19397
19413
|
const content = this.encryptor ? this.encryptor.decryptFileContent(raw) : raw;
|
|
19398
19414
|
const meta = JSON.parse(content);
|
|
19399
19415
|
this._metaCache.set(id, meta);
|
|
@@ -19422,10 +19438,10 @@ class SessionStore {
|
|
|
19422
19438
|
}
|
|
19423
19439
|
loadHistory(id) {
|
|
19424
19440
|
const path = this.historyPath(id);
|
|
19425
|
-
if (!
|
|
19441
|
+
if (!existsSync36(path))
|
|
19426
19442
|
return [];
|
|
19427
19443
|
try {
|
|
19428
|
-
const raw =
|
|
19444
|
+
const raw = readFileSync21(path, "utf-8");
|
|
19429
19445
|
const lines = raw.split(`
|
|
19430
19446
|
`).filter(Boolean);
|
|
19431
19447
|
const parseLine = (line) => {
|
|
@@ -19463,10 +19479,10 @@ class SessionStore {
|
|
|
19463
19479
|
}
|
|
19464
19480
|
loadSessionLog(id) {
|
|
19465
19481
|
const path = this.sessionLogPath(id);
|
|
19466
|
-
if (!
|
|
19482
|
+
if (!existsSync36(path))
|
|
19467
19483
|
return [];
|
|
19468
19484
|
try {
|
|
19469
|
-
const raw =
|
|
19485
|
+
const raw = readFileSync21(path, "utf-8");
|
|
19470
19486
|
const lines = raw.split(`
|
|
19471
19487
|
`).filter(Boolean);
|
|
19472
19488
|
const parseLine = (line) => {
|
|
@@ -19491,7 +19507,7 @@ class SessionStore {
|
|
|
19491
19507
|
}
|
|
19492
19508
|
}
|
|
19493
19509
|
listSessions() {
|
|
19494
|
-
if (!
|
|
19510
|
+
if (!existsSync36(this.baseDir))
|
|
19495
19511
|
return [];
|
|
19496
19512
|
const entries = readdirSync12(this.baseDir, { withFileTypes: true });
|
|
19497
19513
|
const sessions = [];
|
|
@@ -19508,7 +19524,7 @@ class SessionStore {
|
|
|
19508
19524
|
deleteSession(id) {
|
|
19509
19525
|
this._metaCache.delete(id);
|
|
19510
19526
|
const dir = this.sessionDir(id);
|
|
19511
|
-
if (
|
|
19527
|
+
if (existsSync36(dir)) {
|
|
19512
19528
|
rmSync2(dir, { recursive: true, force: true });
|
|
19513
19529
|
}
|
|
19514
19530
|
}
|
|
@@ -19520,10 +19536,10 @@ class SessionStore {
|
|
|
19520
19536
|
const updatedAt = new Date(session2.updatedAt);
|
|
19521
19537
|
if (updatedAt < thirtyDaysAgo) {
|
|
19522
19538
|
const historyPath = this.historyPath(session2.id);
|
|
19523
|
-
if (
|
|
19524
|
-
const content =
|
|
19539
|
+
if (existsSync36(historyPath)) {
|
|
19540
|
+
const content = readFileSync21(historyPath, "utf-8");
|
|
19525
19541
|
const compressed = gzipSync(content);
|
|
19526
|
-
const gzPath =
|
|
19542
|
+
const gzPath = join29(this.baseDir, `${session2.id}.jsonl.gz`);
|
|
19527
19543
|
writeFileSync12(gzPath, compressed);
|
|
19528
19544
|
rmSync2(historyPath);
|
|
19529
19545
|
}
|
|
@@ -19733,8 +19749,8 @@ class ProfileCompressor {
|
|
|
19733
19749
|
}
|
|
19734
19750
|
|
|
19735
19751
|
// src/modules/user-profile/profile.ts
|
|
19736
|
-
import { readFileSync as
|
|
19737
|
-
import { join as
|
|
19752
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync13, existsSync as existsSync37, mkdirSync as mkdirSync16 } from "fs";
|
|
19753
|
+
import { join as join30 } from "path";
|
|
19738
19754
|
import { homedir as homedir9, hostname, platform as platform7, type } from "os";
|
|
19739
19755
|
import { env } from "process";
|
|
19740
19756
|
|
|
@@ -19758,17 +19774,17 @@ class UserProfile {
|
|
|
19758
19774
|
return this.info;
|
|
19759
19775
|
}
|
|
19760
19776
|
save() {
|
|
19761
|
-
if (!
|
|
19777
|
+
if (!existsSync37(this.profileDir)) {
|
|
19762
19778
|
mkdirSync16(this.profileDir, { recursive: true });
|
|
19763
19779
|
}
|
|
19764
|
-
writeFileSync13(
|
|
19780
|
+
writeFileSync13(join30(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
|
|
19765
19781
|
}
|
|
19766
19782
|
load() {
|
|
19767
|
-
const path =
|
|
19768
|
-
if (!
|
|
19783
|
+
const path = join30(this.profileDir, "profile.json");
|
|
19784
|
+
if (!existsSync37(path))
|
|
19769
19785
|
return null;
|
|
19770
19786
|
try {
|
|
19771
|
-
const data = JSON.parse(
|
|
19787
|
+
const data = JSON.parse(readFileSync22(path, "utf-8"));
|
|
19772
19788
|
this.info = {
|
|
19773
19789
|
platform: data.platform,
|
|
19774
19790
|
os: data.os,
|
|
@@ -19803,12 +19819,12 @@ class UserProfile {
|
|
|
19803
19819
|
var init_profile = () => {};
|
|
19804
19820
|
|
|
19805
19821
|
// src/modules/skills/loader.ts
|
|
19806
|
-
import { readdirSync as readdirSync13, readFileSync as
|
|
19807
|
-
import { join as
|
|
19822
|
+
import { readdirSync as readdirSync13, readFileSync as readFileSync23, existsSync as existsSync38, statSync as statSync6 } from "fs";
|
|
19823
|
+
import { join as join31 } from "path";
|
|
19808
19824
|
|
|
19809
19825
|
class SkillsLoader {
|
|
19810
19826
|
loadFromDir(dirPath) {
|
|
19811
|
-
if (!
|
|
19827
|
+
if (!existsSync38(dirPath))
|
|
19812
19828
|
return [];
|
|
19813
19829
|
const skills = [];
|
|
19814
19830
|
this.scanDir(dirPath, skills);
|
|
@@ -19817,7 +19833,7 @@ class SkillsLoader {
|
|
|
19817
19833
|
scanDir(dirPath, skills) {
|
|
19818
19834
|
const entries = readdirSync13(dirPath);
|
|
19819
19835
|
for (const entry of entries) {
|
|
19820
|
-
const fullPath =
|
|
19836
|
+
const fullPath = join31(dirPath, entry);
|
|
19821
19837
|
const stat = statSync6(fullPath);
|
|
19822
19838
|
if (stat.isDirectory()) {
|
|
19823
19839
|
this.scanDir(fullPath, skills);
|
|
@@ -19825,7 +19841,7 @@ class SkillsLoader {
|
|
|
19825
19841
|
}
|
|
19826
19842
|
if (!entry.endsWith(".md") && !entry.endsWith(".skill.md"))
|
|
19827
19843
|
continue;
|
|
19828
|
-
const content =
|
|
19844
|
+
const content = readFileSync23(fullPath, "utf-8");
|
|
19829
19845
|
const parsed = this.parseSkillFile(content, fullPath);
|
|
19830
19846
|
if (parsed)
|
|
19831
19847
|
skills.push(parsed);
|
|
@@ -20296,9 +20312,11 @@ class LspClient {
|
|
|
20296
20312
|
async shutdown() {
|
|
20297
20313
|
try {
|
|
20298
20314
|
if (this.process && this.initialized && this.process.stdin?.writable) {
|
|
20299
|
-
|
|
20315
|
+
try {
|
|
20316
|
+
await this.sendRequest("shutdown", null, 3000);
|
|
20317
|
+
} catch (e) {
|
|
20300
20318
|
this.logger?.debug(`LSP shutdown request failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
20301
|
-
}
|
|
20319
|
+
}
|
|
20302
20320
|
this.sendNotification("exit", null);
|
|
20303
20321
|
await new Promise((r) => setTimeout(r, 200));
|
|
20304
20322
|
}
|
|
@@ -20409,7 +20427,7 @@ var init_check_tool = __esm(() => {
|
|
|
20409
20427
|
});
|
|
20410
20428
|
|
|
20411
20429
|
// src/modules/lsp/module.ts
|
|
20412
|
-
import { existsSync as
|
|
20430
|
+
import { existsSync as existsSync39 } from "fs";
|
|
20413
20431
|
import { relative as relative3, resolve as resolve22 } from "path";
|
|
20414
20432
|
|
|
20415
20433
|
class LspModule {
|
|
@@ -20464,7 +20482,7 @@ class LspModule {
|
|
|
20464
20482
|
if (!filePath)
|
|
20465
20483
|
return;
|
|
20466
20484
|
const fullPath = resolve22(_ctx.baseDir, filePath);
|
|
20467
|
-
if (!
|
|
20485
|
+
if (!existsSync39(fullPath))
|
|
20468
20486
|
return;
|
|
20469
20487
|
const serverConfig = getServerForFile(fullPath, self.config);
|
|
20470
20488
|
if (!serverConfig)
|
|
@@ -20556,7 +20574,7 @@ ${items}`;
|
|
|
20556
20574
|
})
|
|
20557
20575
|
};
|
|
20558
20576
|
}
|
|
20559
|
-
if (!
|
|
20577
|
+
if (!existsSync39(resolved)) {
|
|
20560
20578
|
return { success: false, output: t("lsp.check_notfound", { path }) };
|
|
20561
20579
|
}
|
|
20562
20580
|
const files = await collectCheckFiles(resolved, this.config);
|
|
@@ -20656,8 +20674,8 @@ var init_lsp = __esm(() => {
|
|
|
20656
20674
|
});
|
|
20657
20675
|
|
|
20658
20676
|
// src/modules/lsp/startup-check.ts
|
|
20659
|
-
import { existsSync as
|
|
20660
|
-
import { join as
|
|
20677
|
+
import { existsSync as existsSync40 } from "fs";
|
|
20678
|
+
import { join as join32 } from "path";
|
|
20661
20679
|
import { spawn as spawn7 } from "child_process";
|
|
20662
20680
|
async function runStartupHealthCheck(config, baseDir, deps = {}) {
|
|
20663
20681
|
if (!config.enabled)
|
|
@@ -20684,7 +20702,7 @@ ${result.lines.join(`
|
|
|
20684
20702
|
}
|
|
20685
20703
|
async function runCheck(config, baseDir, deps) {
|
|
20686
20704
|
const projectRoot = findProjectRoot(baseDir, baseDir, ["tsconfig.json", "package.json"]);
|
|
20687
|
-
if (
|
|
20705
|
+
if (existsSync40(join32(projectRoot, "tsconfig.json"))) {
|
|
20688
20706
|
const runTsc = deps.runTsc ?? runTscDefault;
|
|
20689
20707
|
const errors = await runTsc(projectRoot, STARTUP_CHECK_TIMEOUT_MS);
|
|
20690
20708
|
if (errors.length === 0)
|
|
@@ -20692,6 +20710,8 @@ async function runCheck(config, baseDir, deps) {
|
|
|
20692
20710
|
return { lines: errors.slice(0, STARTUP_CHECK_ERROR_CAP) };
|
|
20693
20711
|
}
|
|
20694
20712
|
const client = deps.client ?? new LspClient;
|
|
20713
|
+
if (!deps.client)
|
|
20714
|
+
client.setLogger(deps.logger ?? null);
|
|
20695
20715
|
const files = await collectCheckFiles(baseDir, config);
|
|
20696
20716
|
const lines = [];
|
|
20697
20717
|
let checked = 0;
|
|
@@ -20782,8 +20802,8 @@ var init_startup_check = __esm(() => {
|
|
|
20782
20802
|
});
|
|
20783
20803
|
|
|
20784
20804
|
// src/modules/indexer/walker.ts
|
|
20785
|
-
import { readdirSync as readdirSync14, readFileSync as
|
|
20786
|
-
import { join as
|
|
20805
|
+
import { readdirSync as readdirSync14, readFileSync as readFileSync24, statSync as statSync7, existsSync as existsSync41, watch } from "fs";
|
|
20806
|
+
import { join as join33, relative as relative4, extname as extname5 } from "path";
|
|
20787
20807
|
|
|
20788
20808
|
class Indexer {
|
|
20789
20809
|
baseDir;
|
|
@@ -20810,7 +20830,7 @@ class Indexer {
|
|
|
20810
20830
|
let totalSize = 0;
|
|
20811
20831
|
let count = 0;
|
|
20812
20832
|
const walkDir2 = (dir) => {
|
|
20813
|
-
if (!
|
|
20833
|
+
if (!existsSync41(dir))
|
|
20814
20834
|
return;
|
|
20815
20835
|
let entries;
|
|
20816
20836
|
try {
|
|
@@ -20821,7 +20841,7 @@ class Indexer {
|
|
|
20821
20841
|
for (const entry of entries) {
|
|
20822
20842
|
if (count >= this.MAX_FILES)
|
|
20823
20843
|
return;
|
|
20824
|
-
const fullPath =
|
|
20844
|
+
const fullPath = join33(dir, entry);
|
|
20825
20845
|
const relPath = relative4(this.baseDir, fullPath);
|
|
20826
20846
|
const stat2 = statSync7(fullPath);
|
|
20827
20847
|
if (stat2.isDirectory()) {
|
|
@@ -20832,7 +20852,7 @@ class Indexer {
|
|
|
20832
20852
|
const ext = extname5(entry).toLowerCase();
|
|
20833
20853
|
const language = LANGUAGES[ext];
|
|
20834
20854
|
if (language) {
|
|
20835
|
-
const content =
|
|
20855
|
+
const content = readFileSync24(fullPath, "utf-8");
|
|
20836
20856
|
const exports = this.extractExports(content, language);
|
|
20837
20857
|
files.push({ path: relPath, language, exports, size: stat2.size });
|
|
20838
20858
|
totalSize += stat2.size;
|
|
@@ -20884,22 +20904,22 @@ var init_walker = __esm(() => {
|
|
|
20884
20904
|
});
|
|
20885
20905
|
|
|
20886
20906
|
// src/modules/indexer/cache.ts
|
|
20887
|
-
import { readFileSync as
|
|
20888
|
-
import { join as
|
|
20907
|
+
import { readFileSync as readFileSync25, writeFileSync as writeFileSync14, existsSync as existsSync42, mkdirSync as mkdirSync17, rmSync as rmSync3 } from "fs";
|
|
20908
|
+
import { join as join34 } from "path";
|
|
20889
20909
|
|
|
20890
20910
|
class IndexCache {
|
|
20891
20911
|
cachePath;
|
|
20892
20912
|
cache = null;
|
|
20893
20913
|
constructor(cacheDir) {
|
|
20894
|
-
this.cachePath =
|
|
20914
|
+
this.cachePath = join34(cacheDir, "index-cache.json");
|
|
20895
20915
|
}
|
|
20896
20916
|
load() {
|
|
20897
20917
|
if (this.cache)
|
|
20898
20918
|
return this.cache;
|
|
20899
|
-
if (!
|
|
20919
|
+
if (!existsSync42(this.cachePath))
|
|
20900
20920
|
return null;
|
|
20901
20921
|
try {
|
|
20902
|
-
this.cache = JSON.parse(
|
|
20922
|
+
this.cache = JSON.parse(readFileSync25(this.cachePath, "utf-8"));
|
|
20903
20923
|
return this.cache;
|
|
20904
20924
|
} catch {
|
|
20905
20925
|
return null;
|
|
@@ -20907,14 +20927,14 @@ class IndexCache {
|
|
|
20907
20927
|
}
|
|
20908
20928
|
save(result) {
|
|
20909
20929
|
this.cache = result;
|
|
20910
|
-
const dir =
|
|
20911
|
-
if (!
|
|
20930
|
+
const dir = join34(this.cachePath, "..");
|
|
20931
|
+
if (!existsSync42(dir))
|
|
20912
20932
|
mkdirSync17(dir, { recursive: true });
|
|
20913
20933
|
writeFileSync14(this.cachePath, JSON.stringify(result), "utf-8");
|
|
20914
20934
|
}
|
|
20915
20935
|
invalidate() {
|
|
20916
20936
|
this.cache = null;
|
|
20917
|
-
if (
|
|
20937
|
+
if (existsSync42(this.cachePath)) {
|
|
20918
20938
|
try {
|
|
20919
20939
|
rmSync3(this.cachePath);
|
|
20920
20940
|
} catch {}
|
|
@@ -20924,11 +20944,11 @@ class IndexCache {
|
|
|
20924
20944
|
var init_cache = () => {};
|
|
20925
20945
|
|
|
20926
20946
|
// src/modules/indexer/project-profile.ts
|
|
20927
|
-
import { readFileSync as
|
|
20928
|
-
import { join as
|
|
20947
|
+
import { readFileSync as readFileSync26, existsSync as existsSync43 } from "fs";
|
|
20948
|
+
import { join as join35 } from "path";
|
|
20929
20949
|
function detectManifest(baseDir) {
|
|
20930
20950
|
for (const manifest of MANIFEST_ORDER) {
|
|
20931
|
-
if (
|
|
20951
|
+
if (existsSync43(join35(baseDir, manifest)))
|
|
20932
20952
|
return manifest;
|
|
20933
20953
|
}
|
|
20934
20954
|
return null;
|
|
@@ -20945,7 +20965,7 @@ function cleanDependency(entry) {
|
|
|
20945
20965
|
}
|
|
20946
20966
|
function readPackageJson(baseDir) {
|
|
20947
20967
|
try {
|
|
20948
|
-
const raw = JSON.parse(
|
|
20968
|
+
const raw = JSON.parse(readFileSync26(join35(baseDir, "package.json"), "utf-8"));
|
|
20949
20969
|
if (!raw || typeof raw !== "object")
|
|
20950
20970
|
return null;
|
|
20951
20971
|
const profile = {
|
|
@@ -20969,7 +20989,7 @@ function readPackageJson(baseDir) {
|
|
|
20969
20989
|
}
|
|
20970
20990
|
function readPyproject(baseDir) {
|
|
20971
20991
|
try {
|
|
20972
|
-
const content =
|
|
20992
|
+
const content = readFileSync26(join35(baseDir, "pyproject.toml"), "utf-8");
|
|
20973
20993
|
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
20974
20994
|
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
20975
20995
|
if (nameMatch)
|
|
@@ -20985,7 +21005,7 @@ function readPyproject(baseDir) {
|
|
|
20985
21005
|
}
|
|
20986
21006
|
function readCargo(baseDir) {
|
|
20987
21007
|
try {
|
|
20988
|
-
const content =
|
|
21008
|
+
const content = readFileSync26(join35(baseDir, "Cargo.toml"), "utf-8");
|
|
20989
21009
|
const profile = { runtime: "rust", deps: [], devDeps: [], scripts: {} };
|
|
20990
21010
|
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
20991
21011
|
if (nameMatch)
|
|
@@ -21009,7 +21029,7 @@ function readCargo(baseDir) {
|
|
|
21009
21029
|
}
|
|
21010
21030
|
function readGoMod(baseDir) {
|
|
21011
21031
|
try {
|
|
21012
|
-
const content =
|
|
21032
|
+
const content = readFileSync26(join35(baseDir, "go.mod"), "utf-8");
|
|
21013
21033
|
const profile = { runtime: "go", deps: [], devDeps: [], scripts: {} };
|
|
21014
21034
|
const moduleMatch = content.match(/^module\s+(\S+)/m);
|
|
21015
21035
|
if (moduleMatch)
|
|
@@ -21027,7 +21047,7 @@ function readGoMod(baseDir) {
|
|
|
21027
21047
|
}
|
|
21028
21048
|
function readRequirements(baseDir) {
|
|
21029
21049
|
try {
|
|
21030
|
-
const content =
|
|
21050
|
+
const content = readFileSync26(join35(baseDir, "requirements.txt"), "utf-8");
|
|
21031
21051
|
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
21032
21052
|
for (const line of content.split(`
|
|
21033
21053
|
`)) {
|
|
@@ -21486,7 +21506,7 @@ var init_mcp = __esm(() => {
|
|
|
21486
21506
|
|
|
21487
21507
|
// src/modules/memory/module.ts
|
|
21488
21508
|
import { homedir as homedir10 } from "os";
|
|
21489
|
-
import { join as
|
|
21509
|
+
import { join as join36 } from "path";
|
|
21490
21510
|
|
|
21491
21511
|
class MemoryModule {
|
|
21492
21512
|
name = "memory";
|
|
@@ -21495,7 +21515,7 @@ class MemoryModule {
|
|
|
21495
21515
|
if (storeOrDir instanceof MemoryStore) {
|
|
21496
21516
|
this.store = storeOrDir;
|
|
21497
21517
|
} else {
|
|
21498
|
-
const dir = storeOrDir ||
|
|
21518
|
+
const dir = storeOrDir || join36(homedir10(), ".mma", "memory");
|
|
21499
21519
|
this.store = new MemoryStore(dir);
|
|
21500
21520
|
}
|
|
21501
21521
|
}
|
|
@@ -21581,16 +21601,16 @@ var init_module8 = __esm(() => {
|
|
|
21581
21601
|
});
|
|
21582
21602
|
|
|
21583
21603
|
// src/core/version.ts
|
|
21584
|
-
import { existsSync as
|
|
21585
|
-
import { join as
|
|
21604
|
+
import { existsSync as existsSync44, readFileSync as readFileSync27 } from "fs";
|
|
21605
|
+
import { join as join37, dirname as dirname13 } from "path";
|
|
21586
21606
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
21587
21607
|
function readMmaVersion() {
|
|
21588
21608
|
const here = dirname13(fileURLToPath2(import.meta.url));
|
|
21589
|
-
const candidates = [
|
|
21609
|
+
const candidates = [join37(here, "..", "..", "package.json"), join37(here, "..", "package.json")];
|
|
21590
21610
|
for (const p of candidates) {
|
|
21591
|
-
if (
|
|
21611
|
+
if (existsSync44(p)) {
|
|
21592
21612
|
try {
|
|
21593
|
-
const raw = JSON.parse(
|
|
21613
|
+
const raw = JSON.parse(readFileSync27(p, "utf8"));
|
|
21594
21614
|
if (raw.version)
|
|
21595
21615
|
return raw.version;
|
|
21596
21616
|
} catch {}
|
|
@@ -21601,21 +21621,21 @@ function readMmaVersion() {
|
|
|
21601
21621
|
var init_version = () => {};
|
|
21602
21622
|
|
|
21603
21623
|
// src/core/environment.ts
|
|
21604
|
-
import { existsSync as
|
|
21624
|
+
import { existsSync as existsSync45, readFileSync as readFileSync28, readdirSync as readdirSync15 } from "fs";
|
|
21605
21625
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
21606
21626
|
import { createRequire as createRequire2 } from "module";
|
|
21607
|
-
import { join as
|
|
21627
|
+
import { join as join38, dirname as dirname14 } from "path";
|
|
21608
21628
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
21609
21629
|
import { arch, homedir as homedir11, hostname as hostname2, platform as platform9, release } from "os";
|
|
21610
21630
|
import { env as env2 } from "process";
|
|
21611
21631
|
function readEngineRequirement() {
|
|
21612
21632
|
const here = dirname14(fileURLToPath3(import.meta.url));
|
|
21613
|
-
const candidates = [
|
|
21633
|
+
const candidates = [join38(here, "..", "..", "package.json"), join38(here, "..", "package.json")];
|
|
21614
21634
|
for (const p of candidates) {
|
|
21615
|
-
if (!
|
|
21635
|
+
if (!existsSync45(p))
|
|
21616
21636
|
continue;
|
|
21617
21637
|
try {
|
|
21618
|
-
const raw = JSON.parse(
|
|
21638
|
+
const raw = JSON.parse(readFileSync28(p, "utf8"));
|
|
21619
21639
|
if (raw.engines?.node)
|
|
21620
21640
|
return String(raw.engines.node);
|
|
21621
21641
|
} catch {}
|
|
@@ -21678,7 +21698,7 @@ function toolVersion(cmd) {
|
|
|
21678
21698
|
function playwrightBrowsersDir() {
|
|
21679
21699
|
if (process.env.PLAYWRIGHT_BROWSERS_PATH)
|
|
21680
21700
|
return process.env.PLAYWRIGHT_BROWSERS_PATH;
|
|
21681
|
-
return process.platform === "win32" ?
|
|
21701
|
+
return process.platform === "win32" ? join38(homedir11(), "AppData", "Local", "ms-playwright") : join38(homedir11(), ".cache", "ms-playwright");
|
|
21682
21702
|
}
|
|
21683
21703
|
function playwrightInfo() {
|
|
21684
21704
|
let installed = false;
|
|
@@ -21687,14 +21707,14 @@ function playwrightInfo() {
|
|
|
21687
21707
|
try {
|
|
21688
21708
|
const require2 = createRequire2(import.meta.url);
|
|
21689
21709
|
const pkgPath = require2.resolve("playwright/package.json");
|
|
21690
|
-
installed =
|
|
21691
|
-
version = JSON.parse(
|
|
21710
|
+
installed = existsSync45(pkgPath);
|
|
21711
|
+
version = JSON.parse(readFileSync28(pkgPath, "utf8")).version || "";
|
|
21692
21712
|
} catch {
|
|
21693
21713
|
installed = false;
|
|
21694
21714
|
}
|
|
21695
21715
|
let browsersInstalled = false;
|
|
21696
21716
|
try {
|
|
21697
|
-
if (
|
|
21717
|
+
if (existsSync45(browsersDir)) {
|
|
21698
21718
|
browsersInstalled = readdirSync15(browsersDir).some((d) => /chrom/i.test(d));
|
|
21699
21719
|
}
|
|
21700
21720
|
} catch {
|
|
@@ -21789,8 +21809,8 @@ __export(exports_bootstrap, {
|
|
|
21789
21809
|
bootstrap: () => bootstrap
|
|
21790
21810
|
});
|
|
21791
21811
|
import { homedir as homedir12 } from "os";
|
|
21792
|
-
import { join as
|
|
21793
|
-
import { existsSync as
|
|
21812
|
+
import { join as join39, resolve as resolve23 } from "path";
|
|
21813
|
+
import { existsSync as existsSync46, readFileSync as readFileSync29, writeFileSync as writeFileSync15 } from "fs";
|
|
21794
21814
|
function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
21795
21815
|
const now = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
21796
21816
|
const isWin = profileCompressed.toLowerCase().includes("win32");
|
|
@@ -21816,8 +21836,8 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
21816
21836
|
`);
|
|
21817
21837
|
}
|
|
21818
21838
|
async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
21819
|
-
const dir = configDir ||
|
|
21820
|
-
const projectConfigPath = projectDir ?
|
|
21839
|
+
const dir = configDir || join39(homedir12(), ".mma");
|
|
21840
|
+
const projectConfigPath = projectDir ? join39(projectDir, ".mmrc") : join39(process.cwd(), ".mmrc");
|
|
21821
21841
|
const config = loadConfig({ configDir: dir, projectConfigPath });
|
|
21822
21842
|
setLocale(config.locale);
|
|
21823
21843
|
try {
|
|
@@ -21827,7 +21847,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
21827
21847
|
}
|
|
21828
21848
|
} catch {}
|
|
21829
21849
|
const logger = new Logger(config.logLevel);
|
|
21830
|
-
logger.setLogDir(
|
|
21850
|
+
logger.setLogDir(join39(dir, "logs"));
|
|
21831
21851
|
logger.debug("MMA bootstrap", {
|
|
21832
21852
|
version: config.version,
|
|
21833
21853
|
model: config.model
|
|
@@ -21849,7 +21869,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
21849
21869
|
logger.info(`Model ${config.model} loaded in ${loadResult.loadTime}s`);
|
|
21850
21870
|
}
|
|
21851
21871
|
}
|
|
21852
|
-
const profile = new UserProfile(
|
|
21872
|
+
const profile = new UserProfile(join39(dir));
|
|
21853
21873
|
profile.load() || profile.collect();
|
|
21854
21874
|
profile.save();
|
|
21855
21875
|
const llmProvider = new OpenAICompatProvider({
|
|
@@ -21871,7 +21891,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
21871
21891
|
for (const warning of envReport.warnings) {
|
|
21872
21892
|
logger.warn(warning);
|
|
21873
21893
|
}
|
|
21874
|
-
const projectMapCacheDir =
|
|
21894
|
+
const projectMapCacheDir = join39(baseDir, ".mma");
|
|
21875
21895
|
const indexerModule = new IndexerModule({
|
|
21876
21896
|
baseDir,
|
|
21877
21897
|
cacheDir: projectMapCacheDir
|
|
@@ -21882,9 +21902,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
21882
21902
|
logger.warn(`Project indexing failed: ${err.message}`);
|
|
21883
21903
|
}
|
|
21884
21904
|
const skillsLoader = new SkillsLoader;
|
|
21885
|
-
const builtinDir =
|
|
21886
|
-
const globalDir =
|
|
21887
|
-
const projectSkillsDir =
|
|
21905
|
+
const builtinDir = join39(import.meta.dirname, "skills", "builtin");
|
|
21906
|
+
const globalDir = join39(homedir12(), ".agents", "skills");
|
|
21907
|
+
const projectSkillsDir = join39(baseDir, ".mma", "skills");
|
|
21888
21908
|
const availableSkills = skillsLoader.loadFromAllSources(builtinDir, globalDir, projectSkillsDir);
|
|
21889
21909
|
const skillsBudget = Math.floor(config.contextWindow * config.skills.budget);
|
|
21890
21910
|
const skillsModule = new SkillsModule(availableSkills, skillsBudget);
|
|
@@ -21900,11 +21920,11 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
21900
21920
|
essential: true,
|
|
21901
21921
|
estimatedTokens: Math.ceil(systemInfoContent.length / 4)
|
|
21902
21922
|
};
|
|
21903
|
-
const agentsMdGlobal =
|
|
21904
|
-
if (!
|
|
21923
|
+
const agentsMdGlobal = join39(dir, "AGENTS.md");
|
|
21924
|
+
if (!existsSync46(agentsMdGlobal)) {
|
|
21905
21925
|
writeFileSync15(agentsMdGlobal, "", "utf-8");
|
|
21906
21926
|
}
|
|
21907
|
-
const sessionDir =
|
|
21927
|
+
const sessionDir = join39(dir, "sessions");
|
|
21908
21928
|
const sessionStore = new SessionStore(sessionDir);
|
|
21909
21929
|
sessionStore.init();
|
|
21910
21930
|
const sessionManager = new SessionManager(sessionStore, {
|
|
@@ -21981,7 +22001,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
21981
22001
|
const mcpModule = new MCPModule(config);
|
|
21982
22002
|
await mcpModule.initialize();
|
|
21983
22003
|
moduleRegistry.register(mcpModule);
|
|
21984
|
-
const memoryStore = new MemoryStore(
|
|
22004
|
+
const memoryStore = new MemoryStore(join39(dir, "memory"));
|
|
21985
22005
|
const memoryModule = new MemoryModule(memoryStore);
|
|
21986
22006
|
moduleRegistry.register(memoryModule);
|
|
21987
22007
|
if (config.browser.enabled) {
|
|
@@ -22001,7 +22021,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
22001
22021
|
pluginManager.register(lspPlugin);
|
|
22002
22022
|
}
|
|
22003
22023
|
let startupCheckBlock = null;
|
|
22004
|
-
const startupCheckPromise = !exitOnComplete ? runStartupHealthCheck(config.lsp ?? DEFAULT_LSP_CONFIG, baseDir) : Promise.resolve(null);
|
|
22024
|
+
const startupCheckPromise = !exitOnComplete ? runStartupHealthCheck(config.lsp ?? DEFAULT_LSP_CONFIG, baseDir, { logger }) : Promise.resolve(null);
|
|
22005
22025
|
const moduleTools = moduleRegistry.collectToolDefinitions();
|
|
22006
22026
|
for (const tool of moduleTools) {
|
|
22007
22027
|
toolRegistry.register(tool);
|
|
@@ -22034,8 +22054,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
22034
22054
|
pluginManager.register(plugin);
|
|
22035
22055
|
pluginManager.register(plugin2);
|
|
22036
22056
|
const pluginLoader = new PluginLoader;
|
|
22037
|
-
const globalPluginsDir =
|
|
22038
|
-
const projectPluginsDir =
|
|
22057
|
+
const globalPluginsDir = join39(homedir12(), ".mma", "plugins");
|
|
22058
|
+
const projectPluginsDir = join39(baseDir, ".mma", "plugins");
|
|
22039
22059
|
const mmaVersion = readMmaVersion();
|
|
22040
22060
|
pluginLoader.loadFromDir(globalPluginsDir, pluginManager, logger, {
|
|
22041
22061
|
source: "global",
|
|
@@ -22061,13 +22081,13 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
22061
22081
|
const skipAgentsMd = noAgentsMd === true;
|
|
22062
22082
|
if (!skipAgentsMd) {
|
|
22063
22083
|
const agentsMdCandidates = [
|
|
22064
|
-
|
|
22065
|
-
|
|
22066
|
-
|
|
22084
|
+
join39(baseDir, "AGENTS.md"),
|
|
22085
|
+
join39(baseDir, ".mma", "AGENTS.md"),
|
|
22086
|
+
join39(dir, "AGENTS.md")
|
|
22067
22087
|
];
|
|
22068
22088
|
for (const p of agentsMdCandidates) {
|
|
22069
|
-
if (
|
|
22070
|
-
const content =
|
|
22089
|
+
if (existsSync46(p)) {
|
|
22090
|
+
const content = readFileSync29(p, "utf-8").trim();
|
|
22071
22091
|
if (content) {
|
|
22072
22092
|
agentsMdBlocks.push({
|
|
22073
22093
|
content,
|
|
@@ -22095,6 +22115,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
22095
22115
|
baseDir,
|
|
22096
22116
|
toolTags: activeToolTags,
|
|
22097
22117
|
promptBlocks,
|
|
22118
|
+
envReport,
|
|
22098
22119
|
getDynamicPromptBlocks: () => {
|
|
22099
22120
|
const blocks = [];
|
|
22100
22121
|
const planBlock = execModule.getSystemPromptBlock();
|
|
@@ -22139,7 +22160,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
22139
22160
|
toolCtx,
|
|
22140
22161
|
configDir: dir,
|
|
22141
22162
|
baseDir,
|
|
22142
|
-
noAgentsMd: skipAgentsMd
|
|
22163
|
+
noAgentsMd: skipAgentsMd,
|
|
22164
|
+
envReport
|
|
22143
22165
|
};
|
|
22144
22166
|
}
|
|
22145
22167
|
var init_bootstrap = __esm(() => {
|
|
@@ -22939,20 +22961,20 @@ __export(exports_manifest, {
|
|
|
22939
22961
|
getCertMark: () => getCertMark,
|
|
22940
22962
|
MANIFEST_PATH: () => MANIFEST_PATH
|
|
22941
22963
|
});
|
|
22942
|
-
import { existsSync as
|
|
22964
|
+
import { existsSync as existsSync47, readFileSync as readFileSync30, mkdirSync as mkdirSync18, writeFileSync as writeFileSync16 } from "fs";
|
|
22943
22965
|
import { homedir as homedir14 } from "os";
|
|
22944
|
-
import { join as
|
|
22966
|
+
import { join as join41 } from "path";
|
|
22945
22967
|
function readManifest(path = MANIFEST_PATH) {
|
|
22946
22968
|
try {
|
|
22947
|
-
if (
|
|
22948
|
-
const raw = JSON.parse(
|
|
22969
|
+
if (existsSync47(path)) {
|
|
22970
|
+
const raw = JSON.parse(readFileSync30(path, "utf-8"));
|
|
22949
22971
|
return { version: 1, certifications: raw.certifications ?? [] };
|
|
22950
22972
|
}
|
|
22951
22973
|
} catch {}
|
|
22952
22974
|
return { version: 1, certifications: [] };
|
|
22953
22975
|
}
|
|
22954
22976
|
function saveManifest(m, path = MANIFEST_PATH) {
|
|
22955
|
-
mkdirSync18(
|
|
22977
|
+
mkdirSync18(join41(homedir14(), ".mma"), { recursive: true });
|
|
22956
22978
|
writeFileSync16(path, JSON.stringify(m, null, 2), "utf-8");
|
|
22957
22979
|
}
|
|
22958
22980
|
function upsertCertification(entry, path = MANIFEST_PATH) {
|
|
@@ -22987,7 +23009,7 @@ function getCertMark(model, providerUrl, currentVersion, path = MANIFEST_PATH) {
|
|
|
22987
23009
|
}
|
|
22988
23010
|
var MANIFEST_PATH;
|
|
22989
23011
|
var init_manifest = __esm(() => {
|
|
22990
|
-
MANIFEST_PATH =
|
|
23012
|
+
MANIFEST_PATH = join41(homedir14(), ".mma", "certifications.json");
|
|
22991
23013
|
});
|
|
22992
23014
|
|
|
22993
23015
|
// node_modules/yaml/dist/nodes/identity.js
|
|
@@ -30110,8 +30132,8 @@ var init_scenarios = __esm(() => {
|
|
|
30110
30132
|
});
|
|
30111
30133
|
|
|
30112
30134
|
// src/modules/certification/loader.ts
|
|
30113
|
-
import { existsSync as
|
|
30114
|
-
import { join as
|
|
30135
|
+
import { existsSync as existsSync48, readdirSync as readdirSync16, readFileSync as readFileSync31 } from "fs";
|
|
30136
|
+
import { join as join42 } from "path";
|
|
30115
30137
|
function validateScenario(s) {
|
|
30116
30138
|
const errors2 = [];
|
|
30117
30139
|
const isSkip = s.mode === "skip";
|
|
@@ -30160,12 +30182,12 @@ function loadScenarios(userDir) {
|
|
|
30160
30182
|
else
|
|
30161
30183
|
scenarios.push(s);
|
|
30162
30184
|
}
|
|
30163
|
-
if (userDir &&
|
|
30185
|
+
if (userDir && existsSync48(userDir)) {
|
|
30164
30186
|
for (const file of readdirSync16(userDir)) {
|
|
30165
30187
|
if (!file.endsWith(".yaml") && !file.endsWith(".yml"))
|
|
30166
30188
|
continue;
|
|
30167
30189
|
try {
|
|
30168
|
-
const raw =
|
|
30190
|
+
const raw = readFileSync31(join42(userDir, file), "utf-8");
|
|
30169
30191
|
const data = $parse(raw);
|
|
30170
30192
|
const parsed = normalizeScenario(data, file);
|
|
30171
30193
|
const errs = validateScenario(parsed);
|
|
@@ -30218,8 +30240,8 @@ var init_loader3 = __esm(() => {
|
|
|
30218
30240
|
});
|
|
30219
30241
|
|
|
30220
30242
|
// src/modules/certification/fact-checker.ts
|
|
30221
|
-
import { existsSync as
|
|
30222
|
-
import { join as
|
|
30243
|
+
import { existsSync as existsSync49, readFileSync as readFileSync32, statSync as statSync8 } from "fs";
|
|
30244
|
+
import { join as join43 } from "path";
|
|
30223
30245
|
function checkSandbox(sandboxDir, checks, exitCode, output) {
|
|
30224
30246
|
const failures = [];
|
|
30225
30247
|
for (const check of checks) {
|
|
@@ -30236,16 +30258,16 @@ function runCheck2(sandboxDir, check, exitCode, output) {
|
|
|
30236
30258
|
case "outputContains":
|
|
30237
30259
|
return output.includes(check.text);
|
|
30238
30260
|
case "fileExists":
|
|
30239
|
-
return isFile(
|
|
30261
|
+
return isFile(join43(sandboxDir, check.path));
|
|
30240
30262
|
case "fileNotExists":
|
|
30241
|
-
return !
|
|
30263
|
+
return !existsSync49(join43(sandboxDir, check.path));
|
|
30242
30264
|
case "dirExists":
|
|
30243
|
-
return isDir(
|
|
30265
|
+
return isDir(join43(sandboxDir, check.path));
|
|
30244
30266
|
case "fileContent": {
|
|
30245
|
-
const abs =
|
|
30267
|
+
const abs = join43(sandboxDir, check.path);
|
|
30246
30268
|
if (!isFile(abs))
|
|
30247
30269
|
return false;
|
|
30248
|
-
const content =
|
|
30270
|
+
const content = readFileSync32(abs, "utf-8");
|
|
30249
30271
|
if (check.contains !== undefined)
|
|
30250
30272
|
return content.includes(check.contains);
|
|
30251
30273
|
if (check.equals !== undefined)
|
|
@@ -30253,10 +30275,10 @@ function runCheck2(sandboxDir, check, exitCode, output) {
|
|
|
30253
30275
|
return false;
|
|
30254
30276
|
}
|
|
30255
30277
|
case "fileRegex": {
|
|
30256
|
-
const abs =
|
|
30278
|
+
const abs = join43(sandboxDir, check.path);
|
|
30257
30279
|
if (!isFile(abs))
|
|
30258
30280
|
return false;
|
|
30259
|
-
return new RegExp(check.pattern).test(
|
|
30281
|
+
return new RegExp(check.pattern).test(readFileSync32(abs, "utf-8"));
|
|
30260
30282
|
}
|
|
30261
30283
|
default:
|
|
30262
30284
|
return false;
|
|
@@ -30264,14 +30286,14 @@ function runCheck2(sandboxDir, check, exitCode, output) {
|
|
|
30264
30286
|
}
|
|
30265
30287
|
function isFile(p) {
|
|
30266
30288
|
try {
|
|
30267
|
-
return
|
|
30289
|
+
return existsSync49(p) && statSync8(p).isFile();
|
|
30268
30290
|
} catch {
|
|
30269
30291
|
return false;
|
|
30270
30292
|
}
|
|
30271
30293
|
}
|
|
30272
30294
|
function isDir(p) {
|
|
30273
30295
|
try {
|
|
30274
|
-
return
|
|
30296
|
+
return existsSync49(p) && statSync8(p).isDirectory();
|
|
30275
30297
|
} catch {
|
|
30276
30298
|
return false;
|
|
30277
30299
|
}
|
|
@@ -30302,9 +30324,9 @@ var init_fact_checker = () => {};
|
|
|
30302
30324
|
|
|
30303
30325
|
// src/modules/certification/runner.ts
|
|
30304
30326
|
import { spawn as spawn8 } from "child_process";
|
|
30305
|
-
import { existsSync as
|
|
30327
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync19, rmSync as rmSync4, cpSync as cpSync2 } from "fs";
|
|
30306
30328
|
import { platform as platform10 } from "os";
|
|
30307
|
-
import { join as
|
|
30329
|
+
import { join as join44, resolve as resolve24, dirname as dirname15 } from "path";
|
|
30308
30330
|
async function runScenario(scenario, opts) {
|
|
30309
30331
|
if (scenario.mode === "skip") {
|
|
30310
30332
|
return {
|
|
@@ -30323,7 +30345,7 @@ async function runScenario(scenario, opts) {
|
|
|
30323
30345
|
let passed = 0;
|
|
30324
30346
|
let firstError;
|
|
30325
30347
|
for (let i = 1;i <= reps; i++) {
|
|
30326
|
-
const sandbox =
|
|
30348
|
+
const sandbox = join44(opts.sandboxBase, `run-${scenario.id}-${i}`);
|
|
30327
30349
|
let failures = [];
|
|
30328
30350
|
let exitCode = -1;
|
|
30329
30351
|
let output = "";
|
|
@@ -30384,25 +30406,25 @@ function prepareSandbox(sandbox, scenario, mmaRoot) {
|
|
|
30384
30406
|
rmSync4(sandbox, { recursive: true, force: true });
|
|
30385
30407
|
mkdirSync19(sandbox, { recursive: true });
|
|
30386
30408
|
for (const f of scenario.fixtures ?? []) {
|
|
30387
|
-
const src =
|
|
30388
|
-
if (!
|
|
30409
|
+
const src = join44(mmaRoot, f.source);
|
|
30410
|
+
if (!existsSync50(src)) {
|
|
30389
30411
|
throw new Error(`fixture missing: ${f.source}`);
|
|
30390
30412
|
}
|
|
30391
|
-
const dest =
|
|
30413
|
+
const dest = join44(sandbox, f.dest);
|
|
30392
30414
|
mkdirSync19(dirname15(dest), { recursive: true });
|
|
30393
30415
|
cpSync2(src, dest);
|
|
30394
30416
|
}
|
|
30395
30417
|
}
|
|
30396
30418
|
function resolveMmaEntry(mmaRoot) {
|
|
30397
|
-
const dev =
|
|
30398
|
-
if (
|
|
30419
|
+
const dev = join44(mmaRoot, "src", "cli", "main.ts");
|
|
30420
|
+
if (existsSync50(dev))
|
|
30399
30421
|
return dev;
|
|
30400
|
-
return
|
|
30422
|
+
return join44(mmaRoot, "dist", "main.js");
|
|
30401
30423
|
}
|
|
30402
30424
|
function findMmaRoot(fromDir) {
|
|
30403
30425
|
const candidates = [resolve24(fromDir, "..", "..", ".."), resolve24(fromDir, "..")];
|
|
30404
30426
|
for (const c of candidates) {
|
|
30405
|
-
if (
|
|
30427
|
+
if (existsSync50(join44(c, "package.json")))
|
|
30406
30428
|
return c;
|
|
30407
30429
|
}
|
|
30408
30430
|
return process.cwd();
|
|
@@ -30470,15 +30492,15 @@ __export(exports_cli, {
|
|
|
30470
30492
|
});
|
|
30471
30493
|
import { rmSync as rmSync5 } from "fs";
|
|
30472
30494
|
import { homedir as homedir15 } from "os";
|
|
30473
|
-
import { join as
|
|
30495
|
+
import { join as join45, dirname as dirname16 } from "path";
|
|
30474
30496
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
30475
|
-
import { existsSync as
|
|
30497
|
+
import { existsSync as existsSync51, readFileSync as readFileSync33 } from "fs";
|
|
30476
30498
|
function readVersion() {
|
|
30477
|
-
const candidates = [
|
|
30499
|
+
const candidates = [join45(MMA_ROOT, "package.json")];
|
|
30478
30500
|
for (const p of candidates) {
|
|
30479
|
-
if (
|
|
30501
|
+
if (existsSync51(p)) {
|
|
30480
30502
|
try {
|
|
30481
|
-
const raw = JSON.parse(
|
|
30503
|
+
const raw = JSON.parse(readFileSync33(p, "utf-8"));
|
|
30482
30504
|
if (raw.version)
|
|
30483
30505
|
return raw.version;
|
|
30484
30506
|
} catch {}
|
|
@@ -30514,7 +30536,7 @@ async function certify(opts) {
|
|
|
30514
30536
|
return;
|
|
30515
30537
|
}
|
|
30516
30538
|
console.log(t("cli.cert_started", { model: opts.name, provider: providerUrl }));
|
|
30517
|
-
const sandboxBase =
|
|
30539
|
+
const sandboxBase = join45(process.cwd(), ".mma", "certification");
|
|
30518
30540
|
const results = [];
|
|
30519
30541
|
const total = selected.length;
|
|
30520
30542
|
let idx = 0;
|
|
@@ -30628,7 +30650,7 @@ var init_cli = __esm(() => {
|
|
|
30628
30650
|
init_manifest();
|
|
30629
30651
|
HERE = dirname16(fileURLToPath4(import.meta.url));
|
|
30630
30652
|
MMA_ROOT = findMmaRoot(HERE);
|
|
30631
|
-
USER_SCENARIO_DIR =
|
|
30653
|
+
USER_SCENARIO_DIR = join45(homedir15(), ".mma", "certification", "scenarios");
|
|
30632
30654
|
});
|
|
30633
30655
|
|
|
30634
30656
|
// src/cli/repl-commands.ts
|
|
@@ -30637,17 +30659,17 @@ __export(exports_repl_commands, {
|
|
|
30637
30659
|
registerAllCommands: () => registerAllCommands,
|
|
30638
30660
|
COMMAND_GROUPS: () => COMMAND_GROUPS
|
|
30639
30661
|
});
|
|
30640
|
-
import { join as
|
|
30662
|
+
import { join as join47, dirname as dirname18 } from "path";
|
|
30641
30663
|
import { homedir as homedir17 } from "os";
|
|
30642
|
-
import { existsSync as
|
|
30664
|
+
import { existsSync as existsSync53, readFileSync as readFileSync35 } from "fs";
|
|
30643
30665
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
30644
30666
|
function readVersion3() {
|
|
30645
30667
|
const here = dirname18(fileURLToPath6(import.meta.url));
|
|
30646
|
-
const candidates = [
|
|
30668
|
+
const candidates = [join47(here, "..", "..", "package.json"), join47(here, "..", "package.json")];
|
|
30647
30669
|
for (const p of candidates) {
|
|
30648
|
-
if (
|
|
30670
|
+
if (existsSync53(p)) {
|
|
30649
30671
|
try {
|
|
30650
|
-
const raw = JSON.parse(
|
|
30672
|
+
const raw = JSON.parse(readFileSync35(p, "utf8"));
|
|
30651
30673
|
if (raw.version)
|
|
30652
30674
|
return raw.version;
|
|
30653
30675
|
} catch {}
|
|
@@ -30711,7 +30733,7 @@ function registerMmaCommands(ctx) {
|
|
|
30711
30733
|
}
|
|
30712
30734
|
try {
|
|
30713
30735
|
const { loadFileAsDataUrl: loadFileAsDataUrl2, loadUrlAsDataUrl: loadUrlAsDataUrl2, readClipboardImage: readClipboardImage2 } = await Promise.resolve().then(() => (init_image_utils(), exports_image_utils));
|
|
30714
|
-
const { existsSync:
|
|
30736
|
+
const { existsSync: existsSync54 } = await import("fs");
|
|
30715
30737
|
const { resolve: resolve25 } = await import("path");
|
|
30716
30738
|
let dataUrl;
|
|
30717
30739
|
let label;
|
|
@@ -30731,7 +30753,7 @@ function registerMmaCommands(ctx) {
|
|
|
30731
30753
|
label = source;
|
|
30732
30754
|
} else {
|
|
30733
30755
|
const absPath = resolve25(process.cwd(), source);
|
|
30734
|
-
if (!
|
|
30756
|
+
if (!existsSync54(absPath)) {
|
|
30735
30757
|
console.log(pc2.red(t("image.not_found", { path: source })));
|
|
30736
30758
|
return;
|
|
30737
30759
|
}
|
|
@@ -30810,7 +30832,7 @@ function registerMmaCommands(ctx) {
|
|
|
30810
30832
|
console.log(pc2.yellow(t("repl.wizard_running")));
|
|
30811
30833
|
await ctx.withExclusiveInput(async () => {
|
|
30812
30834
|
const answers = await runSetup(ctx.rl);
|
|
30813
|
-
const configPath =
|
|
30835
|
+
const configPath = join47(homedir17(), ".mma", "config.json");
|
|
30814
30836
|
ctx.config.provider.type = answers.provider;
|
|
30815
30837
|
ctx.config.provider.baseUrl = answers.apiBase;
|
|
30816
30838
|
ctx.config.provider.apiKey = answers.apiKey;
|
|
@@ -30864,7 +30886,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
30864
30886
|
return;
|
|
30865
30887
|
}
|
|
30866
30888
|
ctx.config.provider.type = name;
|
|
30867
|
-
const configPath =
|
|
30889
|
+
const configPath = join47(homedir17(), ".mma", "config.json");
|
|
30868
30890
|
saveConfig(ctx.config, configPath);
|
|
30869
30891
|
await ctx.agent.reconfigure(ctx.config);
|
|
30870
30892
|
console.log(pc2.green(t("repl.provider_set", { name })));
|
|
@@ -30920,7 +30942,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
30920
30942
|
return;
|
|
30921
30943
|
}
|
|
30922
30944
|
ctx.config.model = name;
|
|
30923
|
-
const configPath =
|
|
30945
|
+
const configPath = join47(homedir17(), ".mma", "config.json");
|
|
30924
30946
|
saveConfig(ctx.config, configPath);
|
|
30925
30947
|
await ctx.agent.reconfigure(ctx.config);
|
|
30926
30948
|
console.log(pc2.green(t("repl.model_set", { name })));
|
|
@@ -30945,7 +30967,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
30945
30967
|
return;
|
|
30946
30968
|
}
|
|
30947
30969
|
ctx.config.contextWindow = size;
|
|
30948
|
-
const configPath =
|
|
30970
|
+
const configPath = join47(homedir17(), ".mma", "config.json");
|
|
30949
30971
|
saveConfig(ctx.config, configPath);
|
|
30950
30972
|
await ctx.agent.reconfigure(ctx.config);
|
|
30951
30973
|
console.log(pc2.green(t("cli.context_set", { size })));
|
|
@@ -30964,10 +30986,10 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
30964
30986
|
ctx.agent.shutdown();
|
|
30965
30987
|
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config2(), exports_config));
|
|
30966
30988
|
const { homedir: homedir18 } = await import("os");
|
|
30967
|
-
const { join:
|
|
30989
|
+
const { join: join48 } = await import("path");
|
|
30968
30990
|
const configDir = ctx.configDir;
|
|
30969
30991
|
const baseDir = ctx.baseDir;
|
|
30970
|
-
const projectConfigPath =
|
|
30992
|
+
const projectConfigPath = join48(baseDir, ".mmrc");
|
|
30971
30993
|
const freshConfig = loadConfig2({ configDir, projectConfigPath });
|
|
30972
30994
|
Object.assign(ctx.config, freshConfig);
|
|
30973
30995
|
const { bootstrap: bootstrap2 } = await Promise.resolve().then(() => (init_bootstrap(), exports_bootstrap));
|
|
@@ -31368,14 +31390,14 @@ init_bootstrap();
|
|
|
31368
31390
|
init_config2();
|
|
31369
31391
|
init_setup();
|
|
31370
31392
|
init_i18n();
|
|
31371
|
-
import { join as
|
|
31393
|
+
import { join as join46, dirname as dirname17 } from "path";
|
|
31372
31394
|
import { homedir as homedir16 } from "os";
|
|
31373
|
-
import { existsSync as
|
|
31395
|
+
import { existsSync as existsSync52, readFileSync as readFileSync34 } from "fs";
|
|
31374
31396
|
|
|
31375
31397
|
// src/cli/security-commands.ts
|
|
31376
31398
|
init_bootstrap();
|
|
31377
31399
|
init_config2();
|
|
31378
|
-
import { join as
|
|
31400
|
+
import { join as join40 } from "path";
|
|
31379
31401
|
import { homedir as homedir13 } from "os";
|
|
31380
31402
|
|
|
31381
31403
|
// src/modules/security/security-policies.ts
|
|
@@ -31889,7 +31911,7 @@ function createSecurityCommand(program2) {
|
|
|
31889
31911
|
}
|
|
31890
31912
|
});
|
|
31891
31913
|
securityCmd.command("set-policy").argument("<preset>", t("cli.security.preset")).description(t("cli.security.set_policy")).action(async (preset) => {
|
|
31892
|
-
const configPath =
|
|
31914
|
+
const configPath = join40(homedir13(), ".mma", "config.json");
|
|
31893
31915
|
const { config: appConfig } = await bootstrap();
|
|
31894
31916
|
const validPresets = ["strict", "balanced", "permissive"];
|
|
31895
31917
|
if (!validPresets.includes(preset)) {
|
|
@@ -31904,7 +31926,7 @@ function createSecurityCommand(program2) {
|
|
|
31904
31926
|
console.log(t("cli.security.policy_description", { description: policy.description }));
|
|
31905
31927
|
});
|
|
31906
31928
|
securityCmd.command("enable-encryption").description(t("cli.security.enable_encryption")).action(async () => {
|
|
31907
|
-
const configPath =
|
|
31929
|
+
const configPath = join40(homedir13(), ".mma", "config.json");
|
|
31908
31930
|
const { config: appConfig } = await bootstrap();
|
|
31909
31931
|
appConfig.security = appConfig.security || {};
|
|
31910
31932
|
appConfig.security.sessionEncryption = {
|
|
@@ -31916,7 +31938,7 @@ function createSecurityCommand(program2) {
|
|
|
31916
31938
|
console.log(t("cli.security.encryption_enabled"));
|
|
31917
31939
|
});
|
|
31918
31940
|
securityCmd.command("disable-encryption").description(t("cli.security.disable_encryption")).action(async () => {
|
|
31919
|
-
const configPath =
|
|
31941
|
+
const configPath = join40(homedir13(), ".mma", "config.json");
|
|
31920
31942
|
const { config: appConfig } = await bootstrap();
|
|
31921
31943
|
appConfig.security = appConfig.security || {};
|
|
31922
31944
|
appConfig.security.sessionEncryption = {
|
|
@@ -31928,7 +31950,7 @@ function createSecurityCommand(program2) {
|
|
|
31928
31950
|
console.log(t("cli.security.encryption_disabled"));
|
|
31929
31951
|
});
|
|
31930
31952
|
securityCmd.command("enable-audit").description(t("cli.security.enable_audit")).action(async () => {
|
|
31931
|
-
const configPath =
|
|
31953
|
+
const configPath = join40(homedir13(), ".mma", "config.json");
|
|
31932
31954
|
const { config: appConfig } = await bootstrap();
|
|
31933
31955
|
appConfig.security = appConfig.security || {};
|
|
31934
31956
|
appConfig.security.auditNotifier = {
|
|
@@ -31942,7 +31964,7 @@ function createSecurityCommand(program2) {
|
|
|
31942
31964
|
console.log(t("cli.security.audit_enabled"));
|
|
31943
31965
|
});
|
|
31944
31966
|
securityCmd.command("disable-audit").description(t("cli.security.disable_audit")).action(async () => {
|
|
31945
|
-
const configPath =
|
|
31967
|
+
const configPath = join40(homedir13(), ".mma", "config.json");
|
|
31946
31968
|
const { config: appConfig } = await bootstrap();
|
|
31947
31969
|
appConfig.security = appConfig.security || {};
|
|
31948
31970
|
appConfig.security.auditNotifier = {
|
|
@@ -32009,11 +32031,11 @@ init_setup();
|
|
|
32009
32031
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
32010
32032
|
function readVersion2() {
|
|
32011
32033
|
const here = dirname17(fileURLToPath5(import.meta.url));
|
|
32012
|
-
const candidates = [
|
|
32034
|
+
const candidates = [join46(here, "..", "..", "package.json"), join46(here, "..", "package.json")];
|
|
32013
32035
|
for (const p of candidates) {
|
|
32014
|
-
if (
|
|
32036
|
+
if (existsSync52(p)) {
|
|
32015
32037
|
try {
|
|
32016
|
-
const raw = JSON.parse(
|
|
32038
|
+
const raw = JSON.parse(readFileSync34(p, "utf8"));
|
|
32017
32039
|
if (raw.version)
|
|
32018
32040
|
return raw.version;
|
|
32019
32041
|
} catch {}
|
|
@@ -32026,7 +32048,7 @@ function createProgram() {
|
|
|
32026
32048
|
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"));
|
|
32027
32049
|
program2.command("init").description(t("cli.init")).action(async () => {
|
|
32028
32050
|
const answers = await runSetup();
|
|
32029
|
-
const configPath =
|
|
32051
|
+
const configPath = join46(homedir16(), ".mma", "config.json");
|
|
32030
32052
|
const { config } = await bootstrap();
|
|
32031
32053
|
config.provider.type = answers.provider;
|
|
32032
32054
|
config.provider.baseUrl = answers.apiBase;
|
|
@@ -32071,7 +32093,7 @@ function createProgram() {
|
|
|
32071
32093
|
});
|
|
32072
32094
|
const configCmd = program2.command("config").description(t("cli.manage_config"));
|
|
32073
32095
|
configCmd.command("set").argument("<key>", t("cli.config_key")).argument("<value>", "Config value").description(t("cli.set_value")).action(async (key, value) => {
|
|
32074
|
-
const configPath =
|
|
32096
|
+
const configPath = join46(homedir16(), ".mma", "config.json");
|
|
32075
32097
|
const { config } = await bootstrap();
|
|
32076
32098
|
const keys = key.split(".");
|
|
32077
32099
|
let obj = config;
|
|
@@ -32134,7 +32156,7 @@ function createProgram() {
|
|
|
32134
32156
|
console.log(t("cli.model_hint"));
|
|
32135
32157
|
});
|
|
32136
32158
|
model.command("use").argument("<name>", "Model name").description(t("cli.set_model")).action(async (name) => {
|
|
32137
|
-
const configPath =
|
|
32159
|
+
const configPath = join46(homedir16(), ".mma", "config.json");
|
|
32138
32160
|
const { config } = await bootstrap();
|
|
32139
32161
|
config.model = name;
|
|
32140
32162
|
saveConfig(config, configPath);
|
|
@@ -32170,7 +32192,7 @@ function createProgram() {
|
|
|
32170
32192
|
await uncertify2(name, config);
|
|
32171
32193
|
});
|
|
32172
32194
|
program2.command("context").description(t("cli.manage_context")).argument("<size>", "Context window size in tokens").action(async (size) => {
|
|
32173
|
-
const configPath =
|
|
32195
|
+
const configPath = join46(homedir16(), ".mma", "config.json");
|
|
32174
32196
|
const { config } = await bootstrap();
|
|
32175
32197
|
const contextWindow = parseInt(size, 10);
|
|
32176
32198
|
if (isNaN(contextWindow) || contextWindow < 1024) {
|
|
@@ -32188,7 +32210,7 @@ function createProgram() {
|
|
|
32188
32210
|
console.log(t("cli.base_url"), config.provider.baseUrl);
|
|
32189
32211
|
});
|
|
32190
32212
|
provider.command("use").argument("<name>", "Provider name").description(t("cli.set_provider")).action(async (name) => {
|
|
32191
|
-
const configPath =
|
|
32213
|
+
const configPath = join46(homedir16(), ".mma", "config.json");
|
|
32192
32214
|
const { config } = await bootstrap();
|
|
32193
32215
|
config.provider.type = name;
|
|
32194
32216
|
const baseUrl = HOSTED_BASE_URLS[name];
|
|
@@ -33003,8 +33025,8 @@ class LineEditor {
|
|
|
33003
33025
|
}
|
|
33004
33026
|
|
|
33005
33027
|
// src/cli/repl.ts
|
|
33006
|
-
import { existsSync as
|
|
33007
|
-
import { join as
|
|
33028
|
+
import { existsSync as existsSync55, readFileSync as readFileSync37, writeFileSync as writeFileSync17 } from "fs";
|
|
33029
|
+
import { join as join49 } from "path";
|
|
33008
33030
|
import { homedir as homedir18 } from "os";
|
|
33009
33031
|
|
|
33010
33032
|
// src/cli/completer.ts
|
|
@@ -33572,6 +33594,8 @@ async function probeLspServers(config, baseDir, deps = {}) {
|
|
|
33572
33594
|
const serverTimeout = Math.min(server.timeout ?? timeoutCap, timeoutCap);
|
|
33573
33595
|
const started = Date.now();
|
|
33574
33596
|
const probeClient = deps.client ?? new LspClient;
|
|
33597
|
+
if (!deps.client)
|
|
33598
|
+
probeClient.setLogger(deps.logger ?? null);
|
|
33575
33599
|
try {
|
|
33576
33600
|
await probeClient.probe(server, projectRoot, serverTimeout);
|
|
33577
33601
|
ok.push({ language, ok: true, durationMs: Date.now() - started });
|
|
@@ -33607,19 +33631,20 @@ async function probeLspServers(config, baseDir, deps = {}) {
|
|
|
33607
33631
|
|
|
33608
33632
|
// src/cli/repl.ts
|
|
33609
33633
|
init_config();
|
|
33634
|
+
init_session_logger();
|
|
33610
33635
|
|
|
33611
33636
|
// src/ui/plan-view.ts
|
|
33612
33637
|
init_colors();
|
|
33613
33638
|
init_js_identifiers();
|
|
33614
33639
|
init_i18n();
|
|
33615
|
-
import { existsSync as
|
|
33616
|
-
import { join as
|
|
33640
|
+
import { existsSync as existsSync54, readFileSync as readFileSync36 } from "fs";
|
|
33641
|
+
import { join as join48 } from "path";
|
|
33617
33642
|
function readActivePlan(baseDir) {
|
|
33618
|
-
const p =
|
|
33619
|
-
if (!
|
|
33643
|
+
const p = join48(baseDir, ".mma", "plans", "active.json");
|
|
33644
|
+
if (!existsSync54(p))
|
|
33620
33645
|
return null;
|
|
33621
33646
|
try {
|
|
33622
|
-
const raw =
|
|
33647
|
+
const raw = readFileSync36(p, "utf-8");
|
|
33623
33648
|
if (!raw.trim())
|
|
33624
33649
|
return null;
|
|
33625
33650
|
const parsed = JSON.parse(raw);
|
|
@@ -33754,7 +33779,9 @@ class Repl {
|
|
|
33754
33779
|
skillsModule;
|
|
33755
33780
|
pluginManager;
|
|
33756
33781
|
logger;
|
|
33757
|
-
|
|
33782
|
+
slog;
|
|
33783
|
+
envReport;
|
|
33784
|
+
constructor(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, exitOnClose, envReport) {
|
|
33758
33785
|
this.agent = agent;
|
|
33759
33786
|
this.config = config;
|
|
33760
33787
|
this.exitOnClose = exitOnClose === true;
|
|
@@ -33762,10 +33789,12 @@ class Repl {
|
|
|
33762
33789
|
this.skillsModule = skillsModule;
|
|
33763
33790
|
this.pluginManager = pluginManager;
|
|
33764
33791
|
this.logger = logger;
|
|
33765
|
-
this.
|
|
33792
|
+
this.envReport = envReport;
|
|
33793
|
+
this.slog = new SessionLogger(sessionManager, logger);
|
|
33794
|
+
this.configDir = configDir || join49(homedir18(), ".mma");
|
|
33766
33795
|
this.baseDir = baseDir || process.cwd();
|
|
33767
33796
|
this.noAgentsMd = noAgentsMd === true;
|
|
33768
|
-
this.historyPath =
|
|
33797
|
+
this.historyPath = join49(homedir18(), ".mma", "repl-history");
|
|
33769
33798
|
this.loadHistory();
|
|
33770
33799
|
this.rl = process.stdin.isTTY ? new LineEditor({
|
|
33771
33800
|
input: process.stdin,
|
|
@@ -33798,9 +33827,9 @@ class Repl {
|
|
|
33798
33827
|
this.setupListeners();
|
|
33799
33828
|
}
|
|
33800
33829
|
loadHistory() {
|
|
33801
|
-
if (
|
|
33830
|
+
if (existsSync55(this.historyPath)) {
|
|
33802
33831
|
try {
|
|
33803
|
-
const raw =
|
|
33832
|
+
const raw = readFileSync37(this.historyPath, "utf-8");
|
|
33804
33833
|
this.history = raw.split(`
|
|
33805
33834
|
`).filter(Boolean).slice(-this.maxHistory);
|
|
33806
33835
|
} catch {
|
|
@@ -33876,6 +33905,7 @@ class Repl {
|
|
|
33876
33905
|
return;
|
|
33877
33906
|
}
|
|
33878
33907
|
if (!trimmed) {
|
|
33908
|
+
this.rl.setPrompt(pc2.cyan(t("repl.you")));
|
|
33879
33909
|
this.rl.prompt();
|
|
33880
33910
|
return;
|
|
33881
33911
|
}
|
|
@@ -33885,6 +33915,7 @@ class Repl {
|
|
|
33885
33915
|
await this.runAgent(trimmed);
|
|
33886
33916
|
}
|
|
33887
33917
|
if (this.running) {
|
|
33918
|
+
this.rl.setPrompt(pc2.cyan(t("repl.you")));
|
|
33888
33919
|
this.rl.prompt();
|
|
33889
33920
|
}
|
|
33890
33921
|
});
|
|
@@ -34178,11 +34209,11 @@ ${t("image.clipboard_empty")}`));
|
|
|
34178
34209
|
row(t("repl.agents_label"), pc2.red(t("repl.disabled")));
|
|
34179
34210
|
} else {
|
|
34180
34211
|
const agentsMdCandidates = [
|
|
34181
|
-
|
|
34182
|
-
|
|
34183
|
-
|
|
34212
|
+
join49(this.baseDir, "AGENTS.md"),
|
|
34213
|
+
join49(this.baseDir, ".mma", "AGENTS.md"),
|
|
34214
|
+
join49(this.configDir, "AGENTS.md")
|
|
34184
34215
|
];
|
|
34185
|
-
const foundAgents = agentsMdCandidates.filter((p) =>
|
|
34216
|
+
const foundAgents = agentsMdCandidates.filter((p) => existsSync55(p));
|
|
34186
34217
|
if (foundAgents.length > 0) {
|
|
34187
34218
|
for (const p of foundAgents) {
|
|
34188
34219
|
row(t("repl.agents_label"), pc2.dim(p));
|
|
@@ -34193,7 +34224,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
34193
34224
|
}
|
|
34194
34225
|
const meta = this.sessionManager?.getActiveMeta();
|
|
34195
34226
|
if (meta) {
|
|
34196
|
-
const sessionPath =
|
|
34227
|
+
const sessionPath = join49(this.configDir, "sessions", meta.id);
|
|
34197
34228
|
row(t("repl.session_label"), `${pc2.cyan(meta.name)} ${pc2.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc2.dim(sessionPath)}`);
|
|
34198
34229
|
}
|
|
34199
34230
|
const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
|
|
@@ -34228,7 +34259,19 @@ ${t("image.clipboard_empty")}`));
|
|
|
34228
34259
|
async probeLspBanner() {
|
|
34229
34260
|
const config = this.config.lsp ?? DEFAULT_LSP_CONFIG;
|
|
34230
34261
|
try {
|
|
34231
|
-
const summary = await probeLspServers(config, this.baseDir);
|
|
34262
|
+
const summary = await probeLspServers(config, this.baseDir, { logger: this.logger });
|
|
34263
|
+
this.slog.logSessionStart({
|
|
34264
|
+
environment: this.envReport,
|
|
34265
|
+
lspProbe: {
|
|
34266
|
+
ok: summary.ok.map((r) => ({ language: r.language, durationMs: r.durationMs })),
|
|
34267
|
+
failed: summary.failed.map((r) => ({
|
|
34268
|
+
language: r.language,
|
|
34269
|
+
error: r.error,
|
|
34270
|
+
durationMs: r.durationMs
|
|
34271
|
+
})),
|
|
34272
|
+
noneApplicable: summary.noneApplicable
|
|
34273
|
+
}
|
|
34274
|
+
});
|
|
34232
34275
|
if (summary.noneApplicable)
|
|
34233
34276
|
return null;
|
|
34234
34277
|
const parts = [];
|
|
@@ -34279,8 +34322,8 @@ init_setup();
|
|
|
34279
34322
|
init_config2();
|
|
34280
34323
|
init_i18n();
|
|
34281
34324
|
init_colors();
|
|
34282
|
-
import { existsSync as
|
|
34283
|
-
import { join as
|
|
34325
|
+
import { existsSync as existsSync56, readFileSync as readFileSync38 } from "fs";
|
|
34326
|
+
import { join as join51, dirname as dirname19 } from "path";
|
|
34284
34327
|
import { homedir as homedir20 } from "os";
|
|
34285
34328
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
34286
34329
|
|
|
@@ -34386,9 +34429,9 @@ init_environment();
|
|
|
34386
34429
|
init_data_sanitizer();
|
|
34387
34430
|
init_i18n();
|
|
34388
34431
|
import { appendFileSync as appendFileSync7, mkdirSync as mkdirSync20 } from "fs";
|
|
34389
|
-
import { join as
|
|
34432
|
+
import { join as join50 } from "path";
|
|
34390
34433
|
import { homedir as homedir19 } from "os";
|
|
34391
|
-
var CRASH_LOG_DIR =
|
|
34434
|
+
var CRASH_LOG_DIR = join50(homedir19(), ".mma", "logs");
|
|
34392
34435
|
var CRASH_LOG_FILE = "crash.jsonl";
|
|
34393
34436
|
function formatCrashEntry(type2, err) {
|
|
34394
34437
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -34404,7 +34447,7 @@ function formatCrashEntry(type2, err) {
|
|
|
34404
34447
|
function writeCrashEntry(dir, entry) {
|
|
34405
34448
|
try {
|
|
34406
34449
|
mkdirSync20(dir, { recursive: true });
|
|
34407
|
-
appendFileSync7(
|
|
34450
|
+
appendFileSync7(join50(dir, CRASH_LOG_FILE), JSON.stringify(entry) + `
|
|
34408
34451
|
`, "utf-8");
|
|
34409
34452
|
} catch {}
|
|
34410
34453
|
}
|
|
@@ -34431,11 +34474,11 @@ function installCrashHandlers() {
|
|
|
34431
34474
|
// src/cli/main.ts
|
|
34432
34475
|
function readVersion4() {
|
|
34433
34476
|
const here = dirname19(fileURLToPath7(import.meta.url));
|
|
34434
|
-
const candidates = [
|
|
34477
|
+
const candidates = [join51(here, "..", "..", "package.json"), join51(here, "..", "package.json")];
|
|
34435
34478
|
for (const p of candidates) {
|
|
34436
|
-
if (
|
|
34479
|
+
if (existsSync56(p)) {
|
|
34437
34480
|
try {
|
|
34438
|
-
const raw = JSON.parse(
|
|
34481
|
+
const raw = JSON.parse(readFileSync38(p, "utf8"));
|
|
34439
34482
|
if (raw.version)
|
|
34440
34483
|
return raw.version;
|
|
34441
34484
|
} catch {}
|
|
@@ -34520,15 +34563,15 @@ async function main() {
|
|
|
34520
34563
|
await updater?.waitForIdle();
|
|
34521
34564
|
process.exit(exitCode);
|
|
34522
34565
|
} else {
|
|
34523
|
-
const configPath =
|
|
34524
|
-
if (!
|
|
34566
|
+
const configPath = join51(homedir20(), ".mma", "config.json");
|
|
34567
|
+
if (!existsSync56(configPath)) {
|
|
34525
34568
|
console.log(pc2.yellow(`
|
|
34526
34569
|
` + t("cli.first_run") + `
|
|
34527
34570
|
`));
|
|
34528
34571
|
const answers = await runSetup();
|
|
34529
34572
|
const config2 = loadConfig({
|
|
34530
|
-
configDir:
|
|
34531
|
-
projectConfigPath: projectDir ?
|
|
34573
|
+
configDir: join51(homedir20(), ".mma"),
|
|
34574
|
+
projectConfigPath: projectDir ? join51(projectDir, ".mmrc") : join51(process.cwd(), ".mmrc")
|
|
34532
34575
|
});
|
|
34533
34576
|
config2.provider.type = answers.provider;
|
|
34534
34577
|
config2.provider.baseUrl = answers.apiBase;
|
|
@@ -34578,10 +34621,11 @@ async function main() {
|
|
|
34578
34621
|
pluginManager,
|
|
34579
34622
|
configDir,
|
|
34580
34623
|
baseDir,
|
|
34581
|
-
logger
|
|
34624
|
+
logger,
|
|
34625
|
+
envReport
|
|
34582
34626
|
} = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
|
|
34583
34627
|
startAutoUpdate(config);
|
|
34584
|
-
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true);
|
|
34628
|
+
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true, envReport);
|
|
34585
34629
|
await repl.start();
|
|
34586
34630
|
}
|
|
34587
34631
|
}
|