micro-models-agent 0.59.0 → 0.60.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/CHANGELOG.md +578 -564
- package/README.md +358 -358
- package/dist/certification/certifications.json +493 -493
- package/dist/i18n/en.json +732 -718
- package/dist/i18n/ru.json +732 -718
- package/dist/main.js +504 -62
- package/dist/modules/browser/bridge-server.mjs +219 -219
- package/dist/skills/builtin/git.md +36 -36
- package/dist/skills/builtin/typescript.md +35 -35
- package/package.json +51 -51
- package/dist/cli/commands.js +0 -447
- package/dist/cli/completer.js +0 -167
- package/dist/cli/index.js +0 -2
- package/dist/cli/main.js +0 -153
- package/dist/cli/plugin-commands.js +0 -36
- package/dist/cli/repl-commands.js +0 -761
- package/dist/cli/repl.js +0 -702
- package/dist/cli/run-result.js +0 -33
- package/dist/cli/security-commands.js +0 -164
- package/dist/cli/setup.js +0 -237
- package/dist/config/config.js +0 -276
- package/dist/config/defaults.js +0 -141
- package/dist/config/domains.js +0 -179
- package/dist/config/experts.js +0 -15
- package/dist/config/index.js +0 -4
- package/dist/config/security.js +0 -213
- package/dist/config/types.js +0 -1
- package/dist/core/agent-moe.js +0 -102
- package/dist/core/agent.js +0 -1018
- package/dist/core/bootstrap.js +0 -481
- package/dist/core/crash-handler.js +0 -51
- package/dist/core/environment.js +0 -199
- package/dist/core/index.js +0 -2
- package/dist/core/prompt-builder.js +0 -76
- package/dist/core/session-logger.js +0 -251
- package/dist/core/types.js +0 -1
- package/dist/core/version.js +0 -26
- package/dist/core/workspace.js +0 -76
- package/dist/i18n/index.js +0 -46
- package/dist/index.js +0 -22
- package/dist/llm/image-utils.js +0 -143
- package/dist/llm/index.js +0 -4
- package/dist/llm/model-loader.js +0 -78
- package/dist/llm/openai-compat.js +0 -497
- package/dist/llm/orchestrator.js +0 -200
- package/dist/llm/provider.js +0 -10
- package/dist/llm/response.js +0 -39
- package/dist/llm/token-counter.js +0 -39
- package/dist/llm/types.js +0 -1
- package/dist/logger/app-logger.js +0 -189
- package/dist/logger/file-log.js +0 -151
- package/dist/logger/index.js +0 -1
- package/dist/migration/backup.js +0 -45
- package/dist/migration/detect.js +0 -50
- package/dist/migration/index.js +0 -2
- package/dist/modules/artifacts/store.js +0 -61
- package/dist/modules/browser/actions.js +0 -76
- package/dist/modules/browser/bridge-client.js +0 -199
- package/dist/modules/browser/bridge-path.js +0 -10
- package/dist/modules/browser/cookie-store.js +0 -24
- package/dist/modules/browser/driver.js +0 -136
- package/dist/modules/browser/index.js +0 -7
- package/dist/modules/browser/module.js +0 -29
- package/dist/modules/browser/session.js +0 -342
- package/dist/modules/browser/snapshot.js +0 -148
- package/dist/modules/browser/types.js +0 -12
- package/dist/modules/certification/cli.js +0 -213
- package/dist/modules/certification/fact-checker.js +0 -82
- package/dist/modules/certification/loader.js +0 -106
- package/dist/modules/certification/manifest.js +0 -58
- package/dist/modules/certification/runner.js +0 -245
- package/dist/modules/certification/scenarios.js +0 -407
- package/dist/modules/certification/types.js +0 -1
- package/dist/modules/context/chunk-query.js +0 -100
- package/dist/modules/context/fact-extractor.js +0 -168
- package/dist/modules/context/history.js +0 -15
- package/dist/modules/context/index.js +0 -1
- package/dist/modules/context/manager.js +0 -440
- package/dist/modules/execution/audit-runners.js +0 -206
- package/dist/modules/execution/auditor.js +0 -218
- package/dist/modules/execution/execution-plugin.js +0 -431
- package/dist/modules/execution/index.js +0 -8
- package/dist/modules/execution/module.js +0 -625
- package/dist/modules/execution/moe-executor.js +0 -304
- package/dist/modules/execution/plan-coverage.js +0 -68
- package/dist/modules/execution/plan-persister.js +0 -46
- package/dist/modules/execution/plan-store.js +0 -196
- package/dist/modules/execution/plan-tool.js +0 -677
- package/dist/modules/execution/plan-validator.js +0 -153
- package/dist/modules/execution/planner.js +0 -94
- package/dist/modules/execution/stuck-detector.js +0 -746
- package/dist/modules/execution/tracker.js +0 -69
- package/dist/modules/execution/types.js +0 -1
- package/dist/modules/execution/verifier.js +0 -235
- package/dist/modules/execution/windows-commands.js +0 -41
- package/dist/modules/hallucination/confidence.js +0 -66
- package/dist/modules/hallucination/consistency.js +0 -26
- package/dist/modules/hallucination/detector.js +0 -47
- package/dist/modules/hallucination/factual.js +0 -169
- package/dist/modules/hallucination/index.js +0 -5
- package/dist/modules/hallucination/js-identifiers.js +0 -262
- package/dist/modules/hallucination/llm-judge.js +0 -101
- package/dist/modules/index.js +0 -5
- package/dist/modules/indexer/cache.js +0 -40
- package/dist/modules/indexer/index.js +0 -3
- package/dist/modules/indexer/module.js +0 -246
- package/dist/modules/indexer/project-profile.js +0 -183
- package/dist/modules/indexer/walker.js +0 -101
- package/dist/modules/lsp/check-tool.js +0 -58
- package/dist/modules/lsp/client.js +0 -389
- package/dist/modules/lsp/command.js +0 -60
- package/dist/modules/lsp/config.js +0 -135
- package/dist/modules/lsp/index.js +0 -3
- package/dist/modules/lsp/module.js +0 -260
- package/dist/modules/lsp/probe.js +0 -86
- package/dist/modules/lsp/project-root.js +0 -32
- package/dist/modules/lsp/startup-check.js +0 -144
- package/dist/modules/lsp/types.js +0 -1
- package/dist/modules/mcp/client.js +0 -399
- package/dist/modules/mcp/index.js +0 -3
- package/dist/modules/mcp/module.js +0 -142
- package/dist/modules/mcp/registry.js +0 -15
- package/dist/modules/memory/index.js +0 -1
- package/dist/modules/memory/module.js +0 -96
- package/dist/modules/memory/search.js +0 -42
- package/dist/modules/memory/store.js +0 -69
- package/dist/modules/pipelines/engine.js +0 -60
- package/dist/modules/pipelines/index.js +0 -3
- package/dist/modules/pipelines/parser.js +0 -56
- package/dist/modules/pipelines/template.js +0 -14
- package/dist/modules/plugins/builtin/lint-on-write.js +0 -334
- package/dist/modules/plugins/builtin/notify.js +0 -9
- package/dist/modules/plugins/index.js +0 -1
- package/dist/modules/plugins/loader.js +0 -70
- package/dist/modules/plugins/manager.js +0 -261
- package/dist/modules/plugins/types.js +0 -1
- package/dist/modules/pricing/index.js +0 -61
- package/dist/modules/pricing/prices.js +0 -129
- package/dist/modules/processes/detect.js +0 -34
- package/dist/modules/processes/index.js +0 -2
- package/dist/modules/processes/registry.js +0 -327
- package/dist/modules/processes/runner.js +0 -23
- package/dist/modules/providers/create.js +0 -22
- package/dist/modules/providers/fallback.js +0 -79
- package/dist/modules/providers/health.js +0 -46
- package/dist/modules/providers/index.js +0 -5
- package/dist/modules/providers/manager.js +0 -161
- package/dist/modules/providers/presets.js +0 -128
- package/dist/modules/providers/registry.js +0 -22
- package/dist/modules/providers/types.js +0 -1
- package/dist/modules/registry.js +0 -48
- package/dist/modules/security/audit-log.js +0 -136
- package/dist/modules/security/audit-notifier.js +0 -292
- package/dist/modules/security/command-validator.js +0 -219
- package/dist/modules/security/content-scanner.js +0 -53
- package/dist/modules/security/data-sanitizer.js +0 -89
- package/dist/modules/security/encryption.js +0 -242
- package/dist/modules/security/index.js +0 -14
- package/dist/modules/security/network-validator.js +0 -88
- package/dist/modules/security/path-validator.js +0 -203
- package/dist/modules/security/rate-limiter.js +0 -119
- package/dist/modules/security/security-policies.js +0 -531
- package/dist/modules/security/session-encryption.js +0 -210
- package/dist/modules/security/session-isolation.js +0 -95
- package/dist/modules/session/index.js +0 -3
- package/dist/modules/session/manager.js +0 -172
- package/dist/modules/session/module.js +0 -24
- package/dist/modules/session/store.js +0 -222
- package/dist/modules/session/types.js +0 -1
- package/dist/modules/skills/index.js +0 -2
- package/dist/modules/skills/loader.js +0 -72
- package/dist/modules/skills/matcher.js +0 -27
- package/dist/modules/skills/module.js +0 -129
- package/dist/modules/types.js +0 -1
- package/dist/modules/updater/checker.js +0 -96
- package/dist/modules/updater/index.js +0 -2
- package/dist/modules/updater/module.js +0 -116
- package/dist/modules/user-profile/compressor.js +0 -16
- package/dist/modules/user-profile/index.js +0 -1
- package/dist/modules/user-profile/profile.js +0 -68
- package/dist/tools/approve.js +0 -33
- package/dist/tools/attach-image.js +0 -101
- package/dist/tools/bash.js +0 -519
- package/dist/tools/browser.js +0 -115
- package/dist/tools/chunk-query.js +0 -100
- package/dist/tools/create-dir.js +0 -56
- package/dist/tools/delete-file.js +0 -63
- package/dist/tools/download-file.js +0 -117
- package/dist/tools/edit-file.js +0 -80
- package/dist/tools/enable-tools.js +0 -59
- package/dist/tools/executor.js +0 -154
- package/dist/tools/file-info.js +0 -47
- package/dist/tools/filter-tools.js +0 -17
- package/dist/tools/glob-tool.js +0 -27
- package/dist/tools/grep-tool.js +0 -125
- package/dist/tools/hidden-tools-block.js +0 -37
- package/dist/tools/index.js +0 -78
- package/dist/tools/list-dir.js +0 -49
- package/dist/tools/load-skill.js +0 -43
- package/dist/tools/mcp-call.js +0 -69
- package/dist/tools/move-file.js +0 -86
- package/dist/tools/path-utils.js +0 -101
- package/dist/tools/pipeline-run.js +0 -145
- package/dist/tools/preview.js +0 -2
- package/dist/tools/process-kill.js +0 -40
- package/dist/tools/process-list.js +0 -37
- package/dist/tools/process-log.js +0 -54
- package/dist/tools/question.js +0 -141
- package/dist/tools/read-file.js +0 -179
- package/dist/tools/recall.js +0 -118
- package/dist/tools/registry.js +0 -47
- package/dist/tools/remember.js +0 -68
- package/dist/tools/scope-check.js +0 -32
- package/dist/tools/search-history.js +0 -85
- package/dist/tools/subagent.js +0 -196
- package/dist/tools/types.js +0 -1
- package/dist/tools/user-input.js +0 -123
- package/dist/tools/web-browse.js +0 -87
- package/dist/tools/web-fetch.js +0 -119
- package/dist/tools/web-search.js +0 -105
- package/dist/tools/write-file.js +0 -82
- package/dist/ui/box.js +0 -77
- package/dist/ui/colors.js +0 -4
- package/dist/ui/diff.js +0 -178
- package/dist/ui/index.js +0 -6
- package/dist/ui/line-editor.js +0 -822
- package/dist/ui/line-math.js +0 -73
- package/dist/ui/md-formatter.js +0 -212
- package/dist/ui/output.js +0 -13
- package/dist/ui/plan-view.js +0 -103
- package/dist/ui/renderer.js +0 -259
- package/dist/ui/spinner.js +0 -70
- package/dist/ui/table.js +0 -144
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { readFileSync, existsSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { t } from "../../i18n/index";
|
|
4
|
-
const MANIFEST_ORDER = [
|
|
5
|
-
"package.json",
|
|
6
|
-
"pyproject.toml",
|
|
7
|
-
"Cargo.toml",
|
|
8
|
-
"go.mod",
|
|
9
|
-
"requirements.txt",
|
|
10
|
-
];
|
|
11
|
-
const MAX_DEPS = 5;
|
|
12
|
-
const MAX_DEV_DEPS = 3;
|
|
13
|
-
const MAX_SCRIPTS = 3;
|
|
14
|
-
/**
|
|
15
|
-
* Find the first existing manifest in priority order (best-effort, root only).
|
|
16
|
-
*/
|
|
17
|
-
export function detectManifest(baseDir) {
|
|
18
|
-
for (const manifest of MANIFEST_ORDER) {
|
|
19
|
-
if (existsSync(join(baseDir, manifest)))
|
|
20
|
-
return manifest;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
/** Strip version specifiers from a manifest dependency entry. */
|
|
25
|
-
function cleanDependency(entry) {
|
|
26
|
-
let name = entry.trim();
|
|
27
|
-
const eq = name.indexOf("=");
|
|
28
|
-
if (eq > 0)
|
|
29
|
-
name = name.slice(0, eq);
|
|
30
|
-
const ineq = name.search(/[<>=!~^]/);
|
|
31
|
-
if (ineq > 0)
|
|
32
|
-
name = name.slice(0, ineq);
|
|
33
|
-
return name.replace(/["',]/g, "").trim();
|
|
34
|
-
}
|
|
35
|
-
function readPackageJson(baseDir) {
|
|
36
|
-
try {
|
|
37
|
-
const raw = JSON.parse(readFileSync(join(baseDir, "package.json"), "utf-8"));
|
|
38
|
-
if (!raw || typeof raw !== "object")
|
|
39
|
-
return null;
|
|
40
|
-
const profile = {
|
|
41
|
-
runtime: "node",
|
|
42
|
-
deps: Object.keys(raw.dependencies || {}),
|
|
43
|
-
devDeps: Object.keys(raw.devDependencies || {}),
|
|
44
|
-
scripts: {},
|
|
45
|
-
};
|
|
46
|
-
if (typeof raw.name === "string" && raw.name)
|
|
47
|
-
profile.name = raw.name;
|
|
48
|
-
if (raw.scripts && typeof raw.scripts === "object") {
|
|
49
|
-
for (const [key, val] of Object.entries(raw.scripts)) {
|
|
50
|
-
if (typeof val === "string" && val)
|
|
51
|
-
profile.scripts[key] = val;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return profile;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function readPyproject(baseDir) {
|
|
61
|
-
try {
|
|
62
|
-
const content = readFileSync(join(baseDir, "pyproject.toml"), "utf-8");
|
|
63
|
-
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
64
|
-
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
65
|
-
if (nameMatch)
|
|
66
|
-
profile.name = nameMatch[1];
|
|
67
|
-
const depsBlock = content.match(/dependencies\s*=\s*\[([\s\S]*?)\]/);
|
|
68
|
-
if (depsBlock) {
|
|
69
|
-
profile.deps = [...depsBlock[1].matchAll(/"([^"]+)"/g)]
|
|
70
|
-
.map((m) => cleanDependency(m[1]))
|
|
71
|
-
.filter(Boolean);
|
|
72
|
-
}
|
|
73
|
-
return profile;
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function readCargo(baseDir) {
|
|
80
|
-
try {
|
|
81
|
-
const content = readFileSync(join(baseDir, "Cargo.toml"), "utf-8");
|
|
82
|
-
const profile = { runtime: "rust", deps: [], devDeps: [], scripts: {} };
|
|
83
|
-
const nameMatch = content.match(/^\s*name\s*=\s*"([^"]+)"/m);
|
|
84
|
-
if (nameMatch)
|
|
85
|
-
profile.name = nameMatch[1];
|
|
86
|
-
let inDeps = false;
|
|
87
|
-
for (const line of content.split("\n")) {
|
|
88
|
-
const trimmed = line.trim();
|
|
89
|
-
if (/^\[.*\]$/.test(trimmed)) {
|
|
90
|
-
inDeps = trimmed === "[dependencies]";
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
if (inDeps && /^[A-Za-z0-9_-]+\s*=/.test(trimmed)) {
|
|
94
|
-
profile.deps.push(trimmed.split("=")[0].trim());
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return profile;
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function readGoMod(baseDir) {
|
|
104
|
-
try {
|
|
105
|
-
const content = readFileSync(join(baseDir, "go.mod"), "utf-8");
|
|
106
|
-
const profile = { runtime: "go", deps: [], devDeps: [], scripts: {} };
|
|
107
|
-
const moduleMatch = content.match(/^module\s+(\S+)/m);
|
|
108
|
-
if (moduleMatch)
|
|
109
|
-
profile.name = moduleMatch[1];
|
|
110
|
-
for (const line of content.split("\n")) {
|
|
111
|
-
const m = line.match(/^\s*(\S+)\s+v[\d.]+/);
|
|
112
|
-
if (m && !line.startsWith("//"))
|
|
113
|
-
profile.deps.push(m[1]);
|
|
114
|
-
}
|
|
115
|
-
return profile;
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
function readRequirements(baseDir) {
|
|
122
|
-
try {
|
|
123
|
-
const content = readFileSync(join(baseDir, "requirements.txt"), "utf-8");
|
|
124
|
-
const profile = { runtime: "python", deps: [], devDeps: [], scripts: {} };
|
|
125
|
-
for (const line of content.split("\n")) {
|
|
126
|
-
const trimmed = line.trim();
|
|
127
|
-
if (!trimmed || trimmed.startsWith("#") || trimmed.startsWith("-"))
|
|
128
|
-
continue;
|
|
129
|
-
profile.deps.push(cleanDependency(trimmed));
|
|
130
|
-
}
|
|
131
|
-
return profile;
|
|
132
|
-
}
|
|
133
|
-
catch {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Read a compact project profile from the workspace manifest (best-effort).
|
|
139
|
-
* Returns null when no readable manifest is present.
|
|
140
|
-
*/
|
|
141
|
-
export function readProjectProfile(baseDir) {
|
|
142
|
-
const manifest = detectManifest(baseDir);
|
|
143
|
-
if (!manifest)
|
|
144
|
-
return null;
|
|
145
|
-
switch (manifest) {
|
|
146
|
-
case "package.json":
|
|
147
|
-
return readPackageJson(baseDir);
|
|
148
|
-
case "pyproject.toml":
|
|
149
|
-
return readPyproject(baseDir);
|
|
150
|
-
case "Cargo.toml":
|
|
151
|
-
return readCargo(baseDir);
|
|
152
|
-
case "go.mod":
|
|
153
|
-
return readGoMod(baseDir);
|
|
154
|
-
case "requirements.txt":
|
|
155
|
-
return readRequirements(baseDir);
|
|
156
|
-
default:
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/** One-line stack-neutral summary of the project profile. */
|
|
161
|
-
export function formatProjectProfile(profile) {
|
|
162
|
-
const parts = [];
|
|
163
|
-
if (profile.deps.length > 0) {
|
|
164
|
-
parts.push(`${t("indexer.stack_deps")}: ${profile.deps.slice(0, MAX_DEPS).join(", ")}`);
|
|
165
|
-
}
|
|
166
|
-
if (profile.devDeps.length > 0) {
|
|
167
|
-
parts.push(`${t("indexer.stack_dev")}: ${profile.devDeps.slice(0, MAX_DEV_DEPS).join(", ")}`);
|
|
168
|
-
}
|
|
169
|
-
const scripts = Object.entries(profile.scripts).slice(0, MAX_SCRIPTS);
|
|
170
|
-
if (scripts.length > 0) {
|
|
171
|
-
parts.push(`${t("indexer.stack_scripts")}: ${scripts.map(([k, v]) => `${k}=${v}`).join(", ")}`);
|
|
172
|
-
}
|
|
173
|
-
const name = profile.name ? ` ${profile.name}` : "";
|
|
174
|
-
return `[Stack: ${profile.runtime}${name} — ${parts.join(" | ")}]`;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Convenience: detect + read + format in one call. Returns null when the
|
|
178
|
-
* workspace has no readable manifest.
|
|
179
|
-
*/
|
|
180
|
-
export function buildProjectProfileLine(baseDir) {
|
|
181
|
-
const profile = readProjectProfile(baseDir);
|
|
182
|
-
return profile ? formatProjectProfile(profile) : null;
|
|
183
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { readdirSync, readFileSync, statSync, existsSync, watch } from "fs";
|
|
2
|
-
import { join, relative, extname } from "path";
|
|
3
|
-
const LANGUAGES = {
|
|
4
|
-
".ts": "typescript",
|
|
5
|
-
".tsx": "typescript-react",
|
|
6
|
-
".js": "javascript",
|
|
7
|
-
".jsx": "javascript-react",
|
|
8
|
-
".json": "json",
|
|
9
|
-
".md": "markdown",
|
|
10
|
-
".yaml": "yaml",
|
|
11
|
-
".yml": "yaml",
|
|
12
|
-
".py": "python",
|
|
13
|
-
".rs": "rust",
|
|
14
|
-
".go": "go",
|
|
15
|
-
};
|
|
16
|
-
const IGNORE_DIRS = new Set(["node_modules", ".git", "dist", "build", ".mma", "coverage"]);
|
|
17
|
-
export class Indexer {
|
|
18
|
-
baseDir;
|
|
19
|
-
MAX_FILES = 1000;
|
|
20
|
-
watcher = null;
|
|
21
|
-
constructor(baseDir) {
|
|
22
|
-
this.baseDir = baseDir;
|
|
23
|
-
}
|
|
24
|
-
watch(callback) {
|
|
25
|
-
this.watcher = watch(this.baseDir, { recursive: true }, (event, filename) => {
|
|
26
|
-
if (filename && !Array.from(IGNORE_DIRS).some((dir) => filename.includes(dir))) {
|
|
27
|
-
callback(event, filename);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
unwatch() {
|
|
32
|
-
if (this.watcher) {
|
|
33
|
-
this.watcher.close();
|
|
34
|
-
this.watcher = null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async walk() {
|
|
38
|
-
const files = [];
|
|
39
|
-
let totalSize = 0;
|
|
40
|
-
let count = 0;
|
|
41
|
-
const walkDir = (dir) => {
|
|
42
|
-
if (!existsSync(dir))
|
|
43
|
-
return;
|
|
44
|
-
let entries;
|
|
45
|
-
try {
|
|
46
|
-
entries = readdirSync(dir);
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
for (const entry of entries) {
|
|
52
|
-
if (count >= this.MAX_FILES)
|
|
53
|
-
return;
|
|
54
|
-
const fullPath = join(dir, entry);
|
|
55
|
-
const relPath = relative(this.baseDir, fullPath);
|
|
56
|
-
const stat = statSync(fullPath);
|
|
57
|
-
if (stat.isDirectory()) {
|
|
58
|
-
if (!IGNORE_DIRS.has(entry)) {
|
|
59
|
-
walkDir(fullPath);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
else if (stat.isFile()) {
|
|
63
|
-
const ext = extname(entry).toLowerCase();
|
|
64
|
-
const language = LANGUAGES[ext];
|
|
65
|
-
if (language) {
|
|
66
|
-
const content = readFileSync(fullPath, "utf-8");
|
|
67
|
-
const exports = this.extractExports(content, language);
|
|
68
|
-
files.push({ path: relPath, language, exports, size: stat.size });
|
|
69
|
-
totalSize += stat.size;
|
|
70
|
-
count++;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
walkDir(this.baseDir);
|
|
76
|
-
return { files, totalSize };
|
|
77
|
-
}
|
|
78
|
-
extractExports(content, language) {
|
|
79
|
-
if (language === "typescript" || language === "javascript") {
|
|
80
|
-
const exports = [];
|
|
81
|
-
const exportRegex = /export\s+(?:const|function|class|interface|type|enum|default\s+(?:class|function))\s+(\w+)/g;
|
|
82
|
-
let match;
|
|
83
|
-
while ((match = exportRegex.exec(content)) !== null) {
|
|
84
|
-
exports.push(match[1]);
|
|
85
|
-
}
|
|
86
|
-
return exports;
|
|
87
|
-
}
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
summarize(result) {
|
|
91
|
-
const byLang = {};
|
|
92
|
-
for (const f of result.files) {
|
|
93
|
-
byLang[f.language] = (byLang[f.language] || 0) + 1;
|
|
94
|
-
}
|
|
95
|
-
const langs = Object.entries(byLang)
|
|
96
|
-
.sort((a, b) => b[1] - a[1])
|
|
97
|
-
.map(([lang, count]) => `${lang}:${count}`)
|
|
98
|
-
.join(", ");
|
|
99
|
-
return `[Index: ${result.files.length} files, ${(result.totalSize / 1024).toFixed(1)}KB (${langs})]`;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { readdir, stat } from "fs/promises";
|
|
2
|
-
import { resolve, relative } from "path";
|
|
3
|
-
import { getServerForFile } from "./config";
|
|
4
|
-
/** lsp_check directory mode: walk depth and per-call file cap. */
|
|
5
|
-
export const MAX_LSP_CHECK_FILES = 15;
|
|
6
|
-
const MAX_LSP_WALK_DEPTH = 4;
|
|
7
|
-
const SKIP_DIRS = new Set(["node_modules", ".git", ".mma", "dist"]);
|
|
8
|
-
export const severityLabels = {
|
|
9
|
-
1: "error",
|
|
10
|
-
2: "warning",
|
|
11
|
-
3: "info",
|
|
12
|
-
4: "hint",
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Resolve the target to a file (single check) or a bounded list of source
|
|
16
|
-
* files (directory check, capped at MAX_LSP_CHECK_FILES). Only files with a
|
|
17
|
-
* configured LSP server are collected, so unsupported extensions are simply
|
|
18
|
-
* not checked rather than producing noise.
|
|
19
|
-
*/
|
|
20
|
-
export async function collectCheckFiles(resolved, config) {
|
|
21
|
-
const info = await stat(resolved).catch(() => null);
|
|
22
|
-
if (!info)
|
|
23
|
-
return [];
|
|
24
|
-
if (info.isFile())
|
|
25
|
-
return [resolved];
|
|
26
|
-
const out = [];
|
|
27
|
-
await walkDir(resolved, 0, out, config);
|
|
28
|
-
return out;
|
|
29
|
-
}
|
|
30
|
-
async function walkDir(dir, depth, out, config) {
|
|
31
|
-
if (depth > MAX_LSP_WALK_DEPTH || out.length >= MAX_LSP_CHECK_FILES)
|
|
32
|
-
return;
|
|
33
|
-
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
34
|
-
for (const entry of entries) {
|
|
35
|
-
if (out.length >= MAX_LSP_CHECK_FILES)
|
|
36
|
-
break;
|
|
37
|
-
if (entry.isDirectory()) {
|
|
38
|
-
if (SKIP_DIRS.has(entry.name))
|
|
39
|
-
continue;
|
|
40
|
-
await walkDir(resolve(dir, entry.name), depth + 1, out, config);
|
|
41
|
-
}
|
|
42
|
-
else if (entry.isFile() && getServerForFile(resolve(dir, entry.name), config)) {
|
|
43
|
-
out.push(resolve(dir, entry.name));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export function formatCheckDiagnostics(items, baseDir) {
|
|
48
|
-
return items
|
|
49
|
-
.slice(0, 40)
|
|
50
|
-
.map(({ file, diag }) => {
|
|
51
|
-
const rel = relative(baseDir, file).replace(/\\/g, "/");
|
|
52
|
-
const line = diag.range.start.line + 1;
|
|
53
|
-
const col = diag.range.start.character + 1;
|
|
54
|
-
const sev = severityLabels[diag.severity] ?? "unknown";
|
|
55
|
-
return ` ${rel}(${line},${col}): ${sev}: ${diag.message}`;
|
|
56
|
-
})
|
|
57
|
-
.join("\n");
|
|
58
|
-
}
|