micro-models-agent 0.61.0 → 0.61.1
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/CHANGELOG.md +601 -595
- package/README.md +358 -358
- package/dist/certification/certifications.json +493 -493
- package/dist/cli/commands.js +447 -0
- package/dist/cli/completer.js +167 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/main.js +153 -0
- package/dist/cli/plugin-commands.js +36 -0
- package/dist/cli/repl-commands.js +761 -0
- package/dist/cli/repl.js +702 -0
- package/dist/cli/run-result.js +33 -0
- package/dist/cli/security-commands.js +164 -0
- package/dist/cli/setup.js +237 -0
- package/dist/config/config.js +276 -0
- package/dist/config/defaults.js +141 -0
- package/dist/config/domains.js +179 -0
- package/dist/config/experts.js +15 -0
- package/dist/config/index.js +4 -0
- package/dist/config/security.js +213 -0
- package/dist/config/types.js +1 -0
- package/dist/core/agent-moe.js +102 -0
- package/dist/core/agent.js +1018 -0
- package/dist/core/bootstrap.js +481 -0
- package/dist/core/crash-handler.js +51 -0
- package/dist/core/environment.js +199 -0
- package/dist/core/index.js +2 -0
- package/dist/core/prompt-builder.js +76 -0
- package/dist/core/session-logger.js +251 -0
- package/dist/core/types.js +1 -0
- package/dist/core/version.js +26 -0
- package/dist/core/workspace.js +76 -0
- package/dist/i18n/en.json +757 -757
- package/dist/i18n/index.js +46 -0
- package/dist/i18n/ru.json +757 -757
- package/dist/index.js +22 -0
- package/dist/llm/image-utils.js +143 -0
- package/dist/llm/index.js +4 -0
- package/dist/llm/model-loader.js +78 -0
- package/dist/llm/openai-compat.js +497 -0
- package/dist/llm/orchestrator.js +200 -0
- package/dist/llm/provider.js +10 -0
- package/dist/llm/response.js +39 -0
- package/dist/llm/token-counter.js +39 -0
- package/dist/llm/types.js +1 -0
- package/dist/logger/app-logger.js +189 -0
- package/dist/logger/file-log.js +151 -0
- package/dist/logger/index.js +1 -0
- package/dist/main.js +364 -325
- package/dist/migration/backup.js +45 -0
- package/dist/migration/detect.js +50 -0
- package/dist/migration/index.js +2 -0
- package/dist/modules/artifacts/store.js +61 -0
- package/dist/modules/browser/actions.js +76 -0
- package/dist/modules/browser/bridge-client.js +199 -0
- package/dist/modules/browser/bridge-path.js +10 -0
- package/dist/modules/browser/bridge-server.mjs +219 -219
- package/dist/modules/browser/cookie-store.js +24 -0
- package/dist/modules/browser/driver.js +136 -0
- package/dist/modules/browser/index.js +7 -0
- package/dist/modules/browser/module.js +29 -0
- package/dist/modules/browser/session.js +342 -0
- package/dist/modules/browser/snapshot.js +148 -0
- package/dist/modules/browser/types.js +12 -0
- package/dist/modules/certification/cli.js +213 -0
- package/dist/modules/certification/fact-checker.js +82 -0
- package/dist/modules/certification/loader.js +106 -0
- package/dist/modules/certification/manifest.js +58 -0
- package/dist/modules/certification/runner.js +245 -0
- package/dist/modules/certification/scenarios.js +407 -0
- package/dist/modules/certification/types.js +1 -0
- package/dist/modules/context/chunk-query.js +100 -0
- package/dist/modules/context/fact-extractor.js +168 -0
- package/dist/modules/context/history.js +15 -0
- package/dist/modules/context/index.js +1 -0
- package/dist/modules/context/manager.js +440 -0
- package/dist/modules/execution/audit-runners.js +206 -0
- package/dist/modules/execution/auditor.js +218 -0
- package/dist/modules/execution/execution-plugin.js +431 -0
- package/dist/modules/execution/index.js +8 -0
- package/dist/modules/execution/module.js +625 -0
- package/dist/modules/execution/moe-executor.js +304 -0
- package/dist/modules/execution/plan-coverage.js +68 -0
- package/dist/modules/execution/plan-persister.js +46 -0
- package/dist/modules/execution/plan-store.js +196 -0
- package/dist/modules/execution/plan-tool.js +677 -0
- package/dist/modules/execution/plan-validator.js +153 -0
- package/dist/modules/execution/planner.js +94 -0
- package/dist/modules/execution/stuck-detector.js +746 -0
- package/dist/modules/execution/tracker.js +69 -0
- package/dist/modules/execution/types.js +1 -0
- package/dist/modules/execution/verifier.js +235 -0
- package/dist/modules/execution/windows-commands.js +41 -0
- package/dist/modules/hallucination/confidence.js +66 -0
- package/dist/modules/hallucination/consistency.js +26 -0
- package/dist/modules/hallucination/detector.js +47 -0
- package/dist/modules/hallucination/factual.js +169 -0
- package/dist/modules/hallucination/index.js +5 -0
- package/dist/modules/hallucination/js-identifiers.js +262 -0
- package/dist/modules/hallucination/llm-judge.js +101 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/indexer/cache.js +40 -0
- package/dist/modules/indexer/index.js +3 -0
- package/dist/modules/indexer/module.js +246 -0
- package/dist/modules/indexer/project-profile.js +183 -0
- package/dist/modules/indexer/walker.js +101 -0
- package/dist/modules/lsp/check-tool.js +58 -0
- package/dist/modules/lsp/client.js +389 -0
- package/dist/modules/lsp/command.js +60 -0
- package/dist/modules/lsp/config.js +135 -0
- package/dist/modules/lsp/index.js +3 -0
- package/dist/modules/lsp/module.js +260 -0
- package/dist/modules/lsp/probe.js +86 -0
- package/dist/modules/lsp/project-root.js +32 -0
- package/dist/modules/lsp/startup-check.js +144 -0
- package/dist/modules/lsp/types.js +1 -0
- package/dist/modules/mcp/client.js +399 -0
- package/dist/modules/mcp/index.js +3 -0
- package/dist/modules/mcp/module.js +142 -0
- package/dist/modules/mcp/registry.js +15 -0
- package/dist/modules/memory/index.js +1 -0
- package/dist/modules/memory/module.js +96 -0
- package/dist/modules/memory/search.js +42 -0
- package/dist/modules/memory/store.js +69 -0
- package/dist/modules/pipelines/engine.js +60 -0
- package/dist/modules/pipelines/index.js +3 -0
- package/dist/modules/pipelines/parser.js +56 -0
- package/dist/modules/pipelines/template.js +14 -0
- package/dist/modules/plugins/builtin/lint-on-write.js +334 -0
- package/dist/modules/plugins/builtin/notify.js +9 -0
- package/dist/modules/plugins/index.js +1 -0
- package/dist/modules/plugins/loader.js +70 -0
- package/dist/modules/plugins/manager.js +261 -0
- package/dist/modules/plugins/types.js +1 -0
- package/dist/modules/pricing/index.js +61 -0
- package/dist/modules/pricing/prices.js +129 -0
- package/dist/modules/processes/detect.js +34 -0
- package/dist/modules/processes/index.js +2 -0
- package/dist/modules/processes/registry.js +327 -0
- package/dist/modules/processes/runner.js +23 -0
- package/dist/modules/providers/create.js +22 -0
- package/dist/modules/providers/fallback.js +79 -0
- package/dist/modules/providers/health.js +46 -0
- package/dist/modules/providers/index.js +5 -0
- package/dist/modules/providers/manager.js +161 -0
- package/dist/modules/providers/presets.js +128 -0
- package/dist/modules/providers/registry.js +22 -0
- package/dist/modules/providers/types.js +1 -0
- package/dist/modules/registry.js +48 -0
- package/dist/modules/security/audit-log.js +136 -0
- package/dist/modules/security/audit-notifier.js +292 -0
- package/dist/modules/security/command-validator.js +219 -0
- package/dist/modules/security/content-scanner.js +53 -0
- package/dist/modules/security/data-sanitizer.js +89 -0
- package/dist/modules/security/encryption.js +242 -0
- package/dist/modules/security/index.js +14 -0
- package/dist/modules/security/network-validator.js +88 -0
- package/dist/modules/security/path-validator.js +203 -0
- package/dist/modules/security/rate-limiter.js +119 -0
- package/dist/modules/security/security-policies.js +531 -0
- package/dist/modules/security/session-encryption.js +210 -0
- package/dist/modules/security/session-isolation.js +95 -0
- package/dist/modules/session/index.js +3 -0
- package/dist/modules/session/manager.js +172 -0
- package/dist/modules/session/module.js +24 -0
- package/dist/modules/session/store.js +222 -0
- package/dist/modules/session/types.js +1 -0
- package/dist/modules/skills/index.js +2 -0
- package/dist/modules/skills/loader.js +72 -0
- package/dist/modules/skills/matcher.js +27 -0
- package/dist/modules/skills/module.js +129 -0
- package/dist/modules/types.js +1 -0
- package/dist/modules/updater/checker.js +96 -0
- package/dist/modules/updater/index.js +2 -0
- package/dist/modules/updater/module.js +116 -0
- package/dist/modules/user-profile/compressor.js +16 -0
- package/dist/modules/user-profile/index.js +1 -0
- package/dist/modules/user-profile/profile.js +68 -0
- package/dist/skills/builtin/git.md +36 -36
- package/dist/skills/builtin/typescript.md +35 -35
- package/dist/tools/approve.js +33 -0
- package/dist/tools/attach-image.js +101 -0
- package/dist/tools/bash.js +519 -0
- package/dist/tools/browser.js +115 -0
- package/dist/tools/chunk-query.js +100 -0
- package/dist/tools/create-dir.js +56 -0
- package/dist/tools/delete-file.js +63 -0
- package/dist/tools/download-file.js +117 -0
- package/dist/tools/edit-file.js +80 -0
- package/dist/tools/enable-tools.js +59 -0
- package/dist/tools/executor.js +154 -0
- package/dist/tools/file-info.js +47 -0
- package/dist/tools/filter-tools.js +17 -0
- package/dist/tools/glob-tool.js +27 -0
- package/dist/tools/grep-tool.js +125 -0
- package/dist/tools/hidden-tools-block.js +37 -0
- package/dist/tools/index.js +78 -0
- package/dist/tools/list-dir.js +49 -0
- package/dist/tools/load-skill.js +43 -0
- package/dist/tools/mcp-call.js +69 -0
- package/dist/tools/move-file.js +86 -0
- package/dist/tools/path-utils.js +101 -0
- package/dist/tools/pipeline-run.js +145 -0
- package/dist/tools/preview.js +2 -0
- package/dist/tools/process-kill.js +40 -0
- package/dist/tools/process-list.js +37 -0
- package/dist/tools/process-log.js +54 -0
- package/dist/tools/question.js +141 -0
- package/dist/tools/read-file.js +179 -0
- package/dist/tools/recall.js +118 -0
- package/dist/tools/registry.js +47 -0
- package/dist/tools/remember.js +68 -0
- package/dist/tools/scope-check.js +32 -0
- package/dist/tools/search-history.js +85 -0
- package/dist/tools/subagent.js +196 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/user-input.js +123 -0
- package/dist/tools/web-browse.js +87 -0
- package/dist/tools/web-fetch.js +119 -0
- package/dist/tools/web-search.js +105 -0
- package/dist/tools/write-file.js +82 -0
- package/dist/ui/box.js +77 -0
- package/dist/ui/colors.js +4 -0
- package/dist/ui/diff.js +178 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/line-editor.js +822 -0
- package/dist/ui/line-math.js +73 -0
- package/dist/ui/md-formatter.js +212 -0
- package/dist/ui/output.js +13 -0
- package/dist/ui/plan-view.js +103 -0
- package/dist/ui/renderer.js +259 -0
- package/dist/ui/spinner.js +70 -0
- package/dist/ui/table.js +144 -0
- package/package.json +51 -51
package/dist/main.js
CHANGED
|
@@ -5742,6 +5742,26 @@ var init_token_counter = __esm(() => {
|
|
|
5742
5742
|
init_dist();
|
|
5743
5743
|
});
|
|
5744
5744
|
|
|
5745
|
+
// src/core/version.ts
|
|
5746
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "fs";
|
|
5747
|
+
import { join as join9, dirname as dirname3 } from "path";
|
|
5748
|
+
import { fileURLToPath } from "url";
|
|
5749
|
+
function readMmaVersion() {
|
|
5750
|
+
const here = dirname3(fileURLToPath(import.meta.url));
|
|
5751
|
+
const candidates = [join9(here, "..", "..", "package.json"), join9(here, "..", "package.json")];
|
|
5752
|
+
for (const p of candidates) {
|
|
5753
|
+
if (existsSync9(p)) {
|
|
5754
|
+
try {
|
|
5755
|
+
const raw = JSON.parse(readFileSync5(p, "utf8"));
|
|
5756
|
+
if (raw.version)
|
|
5757
|
+
return raw.version;
|
|
5758
|
+
} catch {}
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5761
|
+
return "0.0.0";
|
|
5762
|
+
}
|
|
5763
|
+
var init_version = () => {};
|
|
5764
|
+
|
|
5745
5765
|
// src/modules/security/rate-limiter.ts
|
|
5746
5766
|
class RateLimiter {
|
|
5747
5767
|
config;
|
|
@@ -5878,6 +5898,11 @@ var exports_openai_compat = {};
|
|
|
5878
5898
|
__export(exports_openai_compat, {
|
|
5879
5899
|
OpenAICompatProvider: () => OpenAICompatProvider
|
|
5880
5900
|
});
|
|
5901
|
+
function defaultUserAgent() {
|
|
5902
|
+
if (cachedUserAgent === null)
|
|
5903
|
+
cachedUserAgent = `micro-models-agent/${readMmaVersion()}`;
|
|
5904
|
+
return cachedUserAgent;
|
|
5905
|
+
}
|
|
5881
5906
|
function buildRequestBody(opts) {
|
|
5882
5907
|
const body = {
|
|
5883
5908
|
model: opts.model,
|
|
@@ -5917,6 +5942,8 @@ class OpenAICompatProvider {
|
|
|
5917
5942
|
retryConfig;
|
|
5918
5943
|
rateLimiter;
|
|
5919
5944
|
debug;
|
|
5945
|
+
getSessionId;
|
|
5946
|
+
userAgent;
|
|
5920
5947
|
constructor(config) {
|
|
5921
5948
|
this.config = config;
|
|
5922
5949
|
this.model = config.model;
|
|
@@ -5930,6 +5957,8 @@ class OpenAICompatProvider {
|
|
|
5930
5957
|
noDataTimeoutMs: 180000
|
|
5931
5958
|
};
|
|
5932
5959
|
this.rateLimiter = createRateLimiter(config.rateLimits);
|
|
5960
|
+
this.getSessionId = config.getSessionId;
|
|
5961
|
+
this.userAgent = config.userAgent ?? defaultUserAgent();
|
|
5933
5962
|
this.debug = config.logger ? config.logger.debug.bind(config.logger) : null;
|
|
5934
5963
|
}
|
|
5935
5964
|
async* chat(messages, tools, signal, options) {
|
|
@@ -6219,11 +6248,15 @@ class OpenAICompatProvider {
|
|
|
6219
6248
|
}
|
|
6220
6249
|
buildRequestSetup(signal) {
|
|
6221
6250
|
const headers = {
|
|
6222
|
-
"Content-Type": "application/json"
|
|
6251
|
+
"Content-Type": "application/json",
|
|
6252
|
+
"User-Agent": this.userAgent
|
|
6223
6253
|
};
|
|
6224
6254
|
if (this.config.apiKey && this.config.apiKey !== "not-needed") {
|
|
6225
6255
|
headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
6226
6256
|
}
|
|
6257
|
+
const sessionId = this.getSessionId?.();
|
|
6258
|
+
if (sessionId)
|
|
6259
|
+
headers["x-opencode-session"] = sessionId;
|
|
6227
6260
|
const controller = new AbortController;
|
|
6228
6261
|
let timedOut = false;
|
|
6229
6262
|
const timeoutId = setTimeout(() => {
|
|
@@ -6335,7 +6368,8 @@ class OpenAICompatProvider {
|
|
|
6335
6368
|
try {
|
|
6336
6369
|
const url = `${this.config.baseUrl.replace(/\/+$/, "")}/models`;
|
|
6337
6370
|
const headers = {
|
|
6338
|
-
"Content-Type": "application/json"
|
|
6371
|
+
"Content-Type": "application/json",
|
|
6372
|
+
"User-Agent": this.userAgent
|
|
6339
6373
|
};
|
|
6340
6374
|
if (this.config.apiKey && this.config.apiKey !== "not-needed") {
|
|
6341
6375
|
headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
@@ -6409,10 +6443,11 @@ class OpenAICompatProvider {
|
|
|
6409
6443
|
});
|
|
6410
6444
|
}
|
|
6411
6445
|
}
|
|
6412
|
-
var REQUEST_TIMEOUT_MS = 120000, MAX_RATE_WAIT_MS = 30000;
|
|
6446
|
+
var REQUEST_TIMEOUT_MS = 120000, MAX_RATE_WAIT_MS = 30000, cachedUserAgent = null;
|
|
6413
6447
|
var init_openai_compat = __esm(() => {
|
|
6414
6448
|
init_token_counter();
|
|
6415
6449
|
init_i18n();
|
|
6450
|
+
init_version();
|
|
6416
6451
|
init_rate_limiter();
|
|
6417
6452
|
init_llm_errors();
|
|
6418
6453
|
});
|
|
@@ -6433,6 +6468,7 @@ function openaiCompat(opts) {
|
|
|
6433
6468
|
retry,
|
|
6434
6469
|
rateLimits,
|
|
6435
6470
|
maxCompletionTokens: opts.maxCompletionTokens,
|
|
6471
|
+
getSessionId: opts.getSessionId,
|
|
6436
6472
|
logger: opts.logger
|
|
6437
6473
|
});
|
|
6438
6474
|
}
|
|
@@ -6710,6 +6746,7 @@ class ProviderManager {
|
|
|
6710
6746
|
retry: entry.retry ?? this.opts.retry,
|
|
6711
6747
|
rateLimits: entry.rateLimits ?? this.opts.rateLimits,
|
|
6712
6748
|
maxCompletionTokens: entry.maxCompletionTokens,
|
|
6749
|
+
getSessionId: this.opts.getSessionId,
|
|
6713
6750
|
logger: this.opts.logger
|
|
6714
6751
|
}, this.registry);
|
|
6715
6752
|
this.cache.set(key, provider);
|
|
@@ -6794,11 +6831,12 @@ var init_fallback = __esm(() => {
|
|
|
6794
6831
|
});
|
|
6795
6832
|
|
|
6796
6833
|
// src/modules/providers/factory.ts
|
|
6797
|
-
function buildActiveProvider(config, logger) {
|
|
6834
|
+
function buildActiveProvider(config, logger, opts) {
|
|
6798
6835
|
const manager = new ProviderManager(config.provider, {
|
|
6799
6836
|
contextWindow: config.contextWindow,
|
|
6800
6837
|
retry: config.retry,
|
|
6801
6838
|
rateLimits: config.security?.rateLimits,
|
|
6839
|
+
getSessionId: opts?.getSessionId,
|
|
6802
6840
|
logger
|
|
6803
6841
|
});
|
|
6804
6842
|
manager.setModel(config.model);
|
|
@@ -7142,8 +7180,8 @@ var init_executor = __esm(() => {
|
|
|
7142
7180
|
});
|
|
7143
7181
|
|
|
7144
7182
|
// src/tools/path-utils.ts
|
|
7145
|
-
import { resolve, normalize, dirname as
|
|
7146
|
-
import { existsSync as
|
|
7183
|
+
import { resolve, normalize, dirname as dirname4, basename, sep, relative, isAbsolute } from "path";
|
|
7184
|
+
import { existsSync as existsSync10 } from "fs";
|
|
7147
7185
|
function toForwardSlash(p) {
|
|
7148
7186
|
return p.replace(/\\/g, "/");
|
|
7149
7187
|
}
|
|
@@ -7164,30 +7202,30 @@ function matchesScopeEntry(targetResolved, entryResolved) {
|
|
|
7164
7202
|
function safeResolvePath(baseDir, userPath) {
|
|
7165
7203
|
const asIs = resolve(normalize(userPath));
|
|
7166
7204
|
if (userPath.startsWith("/") || userPath.startsWith("\\")) {
|
|
7167
|
-
if (
|
|
7205
|
+
if (existsSync10(asIs) || existsSync10(dirname4(asIs)))
|
|
7168
7206
|
return asIs;
|
|
7169
7207
|
}
|
|
7170
7208
|
const norm = normalize(userPath);
|
|
7171
7209
|
if (isAbsolute(norm)) {
|
|
7172
|
-
if (
|
|
7210
|
+
if (existsSync10(norm) || existsSync10(dirname4(norm)))
|
|
7173
7211
|
return norm;
|
|
7174
7212
|
const stripped2 = norm.replace(/^[/\\]/, "");
|
|
7175
7213
|
const relativeCandidate = resolve(baseDir, stripped2);
|
|
7176
|
-
if (
|
|
7214
|
+
if (existsSync10(relativeCandidate) || existsSync10(dirname4(relativeCandidate))) {
|
|
7177
7215
|
return relativeCandidate;
|
|
7178
7216
|
}
|
|
7179
7217
|
return norm;
|
|
7180
7218
|
}
|
|
7181
7219
|
const stripped = norm.replace(/^[/\\]/, "");
|
|
7182
7220
|
const resolved = resolve(baseDir, stripped);
|
|
7183
|
-
if (
|
|
7221
|
+
if (existsSync10(resolved) || existsSync10(dirname4(resolved)))
|
|
7184
7222
|
return resolved;
|
|
7185
7223
|
const baseNorm = normalize(baseDir);
|
|
7186
7224
|
let cur = baseNorm;
|
|
7187
|
-
while (cur && cur !==
|
|
7225
|
+
while (cur && cur !== dirname4(cur)) {
|
|
7188
7226
|
const name = basename(cur);
|
|
7189
7227
|
if (!name) {
|
|
7190
|
-
cur =
|
|
7228
|
+
cur = dirname4(cur);
|
|
7191
7229
|
continue;
|
|
7192
7230
|
}
|
|
7193
7231
|
let idx = stripped.toLowerCase().indexOf(name.toLowerCase());
|
|
@@ -7197,17 +7235,17 @@ function safeResolvePath(baseDir, userPath) {
|
|
|
7197
7235
|
if (afterChar && afterChar !== "\\" && afterChar !== "/") {
|
|
7198
7236
|
const fixed = stripped.slice(0, afterIdx) + sep + stripped.slice(afterIdx);
|
|
7199
7237
|
const fixedResolved = resolve(baseDir, normalize(fixed));
|
|
7200
|
-
if (
|
|
7238
|
+
if (existsSync10(fixedResolved) || existsSync10(dirname4(fixedResolved))) {
|
|
7201
7239
|
return fixedResolved;
|
|
7202
7240
|
}
|
|
7203
|
-
const fromParent = resolve(
|
|
7204
|
-
if (
|
|
7241
|
+
const fromParent = resolve(dirname4(cur), normalize(fixed));
|
|
7242
|
+
if (existsSync10(fromParent) || existsSync10(dirname4(fromParent))) {
|
|
7205
7243
|
return fromParent;
|
|
7206
7244
|
}
|
|
7207
7245
|
}
|
|
7208
7246
|
idx = stripped.toLowerCase().indexOf(name.toLowerCase(), idx + 1);
|
|
7209
7247
|
}
|
|
7210
|
-
cur =
|
|
7248
|
+
cur = dirname4(cur);
|
|
7211
7249
|
}
|
|
7212
7250
|
return resolved;
|
|
7213
7251
|
}
|
|
@@ -7424,10 +7462,10 @@ __export(exports_audit_notifier, {
|
|
|
7424
7462
|
DEFAULT_AUDIT_NOTIFIER_CONFIG: () => DEFAULT_AUDIT_NOTIFIER_CONFIG,
|
|
7425
7463
|
AuditNotifier: () => AuditNotifier
|
|
7426
7464
|
});
|
|
7427
|
-
import { writeFileSync as writeFileSync5, appendFileSync as appendFileSync3, existsSync as
|
|
7428
|
-
import { join as
|
|
7465
|
+
import { writeFileSync as writeFileSync5, appendFileSync as appendFileSync3, existsSync as existsSync11, mkdirSync as mkdirSync6 } from "fs";
|
|
7466
|
+
import { join as join10, dirname as dirname5 } from "path";
|
|
7429
7467
|
import { homedir as homedir3 } from "os";
|
|
7430
|
-
import { readFileSync as
|
|
7468
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
7431
7469
|
|
|
7432
7470
|
class AuditNotifier {
|
|
7433
7471
|
config;
|
|
@@ -7452,7 +7490,7 @@ class AuditNotifier {
|
|
|
7452
7490
|
}
|
|
7453
7491
|
ensureLogDirectory() {
|
|
7454
7492
|
if (this.config.filePath) {
|
|
7455
|
-
const dir =
|
|
7493
|
+
const dir = dirname5(this.config.filePath);
|
|
7456
7494
|
mkdirSync6(dir, { recursive: true });
|
|
7457
7495
|
}
|
|
7458
7496
|
}
|
|
@@ -7582,11 +7620,11 @@ class AuditNotifier {
|
|
|
7582
7620
|
}
|
|
7583
7621
|
}
|
|
7584
7622
|
readNotifications(limit = 100) {
|
|
7585
|
-
if (!this.config.filePath || !
|
|
7623
|
+
if (!this.config.filePath || !existsSync11(this.config.filePath)) {
|
|
7586
7624
|
return [];
|
|
7587
7625
|
}
|
|
7588
7626
|
try {
|
|
7589
|
-
const content =
|
|
7627
|
+
const content = readFileSync6(this.config.filePath, "utf8");
|
|
7590
7628
|
const lines = content.split(`
|
|
7591
7629
|
`).filter(Boolean);
|
|
7592
7630
|
return lines.slice(-limit).map((line) => JSON.parse(line));
|
|
@@ -7640,7 +7678,7 @@ var init_audit_notifier = __esm(() => {
|
|
|
7640
7678
|
};
|
|
7641
7679
|
DEFAULT_AUDIT_NOTIFIER_CONFIG = {
|
|
7642
7680
|
enabled: false,
|
|
7643
|
-
filePath:
|
|
7681
|
+
filePath: join10(homedir3(), ".mma", "logs", "audit-notifications.jsonl"),
|
|
7644
7682
|
webhookTimeout: 5000,
|
|
7645
7683
|
minSeverity: "medium",
|
|
7646
7684
|
eventTypes: [
|
|
@@ -7657,26 +7695,26 @@ var init_audit_notifier = __esm(() => {
|
|
|
7657
7695
|
});
|
|
7658
7696
|
|
|
7659
7697
|
// src/modules/security/audit-log.ts
|
|
7660
|
-
import { existsSync as
|
|
7661
|
-
import { resolve as resolve3, join as
|
|
7698
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, appendFileSync as appendFileSync4 } from "fs";
|
|
7699
|
+
import { resolve as resolve3, join as join11 } from "path";
|
|
7662
7700
|
import { homedir as homedir4 } from "os";
|
|
7663
7701
|
function getAuditDir() {
|
|
7664
7702
|
return _sessionAuditDir ?? _globalAuditDir;
|
|
7665
7703
|
}
|
|
7666
7704
|
function setAuditSessionDir(dir) {
|
|
7667
7705
|
_sessionAuditDir = dir;
|
|
7668
|
-
if (!
|
|
7706
|
+
if (!existsSync12(dir)) {
|
|
7669
7707
|
mkdirSync7(dir, { recursive: true, mode: 448 });
|
|
7670
7708
|
}
|
|
7671
7709
|
}
|
|
7672
7710
|
function logAudit(entry) {
|
|
7673
7711
|
const dir = getAuditDir();
|
|
7674
|
-
if (!
|
|
7712
|
+
if (!existsSync12(dir)) {
|
|
7675
7713
|
mkdirSync7(dir, { recursive: true, mode: 448 });
|
|
7676
7714
|
}
|
|
7677
7715
|
try {
|
|
7678
7716
|
const logEntry = JSON.stringify(entry);
|
|
7679
|
-
appendFileSync4(
|
|
7717
|
+
appendFileSync4(join11(dir, "audit.jsonl"), logEntry + `
|
|
7680
7718
|
`, "utf8");
|
|
7681
7719
|
} catch {}
|
|
7682
7720
|
try {
|
|
@@ -7740,7 +7778,7 @@ var init_audit_log = __esm(() => {
|
|
|
7740
7778
|
});
|
|
7741
7779
|
|
|
7742
7780
|
// src/tools/read-file.ts
|
|
7743
|
-
import { readFileSync as
|
|
7781
|
+
import { readFileSync as readFileSync7, existsSync as existsSync13, statSync as statSync2, openSync, readSync, closeSync } from "fs";
|
|
7744
7782
|
import { extname } from "path";
|
|
7745
7783
|
function readLineSlice(path, offset, limit) {
|
|
7746
7784
|
const fd = openSync(path, "r");
|
|
@@ -7841,7 +7879,7 @@ var init_read_file = __esm(() => {
|
|
|
7841
7879
|
})
|
|
7842
7880
|
};
|
|
7843
7881
|
}
|
|
7844
|
-
if (!
|
|
7882
|
+
if (!existsSync13(resolved)) {
|
|
7845
7883
|
const output = resolved !== path ? t("file.notfound_resolved", {
|
|
7846
7884
|
path,
|
|
7847
7885
|
resolved
|
|
@@ -7858,7 +7896,7 @@ var init_read_file = __esm(() => {
|
|
|
7858
7896
|
total = slice.total;
|
|
7859
7897
|
selected = slice.selected;
|
|
7860
7898
|
} else {
|
|
7861
|
-
const content =
|
|
7899
|
+
const content = readFileSync7(resolved, "utf-8");
|
|
7862
7900
|
lines = content.split(`
|
|
7863
7901
|
`);
|
|
7864
7902
|
total = lines.length;
|
|
@@ -7950,14 +7988,14 @@ __export(exports_session_isolation, {
|
|
|
7950
7988
|
cleanupSessionTempDir: () => cleanupSessionTempDir,
|
|
7951
7989
|
DEFAULT_SESSION_ISOLATION: () => DEFAULT_SESSION_ISOLATION
|
|
7952
7990
|
});
|
|
7953
|
-
import { join as
|
|
7991
|
+
import { join as join12, resolve as resolve5 } from "path";
|
|
7954
7992
|
import { homedir as homedir5 } from "os";
|
|
7955
|
-
import { mkdirSync as mkdirSync8, existsSync as
|
|
7993
|
+
import { mkdirSync as mkdirSync8, existsSync as existsSync14 } from "fs";
|
|
7956
7994
|
function createSessionContext(sessionId, projectDir, isolationConfig, securityOverrides) {
|
|
7957
7995
|
const config = { ...DEFAULT_SESSION_ISOLATION, ...isolationConfig };
|
|
7958
|
-
const baseDir = config.baseDir ||
|
|
7959
|
-
const tempDir =
|
|
7960
|
-
if (config.isolateTempFiles && !
|
|
7996
|
+
const baseDir = config.baseDir || join12(homedir5(), ".mma", "sessions", sessionId);
|
|
7997
|
+
const tempDir = join12(baseDir, "temp");
|
|
7998
|
+
if (config.isolateTempFiles && !existsSync14(tempDir)) {
|
|
7961
7999
|
try {
|
|
7962
8000
|
mkdirSync8(tempDir, { recursive: true, mode: 448 });
|
|
7963
8001
|
} catch {}
|
|
@@ -8207,8 +8245,8 @@ var init_diff = __esm(() => {
|
|
|
8207
8245
|
});
|
|
8208
8246
|
|
|
8209
8247
|
// src/tools/syntax-validator.ts
|
|
8210
|
-
import { writeFileSync as writeFileSync6, existsSync as
|
|
8211
|
-
import { extname as extname2, dirname as
|
|
8248
|
+
import { writeFileSync as writeFileSync6, existsSync as existsSync15, unlinkSync as unlinkSync3 } from "fs";
|
|
8249
|
+
import { extname as extname2, dirname as dirname6 } from "path";
|
|
8212
8250
|
import { spawn } from "child_process";
|
|
8213
8251
|
function contentHash(content) {
|
|
8214
8252
|
let h = 5381;
|
|
@@ -8272,7 +8310,7 @@ async function preValidateSyntax(filePath, content, baseDir) {
|
|
|
8272
8310
|
const tmpFile = `${filePath}.tmp${ext}`;
|
|
8273
8311
|
try {
|
|
8274
8312
|
writeFileSync6(tmpFile, content, "utf-8");
|
|
8275
|
-
await runCommand(`bun build --no-bundle --target=bun "${tmpFile}"`,
|
|
8313
|
+
await runCommand(`bun build --no-bundle --target=bun "${tmpFile}"`, dirname6(filePath), 5000);
|
|
8276
8314
|
SYNTAX_CACHE.set(filePath, { hash, error: null });
|
|
8277
8315
|
return { valid: true };
|
|
8278
8316
|
} catch (err) {
|
|
@@ -8284,7 +8322,7 @@ async function preValidateSyntax(filePath, content, baseDir) {
|
|
|
8284
8322
|
return { valid: false, error };
|
|
8285
8323
|
} finally {
|
|
8286
8324
|
try {
|
|
8287
|
-
if (
|
|
8325
|
+
if (existsSync15(tmpFile))
|
|
8288
8326
|
unlinkSync3(tmpFile);
|
|
8289
8327
|
} catch {}
|
|
8290
8328
|
}
|
|
@@ -8298,7 +8336,7 @@ async function preValidateSyntax(filePath, content, baseDir) {
|
|
|
8298
8336
|
const tmpFile = `${filePath}.tmp${ext}`;
|
|
8299
8337
|
try {
|
|
8300
8338
|
writeFileSync6(tmpFile, content, "utf-8");
|
|
8301
|
-
await runCommand(`node --check "${tmpFile}"`,
|
|
8339
|
+
await runCommand(`node --check "${tmpFile}"`, dirname6(filePath), 5000);
|
|
8302
8340
|
SYNTAX_CACHE.set(filePath, { hash, error: null });
|
|
8303
8341
|
return { valid: true };
|
|
8304
8342
|
} catch (err) {
|
|
@@ -8310,7 +8348,7 @@ async function preValidateSyntax(filePath, content, baseDir) {
|
|
|
8310
8348
|
return { valid: false, error };
|
|
8311
8349
|
} finally {
|
|
8312
8350
|
try {
|
|
8313
|
-
if (
|
|
8351
|
+
if (existsSync15(tmpFile))
|
|
8314
8352
|
unlinkSync3(tmpFile);
|
|
8315
8353
|
} catch {}
|
|
8316
8354
|
}
|
|
@@ -8350,8 +8388,8 @@ var init_syntax_validator = __esm(() => {
|
|
|
8350
8388
|
});
|
|
8351
8389
|
|
|
8352
8390
|
// src/tools/write-file.ts
|
|
8353
|
-
import { writeFileSync as writeFileSync7, mkdirSync as mkdirSync9, existsSync as
|
|
8354
|
-
import { dirname as
|
|
8391
|
+
import { writeFileSync as writeFileSync7, mkdirSync as mkdirSync9, existsSync as existsSync16, readFileSync as readFileSync8 } from "fs";
|
|
8392
|
+
import { dirname as dirname7 } from "path";
|
|
8355
8393
|
var writeFileTool;
|
|
8356
8394
|
var init_write_file = __esm(() => {
|
|
8357
8395
|
init_i18n();
|
|
@@ -8409,8 +8447,8 @@ var init_write_file = __esm(() => {
|
|
|
8409
8447
|
};
|
|
8410
8448
|
}
|
|
8411
8449
|
}
|
|
8412
|
-
const dir =
|
|
8413
|
-
if (!
|
|
8450
|
+
const dir = dirname7(resolved);
|
|
8451
|
+
if (!existsSync16(dir)) {
|
|
8414
8452
|
mkdirSync9(dir, { recursive: true });
|
|
8415
8453
|
}
|
|
8416
8454
|
const validation = await preValidateSyntax(resolved, content, ctx.baseDir);
|
|
@@ -8421,10 +8459,10 @@ var init_write_file = __esm(() => {
|
|
|
8421
8459
|
};
|
|
8422
8460
|
}
|
|
8423
8461
|
const conflicts = detectImportConflicts(content);
|
|
8424
|
-
const fileExists =
|
|
8462
|
+
const fileExists = existsSync16(resolved);
|
|
8425
8463
|
let oldContent = "";
|
|
8426
8464
|
if (fileExists) {
|
|
8427
|
-
oldContent =
|
|
8465
|
+
oldContent = readFileSync8(resolved, "utf-8");
|
|
8428
8466
|
}
|
|
8429
8467
|
writeFileSync7(resolved, content, "utf-8");
|
|
8430
8468
|
const diff = fileExists ? generateDiff(oldContent, content) : generateNewFileDiff(content);
|
|
@@ -8441,7 +8479,7 @@ var init_write_file = __esm(() => {
|
|
|
8441
8479
|
});
|
|
8442
8480
|
|
|
8443
8481
|
// src/tools/edit-file.ts
|
|
8444
|
-
import { readFileSync as
|
|
8482
|
+
import { readFileSync as readFileSync9, writeFileSync as writeFileSync8 } from "fs";
|
|
8445
8483
|
var editFileTool;
|
|
8446
8484
|
var init_edit_file = __esm(() => {
|
|
8447
8485
|
init_i18n();
|
|
@@ -8489,7 +8527,7 @@ var init_edit_file = __esm(() => {
|
|
|
8489
8527
|
})
|
|
8490
8528
|
};
|
|
8491
8529
|
}
|
|
8492
|
-
const content =
|
|
8530
|
+
const content = readFileSync9(resolved, "utf-8");
|
|
8493
8531
|
const oldStr = String(args.old);
|
|
8494
8532
|
const newStr = String(args.new);
|
|
8495
8533
|
if (!content.includes(oldStr)) {
|
|
@@ -8697,7 +8735,7 @@ var init_grep_tool = __esm(() => {
|
|
|
8697
8735
|
});
|
|
8698
8736
|
|
|
8699
8737
|
// src/tools/list-dir.ts
|
|
8700
|
-
import { readdirSync as readdirSync5, statSync as statSync3, existsSync as
|
|
8738
|
+
import { readdirSync as readdirSync5, statSync as statSync3, existsSync as existsSync17 } from "fs";
|
|
8701
8739
|
import { resolve as resolve8 } from "path";
|
|
8702
8740
|
var IGNORED_DIRS, listDirTool;
|
|
8703
8741
|
var init_list_dir = __esm(() => {
|
|
@@ -8730,7 +8768,7 @@ var init_list_dir = __esm(() => {
|
|
|
8730
8768
|
})
|
|
8731
8769
|
};
|
|
8732
8770
|
}
|
|
8733
|
-
if (!
|
|
8771
|
+
if (!existsSync17(resolved)) {
|
|
8734
8772
|
return { success: false, output: t("file.dir_notfound", { path }) };
|
|
8735
8773
|
}
|
|
8736
8774
|
const entries = readdirSync5(resolved).filter((e) => !IGNORED_DIRS.has(e));
|
|
@@ -8750,7 +8788,7 @@ var init_list_dir = __esm(() => {
|
|
|
8750
8788
|
});
|
|
8751
8789
|
|
|
8752
8790
|
// src/tools/create-dir.ts
|
|
8753
|
-
import { mkdirSync as mkdirSync10, existsSync as
|
|
8791
|
+
import { mkdirSync as mkdirSync10, existsSync as existsSync18 } from "fs";
|
|
8754
8792
|
var createDirTool;
|
|
8755
8793
|
var init_create_dir = __esm(() => {
|
|
8756
8794
|
init_i18n();
|
|
@@ -8793,7 +8831,7 @@ var init_create_dir = __esm(() => {
|
|
|
8793
8831
|
})
|
|
8794
8832
|
};
|
|
8795
8833
|
}
|
|
8796
|
-
if (!
|
|
8834
|
+
if (!existsSync18(resolved)) {
|
|
8797
8835
|
mkdirSync10(resolved, { recursive: true });
|
|
8798
8836
|
}
|
|
8799
8837
|
ctx.fileOperationsCount = currentCount + 1;
|
|
@@ -8804,7 +8842,7 @@ var init_create_dir = __esm(() => {
|
|
|
8804
8842
|
});
|
|
8805
8843
|
|
|
8806
8844
|
// src/tools/delete-file.ts
|
|
8807
|
-
import { unlinkSync as unlinkSync4, existsSync as
|
|
8845
|
+
import { unlinkSync as unlinkSync4, existsSync as existsSync19, statSync as statSync4, readFileSync as readFileSync10 } from "fs";
|
|
8808
8846
|
var deleteFileTool;
|
|
8809
8847
|
var init_delete_file = __esm(() => {
|
|
8810
8848
|
init_i18n();
|
|
@@ -8848,13 +8886,13 @@ var init_delete_file = __esm(() => {
|
|
|
8848
8886
|
})
|
|
8849
8887
|
};
|
|
8850
8888
|
}
|
|
8851
|
-
if (!
|
|
8889
|
+
if (!existsSync19(resolved)) {
|
|
8852
8890
|
return { success: false, output: t("file.notfound", { path }) };
|
|
8853
8891
|
}
|
|
8854
8892
|
if (statSync4(resolved).isDirectory()) {
|
|
8855
8893
|
return { success: false, output: t("file.is_directory", { path }) };
|
|
8856
8894
|
}
|
|
8857
|
-
const content =
|
|
8895
|
+
const content = readFileSync10(resolved, "utf-8");
|
|
8858
8896
|
unlinkSync4(resolved);
|
|
8859
8897
|
const diff = generateDeleteDiff(content);
|
|
8860
8898
|
ctx.fileOperationsCount = currentCount + 1;
|
|
@@ -8865,8 +8903,8 @@ var init_delete_file = __esm(() => {
|
|
|
8865
8903
|
});
|
|
8866
8904
|
|
|
8867
8905
|
// src/tools/move-file.ts
|
|
8868
|
-
import { renameSync as renameSync2, existsSync as
|
|
8869
|
-
import { resolve as resolve9, normalize as normalize3, dirname as
|
|
8906
|
+
import { renameSync as renameSync2, existsSync as existsSync20, mkdirSync as mkdirSync11 } from "fs";
|
|
8907
|
+
import { resolve as resolve9, normalize as normalize3, dirname as dirname8 } from "path";
|
|
8870
8908
|
var moveFileTool;
|
|
8871
8909
|
var init_move_file = __esm(() => {
|
|
8872
8910
|
init_i18n();
|
|
@@ -8924,14 +8962,14 @@ var init_move_file = __esm(() => {
|
|
|
8924
8962
|
})
|
|
8925
8963
|
};
|
|
8926
8964
|
}
|
|
8927
|
-
if (!
|
|
8965
|
+
if (!existsSync20(fromResolved)) {
|
|
8928
8966
|
return {
|
|
8929
8967
|
success: false,
|
|
8930
8968
|
output: t("file.not_found_short", { path: fromPath })
|
|
8931
8969
|
};
|
|
8932
8970
|
}
|
|
8933
|
-
const toDir =
|
|
8934
|
-
if (!
|
|
8971
|
+
const toDir = dirname8(toResolved);
|
|
8972
|
+
if (!existsSync20(toDir)) {
|
|
8935
8973
|
mkdirSync11(toDir, { recursive: true });
|
|
8936
8974
|
}
|
|
8937
8975
|
renameSync2(fromResolved, toResolved);
|
|
@@ -8948,7 +8986,7 @@ var init_move_file = __esm(() => {
|
|
|
8948
8986
|
});
|
|
8949
8987
|
|
|
8950
8988
|
// src/tools/file-info.ts
|
|
8951
|
-
import { statSync as statSync5, existsSync as
|
|
8989
|
+
import { statSync as statSync5, existsSync as existsSync21 } from "fs";
|
|
8952
8990
|
var fileInfoTool;
|
|
8953
8991
|
var init_file_info = __esm(() => {
|
|
8954
8992
|
init_i18n();
|
|
@@ -8979,7 +9017,7 @@ var init_file_info = __esm(() => {
|
|
|
8979
9017
|
})
|
|
8980
9018
|
};
|
|
8981
9019
|
}
|
|
8982
|
-
if (!
|
|
9020
|
+
if (!existsSync21(resolved)) {
|
|
8983
9021
|
return { success: false, output: t("file.not_found_short", { path }) };
|
|
8984
9022
|
}
|
|
8985
9023
|
const stat = statSync5(resolved);
|
|
@@ -10079,8 +10117,8 @@ var init_prompt_builder = __esm(() => {
|
|
|
10079
10117
|
});
|
|
10080
10118
|
|
|
10081
10119
|
// src/core/session-logger.ts
|
|
10082
|
-
import { join as
|
|
10083
|
-
import { readFileSync as
|
|
10120
|
+
import { join as join13 } from "path";
|
|
10121
|
+
import { readFileSync as readFileSync11, existsSync as existsSync22 } from "fs";
|
|
10084
10122
|
|
|
10085
10123
|
class SessionLogger {
|
|
10086
10124
|
session;
|
|
@@ -10288,10 +10326,10 @@ class SessionLogger {
|
|
|
10288
10326
|
logSessionStart(data) {
|
|
10289
10327
|
const meta = this.session?.getActiveMeta();
|
|
10290
10328
|
if (meta) {
|
|
10291
|
-
const logPath =
|
|
10329
|
+
const logPath = join13(this.session.getSessionDirectory(meta.id), "session.jsonl");
|
|
10292
10330
|
try {
|
|
10293
|
-
if (
|
|
10294
|
-
const content =
|
|
10331
|
+
if (existsSync22(logPath)) {
|
|
10332
|
+
const content = readFileSync11(logPath, "utf-8");
|
|
10295
10333
|
if (content.includes('"type":"session_start"'))
|
|
10296
10334
|
return;
|
|
10297
10335
|
}
|
|
@@ -11162,8 +11200,10 @@ ${PLAN_SYSTEM_PROMPT_RULES}`;
|
|
|
11162
11200
|
class OrchestratorClient {
|
|
11163
11201
|
config;
|
|
11164
11202
|
provider = null;
|
|
11165
|
-
|
|
11203
|
+
getSessionId;
|
|
11204
|
+
constructor(config, defaultProvider, opts) {
|
|
11166
11205
|
this.config = config;
|
|
11206
|
+
this.getSessionId = opts?.getSessionId;
|
|
11167
11207
|
if (!config.model)
|
|
11168
11208
|
return;
|
|
11169
11209
|
if (config.provider) {
|
|
@@ -11183,6 +11223,7 @@ class OrchestratorClient {
|
|
|
11183
11223
|
contextWindow: config.contextWindow ?? DEFAULT_ORCH_CONTEXT_WINDOW,
|
|
11184
11224
|
retry: config.retry,
|
|
11185
11225
|
rateLimits: config.rateLimits,
|
|
11226
|
+
getSessionId: this.getSessionId,
|
|
11186
11227
|
logger: config.logger
|
|
11187
11228
|
});
|
|
11188
11229
|
manager.setModel(config.model);
|
|
@@ -12208,7 +12249,7 @@ var init_stuck_detector = __esm(() => {
|
|
|
12208
12249
|
});
|
|
12209
12250
|
|
|
12210
12251
|
// src/modules/artifacts/store.ts
|
|
12211
|
-
import { existsSync as
|
|
12252
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync12, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "node:fs";
|
|
12212
12253
|
import { resolve as resolve10, relative as relative2, isAbsolute as isAbsolute2 } from "node:path";
|
|
12213
12254
|
|
|
12214
12255
|
class ArtifactStore {
|
|
@@ -12246,9 +12287,9 @@ class ArtifactStore {
|
|
|
12246
12287
|
const abs = resolve10(this.root, path);
|
|
12247
12288
|
if (!ArtifactStore.isInside(this.root, abs))
|
|
12248
12289
|
return null;
|
|
12249
|
-
if (!
|
|
12290
|
+
if (!existsSync23(abs))
|
|
12250
12291
|
return null;
|
|
12251
|
-
return
|
|
12292
|
+
return readFileSync12(abs, "utf8");
|
|
12252
12293
|
}
|
|
12253
12294
|
summary(content, maxChars) {
|
|
12254
12295
|
if (content.length <= maxChars)
|
|
@@ -12748,23 +12789,23 @@ var init_moe_executor = __esm(() => {
|
|
|
12748
12789
|
});
|
|
12749
12790
|
|
|
12750
12791
|
// src/modules/lsp/project-root.ts
|
|
12751
|
-
import { existsSync as
|
|
12752
|
-
import { dirname as
|
|
12792
|
+
import { existsSync as existsSync24 } from "fs";
|
|
12793
|
+
import { dirname as dirname9, join as join14, relative as relative3, isAbsolute as isAbsolute3 } from "path";
|
|
12753
12794
|
function findProjectRoot(filePath, baseDir, markers) {
|
|
12754
12795
|
if (!markers || markers.length === 0)
|
|
12755
12796
|
return baseDir;
|
|
12756
|
-
let dir =
|
|
12797
|
+
let dir = dirname9(filePath);
|
|
12757
12798
|
const root = baseDir.replace(/[\\/]+$/, "");
|
|
12758
12799
|
const rel = relative3(root, dir);
|
|
12759
12800
|
if (rel && rel.startsWith("..") || isAbsolute3(rel))
|
|
12760
12801
|
dir = root;
|
|
12761
12802
|
while (true) {
|
|
12762
|
-
if (markers.some((m) =>
|
|
12803
|
+
if (markers.some((m) => existsSync24(join14(dir, m)))) {
|
|
12763
12804
|
return dir;
|
|
12764
12805
|
}
|
|
12765
12806
|
if (dir === root)
|
|
12766
12807
|
return dir;
|
|
12767
|
-
const parent =
|
|
12808
|
+
const parent = dirname9(dir);
|
|
12768
12809
|
if (parent === dir)
|
|
12769
12810
|
return root;
|
|
12770
12811
|
dir = parent;
|
|
@@ -12982,13 +13023,13 @@ var init_js_identifiers = __esm(() => {
|
|
|
12982
13023
|
});
|
|
12983
13024
|
|
|
12984
13025
|
// src/modules/execution/audit-runners.ts
|
|
12985
|
-
import { existsSync as
|
|
12986
|
-
import { dirname as
|
|
13026
|
+
import { existsSync as existsSync25, readdirSync as readdirSync6, readFileSync as readFileSync13 } from "fs";
|
|
13027
|
+
import { dirname as dirname10, join as join15, resolve as resolve11 } from "path";
|
|
12987
13028
|
function resolveTestCommand(dir) {
|
|
12988
|
-
const pkgPath =
|
|
12989
|
-
if (
|
|
13029
|
+
const pkgPath = join15(dir, "package.json");
|
|
13030
|
+
if (existsSync25(pkgPath)) {
|
|
12990
13031
|
try {
|
|
12991
|
-
const pkg = JSON.parse(
|
|
13032
|
+
const pkg = JSON.parse(readFileSync13(pkgPath, "utf-8"));
|
|
12992
13033
|
const script = pkg?.scripts?.test;
|
|
12993
13034
|
if (typeof script === "string" && script.trim())
|
|
12994
13035
|
return script.trim();
|
|
@@ -13004,7 +13045,7 @@ function resolveTestCommand(dir) {
|
|
|
13004
13045
|
"jest.config.cjs",
|
|
13005
13046
|
"bunfig.toml"
|
|
13006
13047
|
]) {
|
|
13007
|
-
if (
|
|
13048
|
+
if (existsSync25(join15(dir, f))) {
|
|
13008
13049
|
if (f.startsWith("vitest"))
|
|
13009
13050
|
return "bunx vitest run";
|
|
13010
13051
|
if (f.startsWith("jest"))
|
|
@@ -13013,12 +13054,12 @@ function resolveTestCommand(dir) {
|
|
|
13013
13054
|
return "bun test";
|
|
13014
13055
|
}
|
|
13015
13056
|
}
|
|
13016
|
-
if (
|
|
13057
|
+
if (existsSync25(join15(dir, "pyproject.toml")) || existsSync25(join15(dir, "pytest.ini")) || existsSync25(join15(dir, "conftest.py"))) {
|
|
13017
13058
|
return "python -m pytest -q";
|
|
13018
13059
|
}
|
|
13019
|
-
if (
|
|
13060
|
+
if (existsSync25(join15(dir, "go.mod")))
|
|
13020
13061
|
return "go test ./...";
|
|
13021
|
-
if (
|
|
13062
|
+
if (existsSync25(join15(dir, "Cargo.toml")))
|
|
13022
13063
|
return "cargo test";
|
|
13023
13064
|
return "bun test";
|
|
13024
13065
|
}
|
|
@@ -13032,7 +13073,7 @@ function findTestFile(dir, depth = 0) {
|
|
|
13032
13073
|
return null;
|
|
13033
13074
|
}
|
|
13034
13075
|
for (const e of entries) {
|
|
13035
|
-
const full =
|
|
13076
|
+
const full = join15(dir, e.name);
|
|
13036
13077
|
if (e.isDirectory()) {
|
|
13037
13078
|
if (SKIP_DIRS.has(e.name))
|
|
13038
13079
|
continue;
|
|
@@ -13108,12 +13149,12 @@ function findTypecheckRoot(baseDir, existingFiles = []) {
|
|
|
13108
13149
|
for (const start of candidates) {
|
|
13109
13150
|
let dir = resolve11(start);
|
|
13110
13151
|
for (let depth = 0;depth <= 10; depth++) {
|
|
13111
|
-
if (
|
|
13152
|
+
if (existsSync25(join15(dir, "tsconfig.json"))) {
|
|
13112
13153
|
if (!best || depth < best.depth)
|
|
13113
13154
|
best = { depth, root: dir };
|
|
13114
13155
|
break;
|
|
13115
13156
|
}
|
|
13116
|
-
const parent =
|
|
13157
|
+
const parent = dirname10(dir);
|
|
13117
13158
|
if (parent === dir)
|
|
13118
13159
|
break;
|
|
13119
13160
|
dir = parent;
|
|
@@ -13152,11 +13193,11 @@ var init_audit_runners = __esm(() => {
|
|
|
13152
13193
|
});
|
|
13153
13194
|
|
|
13154
13195
|
// src/modules/execution/auditor.ts
|
|
13155
|
-
import { existsSync as
|
|
13156
|
-
import { resolve as resolve12, join as
|
|
13196
|
+
import { existsSync as existsSync26, readdirSync as readdirSync7 } from "fs";
|
|
13197
|
+
import { resolve as resolve12, join as join16, basename as basename2 } from "path";
|
|
13157
13198
|
function findExistingFile(baseDir, filePath) {
|
|
13158
13199
|
const direct = resolve12(baseDir, filePath);
|
|
13159
|
-
if (
|
|
13200
|
+
if (existsSync26(direct))
|
|
13160
13201
|
return direct;
|
|
13161
13202
|
const name = basename2(filePath).toLowerCase();
|
|
13162
13203
|
const suffix = toForwardSlash(filePath).toLowerCase();
|
|
@@ -13173,7 +13214,7 @@ function findExistingFile(baseDir, filePath) {
|
|
|
13173
13214
|
for (const e of entries) {
|
|
13174
13215
|
if (found)
|
|
13175
13216
|
return;
|
|
13176
|
-
const full =
|
|
13217
|
+
const full = join16(dir, e.name);
|
|
13177
13218
|
if (e.isDirectory()) {
|
|
13178
13219
|
if (SKIP_DIRS.has(e.name))
|
|
13179
13220
|
continue;
|
|
@@ -13312,8 +13353,8 @@ var init_auditor = __esm(() => {
|
|
|
13312
13353
|
});
|
|
13313
13354
|
|
|
13314
13355
|
// src/modules/execution/verifier.ts
|
|
13315
|
-
import { existsSync as
|
|
13316
|
-
import { resolve as resolve13, extname as extname3, join as
|
|
13356
|
+
import { existsSync as existsSync27, readFileSync as readFileSync14 } from "fs";
|
|
13357
|
+
import { resolve as resolve13, extname as extname3, join as join17 } from "path";
|
|
13317
13358
|
import { spawn as spawn4 } from "child_process";
|
|
13318
13359
|
|
|
13319
13360
|
class StepVerifier {
|
|
@@ -13323,7 +13364,7 @@ class StepVerifier {
|
|
|
13323
13364
|
}
|
|
13324
13365
|
async checkFileExists(path) {
|
|
13325
13366
|
const resolved = resolve13(this.baseDir, path);
|
|
13326
|
-
const exists =
|
|
13367
|
+
const exists = existsSync27(resolved);
|
|
13327
13368
|
return {
|
|
13328
13369
|
passed: exists,
|
|
13329
13370
|
message: exists ? t("verify.file_exists", { path }) : t("verify.file_not_found", { path })
|
|
@@ -13342,7 +13383,7 @@ class StepVerifier {
|
|
|
13342
13383
|
}
|
|
13343
13384
|
async runTypeCheck() {
|
|
13344
13385
|
const tsconfigPath = resolve13(this.baseDir, "tsconfig.json");
|
|
13345
|
-
if (!
|
|
13386
|
+
if (!existsSync27(tsconfigPath)) {
|
|
13346
13387
|
return { passed: true, message: "No tsconfig.json found — skipping type check" };
|
|
13347
13388
|
}
|
|
13348
13389
|
try {
|
|
@@ -13355,8 +13396,8 @@ class StepVerifier {
|
|
|
13355
13396
|
}
|
|
13356
13397
|
async runTypeCheckForFile(filePath) {
|
|
13357
13398
|
const projectRoot = findProjectRoot(filePath, this.baseDir, ["tsconfig.json", "package.json"]);
|
|
13358
|
-
const tsconfigPath =
|
|
13359
|
-
if (!
|
|
13399
|
+
const tsconfigPath = join17(projectRoot, "tsconfig.json");
|
|
13400
|
+
if (!existsSync27(tsconfigPath)) {
|
|
13360
13401
|
return { passed: true, message: "No tsconfig.json found — skipping type check" };
|
|
13361
13402
|
}
|
|
13362
13403
|
try {
|
|
@@ -13369,7 +13410,7 @@ class StepVerifier {
|
|
|
13369
13410
|
}
|
|
13370
13411
|
async runTests() {
|
|
13371
13412
|
const pkgPath = resolve13(this.baseDir, "package.json");
|
|
13372
|
-
if (!
|
|
13413
|
+
if (!existsSync27(pkgPath)) {
|
|
13373
13414
|
return { passed: true, message: "No package.json found — skipping tests" };
|
|
13374
13415
|
}
|
|
13375
13416
|
try {
|
|
@@ -13411,13 +13452,13 @@ class StepVerifier {
|
|
|
13411
13452
|
const path = rest.slice(0, colon);
|
|
13412
13453
|
const needle = rest.slice(colon + 1);
|
|
13413
13454
|
const resolved = resolve13(this.baseDir, path);
|
|
13414
|
-
if (!
|
|
13455
|
+
if (!existsSync27(resolved)) {
|
|
13415
13456
|
const item = { passed: false, message: t("verify.file_not_found", { path }) };
|
|
13416
13457
|
details.push(item);
|
|
13417
13458
|
errors.push(`[${subtask.id}] ${item.message}`);
|
|
13418
13459
|
continue;
|
|
13419
13460
|
}
|
|
13420
|
-
const content =
|
|
13461
|
+
const content = readFileSync14(resolved, "utf-8");
|
|
13421
13462
|
const passed = content.includes(needle);
|
|
13422
13463
|
details.push({ passed, message: `substring "${needle}" in ${path}: ${passed}` });
|
|
13423
13464
|
if (!passed)
|
|
@@ -13603,7 +13644,7 @@ async function runWithMoE(deps, input, fallback, opts = {}) {
|
|
|
13603
13644
|
rateLimits: config.security?.rateLimits,
|
|
13604
13645
|
logger,
|
|
13605
13646
|
experts: config.experts
|
|
13606
|
-
}, llmProvider);
|
|
13647
|
+
}, llmProvider, { getSessionId: () => sessionId });
|
|
13607
13648
|
}
|
|
13608
13649
|
if (!orchestrator.isEnabled()) {
|
|
13609
13650
|
logger.warn("MoE enabled but no orchestrator model configured — falling back to single-agent. Set orchestrator.model to activate MoE.");
|
|
@@ -14604,8 +14645,8 @@ var init_audit_gate = __esm(() => {
|
|
|
14604
14645
|
|
|
14605
14646
|
// src/core/prompt-overflow.ts
|
|
14606
14647
|
import { createHash } from "crypto";
|
|
14607
|
-
import { existsSync as
|
|
14608
|
-
import { join as
|
|
14648
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync13, readFileSync as readFileSync15, writeFileSync as writeFileSync10 } from "fs";
|
|
14649
|
+
import { join as join18 } from "path";
|
|
14609
14650
|
function dryRunOverflow(allBlocks, systemBudget) {
|
|
14610
14651
|
const builder = new PromptBuilder(systemBudget);
|
|
14611
14652
|
builder.addBlocks(allBlocks);
|
|
@@ -14619,10 +14660,10 @@ function cacheKey(kind, content, maxTokens) {
|
|
|
14619
14660
|
}
|
|
14620
14661
|
function readCache(cacheDir, key) {
|
|
14621
14662
|
try {
|
|
14622
|
-
const path =
|
|
14623
|
-
if (!
|
|
14663
|
+
const path = join18(cacheDir, `${key}.md`);
|
|
14664
|
+
if (!existsSync28(path))
|
|
14624
14665
|
return null;
|
|
14625
|
-
const raw =
|
|
14666
|
+
const raw = readFileSync15(path, "utf-8").trim();
|
|
14626
14667
|
if (!raw)
|
|
14627
14668
|
return null;
|
|
14628
14669
|
try {
|
|
@@ -14640,7 +14681,7 @@ function readCache(cacheDir, key) {
|
|
|
14640
14681
|
function writeCache(cacheDir, key, entry) {
|
|
14641
14682
|
try {
|
|
14642
14683
|
mkdirSync13(cacheDir, { recursive: true });
|
|
14643
|
-
writeFileSync10(
|
|
14684
|
+
writeFileSync10(join18(cacheDir, `${key}.md`), JSON.stringify(entry), "utf-8");
|
|
14644
14685
|
} catch {}
|
|
14645
14686
|
}
|
|
14646
14687
|
async function collectText(provider, prompt, maxTokens) {
|
|
@@ -14800,7 +14841,7 @@ function contextWindowHint(config, configDir, recommended) {
|
|
|
14800
14841
|
if (src.source === "global") {
|
|
14801
14842
|
return `run "mma context ${recommended}"`;
|
|
14802
14843
|
}
|
|
14803
|
-
return `edit "${
|
|
14844
|
+
return `edit "${join18(configDir, "config", "provider.json")}" → provider.entries[label="${src.label}"].contextWindow = ${recommended}`;
|
|
14804
14845
|
}
|
|
14805
14846
|
function recommendContextSize(neededSystemTokens) {
|
|
14806
14847
|
const sizes = [8192, 16384, 32768, 65536, 131072, 262144];
|
|
@@ -14850,7 +14891,7 @@ var init_prompt_overflow = __esm(() => {
|
|
|
14850
14891
|
});
|
|
14851
14892
|
|
|
14852
14893
|
// src/core/agent.ts
|
|
14853
|
-
import { join as
|
|
14894
|
+
import { join as join19 } from "path";
|
|
14854
14895
|
function mutationTargetKey(name, rawArgs) {
|
|
14855
14896
|
let a = null;
|
|
14856
14897
|
if (typeof rawArgs === "string") {
|
|
@@ -15005,7 +15046,7 @@ class Agent {
|
|
|
15005
15046
|
includedTokens: dry.blocks.filter((b) => b.included).reduce((s, b) => s + b.tokens, 0),
|
|
15006
15047
|
systemBudget,
|
|
15007
15048
|
provider: cfg.instructions?.summarize === false ? null : this.deps.llmProvider,
|
|
15008
|
-
cacheDir:
|
|
15049
|
+
cacheDir: join19(this.deps.baseDir, ".mma", "cache", "prompt-summaries"),
|
|
15009
15050
|
logger: this.deps.logger
|
|
15010
15051
|
});
|
|
15011
15052
|
for (const r of res.replacements) {
|
|
@@ -15508,7 +15549,9 @@ class Agent {
|
|
|
15508
15549
|
}
|
|
15509
15550
|
async reconfigure(config) {
|
|
15510
15551
|
const { TokenCounter: TokenCounter2 } = await Promise.resolve().then(() => (init_token_counter(), exports_token_counter));
|
|
15511
|
-
const { provider: newProvider } = buildActiveProvider(config, this.deps.logger
|
|
15552
|
+
const { provider: newProvider } = buildActiveProvider(config, this.deps.logger, {
|
|
15553
|
+
getSessionId: () => this.deps.sessionManager?.getActiveMeta()?.id
|
|
15554
|
+
});
|
|
15512
15555
|
this.deps.llmProvider = newProvider;
|
|
15513
15556
|
this.deps.toolExecutor.updateProvider(newProvider);
|
|
15514
15557
|
const newTokenCounter = new TokenCounter2(config.model);
|
|
@@ -15519,7 +15562,9 @@ class Agent {
|
|
|
15519
15562
|
this.costTracker.setModel(config.model);
|
|
15520
15563
|
}
|
|
15521
15564
|
setProvider(name, model) {
|
|
15522
|
-
const { manager, provider } = buildActiveProvider(this.deps.config, this.deps.logger
|
|
15565
|
+
const { manager, provider } = buildActiveProvider(this.deps.config, this.deps.logger, {
|
|
15566
|
+
getSessionId: () => this.deps.sessionManager?.getActiveMeta()?.id
|
|
15567
|
+
});
|
|
15523
15568
|
manager.switch(name, model);
|
|
15524
15569
|
const providerCfg = manager.toConfig();
|
|
15525
15570
|
this.deps.config.provider = providerCfg;
|
|
@@ -15530,7 +15575,8 @@ class Agent {
|
|
|
15530
15575
|
const manager = new ProviderManager(this.deps.config.provider, {
|
|
15531
15576
|
contextWindow: this.deps.config.contextWindow,
|
|
15532
15577
|
retry: this.deps.config.retry,
|
|
15533
|
-
rateLimits: this.deps.config.security?.rateLimits
|
|
15578
|
+
rateLimits: this.deps.config.security?.rateLimits,
|
|
15579
|
+
getSessionId: () => this.deps.sessionManager?.getActiveMeta()?.id
|
|
15534
15580
|
});
|
|
15535
15581
|
const activeName = this.deps.config.provider.active;
|
|
15536
15582
|
return manager.list().map((e) => ({
|
|
@@ -15544,6 +15590,7 @@ class Agent {
|
|
|
15544
15590
|
contextWindow: this.deps.config.contextWindow,
|
|
15545
15591
|
retry: this.deps.config.retry,
|
|
15546
15592
|
rateLimits: this.deps.config.security?.rateLimits,
|
|
15593
|
+
getSessionId: () => this.deps.sessionManager?.getActiveMeta()?.id,
|
|
15547
15594
|
logger: this.deps.logger
|
|
15548
15595
|
});
|
|
15549
15596
|
manager.setModel(this.deps.config.model);
|
|
@@ -16183,8 +16230,8 @@ var init_confidence = __esm(() => {
|
|
|
16183
16230
|
});
|
|
16184
16231
|
|
|
16185
16232
|
// src/modules/hallucination/factual.ts
|
|
16186
|
-
import { existsSync as
|
|
16187
|
-
import { resolve as resolve14, isAbsolute as isAbsolute4, join as
|
|
16233
|
+
import { existsSync as existsSync29, readdirSync as readdirSync8 } from "fs";
|
|
16234
|
+
import { resolve as resolve14, isAbsolute as isAbsolute4, join as join20 } from "path";
|
|
16188
16235
|
|
|
16189
16236
|
class FactualCheck {
|
|
16190
16237
|
baseDir;
|
|
@@ -16227,13 +16274,13 @@ class FactualCheck {
|
|
|
16227
16274
|
}
|
|
16228
16275
|
pathExists(fp) {
|
|
16229
16276
|
if (isAbsolute4(fp))
|
|
16230
|
-
return
|
|
16277
|
+
return existsSync29(fp);
|
|
16231
16278
|
if (this.knownFiles.has(fp))
|
|
16232
16279
|
return true;
|
|
16233
16280
|
for (const cand of this.dotfileVariants(fp)) {
|
|
16234
16281
|
if (this.knownFiles.has(cand))
|
|
16235
16282
|
return true;
|
|
16236
|
-
if (
|
|
16283
|
+
if (existsSync29(resolve14(this.baseDir, cand)))
|
|
16237
16284
|
return true;
|
|
16238
16285
|
}
|
|
16239
16286
|
if (!fp.includes("/") && !fp.includes("\\")) {
|
|
@@ -16261,7 +16308,7 @@ class FactualCheck {
|
|
|
16261
16308
|
}
|
|
16262
16309
|
bareNameExists(name) {
|
|
16263
16310
|
for (const cand of this.dotfileVariants(name)) {
|
|
16264
|
-
if (
|
|
16311
|
+
if (existsSync29(resolve14(this.baseDir, cand)))
|
|
16265
16312
|
return true;
|
|
16266
16313
|
if (this.indexHas(cand))
|
|
16267
16314
|
return true;
|
|
@@ -16307,7 +16354,7 @@ class FactualCheck {
|
|
|
16307
16354
|
for (const entry of entries) {
|
|
16308
16355
|
if (count >= FactualCheck.MAX_INDEXED_FILES)
|
|
16309
16356
|
break;
|
|
16310
|
-
const full =
|
|
16357
|
+
const full = join20(dir, entry.name);
|
|
16311
16358
|
if (entry.isDirectory()) {
|
|
16312
16359
|
if (!IGNORED_DIRS2.has(entry.name)) {
|
|
16313
16360
|
count = this.scanDir(full, index, count);
|
|
@@ -16489,8 +16536,8 @@ var init_detector = __esm(() => {
|
|
|
16489
16536
|
});
|
|
16490
16537
|
|
|
16491
16538
|
// src/modules/lsp/command.ts
|
|
16492
|
-
import { delimiter, join as
|
|
16493
|
-
import { existsSync as
|
|
16539
|
+
import { delimiter, join as join21 } from "path";
|
|
16540
|
+
import { existsSync as existsSync30 } from "fs";
|
|
16494
16541
|
import { platform as platform4 } from "os";
|
|
16495
16542
|
function resolveSpawnCommand(command, platformName = platform4(), pathEnv = process.env.PATH ?? "") {
|
|
16496
16543
|
if (platformName !== "win32")
|
|
@@ -16501,8 +16548,8 @@ function resolveSpawnCommand(command, platformName = platform4(), pathEnv = proc
|
|
|
16501
16548
|
const dirs = pathEnv.split(delimiter).filter(Boolean);
|
|
16502
16549
|
for (const dir of dirs) {
|
|
16503
16550
|
for (const ext of WIN_EXTS) {
|
|
16504
|
-
const candidate =
|
|
16505
|
-
if (
|
|
16551
|
+
const candidate = join21(dir, `${command}${ext}`);
|
|
16552
|
+
if (existsSync30(candidate))
|
|
16506
16553
|
return `${command}${ext}`;
|
|
16507
16554
|
}
|
|
16508
16555
|
}
|
|
@@ -17146,7 +17193,7 @@ var init_chunk_query = __esm(() => {
|
|
|
17146
17193
|
});
|
|
17147
17194
|
|
|
17148
17195
|
// src/tools/chunk-query.ts
|
|
17149
|
-
import { readFileSync as
|
|
17196
|
+
import { readFileSync as readFileSync16 } from "node:fs";
|
|
17150
17197
|
import { resolve as resolve15 } from "node:path";
|
|
17151
17198
|
var chunkQueryTool;
|
|
17152
17199
|
var init_chunk_query2 = __esm(() => {
|
|
@@ -17219,7 +17266,7 @@ var init_chunk_query2 = __esm(() => {
|
|
|
17219
17266
|
return { success: false, output: `[SCOPE] ${check.reason || "Path not allowed"}` };
|
|
17220
17267
|
}
|
|
17221
17268
|
try {
|
|
17222
|
-
content =
|
|
17269
|
+
content = readFileSync16(resolvedInput, "utf8");
|
|
17223
17270
|
} catch (e) {
|
|
17224
17271
|
return { success: false, output: `Cannot read ${inputPath}: ${e.message}` };
|
|
17225
17272
|
}
|
|
@@ -17672,7 +17719,7 @@ var init_web_browse = __esm(() => {
|
|
|
17672
17719
|
|
|
17673
17720
|
// src/tools/download-file.ts
|
|
17674
17721
|
import { writeFileSync as writeFileSync11, mkdirSync as mkdirSync14 } from "fs";
|
|
17675
|
-
import { dirname as
|
|
17722
|
+
import { dirname as dirname12 } from "path";
|
|
17676
17723
|
var MAX_DOWNLOAD_BYTES, downloadFileTool;
|
|
17677
17724
|
var init_download_file = __esm(() => {
|
|
17678
17725
|
init_i18n();
|
|
@@ -17760,7 +17807,7 @@ var init_download_file = __esm(() => {
|
|
|
17760
17807
|
output: t("tool.download_too_large", { max: String(maxBytes) })
|
|
17761
17808
|
};
|
|
17762
17809
|
}
|
|
17763
|
-
mkdirSync14(
|
|
17810
|
+
mkdirSync14(dirname12(resolved), { recursive: true });
|
|
17764
17811
|
writeFileSync11(resolved, buffer);
|
|
17765
17812
|
const contentType = response.headers.get("content-type")?.split(";")[0]?.trim() || "unknown";
|
|
17766
17813
|
logNetworkRequest(ctx.sessionId, sanitizeUrl(url), true, `Status: ${response.status}`);
|
|
@@ -18627,7 +18674,7 @@ ${JSON.stringify(result, null, 2)}`
|
|
|
18627
18674
|
|
|
18628
18675
|
// src/tools/search-history.ts
|
|
18629
18676
|
import * as fs from "fs";
|
|
18630
|
-
import { join as
|
|
18677
|
+
import { join as join22 } from "path";
|
|
18631
18678
|
import { homedir as homedir6 } from "os";
|
|
18632
18679
|
function searchFile(filePath, query, maxResults, results) {
|
|
18633
18680
|
if (!fs.existsSync(filePath))
|
|
@@ -18672,7 +18719,7 @@ var init_search_history = __esm(() => {
|
|
|
18672
18719
|
const query = String(args.query || "").toLowerCase();
|
|
18673
18720
|
const maxResults = Number(args.maxResults) || 5;
|
|
18674
18721
|
const sessionId = args.sessionId ? String(args.sessionId) : null;
|
|
18675
|
-
const sessionDir =
|
|
18722
|
+
const sessionDir = join22(homedir6(), ".mma", "sessions");
|
|
18676
18723
|
const results = [];
|
|
18677
18724
|
try {
|
|
18678
18725
|
if (!fs.existsSync(sessionDir)) {
|
|
@@ -18687,7 +18734,7 @@ var init_search_history = __esm(() => {
|
|
|
18687
18734
|
continue;
|
|
18688
18735
|
if (sessionId && entry.name !== sessionId)
|
|
18689
18736
|
continue;
|
|
18690
|
-
const historyFile =
|
|
18737
|
+
const historyFile = join22(sessionDir, entry.name, "history.jsonl");
|
|
18691
18738
|
searchFile(historyFile, query, maxResults, results);
|
|
18692
18739
|
if (results.length >= maxResults)
|
|
18693
18740
|
break;
|
|
@@ -18714,8 +18761,8 @@ var init_search_history = __esm(() => {
|
|
|
18714
18761
|
});
|
|
18715
18762
|
|
|
18716
18763
|
// src/modules/memory/search.ts
|
|
18717
|
-
import { readFileSync as
|
|
18718
|
-
import { join as
|
|
18764
|
+
import { readFileSync as readFileSync18, existsSync as existsSync32 } from "fs";
|
|
18765
|
+
import { join as join23 } from "path";
|
|
18719
18766
|
|
|
18720
18767
|
class MemorySearch {
|
|
18721
18768
|
memoryDir;
|
|
@@ -18726,10 +18773,10 @@ class MemorySearch {
|
|
|
18726
18773
|
const results = [];
|
|
18727
18774
|
const lowerQuery = query.toLowerCase();
|
|
18728
18775
|
for (const name of MEMORY_FILES) {
|
|
18729
|
-
const path =
|
|
18730
|
-
if (!
|
|
18776
|
+
const path = join23(this.memoryDir, `${name}.md`);
|
|
18777
|
+
if (!existsSync32(path))
|
|
18731
18778
|
continue;
|
|
18732
|
-
const content =
|
|
18779
|
+
const content = readFileSync18(path, "utf-8");
|
|
18733
18780
|
const lines = content.split(`
|
|
18734
18781
|
`);
|
|
18735
18782
|
for (const line of lines) {
|
|
@@ -18738,10 +18785,10 @@ class MemorySearch {
|
|
|
18738
18785
|
}
|
|
18739
18786
|
}
|
|
18740
18787
|
}
|
|
18741
|
-
const prefsPath =
|
|
18742
|
-
if (
|
|
18788
|
+
const prefsPath = join23(this.memoryDir, "preferences.json");
|
|
18789
|
+
if (existsSync32(prefsPath)) {
|
|
18743
18790
|
try {
|
|
18744
|
-
const prefs = JSON.parse(
|
|
18791
|
+
const prefs = JSON.parse(readFileSync18(prefsPath, "utf-8"));
|
|
18745
18792
|
for (const [key, value] of Object.entries(prefs)) {
|
|
18746
18793
|
const searchStr = `${key}=${value}`;
|
|
18747
18794
|
if (searchStr.toLowerCase().includes(lowerQuery)) {
|
|
@@ -18759,8 +18806,8 @@ var init_search = __esm(() => {
|
|
|
18759
18806
|
});
|
|
18760
18807
|
|
|
18761
18808
|
// src/modules/memory/store.ts
|
|
18762
|
-
import { readFileSync as
|
|
18763
|
-
import { join as
|
|
18809
|
+
import { readFileSync as readFileSync19, writeFileSync as writeFileSync12, appendFileSync as appendFileSync5, existsSync as existsSync33, mkdirSync as mkdirSync15 } from "fs";
|
|
18810
|
+
import { join as join24 } from "path";
|
|
18764
18811
|
|
|
18765
18812
|
class MemoryStore {
|
|
18766
18813
|
memoryDir;
|
|
@@ -18768,8 +18815,8 @@ class MemoryStore {
|
|
|
18768
18815
|
this.memoryDir = memoryDir;
|
|
18769
18816
|
this.ensureDir();
|
|
18770
18817
|
for (const name of MEMORY_FILES2) {
|
|
18771
|
-
const path =
|
|
18772
|
-
if (!
|
|
18818
|
+
const path = join24(this.memoryDir, `${name}.md`);
|
|
18819
|
+
if (!existsSync33(path)) {
|
|
18773
18820
|
writeFileSync12(path, `# ${name.charAt(0).toUpperCase() + name.slice(1)}
|
|
18774
18821
|
|
|
18775
18822
|
`, "utf-8");
|
|
@@ -18777,18 +18824,18 @@ class MemoryStore {
|
|
|
18777
18824
|
}
|
|
18778
18825
|
}
|
|
18779
18826
|
ensureDir() {
|
|
18780
|
-
if (!
|
|
18827
|
+
if (!existsSync33(this.memoryDir)) {
|
|
18781
18828
|
mkdirSync15(this.memoryDir, { recursive: true });
|
|
18782
18829
|
}
|
|
18783
18830
|
}
|
|
18784
18831
|
read(name) {
|
|
18785
|
-
const path =
|
|
18786
|
-
if (!
|
|
18832
|
+
const path = join24(this.memoryDir, `${name}.md`);
|
|
18833
|
+
if (!existsSync33(path))
|
|
18787
18834
|
return "";
|
|
18788
|
-
return
|
|
18835
|
+
return readFileSync19(path, "utf-8");
|
|
18789
18836
|
}
|
|
18790
18837
|
append(name, entry) {
|
|
18791
|
-
const path =
|
|
18838
|
+
const path = join24(this.memoryDir, `${name}.md`);
|
|
18792
18839
|
const timestamp = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
18793
18840
|
const formatted = `- **${timestamp}** — ${entry}
|
|
18794
18841
|
`;
|
|
@@ -18799,14 +18846,14 @@ class MemoryStore {
|
|
|
18799
18846
|
return searchModule.query(query);
|
|
18800
18847
|
}
|
|
18801
18848
|
prefsPath() {
|
|
18802
|
-
return
|
|
18849
|
+
return join24(this.memoryDir, "preferences.json");
|
|
18803
18850
|
}
|
|
18804
18851
|
getPreferences() {
|
|
18805
18852
|
const path = this.prefsPath();
|
|
18806
|
-
if (!
|
|
18853
|
+
if (!existsSync33(path))
|
|
18807
18854
|
return {};
|
|
18808
18855
|
try {
|
|
18809
|
-
return JSON.parse(
|
|
18856
|
+
return JSON.parse(readFileSync19(path, "utf-8"));
|
|
18810
18857
|
} catch {
|
|
18811
18858
|
return {};
|
|
18812
18859
|
}
|
|
@@ -18839,7 +18886,7 @@ var init_store2 = __esm(() => {
|
|
|
18839
18886
|
|
|
18840
18887
|
// src/tools/remember.ts
|
|
18841
18888
|
import { homedir as homedir7 } from "os";
|
|
18842
|
-
import { join as
|
|
18889
|
+
import { join as join25 } from "path";
|
|
18843
18890
|
var CATEGORIES, rememberTool;
|
|
18844
18891
|
var init_remember = __esm(() => {
|
|
18845
18892
|
init_i18n();
|
|
@@ -18878,7 +18925,7 @@ var init_remember = __esm(() => {
|
|
|
18878
18925
|
if (!CATEGORIES.includes(category)) {
|
|
18879
18926
|
return { success: false, output: t("tool.invalid_params") };
|
|
18880
18927
|
}
|
|
18881
|
-
const memoryDir =
|
|
18928
|
+
const memoryDir = join25(homedir7(), ".mma", "memory");
|
|
18882
18929
|
const store = new MemoryStore(memoryDir);
|
|
18883
18930
|
try {
|
|
18884
18931
|
if (category === "preferences") {
|
|
@@ -18911,7 +18958,7 @@ var init_remember = __esm(() => {
|
|
|
18911
18958
|
|
|
18912
18959
|
// src/tools/recall.ts
|
|
18913
18960
|
import { homedir as homedir8 } from "os";
|
|
18914
|
-
import { join as
|
|
18961
|
+
import { join as join26 } from "path";
|
|
18915
18962
|
function formatAll(store) {
|
|
18916
18963
|
const parts = [];
|
|
18917
18964
|
const prefs = store.getPreferences();
|
|
@@ -18995,7 +19042,7 @@ var init_recall = __esm(() => {
|
|
|
18995
19042
|
handler: async (_ctx, args) => {
|
|
18996
19043
|
const query = args.query ? String(args.query) : "";
|
|
18997
19044
|
const category = args.category ? String(args.category) : "";
|
|
18998
|
-
const memoryDir =
|
|
19045
|
+
const memoryDir = join26(homedir8(), ".mma", "memory");
|
|
18999
19046
|
const store = new MemoryStore(memoryDir);
|
|
19000
19047
|
try {
|
|
19001
19048
|
if (!query && !category) {
|
|
@@ -19033,9 +19080,9 @@ var init_recall = __esm(() => {
|
|
|
19033
19080
|
});
|
|
19034
19081
|
|
|
19035
19082
|
// src/modules/browser/bridge-path.ts
|
|
19036
|
-
import { existsSync as
|
|
19083
|
+
import { existsSync as existsSync34 } from "fs";
|
|
19037
19084
|
function pickExistingPath(candidates, fallback = candidates[0]) {
|
|
19038
|
-
return candidates.find((p) =>
|
|
19085
|
+
return candidates.find((p) => existsSync34(p)) ?? fallback;
|
|
19039
19086
|
}
|
|
19040
19087
|
var init_bridge_path = () => {};
|
|
19041
19088
|
|
|
@@ -19046,13 +19093,13 @@ __export(exports_bridge_client, {
|
|
|
19046
19093
|
});
|
|
19047
19094
|
import { spawn as spawn6 } from "child_process";
|
|
19048
19095
|
import { createInterface } from "readline";
|
|
19049
|
-
import { dirname as
|
|
19050
|
-
import { fileURLToPath } from "url";
|
|
19096
|
+
import { dirname as dirname13, join as join27 } from "path";
|
|
19097
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
19051
19098
|
function bridgeScriptPath() {
|
|
19052
|
-
const dir =
|
|
19099
|
+
const dir = dirname13(fileURLToPath2(import.meta.url));
|
|
19053
19100
|
const candidates = [
|
|
19054
|
-
|
|
19055
|
-
|
|
19101
|
+
join27(dir, "bridge-server.mjs"),
|
|
19102
|
+
join27(dir, "modules", "browser", "bridge-server.mjs")
|
|
19056
19103
|
];
|
|
19057
19104
|
return pickExistingPath(candidates);
|
|
19058
19105
|
}
|
|
@@ -19606,15 +19653,15 @@ function buildTextExtractionScript() {
|
|
|
19606
19653
|
|
|
19607
19654
|
// src/modules/browser/cookie-store.ts
|
|
19608
19655
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
19609
|
-
import { join as
|
|
19656
|
+
import { join as join28 } from "path";
|
|
19610
19657
|
|
|
19611
19658
|
class CookieStore {
|
|
19612
19659
|
filePath;
|
|
19613
19660
|
constructor(cookieDir) {
|
|
19614
|
-
this.filePath =
|
|
19661
|
+
this.filePath = join28(cookieDir, "cookies.json");
|
|
19615
19662
|
}
|
|
19616
19663
|
async save(cookies) {
|
|
19617
|
-
await mkdir(
|
|
19664
|
+
await mkdir(join28(this.filePath, ".."), { recursive: true });
|
|
19618
19665
|
await writeFile(this.filePath, JSON.stringify(cookies, null, 2), "utf-8");
|
|
19619
19666
|
}
|
|
19620
19667
|
async load() {
|
|
@@ -19972,10 +20019,10 @@ var init_session = __esm(() => {
|
|
|
19972
20019
|
});
|
|
19973
20020
|
|
|
19974
20021
|
// src/tools/browser.ts
|
|
19975
|
-
import { join as
|
|
20022
|
+
import { join as join29 } from "path";
|
|
19976
20023
|
function getSession(ctx) {
|
|
19977
20024
|
if (!session) {
|
|
19978
|
-
const cookieDir =
|
|
20025
|
+
const cookieDir = join29(ctx.baseDir, ".mma", "browser");
|
|
19979
20026
|
session = new BrowserSession({
|
|
19980
20027
|
...DEFAULT_BROWSER_CONFIG,
|
|
19981
20028
|
headless: ctx.config.browser?.headless ?? true,
|
|
@@ -20101,7 +20148,7 @@ __export(exports_image_utils, {
|
|
|
20101
20148
|
detectMime: () => detectMime,
|
|
20102
20149
|
bufferToDataUrl: () => bufferToDataUrl
|
|
20103
20150
|
});
|
|
20104
|
-
import { readFileSync as
|
|
20151
|
+
import { readFileSync as readFileSync20 } from "fs";
|
|
20105
20152
|
import { extname as extname4 } from "path";
|
|
20106
20153
|
function detectMime(filePath) {
|
|
20107
20154
|
const ext = extname4(filePath).toLowerCase();
|
|
@@ -20122,11 +20169,11 @@ async function readClipboardImage() {
|
|
|
20122
20169
|
async function readClipboardFallback() {
|
|
20123
20170
|
const { platform: platform6 } = await import("os");
|
|
20124
20171
|
const { execSync } = await import("child_process");
|
|
20125
|
-
const { readFileSync:
|
|
20126
|
-
const { join:
|
|
20172
|
+
const { readFileSync: readFileSync21, unlinkSync: unlinkSync5 } = await import("fs");
|
|
20173
|
+
const { join: join30 } = await import("path");
|
|
20127
20174
|
if (platform6() !== "linux")
|
|
20128
20175
|
return null;
|
|
20129
|
-
const tmpPath =
|
|
20176
|
+
const tmpPath = join30(process.env.TEMP || process.env.TMP || "/tmp", `mma-clip-${Date.now()}.png`);
|
|
20130
20177
|
const commands = [
|
|
20131
20178
|
`wl-paste --type image/png > "${tmpPath}" 2>/dev/null`,
|
|
20132
20179
|
`xclip -selection clipboard -t image/png -o > "${tmpPath}" 2>/dev/null`
|
|
@@ -20134,7 +20181,7 @@ async function readClipboardFallback() {
|
|
|
20134
20181
|
for (const cmd of commands) {
|
|
20135
20182
|
try {
|
|
20136
20183
|
execSync(cmd, { timeout: 5000 });
|
|
20137
|
-
const buf =
|
|
20184
|
+
const buf = readFileSync21(tmpPath);
|
|
20138
20185
|
unlinkSync5(tmpPath);
|
|
20139
20186
|
if (buf.length > 0)
|
|
20140
20187
|
return buf;
|
|
@@ -20146,7 +20193,7 @@ async function readClipboardFallback() {
|
|
|
20146
20193
|
return null;
|
|
20147
20194
|
}
|
|
20148
20195
|
async function loadFileAsDataUrl(filePath) {
|
|
20149
|
-
const buf =
|
|
20196
|
+
const buf = readFileSync20(filePath);
|
|
20150
20197
|
if (typeof Bun !== "undefined" && typeof Bun.Image !== "undefined") {
|
|
20151
20198
|
try {
|
|
20152
20199
|
const img = new Bun.Image(buf);
|
|
@@ -20206,7 +20253,7 @@ var init_image_utils = __esm(() => {
|
|
|
20206
20253
|
});
|
|
20207
20254
|
|
|
20208
20255
|
// src/tools/attach-image.ts
|
|
20209
|
-
import { existsSync as
|
|
20256
|
+
import { existsSync as existsSync35 } from "fs";
|
|
20210
20257
|
import { resolve as resolve16 } from "path";
|
|
20211
20258
|
var attachImageTool;
|
|
20212
20259
|
var init_attach_image = __esm(() => {
|
|
@@ -20258,7 +20305,7 @@ var init_attach_image = __esm(() => {
|
|
|
20258
20305
|
dataUrl = result.dataUrl;
|
|
20259
20306
|
} else {
|
|
20260
20307
|
const absPath = resolve16(ctx.baseDir, source);
|
|
20261
|
-
if (!
|
|
20308
|
+
if (!existsSync35(absPath)) {
|
|
20262
20309
|
return {
|
|
20263
20310
|
success: false,
|
|
20264
20311
|
output: t("image.not_found", { path: source })
|
|
@@ -20567,16 +20614,16 @@ class ModuleRegistry {
|
|
|
20567
20614
|
}
|
|
20568
20615
|
|
|
20569
20616
|
// src/modules/plugins/loader.ts
|
|
20570
|
-
import { readdirSync as readdirSync10, existsSync as
|
|
20571
|
-
import { join as
|
|
20617
|
+
import { readdirSync as readdirSync10, existsSync as existsSync36, statSync as statSync6 } from "fs";
|
|
20618
|
+
import { join as join30, basename as basename3 } from "path";
|
|
20572
20619
|
|
|
20573
20620
|
class PluginLoader {
|
|
20574
20621
|
loadFromDir(dirPath, pluginManager, logger2, options) {
|
|
20575
|
-
if (!
|
|
20622
|
+
if (!existsSync36(dirPath))
|
|
20576
20623
|
return;
|
|
20577
20624
|
const entries = readdirSync10(dirPath).sort();
|
|
20578
20625
|
for (const entry of entries) {
|
|
20579
|
-
const fullPath =
|
|
20626
|
+
const fullPath = join30(dirPath, entry);
|
|
20580
20627
|
const stat = statSync6(fullPath);
|
|
20581
20628
|
if (stat.isFile()) {
|
|
20582
20629
|
if (!entry.endsWith(".ts") && !entry.endsWith(".js"))
|
|
@@ -20592,8 +20639,8 @@ class PluginLoader {
|
|
|
20592
20639
|
}
|
|
20593
20640
|
findEntryFile(dir) {
|
|
20594
20641
|
for (const name of FOLDER_ENTRY_NAMES) {
|
|
20595
|
-
const candidate =
|
|
20596
|
-
if (
|
|
20642
|
+
const candidate = join30(dir, name);
|
|
20643
|
+
if (existsSync36(candidate))
|
|
20597
20644
|
return candidate;
|
|
20598
20645
|
}
|
|
20599
20646
|
return null;
|
|
@@ -20798,8 +20845,8 @@ var init_auto_fixer = __esm(() => {
|
|
|
20798
20845
|
|
|
20799
20846
|
// src/modules/plugins/builtin/lint-on-write.ts
|
|
20800
20847
|
import { spawn as spawn7, execSync } from "child_process";
|
|
20801
|
-
import { existsSync as
|
|
20802
|
-
import { resolve as resolve17, extname as extname6, join as
|
|
20848
|
+
import { existsSync as existsSync37, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "fs";
|
|
20849
|
+
import { resolve as resolve17, extname as extname6, join as join31 } from "path";
|
|
20803
20850
|
import { platform as platform6 } from "os";
|
|
20804
20851
|
function lintCacheKey(baseDir, lintScript) {
|
|
20805
20852
|
return `${baseDir}::${lintScript}`;
|
|
@@ -20875,7 +20922,7 @@ class LintOnWritePlugin {
|
|
|
20875
20922
|
if (!path)
|
|
20876
20923
|
return;
|
|
20877
20924
|
const fullPath = resolve17(ctx.baseDir, path);
|
|
20878
|
-
if (!
|
|
20925
|
+
if (!existsSync37(fullPath))
|
|
20879
20926
|
return;
|
|
20880
20927
|
const signal = ctx.signal;
|
|
20881
20928
|
if (signal?.aborted)
|
|
@@ -20899,7 +20946,7 @@ class LintOnWritePlugin {
|
|
|
20899
20946
|
if (ext === ".ts" || ext === ".tsx" || ext === ".cts" || ext === ".mts") {
|
|
20900
20947
|
let content = "";
|
|
20901
20948
|
try {
|
|
20902
|
-
content =
|
|
20949
|
+
content = readFileSync21(filePath, "utf-8");
|
|
20903
20950
|
} catch {
|
|
20904
20951
|
return null;
|
|
20905
20952
|
}
|
|
@@ -20941,11 +20988,11 @@ class LintOnWritePlugin {
|
|
|
20941
20988
|
async runProjectLint(ctx, result, signal) {
|
|
20942
20989
|
let lintScript;
|
|
20943
20990
|
try {
|
|
20944
|
-
const packageJsonPath =
|
|
20945
|
-
if (!
|
|
20991
|
+
const packageJsonPath = join31(ctx.baseDir, "package.json");
|
|
20992
|
+
if (!existsSync37(packageJsonPath)) {
|
|
20946
20993
|
return;
|
|
20947
20994
|
}
|
|
20948
|
-
const packageJson = JSON.parse(
|
|
20995
|
+
const packageJson = JSON.parse(readFileSync21(packageJsonPath, "utf-8"));
|
|
20949
20996
|
lintScript = packageJson.scripts?.lint;
|
|
20950
20997
|
if (!lintScript) {
|
|
20951
20998
|
return;
|
|
@@ -20978,8 +21025,8 @@ ${stdout}`;
|
|
|
20978
21025
|
}
|
|
20979
21026
|
async runProjectTypeCheck(filePath, baseDir, result, signal) {
|
|
20980
21027
|
const projectRoot = findProjectRoot(filePath, baseDir, ["tsconfig.json", "package.json"]);
|
|
20981
|
-
const tsconfigPath =
|
|
20982
|
-
if (!
|
|
21028
|
+
const tsconfigPath = join31(projectRoot, "tsconfig.json");
|
|
21029
|
+
if (!existsSync37(tsconfigPath)) {
|
|
20983
21030
|
return;
|
|
20984
21031
|
}
|
|
20985
21032
|
const now = Date.now();
|
|
@@ -21000,7 +21047,7 @@ ${stdout}`;
|
|
|
21000
21047
|
const output = stderr || stdout;
|
|
21001
21048
|
const errors = parseTscOutput(output);
|
|
21002
21049
|
if (errors.length > 0) {
|
|
21003
|
-
const fixResult = autoFixErrors(filePath,
|
|
21050
|
+
const fixResult = autoFixErrors(filePath, readFileSync21(filePath, "utf-8"), errors);
|
|
21004
21051
|
if (fixResult.fixed) {
|
|
21005
21052
|
writeFileSync13(filePath, fixResult.newContent, "utf-8");
|
|
21006
21053
|
result.output += `
|
|
@@ -21265,11 +21312,11 @@ class PlanTracker {
|
|
|
21265
21312
|
var init_tracker = () => {};
|
|
21266
21313
|
|
|
21267
21314
|
// src/modules/execution/plan-store.ts
|
|
21268
|
-
import { readFileSync as
|
|
21269
|
-
import { join as
|
|
21315
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync14, renameSync as renameSync3, mkdirSync as mkdirSync16, existsSync as existsSync38, readdirSync as readdirSync11, rmSync } from "fs";
|
|
21316
|
+
import { join as join32 } from "path";
|
|
21270
21317
|
function readPlanFile(path, fallbackBaseDir) {
|
|
21271
21318
|
try {
|
|
21272
|
-
const raw =
|
|
21319
|
+
const raw = readFileSync22(path, "utf-8");
|
|
21273
21320
|
if (!raw.trim())
|
|
21274
21321
|
return null;
|
|
21275
21322
|
const parsed = JSON.parse(raw);
|
|
@@ -21293,10 +21340,10 @@ function writePlanFile(path, plan) {
|
|
|
21293
21340
|
renameSync3(tmpPath, path);
|
|
21294
21341
|
}
|
|
21295
21342
|
function listDir(dir, baseDir) {
|
|
21296
|
-
if (!
|
|
21343
|
+
if (!existsSync38(dir))
|
|
21297
21344
|
return [];
|
|
21298
21345
|
const files = readdirSync11(dir).filter((f) => f.endsWith(".json"));
|
|
21299
|
-
return files.map((f) => readPlanFile(
|
|
21346
|
+
return files.map((f) => readPlanFile(join32(dir, f), baseDir)).filter((p) => p !== null);
|
|
21300
21347
|
}
|
|
21301
21348
|
function toMeta(plan, status) {
|
|
21302
21349
|
return {
|
|
@@ -21317,33 +21364,33 @@ class PlanStore {
|
|
|
21317
21364
|
archiveDir;
|
|
21318
21365
|
legacyPath;
|
|
21319
21366
|
constructor(baseDir) {
|
|
21320
|
-
const mmaDir =
|
|
21321
|
-
if (!
|
|
21367
|
+
const mmaDir = join32(baseDir, ".mma");
|
|
21368
|
+
if (!existsSync38(mmaDir))
|
|
21322
21369
|
mkdirSync16(mmaDir, { recursive: true });
|
|
21323
21370
|
this.baseDir = baseDir;
|
|
21324
|
-
this.plansDir =
|
|
21325
|
-
this.draftsDir =
|
|
21326
|
-
this.archiveDir =
|
|
21327
|
-
this.legacyPath =
|
|
21371
|
+
this.plansDir = join32(mmaDir, "plans");
|
|
21372
|
+
this.draftsDir = join32(this.plansDir, "drafts");
|
|
21373
|
+
this.archiveDir = join32(this.plansDir, "archive");
|
|
21374
|
+
this.legacyPath = join32(mmaDir, LEGACY_FILE);
|
|
21328
21375
|
for (const dir of [this.plansDir, this.draftsDir, this.archiveDir]) {
|
|
21329
|
-
if (!
|
|
21376
|
+
if (!existsSync38(dir))
|
|
21330
21377
|
mkdirSync16(dir, { recursive: true });
|
|
21331
21378
|
}
|
|
21332
21379
|
}
|
|
21333
21380
|
activePath() {
|
|
21334
|
-
return
|
|
21381
|
+
return join32(this.plansDir, "active.json");
|
|
21335
21382
|
}
|
|
21336
21383
|
saveActive(plan) {
|
|
21337
21384
|
writePlanFile(this.activePath(), plan);
|
|
21338
21385
|
}
|
|
21339
21386
|
loadActive() {
|
|
21340
21387
|
const activePath = this.activePath();
|
|
21341
|
-
if (
|
|
21388
|
+
if (existsSync38(activePath)) {
|
|
21342
21389
|
const plan = readPlanFile(activePath, this.baseDir);
|
|
21343
21390
|
if (plan)
|
|
21344
21391
|
return plan;
|
|
21345
21392
|
}
|
|
21346
|
-
if (
|
|
21393
|
+
if (existsSync38(this.legacyPath)) {
|
|
21347
21394
|
const legacy = readPlanFile(this.legacyPath, this.baseDir);
|
|
21348
21395
|
if (legacy) {
|
|
21349
21396
|
this.saveActive(legacy);
|
|
@@ -21362,26 +21409,26 @@ class PlanStore {
|
|
|
21362
21409
|
}
|
|
21363
21410
|
clearActive() {
|
|
21364
21411
|
const p = this.activePath();
|
|
21365
|
-
if (
|
|
21412
|
+
if (existsSync38(p))
|
|
21366
21413
|
rmSync(p, { force: true });
|
|
21367
21414
|
}
|
|
21368
21415
|
saveDraft(plan) {
|
|
21369
|
-
writePlanFile(
|
|
21416
|
+
writePlanFile(join32(this.draftsDir, `${plan.id}.json`), plan);
|
|
21370
21417
|
}
|
|
21371
21418
|
loadDraft(id) {
|
|
21372
|
-
const p =
|
|
21373
|
-
return
|
|
21419
|
+
const p = join32(this.draftsDir, `${id}.json`);
|
|
21420
|
+
return existsSync38(p) ? readPlanFile(p, this.baseDir) : null;
|
|
21374
21421
|
}
|
|
21375
21422
|
removeDraft(id) {
|
|
21376
|
-
const p =
|
|
21377
|
-
if (
|
|
21423
|
+
const p = join32(this.draftsDir, `${id}.json`);
|
|
21424
|
+
if (existsSync38(p))
|
|
21378
21425
|
rmSync(p, { force: true });
|
|
21379
21426
|
}
|
|
21380
21427
|
listDrafts() {
|
|
21381
21428
|
return listDir(this.draftsDir, this.baseDir);
|
|
21382
21429
|
}
|
|
21383
21430
|
archivePlan(plan) {
|
|
21384
|
-
writePlanFile(
|
|
21431
|
+
writePlanFile(join32(this.archiveDir, `${plan.id}.json`), plan);
|
|
21385
21432
|
this.removeDraft(plan.id);
|
|
21386
21433
|
const active = this.loadActive();
|
|
21387
21434
|
if (active && active.id === plan.id) {
|
|
@@ -21392,8 +21439,8 @@ class PlanStore {
|
|
|
21392
21439
|
return listDir(this.archiveDir, this.baseDir);
|
|
21393
21440
|
}
|
|
21394
21441
|
removeArchived(id) {
|
|
21395
|
-
const p =
|
|
21396
|
-
if (
|
|
21442
|
+
const p = join32(this.archiveDir, `${id}.json`);
|
|
21443
|
+
if (existsSync38(p))
|
|
21397
21444
|
rmSync(p, { force: true });
|
|
21398
21445
|
}
|
|
21399
21446
|
listAll() {
|
|
@@ -21425,13 +21472,13 @@ class PlanStore {
|
|
|
21425
21472
|
this.clearActive();
|
|
21426
21473
|
return "active";
|
|
21427
21474
|
}
|
|
21428
|
-
const draftPath =
|
|
21429
|
-
if (
|
|
21475
|
+
const draftPath = join32(this.draftsDir, `${id}.json`);
|
|
21476
|
+
if (existsSync38(draftPath)) {
|
|
21430
21477
|
rmSync(draftPath, { force: true });
|
|
21431
21478
|
return "draft";
|
|
21432
21479
|
}
|
|
21433
|
-
const archivedPath =
|
|
21434
|
-
if (
|
|
21480
|
+
const archivedPath = join32(this.archiveDir, `${id}.json`);
|
|
21481
|
+
if (existsSync38(archivedPath)) {
|
|
21435
21482
|
rmSync(archivedPath, { force: true });
|
|
21436
21483
|
return "archived";
|
|
21437
21484
|
}
|
|
@@ -22551,7 +22598,7 @@ var init_plan_tool = __esm(() => {
|
|
|
22551
22598
|
});
|
|
22552
22599
|
|
|
22553
22600
|
// src/modules/execution/module.ts
|
|
22554
|
-
import { existsSync as
|
|
22601
|
+
import { existsSync as existsSync39, readFileSync as readFileSync23 } from "fs";
|
|
22555
22602
|
import { resolve as resolve18 } from "path";
|
|
22556
22603
|
|
|
22557
22604
|
class ExecutionModule {
|
|
@@ -22910,7 +22957,7 @@ class ExecutionModule {
|
|
|
22910
22957
|
"poetry.lock",
|
|
22911
22958
|
"requirements.txt"
|
|
22912
22959
|
];
|
|
22913
|
-
const hasLockFile = lockFiles.some((f) =>
|
|
22960
|
+
const hasLockFile = lockFiles.some((f) => existsSync39(resolve18(this.baseDir, f)));
|
|
22914
22961
|
if (!hasLockFile) {
|
|
22915
22962
|
if (contextManager) {
|
|
22916
22963
|
const hints = this.state.depsGateHints.get(step.id) || 0;
|
|
@@ -22942,7 +22989,7 @@ class ExecutionModule {
|
|
|
22942
22989
|
if (!r)
|
|
22943
22990
|
continue;
|
|
22944
22991
|
try {
|
|
22945
|
-
const content =
|
|
22992
|
+
const content = readFileSync23(r, "utf-8");
|
|
22946
22993
|
if (content.trim().length < 10) {
|
|
22947
22994
|
emptyFiles.push(r);
|
|
22948
22995
|
}
|
|
@@ -23050,8 +23097,8 @@ var init_module = __esm(() => {
|
|
|
23050
23097
|
});
|
|
23051
23098
|
|
|
23052
23099
|
// src/modules/security/session-encryption.ts
|
|
23053
|
-
import { readFileSync as
|
|
23054
|
-
import { join as
|
|
23100
|
+
import { readFileSync as readFileSync24, writeFileSync as writeFileSync15, existsSync as existsSync40, readdirSync as readdirSync12, unlinkSync as unlinkSync5 } from "fs";
|
|
23101
|
+
import { join as join33 } from "path";
|
|
23055
23102
|
import { homedir as homedir9 } from "os";
|
|
23056
23103
|
|
|
23057
23104
|
class SessionFileEncryptor {
|
|
@@ -23060,7 +23107,7 @@ class SessionFileEncryptor {
|
|
|
23060
23107
|
constructor(config) {
|
|
23061
23108
|
this.config = { ...DEFAULT_SESSION_ENCRYPTION, ...config };
|
|
23062
23109
|
this.encryptor = new ConfigEncryptor({
|
|
23063
|
-
keyPath: config?.keyPath ||
|
|
23110
|
+
keyPath: config?.keyPath || join33(homedir9(), ".mma", ".session-encryption-key")
|
|
23064
23111
|
});
|
|
23065
23112
|
}
|
|
23066
23113
|
isEnabled() {
|
|
@@ -23112,7 +23159,7 @@ class SessionFileEncryptor {
|
|
|
23112
23159
|
});
|
|
23113
23160
|
}
|
|
23114
23161
|
readSessionFile(filePath) {
|
|
23115
|
-
const content =
|
|
23162
|
+
const content = readFileSync24(filePath, "utf8");
|
|
23116
23163
|
return this.decryptFileContent(content);
|
|
23117
23164
|
}
|
|
23118
23165
|
writeSessionFile(filePath, content) {
|
|
@@ -23120,7 +23167,7 @@ class SessionFileEncryptor {
|
|
|
23120
23167
|
writeFileSync15(filePath, encrypted, "utf8");
|
|
23121
23168
|
}
|
|
23122
23169
|
readSessionJSON(filePath) {
|
|
23123
|
-
const content =
|
|
23170
|
+
const content = readFileSync24(filePath, "utf8");
|
|
23124
23171
|
return this.decryptJSON(content);
|
|
23125
23172
|
}
|
|
23126
23173
|
writeSessionJSON(filePath, obj) {
|
|
@@ -23128,7 +23175,7 @@ class SessionFileEncryptor {
|
|
|
23128
23175
|
writeFileSync15(filePath, content, "utf8");
|
|
23129
23176
|
}
|
|
23130
23177
|
readSessionJSONL(filePath) {
|
|
23131
|
-
const content =
|
|
23178
|
+
const content = readFileSync24(filePath, "utf8");
|
|
23132
23179
|
const lines = content.split(`
|
|
23133
23180
|
`).filter((line) => line.trim());
|
|
23134
23181
|
const decryptedLines = this.decryptJSONL(lines);
|
|
@@ -23153,10 +23200,10 @@ class SessionFileEncryptor {
|
|
|
23153
23200
|
return;
|
|
23154
23201
|
const files = readdirSync12(sessionDir);
|
|
23155
23202
|
for (const file of files) {
|
|
23156
|
-
const filePath =
|
|
23157
|
-
if (
|
|
23203
|
+
const filePath = join33(sessionDir, file);
|
|
23204
|
+
if (existsSync40(filePath) && !file.endsWith(".enc")) {
|
|
23158
23205
|
try {
|
|
23159
|
-
const content =
|
|
23206
|
+
const content = readFileSync24(filePath, "utf8");
|
|
23160
23207
|
const encrypted = this.encryptFileContent(content);
|
|
23161
23208
|
writeFileSync15(filePath + ".enc", encrypted, "utf8");
|
|
23162
23209
|
unlinkSync5(filePath);
|
|
@@ -23170,10 +23217,10 @@ class SessionFileEncryptor {
|
|
|
23170
23217
|
const files = readdirSync12(sessionDir);
|
|
23171
23218
|
for (const file of files) {
|
|
23172
23219
|
if (file.endsWith(".enc")) {
|
|
23173
|
-
const encFilePath =
|
|
23220
|
+
const encFilePath = join33(sessionDir, file);
|
|
23174
23221
|
const decFilePath = encFilePath.slice(0, -4);
|
|
23175
23222
|
try {
|
|
23176
|
-
const content =
|
|
23223
|
+
const content = readFileSync24(encFilePath, "utf8");
|
|
23177
23224
|
const decrypted = this.decryptFileContent(content);
|
|
23178
23225
|
writeFileSync15(decFilePath, decrypted, "utf8");
|
|
23179
23226
|
unlinkSync5(encFilePath);
|
|
@@ -23195,15 +23242,15 @@ var init_session_encryption = __esm(() => {
|
|
|
23195
23242
|
|
|
23196
23243
|
// src/modules/session/store.ts
|
|
23197
23244
|
import {
|
|
23198
|
-
existsSync as
|
|
23245
|
+
existsSync as existsSync41,
|
|
23199
23246
|
mkdirSync as mkdirSync17,
|
|
23200
23247
|
readdirSync as readdirSync13,
|
|
23201
|
-
readFileSync as
|
|
23248
|
+
readFileSync as readFileSync25,
|
|
23202
23249
|
rmSync as rmSync2,
|
|
23203
23250
|
writeFileSync as writeFileSync16,
|
|
23204
23251
|
appendFileSync as appendFileSync6
|
|
23205
23252
|
} from "fs";
|
|
23206
|
-
import { join as
|
|
23253
|
+
import { join as join34 } from "path";
|
|
23207
23254
|
import { gzipSync } from "zlib";
|
|
23208
23255
|
|
|
23209
23256
|
class SessionStore {
|
|
@@ -23217,7 +23264,7 @@ class SessionStore {
|
|
|
23217
23264
|
}
|
|
23218
23265
|
}
|
|
23219
23266
|
getSessionDir(id) {
|
|
23220
|
-
return
|
|
23267
|
+
return join34(this.baseDir, id);
|
|
23221
23268
|
}
|
|
23222
23269
|
updateEncryption(config) {
|
|
23223
23270
|
if (config?.enabled) {
|
|
@@ -23233,19 +23280,19 @@ class SessionStore {
|
|
|
23233
23280
|
mkdirSync17(this.baseDir, { recursive: true, mode: 448 });
|
|
23234
23281
|
}
|
|
23235
23282
|
sessionDir(id) {
|
|
23236
|
-
return
|
|
23283
|
+
return join34(this.baseDir, id);
|
|
23237
23284
|
}
|
|
23238
23285
|
metaPath(id) {
|
|
23239
|
-
return
|
|
23286
|
+
return join34(this.sessionDir(id), "meta.json");
|
|
23240
23287
|
}
|
|
23241
23288
|
historyPath(id) {
|
|
23242
|
-
return
|
|
23289
|
+
return join34(this.sessionDir(id), "history.jsonl");
|
|
23243
23290
|
}
|
|
23244
23291
|
sessionLogPath(id) {
|
|
23245
|
-
return
|
|
23292
|
+
return join34(this.sessionDir(id), "session.jsonl");
|
|
23246
23293
|
}
|
|
23247
23294
|
sessionExists(id) {
|
|
23248
|
-
return
|
|
23295
|
+
return existsSync41(this.metaPath(id));
|
|
23249
23296
|
}
|
|
23250
23297
|
saveMeta(id, meta) {
|
|
23251
23298
|
this._metaCache.set(id, meta);
|
|
@@ -23263,10 +23310,10 @@ class SessionStore {
|
|
|
23263
23310
|
if (cached)
|
|
23264
23311
|
return cached;
|
|
23265
23312
|
const path = this.metaPath(id);
|
|
23266
|
-
if (!
|
|
23313
|
+
if (!existsSync41(path))
|
|
23267
23314
|
return null;
|
|
23268
23315
|
try {
|
|
23269
|
-
const raw =
|
|
23316
|
+
const raw = readFileSync25(path, "utf-8");
|
|
23270
23317
|
const content = this.encryptor ? this.encryptor.decryptFileContent(raw) : raw;
|
|
23271
23318
|
const meta = JSON.parse(content);
|
|
23272
23319
|
this._metaCache.set(id, meta);
|
|
@@ -23277,10 +23324,10 @@ class SessionStore {
|
|
|
23277
23324
|
}
|
|
23278
23325
|
readMetaFromDisk(id) {
|
|
23279
23326
|
const path = this.metaPath(id);
|
|
23280
|
-
if (!
|
|
23327
|
+
if (!existsSync41(path))
|
|
23281
23328
|
return null;
|
|
23282
23329
|
try {
|
|
23283
|
-
const raw =
|
|
23330
|
+
const raw = readFileSync25(path, "utf-8");
|
|
23284
23331
|
const content = this.encryptor ? this.encryptor.decryptFileContent(raw) : raw;
|
|
23285
23332
|
return JSON.parse(content);
|
|
23286
23333
|
} catch {
|
|
@@ -23307,10 +23354,10 @@ class SessionStore {
|
|
|
23307
23354
|
}
|
|
23308
23355
|
loadHistory(id) {
|
|
23309
23356
|
const path = this.historyPath(id);
|
|
23310
|
-
if (!
|
|
23357
|
+
if (!existsSync41(path))
|
|
23311
23358
|
return [];
|
|
23312
23359
|
try {
|
|
23313
|
-
const raw =
|
|
23360
|
+
const raw = readFileSync25(path, "utf-8");
|
|
23314
23361
|
const lines = raw.split(`
|
|
23315
23362
|
`).filter(Boolean);
|
|
23316
23363
|
const parseLine = (line) => {
|
|
@@ -23348,10 +23395,10 @@ class SessionStore {
|
|
|
23348
23395
|
}
|
|
23349
23396
|
loadSessionLog(id) {
|
|
23350
23397
|
const path = this.sessionLogPath(id);
|
|
23351
|
-
if (!
|
|
23398
|
+
if (!existsSync41(path))
|
|
23352
23399
|
return [];
|
|
23353
23400
|
try {
|
|
23354
|
-
const raw =
|
|
23401
|
+
const raw = readFileSync25(path, "utf-8");
|
|
23355
23402
|
const lines = raw.split(`
|
|
23356
23403
|
`).filter(Boolean);
|
|
23357
23404
|
const parseLine = (line) => {
|
|
@@ -23376,7 +23423,7 @@ class SessionStore {
|
|
|
23376
23423
|
}
|
|
23377
23424
|
}
|
|
23378
23425
|
listSessions() {
|
|
23379
|
-
if (!
|
|
23426
|
+
if (!existsSync41(this.baseDir))
|
|
23380
23427
|
return [];
|
|
23381
23428
|
const entries = readdirSync13(this.baseDir, { withFileTypes: true });
|
|
23382
23429
|
const sessions = [];
|
|
@@ -23393,7 +23440,7 @@ class SessionStore {
|
|
|
23393
23440
|
deleteSession(id) {
|
|
23394
23441
|
this._metaCache.delete(id);
|
|
23395
23442
|
const dir = this.sessionDir(id);
|
|
23396
|
-
if (
|
|
23443
|
+
if (existsSync41(dir)) {
|
|
23397
23444
|
rmSync2(dir, { recursive: true, force: true });
|
|
23398
23445
|
}
|
|
23399
23446
|
}
|
|
@@ -23405,10 +23452,10 @@ class SessionStore {
|
|
|
23405
23452
|
const updatedAt = new Date(session2.updatedAt);
|
|
23406
23453
|
if (updatedAt < thirtyDaysAgo) {
|
|
23407
23454
|
const historyPath = this.historyPath(session2.id);
|
|
23408
|
-
if (
|
|
23409
|
-
const content =
|
|
23455
|
+
if (existsSync41(historyPath)) {
|
|
23456
|
+
const content = readFileSync25(historyPath, "utf-8");
|
|
23410
23457
|
const compressed = gzipSync(content);
|
|
23411
|
-
const gzPath =
|
|
23458
|
+
const gzPath = join34(this.baseDir, `${session2.id}.jsonl.gz`);
|
|
23412
23459
|
writeFileSync16(gzPath, compressed);
|
|
23413
23460
|
rmSync2(historyPath);
|
|
23414
23461
|
const meta = this.loadMeta(session2.id);
|
|
@@ -23638,8 +23685,8 @@ class ProfileCompressor {
|
|
|
23638
23685
|
}
|
|
23639
23686
|
|
|
23640
23687
|
// src/modules/user-profile/profile.ts
|
|
23641
|
-
import { readFileSync as
|
|
23642
|
-
import { join as
|
|
23688
|
+
import { readFileSync as readFileSync26, writeFileSync as writeFileSync17, existsSync as existsSync42, mkdirSync as mkdirSync18 } from "fs";
|
|
23689
|
+
import { join as join35 } from "path";
|
|
23643
23690
|
import { homedir as homedir10, hostname, platform as platform8, type } from "os";
|
|
23644
23691
|
import { env } from "process";
|
|
23645
23692
|
|
|
@@ -23663,17 +23710,17 @@ class UserProfile {
|
|
|
23663
23710
|
return this.info;
|
|
23664
23711
|
}
|
|
23665
23712
|
save() {
|
|
23666
|
-
if (!
|
|
23713
|
+
if (!existsSync42(this.profileDir)) {
|
|
23667
23714
|
mkdirSync18(this.profileDir, { recursive: true });
|
|
23668
23715
|
}
|
|
23669
|
-
writeFileSync17(
|
|
23716
|
+
writeFileSync17(join35(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
|
|
23670
23717
|
}
|
|
23671
23718
|
load() {
|
|
23672
|
-
const path =
|
|
23673
|
-
if (!
|
|
23719
|
+
const path = join35(this.profileDir, "profile.json");
|
|
23720
|
+
if (!existsSync42(path))
|
|
23674
23721
|
return null;
|
|
23675
23722
|
try {
|
|
23676
|
-
const data = JSON.parse(
|
|
23723
|
+
const data = JSON.parse(readFileSync26(path, "utf-8"));
|
|
23677
23724
|
this.info = {
|
|
23678
23725
|
platform: data.platform,
|
|
23679
23726
|
os: data.os,
|
|
@@ -23708,12 +23755,12 @@ class UserProfile {
|
|
|
23708
23755
|
var init_profile = () => {};
|
|
23709
23756
|
|
|
23710
23757
|
// src/modules/skills/loader.ts
|
|
23711
|
-
import { readdirSync as readdirSync14, readFileSync as
|
|
23712
|
-
import { join as
|
|
23758
|
+
import { readdirSync as readdirSync14, readFileSync as readFileSync27, existsSync as existsSync43, statSync as statSync7 } from "fs";
|
|
23759
|
+
import { join as join36 } from "path";
|
|
23713
23760
|
|
|
23714
23761
|
class SkillsLoader {
|
|
23715
23762
|
loadFromDir(dirPath) {
|
|
23716
|
-
if (!
|
|
23763
|
+
if (!existsSync43(dirPath))
|
|
23717
23764
|
return [];
|
|
23718
23765
|
const skills = [];
|
|
23719
23766
|
this.scanDir(dirPath, skills);
|
|
@@ -23722,7 +23769,7 @@ class SkillsLoader {
|
|
|
23722
23769
|
scanDir(dirPath, skills) {
|
|
23723
23770
|
const entries = readdirSync14(dirPath);
|
|
23724
23771
|
for (const entry of entries) {
|
|
23725
|
-
const fullPath =
|
|
23772
|
+
const fullPath = join36(dirPath, entry);
|
|
23726
23773
|
let stat;
|
|
23727
23774
|
try {
|
|
23728
23775
|
stat = statSync7(fullPath);
|
|
@@ -23735,7 +23782,7 @@ class SkillsLoader {
|
|
|
23735
23782
|
}
|
|
23736
23783
|
if (!entry.endsWith(".md") && !entry.endsWith(".skill.md"))
|
|
23737
23784
|
continue;
|
|
23738
|
-
const content =
|
|
23785
|
+
const content = readFileSync27(fullPath, "utf-8");
|
|
23739
23786
|
const parsed = this.parseSkillFile(content, fullPath);
|
|
23740
23787
|
if (parsed)
|
|
23741
23788
|
skills.push(parsed);
|
|
@@ -24382,11 +24429,11 @@ var init_check_tool = __esm(() => {
|
|
|
24382
24429
|
});
|
|
24383
24430
|
|
|
24384
24431
|
// src/modules/lsp/module.ts
|
|
24385
|
-
import { existsSync as
|
|
24432
|
+
import { existsSync as existsSync44 } from "fs";
|
|
24386
24433
|
import { relative as relative5, resolve as resolve21 } from "path";
|
|
24387
|
-
import { join as
|
|
24434
|
+
import { join as join37 } from "path";
|
|
24388
24435
|
function hasTypeEnvironment(projectRoot) {
|
|
24389
|
-
return
|
|
24436
|
+
return existsSync44(join37(projectRoot, "tsconfig.json")) || existsSync44(join37(projectRoot, "jsconfig.json")) || existsSync44(join37(projectRoot, "node_modules"));
|
|
24390
24437
|
}
|
|
24391
24438
|
|
|
24392
24439
|
class LspModule {
|
|
@@ -24441,7 +24488,7 @@ class LspModule {
|
|
|
24441
24488
|
if (!filePath)
|
|
24442
24489
|
return;
|
|
24443
24490
|
const fullPath = resolve21(_ctx.baseDir, filePath);
|
|
24444
|
-
if (!
|
|
24491
|
+
if (!existsSync44(fullPath))
|
|
24445
24492
|
return;
|
|
24446
24493
|
const serverConfig = getServerForFile(fullPath, self.config);
|
|
24447
24494
|
if (!serverConfig)
|
|
@@ -24533,7 +24580,7 @@ ${items}`;
|
|
|
24533
24580
|
})
|
|
24534
24581
|
};
|
|
24535
24582
|
}
|
|
24536
|
-
if (!
|
|
24583
|
+
if (!existsSync44(resolved)) {
|
|
24537
24584
|
return { success: false, output: t("lsp.check_notfound", { path }) };
|
|
24538
24585
|
}
|
|
24539
24586
|
const files = await collectCheckFiles(resolved, this.config);
|
|
@@ -24650,8 +24697,8 @@ var init_lsp = __esm(() => {
|
|
|
24650
24697
|
});
|
|
24651
24698
|
|
|
24652
24699
|
// src/modules/lsp/startup-check.ts
|
|
24653
|
-
import { existsSync as
|
|
24654
|
-
import { join as
|
|
24700
|
+
import { existsSync as existsSync45 } from "fs";
|
|
24701
|
+
import { join as join38 } from "path";
|
|
24655
24702
|
import { spawn as spawn9 } from "child_process";
|
|
24656
24703
|
async function runStartupHealthCheck(config, baseDir, deps = {}) {
|
|
24657
24704
|
if (!config.enabled)
|
|
@@ -24678,7 +24725,7 @@ ${result.lines.join(`
|
|
|
24678
24725
|
}
|
|
24679
24726
|
async function runCheck(config, baseDir, deps) {
|
|
24680
24727
|
const projectRoot = findProjectRoot(baseDir, baseDir, ["tsconfig.json", "package.json"]);
|
|
24681
|
-
if (
|
|
24728
|
+
if (existsSync45(join38(projectRoot, "tsconfig.json"))) {
|
|
24682
24729
|
const runTsc = deps.runTsc ?? runTscDefault;
|
|
24683
24730
|
const errors = await runTsc(projectRoot, STARTUP_CHECK_TIMEOUT_MS);
|
|
24684
24731
|
if (errors.length === 0)
|
|
@@ -24951,8 +24998,8 @@ var init_symbols = __esm(() => {
|
|
|
24951
24998
|
});
|
|
24952
24999
|
|
|
24953
25000
|
// src/modules/indexer/walker.ts
|
|
24954
|
-
import { readdirSync as readdirSync15, readFileSync as
|
|
24955
|
-
import { join as
|
|
25001
|
+
import { readdirSync as readdirSync15, readFileSync as readFileSync28, statSync as statSync8, lstatSync, existsSync as existsSync46, watch } from "fs";
|
|
25002
|
+
import { join as join39, relative as relative6, extname as extname7 } from "path";
|
|
24956
25003
|
function isIgnoredDirName(name) {
|
|
24957
25004
|
return IGNORE_DIRS.has(name.toLowerCase());
|
|
24958
25005
|
}
|
|
@@ -24985,7 +25032,7 @@ class Indexer {
|
|
|
24985
25032
|
let totalSize = 0;
|
|
24986
25033
|
let count = 0;
|
|
24987
25034
|
const walkDir2 = (dir) => {
|
|
24988
|
-
if (!
|
|
25035
|
+
if (!existsSync46(dir))
|
|
24989
25036
|
return;
|
|
24990
25037
|
let entries;
|
|
24991
25038
|
try {
|
|
@@ -24996,7 +25043,7 @@ class Indexer {
|
|
|
24996
25043
|
for (const entry of entries) {
|
|
24997
25044
|
if (count >= this.MAX_FILES)
|
|
24998
25045
|
return;
|
|
24999
|
-
const fullPath =
|
|
25046
|
+
const fullPath = join39(dir, entry);
|
|
25000
25047
|
const relPath = relative6(this.baseDir, fullPath);
|
|
25001
25048
|
try {
|
|
25002
25049
|
const lst = lstatSync(fullPath, { throwIfNoEntry: false });
|
|
@@ -25011,7 +25058,7 @@ class Indexer {
|
|
|
25011
25058
|
const ext = extname7(entry).toLowerCase();
|
|
25012
25059
|
const language = languageIdForExt(ext);
|
|
25013
25060
|
if (language) {
|
|
25014
|
-
const content =
|
|
25061
|
+
const content = readFileSync28(fullPath, "utf-8");
|
|
25015
25062
|
const exports = extractSymbols(content, language);
|
|
25016
25063
|
files.push({ path: relPath, language, exports, size: stat2.size });
|
|
25017
25064
|
totalSize += stat2.size;
|
|
@@ -25081,22 +25128,22 @@ var init_walker = __esm(() => {
|
|
|
25081
25128
|
});
|
|
25082
25129
|
|
|
25083
25130
|
// src/modules/indexer/cache.ts
|
|
25084
|
-
import { readFileSync as
|
|
25085
|
-
import { join as
|
|
25131
|
+
import { readFileSync as readFileSync29, writeFileSync as writeFileSync18, existsSync as existsSync47, mkdirSync as mkdirSync19, rmSync as rmSync3 } from "fs";
|
|
25132
|
+
import { join as join40 } from "path";
|
|
25086
25133
|
|
|
25087
25134
|
class IndexCache {
|
|
25088
25135
|
cachePath;
|
|
25089
25136
|
cache = null;
|
|
25090
25137
|
constructor(cacheDir) {
|
|
25091
|
-
this.cachePath =
|
|
25138
|
+
this.cachePath = join40(cacheDir, "index-cache.json");
|
|
25092
25139
|
}
|
|
25093
25140
|
load() {
|
|
25094
25141
|
if (this.cache)
|
|
25095
25142
|
return this.cache;
|
|
25096
|
-
if (!
|
|
25143
|
+
if (!existsSync47(this.cachePath))
|
|
25097
25144
|
return null;
|
|
25098
25145
|
try {
|
|
25099
|
-
this.cache = JSON.parse(
|
|
25146
|
+
this.cache = JSON.parse(readFileSync29(this.cachePath, "utf-8"));
|
|
25100
25147
|
return this.cache;
|
|
25101
25148
|
} catch {
|
|
25102
25149
|
return null;
|
|
@@ -25104,14 +25151,14 @@ class IndexCache {
|
|
|
25104
25151
|
}
|
|
25105
25152
|
save(result) {
|
|
25106
25153
|
this.cache = result;
|
|
25107
|
-
const dir =
|
|
25108
|
-
if (!
|
|
25154
|
+
const dir = join40(this.cachePath, "..");
|
|
25155
|
+
if (!existsSync47(dir))
|
|
25109
25156
|
mkdirSync19(dir, { recursive: true });
|
|
25110
25157
|
writeFileSync18(this.cachePath, JSON.stringify(result), "utf-8");
|
|
25111
25158
|
}
|
|
25112
25159
|
invalidate() {
|
|
25113
25160
|
this.cache = null;
|
|
25114
|
-
if (
|
|
25161
|
+
if (existsSync47(this.cachePath)) {
|
|
25115
25162
|
try {
|
|
25116
25163
|
rmSync3(this.cachePath);
|
|
25117
25164
|
} catch {}
|
|
@@ -25186,11 +25233,11 @@ var init_map_select = __esm(() => {
|
|
|
25186
25233
|
});
|
|
25187
25234
|
|
|
25188
25235
|
// src/modules/indexer/project-profile.ts
|
|
25189
|
-
import { readFileSync as
|
|
25190
|
-
import { join as
|
|
25236
|
+
import { readFileSync as readFileSync30, existsSync as existsSync48 } from "fs";
|
|
25237
|
+
import { join as join41 } from "path";
|
|
25191
25238
|
function detectManifest(baseDir) {
|
|
25192
25239
|
for (const manifest of MANIFEST_ORDER) {
|
|
25193
|
-
if (
|
|
25240
|
+
if (existsSync48(join41(baseDir, manifest)))
|
|
25194
25241
|
return manifest;
|
|
25195
25242
|
}
|
|
25196
25243
|
return null;
|
|
@@ -25207,7 +25254,7 @@ function cleanDependency(entry) {
|
|
|
25207
25254
|
}
|
|
25208
25255
|
function readPackageJson(baseDir) {
|
|
25209
25256
|
try {
|
|
25210
|
-
const raw = JSON.parse(
|
|
25257
|
+
const raw = JSON.parse(readFileSync30(join41(baseDir, "package.json"), "utf-8"));
|
|
25211
25258
|
if (!raw || typeof raw !== "object")
|
|
25212
25259
|
return null;
|
|
25213
25260
|
const profile = {
|
|
@@ -25231,7 +25278,7 @@ function readPackageJson(baseDir) {
|
|
|
25231
25278
|
}
|
|
25232
25279
|
function readPyproject(baseDir) {
|
|
25233
25280
|
try {
|
|
25234
|
-
const content =
|
|
25281
|
+
const content = readFileSync30(join41(baseDir, "pyproject.toml"), "utf-8");
|
|
25235
25282
|
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
25236
25283
|
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
25237
25284
|
if (nameMatch)
|
|
@@ -25247,7 +25294,7 @@ function readPyproject(baseDir) {
|
|
|
25247
25294
|
}
|
|
25248
25295
|
function readCargo(baseDir) {
|
|
25249
25296
|
try {
|
|
25250
|
-
const content =
|
|
25297
|
+
const content = readFileSync30(join41(baseDir, "Cargo.toml"), "utf-8");
|
|
25251
25298
|
const profile = { runtime: "rust", deps: [], devDeps: [], scripts: {} };
|
|
25252
25299
|
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
25253
25300
|
if (nameMatch)
|
|
@@ -25271,7 +25318,7 @@ function readCargo(baseDir) {
|
|
|
25271
25318
|
}
|
|
25272
25319
|
function readGoMod(baseDir) {
|
|
25273
25320
|
try {
|
|
25274
|
-
const content =
|
|
25321
|
+
const content = readFileSync30(join41(baseDir, "go.mod"), "utf-8");
|
|
25275
25322
|
const profile = { runtime: "go", deps: [], devDeps: [], scripts: {} };
|
|
25276
25323
|
const moduleMatch = content.match(/^module\s+(\S+)/m);
|
|
25277
25324
|
if (moduleMatch)
|
|
@@ -25289,7 +25336,7 @@ function readGoMod(baseDir) {
|
|
|
25289
25336
|
}
|
|
25290
25337
|
function readRequirements(baseDir) {
|
|
25291
25338
|
try {
|
|
25292
|
-
const content =
|
|
25339
|
+
const content = readFileSync30(join41(baseDir, "requirements.txt"), "utf-8");
|
|
25293
25340
|
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
25294
25341
|
for (const line of content.split(`
|
|
25295
25342
|
`)) {
|
|
@@ -25354,7 +25401,7 @@ var init_project_profile = __esm(() => {
|
|
|
25354
25401
|
});
|
|
25355
25402
|
|
|
25356
25403
|
// src/modules/indexer/module.ts
|
|
25357
|
-
import { dirname as
|
|
25404
|
+
import { dirname as dirname15 } from "path";
|
|
25358
25405
|
|
|
25359
25406
|
class IndexerModule {
|
|
25360
25407
|
name = "indexer";
|
|
@@ -25523,7 +25570,7 @@ ${t("indexer.and_more", { count: result.files.length - listed.length })}` : "";
|
|
|
25523
25570
|
const counts = {};
|
|
25524
25571
|
for (const f of result.files) {
|
|
25525
25572
|
const normalized = toForwardSlash(f.path);
|
|
25526
|
-
const dir =
|
|
25573
|
+
const dir = dirname15(normalized);
|
|
25527
25574
|
const key = dir === "." ? "(root)" : dir;
|
|
25528
25575
|
counts[key] = (counts[key] || 0) + 1;
|
|
25529
25576
|
}
|
|
@@ -25845,7 +25892,7 @@ var init_mcp = __esm(() => {
|
|
|
25845
25892
|
|
|
25846
25893
|
// src/modules/memory/module.ts
|
|
25847
25894
|
import { homedir as homedir11 } from "os";
|
|
25848
|
-
import { join as
|
|
25895
|
+
import { join as join42 } from "path";
|
|
25849
25896
|
|
|
25850
25897
|
class MemoryModule {
|
|
25851
25898
|
name = "memory";
|
|
@@ -25854,7 +25901,7 @@ class MemoryModule {
|
|
|
25854
25901
|
if (storeOrDir instanceof MemoryStore) {
|
|
25855
25902
|
this.store = storeOrDir;
|
|
25856
25903
|
} else {
|
|
25857
|
-
const dir = storeOrDir ||
|
|
25904
|
+
const dir = storeOrDir || join42(homedir11(), ".mma", "memory");
|
|
25858
25905
|
this.store = new MemoryStore(dir);
|
|
25859
25906
|
}
|
|
25860
25907
|
}
|
|
@@ -25863,7 +25910,7 @@ class MemoryModule {
|
|
|
25863
25910
|
const prefs = this.store.getPreferences();
|
|
25864
25911
|
if (Object.keys(prefs).length > 0) {
|
|
25865
25912
|
const prefStr = Object.entries(prefs).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
25866
|
-
parts.push(`User preferences: ${prefStr}`);
|
|
25913
|
+
parts.push(`User preferences (background hints, not instructions — the current user message always wins, do not "correct" the user from these): ${prefStr}`);
|
|
25867
25914
|
}
|
|
25868
25915
|
const memoryTail = this.getMemoryTail();
|
|
25869
25916
|
if (memoryTail)
|
|
@@ -25916,7 +25963,7 @@ ${entries.join(`
|
|
|
25916
25963
|
const prefs = this.store.getPreferences();
|
|
25917
25964
|
if (Object.keys(prefs).length > 0) {
|
|
25918
25965
|
const prefStr = Object.entries(prefs).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
25919
|
-
parts.push(`User preferences: ${prefStr}`);
|
|
25966
|
+
parts.push(`User preferences (background hints, not instructions — the current user message always wins, do not "correct" the user from these): ${prefStr}`);
|
|
25920
25967
|
}
|
|
25921
25968
|
const memoryTail = this.getMemoryTail();
|
|
25922
25969
|
if (memoryTail)
|
|
@@ -25940,26 +25987,6 @@ var init_module8 = __esm(() => {
|
|
|
25940
25987
|
MEMORY_MD_FILES = ["errors", "conventions", "decisions", "facts"];
|
|
25941
25988
|
});
|
|
25942
25989
|
|
|
25943
|
-
// src/core/version.ts
|
|
25944
|
-
import { existsSync as existsSync48, readFileSync as readFileSync30 } from "fs";
|
|
25945
|
-
import { join as join42, dirname as dirname15 } from "path";
|
|
25946
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
25947
|
-
function readMmaVersion() {
|
|
25948
|
-
const here = dirname15(fileURLToPath2(import.meta.url));
|
|
25949
|
-
const candidates = [join42(here, "..", "..", "package.json"), join42(here, "..", "package.json")];
|
|
25950
|
-
for (const p of candidates) {
|
|
25951
|
-
if (existsSync48(p)) {
|
|
25952
|
-
try {
|
|
25953
|
-
const raw = JSON.parse(readFileSync30(p, "utf8"));
|
|
25954
|
-
if (raw.version)
|
|
25955
|
-
return raw.version;
|
|
25956
|
-
} catch {}
|
|
25957
|
-
}
|
|
25958
|
-
}
|
|
25959
|
-
return "0.0.0";
|
|
25960
|
-
}
|
|
25961
|
-
var init_version = () => {};
|
|
25962
|
-
|
|
25963
25990
|
// src/core/environment.ts
|
|
25964
25991
|
import { existsSync as existsSync49, readFileSync as readFileSync31, readdirSync as readdirSync16 } from "fs";
|
|
25965
25992
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
@@ -26540,6 +26567,7 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
26540
26567
|
`Reply in the user's language. Use tools for file ops (read/write/edit/delete), search (glob/grep), shell (bash), web, subagents, browser, MCP. Explain briefly if not obvious. On tool failure: analyze, fix the call, retry up to 2x with different approaches, then ask the user.`,
|
|
26541
26568
|
`Design: YAGNI (no unneeded code), KISS (simple over clever), DRY (reuse existing utilities).`,
|
|
26542
26569
|
`SCOPE DISCIPLINE: do ONLY what the user explicitly asked — no extra features, files, refactors, "improvements", or fixes beyond the request. Read-only requests ("расскажи", "покажи", "объясни", "check") mean READ-ONLY: inspect and answer, never create/modify/delete anything. If the task is ambiguous (what to create, where, which variant) or the request implies action on something you could not find — STOP and ask the user a short clarifying question in plain text instead of guessing.`,
|
|
26570
|
+
`INPUT PRIORITY: the current user message outranks stored memory/preferences/facts. Never override, reinterpret, or "correct" an explicit value the user states now (city, path, name, language, choice) because a stored preference disagrees — follow the user's current message. If they truly conflict or look like a typo, ask the user instead of assuming.`,
|
|
26543
26571
|
`NOT FOUND ≠ MISSING PROJECT: a "not found" tool result means the PATH was wrong (typo, different location), not that the project does not exist. Before creating or scaffolding ANY project/files: first run list_dir on the working directory to see what is already there; if a user-named path is not found, list its parent directory to locate the real path. NEVER create a new project when the user asked about an existing one — inspect first, create only after confirming the workspace is empty AND the user asked for creation.`
|
|
26544
26572
|
];
|
|
26545
26573
|
if (isWin) {
|
|
@@ -26645,7 +26673,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete, reas
|
|
|
26645
26673
|
const profile = new UserProfile(join46(dir));
|
|
26646
26674
|
profile.load() || profile.collect();
|
|
26647
26675
|
profile.save();
|
|
26648
|
-
|
|
26676
|
+
let activeSessionManager;
|
|
26677
|
+
const getSessionId = () => activeSessionManager?.getActiveMeta()?.id;
|
|
26678
|
+
const llmProvider = buildActiveProvider(config, logger4, { getSessionId }).provider;
|
|
26649
26679
|
const providerSpec = BUILTIN_PROVIDERS.find((p) => p.type === config.provider.type);
|
|
26650
26680
|
const reasoningStrategy = providerSpec?.capabilities.reasoningStrategy ?? "none";
|
|
26651
26681
|
let reasoningProbePromise = Promise.resolve(false);
|
|
@@ -26724,6 +26754,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete, reas
|
|
|
26724
26754
|
maxSessions: config.session.maxSessions,
|
|
26725
26755
|
isolation: config.sessionIsolation
|
|
26726
26756
|
});
|
|
26757
|
+
activeSessionManager = sessionManager;
|
|
26727
26758
|
if (config.session.autoSave && !sessionManager.getActive()) {
|
|
26728
26759
|
sessionManager.create();
|
|
26729
26760
|
}
|
|
@@ -40369,6 +40400,7 @@ init_colors();
|
|
|
40369
40400
|
import { existsSync as existsSync61 } from "fs";
|
|
40370
40401
|
import { join as join57, dirname as dirname25 } from "path";
|
|
40371
40402
|
import { homedir as homedir20 } from "os";
|
|
40403
|
+
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
40372
40404
|
|
|
40373
40405
|
// src/modules/updater/index.ts
|
|
40374
40406
|
init_checker();
|
|
@@ -40476,6 +40508,11 @@ ${t("cli.changelog_title", { version: result.latest })}
|
|
|
40476
40508
|
await this.runOnce();
|
|
40477
40509
|
}
|
|
40478
40510
|
}
|
|
40511
|
+
// src/modules/updater/dev-detect.ts
|
|
40512
|
+
function isDevEntryPath(path) {
|
|
40513
|
+
const clean = path.split(/[?#]/)[0];
|
|
40514
|
+
return clean.endsWith(".ts") || clean.endsWith(".tsx") || clean.endsWith(".mts") || clean.endsWith(".cts");
|
|
40515
|
+
}
|
|
40479
40516
|
// src/core/crash-handler.ts
|
|
40480
40517
|
init_environment();
|
|
40481
40518
|
init_data_sanitizer();
|
|
@@ -40564,6 +40601,8 @@ function closestCommand(input, known, maxDistance = 2) {
|
|
|
40564
40601
|
// src/cli/main.ts
|
|
40565
40602
|
init_utils();
|
|
40566
40603
|
function startAutoUpdate(config) {
|
|
40604
|
+
if (isDevEntryPath(fileURLToPath6(import.meta.url)))
|
|
40605
|
+
return;
|
|
40567
40606
|
try {
|
|
40568
40607
|
const module = new UpdaterModule(config.updater, readMmaVersion(), "micro-models-agent", {
|
|
40569
40608
|
info: (m) => process.stderr.write(pc2.dim(m) + `
|