micro-models-agent 0.24.11 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands.js +220 -0
- package/dist/cli/completer.js +168 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/main.js +113 -0
- package/dist/cli/repl.js +987 -0
- package/dist/cli/security-commands.js +166 -0
- package/dist/cli/setup.js +229 -0
- package/dist/config/config.js +186 -0
- package/dist/config/defaults.js +91 -0
- package/dist/config/experts.js +15 -0
- package/dist/config/index.js +3 -0
- package/dist/config/security.js +193 -0
- package/dist/config/types.js +1 -0
- package/dist/core/agent-moe.js +98 -0
- package/dist/core/agent.js +461 -0
- package/dist/core/bootstrap.js +321 -0
- package/dist/core/index.js +2 -0
- package/dist/core/prompt-builder.js +55 -0
- package/dist/core/session-logger.js +122 -0
- package/dist/core/types.js +1 -0
- package/dist/i18n/en.json +461 -0
- package/dist/i18n/index.js +43 -0
- package/dist/i18n/ru.json +461 -0
- package/dist/index.js +22 -0
- package/dist/llm/image-utils.js +144 -0
- package/dist/llm/index.js +4 -0
- package/dist/llm/model-loader.js +78 -0
- package/dist/llm/openai-compat.js +324 -0
- package/dist/llm/orchestrator.js +194 -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 +76 -0
- package/dist/logger/index.js +1 -0
- package/dist/main.js +709 -462
- package/dist/migration/backup.js +45 -0
- package/dist/migration/detect.js +50 -0
- package/dist/migration/index.js +2 -0
- package/dist/modules/browser/actions.js +46 -0
- package/dist/modules/browser/cookie-store.js +24 -0
- package/dist/modules/browser/index.js +5 -0
- package/dist/modules/browser/module.js +28 -0
- package/dist/modules/browser/session.js +287 -0
- package/dist/modules/browser/snapshot.js +114 -0
- package/dist/modules/browser/types.js +9 -0
- package/dist/modules/context/history.js +15 -0
- package/dist/modules/context/index.js +1 -0
- package/dist/modules/context/manager.js +240 -0
- package/dist/modules/execution/auditor.js +72 -0
- package/dist/modules/execution/index.js +6 -0
- package/dist/modules/execution/module.js +337 -0
- package/dist/modules/execution/moe-executor.js +209 -0
- package/dist/modules/execution/plan-validator.js +153 -0
- package/dist/modules/execution/planner.js +35 -0
- package/dist/modules/execution/stuck-detector.js +134 -0
- package/dist/modules/execution/tracker.js +53 -0
- package/dist/modules/execution/types.js +1 -0
- package/dist/modules/execution/verifier.js +149 -0
- package/dist/modules/hallucination/confidence.js +54 -0
- package/dist/modules/hallucination/consistency.js +60 -0
- package/dist/modules/hallucination/detector.js +41 -0
- package/dist/modules/hallucination/factual.js +170 -0
- package/dist/modules/hallucination/index.js +4 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/indexer/cache.js +38 -0
- package/dist/modules/indexer/index.js +3 -0
- package/dist/modules/indexer/module.js +192 -0
- package/dist/modules/indexer/walker.js +101 -0
- package/dist/modules/mcp/client.js +393 -0
- package/dist/modules/mcp/index.js +3 -0
- package/dist/modules/mcp/module.js +146 -0
- package/dist/modules/mcp/registry.js +15 -0
- package/dist/modules/memory/index.js +1 -0
- package/dist/modules/memory/module.js +48 -0
- package/dist/modules/memory/search.js +40 -0
- package/dist/modules/memory/store.js +65 -0
- package/dist/modules/pipelines/engine.js +60 -0
- package/dist/modules/pipelines/index.js +3 -0
- package/dist/modules/pipelines/parser.js +53 -0
- package/dist/modules/pipelines/template.js +14 -0
- package/dist/modules/plugins/builtin/lint-on-write.js +121 -0
- package/dist/modules/plugins/builtin/notify.js +8 -0
- package/dist/modules/plugins/index.js +1 -0
- package/dist/modules/plugins/loader.js +28 -0
- package/dist/modules/plugins/manager.js +161 -0
- package/dist/modules/plugins/types.js +1 -0
- package/dist/modules/processes/detect.js +34 -0
- package/dist/modules/processes/index.js +3 -0
- package/dist/modules/processes/registry.js +148 -0
- package/dist/modules/processes/runner.js +124 -0
- package/dist/modules/registry.js +45 -0
- package/dist/modules/security/audit-log.js +116 -0
- package/dist/modules/security/audit-notifier.js +292 -0
- package/dist/modules/security/command-validator.js +185 -0
- package/dist/modules/security/content-scanner.js +52 -0
- package/dist/modules/security/data-sanitizer.js +97 -0
- package/dist/modules/security/encryption.js +240 -0
- package/dist/modules/security/index.js +14 -0
- package/dist/modules/security/network-validator.js +79 -0
- package/dist/modules/security/path-validator.js +155 -0
- package/dist/modules/security/rate-limiter.js +119 -0
- package/dist/modules/security/security-policies.js +393 -0
- package/dist/modules/security/session-encryption.js +193 -0
- package/dist/modules/security/session-isolation.js +95 -0
- package/dist/modules/session/index.js +3 -0
- package/dist/modules/session/manager.js +167 -0
- package/dist/modules/session/module.js +24 -0
- package/dist/modules/session/store.js +174 -0
- package/dist/modules/session/types.js +1 -0
- package/dist/modules/skills/index.js +3 -0
- package/dist/modules/skills/loader.js +72 -0
- package/dist/modules/skills/matcher.js +27 -0
- package/dist/modules/skills/module.js +143 -0
- package/dist/modules/types.js +1 -0
- package/dist/modules/updater/checker.js +32 -0
- package/dist/modules/updater/index.js +1 -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/tools/approve.js +32 -0
- package/dist/tools/attach-image.js +89 -0
- package/dist/tools/bash.js +140 -0
- package/dist/tools/browser.js +97 -0
- package/dist/tools/create-dir.js +56 -0
- package/dist/tools/delete-file.js +63 -0
- package/dist/tools/edit-file.js +77 -0
- package/dist/tools/executor.js +95 -0
- package/dist/tools/file-info.js +45 -0
- package/dist/tools/filter-tools.js +10 -0
- package/dist/tools/glob-tool.js +26 -0
- package/dist/tools/grep-tool.js +64 -0
- package/dist/tools/index.js +52 -0
- package/dist/tools/list-dir.js +47 -0
- package/dist/tools/load-skill.js +48 -0
- package/dist/tools/mcp-call.js +68 -0
- package/dist/tools/move-file.js +84 -0
- package/dist/tools/path-utils.js +51 -0
- package/dist/tools/pipeline-run.js +144 -0
- package/dist/tools/preview.js +2 -0
- package/dist/tools/process-kill.js +29 -0
- package/dist/tools/process-list.js +38 -0
- package/dist/tools/process-log.js +41 -0
- package/dist/tools/question.js +142 -0
- package/dist/tools/read-file.js +73 -0
- package/dist/tools/recall.js +110 -0
- package/dist/tools/registry.js +36 -0
- package/dist/tools/remember.js +67 -0
- package/dist/tools/scope-check.js +30 -0
- package/dist/tools/search-history.js +64 -0
- package/dist/tools/subagent.js +142 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/user-input.js +123 -0
- package/dist/tools/web-browse.js +57 -0
- package/dist/tools/web-fetch.js +72 -0
- package/dist/tools/web-search.js +59 -0
- package/dist/tools/write-file.js +80 -0
- package/dist/ui/box.js +81 -0
- package/dist/ui/colors.js +4 -0
- package/dist/ui/diff.js +185 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/md-formatter.js +212 -0
- package/dist/ui/output.js +13 -0
- package/dist/ui/renderer.js +141 -0
- package/dist/ui/spinner.js +70 -0
- package/dist/ui/table.js +144 -0
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2076,10 +2076,90 @@ var init_security = __esm(() => {
|
|
|
2076
2076
|
};
|
|
2077
2077
|
});
|
|
2078
2078
|
|
|
2079
|
+
// src/modules/lsp/config.ts
|
|
2080
|
+
function getServerForFile(filePath, config) {
|
|
2081
|
+
const ext = filePath.split(".").pop()?.toLowerCase();
|
|
2082
|
+
if (!ext)
|
|
2083
|
+
return null;
|
|
2084
|
+
const lang = LANGUAGE_MAP[ext];
|
|
2085
|
+
if (!lang)
|
|
2086
|
+
return null;
|
|
2087
|
+
return config.servers[lang] ?? null;
|
|
2088
|
+
}
|
|
2089
|
+
var DEFAULT_LSP_CONFIG, LANGUAGE_MAP;
|
|
2090
|
+
var init_config = __esm(() => {
|
|
2091
|
+
DEFAULT_LSP_CONFIG = {
|
|
2092
|
+
enabled: true,
|
|
2093
|
+
timeout: 15000,
|
|
2094
|
+
servers: {
|
|
2095
|
+
typescript: {
|
|
2096
|
+
command: "npx",
|
|
2097
|
+
args: ["typescript-language-server", "--stdio"],
|
|
2098
|
+
timeout: 20000,
|
|
2099
|
+
autoInstall: true
|
|
2100
|
+
},
|
|
2101
|
+
javascript: {
|
|
2102
|
+
command: "npx",
|
|
2103
|
+
args: ["typescript-language-server", "--stdio"],
|
|
2104
|
+
timeout: 15000,
|
|
2105
|
+
autoInstall: true
|
|
2106
|
+
},
|
|
2107
|
+
python: {
|
|
2108
|
+
command: "npx",
|
|
2109
|
+
args: ["pyright", "--stdio"],
|
|
2110
|
+
timeout: 15000,
|
|
2111
|
+
autoInstall: true
|
|
2112
|
+
},
|
|
2113
|
+
rust: {
|
|
2114
|
+
command: "rust-analyzer",
|
|
2115
|
+
timeout: 15000,
|
|
2116
|
+
autoInstall: false
|
|
2117
|
+
},
|
|
2118
|
+
go: {
|
|
2119
|
+
command: "gopls",
|
|
2120
|
+
timeout: 15000,
|
|
2121
|
+
autoInstall: false
|
|
2122
|
+
},
|
|
2123
|
+
json: {
|
|
2124
|
+
command: "npx",
|
|
2125
|
+
args: ["vscode-json-languageserver", "--stdio"],
|
|
2126
|
+
timeout: 1e4,
|
|
2127
|
+
autoInstall: true
|
|
2128
|
+
},
|
|
2129
|
+
html: {
|
|
2130
|
+
command: "npx",
|
|
2131
|
+
args: ["vscode-html-languageserver", "--stdio"],
|
|
2132
|
+
timeout: 1e4,
|
|
2133
|
+
autoInstall: true
|
|
2134
|
+
},
|
|
2135
|
+
css: {
|
|
2136
|
+
command: "npx",
|
|
2137
|
+
args: ["vscode-css-languageserver", "--stdio"],
|
|
2138
|
+
timeout: 1e4,
|
|
2139
|
+
autoInstall: true
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
};
|
|
2143
|
+
LANGUAGE_MAP = {
|
|
2144
|
+
ts: "typescript",
|
|
2145
|
+
tsx: "typescript",
|
|
2146
|
+
js: "javascript",
|
|
2147
|
+
jsx: "javascript",
|
|
2148
|
+
py: "python",
|
|
2149
|
+
rs: "rust",
|
|
2150
|
+
go: "go",
|
|
2151
|
+
json: "json",
|
|
2152
|
+
html: "html",
|
|
2153
|
+
css: "css",
|
|
2154
|
+
scss: "css"
|
|
2155
|
+
};
|
|
2156
|
+
});
|
|
2157
|
+
|
|
2079
2158
|
// src/config/defaults.ts
|
|
2080
2159
|
var DEFAULTS;
|
|
2081
2160
|
var init_defaults = __esm(() => {
|
|
2082
2161
|
init_security();
|
|
2162
|
+
init_config();
|
|
2083
2163
|
DEFAULTS = {
|
|
2084
2164
|
version: "2.0.0",
|
|
2085
2165
|
model: "qwen3.5-9b",
|
|
@@ -2125,9 +2205,9 @@ var init_defaults = __esm(() => {
|
|
|
2125
2205
|
offloadKvCacheToGpu: true
|
|
2126
2206
|
},
|
|
2127
2207
|
retry: {
|
|
2128
|
-
maxRetries:
|
|
2129
|
-
baseDelay:
|
|
2130
|
-
maxDelay:
|
|
2208
|
+
maxRetries: 3,
|
|
2209
|
+
baseDelay: 1000,
|
|
2210
|
+
maxDelay: 30000
|
|
2131
2211
|
},
|
|
2132
2212
|
maxToolIterations: 1000,
|
|
2133
2213
|
stuckThreshold: 8,
|
|
@@ -2168,7 +2248,8 @@ var init_defaults = __esm(() => {
|
|
|
2168
2248
|
enabled: false,
|
|
2169
2249
|
isolatePlugins: true,
|
|
2170
2250
|
isolateTempFiles: true
|
|
2171
|
-
}
|
|
2251
|
+
},
|
|
2252
|
+
lsp: DEFAULT_LSP_CONFIG
|
|
2172
2253
|
};
|
|
2173
2254
|
});
|
|
2174
2255
|
|
|
@@ -3751,7 +3832,7 @@ function saveConfig(config, configPath) {
|
|
|
3751
3832
|
writeFileSync3(configPath, JSON.stringify(config, regexReplacer, 2), "utf-8");
|
|
3752
3833
|
}
|
|
3753
3834
|
}
|
|
3754
|
-
var
|
|
3835
|
+
var init_config2 = __esm(() => {
|
|
3755
3836
|
init_defaults();
|
|
3756
3837
|
init_security();
|
|
3757
3838
|
init_i18n();
|
|
@@ -4435,12 +4516,12 @@ class OpenAICompatProvider {
|
|
|
4435
4516
|
};
|
|
4436
4517
|
this.rateLimiter = createRateLimiter(config.rateLimits);
|
|
4437
4518
|
}
|
|
4438
|
-
async* chat(messages, tools
|
|
4519
|
+
async* chat(messages, tools) {
|
|
4439
4520
|
if (!this.rateLimiter.canMakeRequest()) {
|
|
4440
4521
|
throw new Error(`Rate limit exceeded: ${this.rateLimiter.getConfig().maxRequestsPerMinute} requests per minute`);
|
|
4441
4522
|
}
|
|
4442
4523
|
this.rateLimiter.recordRequest();
|
|
4443
|
-
const streamResult = this.doStream(messages, tools
|
|
4524
|
+
const streamResult = this.doStream(messages, tools);
|
|
4444
4525
|
let hasToolCall = false;
|
|
4445
4526
|
let hasText = false;
|
|
4446
4527
|
let reasoningAcc = "";
|
|
@@ -4455,13 +4536,13 @@ class OpenAICompatProvider {
|
|
|
4455
4536
|
yield chunk;
|
|
4456
4537
|
}
|
|
4457
4538
|
if (!hasToolCall && !hasText) {
|
|
4458
|
-
const fallback = await this.doNonStreaming(messages, tools
|
|
4539
|
+
const fallback = await this.doNonStreaming(messages, tools);
|
|
4459
4540
|
for (const chunk of fallback) {
|
|
4460
4541
|
yield chunk;
|
|
4461
4542
|
}
|
|
4462
4543
|
}
|
|
4463
4544
|
}
|
|
4464
|
-
async* doStream(messages, tools
|
|
4545
|
+
async* doStream(messages, tools) {
|
|
4465
4546
|
const body = {
|
|
4466
4547
|
model: this.model,
|
|
4467
4548
|
messages,
|
|
@@ -4488,15 +4569,6 @@ class OpenAICompatProvider {
|
|
|
4488
4569
|
const controller = new AbortController;
|
|
4489
4570
|
const totalTimeoutMs = 120000;
|
|
4490
4571
|
const timeoutId = setTimeout(() => controller.abort(), totalTimeoutMs);
|
|
4491
|
-
if (externalSignal) {
|
|
4492
|
-
if (externalSignal.aborted) {
|
|
4493
|
-
controller.abort();
|
|
4494
|
-
} else {
|
|
4495
|
-
externalSignal.addEventListener("abort", () => controller.abort(), {
|
|
4496
|
-
once: true
|
|
4497
|
-
});
|
|
4498
|
-
}
|
|
4499
|
-
}
|
|
4500
4572
|
const response = await this.fetchWithRetry(`${this.config.baseUrl}/chat/completions`, {
|
|
4501
4573
|
method: "POST",
|
|
4502
4574
|
headers,
|
|
@@ -4600,7 +4672,7 @@ class OpenAICompatProvider {
|
|
|
4600
4672
|
reader.releaseLock();
|
|
4601
4673
|
}
|
|
4602
4674
|
}
|
|
4603
|
-
async doNonStreaming(messages, tools
|
|
4675
|
+
async doNonStreaming(messages, tools) {
|
|
4604
4676
|
const body = {
|
|
4605
4677
|
model: this.model,
|
|
4606
4678
|
messages,
|
|
@@ -4625,15 +4697,11 @@ class OpenAICompatProvider {
|
|
|
4625
4697
|
headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
4626
4698
|
}
|
|
4627
4699
|
try {
|
|
4628
|
-
const
|
|
4700
|
+
const response = await this.fetchWithRetry(`${this.config.baseUrl}/chat/completions`, {
|
|
4629
4701
|
method: "POST",
|
|
4630
4702
|
headers,
|
|
4631
4703
|
body: JSON.stringify(body)
|
|
4632
|
-
};
|
|
4633
|
-
if (externalSignal) {
|
|
4634
|
-
fetchInit.signal = externalSignal;
|
|
4635
|
-
}
|
|
4636
|
-
const response = await this.fetchWithRetry(`${this.config.baseUrl}/chat/completions`, fetchInit);
|
|
4704
|
+
});
|
|
4637
4705
|
if (!response.ok) {
|
|
4638
4706
|
const errorText = await response.text();
|
|
4639
4707
|
throw new Error(t("error.llm_api", {
|
|
@@ -4897,8 +4965,7 @@ function runCommand(command, options = {}) {
|
|
|
4897
4965
|
cwd,
|
|
4898
4966
|
callId,
|
|
4899
4967
|
timeoutMs = 120000,
|
|
4900
|
-
maxBuffer = 10 * 1024 * 1024
|
|
4901
|
-
onOutput
|
|
4968
|
+
maxBuffer = 10 * 1024 * 1024
|
|
4902
4969
|
} = options;
|
|
4903
4970
|
return new Promise((resolve) => {
|
|
4904
4971
|
let timedOut = false;
|
|
@@ -4917,7 +4984,6 @@ function runCommand(command, options = {}) {
|
|
|
4917
4984
|
const decodeChunk = (chunk) => decoder ? decoder.decode(chunk, { stream: true }) : chunk.toString("utf-8");
|
|
4918
4985
|
child.stdout?.on("data", (chunk) => {
|
|
4919
4986
|
const text = decodeChunk(chunk);
|
|
4920
|
-
onOutput?.(text);
|
|
4921
4987
|
const next = stdoutRef.value.length + text.length;
|
|
4922
4988
|
if (next > maxBuffer) {
|
|
4923
4989
|
stdoutRef.value = stdoutRef.value.slice(stdoutRef.value.length + text.length - maxBuffer) + text;
|
|
@@ -4927,7 +4993,6 @@ function runCommand(command, options = {}) {
|
|
|
4927
4993
|
});
|
|
4928
4994
|
child.stderr?.on("data", (chunk) => {
|
|
4929
4995
|
const text = decodeChunk(chunk);
|
|
4930
|
-
onOutput?.(text);
|
|
4931
4996
|
const next = stderrRef.value.length + text.length;
|
|
4932
4997
|
if (next > maxBuffer) {
|
|
4933
4998
|
stderrRef.value = stderrRef.value.slice(stderrRef.value.length + text.length - maxBuffer) + text;
|
|
@@ -4961,13 +5026,7 @@ function runCommand(command, options = {}) {
|
|
|
4961
5026
|
clearTimeout(timer);
|
|
4962
5027
|
if (callId)
|
|
4963
5028
|
activeChildren.delete(callId);
|
|
4964
|
-
resolve({
|
|
4965
|
-
stdout: stdoutRef.value,
|
|
4966
|
-
stderr: stderrRef.value,
|
|
4967
|
-
code,
|
|
4968
|
-
signal,
|
|
4969
|
-
timedOut
|
|
4970
|
-
});
|
|
5029
|
+
resolve({ stdout: stdoutRef.value, stderr: stderrRef.value, code, signal, timedOut });
|
|
4971
5030
|
});
|
|
4972
5031
|
});
|
|
4973
5032
|
}
|
|
@@ -4976,61 +5035,11 @@ var init_runner = __esm(() => {
|
|
|
4976
5035
|
activeChildren = new Map;
|
|
4977
5036
|
});
|
|
4978
5037
|
|
|
4979
|
-
// src/tools/cache.ts
|
|
4980
|
-
class ToolResultCache {
|
|
4981
|
-
cache = new Map;
|
|
4982
|
-
maxEntries;
|
|
4983
|
-
defaultTtlMs;
|
|
4984
|
-
constructor(maxEntries = 50, defaultTtlMs = 60000) {
|
|
4985
|
-
this.maxEntries = maxEntries;
|
|
4986
|
-
this.defaultTtlMs = defaultTtlMs;
|
|
4987
|
-
}
|
|
4988
|
-
get(key) {
|
|
4989
|
-
const entry = this.cache.get(key);
|
|
4990
|
-
if (!entry)
|
|
4991
|
-
return;
|
|
4992
|
-
if (Date.now() > entry.expiresAt) {
|
|
4993
|
-
this.cache.delete(key);
|
|
4994
|
-
return;
|
|
4995
|
-
}
|
|
4996
|
-
this.cache.delete(key);
|
|
4997
|
-
this.cache.set(key, entry);
|
|
4998
|
-
return entry.value;
|
|
4999
|
-
}
|
|
5000
|
-
set(key, value, ttlMs) {
|
|
5001
|
-
if (this.cache.size >= this.maxEntries) {
|
|
5002
|
-
const firstKey = this.cache.keys().next().value;
|
|
5003
|
-
if (firstKey !== undefined) {
|
|
5004
|
-
this.cache.delete(firstKey);
|
|
5005
|
-
}
|
|
5006
|
-
}
|
|
5007
|
-
this.cache.set(key, {
|
|
5008
|
-
value,
|
|
5009
|
-
expiresAt: Date.now() + (ttlMs ?? this.defaultTtlMs)
|
|
5010
|
-
});
|
|
5011
|
-
}
|
|
5012
|
-
has(key) {
|
|
5013
|
-
return this.get(key) !== undefined;
|
|
5014
|
-
}
|
|
5015
|
-
clear() {
|
|
5016
|
-
this.cache.clear();
|
|
5017
|
-
}
|
|
5018
|
-
get size() {
|
|
5019
|
-
return this.cache.size;
|
|
5020
|
-
}
|
|
5021
|
-
}
|
|
5022
|
-
function hashKey(toolName, args) {
|
|
5023
|
-
const payload = toolName + JSON.stringify(args);
|
|
5024
|
-
const hash = Bun.hash(payload).toString(16).slice(0, 16);
|
|
5025
|
-
return hash;
|
|
5026
|
-
}
|
|
5027
|
-
|
|
5028
5038
|
// src/tools/executor.ts
|
|
5029
5039
|
class ToolExecutor {
|
|
5030
5040
|
registry;
|
|
5031
5041
|
ctx;
|
|
5032
5042
|
pluginManager;
|
|
5033
|
-
cache = new ToolResultCache(50, CACHE_TTL_MS);
|
|
5034
5043
|
constructor(registry, ctx, pluginManager) {
|
|
5035
5044
|
this.registry = registry;
|
|
5036
5045
|
this.ctx = ctx;
|
|
@@ -5045,18 +5054,6 @@ class ToolExecutor {
|
|
|
5045
5054
|
toolCallId: call.id
|
|
5046
5055
|
};
|
|
5047
5056
|
}
|
|
5048
|
-
if (CACHEABLE_TOOLS.has(call.name)) {
|
|
5049
|
-
const key = hashKey(call.name, call.arguments);
|
|
5050
|
-
const cached = this.cache.get(key);
|
|
5051
|
-
if (cached !== undefined) {
|
|
5052
|
-
this.ctx.logger.debug(`Tool ${call.name}: CACHE HIT`);
|
|
5053
|
-
return {
|
|
5054
|
-
success: true,
|
|
5055
|
-
output: cached,
|
|
5056
|
-
toolCallId: call.id
|
|
5057
|
-
};
|
|
5058
|
-
}
|
|
5059
|
-
}
|
|
5060
5057
|
for (const plugin of this.pluginManager.getAllPlugins()) {
|
|
5061
5058
|
if (plugin.onBeforeTool) {
|
|
5062
5059
|
try {
|
|
@@ -5127,11 +5124,6 @@ class ToolExecutor {
|
|
|
5127
5124
|
}
|
|
5128
5125
|
}
|
|
5129
5126
|
}
|
|
5130
|
-
if (result.success && CACHEABLE_TOOLS.has(call.name)) {
|
|
5131
|
-
const key = hashKey(call.name, call.arguments);
|
|
5132
|
-
this.cache.set(key, result.output);
|
|
5133
|
-
this.ctx.logger.debug(`Tool ${call.name}: CACHED`);
|
|
5134
|
-
}
|
|
5135
5127
|
this.ctx.logger.debug(`Tool ${call.name}: ${result.success ? "OK" : "FAIL"}`);
|
|
5136
5128
|
return result;
|
|
5137
5129
|
}
|
|
@@ -5141,9 +5133,6 @@ class ToolExecutor {
|
|
|
5141
5133
|
getRegistry() {
|
|
5142
5134
|
return this.registry;
|
|
5143
5135
|
}
|
|
5144
|
-
getContext() {
|
|
5145
|
-
return this.ctx;
|
|
5146
|
-
}
|
|
5147
5136
|
setScope(scope) {
|
|
5148
5137
|
this.ctx.scope = scope;
|
|
5149
5138
|
}
|
|
@@ -5151,11 +5140,10 @@ class ToolExecutor {
|
|
|
5151
5140
|
this.ctx.llmProvider = provider;
|
|
5152
5141
|
}
|
|
5153
5142
|
}
|
|
5154
|
-
var TOOL_EXECUTION_TIMEOUT_MS = 60000
|
|
5143
|
+
var TOOL_EXECUTION_TIMEOUT_MS = 60000;
|
|
5155
5144
|
var init_executor = __esm(() => {
|
|
5156
5145
|
init_runner();
|
|
5157
5146
|
init_i18n();
|
|
5158
|
-
CACHEABLE_TOOLS = new Set(["web_fetch"]);
|
|
5159
5147
|
});
|
|
5160
5148
|
|
|
5161
5149
|
// src/modules/security/path-validator.ts
|
|
@@ -5686,7 +5674,7 @@ function safeResolvePath(baseDir, userPath) {
|
|
|
5686
5674
|
var init_path_utils = () => {};
|
|
5687
5675
|
|
|
5688
5676
|
// src/tools/preview.ts
|
|
5689
|
-
var MAX_PREVIEW_LINES =
|
|
5677
|
+
var MAX_PREVIEW_LINES = 15;
|
|
5690
5678
|
|
|
5691
5679
|
// src/tools/read-file.ts
|
|
5692
5680
|
import { readFileSync as readFileSync5, existsSync as existsSync9 } from "fs";
|
|
@@ -7050,14 +7038,8 @@ var init_bash = __esm(() => {
|
|
|
7050
7038
|
type: "object",
|
|
7051
7039
|
properties: {
|
|
7052
7040
|
command: { type: "string", description: "Shell command to execute" },
|
|
7053
|
-
workdir: {
|
|
7054
|
-
|
|
7055
|
-
description: "Working directory (default: baseDir)"
|
|
7056
|
-
},
|
|
7057
|
-
background: {
|
|
7058
|
-
type: "boolean",
|
|
7059
|
-
description: "Start the command in the background and return immediately with a process id (default: auto-detect long-running commands)"
|
|
7060
|
-
}
|
|
7041
|
+
workdir: { type: "string", description: "Working directory (default: baseDir)" },
|
|
7042
|
+
background: { type: "boolean", description: "Start the command in the background and return immediately with a process id (default: auto-detect long-running commands)" }
|
|
7061
7043
|
},
|
|
7062
7044
|
required: ["command"]
|
|
7063
7045
|
},
|
|
@@ -7104,8 +7086,7 @@ ${t("proc.manage_hint", {
|
|
|
7104
7086
|
const res = await runCommand(command, {
|
|
7105
7087
|
cwd: workdir,
|
|
7106
7088
|
callId: ctx.activeCallId,
|
|
7107
|
-
timeoutMs: BASH_TIMEOUT_MS
|
|
7108
|
-
onOutput: ctx.onMeta
|
|
7089
|
+
timeoutMs: BASH_TIMEOUT_MS
|
|
7109
7090
|
});
|
|
7110
7091
|
const parts = [res.stdout.trimEnd(), res.stderr.trimEnd()].filter(Boolean);
|
|
7111
7092
|
let output = parts.join(`
|
|
@@ -9165,16 +9146,6 @@ var init_store = __esm(() => {
|
|
|
9165
9146
|
|
|
9166
9147
|
// src/core/agent.ts
|
|
9167
9148
|
import { join as join10 } from "path";
|
|
9168
|
-
function canRunInParallel(calls) {
|
|
9169
|
-
if (calls.length <= 1)
|
|
9170
|
-
return false;
|
|
9171
|
-
for (const call of calls) {
|
|
9172
|
-
if (SIDE_EFFECT_TOOLS.has(call.name) || WRITE_TOOLS.has(call.name)) {
|
|
9173
|
-
return false;
|
|
9174
|
-
}
|
|
9175
|
-
}
|
|
9176
|
-
return true;
|
|
9177
|
-
}
|
|
9178
9149
|
|
|
9179
9150
|
class Agent {
|
|
9180
9151
|
deps;
|
|
@@ -9297,7 +9268,6 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9297
9268
|
} = this.deps;
|
|
9298
9269
|
const slog = new SessionLogger(sessionManager);
|
|
9299
9270
|
this.abortController = new AbortController;
|
|
9300
|
-
this.shutdownRequested = false;
|
|
9301
9271
|
let iteration = 0;
|
|
9302
9272
|
let lastText = "";
|
|
9303
9273
|
let hallucinationRetries = 0;
|
|
@@ -9343,7 +9313,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9343
9313
|
const textChunks = [];
|
|
9344
9314
|
this.emitPhase(iteration, "thinking", onPhase);
|
|
9345
9315
|
try {
|
|
9346
|
-
for await (const chunk of llmProvider.chat(history, allTools
|
|
9316
|
+
for await (const chunk of llmProvider.chat(history, allTools)) {
|
|
9347
9317
|
if (this.shutdownRequested)
|
|
9348
9318
|
break;
|
|
9349
9319
|
if (chunk.type === "text" && chunk.content) {
|
|
@@ -9438,7 +9408,7 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9438
9408
|
});
|
|
9439
9409
|
const summaries = [];
|
|
9440
9410
|
let anyToolFailed = false;
|
|
9441
|
-
const
|
|
9411
|
+
for (const call of toolCalls) {
|
|
9442
9412
|
this.setScope();
|
|
9443
9413
|
const startTime = Date.now();
|
|
9444
9414
|
pluginManager.runOnToolCall({
|
|
@@ -9449,28 +9419,11 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9449
9419
|
onTool?.({ type: "start", tool: call.name, args: call.arguments });
|
|
9450
9420
|
slog.logToolCall(call, iteration);
|
|
9451
9421
|
const tokensBeforeTool = contextManager.getEstimatedTokens();
|
|
9452
|
-
const toolCtx = this.deps.toolExecutor?.getContext?.();
|
|
9453
|
-
const prevOnMeta = toolCtx?.onMeta;
|
|
9454
|
-
if (toolCtx) {
|
|
9455
|
-
toolCtx.onMeta = onMeta;
|
|
9456
|
-
}
|
|
9457
9422
|
const result = await toolExecutor.execute(call, this.abortController?.signal);
|
|
9458
|
-
if (toolCtx) {
|
|
9459
|
-
toolCtx.onMeta = prevOnMeta;
|
|
9460
|
-
}
|
|
9461
9423
|
const duration = Date.now() - startTime;
|
|
9462
|
-
pluginManager.runOnToolEnd({ iteration, logger }, { id: call.id, name: call.name, arguments: call.arguments }, result, duration);
|
|
9463
|
-
return { call, result, duration, tokensBefore: tokensBeforeTool };
|
|
9464
|
-
};
|
|
9465
|
-
const processToolResult = (entry) => {
|
|
9466
|
-
const {
|
|
9467
|
-
call,
|
|
9468
|
-
result,
|
|
9469
|
-
duration,
|
|
9470
|
-
tokensBefore: tokensBeforeTool
|
|
9471
|
-
} = entry;
|
|
9472
9424
|
if (!result.success)
|
|
9473
9425
|
anyToolFailed = true;
|
|
9426
|
+
pluginManager.runOnToolEnd({ iteration, logger }, { id: call.id, name: call.name, arguments: call.arguments }, result, duration);
|
|
9474
9427
|
if (result.display) {
|
|
9475
9428
|
onMeta?.(`
|
|
9476
9429
|
` + result.display + `
|
|
@@ -9514,17 +9467,6 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
|
|
|
9514
9467
|
contextManager.compact();
|
|
9515
9468
|
logger.debug("Context compacted after tool result");
|
|
9516
9469
|
}
|
|
9517
|
-
};
|
|
9518
|
-
if (canRunInParallel(toolCalls)) {
|
|
9519
|
-
const entries = await Promise.all(toolCalls.map(executeToolCall));
|
|
9520
|
-
for (const entry of entries) {
|
|
9521
|
-
processToolResult(entry);
|
|
9522
|
-
}
|
|
9523
|
-
} else {
|
|
9524
|
-
for (const call of toolCalls) {
|
|
9525
|
-
const entry = await executeToolCall(call);
|
|
9526
|
-
processToolResult(entry);
|
|
9527
|
-
}
|
|
9528
9470
|
}
|
|
9529
9471
|
if (anyToolFailed) {
|
|
9530
9472
|
consecutiveToolFailures++;
|
|
@@ -9735,7 +9677,7 @@ ${taskReminder}</system-summary>`
|
|
|
9735
9677
|
});
|
|
9736
9678
|
}
|
|
9737
9679
|
}
|
|
9738
|
-
var TOOL_RESULT_MAX_TOKENS_RATIO = 0.3, TOOL_RESULT_ABSOLUTE_MAX_CHARS = 15000
|
|
9680
|
+
var TOOL_RESULT_MAX_TOKENS_RATIO = 0.3, TOOL_RESULT_ABSOLUTE_MAX_CHARS = 15000;
|
|
9739
9681
|
var init_agent = __esm(() => {
|
|
9740
9682
|
init_i18n();
|
|
9741
9683
|
init_colors();
|
|
@@ -9743,14 +9685,6 @@ var init_agent = __esm(() => {
|
|
|
9743
9685
|
init_processes();
|
|
9744
9686
|
init_agent_moe();
|
|
9745
9687
|
init_store();
|
|
9746
|
-
WRITE_TOOLS = new Set([
|
|
9747
|
-
"write_file",
|
|
9748
|
-
"edit_file",
|
|
9749
|
-
"delete_file",
|
|
9750
|
-
"move_file",
|
|
9751
|
-
"create_dir"
|
|
9752
|
-
]);
|
|
9753
|
-
SIDE_EFFECT_TOOLS = new Set(["bash", "subagent", "pipeline_run"]);
|
|
9754
9688
|
});
|
|
9755
9689
|
|
|
9756
9690
|
// src/modules/context/manager.ts
|
|
@@ -13297,9 +13231,8 @@ var init_stuck_detector = __esm(() => {
|
|
|
13297
13231
|
});
|
|
13298
13232
|
|
|
13299
13233
|
// src/modules/execution/auditor.ts
|
|
13300
|
-
import { execSync as execSync4 } from "child_process";
|
|
13301
13234
|
import { existsSync as existsSync24 } from "fs";
|
|
13302
|
-
import { resolve as resolve13
|
|
13235
|
+
import { resolve as resolve13 } from "path";
|
|
13303
13236
|
|
|
13304
13237
|
class Auditor {
|
|
13305
13238
|
baseDir;
|
|
@@ -13322,22 +13255,16 @@ class Auditor {
|
|
|
13322
13255
|
}
|
|
13323
13256
|
const doneSteps = plan.steps.filter((s) => s.status === "done").length;
|
|
13324
13257
|
const totalSteps = plan.steps.length;
|
|
13325
|
-
const typeCheckError = await this.runProjectTypeCheck();
|
|
13326
13258
|
let massEditWarning = null;
|
|
13327
13259
|
if (uniqueFiles.length > MASS_EDIT_THRESHOLD) {
|
|
13328
13260
|
massEditWarning = t("exec.mass_edit_warning", { count: String(uniqueFiles.length) });
|
|
13329
13261
|
}
|
|
13330
|
-
const passed = missingFiles.length === 0
|
|
13262
|
+
const passed = missingFiles.length === 0;
|
|
13331
13263
|
let summary;
|
|
13332
13264
|
if (passed) {
|
|
13333
13265
|
summary = t("exec.audit_pass", { done: doneSteps, total: totalSteps, files: existingFiles.length });
|
|
13334
13266
|
} else {
|
|
13335
|
-
|
|
13336
|
-
if (typeCheckError) {
|
|
13337
|
-
summary = t("exec.audit_fail_typecheck", { done: doneSteps, total: totalSteps, missing: missingCount, typeError: typeCheckError });
|
|
13338
|
-
} else {
|
|
13339
|
-
summary = t("exec.audit_fail", { done: doneSteps, total: totalSteps, files: missingCount });
|
|
13340
|
-
}
|
|
13267
|
+
summary = t("exec.audit_fail", { done: doneSteps, total: totalSteps, files: missingFiles.length });
|
|
13341
13268
|
}
|
|
13342
13269
|
return {
|
|
13343
13270
|
passed,
|
|
@@ -13345,31 +13272,9 @@ class Auditor {
|
|
|
13345
13272
|
createdFiles: existingFiles,
|
|
13346
13273
|
modifiedFiles: [],
|
|
13347
13274
|
summary,
|
|
13348
|
-
typeCheckError,
|
|
13349
13275
|
massEditWarning
|
|
13350
13276
|
};
|
|
13351
13277
|
}
|
|
13352
|
-
async runProjectTypeCheck() {
|
|
13353
|
-
const tsconfigPath = join18(this.baseDir, "tsconfig.json");
|
|
13354
|
-
if (!existsSync24(tsconfigPath)) {
|
|
13355
|
-
return null;
|
|
13356
|
-
}
|
|
13357
|
-
try {
|
|
13358
|
-
execSync4(`npx tsc --noEmit --skipLibCheck`, { cwd: this.baseDir, stdio: "pipe", timeout: 30000 });
|
|
13359
|
-
return null;
|
|
13360
|
-
} catch (err) {
|
|
13361
|
-
if (err.status === 127 || err.message.includes("not found") || err.message.includes("ENOENT")) {
|
|
13362
|
-
return null;
|
|
13363
|
-
}
|
|
13364
|
-
const stderr = err.stderr?.toString() || err.stdout?.toString() || "";
|
|
13365
|
-
if (stderr.includes("error TS")) {
|
|
13366
|
-
const firstError = stderr.split(`
|
|
13367
|
-
`).find((line) => line.includes("error TS")) || "TypeScript type error";
|
|
13368
|
-
return firstError.trim();
|
|
13369
|
-
}
|
|
13370
|
-
return null;
|
|
13371
|
-
}
|
|
13372
|
-
}
|
|
13373
13278
|
}
|
|
13374
13279
|
var MASS_EDIT_THRESHOLD = 10;
|
|
13375
13280
|
var init_auditor = __esm(() => {
|
|
@@ -13378,16 +13283,16 @@ var init_auditor = __esm(() => {
|
|
|
13378
13283
|
|
|
13379
13284
|
// src/modules/execution/plan-persister.ts
|
|
13380
13285
|
import { readFileSync as readFileSync14, writeFileSync as writeFileSync9, mkdirSync as mkdirSync11, existsSync as existsSync25 } from "fs";
|
|
13381
|
-
import { join as
|
|
13286
|
+
import { join as join18 } from "path";
|
|
13382
13287
|
|
|
13383
13288
|
class PlanPersister {
|
|
13384
13289
|
filePath;
|
|
13385
13290
|
constructor(baseDir) {
|
|
13386
|
-
const mmaDir =
|
|
13291
|
+
const mmaDir = join18(baseDir, ".mma");
|
|
13387
13292
|
if (!existsSync25(mmaDir)) {
|
|
13388
13293
|
mkdirSync11(mmaDir, { recursive: true });
|
|
13389
13294
|
}
|
|
13390
|
-
this.filePath =
|
|
13295
|
+
this.filePath = join18(mmaDir, "plan.json");
|
|
13391
13296
|
}
|
|
13392
13297
|
save(plan) {
|
|
13393
13298
|
const file = {
|
|
@@ -14030,7 +13935,7 @@ var init_module = __esm(() => {
|
|
|
14030
13935
|
|
|
14031
13936
|
// src/modules/security/session-encryption.ts
|
|
14032
13937
|
import { readFileSync as readFileSync16, writeFileSync as writeFileSync10, existsSync as existsSync27, readdirSync as readdirSync6, unlinkSync as unlinkSync3 } from "fs";
|
|
14033
|
-
import { join as
|
|
13938
|
+
import { join as join19 } from "path";
|
|
14034
13939
|
import { homedir as homedir8 } from "os";
|
|
14035
13940
|
|
|
14036
13941
|
class SessionFileEncryptor {
|
|
@@ -14039,7 +13944,7 @@ class SessionFileEncryptor {
|
|
|
14039
13944
|
constructor(config) {
|
|
14040
13945
|
this.config = { ...DEFAULT_SESSION_ENCRYPTION, ...config };
|
|
14041
13946
|
this.encryptor = new ConfigEncryptor({
|
|
14042
|
-
keyPath: config?.keyPath ||
|
|
13947
|
+
keyPath: config?.keyPath || join19(homedir8(), ".mma", ".session-encryption-key")
|
|
14043
13948
|
});
|
|
14044
13949
|
}
|
|
14045
13950
|
isEnabled() {
|
|
@@ -14111,7 +14016,7 @@ class SessionFileEncryptor {
|
|
|
14111
14016
|
return;
|
|
14112
14017
|
const files = readdirSync6(sessionDir);
|
|
14113
14018
|
for (const file of files) {
|
|
14114
|
-
const filePath =
|
|
14019
|
+
const filePath = join19(sessionDir, file);
|
|
14115
14020
|
if (existsSync27(filePath) && !file.endsWith(".enc")) {
|
|
14116
14021
|
try {
|
|
14117
14022
|
const content = readFileSync16(filePath, "utf8");
|
|
@@ -14128,7 +14033,7 @@ class SessionFileEncryptor {
|
|
|
14128
14033
|
const files = readdirSync6(sessionDir);
|
|
14129
14034
|
for (const file of files) {
|
|
14130
14035
|
if (file.endsWith(".enc")) {
|
|
14131
|
-
const encFilePath =
|
|
14036
|
+
const encFilePath = join19(sessionDir, file);
|
|
14132
14037
|
const decFilePath = encFilePath.slice(0, -4);
|
|
14133
14038
|
try {
|
|
14134
14039
|
const content = readFileSync16(encFilePath, "utf8");
|
|
@@ -14161,7 +14066,7 @@ import {
|
|
|
14161
14066
|
writeFileSync as writeFileSync11,
|
|
14162
14067
|
appendFileSync as appendFileSync5
|
|
14163
14068
|
} from "fs";
|
|
14164
|
-
import { join as
|
|
14069
|
+
import { join as join20 } from "path";
|
|
14165
14070
|
import { gzipSync } from "zlib";
|
|
14166
14071
|
|
|
14167
14072
|
class SessionStore {
|
|
@@ -14187,16 +14092,16 @@ class SessionStore {
|
|
|
14187
14092
|
mkdirSync12(this.baseDir, { recursive: true });
|
|
14188
14093
|
}
|
|
14189
14094
|
sessionDir(id) {
|
|
14190
|
-
return
|
|
14095
|
+
return join20(this.baseDir, id);
|
|
14191
14096
|
}
|
|
14192
14097
|
metaPath(id) {
|
|
14193
|
-
return
|
|
14098
|
+
return join20(this.sessionDir(id), "meta.json");
|
|
14194
14099
|
}
|
|
14195
14100
|
historyPath(id) {
|
|
14196
|
-
return
|
|
14101
|
+
return join20(this.sessionDir(id), "history.jsonl");
|
|
14197
14102
|
}
|
|
14198
14103
|
sessionLogPath(id) {
|
|
14199
|
-
return
|
|
14104
|
+
return join20(this.sessionDir(id), "session.jsonl");
|
|
14200
14105
|
}
|
|
14201
14106
|
sessionExists(id) {
|
|
14202
14107
|
return existsSync28(this.metaPath(id));
|
|
@@ -14319,7 +14224,7 @@ class SessionStore {
|
|
|
14319
14224
|
if (existsSync28(historyPath)) {
|
|
14320
14225
|
const content = readFileSync17(historyPath, "utf-8");
|
|
14321
14226
|
const compressed = gzipSync(content);
|
|
14322
|
-
const gzPath =
|
|
14227
|
+
const gzPath = join20(this.baseDir, `${session2.id}.jsonl.gz`);
|
|
14323
14228
|
writeFileSync11(gzPath, compressed);
|
|
14324
14229
|
rmSync(historyPath);
|
|
14325
14230
|
}
|
|
@@ -14527,7 +14432,7 @@ class ProfileCompressor {
|
|
|
14527
14432
|
|
|
14528
14433
|
// src/modules/user-profile/profile.ts
|
|
14529
14434
|
import { readFileSync as readFileSync18, writeFileSync as writeFileSync12, existsSync as existsSync29, mkdirSync as mkdirSync13 } from "fs";
|
|
14530
|
-
import { join as
|
|
14435
|
+
import { join as join21 } from "path";
|
|
14531
14436
|
import { homedir as homedir9, hostname, platform as platform4, type } from "os";
|
|
14532
14437
|
import { env } from "process";
|
|
14533
14438
|
|
|
@@ -14554,10 +14459,10 @@ class UserProfile {
|
|
|
14554
14459
|
if (!existsSync29(this.profileDir)) {
|
|
14555
14460
|
mkdirSync13(this.profileDir, { recursive: true });
|
|
14556
14461
|
}
|
|
14557
|
-
writeFileSync12(
|
|
14462
|
+
writeFileSync12(join21(this.profileDir, "profile.json"), JSON.stringify({ ...this.info, preferences: this.preferences }, null, 2), "utf-8");
|
|
14558
14463
|
}
|
|
14559
14464
|
load() {
|
|
14560
|
-
const path =
|
|
14465
|
+
const path = join21(this.profileDir, "profile.json");
|
|
14561
14466
|
if (!existsSync29(path))
|
|
14562
14467
|
return null;
|
|
14563
14468
|
try {
|
|
@@ -14597,7 +14502,7 @@ var init_profile = () => {};
|
|
|
14597
14502
|
|
|
14598
14503
|
// src/modules/skills/loader.ts
|
|
14599
14504
|
import { readdirSync as readdirSync8, readFileSync as readFileSync19, existsSync as existsSync30, statSync as statSync5 } from "fs";
|
|
14600
|
-
import { join as
|
|
14505
|
+
import { join as join22 } from "path";
|
|
14601
14506
|
|
|
14602
14507
|
class SkillsLoader {
|
|
14603
14508
|
loadFromDir(dirPath) {
|
|
@@ -14610,7 +14515,7 @@ class SkillsLoader {
|
|
|
14610
14515
|
scanDir(dirPath, skills) {
|
|
14611
14516
|
const entries = readdirSync8(dirPath);
|
|
14612
14517
|
for (const entry of entries) {
|
|
14613
|
-
const fullPath =
|
|
14518
|
+
const fullPath = join22(dirPath, entry);
|
|
14614
14519
|
const stat = statSync5(fullPath);
|
|
14615
14520
|
if (stat.isDirectory()) {
|
|
14616
14521
|
this.scanDir(fullPath, skills);
|
|
@@ -14889,9 +14794,320 @@ var init_browser2 = __esm(() => {
|
|
|
14889
14794
|
init_types();
|
|
14890
14795
|
});
|
|
14891
14796
|
|
|
14797
|
+
// src/modules/lsp/client.ts
|
|
14798
|
+
import { spawn as spawn4, execSync as execSync4 } from "child_process";
|
|
14799
|
+
import { resolve as resolve15 } from "path";
|
|
14800
|
+
|
|
14801
|
+
class LspClient {
|
|
14802
|
+
process = null;
|
|
14803
|
+
requestId = 0;
|
|
14804
|
+
pending = new Map;
|
|
14805
|
+
buffer = "";
|
|
14806
|
+
contentLength = -1;
|
|
14807
|
+
diagnostics = [];
|
|
14808
|
+
diagnosticsResolve = null;
|
|
14809
|
+
diagnosticsTimer = null;
|
|
14810
|
+
initialized = false;
|
|
14811
|
+
async checkFile(filePath, baseDir, config) {
|
|
14812
|
+
const timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
14813
|
+
try {
|
|
14814
|
+
await this.startServer(config, baseDir);
|
|
14815
|
+
const rootUri = this.pathToUri(resolve15(baseDir));
|
|
14816
|
+
const initResult = await this.sendRequest("initialize", {
|
|
14817
|
+
processId: process.pid,
|
|
14818
|
+
rootUri,
|
|
14819
|
+
workspaceFolders: [{ uri: rootUri, name: "workspace" }],
|
|
14820
|
+
capabilities: { textDocument: { publishDiagnostics: {} } }
|
|
14821
|
+
}, timeout);
|
|
14822
|
+
this.initialized = true;
|
|
14823
|
+
this.sendNotification("initialized", {});
|
|
14824
|
+
const uri = this.pathToUri(resolve15(filePath));
|
|
14825
|
+
const fs2 = await import("fs");
|
|
14826
|
+
const content = fs2.readFileSync(filePath, "utf-8");
|
|
14827
|
+
const diagPromise = new Promise((resolve16) => {
|
|
14828
|
+
this.diagnosticsResolve = resolve16;
|
|
14829
|
+
this.diagnostics = [];
|
|
14830
|
+
this.diagnosticsTimer = setTimeout(() => {
|
|
14831
|
+
if (this.diagnosticsResolve) {
|
|
14832
|
+
this.diagnosticsResolve([]);
|
|
14833
|
+
this.diagnosticsResolve = null;
|
|
14834
|
+
}
|
|
14835
|
+
}, timeout);
|
|
14836
|
+
});
|
|
14837
|
+
this.sendNotification("textDocument/didOpen", {
|
|
14838
|
+
textDocument: {
|
|
14839
|
+
uri,
|
|
14840
|
+
languageId: this.languageFromPath(filePath),
|
|
14841
|
+
version: 1,
|
|
14842
|
+
text: content
|
|
14843
|
+
}
|
|
14844
|
+
});
|
|
14845
|
+
return await diagPromise;
|
|
14846
|
+
} catch {
|
|
14847
|
+
return [];
|
|
14848
|
+
} finally {
|
|
14849
|
+
await this.shutdown();
|
|
14850
|
+
}
|
|
14851
|
+
}
|
|
14852
|
+
async startServer(config, baseDir) {
|
|
14853
|
+
if (config.autoInstall === false) {
|
|
14854
|
+
try {
|
|
14855
|
+
execSync4(`where ${config.command}`, { stdio: "pipe", timeout: 3000 });
|
|
14856
|
+
} catch {
|
|
14857
|
+
throw new Error(`${config.command} not found in PATH`);
|
|
14858
|
+
}
|
|
14859
|
+
}
|
|
14860
|
+
return new Promise((resolve16, reject) => {
|
|
14861
|
+
const args = config.args ?? [];
|
|
14862
|
+
const proc = spawn4(config.command, args, {
|
|
14863
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
14864
|
+
env: { ...process.env, ...config.env },
|
|
14865
|
+
cwd: baseDir
|
|
14866
|
+
});
|
|
14867
|
+
proc.on("error", reject);
|
|
14868
|
+
proc.stdout.on("data", (chunk) => {
|
|
14869
|
+
this.handleData(chunk);
|
|
14870
|
+
});
|
|
14871
|
+
proc.stderr.on("data", () => {});
|
|
14872
|
+
proc.once("spawn", () => {
|
|
14873
|
+
resolve16();
|
|
14874
|
+
});
|
|
14875
|
+
this.process = proc;
|
|
14876
|
+
setTimeout(() => {
|
|
14877
|
+
if (!this.initialized && this.process) {
|
|
14878
|
+
reject(new Error("LSP server start timeout"));
|
|
14879
|
+
}
|
|
14880
|
+
}, config.timeout ?? 1e4);
|
|
14881
|
+
});
|
|
14882
|
+
}
|
|
14883
|
+
handleData(chunk) {
|
|
14884
|
+
this.buffer += chunk.toString();
|
|
14885
|
+
this.parseMessages();
|
|
14886
|
+
}
|
|
14887
|
+
parseMessages() {
|
|
14888
|
+
while (true) {
|
|
14889
|
+
if (this.contentLength === -1) {
|
|
14890
|
+
const headerEnd = this.buffer.indexOf(`\r
|
|
14891
|
+
\r
|
|
14892
|
+
`);
|
|
14893
|
+
if (headerEnd === -1)
|
|
14894
|
+
return;
|
|
14895
|
+
const header = this.buffer.slice(0, headerEnd);
|
|
14896
|
+
const match = header.match(/Content-Length: (\d+)/i);
|
|
14897
|
+
if (!match) {
|
|
14898
|
+
this.buffer = this.buffer.slice(headerEnd + 4);
|
|
14899
|
+
this.contentLength = -1;
|
|
14900
|
+
continue;
|
|
14901
|
+
}
|
|
14902
|
+
this.contentLength = parseInt(match[1], 10);
|
|
14903
|
+
this.buffer = this.buffer.slice(headerEnd + 4);
|
|
14904
|
+
}
|
|
14905
|
+
if (this.buffer.length < this.contentLength)
|
|
14906
|
+
return;
|
|
14907
|
+
const body = this.buffer.slice(0, this.contentLength);
|
|
14908
|
+
this.buffer = this.buffer.slice(this.contentLength);
|
|
14909
|
+
this.contentLength = -1;
|
|
14910
|
+
try {
|
|
14911
|
+
const msg = JSON.parse(body);
|
|
14912
|
+
this.handleMessage(msg);
|
|
14913
|
+
} catch {}
|
|
14914
|
+
}
|
|
14915
|
+
}
|
|
14916
|
+
handleMessage(msg) {
|
|
14917
|
+
if (msg.method === "textDocument/publishDiagnostics") {
|
|
14918
|
+
const params = msg.params;
|
|
14919
|
+
if (params?.diagnostics) {
|
|
14920
|
+
this.diagnostics = params.diagnostics;
|
|
14921
|
+
if (this.diagnosticsTimer) {
|
|
14922
|
+
clearTimeout(this.diagnosticsTimer);
|
|
14923
|
+
this.diagnosticsTimer = null;
|
|
14924
|
+
}
|
|
14925
|
+
if (this.diagnosticsResolve) {
|
|
14926
|
+
this.diagnosticsResolve(this.diagnostics);
|
|
14927
|
+
this.diagnosticsResolve = null;
|
|
14928
|
+
}
|
|
14929
|
+
}
|
|
14930
|
+
return;
|
|
14931
|
+
}
|
|
14932
|
+
if (msg.id !== undefined && msg.id !== null) {
|
|
14933
|
+
const pending = this.pending.get(msg.id);
|
|
14934
|
+
if (pending) {
|
|
14935
|
+
this.pending.delete(msg.id);
|
|
14936
|
+
if (msg.error) {
|
|
14937
|
+
pending.reject(new Error(String(msg.error.message ?? "LSP error")));
|
|
14938
|
+
} else {
|
|
14939
|
+
pending.resolve(msg.result);
|
|
14940
|
+
}
|
|
14941
|
+
}
|
|
14942
|
+
}
|
|
14943
|
+
}
|
|
14944
|
+
sendRequest(method, params, timeout) {
|
|
14945
|
+
return new Promise((resolve16, reject) => {
|
|
14946
|
+
const id = ++this.requestId;
|
|
14947
|
+
this.pending.set(id, { resolve: resolve16, reject });
|
|
14948
|
+
const message = JSON.stringify({ jsonrpc: "2.0", id, method, params });
|
|
14949
|
+
this.write(message);
|
|
14950
|
+
setTimeout(() => {
|
|
14951
|
+
if (this.pending.has(id)) {
|
|
14952
|
+
this.pending.delete(id);
|
|
14953
|
+
reject(new Error(`LSP request timeout: ${method}`));
|
|
14954
|
+
}
|
|
14955
|
+
}, timeout);
|
|
14956
|
+
});
|
|
14957
|
+
}
|
|
14958
|
+
sendNotification(method, params) {
|
|
14959
|
+
const message = JSON.stringify({ jsonrpc: "2.0", method, params });
|
|
14960
|
+
this.write(message);
|
|
14961
|
+
}
|
|
14962
|
+
write(message) {
|
|
14963
|
+
if (!this.process?.stdin?.writable)
|
|
14964
|
+
return;
|
|
14965
|
+
const header = `Content-Length: ${Buffer.byteLength(message)}\r
|
|
14966
|
+
\r
|
|
14967
|
+
`;
|
|
14968
|
+
try {
|
|
14969
|
+
this.process.stdin.write(header + message);
|
|
14970
|
+
} catch {}
|
|
14971
|
+
}
|
|
14972
|
+
async shutdown() {
|
|
14973
|
+
try {
|
|
14974
|
+
if (this.process && this.initialized && this.process.stdin?.writable) {
|
|
14975
|
+
this.sendRequest("shutdown", null, 3000).catch(() => {});
|
|
14976
|
+
this.sendNotification("exit", null);
|
|
14977
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
14978
|
+
}
|
|
14979
|
+
} catch {} finally {
|
|
14980
|
+
if (this.process) {
|
|
14981
|
+
try {
|
|
14982
|
+
this.process.kill();
|
|
14983
|
+
} catch {}
|
|
14984
|
+
this.process = null;
|
|
14985
|
+
}
|
|
14986
|
+
this.initialized = false;
|
|
14987
|
+
if (this.diagnosticsTimer) {
|
|
14988
|
+
clearTimeout(this.diagnosticsTimer);
|
|
14989
|
+
this.diagnosticsTimer = null;
|
|
14990
|
+
}
|
|
14991
|
+
}
|
|
14992
|
+
}
|
|
14993
|
+
pathToUri(filePath) {
|
|
14994
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
14995
|
+
if (/^[a-zA-Z]:/.test(normalized)) {
|
|
14996
|
+
return `file:///${normalized}`;
|
|
14997
|
+
}
|
|
14998
|
+
return `file://${normalized}`;
|
|
14999
|
+
}
|
|
15000
|
+
languageFromPath(filePath) {
|
|
15001
|
+
const ext = filePath.split(".").pop()?.toLowerCase();
|
|
15002
|
+
const map = {
|
|
15003
|
+
ts: "typescript",
|
|
15004
|
+
tsx: "typescriptreact",
|
|
15005
|
+
js: "javascript",
|
|
15006
|
+
jsx: "javascriptreact",
|
|
15007
|
+
py: "python",
|
|
15008
|
+
go: "go",
|
|
15009
|
+
rs: "rust",
|
|
15010
|
+
json: "json",
|
|
15011
|
+
html: "html",
|
|
15012
|
+
css: "css",
|
|
15013
|
+
scss: "scss",
|
|
15014
|
+
md: "markdown",
|
|
15015
|
+
yaml: "yaml",
|
|
15016
|
+
yml: "yaml"
|
|
15017
|
+
};
|
|
15018
|
+
return map[ext ?? ""] ?? "plaintext";
|
|
15019
|
+
}
|
|
15020
|
+
}
|
|
15021
|
+
var DEFAULT_TIMEOUT = 15000;
|
|
15022
|
+
var init_client2 = () => {};
|
|
15023
|
+
|
|
15024
|
+
// src/modules/lsp/module.ts
|
|
15025
|
+
import { existsSync as existsSync31 } from "fs";
|
|
15026
|
+
import { resolve as resolve16 } from "path";
|
|
15027
|
+
|
|
15028
|
+
class LspModule {
|
|
15029
|
+
name = "lsp";
|
|
15030
|
+
config;
|
|
15031
|
+
client = new LspClient;
|
|
15032
|
+
constructor(config) {
|
|
15033
|
+
this.config = { ...DEFAULT_LSP_CONFIG, ...config };
|
|
15034
|
+
}
|
|
15035
|
+
getPlugin() {
|
|
15036
|
+
const self = this;
|
|
15037
|
+
return {
|
|
15038
|
+
name: "lsp-check",
|
|
15039
|
+
priority: 15,
|
|
15040
|
+
onAfterTool: async (_ctx, call, result) => {
|
|
15041
|
+
if (!self.config.enabled)
|
|
15042
|
+
return;
|
|
15043
|
+
if (call.name !== "write_file" && call.name !== "edit_file")
|
|
15044
|
+
return;
|
|
15045
|
+
if (!result.success)
|
|
15046
|
+
return;
|
|
15047
|
+
const filePath = String(call.arguments.path ?? "");
|
|
15048
|
+
if (!filePath)
|
|
15049
|
+
return;
|
|
15050
|
+
const fullPath = resolve16(_ctx.baseDir, filePath);
|
|
15051
|
+
if (!existsSync31(fullPath))
|
|
15052
|
+
return;
|
|
15053
|
+
const serverConfig = getServerForFile(fullPath, self.config);
|
|
15054
|
+
if (!serverConfig)
|
|
15055
|
+
return;
|
|
15056
|
+
try {
|
|
15057
|
+
const diagnostics = await self.client.checkFile(fullPath, _ctx.baseDir, serverConfig);
|
|
15058
|
+
const errors = diagnostics.filter((d) => d.severity === 1);
|
|
15059
|
+
const warnings = diagnostics.filter((d) => d.severity === 2);
|
|
15060
|
+
if (errors.length > 0) {
|
|
15061
|
+
const items = formatDiagnostics(errors, fullPath);
|
|
15062
|
+
result.output += `
|
|
15063
|
+
|
|
15064
|
+
[LSP errors]:
|
|
15065
|
+
${items}`;
|
|
15066
|
+
}
|
|
15067
|
+
if (warnings.length > 0) {
|
|
15068
|
+
const items = formatDiagnostics(warnings, fullPath);
|
|
15069
|
+
result.output += `
|
|
15070
|
+
|
|
15071
|
+
[LSP warnings]:
|
|
15072
|
+
${items}`;
|
|
15073
|
+
}
|
|
15074
|
+
} catch {}
|
|
15075
|
+
}
|
|
15076
|
+
};
|
|
15077
|
+
}
|
|
15078
|
+
}
|
|
15079
|
+
function formatDiagnostics(diagnostics, filePath) {
|
|
15080
|
+
const filename = filePath.replace(/\\/g, "/").split("/").pop() ?? filePath;
|
|
15081
|
+
return diagnostics.slice(0, 5).map((d) => {
|
|
15082
|
+
const line = d.range.start.line + 1;
|
|
15083
|
+
const col = d.range.start.character + 1;
|
|
15084
|
+
const sev = severityLabels[d.severity] ?? "unknown";
|
|
15085
|
+
return ` ${filename}(${line},${col}): ${sev}: ${d.message}`;
|
|
15086
|
+
}).join(`
|
|
15087
|
+
`);
|
|
15088
|
+
}
|
|
15089
|
+
var severityLabels;
|
|
15090
|
+
var init_module5 = __esm(() => {
|
|
15091
|
+
init_client2();
|
|
15092
|
+
init_config();
|
|
15093
|
+
severityLabels = {
|
|
15094
|
+
1: "error",
|
|
15095
|
+
2: "warning",
|
|
15096
|
+
3: "info",
|
|
15097
|
+
4: "hint"
|
|
15098
|
+
};
|
|
15099
|
+
});
|
|
15100
|
+
|
|
15101
|
+
// src/modules/lsp/index.ts
|
|
15102
|
+
var init_lsp = __esm(() => {
|
|
15103
|
+
init_module5();
|
|
15104
|
+
init_client2();
|
|
15105
|
+
init_config();
|
|
15106
|
+
});
|
|
15107
|
+
|
|
14892
15108
|
// src/modules/indexer/walker.ts
|
|
14893
|
-
import { readdirSync as readdirSync9, readFileSync as readFileSync20, statSync as statSync6, existsSync as
|
|
14894
|
-
import { join as
|
|
15109
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync20, statSync as statSync6, existsSync as existsSync32, watch } from "fs";
|
|
15110
|
+
import { join as join23, relative, extname as extname5 } from "path";
|
|
14895
15111
|
|
|
14896
15112
|
class Indexer {
|
|
14897
15113
|
baseDir;
|
|
@@ -14918,7 +15134,7 @@ class Indexer {
|
|
|
14918
15134
|
let totalSize = 0;
|
|
14919
15135
|
let count = 0;
|
|
14920
15136
|
const walkDir = (dir) => {
|
|
14921
|
-
if (!
|
|
15137
|
+
if (!existsSync32(dir))
|
|
14922
15138
|
return;
|
|
14923
15139
|
let entries;
|
|
14924
15140
|
try {
|
|
@@ -14929,7 +15145,7 @@ class Indexer {
|
|
|
14929
15145
|
for (const entry of entries) {
|
|
14930
15146
|
if (count >= this.MAX_FILES)
|
|
14931
15147
|
return;
|
|
14932
|
-
const fullPath =
|
|
15148
|
+
const fullPath = join23(dir, entry);
|
|
14933
15149
|
const relPath = relative(this.baseDir, fullPath);
|
|
14934
15150
|
const stat = statSync6(fullPath);
|
|
14935
15151
|
if (stat.isDirectory()) {
|
|
@@ -14992,19 +15208,19 @@ var init_walker = __esm(() => {
|
|
|
14992
15208
|
});
|
|
14993
15209
|
|
|
14994
15210
|
// src/modules/indexer/cache.ts
|
|
14995
|
-
import { readFileSync as readFileSync21, writeFileSync as writeFileSync13, existsSync as
|
|
14996
|
-
import { join as
|
|
15211
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync13, existsSync as existsSync33, mkdirSync as mkdirSync14, rmSync as rmSync2 } from "fs";
|
|
15212
|
+
import { join as join24 } from "path";
|
|
14997
15213
|
|
|
14998
15214
|
class IndexCache {
|
|
14999
15215
|
cachePath;
|
|
15000
15216
|
cache = null;
|
|
15001
15217
|
constructor(cacheDir) {
|
|
15002
|
-
this.cachePath =
|
|
15218
|
+
this.cachePath = join24(cacheDir, "index-cache.json");
|
|
15003
15219
|
}
|
|
15004
15220
|
load() {
|
|
15005
15221
|
if (this.cache)
|
|
15006
15222
|
return this.cache;
|
|
15007
|
-
if (!
|
|
15223
|
+
if (!existsSync33(this.cachePath))
|
|
15008
15224
|
return null;
|
|
15009
15225
|
try {
|
|
15010
15226
|
this.cache = JSON.parse(readFileSync21(this.cachePath, "utf-8"));
|
|
@@ -15015,14 +15231,14 @@ class IndexCache {
|
|
|
15015
15231
|
}
|
|
15016
15232
|
save(result) {
|
|
15017
15233
|
this.cache = result;
|
|
15018
|
-
const dir =
|
|
15019
|
-
if (!
|
|
15234
|
+
const dir = join24(this.cachePath, "..");
|
|
15235
|
+
if (!existsSync33(dir))
|
|
15020
15236
|
mkdirSync14(dir, { recursive: true });
|
|
15021
15237
|
writeFileSync13(this.cachePath, JSON.stringify(result), "utf-8");
|
|
15022
15238
|
}
|
|
15023
15239
|
invalidate() {
|
|
15024
15240
|
this.cache = null;
|
|
15025
|
-
if (
|
|
15241
|
+
if (existsSync33(this.cachePath)) {
|
|
15026
15242
|
try {
|
|
15027
15243
|
rmSync2(this.cachePath);
|
|
15028
15244
|
} catch {}
|
|
@@ -15215,7 +15431,7 @@ ${t("indexer.and_more", { count: result.files.length - 100 })}` : "";
|
|
|
15215
15431
|
return { success: true, output, display: output };
|
|
15216
15432
|
}
|
|
15217
15433
|
}
|
|
15218
|
-
var
|
|
15434
|
+
var init_module6 = __esm(() => {
|
|
15219
15435
|
init_walker();
|
|
15220
15436
|
init_cache();
|
|
15221
15437
|
init_i18n();
|
|
@@ -15225,7 +15441,7 @@ var init_module5 = __esm(() => {
|
|
|
15225
15441
|
var init_indexer = __esm(() => {
|
|
15226
15442
|
init_walker();
|
|
15227
15443
|
init_cache();
|
|
15228
|
-
|
|
15444
|
+
init_module6();
|
|
15229
15445
|
});
|
|
15230
15446
|
|
|
15231
15447
|
// src/modules/mcp/module.ts
|
|
@@ -15368,25 +15584,25 @@ class MCPModule {
|
|
|
15368
15584
|
};
|
|
15369
15585
|
}
|
|
15370
15586
|
}
|
|
15371
|
-
var
|
|
15587
|
+
var init_module7 = __esm(() => {
|
|
15372
15588
|
init_client();
|
|
15373
15589
|
});
|
|
15374
15590
|
|
|
15375
15591
|
// src/modules/mcp/index.ts
|
|
15376
15592
|
var init_mcp = __esm(() => {
|
|
15377
15593
|
init_client();
|
|
15378
|
-
|
|
15594
|
+
init_module7();
|
|
15379
15595
|
});
|
|
15380
15596
|
|
|
15381
15597
|
// src/modules/memory/module.ts
|
|
15382
15598
|
import { homedir as homedir10 } from "os";
|
|
15383
|
-
import { join as
|
|
15599
|
+
import { join as join25 } from "path";
|
|
15384
15600
|
|
|
15385
15601
|
class MemoryModule {
|
|
15386
15602
|
name = "memory";
|
|
15387
15603
|
store;
|
|
15388
15604
|
constructor(memoryDir) {
|
|
15389
|
-
const dir = memoryDir ||
|
|
15605
|
+
const dir = memoryDir || join25(homedir10(), ".mma", "memory");
|
|
15390
15606
|
this.store = new MemoryStore(dir);
|
|
15391
15607
|
}
|
|
15392
15608
|
getSystemPromptBlock() {
|
|
@@ -15421,7 +15637,7 @@ class MemoryModule {
|
|
|
15421
15637
|
return this.store;
|
|
15422
15638
|
}
|
|
15423
15639
|
}
|
|
15424
|
-
var
|
|
15640
|
+
var init_module8 = __esm(() => {
|
|
15425
15641
|
init_store();
|
|
15426
15642
|
init_remember();
|
|
15427
15643
|
init_recall();
|
|
@@ -15433,8 +15649,8 @@ __export(exports_bootstrap, {
|
|
|
15433
15649
|
bootstrap: () => bootstrap
|
|
15434
15650
|
});
|
|
15435
15651
|
import { homedir as homedir11 } from "os";
|
|
15436
|
-
import { join as
|
|
15437
|
-
import { existsSync as
|
|
15652
|
+
import { join as join26, resolve as resolve17 } from "path";
|
|
15653
|
+
import { existsSync as existsSync34, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "fs";
|
|
15438
15654
|
function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
15439
15655
|
const now = new Date().toISOString().replace("T", " ").slice(0, 19);
|
|
15440
15656
|
const isWin = profileCompressed.toLowerCase().includes("win32");
|
|
@@ -15453,10 +15669,9 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
15453
15669
|
`- DRY: Do not duplicate code, logic, or configuration — reuse existing utilities and patterns.`
|
|
15454
15670
|
];
|
|
15455
15671
|
if (isWin) {
|
|
15456
|
-
lines.push(``, `Windows environment — use Windows-compatible commands:`, `- Use "dir" instead of "ls". Use "dir /b" for bare listing.`, `- Use "type" or "Get-Content" instead of "cat".`, `- Use "cd" instead of "pwd". Use "echo %cd%" to print working directory.`, `- Use "copy" instead of "cp", "move" instead of "mv", "del" instead of "rm".`, `- Do not use "mkdir -p" — Windows mkdir creates intermediate dirs by default. Use the create_dir tool instead.`, `- Use forward slashes (/) or escaped backslashes (\\\\) in file paths.`, `- Your working directory is: ${baseDir}`);
|
|
15672
|
+
lines.push(``, `Windows environment — use Windows-compatible commands:`, `- Use "dir" instead of "ls". Use "dir /b" for bare listing.`, `- Use "type" or "Get-Content" instead of "cat".`, `- Use "cd" instead of "pwd". Use "echo %cd%" to print working directory.`, `- Use "copy" instead of "cp", "move" instead of "mv", "del" instead of "rm".`, `- Do not use "mkdir -p" — Windows mkdir creates intermediate dirs by default. Use the create_dir tool instead.`, `- Do not use "head" or "tail" — they are Unix commands. Use "Select-Object -First N" or "Get-Content ... | Select-Object -First N" instead (PowerShell).`, `- Use forward slashes (/) or escaped backslashes (\\\\) in file paths.`, `- Your working directory is: ${baseDir}`);
|
|
15457
15673
|
}
|
|
15458
15674
|
lines.push(``, `Bash tool rules:`, `- Use the "workdir" parameter to run commands in a specific directory. Prefer workdir over "cd dir && cmd" chaining.`, `- Run one command per tool call. Split multi-step shell operations into separate bash calls.`, `- Background processes (dev servers, watchers, long-running npm install): use the "background: true" parameter or the tool will auto-detect and background them. Check output with process_log.`);
|
|
15459
|
-
lines.push(``, `Parallel tool calls:`, `- When you need to read multiple files, call read_file for ALL of them in a SINGLE response (one tool_calls array with multiple read_file calls). They will execute in parallel — much faster than reading one at a time.`, `- Example: to read 3 files, return one assistant message with 3 read_file tool_calls. Do NOT read them one by one in separate iterations.`, `- This works for: read_file, glob, grep, file_info, list_dir — any read-only operations.`, `- Do NOT parallelize write operations (write_file, edit_file, delete_file, bash) — these run sequentially.`);
|
|
15460
15675
|
lines.push(``, `=== DEVELOPMENT RULES — follow these strictly ===`, ``, `1. DEPENDENCIES FIRST: Before writing any source code, ALWAYS install project dependencies (e.g., "npm install", "pip install -r requirements.txt", "cargo build", "go mod tidy"). Verify the package manager's lock file or dependency directory exists. Never write code that imports/uses packages that aren't installed yet.`, `2. TOOLKIT/FWK FIRST: If the task specifies a framework or UI library, initialize and configure it BEFORE writing application code. Run its project init command first, then add components/modules. Never write your own version of what the framework already provides.`, `3. ONE STEP AT A TIME: Follow the plan sequentially. Complete step N before starting step N+1. When a step is done: verify the deliverables exist and have real content (not empty), then call "plan update step=N status=done". Do not redo completed work.`, `4. VERIFY YOUR WORK: After creating/modifying files, verify they exist on disk. After installing dependencies, verify the package manager completed successfully. After any command, check its output for errors. Don't assume operations succeeded.`, `5. NO PREMATURE WORK: Do not create files for future steps. Do not add imports/references to packages or modules that haven't been installed yet. Do not reference files or components that don't exist yet. Build incrementally — one layer at a time.`, `6. WHEN STUCK: If a command fails 2+ times, STOP and try a different approach. Write files directly instead of using commands. Ask the user for help. Never repeat the same failing command more than twice.`, ``, `=== PLAN QUALITY RULES — your plan MUST follow these ===`, ``, `- Each step must describe CONCRETE deliverables: exact filenames with paths, exact packages to install, exact CLI commands to run. Avoid vague steps — be specific.`, `- A step like "Настройка проекта" or "Setup the project" is too vague — describe what exactly needs to be configured or set up.`, `- A step like "Создать src/components/Header.tsx с навигацией и логотипом, добавить в src/App.tsx импорт <Header />" is GOOD.`, `- Include file extensions (.tsx, .css, .json) and directory paths. Every step must mention at least one file or command.`, `- The plan must cover EVERYTHING needed: init → deps → framework setup → code → verification.`, `- Number of steps: 5-8 for a typical task. Too few means you're being vague. Too many means you're over-splitting.`);
|
|
15461
15676
|
if (config.autoPlan) {
|
|
15462
15677
|
lines.push(``, `Plan rule (MANDATORY): For ANY task that requires creating files, installing packages, or multiple actions — you MUST create a plan using the "plan" tool BEFORE starting work. Each step must describe a concrete deliverable (specific files to create, packages to install, commands to run). Do not combine unrelated work into one step.`);
|
|
@@ -15469,8 +15684,8 @@ function buildSystemInfo(config, baseDir, profileCompressed) {
|
|
|
15469
15684
|
`);
|
|
15470
15685
|
}
|
|
15471
15686
|
async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
15472
|
-
const dir = configDir ||
|
|
15473
|
-
const projectConfigPath = projectDir ?
|
|
15687
|
+
const dir = configDir || join26(homedir11(), ".mma");
|
|
15688
|
+
const projectConfigPath = projectDir ? join26(projectDir, ".mmrc") : join26(process.cwd(), ".mmrc");
|
|
15474
15689
|
const config = loadConfig({ configDir: dir, projectConfigPath });
|
|
15475
15690
|
setLocale(config.locale);
|
|
15476
15691
|
try {
|
|
@@ -15480,7 +15695,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15480
15695
|
}
|
|
15481
15696
|
} catch {}
|
|
15482
15697
|
const logger = new Logger(config.logLevel);
|
|
15483
|
-
logger.setLogDir(
|
|
15698
|
+
logger.setLogDir(join26(dir, "logs"));
|
|
15484
15699
|
logger.debug("MMA bootstrap", {
|
|
15485
15700
|
version: config.version,
|
|
15486
15701
|
model: config.model
|
|
@@ -15502,7 +15717,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15502
15717
|
logger.info(`Model ${config.model} loaded in ${loadResult.loadTime}s`);
|
|
15503
15718
|
}
|
|
15504
15719
|
}
|
|
15505
|
-
const profile = new UserProfile(
|
|
15720
|
+
const profile = new UserProfile(join26(dir));
|
|
15506
15721
|
profile.load() || profile.collect();
|
|
15507
15722
|
profile.save();
|
|
15508
15723
|
const llmProvider = new OpenAICompatProvider({
|
|
@@ -15513,8 +15728,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15513
15728
|
retry: config.retry,
|
|
15514
15729
|
rateLimits: config.security?.rateLimits
|
|
15515
15730
|
});
|
|
15516
|
-
const baseDir = projectDir ?
|
|
15517
|
-
const projectMapCacheDir =
|
|
15731
|
+
const baseDir = projectDir ? resolve17(projectDir) : process.cwd();
|
|
15732
|
+
const projectMapCacheDir = join26(baseDir, ".mma");
|
|
15518
15733
|
const indexerModule = new IndexerModule({
|
|
15519
15734
|
baseDir,
|
|
15520
15735
|
cacheDir: projectMapCacheDir
|
|
@@ -15525,9 +15740,9 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15525
15740
|
logger.warn(`Project indexing failed: ${err.message}`);
|
|
15526
15741
|
}
|
|
15527
15742
|
const skillsLoader = new SkillsLoader;
|
|
15528
|
-
const builtinDir =
|
|
15529
|
-
const globalDir =
|
|
15530
|
-
const projectSkillsDir =
|
|
15743
|
+
const builtinDir = join26(import.meta.dirname, "skills", "builtin");
|
|
15744
|
+
const globalDir = join26(homedir11(), ".agents", "skills");
|
|
15745
|
+
const projectSkillsDir = join26(baseDir, ".mma", "skills");
|
|
15531
15746
|
const availableSkills = skillsLoader.loadFromAllSources(builtinDir, globalDir, projectSkillsDir);
|
|
15532
15747
|
const skillsMatcher = new SkillsMatcher;
|
|
15533
15748
|
const skillsBudget = Math.floor(config.contextWindow * 0.1);
|
|
@@ -15541,11 +15756,11 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15541
15756
|
essential: true,
|
|
15542
15757
|
estimatedTokens: 250
|
|
15543
15758
|
};
|
|
15544
|
-
const agentsMdGlobal =
|
|
15545
|
-
if (!
|
|
15759
|
+
const agentsMdGlobal = join26(dir, "AGENTS.md");
|
|
15760
|
+
if (!existsSync34(agentsMdGlobal)) {
|
|
15546
15761
|
writeFileSync14(agentsMdGlobal, "", "utf-8");
|
|
15547
15762
|
}
|
|
15548
|
-
const sessionDir =
|
|
15763
|
+
const sessionDir = join26(dir, "sessions");
|
|
15549
15764
|
const sessionStore = new SessionStore(sessionDir);
|
|
15550
15765
|
sessionStore.init();
|
|
15551
15766
|
const sessionManager = new SessionManager(sessionStore, {
|
|
@@ -15599,7 +15814,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15599
15814
|
const mcpModule = new MCPModule(config);
|
|
15600
15815
|
await mcpModule.initialize();
|
|
15601
15816
|
moduleRegistry.register(mcpModule);
|
|
15602
|
-
const memoryModule = new MemoryModule(
|
|
15817
|
+
const memoryModule = new MemoryModule(join26(dir, "memory"));
|
|
15603
15818
|
moduleRegistry.register(memoryModule);
|
|
15604
15819
|
if (config.browser.enabled) {
|
|
15605
15820
|
const browserModule = new BrowserModule;
|
|
@@ -15610,6 +15825,13 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15610
15825
|
pluginManager.register(browserPlugin);
|
|
15611
15826
|
}
|
|
15612
15827
|
}
|
|
15828
|
+
const lspModule = new LspModule(config.lsp);
|
|
15829
|
+
moduleRegistry.register(lspModule);
|
|
15830
|
+
const lspPlugin = lspModule.getPlugin();
|
|
15831
|
+
if (lspPlugin) {
|
|
15832
|
+
lspPlugin.isBuiltin = true;
|
|
15833
|
+
pluginManager.register(lspPlugin);
|
|
15834
|
+
}
|
|
15613
15835
|
const moduleTools = moduleRegistry.collectToolDefinitions();
|
|
15614
15836
|
for (const tool of moduleTools) {
|
|
15615
15837
|
toolRegistry.register(tool);
|
|
@@ -15642,8 +15864,8 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15642
15864
|
pluginManager.register(plugin);
|
|
15643
15865
|
pluginManager.register(plugin2);
|
|
15644
15866
|
const pluginLoader = new PluginLoader;
|
|
15645
|
-
const globalPluginsDir =
|
|
15646
|
-
const projectPluginsDir =
|
|
15867
|
+
const globalPluginsDir = join26(homedir11(), ".mma", "plugins");
|
|
15868
|
+
const projectPluginsDir = join26(dir, ".mma", "plugins");
|
|
15647
15869
|
pluginLoader.loadFromDir(globalPluginsDir, pluginManager, logger);
|
|
15648
15870
|
pluginLoader.loadFromDir(projectPluginsDir, pluginManager, logger);
|
|
15649
15871
|
contextManager.onCompact = (summary) => {
|
|
@@ -15661,12 +15883,12 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15661
15883
|
const skipAgentsMd = noAgentsMd === true;
|
|
15662
15884
|
if (!skipAgentsMd) {
|
|
15663
15885
|
const agentsMdCandidates = [
|
|
15664
|
-
|
|
15665
|
-
|
|
15666
|
-
|
|
15886
|
+
join26(baseDir, "AGENTS.md"),
|
|
15887
|
+
join26(baseDir, ".mma", "AGENTS.md"),
|
|
15888
|
+
join26(dir, "AGENTS.md")
|
|
15667
15889
|
];
|
|
15668
15890
|
for (const p of agentsMdCandidates) {
|
|
15669
|
-
if (
|
|
15891
|
+
if (existsSync34(p)) {
|
|
15670
15892
|
const content = readFileSync22(p, "utf-8").trim();
|
|
15671
15893
|
if (content) {
|
|
15672
15894
|
agentsMdBlocks.push({
|
|
@@ -15716,7 +15938,7 @@ async function bootstrap(configDir, projectDir, noAgentsMd, exitOnComplete) {
|
|
|
15716
15938
|
};
|
|
15717
15939
|
}
|
|
15718
15940
|
var init_bootstrap = __esm(() => {
|
|
15719
|
-
|
|
15941
|
+
init_config2();
|
|
15720
15942
|
init_app_logger();
|
|
15721
15943
|
init_openai_compat();
|
|
15722
15944
|
init_tools();
|
|
@@ -15732,9 +15954,10 @@ var init_bootstrap = __esm(() => {
|
|
|
15732
15954
|
init_profile();
|
|
15733
15955
|
init_skills();
|
|
15734
15956
|
init_browser2();
|
|
15957
|
+
init_lsp();
|
|
15735
15958
|
init_indexer();
|
|
15736
15959
|
init_mcp();
|
|
15737
|
-
|
|
15960
|
+
init_module8();
|
|
15738
15961
|
init_i18n();
|
|
15739
15962
|
init_agent();
|
|
15740
15963
|
});
|
|
@@ -15748,7 +15971,7 @@ function ansiRegex({ onlyFirst = false } = {}) {
|
|
|
15748
15971
|
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
15749
15972
|
}
|
|
15750
15973
|
|
|
15751
|
-
// node_modules/
|
|
15974
|
+
// node_modules/strip-ansi/index.js
|
|
15752
15975
|
function stripAnsi(string) {
|
|
15753
15976
|
if (typeof string !== "string") {
|
|
15754
15977
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
@@ -15847,65 +16070,135 @@ var init_get_east_asian_width = __esm(() => {
|
|
|
15847
16070
|
init_lookup();
|
|
15848
16071
|
});
|
|
15849
16072
|
|
|
15850
|
-
// node_modules/emoji-regex/index.js
|
|
15851
|
-
var require_emoji_regex = __commonJS((exports, module) => {
|
|
15852
|
-
module.exports = () => {
|
|
15853
|
-
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
|
15854
|
-
};
|
|
15855
|
-
});
|
|
15856
|
-
|
|
15857
16073
|
// node_modules/string-width/index.js
|
|
15858
|
-
function
|
|
15859
|
-
if (
|
|
16074
|
+
function isDoubleWidthNonRgiEmojiSequence(segment) {
|
|
16075
|
+
if (segment.length > 50) {
|
|
16076
|
+
return false;
|
|
16077
|
+
}
|
|
16078
|
+
if (unqualifiedKeycapRegex.test(segment)) {
|
|
16079
|
+
return true;
|
|
16080
|
+
}
|
|
16081
|
+
if (segment.includes("")) {
|
|
16082
|
+
const pictographics = segment.match(extendedPictographicRegex);
|
|
16083
|
+
return pictographics !== null && pictographics.length >= 2;
|
|
16084
|
+
}
|
|
16085
|
+
return false;
|
|
16086
|
+
}
|
|
16087
|
+
function baseVisible(segment) {
|
|
16088
|
+
return segment.replace(leadingNonPrintingRegex, "");
|
|
16089
|
+
}
|
|
16090
|
+
function isZeroWidthCluster(segment) {
|
|
16091
|
+
return zeroWidthClusterRegex.test(segment);
|
|
16092
|
+
}
|
|
16093
|
+
function isHangulLeadingJamo(codePoint) {
|
|
16094
|
+
return codePoint >= 4352 && codePoint <= 4447 || codePoint >= 43360 && codePoint <= 43388;
|
|
16095
|
+
}
|
|
16096
|
+
function isHangulVowelJamo(codePoint) {
|
|
16097
|
+
return codePoint >= 4448 && codePoint <= 4519 || codePoint >= 55216 && codePoint <= 55238;
|
|
16098
|
+
}
|
|
16099
|
+
function isHangulTrailingJamo(codePoint) {
|
|
16100
|
+
return codePoint >= 4520 && codePoint <= 4607 || codePoint >= 55243 && codePoint <= 55291;
|
|
16101
|
+
}
|
|
16102
|
+
function isHangulJamo(codePoint) {
|
|
16103
|
+
return isHangulLeadingJamo(codePoint) || isHangulVowelJamo(codePoint) || isHangulTrailingJamo(codePoint);
|
|
16104
|
+
}
|
|
16105
|
+
function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
|
|
16106
|
+
const codePoints = [];
|
|
16107
|
+
for (const character of visibleSegment) {
|
|
16108
|
+
if (zeroWidthClusterRegex.test(character)) {
|
|
16109
|
+
continue;
|
|
16110
|
+
}
|
|
16111
|
+
codePoints.push(character.codePointAt(0));
|
|
16112
|
+
}
|
|
16113
|
+
if (codePoints.length === 0) {
|
|
16114
|
+
return;
|
|
16115
|
+
}
|
|
16116
|
+
let width = 0;
|
|
16117
|
+
for (let index = 0;index < codePoints.length; index++) {
|
|
16118
|
+
const codePoint = codePoints[index];
|
|
16119
|
+
if (!isHangulJamo(codePoint)) {
|
|
16120
|
+
if (width === 0) {
|
|
16121
|
+
return;
|
|
16122
|
+
}
|
|
16123
|
+
for (let remaining = index;remaining < codePoints.length; remaining++) {
|
|
16124
|
+
width += eastAsianWidth(codePoints[remaining], eastAsianWidthOptions);
|
|
16125
|
+
}
|
|
16126
|
+
return width;
|
|
16127
|
+
}
|
|
16128
|
+
if (isHangulLeadingJamo(codePoint) && isHangulVowelJamo(codePoints[index + 1])) {
|
|
16129
|
+
width += 2;
|
|
16130
|
+
index += isHangulTrailingJamo(codePoints[index + 2]) ? 2 : 1;
|
|
16131
|
+
continue;
|
|
16132
|
+
}
|
|
16133
|
+
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
16134
|
+
}
|
|
16135
|
+
return width;
|
|
16136
|
+
}
|
|
16137
|
+
function trailingWidth(visibleSegment, eastAsianWidthOptions) {
|
|
16138
|
+
let extra = 0;
|
|
16139
|
+
let first = true;
|
|
16140
|
+
for (const character of visibleSegment) {
|
|
16141
|
+
if (first) {
|
|
16142
|
+
first = false;
|
|
16143
|
+
continue;
|
|
16144
|
+
}
|
|
16145
|
+
if (spacingMarkRegex.test(character) || character >= "" && character <= "") {
|
|
16146
|
+
extra += eastAsianWidth(character.codePointAt(0), eastAsianWidthOptions);
|
|
16147
|
+
}
|
|
16148
|
+
}
|
|
16149
|
+
return extra;
|
|
16150
|
+
}
|
|
16151
|
+
function stringWidth(input, options = {}) {
|
|
16152
|
+
if (typeof input !== "string" || input.length === 0) {
|
|
15860
16153
|
return 0;
|
|
15861
16154
|
}
|
|
15862
16155
|
const {
|
|
15863
16156
|
ambiguousIsNarrow = true,
|
|
15864
16157
|
countAnsiEscapeCodes = false
|
|
15865
16158
|
} = options;
|
|
15866
|
-
|
|
16159
|
+
let string = input;
|
|
16160
|
+
if (!countAnsiEscapeCodes && (string.includes("\x1B") || string.includes(""))) {
|
|
15867
16161
|
string = stripAnsi(string);
|
|
15868
16162
|
}
|
|
15869
16163
|
if (string.length === 0) {
|
|
15870
16164
|
return 0;
|
|
15871
16165
|
}
|
|
16166
|
+
if (/^[\u0020-\u007E]*$/.test(string)) {
|
|
16167
|
+
return string.length;
|
|
16168
|
+
}
|
|
15872
16169
|
let width = 0;
|
|
15873
16170
|
const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
|
|
15874
|
-
for (const { segment
|
|
15875
|
-
|
|
15876
|
-
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
|
15877
|
-
continue;
|
|
15878
|
-
}
|
|
15879
|
-
if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) {
|
|
16171
|
+
for (const { segment } of segmenter.segment(string)) {
|
|
16172
|
+
if (isZeroWidthCluster(segment)) {
|
|
15880
16173
|
continue;
|
|
15881
16174
|
}
|
|
15882
|
-
if (
|
|
15883
|
-
|
|
15884
|
-
}
|
|
15885
|
-
if (codePoint >= 55296 && codePoint <= 57343) {
|
|
15886
|
-
continue;
|
|
15887
|
-
}
|
|
15888
|
-
if (codePoint >= 65024 && codePoint <= 65039) {
|
|
15889
|
-
continue;
|
|
15890
|
-
}
|
|
15891
|
-
if (defaultIgnorableCodePointRegex.test(character)) {
|
|
16175
|
+
if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
|
|
16176
|
+
width += 2;
|
|
15892
16177
|
continue;
|
|
15893
16178
|
}
|
|
15894
|
-
|
|
15895
|
-
|
|
16179
|
+
const visibleSegment = baseVisible(segment);
|
|
16180
|
+
const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions);
|
|
16181
|
+
if (hangulWidth !== undefined) {
|
|
16182
|
+
width += hangulWidth;
|
|
15896
16183
|
continue;
|
|
15897
16184
|
}
|
|
16185
|
+
const codePoint = visibleSegment.codePointAt(0);
|
|
15898
16186
|
width += eastAsianWidth(codePoint, eastAsianWidthOptions);
|
|
16187
|
+
width += trailingWidth(visibleSegment, eastAsianWidthOptions);
|
|
15899
16188
|
}
|
|
15900
16189
|
return width;
|
|
15901
16190
|
}
|
|
15902
|
-
var
|
|
16191
|
+
var segmenter, zeroWidthClusterRegex, leadingNonPrintingRegex, spacingMarkRegex, rgiEmojiRegex, unqualifiedKeycapRegex, extendedPictographicRegex;
|
|
15903
16192
|
var init_string_width = __esm(() => {
|
|
15904
16193
|
init_strip_ansi();
|
|
15905
16194
|
init_get_east_asian_width();
|
|
15906
|
-
import_emoji_regex = __toESM(require_emoji_regex(), 1);
|
|
15907
16195
|
segmenter = new Intl.Segmenter;
|
|
15908
|
-
|
|
16196
|
+
zeroWidthClusterRegex = /^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v;
|
|
16197
|
+
leadingNonPrintingRegex = /^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v;
|
|
16198
|
+
spacingMarkRegex = /\p{Spacing_Mark}/v;
|
|
16199
|
+
rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
|
|
16200
|
+
unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
|
|
16201
|
+
extendedPictographicRegex = /\p{Extended_Pictographic}/gu;
|
|
15909
16202
|
});
|
|
15910
16203
|
|
|
15911
16204
|
// src/ui/table.ts
|
|
@@ -16213,10 +16506,10 @@ function menuList(items) {
|
|
|
16213
16506
|
console.log(l);
|
|
16214
16507
|
}
|
|
16215
16508
|
function ask(rl, question, defaultValue) {
|
|
16216
|
-
return new Promise((
|
|
16509
|
+
return new Promise((resolve18) => {
|
|
16217
16510
|
const prompt = defaultValue ? `${question} [${defaultValue}]: ` : `${question}: `;
|
|
16218
16511
|
rl.question(prompt, (answer) => {
|
|
16219
|
-
|
|
16512
|
+
resolve18(answer.trim() || defaultValue || "");
|
|
16220
16513
|
});
|
|
16221
16514
|
});
|
|
16222
16515
|
}
|
|
@@ -16435,12 +16728,12 @@ __export(exports_manifest, {
|
|
|
16435
16728
|
getCertMark: () => getCertMark,
|
|
16436
16729
|
MANIFEST_PATH: () => MANIFEST_PATH
|
|
16437
16730
|
});
|
|
16438
|
-
import { existsSync as
|
|
16731
|
+
import { existsSync as existsSync35, readFileSync as readFileSync23, mkdirSync as mkdirSync15, writeFileSync as writeFileSync15 } from "fs";
|
|
16439
16732
|
import { homedir as homedir13 } from "os";
|
|
16440
|
-
import { join as
|
|
16733
|
+
import { join as join28 } from "path";
|
|
16441
16734
|
function readManifest(path = MANIFEST_PATH) {
|
|
16442
16735
|
try {
|
|
16443
|
-
if (
|
|
16736
|
+
if (existsSync35(path)) {
|
|
16444
16737
|
const raw = JSON.parse(readFileSync23(path, "utf-8"));
|
|
16445
16738
|
return { version: 1, certifications: raw.certifications ?? [] };
|
|
16446
16739
|
}
|
|
@@ -16448,7 +16741,7 @@ function readManifest(path = MANIFEST_PATH) {
|
|
|
16448
16741
|
return { version: 1, certifications: [] };
|
|
16449
16742
|
}
|
|
16450
16743
|
function saveManifest(m, path = MANIFEST_PATH) {
|
|
16451
|
-
mkdirSync15(
|
|
16744
|
+
mkdirSync15(join28(homedir13(), ".mma"), { recursive: true });
|
|
16452
16745
|
writeFileSync15(path, JSON.stringify(m, null, 2), "utf-8");
|
|
16453
16746
|
}
|
|
16454
16747
|
function upsertCertification(entry, path = MANIFEST_PATH) {
|
|
@@ -16483,7 +16776,7 @@ function getCertMark(model, providerUrl, currentVersion, path = MANIFEST_PATH) {
|
|
|
16483
16776
|
}
|
|
16484
16777
|
var MANIFEST_PATH;
|
|
16485
16778
|
var init_manifest = __esm(() => {
|
|
16486
|
-
MANIFEST_PATH =
|
|
16779
|
+
MANIFEST_PATH = join28(homedir13(), ".mma", "certifications.json");
|
|
16487
16780
|
});
|
|
16488
16781
|
|
|
16489
16782
|
// node_modules/yaml/dist/nodes/identity.js
|
|
@@ -23606,8 +23899,8 @@ var init_scenarios = __esm(() => {
|
|
|
23606
23899
|
});
|
|
23607
23900
|
|
|
23608
23901
|
// src/modules/certification/loader.ts
|
|
23609
|
-
import { existsSync as
|
|
23610
|
-
import { join as
|
|
23902
|
+
import { existsSync as existsSync36, readdirSync as readdirSync10, readFileSync as readFileSync24 } from "fs";
|
|
23903
|
+
import { join as join29 } from "path";
|
|
23611
23904
|
function validateScenario(s) {
|
|
23612
23905
|
const errors2 = [];
|
|
23613
23906
|
const isSkip = s.mode === "skip";
|
|
@@ -23656,12 +23949,12 @@ function loadScenarios(userDir) {
|
|
|
23656
23949
|
else
|
|
23657
23950
|
scenarios.push(s);
|
|
23658
23951
|
}
|
|
23659
|
-
if (userDir &&
|
|
23952
|
+
if (userDir && existsSync36(userDir)) {
|
|
23660
23953
|
for (const file of readdirSync10(userDir)) {
|
|
23661
23954
|
if (!file.endsWith(".yaml") && !file.endsWith(".yml"))
|
|
23662
23955
|
continue;
|
|
23663
23956
|
try {
|
|
23664
|
-
const raw = readFileSync24(
|
|
23957
|
+
const raw = readFileSync24(join29(userDir, file), "utf-8");
|
|
23665
23958
|
const data = $parse(raw);
|
|
23666
23959
|
const parsed = normalizeScenario(data, file);
|
|
23667
23960
|
const errs = validateScenario(parsed);
|
|
@@ -23714,8 +24007,8 @@ var init_loader3 = __esm(() => {
|
|
|
23714
24007
|
});
|
|
23715
24008
|
|
|
23716
24009
|
// src/modules/certification/fact-checker.ts
|
|
23717
|
-
import { existsSync as
|
|
23718
|
-
import { join as
|
|
24010
|
+
import { existsSync as existsSync37, readFileSync as readFileSync25, statSync as statSync7 } from "fs";
|
|
24011
|
+
import { join as join30 } from "path";
|
|
23719
24012
|
function checkSandbox(sandboxDir, checks, exitCode, output) {
|
|
23720
24013
|
const failures = [];
|
|
23721
24014
|
for (const check of checks) {
|
|
@@ -23732,13 +24025,13 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
23732
24025
|
case "outputContains":
|
|
23733
24026
|
return output.includes(check.text);
|
|
23734
24027
|
case "fileExists":
|
|
23735
|
-
return isFile(
|
|
24028
|
+
return isFile(join30(sandboxDir, check.path));
|
|
23736
24029
|
case "fileNotExists":
|
|
23737
|
-
return !
|
|
24030
|
+
return !existsSync37(join30(sandboxDir, check.path));
|
|
23738
24031
|
case "dirExists":
|
|
23739
|
-
return isDir(
|
|
24032
|
+
return isDir(join30(sandboxDir, check.path));
|
|
23740
24033
|
case "fileContent": {
|
|
23741
|
-
const abs =
|
|
24034
|
+
const abs = join30(sandboxDir, check.path);
|
|
23742
24035
|
if (!isFile(abs))
|
|
23743
24036
|
return false;
|
|
23744
24037
|
const content = readFileSync25(abs, "utf-8");
|
|
@@ -23749,7 +24042,7 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
23749
24042
|
return false;
|
|
23750
24043
|
}
|
|
23751
24044
|
case "fileRegex": {
|
|
23752
|
-
const abs =
|
|
24045
|
+
const abs = join30(sandboxDir, check.path);
|
|
23753
24046
|
if (!isFile(abs))
|
|
23754
24047
|
return false;
|
|
23755
24048
|
return new RegExp(check.pattern).test(readFileSync25(abs, "utf-8"));
|
|
@@ -23760,14 +24053,14 @@ function runCheck(sandboxDir, check, exitCode, output) {
|
|
|
23760
24053
|
}
|
|
23761
24054
|
function isFile(p) {
|
|
23762
24055
|
try {
|
|
23763
|
-
return
|
|
24056
|
+
return existsSync37(p) && statSync7(p).isFile();
|
|
23764
24057
|
} catch {
|
|
23765
24058
|
return false;
|
|
23766
24059
|
}
|
|
23767
24060
|
}
|
|
23768
24061
|
function isDir(p) {
|
|
23769
24062
|
try {
|
|
23770
|
-
return
|
|
24063
|
+
return existsSync37(p) && statSync7(p).isDirectory();
|
|
23771
24064
|
} catch {
|
|
23772
24065
|
return false;
|
|
23773
24066
|
}
|
|
@@ -23797,10 +24090,10 @@ function describe(check) {
|
|
|
23797
24090
|
var init_fact_checker = () => {};
|
|
23798
24091
|
|
|
23799
24092
|
// src/modules/certification/runner.ts
|
|
23800
|
-
import { spawn as
|
|
23801
|
-
import { existsSync as
|
|
24093
|
+
import { spawn as spawn5 } from "child_process";
|
|
24094
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync16, rmSync as rmSync3, cpSync as cpSync2 } from "fs";
|
|
23802
24095
|
import { platform as platform5 } from "os";
|
|
23803
|
-
import { join as
|
|
24096
|
+
import { join as join31, resolve as resolve18, dirname as dirname9 } from "path";
|
|
23804
24097
|
async function runScenario(scenario, opts) {
|
|
23805
24098
|
if (scenario.mode === "skip") {
|
|
23806
24099
|
return {
|
|
@@ -23819,7 +24112,7 @@ async function runScenario(scenario, opts) {
|
|
|
23819
24112
|
let passed = 0;
|
|
23820
24113
|
let firstError;
|
|
23821
24114
|
for (let i = 1;i <= reps; i++) {
|
|
23822
|
-
const sandbox =
|
|
24115
|
+
const sandbox = join31(opts.sandboxBase, `run-${scenario.id}-${i}`);
|
|
23823
24116
|
let failures = [];
|
|
23824
24117
|
let exitCode = -1;
|
|
23825
24118
|
let output = "";
|
|
@@ -23880,28 +24173,28 @@ function prepareSandbox(sandbox, scenario, mmaRoot) {
|
|
|
23880
24173
|
rmSync3(sandbox, { recursive: true, force: true });
|
|
23881
24174
|
mkdirSync16(sandbox, { recursive: true });
|
|
23882
24175
|
for (const f of scenario.fixtures ?? []) {
|
|
23883
|
-
const src =
|
|
23884
|
-
if (!
|
|
24176
|
+
const src = join31(mmaRoot, f.source);
|
|
24177
|
+
if (!existsSync38(src)) {
|
|
23885
24178
|
throw new Error(`fixture missing: ${f.source}`);
|
|
23886
24179
|
}
|
|
23887
|
-
const dest =
|
|
24180
|
+
const dest = join31(sandbox, f.dest);
|
|
23888
24181
|
mkdirSync16(dirname9(dest), { recursive: true });
|
|
23889
24182
|
cpSync2(src, dest);
|
|
23890
24183
|
}
|
|
23891
24184
|
}
|
|
23892
24185
|
function resolveMmaEntry(mmaRoot) {
|
|
23893
|
-
const dev =
|
|
23894
|
-
if (
|
|
24186
|
+
const dev = join31(mmaRoot, "src", "cli", "main.ts");
|
|
24187
|
+
if (existsSync38(dev))
|
|
23895
24188
|
return dev;
|
|
23896
|
-
return
|
|
24189
|
+
return join31(mmaRoot, "dist", "main.js");
|
|
23897
24190
|
}
|
|
23898
24191
|
function findMmaRoot(fromDir) {
|
|
23899
24192
|
const candidates = [
|
|
23900
|
-
|
|
23901
|
-
|
|
24193
|
+
resolve18(fromDir, "..", "..", ".."),
|
|
24194
|
+
resolve18(fromDir, "..")
|
|
23902
24195
|
];
|
|
23903
24196
|
for (const c of candidates) {
|
|
23904
|
-
if (
|
|
24197
|
+
if (existsSync38(join31(c, "package.json")))
|
|
23905
24198
|
return c;
|
|
23906
24199
|
}
|
|
23907
24200
|
return process.cwd();
|
|
@@ -23911,7 +24204,7 @@ function killTree3(child) {
|
|
|
23911
24204
|
if (!pid)
|
|
23912
24205
|
return;
|
|
23913
24206
|
if (platform5() === "win32") {
|
|
23914
|
-
|
|
24207
|
+
spawn5("taskkill", ["/pid", String(pid), "/T", "/F"], {
|
|
23915
24208
|
windowsHide: true,
|
|
23916
24209
|
stdio: "ignore"
|
|
23917
24210
|
});
|
|
@@ -23926,7 +24219,7 @@ function killTree3(child) {
|
|
|
23926
24219
|
}
|
|
23927
24220
|
}
|
|
23928
24221
|
var defaultRunner = (env2, cwd, args, timeoutMs) => new Promise((resolvePromise) => {
|
|
23929
|
-
const child =
|
|
24222
|
+
const child = spawn5(process.execPath, args, {
|
|
23930
24223
|
cwd,
|
|
23931
24224
|
env: env2,
|
|
23932
24225
|
windowsHide: true,
|
|
@@ -23969,15 +24262,15 @@ __export(exports_cli, {
|
|
|
23969
24262
|
});
|
|
23970
24263
|
import { rmSync as rmSync4 } from "fs";
|
|
23971
24264
|
import { homedir as homedir14 } from "os";
|
|
23972
|
-
import { join as
|
|
24265
|
+
import { join as join32, dirname as dirname10 } from "path";
|
|
23973
24266
|
import { fileURLToPath } from "url";
|
|
23974
|
-
import { existsSync as
|
|
24267
|
+
import { existsSync as existsSync39, readFileSync as readFileSync26 } from "fs";
|
|
23975
24268
|
function readVersion() {
|
|
23976
24269
|
const candidates = [
|
|
23977
|
-
|
|
24270
|
+
join32(MMA_ROOT, "package.json")
|
|
23978
24271
|
];
|
|
23979
24272
|
for (const p of candidates) {
|
|
23980
|
-
if (
|
|
24273
|
+
if (existsSync39(p)) {
|
|
23981
24274
|
const raw = JSON.parse(readFileSync26(p, "utf-8"));
|
|
23982
24275
|
if (raw.version)
|
|
23983
24276
|
return raw.version;
|
|
@@ -24013,7 +24306,7 @@ async function certify(opts) {
|
|
|
24013
24306
|
return;
|
|
24014
24307
|
}
|
|
24015
24308
|
console.log(t("cli.cert_started", { model: opts.name, provider: providerUrl }));
|
|
24016
|
-
const sandboxBase =
|
|
24309
|
+
const sandboxBase = join32(process.cwd(), ".mma", "certification");
|
|
24017
24310
|
const results = [];
|
|
24018
24311
|
const total = selected.length;
|
|
24019
24312
|
let idx = 0;
|
|
@@ -24121,7 +24414,7 @@ var init_cli = __esm(() => {
|
|
|
24121
24414
|
init_manifest();
|
|
24122
24415
|
HERE = dirname10(fileURLToPath(import.meta.url));
|
|
24123
24416
|
MMA_ROOT = findMmaRoot(HERE);
|
|
24124
|
-
USER_SCENARIO_DIR =
|
|
24417
|
+
USER_SCENARIO_DIR = join32(homedir14(), ".mma", "certification", "scenarios");
|
|
24125
24418
|
});
|
|
24126
24419
|
|
|
24127
24420
|
// src/cli/repl-commands.ts
|
|
@@ -24130,18 +24423,18 @@ __export(exports_repl_commands, {
|
|
|
24130
24423
|
registerAllCommands: () => registerAllCommands,
|
|
24131
24424
|
COMMAND_GROUPS: () => COMMAND_GROUPS
|
|
24132
24425
|
});
|
|
24133
|
-
import { join as
|
|
24426
|
+
import { join as join34, dirname as dirname12 } from "path";
|
|
24134
24427
|
import { homedir as homedir16 } from "os";
|
|
24135
|
-
import { existsSync as
|
|
24428
|
+
import { existsSync as existsSync41, readFileSync as readFileSync28 } from "fs";
|
|
24136
24429
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
24137
24430
|
function readVersion3() {
|
|
24138
24431
|
const here = dirname12(fileURLToPath3(import.meta.url));
|
|
24139
24432
|
const candidates = [
|
|
24140
|
-
|
|
24141
|
-
|
|
24433
|
+
join34(here, "..", "..", "package.json"),
|
|
24434
|
+
join34(here, "..", "package.json")
|
|
24142
24435
|
];
|
|
24143
24436
|
for (const p of candidates) {
|
|
24144
|
-
if (
|
|
24437
|
+
if (existsSync41(p)) {
|
|
24145
24438
|
const raw = JSON.parse(readFileSync28(p, "utf8"));
|
|
24146
24439
|
if (raw.version)
|
|
24147
24440
|
return raw.version;
|
|
@@ -24205,8 +24498,8 @@ function registerMmaCommands(ctx) {
|
|
|
24205
24498
|
}
|
|
24206
24499
|
try {
|
|
24207
24500
|
const { loadFileAsDataUrl: loadFileAsDataUrl2, loadUrlAsDataUrl: loadUrlAsDataUrl2, readClipboardImage: readClipboardImage2 } = await Promise.resolve().then(() => (init_image_utils(), exports_image_utils));
|
|
24208
|
-
const { existsSync:
|
|
24209
|
-
const { resolve:
|
|
24501
|
+
const { existsSync: existsSync42 } = await import("fs");
|
|
24502
|
+
const { resolve: resolve19 } = await import("path");
|
|
24210
24503
|
let dataUrl;
|
|
24211
24504
|
let label;
|
|
24212
24505
|
if (source.toLowerCase() === "clipboard") {
|
|
@@ -24224,8 +24517,8 @@ function registerMmaCommands(ctx) {
|
|
|
24224
24517
|
dataUrl = result.dataUrl;
|
|
24225
24518
|
label = source;
|
|
24226
24519
|
} else {
|
|
24227
|
-
const absPath =
|
|
24228
|
-
if (!
|
|
24520
|
+
const absPath = resolve19(process.cwd(), source);
|
|
24521
|
+
if (!existsSync42(absPath)) {
|
|
24229
24522
|
console.log(pc.red(t("image.not_found", { path: source })));
|
|
24230
24523
|
return;
|
|
24231
24524
|
}
|
|
@@ -24304,7 +24597,7 @@ function registerMmaCommands(ctx) {
|
|
|
24304
24597
|
console.log(pc.yellow(t("repl.wizard_running")));
|
|
24305
24598
|
await ctx.withExclusiveInput(async () => {
|
|
24306
24599
|
const answers = await runSetup(ctx.rl);
|
|
24307
|
-
const configPath =
|
|
24600
|
+
const configPath = join34(homedir16(), ".mma", "config.json");
|
|
24308
24601
|
ctx.config.provider.type = answers.provider;
|
|
24309
24602
|
ctx.config.provider.baseUrl = answers.apiBase;
|
|
24310
24603
|
ctx.config.provider.apiKey = answers.apiKey;
|
|
@@ -24358,7 +24651,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
24358
24651
|
return;
|
|
24359
24652
|
}
|
|
24360
24653
|
ctx.config.provider.type = name;
|
|
24361
|
-
const configPath =
|
|
24654
|
+
const configPath = join34(homedir16(), ".mma", "config.json");
|
|
24362
24655
|
saveConfig(ctx.config, configPath);
|
|
24363
24656
|
await ctx.agent.reconfigure(ctx.config);
|
|
24364
24657
|
console.log(pc.green(t("repl.provider_set", { name })));
|
|
@@ -24414,7 +24707,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
24414
24707
|
return;
|
|
24415
24708
|
}
|
|
24416
24709
|
ctx.config.model = name;
|
|
24417
|
-
const configPath =
|
|
24710
|
+
const configPath = join34(homedir16(), ".mma", "config.json");
|
|
24418
24711
|
saveConfig(ctx.config, configPath);
|
|
24419
24712
|
await ctx.agent.reconfigure(ctx.config);
|
|
24420
24713
|
console.log(pc.green(t("repl.model_set", { name })));
|
|
@@ -24439,7 +24732,7 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
24439
24732
|
return;
|
|
24440
24733
|
}
|
|
24441
24734
|
ctx.config.contextWindow = size;
|
|
24442
|
-
const configPath =
|
|
24735
|
+
const configPath = join34(homedir16(), ".mma", "config.json");
|
|
24443
24736
|
saveConfig(ctx.config, configPath);
|
|
24444
24737
|
await ctx.agent.reconfigure(ctx.config);
|
|
24445
24738
|
console.log(pc.green(t("cli.context_set", { size })));
|
|
@@ -24456,11 +24749,11 @@ Excluded blocks: ${info.excluded.length}`));
|
|
|
24456
24749
|
if (active) {}
|
|
24457
24750
|
}
|
|
24458
24751
|
ctx.agent.shutdown();
|
|
24459
|
-
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (
|
|
24752
|
+
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_config2(), exports_config));
|
|
24460
24753
|
const { homedir: homedir17 } = await import("os");
|
|
24461
|
-
const { join:
|
|
24462
|
-
const configDir =
|
|
24463
|
-
const projectConfigPath =
|
|
24754
|
+
const { join: join35 } = await import("path");
|
|
24755
|
+
const configDir = join35(homedir17(), ".mma");
|
|
24756
|
+
const projectConfigPath = join35(process.cwd(), ".mmrc");
|
|
24464
24757
|
const freshConfig = loadConfig2({ configDir, projectConfigPath });
|
|
24465
24758
|
Object.assign(ctx.config, freshConfig);
|
|
24466
24759
|
const { bootstrap: bootstrap2 } = await Promise.resolve().then(() => (init_bootstrap(), exports_bootstrap));
|
|
@@ -24713,7 +25006,7 @@ var init_repl_commands = __esm(() => {
|
|
|
24713
25006
|
init_table();
|
|
24714
25007
|
init_i18n();
|
|
24715
25008
|
init_setup();
|
|
24716
|
-
|
|
25009
|
+
init_config2();
|
|
24717
25010
|
version2 = readVersion3();
|
|
24718
25011
|
COMMAND_GROUPS = {
|
|
24719
25012
|
help: "general",
|
|
@@ -24757,17 +25050,17 @@ var {
|
|
|
24757
25050
|
|
|
24758
25051
|
// src/cli/commands.ts
|
|
24759
25052
|
init_bootstrap();
|
|
24760
|
-
|
|
25053
|
+
init_config2();
|
|
24761
25054
|
init_setup();
|
|
24762
25055
|
init_i18n();
|
|
24763
|
-
import { join as
|
|
25056
|
+
import { join as join33, dirname as dirname11 } from "path";
|
|
24764
25057
|
import { homedir as homedir15 } from "os";
|
|
24765
|
-
import { existsSync as
|
|
25058
|
+
import { existsSync as existsSync40, readFileSync as readFileSync27 } from "fs";
|
|
24766
25059
|
|
|
24767
25060
|
// src/cli/security-commands.ts
|
|
24768
25061
|
init_bootstrap();
|
|
24769
|
-
|
|
24770
|
-
import { join as
|
|
25062
|
+
init_config2();
|
|
25063
|
+
import { join as join27 } from "path";
|
|
24771
25064
|
import { homedir as homedir12 } from "os";
|
|
24772
25065
|
|
|
24773
25066
|
// src/modules/security/security-policies.ts
|
|
@@ -25297,7 +25590,7 @@ function createSecurityCommand(program2) {
|
|
|
25297
25590
|
}
|
|
25298
25591
|
});
|
|
25299
25592
|
securityCmd.command("set-policy").argument("<preset>", t("cli.security.preset")).description(t("cli.security.set_policy")).action(async (preset) => {
|
|
25300
|
-
const configPath =
|
|
25593
|
+
const configPath = join27(homedir12(), ".mma", "config.json");
|
|
25301
25594
|
const { config: appConfig } = await bootstrap();
|
|
25302
25595
|
const validPresets = ["strict", "balanced", "permissive"];
|
|
25303
25596
|
if (!validPresets.includes(preset)) {
|
|
@@ -25312,7 +25605,7 @@ function createSecurityCommand(program2) {
|
|
|
25312
25605
|
console.log(t("cli.security.policy_description", { description: policy.description }));
|
|
25313
25606
|
});
|
|
25314
25607
|
securityCmd.command("enable-encryption").description(t("cli.security.enable_encryption")).action(async () => {
|
|
25315
|
-
const configPath =
|
|
25608
|
+
const configPath = join27(homedir12(), ".mma", "config.json");
|
|
25316
25609
|
const { config: appConfig } = await bootstrap();
|
|
25317
25610
|
appConfig.security = appConfig.security || {};
|
|
25318
25611
|
appConfig.security.sessionEncryption = {
|
|
@@ -25324,7 +25617,7 @@ function createSecurityCommand(program2) {
|
|
|
25324
25617
|
console.log(t("cli.security.encryption_enabled"));
|
|
25325
25618
|
});
|
|
25326
25619
|
securityCmd.command("disable-encryption").description(t("cli.security.disable_encryption")).action(async () => {
|
|
25327
|
-
const configPath =
|
|
25620
|
+
const configPath = join27(homedir12(), ".mma", "config.json");
|
|
25328
25621
|
const { config: appConfig } = await bootstrap();
|
|
25329
25622
|
appConfig.security = appConfig.security || {};
|
|
25330
25623
|
appConfig.security.sessionEncryption = {
|
|
@@ -25336,7 +25629,7 @@ function createSecurityCommand(program2) {
|
|
|
25336
25629
|
console.log(t("cli.security.encryption_disabled"));
|
|
25337
25630
|
});
|
|
25338
25631
|
securityCmd.command("enable-audit").description(t("cli.security.enable_audit")).action(async () => {
|
|
25339
|
-
const configPath =
|
|
25632
|
+
const configPath = join27(homedir12(), ".mma", "config.json");
|
|
25340
25633
|
const { config: appConfig } = await bootstrap();
|
|
25341
25634
|
appConfig.security = appConfig.security || {};
|
|
25342
25635
|
appConfig.security.auditNotifier = {
|
|
@@ -25350,7 +25643,7 @@ function createSecurityCommand(program2) {
|
|
|
25350
25643
|
console.log(t("cli.security.audit_enabled"));
|
|
25351
25644
|
});
|
|
25352
25645
|
securityCmd.command("disable-audit").description(t("cli.security.disable_audit")).action(async () => {
|
|
25353
|
-
const configPath =
|
|
25646
|
+
const configPath = join27(homedir12(), ".mma", "config.json");
|
|
25354
25647
|
const { config: appConfig } = await bootstrap();
|
|
25355
25648
|
appConfig.security = appConfig.security || {};
|
|
25356
25649
|
appConfig.security.auditNotifier = {
|
|
@@ -25386,11 +25679,11 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
25386
25679
|
function readVersion2() {
|
|
25387
25680
|
const here = dirname11(fileURLToPath2(import.meta.url));
|
|
25388
25681
|
const candidates = [
|
|
25389
|
-
|
|
25390
|
-
|
|
25682
|
+
join33(here, "..", "..", "package.json"),
|
|
25683
|
+
join33(here, "..", "package.json")
|
|
25391
25684
|
];
|
|
25392
25685
|
for (const p of candidates) {
|
|
25393
|
-
if (
|
|
25686
|
+
if (existsSync40(p)) {
|
|
25394
25687
|
const raw = JSON.parse(readFileSync27(p, "utf8"));
|
|
25395
25688
|
if (raw.version)
|
|
25396
25689
|
return raw.version;
|
|
@@ -25403,7 +25696,7 @@ function createProgram() {
|
|
|
25403
25696
|
const program2 = new Command().name("mma").description(t("cli.description")).version(version).option("--no-agents-md", t("cli.no_agents_md")).option("-d, --dir <path>", t("cli.dir")).option("-e, --exit-on-complete", t("cli.exit_on_complete")).option("-j, --json", t("cli.json"));
|
|
25404
25697
|
program2.command("init").description(t("cli.init")).action(async () => {
|
|
25405
25698
|
const answers = await runSetup();
|
|
25406
|
-
const configPath =
|
|
25699
|
+
const configPath = join33(homedir15(), ".mma", "config.json");
|
|
25407
25700
|
const { config } = await bootstrap();
|
|
25408
25701
|
config.provider.type = answers.provider;
|
|
25409
25702
|
config.provider.baseUrl = answers.apiBase;
|
|
@@ -25448,7 +25741,7 @@ function createProgram() {
|
|
|
25448
25741
|
});
|
|
25449
25742
|
const configCmd = program2.command("config").description(t("cli.manage_config"));
|
|
25450
25743
|
configCmd.command("set").argument("<key>", t("cli.config_key")).argument("<value>", "Config value").description(t("cli.set_value")).action(async (key, value) => {
|
|
25451
|
-
const configPath =
|
|
25744
|
+
const configPath = join33(homedir15(), ".mma", "config.json");
|
|
25452
25745
|
const { config } = await bootstrap();
|
|
25453
25746
|
const keys = key.split(".");
|
|
25454
25747
|
let obj = config;
|
|
@@ -25511,7 +25804,7 @@ function createProgram() {
|
|
|
25511
25804
|
console.log(t("cli.model_hint"));
|
|
25512
25805
|
});
|
|
25513
25806
|
model.command("use").argument("<name>", "Model name").description(t("cli.set_model")).action(async (name) => {
|
|
25514
|
-
const configPath =
|
|
25807
|
+
const configPath = join33(homedir15(), ".mma", "config.json");
|
|
25515
25808
|
const { config } = await bootstrap();
|
|
25516
25809
|
config.model = name;
|
|
25517
25810
|
saveConfig(config, configPath);
|
|
@@ -25547,7 +25840,7 @@ function createProgram() {
|
|
|
25547
25840
|
await uncertify2(name, config);
|
|
25548
25841
|
});
|
|
25549
25842
|
program2.command("context").description(t("cli.manage_context")).argument("<size>", "Context window size in tokens").action(async (size) => {
|
|
25550
|
-
const configPath =
|
|
25843
|
+
const configPath = join33(homedir15(), ".mma", "config.json");
|
|
25551
25844
|
const { config } = await bootstrap();
|
|
25552
25845
|
const contextWindow = parseInt(size, 10);
|
|
25553
25846
|
if (isNaN(contextWindow) || contextWindow < 1024) {
|
|
@@ -25565,7 +25858,7 @@ function createProgram() {
|
|
|
25565
25858
|
console.log(t("cli.base_url"), config.provider.baseUrl);
|
|
25566
25859
|
});
|
|
25567
25860
|
provider.command("use").argument("<name>", "Provider name").description(t("cli.set_provider")).action(async (name) => {
|
|
25568
|
-
const configPath =
|
|
25861
|
+
const configPath = join33(homedir15(), ".mma", "config.json");
|
|
25569
25862
|
const { config } = await bootstrap();
|
|
25570
25863
|
config.provider.type = name;
|
|
25571
25864
|
saveConfig(config, configPath);
|
|
@@ -25617,8 +25910,8 @@ init_bootstrap();
|
|
|
25617
25910
|
// src/cli/repl.ts
|
|
25618
25911
|
init_colors();
|
|
25619
25912
|
import * as readline2 from "readline";
|
|
25620
|
-
import { existsSync as
|
|
25621
|
-
import { join as
|
|
25913
|
+
import { existsSync as existsSync42, readFileSync as readFileSync29, writeFileSync as writeFileSync16 } from "fs";
|
|
25914
|
+
import { join as join35, dirname as dirname13 } from "path";
|
|
25622
25915
|
import { homedir as homedir17 } from "os";
|
|
25623
25916
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
25624
25917
|
|
|
@@ -25728,7 +26021,6 @@ init_colors();
|
|
|
25728
26021
|
init_colors();
|
|
25729
26022
|
init_i18n();
|
|
25730
26023
|
init_table();
|
|
25731
|
-
init_string_width();
|
|
25732
26024
|
var KW = /\b(import|export|from|const|let|var|function|return|if|else|for|while|do|switch|case|break|continue|new|class|extends|implements|interface|type|enum|namespace|module|declare|abstract|async|await|yield|throw|try|catch|finally|typeof|instanceof|in|of|as|is|keyof|readonly|static|private|public|protected|get|set|constructor|this|super|void|never|any|unknown|boolean|string|number|symbol|object|true|false|null|undefined|default)\b/g;
|
|
25733
26025
|
var STRING = /('[^']*'|"[^"]*"|`[^`]*`)/g;
|
|
25734
26026
|
var COMMENT = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|#[^\n]*)/g;
|
|
@@ -25777,13 +26069,9 @@ class FormattingStream {
|
|
|
25777
26069
|
tableBuffer = [];
|
|
25778
26070
|
onWrite;
|
|
25779
26071
|
width;
|
|
25780
|
-
|
|
25781
|
-
partialEmitted = false;
|
|
25782
|
-
lastPartial = "";
|
|
25783
|
-
constructor(onWrite, width, streaming = false) {
|
|
26072
|
+
constructor(onWrite, width) {
|
|
25784
26073
|
this.onWrite = onWrite;
|
|
25785
26074
|
this.width = width ?? getTerminalWidth();
|
|
25786
|
-
this.streaming = streaming;
|
|
25787
26075
|
}
|
|
25788
26076
|
write(chunk) {
|
|
25789
26077
|
this.buffer += chunk;
|
|
@@ -25792,13 +26080,10 @@ class FormattingStream {
|
|
|
25792
26080
|
`)) !== -1) {
|
|
25793
26081
|
const line = this.buffer.slice(0, idx);
|
|
25794
26082
|
this.buffer = this.buffer.slice(idx + 1);
|
|
25795
|
-
this.clearPartial();
|
|
25796
26083
|
this.processLine(line);
|
|
25797
26084
|
}
|
|
25798
|
-
this.emitPartial(this.buffer);
|
|
25799
26085
|
}
|
|
25800
26086
|
flush() {
|
|
25801
|
-
this.clearPartial();
|
|
25802
26087
|
if (this.inCodeBlock && this.codeLines.length > 0) {
|
|
25803
26088
|
this.emitCodeBlock();
|
|
25804
26089
|
}
|
|
@@ -25814,39 +26099,8 @@ class FormattingStream {
|
|
|
25814
26099
|
}
|
|
25815
26100
|
return;
|
|
25816
26101
|
}
|
|
25817
|
-
this.
|
|
25818
|
-
}
|
|
25819
|
-
}
|
|
25820
|
-
emitLine(text) {
|
|
25821
|
-
this.onWrite(text, true);
|
|
25822
|
-
}
|
|
25823
|
-
emitRaw(text) {
|
|
25824
|
-
this.onWrite(text, false);
|
|
25825
|
-
}
|
|
25826
|
-
clearPartial() {
|
|
25827
|
-
if (!this.streaming || !this.partialEmitted)
|
|
25828
|
-
return;
|
|
25829
|
-
const rows = Math.max(1, Math.ceil(stringWidth(this.lastPartial) / Math.max(1, this.width)));
|
|
25830
|
-
for (let i = 0;i < rows; i++) {
|
|
25831
|
-
this.emitRaw("\x1B[2K");
|
|
25832
|
-
if (i < rows - 1)
|
|
25833
|
-
this.emitRaw("\x1B[1A");
|
|
25834
|
-
}
|
|
25835
|
-
this.emitRaw("\r");
|
|
25836
|
-
this.lastPartial = "";
|
|
25837
|
-
this.partialEmitted = false;
|
|
25838
|
-
}
|
|
25839
|
-
emitPartial(text) {
|
|
25840
|
-
if (!this.streaming || !text)
|
|
25841
|
-
return;
|
|
25842
|
-
if (this.inCodeBlock || this.tableBuffer.length > 0) {
|
|
25843
|
-
this.clearPartial();
|
|
25844
|
-
return;
|
|
26102
|
+
this.onWrite(this.formatLine(line));
|
|
25845
26103
|
}
|
|
25846
|
-
this.clearPartial();
|
|
25847
|
-
this.emitRaw(text);
|
|
25848
|
-
this.lastPartial = text;
|
|
25849
|
-
this.partialEmitted = true;
|
|
25850
26104
|
}
|
|
25851
26105
|
processLine(line) {
|
|
25852
26106
|
if (line.trim() === "```" || line.trim().startsWith("```")) {
|
|
@@ -25870,7 +26124,7 @@ class FormattingStream {
|
|
|
25870
26124
|
if (this.tableBuffer.length > 0) {
|
|
25871
26125
|
this.flushTable();
|
|
25872
26126
|
}
|
|
25873
|
-
this.
|
|
26127
|
+
this.onWrite(this.formatLine(line));
|
|
25874
26128
|
}
|
|
25875
26129
|
flushTable() {
|
|
25876
26130
|
const lines = this.tableBuffer;
|
|
@@ -25878,11 +26132,11 @@ class FormattingStream {
|
|
|
25878
26132
|
const hasSeparator = lines.length >= 2 && /^\s*\|?[\s:|-]+\|?\s*$/.test(lines[1].trim());
|
|
25879
26133
|
if (hasSeparator) {
|
|
25880
26134
|
for (const l of formatTable(lines, { maxWidth: this.width })) {
|
|
25881
|
-
this.
|
|
26135
|
+
this.onWrite(l);
|
|
25882
26136
|
}
|
|
25883
26137
|
} else {
|
|
25884
26138
|
for (const l of lines) {
|
|
25885
|
-
this.
|
|
26139
|
+
this.onWrite(this.formatLine(l));
|
|
25886
26140
|
}
|
|
25887
26141
|
}
|
|
25888
26142
|
}
|
|
@@ -25894,12 +26148,12 @@ class FormattingStream {
|
|
|
25894
26148
|
const highlighted = highlight(code, this.codeLang);
|
|
25895
26149
|
const lang = this.codeLang ? ` ${this.codeLang} ` : " ";
|
|
25896
26150
|
const top = pc.dim(`┌─${lang}${"─".repeat(Math.max(0, this.width - 3 - lang.length))}┐`);
|
|
25897
|
-
this.
|
|
26151
|
+
this.onWrite(top);
|
|
25898
26152
|
for (const l of highlighted.split(`
|
|
25899
26153
|
`)) {
|
|
25900
|
-
this.
|
|
26154
|
+
this.onWrite(pc.dim("│ ") + l);
|
|
25901
26155
|
}
|
|
25902
|
-
this.
|
|
26156
|
+
this.onWrite(pc.dim(`└${"─".repeat(Math.max(0, this.width - 1))}┘`));
|
|
25903
26157
|
}
|
|
25904
26158
|
this.codeLines = [];
|
|
25905
26159
|
this.codeLang = "";
|
|
@@ -26011,8 +26265,8 @@ class Renderer {
|
|
|
26011
26265
|
stream: this.err,
|
|
26012
26266
|
width: this.width
|
|
26013
26267
|
});
|
|
26014
|
-
this.fmt = new FormattingStream((line
|
|
26015
|
-
`
|
|
26268
|
+
this.fmt = new FormattingStream((line) => this.out.write(`${line}
|
|
26269
|
+
`), this.width);
|
|
26016
26270
|
}
|
|
26017
26271
|
text(chunk) {
|
|
26018
26272
|
this.endCard();
|
|
@@ -26021,7 +26275,6 @@ class Renderer {
|
|
|
26021
26275
|
}
|
|
26022
26276
|
meta(chunk) {
|
|
26023
26277
|
this.spinner.stop();
|
|
26024
|
-
this.fmt.clearPartial();
|
|
26025
26278
|
if (this.card) {
|
|
26026
26279
|
this.card.body.push(chunk);
|
|
26027
26280
|
} else {
|
|
@@ -26030,7 +26283,6 @@ class Renderer {
|
|
|
26030
26283
|
}
|
|
26031
26284
|
reasoning(chunk) {
|
|
26032
26285
|
this.spinner.stop();
|
|
26033
|
-
this.fmt.clearPartial();
|
|
26034
26286
|
this.out.write(pc.dim(chunk));
|
|
26035
26287
|
}
|
|
26036
26288
|
thinkingStart() {
|
|
@@ -26042,7 +26294,6 @@ class Renderer {
|
|
|
26042
26294
|
toolStart(tool, args) {
|
|
26043
26295
|
this.endCard();
|
|
26044
26296
|
this.spinner.stop();
|
|
26045
|
-
this.fmt.clearPartial();
|
|
26046
26297
|
const summary = summarizeArgs2(args);
|
|
26047
26298
|
if (!this.rich) {
|
|
26048
26299
|
this.out.write(`
|
|
@@ -26094,13 +26345,11 @@ ${pc.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}
|
|
|
26094
26345
|
raw(text) {
|
|
26095
26346
|
this.endCard();
|
|
26096
26347
|
this.spinner.stop();
|
|
26097
|
-
this.fmt.clearPartial();
|
|
26098
26348
|
this.out.write(text);
|
|
26099
26349
|
}
|
|
26100
26350
|
error(text) {
|
|
26101
26351
|
this.endCard();
|
|
26102
26352
|
this.spinner.stop();
|
|
26103
|
-
this.fmt.clearPartial();
|
|
26104
26353
|
this.err.write(`${pc.red(text)}
|
|
26105
26354
|
`);
|
|
26106
26355
|
}
|
|
@@ -26124,11 +26373,11 @@ init_repl_commands();
|
|
|
26124
26373
|
function readVersion4() {
|
|
26125
26374
|
const here = dirname13(fileURLToPath4(import.meta.url));
|
|
26126
26375
|
const candidates = [
|
|
26127
|
-
|
|
26128
|
-
|
|
26376
|
+
join35(here, "..", "..", "package.json"),
|
|
26377
|
+
join35(here, "..", "package.json")
|
|
26129
26378
|
];
|
|
26130
26379
|
for (const p of candidates) {
|
|
26131
|
-
if (
|
|
26380
|
+
if (existsSync42(p)) {
|
|
26132
26381
|
const raw = JSON.parse(readFileSync29(p, "utf8"));
|
|
26133
26382
|
if (raw.version)
|
|
26134
26383
|
return raw.version;
|
|
@@ -26180,10 +26429,10 @@ class Repl {
|
|
|
26180
26429
|
this.sessionManager = sessionManager;
|
|
26181
26430
|
this.skillsModule = skillsModule;
|
|
26182
26431
|
this.pluginManager = pluginManager;
|
|
26183
|
-
this.configDir = configDir ||
|
|
26432
|
+
this.configDir = configDir || join35(homedir17(), ".mma");
|
|
26184
26433
|
this.baseDir = baseDir || process.cwd();
|
|
26185
26434
|
this.noAgentsMd = noAgentsMd === true;
|
|
26186
|
-
this.historyPath =
|
|
26435
|
+
this.historyPath = join35(homedir17(), ".mma", "repl-history");
|
|
26187
26436
|
this.loadHistory();
|
|
26188
26437
|
this.rl = readline2.createInterface({
|
|
26189
26438
|
input: process.stdin,
|
|
@@ -26204,7 +26453,7 @@ class Repl {
|
|
|
26204
26453
|
this.setupListeners();
|
|
26205
26454
|
}
|
|
26206
26455
|
loadHistory() {
|
|
26207
|
-
if (
|
|
26456
|
+
if (existsSync42(this.historyPath)) {
|
|
26208
26457
|
try {
|
|
26209
26458
|
const raw = readFileSync29(this.historyPath, "utf-8");
|
|
26210
26459
|
this.history = raw.split(`
|
|
@@ -26304,8 +26553,9 @@ class Repl {
|
|
|
26304
26553
|
this.running = false;
|
|
26305
26554
|
});
|
|
26306
26555
|
if (process.stdin.isTTY) {
|
|
26307
|
-
process.stdin
|
|
26308
|
-
|
|
26556
|
+
readline2.emitKeypressEvents(process.stdin);
|
|
26557
|
+
process.stdin.on("keypress", async (str, key) => {
|
|
26558
|
+
if (key.name === "escape") {
|
|
26309
26559
|
const now = Date.now();
|
|
26310
26560
|
if (now - this.lastEscTime < this.doubleEscDelay) {
|
|
26311
26561
|
if (this.agentRunning) {
|
|
@@ -26319,8 +26569,19 @@ ${t("repl.interrupt")}
|
|
|
26319
26569
|
}
|
|
26320
26570
|
this.lastEscTime = now;
|
|
26321
26571
|
}
|
|
26322
|
-
if (
|
|
26323
|
-
|
|
26572
|
+
if (key.ctrl && key.name === "v" && !this.agentRunning) {
|
|
26573
|
+
try {
|
|
26574
|
+
const { readClipboardImage: readClipboardImage2, bufferToDataUrl: bufferToDataUrl2 } = await Promise.resolve().then(() => (init_image_utils(), exports_image_utils));
|
|
26575
|
+
const clipBuf = await readClipboardImage2();
|
|
26576
|
+
if (clipBuf) {
|
|
26577
|
+
const { dataUrl } = await bufferToDataUrl2(clipBuf);
|
|
26578
|
+
this.pendingClipboardImage = dataUrl;
|
|
26579
|
+
const sizeKb = Math.round(dataUrl.length * 3 / 4 / 1024);
|
|
26580
|
+
console.log(pc.green(`
|
|
26581
|
+
${t("image.attached", { source: "clipboard", size: `${sizeKb} KB` })}`));
|
|
26582
|
+
this.rl.prompt();
|
|
26583
|
+
}
|
|
26584
|
+
} catch {}
|
|
26324
26585
|
}
|
|
26325
26586
|
});
|
|
26326
26587
|
}
|
|
@@ -26336,20 +26597,6 @@ ${t("repl.interrupt")}
|
|
|
26336
26597
|
}
|
|
26337
26598
|
});
|
|
26338
26599
|
}
|
|
26339
|
-
async handlePasteImage() {
|
|
26340
|
-
try {
|
|
26341
|
-
const { readClipboardImage: readClipboardImage2, bufferToDataUrl: bufferToDataUrl2 } = await Promise.resolve().then(() => (init_image_utils(), exports_image_utils));
|
|
26342
|
-
const clipBuf = await readClipboardImage2();
|
|
26343
|
-
if (clipBuf) {
|
|
26344
|
-
const { dataUrl } = await bufferToDataUrl2(clipBuf);
|
|
26345
|
-
this.pendingClipboardImage = dataUrl;
|
|
26346
|
-
const sizeKb = Math.round(dataUrl.length * 3 / 4 / 1024);
|
|
26347
|
-
console.log(pc.green(`
|
|
26348
|
-
${t("image.attached", { source: "clipboard", size: `${sizeKb} KB` })}`));
|
|
26349
|
-
this.rl.prompt();
|
|
26350
|
-
}
|
|
26351
|
-
} catch {}
|
|
26352
|
-
}
|
|
26353
26600
|
isMultiLineInput(line) {
|
|
26354
26601
|
if (line.endsWith("\\"))
|
|
26355
26602
|
return true;
|
|
@@ -26516,11 +26763,11 @@ ${t("image.attached", { source: "clipboard", size: `${sizeKb} KB` })}`));
|
|
|
26516
26763
|
row(t("repl.agents_label"), pc.red(t("repl.disabled")));
|
|
26517
26764
|
} else {
|
|
26518
26765
|
const agentsMdCandidates = [
|
|
26519
|
-
|
|
26520
|
-
|
|
26521
|
-
|
|
26766
|
+
join35(this.baseDir, "AGENTS.md"),
|
|
26767
|
+
join35(this.baseDir, ".mma", "AGENTS.md"),
|
|
26768
|
+
join35(this.configDir, "AGENTS.md")
|
|
26522
26769
|
];
|
|
26523
|
-
const foundAgents = agentsMdCandidates.filter((p) =>
|
|
26770
|
+
const foundAgents = agentsMdCandidates.filter((p) => existsSync42(p));
|
|
26524
26771
|
if (foundAgents.length > 0) {
|
|
26525
26772
|
for (const p of foundAgents) {
|
|
26526
26773
|
row(t("repl.agents_label"), pc.dim(p));
|
|
@@ -26531,7 +26778,7 @@ ${t("image.attached", { source: "clipboard", size: `${sizeKb} KB` })}`));
|
|
|
26531
26778
|
}
|
|
26532
26779
|
const meta = this.sessionManager?.getActiveMeta();
|
|
26533
26780
|
if (meta) {
|
|
26534
|
-
const sessionPath =
|
|
26781
|
+
const sessionPath = join35(this.configDir, "sessions", meta.id);
|
|
26535
26782
|
row(t("repl.session_label"), `${pc.cyan(meta.name)} ${pc.dim(`(${meta.id.slice(0, 12)})`)} — ${meta.messageCount} msgs ${pc.dim(sessionPath)}`);
|
|
26536
26783
|
}
|
|
26537
26784
|
const headerWidth = Math.max(50, Math.min(96, process.stdout.columns || 96));
|
|
@@ -26554,11 +26801,11 @@ ${t("image.attached", { source: "clipboard", size: `${sizeKb} KB` })}`));
|
|
|
26554
26801
|
|
|
26555
26802
|
// src/cli/main.ts
|
|
26556
26803
|
init_setup();
|
|
26557
|
-
|
|
26804
|
+
init_config2();
|
|
26558
26805
|
init_i18n();
|
|
26559
26806
|
init_colors();
|
|
26560
|
-
import { existsSync as
|
|
26561
|
-
import { join as
|
|
26807
|
+
import { existsSync as existsSync43 } from "fs";
|
|
26808
|
+
import { join as join36 } from "path";
|
|
26562
26809
|
import { homedir as homedir18 } from "os";
|
|
26563
26810
|
async function main() {
|
|
26564
26811
|
const program2 = createProgram();
|
|
@@ -26622,8 +26869,8 @@ async function main() {
|
|
|
26622
26869
|
}
|
|
26623
26870
|
agent.shutdown();
|
|
26624
26871
|
} else {
|
|
26625
|
-
const configPath =
|
|
26626
|
-
if (!
|
|
26872
|
+
const configPath = join36(homedir18(), ".mma", "config.json");
|
|
26873
|
+
if (!existsSync43(configPath)) {
|
|
26627
26874
|
console.log(pc.yellow(`
|
|
26628
26875
|
` + t("cli.first_run") + `
|
|
26629
26876
|
`));
|