micro-models-agent 0.54.1 β†’ 0.55.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.
Files changed (232) hide show
  1. package/README.md +358 -358
  2. package/dist/certification/certifications.json +493 -493
  3. package/dist/main.js +489 -82
  4. package/dist/modules/browser/bridge-server.mjs +202 -202
  5. package/dist/skills/builtin/git.md +36 -36
  6. package/dist/skills/builtin/typescript.md +35 -35
  7. package/package.json +1 -1
  8. package/dist/cli/commands.js +0 -447
  9. package/dist/cli/completer.js +0 -167
  10. package/dist/cli/index.js +0 -2
  11. package/dist/cli/main.js +0 -153
  12. package/dist/cli/plugin-commands.js +0 -36
  13. package/dist/cli/repl-commands.js +0 -761
  14. package/dist/cli/repl.js +0 -702
  15. package/dist/cli/run-result.js +0 -33
  16. package/dist/cli/security-commands.js +0 -164
  17. package/dist/cli/setup.js +0 -237
  18. package/dist/config/config.js +0 -276
  19. package/dist/config/defaults.js +0 -141
  20. package/dist/config/domains.js +0 -179
  21. package/dist/config/experts.js +0 -15
  22. package/dist/config/index.js +0 -4
  23. package/dist/config/security.js +0 -213
  24. package/dist/config/types.js +0 -1
  25. package/dist/core/agent-moe.js +0 -102
  26. package/dist/core/agent.js +0 -1018
  27. package/dist/core/bootstrap.js +0 -481
  28. package/dist/core/crash-handler.js +0 -51
  29. package/dist/core/environment.js +0 -199
  30. package/dist/core/index.js +0 -2
  31. package/dist/core/prompt-builder.js +0 -76
  32. package/dist/core/session-logger.js +0 -251
  33. package/dist/core/types.js +0 -1
  34. package/dist/core/version.js +0 -26
  35. package/dist/core/workspace.js +0 -76
  36. package/dist/i18n/en.json +0 -679
  37. package/dist/i18n/index.js +0 -46
  38. package/dist/i18n/ru.json +0 -679
  39. package/dist/index.js +0 -22
  40. package/dist/llm/image-utils.js +0 -143
  41. package/dist/llm/index.js +0 -4
  42. package/dist/llm/model-loader.js +0 -78
  43. package/dist/llm/openai-compat.js +0 -497
  44. package/dist/llm/orchestrator.js +0 -200
  45. package/dist/llm/provider.js +0 -10
  46. package/dist/llm/response.js +0 -39
  47. package/dist/llm/token-counter.js +0 -39
  48. package/dist/llm/types.js +0 -1
  49. package/dist/logger/app-logger.js +0 -189
  50. package/dist/logger/file-log.js +0 -151
  51. package/dist/logger/index.js +0 -1
  52. package/dist/migration/backup.js +0 -45
  53. package/dist/migration/detect.js +0 -50
  54. package/dist/migration/index.js +0 -2
  55. package/dist/modules/artifacts/store.js +0 -61
  56. package/dist/modules/browser/actions.js +0 -76
  57. package/dist/modules/browser/bridge-client.js +0 -199
  58. package/dist/modules/browser/bridge-path.js +0 -10
  59. package/dist/modules/browser/cookie-store.js +0 -24
  60. package/dist/modules/browser/driver.js +0 -136
  61. package/dist/modules/browser/index.js +0 -7
  62. package/dist/modules/browser/module.js +0 -29
  63. package/dist/modules/browser/session.js +0 -342
  64. package/dist/modules/browser/snapshot.js +0 -148
  65. package/dist/modules/browser/types.js +0 -12
  66. package/dist/modules/certification/cli.js +0 -213
  67. package/dist/modules/certification/fact-checker.js +0 -82
  68. package/dist/modules/certification/loader.js +0 -106
  69. package/dist/modules/certification/manifest.js +0 -58
  70. package/dist/modules/certification/runner.js +0 -245
  71. package/dist/modules/certification/scenarios.js +0 -407
  72. package/dist/modules/certification/types.js +0 -1
  73. package/dist/modules/context/chunk-query.js +0 -100
  74. package/dist/modules/context/fact-extractor.js +0 -168
  75. package/dist/modules/context/history.js +0 -15
  76. package/dist/modules/context/index.js +0 -1
  77. package/dist/modules/context/manager.js +0 -440
  78. package/dist/modules/execution/audit-runners.js +0 -206
  79. package/dist/modules/execution/auditor.js +0 -218
  80. package/dist/modules/execution/execution-plugin.js +0 -431
  81. package/dist/modules/execution/index.js +0 -8
  82. package/dist/modules/execution/module.js +0 -625
  83. package/dist/modules/execution/moe-executor.js +0 -304
  84. package/dist/modules/execution/plan-coverage.js +0 -68
  85. package/dist/modules/execution/plan-persister.js +0 -46
  86. package/dist/modules/execution/plan-store.js +0 -196
  87. package/dist/modules/execution/plan-tool.js +0 -677
  88. package/dist/modules/execution/plan-validator.js +0 -153
  89. package/dist/modules/execution/planner.js +0 -94
  90. package/dist/modules/execution/stuck-detector.js +0 -746
  91. package/dist/modules/execution/tracker.js +0 -69
  92. package/dist/modules/execution/types.js +0 -1
  93. package/dist/modules/execution/verifier.js +0 -235
  94. package/dist/modules/execution/windows-commands.js +0 -41
  95. package/dist/modules/hallucination/confidence.js +0 -66
  96. package/dist/modules/hallucination/consistency.js +0 -26
  97. package/dist/modules/hallucination/detector.js +0 -47
  98. package/dist/modules/hallucination/factual.js +0 -169
  99. package/dist/modules/hallucination/index.js +0 -5
  100. package/dist/modules/hallucination/js-identifiers.js +0 -262
  101. package/dist/modules/hallucination/llm-judge.js +0 -101
  102. package/dist/modules/index.js +0 -5
  103. package/dist/modules/indexer/cache.js +0 -40
  104. package/dist/modules/indexer/index.js +0 -3
  105. package/dist/modules/indexer/module.js +0 -246
  106. package/dist/modules/indexer/project-profile.js +0 -183
  107. package/dist/modules/indexer/walker.js +0 -101
  108. package/dist/modules/lsp/check-tool.js +0 -58
  109. package/dist/modules/lsp/client.js +0 -389
  110. package/dist/modules/lsp/command.js +0 -60
  111. package/dist/modules/lsp/config.js +0 -135
  112. package/dist/modules/lsp/index.js +0 -3
  113. package/dist/modules/lsp/module.js +0 -260
  114. package/dist/modules/lsp/probe.js +0 -86
  115. package/dist/modules/lsp/project-root.js +0 -32
  116. package/dist/modules/lsp/startup-check.js +0 -144
  117. package/dist/modules/lsp/types.js +0 -1
  118. package/dist/modules/mcp/client.js +0 -399
  119. package/dist/modules/mcp/index.js +0 -3
  120. package/dist/modules/mcp/module.js +0 -142
  121. package/dist/modules/mcp/registry.js +0 -15
  122. package/dist/modules/memory/index.js +0 -1
  123. package/dist/modules/memory/module.js +0 -96
  124. package/dist/modules/memory/search.js +0 -42
  125. package/dist/modules/memory/store.js +0 -69
  126. package/dist/modules/pipelines/engine.js +0 -60
  127. package/dist/modules/pipelines/index.js +0 -3
  128. package/dist/modules/pipelines/parser.js +0 -56
  129. package/dist/modules/pipelines/template.js +0 -14
  130. package/dist/modules/plugins/builtin/lint-on-write.js +0 -334
  131. package/dist/modules/plugins/builtin/notify.js +0 -9
  132. package/dist/modules/plugins/index.js +0 -1
  133. package/dist/modules/plugins/loader.js +0 -70
  134. package/dist/modules/plugins/manager.js +0 -261
  135. package/dist/modules/plugins/types.js +0 -1
  136. package/dist/modules/pricing/index.js +0 -61
  137. package/dist/modules/pricing/prices.js +0 -129
  138. package/dist/modules/processes/detect.js +0 -34
  139. package/dist/modules/processes/index.js +0 -2
  140. package/dist/modules/processes/registry.js +0 -327
  141. package/dist/modules/processes/runner.js +0 -23
  142. package/dist/modules/providers/create.js +0 -22
  143. package/dist/modules/providers/fallback.js +0 -79
  144. package/dist/modules/providers/health.js +0 -46
  145. package/dist/modules/providers/index.js +0 -5
  146. package/dist/modules/providers/manager.js +0 -161
  147. package/dist/modules/providers/presets.js +0 -128
  148. package/dist/modules/providers/registry.js +0 -22
  149. package/dist/modules/providers/types.js +0 -1
  150. package/dist/modules/registry.js +0 -48
  151. package/dist/modules/security/audit-log.js +0 -136
  152. package/dist/modules/security/audit-notifier.js +0 -292
  153. package/dist/modules/security/command-validator.js +0 -219
  154. package/dist/modules/security/content-scanner.js +0 -53
  155. package/dist/modules/security/data-sanitizer.js +0 -89
  156. package/dist/modules/security/encryption.js +0 -242
  157. package/dist/modules/security/index.js +0 -14
  158. package/dist/modules/security/network-validator.js +0 -88
  159. package/dist/modules/security/path-validator.js +0 -203
  160. package/dist/modules/security/rate-limiter.js +0 -119
  161. package/dist/modules/security/security-policies.js +0 -531
  162. package/dist/modules/security/session-encryption.js +0 -210
  163. package/dist/modules/security/session-isolation.js +0 -95
  164. package/dist/modules/session/index.js +0 -3
  165. package/dist/modules/session/manager.js +0 -172
  166. package/dist/modules/session/module.js +0 -24
  167. package/dist/modules/session/store.js +0 -222
  168. package/dist/modules/session/types.js +0 -1
  169. package/dist/modules/skills/index.js +0 -2
  170. package/dist/modules/skills/loader.js +0 -72
  171. package/dist/modules/skills/matcher.js +0 -27
  172. package/dist/modules/skills/module.js +0 -129
  173. package/dist/modules/types.js +0 -1
  174. package/dist/modules/updater/checker.js +0 -96
  175. package/dist/modules/updater/index.js +0 -2
  176. package/dist/modules/updater/module.js +0 -116
  177. package/dist/modules/user-profile/compressor.js +0 -16
  178. package/dist/modules/user-profile/index.js +0 -1
  179. package/dist/modules/user-profile/profile.js +0 -68
  180. package/dist/tools/approve.js +0 -33
  181. package/dist/tools/attach-image.js +0 -101
  182. package/dist/tools/bash.js +0 -519
  183. package/dist/tools/browser.js +0 -115
  184. package/dist/tools/chunk-query.js +0 -100
  185. package/dist/tools/create-dir.js +0 -56
  186. package/dist/tools/delete-file.js +0 -63
  187. package/dist/tools/download-file.js +0 -117
  188. package/dist/tools/edit-file.js +0 -80
  189. package/dist/tools/enable-tools.js +0 -59
  190. package/dist/tools/executor.js +0 -154
  191. package/dist/tools/file-info.js +0 -47
  192. package/dist/tools/filter-tools.js +0 -17
  193. package/dist/tools/glob-tool.js +0 -27
  194. package/dist/tools/grep-tool.js +0 -125
  195. package/dist/tools/hidden-tools-block.js +0 -37
  196. package/dist/tools/index.js +0 -78
  197. package/dist/tools/list-dir.js +0 -49
  198. package/dist/tools/load-skill.js +0 -43
  199. package/dist/tools/mcp-call.js +0 -69
  200. package/dist/tools/move-file.js +0 -86
  201. package/dist/tools/path-utils.js +0 -101
  202. package/dist/tools/pipeline-run.js +0 -145
  203. package/dist/tools/preview.js +0 -2
  204. package/dist/tools/process-kill.js +0 -40
  205. package/dist/tools/process-list.js +0 -37
  206. package/dist/tools/process-log.js +0 -54
  207. package/dist/tools/question.js +0 -141
  208. package/dist/tools/read-file.js +0 -179
  209. package/dist/tools/recall.js +0 -118
  210. package/dist/tools/registry.js +0 -47
  211. package/dist/tools/remember.js +0 -68
  212. package/dist/tools/scope-check.js +0 -32
  213. package/dist/tools/search-history.js +0 -85
  214. package/dist/tools/subagent.js +0 -196
  215. package/dist/tools/types.js +0 -1
  216. package/dist/tools/user-input.js +0 -123
  217. package/dist/tools/web-browse.js +0 -87
  218. package/dist/tools/web-fetch.js +0 -119
  219. package/dist/tools/web-search.js +0 -105
  220. package/dist/tools/write-file.js +0 -82
  221. package/dist/ui/box.js +0 -77
  222. package/dist/ui/colors.js +0 -4
  223. package/dist/ui/diff.js +0 -178
  224. package/dist/ui/index.js +0 -6
  225. package/dist/ui/line-editor.js +0 -822
  226. package/dist/ui/line-math.js +0 -73
  227. package/dist/ui/md-formatter.js +0 -212
  228. package/dist/ui/output.js +0 -13
  229. package/dist/ui/plan-view.js +0 -103
  230. package/dist/ui/renderer.js +0 -259
  231. package/dist/ui/spinner.js +0 -70
  232. package/dist/ui/table.js +0 -144
