micro-models-agent 0.40.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +142 -28
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2072,11 +2072,14 @@ var init_security = __esm(() => {
|
|
|
2072
2072
|
});
|
|
2073
2073
|
|
|
2074
2074
|
// src/modules/lsp/config.ts
|
|
2075
|
-
function
|
|
2075
|
+
function getLanguageForFile(filePath) {
|
|
2076
2076
|
const ext = filePath.split(".").pop()?.toLowerCase();
|
|
2077
2077
|
if (!ext)
|
|
2078
2078
|
return null;
|
|
2079
|
-
|
|
2079
|
+
return LANGUAGE_MAP[ext] ?? null;
|
|
2080
|
+
}
|
|
2081
|
+
function getServerForFile(filePath, config) {
|
|
2082
|
+
const lang = getLanguageForFile(filePath);
|
|
2080
2083
|
if (!lang)
|
|
2081
2084
|
return null;
|
|
2082
2085
|
return config.servers[lang] ?? null;
|
|
@@ -2122,22 +2125,40 @@ var init_config = __esm(() => {
|
|
|
2122
2125
|
},
|
|
2123
2126
|
json: {
|
|
2124
2127
|
command: "npx",
|
|
2125
|
-
args: [
|
|
2126
|
-
|
|
2128
|
+
args: [
|
|
2129
|
+
"--yes",
|
|
2130
|
+
"--package",
|
|
2131
|
+
"vscode-langservers-extracted",
|
|
2132
|
+
"vscode-json-language-server",
|
|
2133
|
+
"--stdio"
|
|
2134
|
+
],
|
|
2135
|
+
timeout: 30000,
|
|
2127
2136
|
autoInstall: true,
|
|
2128
2137
|
workspaceMarkers: ["package.json"]
|
|
2129
2138
|
},
|
|
2130
2139
|
html: {
|
|
2131
2140
|
command: "npx",
|
|
2132
|
-
args: [
|
|
2133
|
-
|
|
2141
|
+
args: [
|
|
2142
|
+
"--yes",
|
|
2143
|
+
"--package",
|
|
2144
|
+
"vscode-langservers-extracted",
|
|
2145
|
+
"vscode-html-language-server",
|
|
2146
|
+
"--stdio"
|
|
2147
|
+
],
|
|
2148
|
+
timeout: 60000,
|
|
2134
2149
|
autoInstall: true,
|
|
2135
2150
|
workspaceMarkers: ["package.json"]
|
|
2136
2151
|
},
|
|
2137
2152
|
css: {
|
|
2138
2153
|
command: "npx",
|
|
2139
|
-
args: [
|
|
2140
|
-
|
|
2154
|
+
args: [
|
|
2155
|
+
"--yes",
|
|
2156
|
+
"--package",
|
|
2157
|
+
"vscode-langservers-extracted",
|
|
2158
|
+
"vscode-css-language-server",
|
|
2159
|
+
"--stdio"
|
|
2160
|
+
],
|
|
2161
|
+
timeout: 60000,
|
|
2141
2162
|
autoInstall: true,
|
|
2142
2163
|
workspaceMarkers: ["package.json"]
|
|
2143
2164
|
}
|
|
@@ -2697,6 +2718,10 @@ Available commands:`,
|
|
|
2697
2718
|
"repl.skills_label": "Skills:",
|
|
2698
2719
|
"repl.plugins_label": "Plugins:",
|
|
2699
2720
|
"repl.mcp_label": "MCP:",
|
|
2721
|
+
"repl.lsp_label": "LSP:",
|
|
2722
|
+
"repl.lsp_timeout": "timeout",
|
|
2723
|
+
"repl.lsp_failed": "did not start",
|
|
2724
|
+
"repl.lsp_unknown": "unknown",
|
|
2700
2725
|
"repl.work_dir": "Dir:",
|
|
2701
2726
|
"repl.agents_label": "Instructions:",
|
|
2702
2727
|
"repl.not_found": "not found",
|
|
@@ -3319,6 +3344,10 @@ var init_ru = __esm(() => {
|
|
|
3319
3344
|
"repl.skills_label": "Скиллы:",
|
|
3320
3345
|
"repl.plugins_label": "Плагины:",
|
|
3321
3346
|
"repl.mcp_label": "MCP:",
|
|
3347
|
+
"repl.lsp_label": "LSP:",
|
|
3348
|
+
"repl.lsp_timeout": "таймаут",
|
|
3349
|
+
"repl.lsp_failed": "не стартовал",
|
|
3350
|
+
"repl.lsp_unknown": "неизвестно",
|
|
3322
3351
|
"repl.work_dir": "Директория:",
|
|
3323
3352
|
"repl.agents_label": "Инструкции:",
|
|
3324
3353
|
"repl.not_found": "не найден",
|
|
@@ -18946,24 +18975,7 @@ class LspClient {
|
|
|
18946
18975
|
async checkFile(filePath, baseDir, config, projectRoot = baseDir) {
|
|
18947
18976
|
const timeout = config.timeout ?? DEFAULT_TIMEOUT;
|
|
18948
18977
|
try {
|
|
18949
|
-
await this.
|
|
18950
|
-
const rootUri = this.pathToUri(projectRoot);
|
|
18951
|
-
const initParams = {
|
|
18952
|
-
processId: process.pid,
|
|
18953
|
-
rootUri,
|
|
18954
|
-
workspaceFolders: [{ uri: rootUri, name: "workspace" }],
|
|
18955
|
-
capabilities: { textDocument: { publishDiagnostics: {} } }
|
|
18956
|
-
};
|
|
18957
|
-
try {
|
|
18958
|
-
await this.sendRequest("initialize", initParams, timeout);
|
|
18959
|
-
} catch (e) {
|
|
18960
|
-
if (!(e instanceof Error) || !e.message.includes("initialize"))
|
|
18961
|
-
throw e;
|
|
18962
|
-
await this.shutdown();
|
|
18963
|
-
await this.startServer(config, projectRoot);
|
|
18964
|
-
await this.sendRequest("initialize", initParams, timeout);
|
|
18965
|
-
}
|
|
18966
|
-
this.initialized = true;
|
|
18978
|
+
await this.initialize(config, projectRoot, timeout);
|
|
18967
18979
|
this.sendNotification("initialized", {});
|
|
18968
18980
|
const uri = this.pathToUri(resolve20(filePath));
|
|
18969
18981
|
const fs2 = await import("fs");
|
|
@@ -18991,6 +19003,33 @@ class LspClient {
|
|
|
18991
19003
|
await this.shutdown();
|
|
18992
19004
|
}
|
|
18993
19005
|
}
|
|
19006
|
+
async probe(config, projectRoot, timeout) {
|
|
19007
|
+
try {
|
|
19008
|
+
await this.initialize(config, projectRoot, timeout);
|
|
19009
|
+
} finally {
|
|
19010
|
+
await this.shutdown();
|
|
19011
|
+
}
|
|
19012
|
+
}
|
|
19013
|
+
async initialize(config, projectRoot, timeout) {
|
|
19014
|
+
await this.startServer(config, projectRoot);
|
|
19015
|
+
const rootUri = this.pathToUri(projectRoot);
|
|
19016
|
+
const initParams = {
|
|
19017
|
+
processId: process.pid,
|
|
19018
|
+
rootUri,
|
|
19019
|
+
workspaceFolders: [{ uri: rootUri, name: "workspace" }],
|
|
19020
|
+
capabilities: { textDocument: { publishDiagnostics: {} } }
|
|
19021
|
+
};
|
|
19022
|
+
try {
|
|
19023
|
+
await this.sendRequest("initialize", initParams, timeout);
|
|
19024
|
+
} catch (e) {
|
|
19025
|
+
if (!(e instanceof Error) || !e.message.includes("initialize"))
|
|
19026
|
+
throw e;
|
|
19027
|
+
await this.shutdown();
|
|
19028
|
+
await this.startServer(config, projectRoot);
|
|
19029
|
+
await this.sendRequest("initialize", initParams, timeout);
|
|
19030
|
+
}
|
|
19031
|
+
this.initialized = true;
|
|
19032
|
+
}
|
|
18994
19033
|
async startServer(config, projectRoot) {
|
|
18995
19034
|
if (config.autoInstall === false) {
|
|
18996
19035
|
try {
|
|
@@ -32020,6 +32059,58 @@ ${pc2.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc2.dim(summary)}` : ""}
|
|
|
32020
32059
|
init_box();
|
|
32021
32060
|
init_i18n();
|
|
32022
32061
|
init_repl_commands();
|
|
32062
|
+
|
|
32063
|
+
// src/modules/lsp/probe.ts
|
|
32064
|
+
init_client2();
|
|
32065
|
+
init_config();
|
|
32066
|
+
init_check_tool();
|
|
32067
|
+
init_project_root();
|
|
32068
|
+
var DEFAULT_PROBE_TIMEOUT_MS = 20000;
|
|
32069
|
+
async function probeLspServers(config, baseDir, deps = {}) {
|
|
32070
|
+
if (!config.enabled)
|
|
32071
|
+
return { ok: [], failed: [], noneApplicable: true };
|
|
32072
|
+
const client = deps.client ?? new LspClient;
|
|
32073
|
+
const timeoutMs = deps.timeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
|
|
32074
|
+
const collect = deps.collectFiles ?? collectCheckFiles;
|
|
32075
|
+
const files = await collect(baseDir, config);
|
|
32076
|
+
const seen = new Set;
|
|
32077
|
+
const servers = [];
|
|
32078
|
+
for (const file of files) {
|
|
32079
|
+
const language = getLanguageForFile(file);
|
|
32080
|
+
if (!language)
|
|
32081
|
+
continue;
|
|
32082
|
+
const server = config.servers[language];
|
|
32083
|
+
if (!server || seen.has(language))
|
|
32084
|
+
continue;
|
|
32085
|
+
seen.add(language);
|
|
32086
|
+
servers.push({ language, config: server });
|
|
32087
|
+
}
|
|
32088
|
+
if (servers.length === 0)
|
|
32089
|
+
return { ok: [], failed: [], noneApplicable: true };
|
|
32090
|
+
const results = await Promise.all(servers.map(async ({ language, config: server }) => {
|
|
32091
|
+
const projectRoot = findProjectRoot(baseDir, baseDir, server.workspaceMarkers ?? []);
|
|
32092
|
+
const started = Date.now();
|
|
32093
|
+
try {
|
|
32094
|
+
await client.probe(server, projectRoot, timeoutMs);
|
|
32095
|
+
return { language, ok: true, durationMs: Date.now() - started };
|
|
32096
|
+
} catch (e) {
|
|
32097
|
+
return {
|
|
32098
|
+
language,
|
|
32099
|
+
ok: false,
|
|
32100
|
+
error: e instanceof Error ? e.message : String(e),
|
|
32101
|
+
durationMs: Date.now() - started
|
|
32102
|
+
};
|
|
32103
|
+
}
|
|
32104
|
+
}));
|
|
32105
|
+
return {
|
|
32106
|
+
ok: results.filter((r) => r.ok),
|
|
32107
|
+
failed: results.filter((r) => !r.ok),
|
|
32108
|
+
noneApplicable: false
|
|
32109
|
+
};
|
|
32110
|
+
}
|
|
32111
|
+
|
|
32112
|
+
// src/cli/repl.ts
|
|
32113
|
+
init_config();
|
|
32023
32114
|
function readVersion4() {
|
|
32024
32115
|
const here = dirname18(fileURLToPath6(import.meta.url));
|
|
32025
32116
|
const candidates = [join46(here, "..", "..", "package.json"), join46(here, "..", "package.json")];
|
|
@@ -32433,7 +32524,7 @@ ${t("image.clipboard_empty")}`));
|
|
|
32433
32524
|
}
|
|
32434
32525
|
}
|
|
32435
32526
|
}
|
|
32436
|
-
start() {
|
|
32527
|
+
async start() {
|
|
32437
32528
|
this.running = true;
|
|
32438
32529
|
const info = [];
|
|
32439
32530
|
const row = (label, value) => {
|
|
@@ -32469,6 +32560,10 @@ ${t("image.clipboard_empty")}`));
|
|
|
32469
32560
|
const names = enabledServers.map(([name]) => name).join(", ");
|
|
32470
32561
|
row(t("repl.mcp_label"), `${pc2.white(String(enabledServers.length))} ${pc2.dim(`(${names})`)}`);
|
|
32471
32562
|
}
|
|
32563
|
+
const lspSummary = await this.probeLspBanner();
|
|
32564
|
+
if (lspSummary) {
|
|
32565
|
+
row(t("repl.lsp_label"), lspSummary);
|
|
32566
|
+
}
|
|
32472
32567
|
const cwd = process.cwd();
|
|
32473
32568
|
row(t("repl.work_dir"), pc2.dim(cwd));
|
|
32474
32569
|
if (this.noAgentsMd) {
|
|
@@ -32503,6 +32598,25 @@ ${t("image.clipboard_empty")}`));
|
|
|
32503
32598
|
console.log();
|
|
32504
32599
|
this.rl.prompt();
|
|
32505
32600
|
}
|
|
32601
|
+
async probeLspBanner() {
|
|
32602
|
+
const config = this.config.lsp ?? DEFAULT_LSP_CONFIG;
|
|
32603
|
+
try {
|
|
32604
|
+
const summary = await probeLspServers(config, this.baseDir);
|
|
32605
|
+
if (summary.noneApplicable)
|
|
32606
|
+
return null;
|
|
32607
|
+
const parts = [];
|
|
32608
|
+
for (const r of summary.ok) {
|
|
32609
|
+
parts.push(pc2.green(`✓ ${r.language}${pc2.dim(` (${(r.durationMs / 1000).toFixed(1)}s)`)}`));
|
|
32610
|
+
}
|
|
32611
|
+
for (const r of summary.failed) {
|
|
32612
|
+
const reason = r.error?.includes("timeout") ? t("repl.lsp_timeout") : t("repl.lsp_failed");
|
|
32613
|
+
parts.push(pc2.red(`✗ ${r.language}${pc2.dim(` — ${reason}`)}`));
|
|
32614
|
+
}
|
|
32615
|
+
return parts.join(" ");
|
|
32616
|
+
} catch {
|
|
32617
|
+
return pc2.yellow(t("repl.lsp_unknown"));
|
|
32618
|
+
}
|
|
32619
|
+
}
|
|
32506
32620
|
stop() {
|
|
32507
32621
|
this.running = false;
|
|
32508
32622
|
this.saveHistory();
|
|
@@ -32785,7 +32899,7 @@ async function main() {
|
|
|
32785
32899
|
} = await bootstrap(undefined, projectDir, noAgentsMd, exitOnComplete);
|
|
32786
32900
|
startAutoUpdate(config);
|
|
32787
32901
|
const repl = new Repl(agent, config, sessionManager, skillsModule, pluginManager, configDir, baseDir, noAgentsMd, logger, true);
|
|
32788
|
-
repl.start();
|
|
32902
|
+
await repl.start();
|
|
32789
32903
|
}
|
|
32790
32904
|
}
|
|
32791
32905
|
main();
|