@@ -1,262 +0,0 @@
1
- /**
2
- * JS/TS global identifiers whose member access (`process.env`, `console.log`,
3
- * `Math.max`) looks like a file path to `\b[\w./\\-]+\.[a-z]+\b`-style regexes
4
- * but is code, not a file. Shared by the hallucination factual check and the
5
- * execution auditor so both stop flagging member access as "missing files".
6
- *
7
- * Also home of the shared "is this token actually a file?" filter
8
- * (`isFilePathLike` / `extractFileLikeTokens` / `stripUrls`) so the two
9
- * extractors cannot drift apart again (observed: auditor treated a URL
10
- * hostname `whom-pointing-jewel-maine.trycloudflare.com` in a plan step as a
11
- * missing file while the factual check correctly ignored it).
12
- *
13
- * Bare `word.ext` tokens are gated on an allow-list of real file extensions
14
- * (`FILE_EXTENSIONS`) instead of a deny-list of TLDs β€” a domain in any present
15
- * or future TLD (`Gismeteo.by`, `weather.com`, `example.xyz`) can never be
16
- * mistaken for a file, and no TLD list needs maintaining.
17
- */
18
- const JS_GLOBALS = new Set([
19
- "process",
20
- "console",
21
- "math",
22
- "json",
23
- "global",
24
- "globalthis",
25
- "window",
26
- "document",
27
- "buffer",
28
- "module",
29
- "require",
30
- "exports",
31
- "url",
32
- "promise",
33
- "array",
34
- "object",
35
- "string",
36
- "number",
37
- "boolean",
38
- "symbol",
39
- "date",
40
- "regexp",
41
- "error",
42
- "map",
43
- "set",
44
- "weakmap",
45
- "weakset",
46
- "proxy",
47
- "reflect",
48
- "intl",
49
- "crypto",
50
- "performance",
51
- "fetch",
52
- "navigator",
53
- "location",
54
- "settimeout",
55
- "setinterval",
56
- "cleartimeout",
57
- "clearinterval",
58
- "queuemicrotask",
59
- "structuredclone",
60
- "textencoder",
61
- "textdecoder",
62
- "atomics",
63
- "sharedarraybuffer",
64
- "dataview",
65
- "arraybuffer",
66
- "bigint",
67
- "infinity",
68
- "nan",
69
- "undefined",
70
- "bun",
71
- "deno",
72
- "node",
73
- ]);
74
- /**
75
- * True when `candidate` starts with a known JS/TS global followed by a dot
76
- * (`process.env`, `console.log`, `process.env.NODE` partial matches from
77
- * `\b[\w./\\-]+\.[a-z]+`-style regexes) β€” member access, not a file path.
78
- */
79
- export function isJsMemberAccess(candidate) {
80
- const lower = candidate.toLowerCase();
81
- const m = lower.match(/^([\w-]+)\./);
82
- return m !== null && JS_GLOBALS.has(m[1]);
83
- }
84
- /**
85
- * File extensions that make a bare `word.ext` token a plausible file path.
86
- *
87
- * An allow-list, deliberately: enumerating everything that is NOT a file (TLDs,
88
- * brand names, …) is a brittle heuristic that can never be complete. Instead a
89
- * bare `word.ext` is only treated as a file when its extension is a known one β€”
90
- * so `Gismeteo.by`, `weather.com`, or any future TLD is never flagged, while a
91
- * genuine `config.json` / `helper.ts` still is.
92
- */
93
- const FILE_EXTENSIONS = new Set([
94
- // source / code
95
- "ts",
96
- "tsx",
97
- "js",
98
- "jsx",
99
- "mjs",
100
- "cjs",
101
- "py",
102
- "pyc",
103
- "rb",
104
- "go",
105
- "rs",
106
- "java",
107
- "jar",
108
- "kt",
109
- "kts",
110
- "c",
111
- "h",
112
- "cc",
113
- "cpp",
114
- "cxx",
115
- "hpp",
116
- "hh",
117
- "cs",
118
- "php",
119
- "swift",
120
- "m",
121
- "mm",
122
- "lua",
123
- "pl",
124
- "sh",
125
- "bash",
126
- "zsh",
127
- "fish",
128
- "bat",
129
- "cmd",
130
- "ps1",
131
- "vue",
132
- "svelte",
133
- "dart",
134
- // config / data / docs
135
- "json",
136
- "jsonc",
137
- "json5",
138
- "yaml",
139
- "yml",
140
- "toml",
141
- "ini",
142
- "cfg",
143
- "conf",
144
- "env",
145
- "xml",
146
- "html",
147
- "htm",
148
- "md",
149
- "markdown",
150
- "rst",
151
- "txt",
152
- "log",
153
- "csv",
154
- "tsv",
155
- "lock",
156
- "sql",
157
- "sqlite",
158
- "db",
159
- "wasm",
160
- "map",
161
- "css",
162
- "scss",
163
- "sass",
164
- "less",
165
- // assets / binary
166
- "svg",
167
- "png",
168
- "jpg",
169
- "jpeg",
170
- "gif",
171
- "webp",
172
- "bmp",
173
- "ico",
174
- "avif",
175
- "tiff",
176
- "pdf",
177
- "doc",
178
- "docx",
179
- "xls",
180
- "xlsx",
181
- "ppt",
182
- "pptx",
183
- "odt",
184
- "ods",
185
- "zip",
186
- "gz",
187
- "tar",
188
- "tgz",
189
- "bz2",
190
- "xz",
191
- "7z",
192
- "rar",
193
- "bin",
194
- "exe",
195
- "dll",
196
- "so",
197
- "o",
198
- "a",
199
- "dylib",
200
- ]);
201
- /** Well-known runtime/library names that end in .js/.ts but are NOT files. */
202
- const TECH_NAMES = new Set([
203
- "node.js",
204
- "react.js",
205
- "vue.js",
206
- "next.js",
207
- "angular.js",
208
- "express.js",
209
- "deno.js",
210
- "qwik.js",
211
- "svelte.js",
212
- "jquery.js",
213
- ]);
214
- const FILE_TOKEN_RE = /\b(?:[a-zA-Z]:[\\/])?[\w./\\-]+\.[a-z]{1,6}\b/gi;
215
- /**
216
- * True when `candidate` is a plausible file path token: for a path with a
217
- * directory separator the last segment must carry a non-empty stem before the
218
- * extension (extension-only segments like `tsx/.ts` are rejected), while a bare
219
- * `word.ext` is only a file when its extension is a known file extension (so
220
- * domains like `Gismeteo.by` / `weather.com` are never files). JS member access
221
- * (`process.env`) and technology names (`node.js`) are never files.
222
- */
223
- export function isFilePathLike(s) {
224
- const lower = s.toLowerCase();
225
- if (TECH_NAMES.has(lower))
226
- return false;
227
- if (isJsMemberAccess(s))
228
- return false;
229
- const ext = s.split(".").pop()?.toLowerCase() || "";
230
- if (!s.includes("/") && !s.includes("\\")) {
231
- if (!/^\w+\.[a-z]{1,6}$/i.test(s))
232
- return false;
233
- return FILE_EXTENSIONS.has(ext);
234
- }
235
- // Tokens with a directory separator: require the LAST segment to carry a
236
- // real file name (a non-empty stem before the extension). Otherwise an
237
- // extension-only segment like "tsx/.ts" (from ".tsx/.ts" in a step
238
- // description) or a dotfile ("src/.env") is misread as a file and the plan
239
- // deliverable gate demands "create tsx/.ts" (observed in ses_mstda6uo:
240
- // step "ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΈΡ‚ΡŒ Ρ‡Ρ‚ΠΎ ΠΎΡΡ‚Π°Π»ΠΈΡΡŒ Ρ‚ΠΎΠ»ΡŒΠΊΠΎ .tsx/.ts Ρ„Π°ΠΉΠ»Ρ‹").
241
- const last = s.split(/[\\/]/).pop() ?? "";
242
- const lastDot = last.lastIndexOf(".");
243
- if (lastDot <= 0)
244
- return false;
245
- return true;
246
- }
247
- /**
248
- * Extract deduplicated file-like tokens from free text. Bare `word.ext` tokens
249
- * are filtered through `isFilePathLike` (allow-list of real file extensions, so
250
- * hostnames/TLDs like `whom-pointing-jewel-maine.trycloudflare.com` or
251
- * `Gismeteo.by` never survive); URLs are stripped first so
252
- * `https://host/repo.git` never survives as a "file".
253
- */
254
- export function extractFileLikeTokens(text) {
255
- const matches = text.match(FILE_TOKEN_RE) || [];
256
- return [...new Set(matches.filter(isFilePathLike))];
257
- }
258
- /** Remove URL tokens (scheme://… up to whitespace/quote) so they are never
259
- * parsed as file paths. */
260
- export function stripUrls(text) {
261
- return text.replace(/\bhttps?:\/\/[^\s"'<>]+/gi, " ");
262
- }
@@ -1,101 +0,0 @@
1
- import { t } from "../../i18n/index";
2
- const JUDGE_TIMEOUT_MS = 15000;
3
- const MAX_DECISIONS_SHOWN = 6;
4
- const MAX_RESPONSE_CHARS = 2000;
5
- /**
6
- * LLM-as-judge consistency check. Asks a model whether the agent's latest
7
- * response contradicts any of its earlier decisions β€” replacing the fragile
8
- * word-matching heuristic that only caught exact substring reversals.
9
- *
10
- * Fast path: when no decisions are tracked, returns pass without any LLM call.
11
- * Any judge failure (timeout, provider error, unparseable verdict) degrades to
12
- * pass so the agent loop is never blocked by the judge.
13
- */
14
- export class LLMJudge {
15
- provider;
16
- constructor(provider) {
17
- this.provider = provider;
18
- }
19
- async validate(response, consistency) {
20
- const decisions = consistency.getDecisions();
21
- if (decisions.length === 0) {
22
- return { status: "pass" };
23
- }
24
- const shown = decisions.slice(-MAX_DECISIONS_SHOWN);
25
- const decisionLines = shown
26
- .map((d, i) => `${i + 1}. [${d.location || "agent"}] "${d.decision}"`)
27
- .join("\n");
28
- const system = `You are a consistency checker for an AI coding agent. The agent previously made these decisions:
29
-
30
- ${decisionLines}
31
-
32
- Decide whether the agent's NEW response contradicts any of these decisions. A contradiction means reversing or abandoning a previously stated approach (e.g. switching to a different framework, changing a chosen strategy, or undoing a decision that was explicitly made).
33
-
34
- Reply with ONLY valid JSON, no other text:
35
- - {"contradicts": false}
36
- - {"contradicts": true, "reason": "short explanation"}`;
37
- const user = `Agent's new response:\n\n${response.slice(0, MAX_RESPONSE_CHARS)}`;
38
- try {
39
- const verdictText = await this.askJudge([
40
- { role: "system", content: system },
41
- { role: "user", content: user },
42
- ]);
43
- const verdict = this.parseVerdict(verdictText);
44
- if (verdict.contradicts) {
45
- const reason = verdict.reason?.trim() ? ` β€” ${verdict.reason.trim()}` : "";
46
- return {
47
- status: "warn",
48
- reason: t("hall.contradiction_llm", { reason }),
49
- };
50
- }
51
- return { status: "pass" };
52
- }
53
- catch {
54
- return { status: "pass" };
55
- }
56
- }
57
- async askJudge(messages) {
58
- let text = "";
59
- let timer;
60
- const consume = (async () => {
61
- for await (const chunk of this.provider.chat(messages, [])) {
62
- if (chunk.type === "text" && chunk.content) {
63
- text += chunk.content;
64
- }
65
- }
66
- return text;
67
- })();
68
- const timeout = new Promise((_, reject) => {
69
- timer = setTimeout(() => reject(new Error("LLM judge timed out")), JUDGE_TIMEOUT_MS);
70
- });
71
- try {
72
- return await Promise.race([consume, timeout]);
73
- }
74
- finally {
75
- if (timer)
76
- clearTimeout(timer);
77
- }
78
- }
79
- parseVerdict(text) {
80
- const block = text.match(/\{[\s\S]*\}/);
81
- if (block) {
82
- try {
83
- const obj = JSON.parse(block[0]);
84
- if (typeof obj.contradicts === "boolean") {
85
- return {
86
- contradicts: obj.contradicts,
87
- reason: typeof obj.reason === "string" ? obj.reason : undefined,
88
- };
89
- }
90
- }
91
- catch {
92
- // fall through to lenient parsing
93
- }
94
- }
95
- const lower = text.toLowerCase();
96
- if (lower.includes('"contradicts": true') || /^yes\b/.test(lower.trim())) {
97
- return { contradicts: true, reason: text.slice(0, 200) };
98
- }
99
- return { contradicts: false };
100
- }
101
- }
@@ -1,5 +0,0 @@
1
- export { ModuleRegistry } from "./registry";
2
- export { SkillsLoader, SkillsModule } from "./skills";
3
- export { PluginManager } from "./plugins";
4
- export { PluginLoader } from "./plugins/loader";
5
- export { MCPClient, MCPRegistry } from "./mcp";
@@ -1,40 +0,0 @@
1
- import { readFileSync, writeFileSync, existsSync, mkdirSync, rmSync } from "fs";
2
- import { join } from "path";
3
- export class IndexCache {
4
- cachePath;
5
- cache = null;
6
- constructor(cacheDir) {
7
- this.cachePath = join(cacheDir, "index-cache.json");
8
- }
9
- load() {
10
- if (this.cache)
11
- return this.cache;
12
- if (!existsSync(this.cachePath))
13
- return null;
14
- try {
15
- this.cache = JSON.parse(readFileSync(this.cachePath, "utf-8"));
16
- return this.cache;
17
- }
18
- catch {
19
- return null;
20
- }
21
- }
22
- save(result) {
23
- this.cache = result;
24
- const dir = join(this.cachePath, "..");
25
- if (!existsSync(dir))
26
- mkdirSync(dir, { recursive: true });
27
- writeFileSync(this.cachePath, JSON.stringify(result), "utf-8");
28
- }
29
- invalidate() {
30
- this.cache = null;
31
- if (existsSync(this.cachePath)) {
32
- try {
33
- rmSync(this.cachePath);
34
- }
35
- catch {
36
- /* ignore */
37
- }
38
- }
39
- }
40
- }
@@ -1,3 +0,0 @@
1
- export { Indexer } from "./walker";
2
- export { IndexCache } from "./cache";
3
- export { IndexerModule } from "./module";
@@ -1,246 +0,0 @@
1
- import { dirname } from "path";
2
- import { Indexer } from "./walker";
3
- import { IndexCache } from "./cache";
4
- import { buildProjectProfileLine } from "./project-profile";
5
- import { t } from "../../i18n/index";
6
- export class IndexerModule {
7
- name = "indexer";
8
- indexer;
9
- cache;
10
- baseDir;
11
- index = null;
12
- rebuildTimeout = null;
13
- constructor(opts) {
14
- this.baseDir = opts.baseDir;
15
- this.indexer = new Indexer(opts.baseDir);
16
- this.cache = new IndexCache(opts.cacheDir);
17
- }
18
- async buildIndex() {
19
- if (this.index)
20
- return this.index;
21
- const cached = this.cache.load();
22
- if (cached) {
23
- this.index = cached;
24
- return cached;
25
- }
26
- try {
27
- const result = await this.indexer.walk();
28
- this.cache.save(result);
29
- this.index = result;
30
- return result;
31
- }
32
- catch {
33
- return null;
34
- }
35
- }
36
- async refresh() {
37
- this.cache.invalidate();
38
- this.index = null;
39
- return this.buildIndex();
40
- }
41
- find(query) {
42
- if (!this.index)
43
- return [];
44
- const q = query.toLowerCase();
45
- return this.index.files.filter((f) => {
46
- const path = f.path.toLowerCase();
47
- return path.includes(q) || f.exports.some((e) => e.toLowerCase().includes(q));
48
- });
49
- }
50
- watch() {
51
- this.unwatch();
52
- try {
53
- this.indexer.watch((_event, filename) => {
54
- if (!filename)
55
- return;
56
- if (this.rebuildTimeout)
57
- clearTimeout(this.rebuildTimeout);
58
- this.rebuildTimeout = setTimeout(() => {
59
- this.refresh().catch(() => { });
60
- }, 2000);
61
- });
62
- }
63
- catch {
64
- // Watching is best-effort; manual refresh still works.
65
- }
66
- }
67
- unwatch() {
68
- if (this.rebuildTimeout) {
69
- clearTimeout(this.rebuildTimeout);
70
- this.rebuildTimeout = null;
71
- }
72
- this.indexer.unwatch();
73
- }
74
- getSystemPromptBlock() {
75
- if (!this.index)
76
- return null;
77
- const content = this.formatMap(this.index);
78
- return {
79
- content,
80
- priority: "normal",
81
- essential: false,
82
- estimatedTokens: this.estimateTokens(content),
83
- };
84
- }
85
- getToolDefinitions() {
86
- return [this.createProjectMapTool()];
87
- }
88
- getPlugin() {
89
- return {
90
- name: "indexer",
91
- onSessionStart: () => {
92
- this.buildIndex().catch(() => { });
93
- this.watch();
94
- },
95
- onSessionEnd: () => {
96
- this.unwatch();
97
- },
98
- };
99
- }
100
- formatMap(result) {
101
- const summary = this.indexer.summarize(result);
102
- const stackLine = buildProjectProfileLine(this.baseDir);
103
- const dirCounts = this.getDirectoryCounts(result);
104
- const topDirs = Object.entries(dirCounts)
105
- .sort((a, b) => b[1] - a[1])
106
- .slice(0, 10)
107
- .map(([dir, count]) => `${dir} (${count})`)
108
- .join(", ") || "-";
109
- const fileLines = result.files.slice(0, 100).map((f) => {
110
- const path = f.path.replace(/\\/g, "/");
111
- const exports = f.exports.length > 0 ? `: ${f.exports.join(", ")}` : "";
112
- return `- ${path}${exports}`;
113
- });
114
- const more = result.files.length > 100
115
- ? `\n${t("indexer.and_more", { count: result.files.length - 100 })}`
116
- : "";
117
- const duplicates = this.findDuplicateBasenames(result);
118
- return [
119
- `${t("indexer.map_header")} (${this.baseDir})`,
120
- summary,
121
- ...(stackLine ? [stackLine] : []),
122
- `${t("indexer.top_directories")}: ${topDirs}`,
123
- ...(duplicates.length > 0 ? [t("indexer.duplicates", { names: duplicates.join(", ") })] : []),
124
- `${t("indexer.files")}:` + (fileLines.length > 0 ? "" : " " + t("indexer.empty")),
125
- ...fileLines,
126
- more,
127
- ].join("\n");
128
- }
129
- /**
130
- * Find files that share a basename across different extensions in the same
131
- * directory (e.g. `ProductCard.js` + `ProductCard.tsx`). This is a purely
132
- * structural fact about the file tree β€” a stale transpiled twin may shadow
133
- * the real source at build time. Flagging it is not task classification, so
134
- * it does not violate the no-keyword-matching rule; the model decides what
135
- * to do with the information.
136
- */
137
- findDuplicateBasenames(result) {
138
- const byDir = {};
139
- for (const f of result.files) {
140
- const path = f.path.replace(/\\/g, "/");
141
- const idx = path.lastIndexOf("/");
142
- const dir = idx >= 0 ? path.slice(0, idx) : "";
143
- const name = path.slice(idx + 1);
144
- const dot = name.lastIndexOf(".");
145
- if (dot <= 0)
146
- continue;
147
- const base = name.slice(0, dot);
148
- const ext = name.slice(dot + 1);
149
- if (!byDir[dir])
150
- byDir[dir] = new Map();
151
- const list = byDir[dir].get(base) ?? [];
152
- list.push(ext);
153
- byDir[dir].set(base, list);
154
- }
155
- const dups = [];
156
- for (const dir of Object.keys(byDir).sort()) {
157
- for (const [base, exts] of byDir[dir]) {
158
- if (exts.length < 2)
159
- continue;
160
- const uniqueExts = [...new Set(exts)].sort();
161
- const dirPrefix = dir ? `${dir}/` : "";
162
- dups.push(`${dirPrefix}${base}.{${uniqueExts.join(",")}}`);
163
- }
164
- }
165
- return dups;
166
- }
167
- getDirectoryCounts(result) {
168
- const counts = {};
169
- for (const f of result.files) {
170
- const normalized = f.path.replace(/\\/g, "/");
171
- const dir = dirname(normalized);
172
- const key = dir === "." ? "(root)" : dir;
173
- counts[key] = (counts[key] || 0) + 1;
174
- }
175
- return counts;
176
- }
177
- estimateTokens(content) {
178
- return Math.ceil(content.length / 4);
179
- }
180
- createProjectMapTool() {
181
- return {
182
- name: "project_map",
183
- icon: "πŸ—ΊοΈ",
184
- alwaysOn: true,
185
- description: t("indexer.project_map_desc"),
186
- parameters: {
187
- type: "object",
188
- properties: {
189
- action: {
190
- type: "string",
191
- enum: ["summary", "refresh", "find"],
192
- description: t("indexer.project_map_action_desc"),
193
- },
194
- query: {
195
- type: "string",
196
- description: t("indexer.project_map_query_desc"),
197
- },
198
- },
199
- required: ["action"],
200
- },
201
- handler: async (_ctx, args) => {
202
- const action = String(args.action || "summary");
203
- if (action === "refresh") {
204
- const result = await this.refresh();
205
- const summary = result ? this.indexer.summarize(result) : t("indexer.empty");
206
- const stackLine = result ? buildProjectProfileLine(this.baseDir) : null;
207
- const output = summary && stackLine ? `${summary}\n${stackLine}` : summary;
208
- return this.makeResult(t("indexer.refreshed", { summary: output }));
209
- }
210
- if (action === "find") {
211
- const query = String(args.query || "").toLowerCase();
212
- if (!query)
213
- return { success: false, output: t("tool.invalid_params") };
214
- const matches = this.find(query);
215
- if (matches.length === 0) {
216
- return this.makeResult(t("indexer.no_matches", { query }));
217
- }
218
- const lines = matches
219
- .map((f) => {
220
- const path = f.path.replace(/\\/g, "/");
221
- const exports = f.exports.length > 0 ? `: ${f.exports.join(", ")}` : "";
222
- return `- ${path}${exports}`;
223
- })
224
- .join("\n");
225
- return this.makeResult(t("indexer.find_results", {
226
- count: matches.length,
227
- results: lines,
228
- }));
229
- }
230
- if (!this.index) {
231
- await this.buildIndex();
232
- }
233
- if (!this.index) {
234
- return this.makeResult(t("indexer.not_indexed"));
235
- }
236
- const summary = this.indexer.summarize(this.index);
237
- const stackLine = buildProjectProfileLine(this.baseDir);
238
- const output = summary && stackLine ? `${summary}\n${stackLine}` : summary;
239
- return this.makeResult(t("indexer.summary", { summary: output }));
240
- },
241
- };
242
- }
243
- makeResult(output) {
244
- return { success: true, output, display: output };
245
- }
246
- }