micro-models-agent 0.51.1 → 0.51.2

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 (218) hide show
  1. package/README.md +358 -358
  2. package/dist/main.js +817 -573
  3. package/dist/modules/browser/bridge-server.mjs +202 -202
  4. package/dist/skills/builtin/git.md +36 -36
  5. package/dist/skills/builtin/typescript.md +35 -35
  6. package/package.json +48 -48
  7. package/dist/cli/commands.js +0 -323
  8. package/dist/cli/completer.js +0 -167
  9. package/dist/cli/index.js +0 -2
  10. package/dist/cli/main.js +0 -165
  11. package/dist/cli/plugin-commands.js +0 -36
  12. package/dist/cli/repl-commands.js +0 -661
  13. package/dist/cli/repl.js +0 -616
  14. package/dist/cli/run-result.js +0 -22
  15. package/dist/cli/security-commands.js +0 -164
  16. package/dist/cli/setup.js +0 -231
  17. package/dist/config/config.js +0 -249
  18. package/dist/config/defaults.js +0 -124
  19. package/dist/config/experts.js +0 -15
  20. package/dist/config/index.js +0 -3
  21. package/dist/config/security.js +0 -193
  22. package/dist/config/types.js +0 -1
  23. package/dist/core/agent-moe.js +0 -102
  24. package/dist/core/agent.js +0 -886
  25. package/dist/core/bootstrap.js +0 -404
  26. package/dist/core/index.js +0 -2
  27. package/dist/core/prompt-builder.js +0 -76
  28. package/dist/core/session-logger.js +0 -197
  29. package/dist/core/types.js +0 -1
  30. package/dist/core/version.js +0 -24
  31. package/dist/core/workspace.js +0 -76
  32. package/dist/i18n/en.json +0 -598
  33. package/dist/i18n/index.js +0 -46
  34. package/dist/i18n/ru.json +0 -598
  35. package/dist/index.js +0 -22
  36. package/dist/llm/image-utils.js +0 -143
  37. package/dist/llm/index.js +0 -4
  38. package/dist/llm/model-loader.js +0 -78
  39. package/dist/llm/openai-compat.js +0 -359
  40. package/dist/llm/orchestrator.js +0 -198
  41. package/dist/llm/provider.js +0 -10
  42. package/dist/llm/response.js +0 -39
  43. package/dist/llm/token-counter.js +0 -39
  44. package/dist/llm/types.js +0 -1
  45. package/dist/logger/app-logger.js +0 -143
  46. package/dist/logger/file-log.js +0 -151
  47. package/dist/logger/index.js +0 -1
  48. package/dist/migration/backup.js +0 -45
  49. package/dist/migration/detect.js +0 -50
  50. package/dist/migration/index.js +0 -2
  51. package/dist/modules/artifacts/store.js +0 -61
  52. package/dist/modules/browser/actions.js +0 -76
  53. package/dist/modules/browser/bridge-client.js +0 -199
  54. package/dist/modules/browser/bridge-path.js +0 -10
  55. package/dist/modules/browser/cookie-store.js +0 -24
  56. package/dist/modules/browser/driver.js +0 -136
  57. package/dist/modules/browser/index.js +0 -7
  58. package/dist/modules/browser/module.js +0 -29
  59. package/dist/modules/browser/session.js +0 -338
  60. package/dist/modules/browser/snapshot.js +0 -148
  61. package/dist/modules/browser/types.js +0 -12
  62. package/dist/modules/certification/cli.js +0 -174
  63. package/dist/modules/certification/fact-checker.js +0 -82
  64. package/dist/modules/certification/loader.js +0 -105
  65. package/dist/modules/certification/manifest.js +0 -50
  66. package/dist/modules/certification/runner.js +0 -159
  67. package/dist/modules/certification/scenarios.js +0 -124
  68. package/dist/modules/certification/types.js +0 -1
  69. package/dist/modules/context/chunk-query.js +0 -100
  70. package/dist/modules/context/fact-extractor.js +0 -162
  71. package/dist/modules/context/history.js +0 -15
  72. package/dist/modules/context/index.js +0 -1
  73. package/dist/modules/context/manager.js +0 -423
  74. package/dist/modules/execution/audit-runners.js +0 -152
  75. package/dist/modules/execution/auditor.js +0 -218
  76. package/dist/modules/execution/execution-plugin.js +0 -272
  77. package/dist/modules/execution/index.js +0 -8
  78. package/dist/modules/execution/module.js +0 -436
  79. package/dist/modules/execution/moe-executor.js +0 -291
  80. package/dist/modules/execution/plan-coverage.js +0 -68
  81. package/dist/modules/execution/plan-persister.js +0 -46
  82. package/dist/modules/execution/plan-store.js +0 -157
  83. package/dist/modules/execution/plan-tool.js +0 -508
  84. package/dist/modules/execution/plan-validator.js +0 -153
  85. package/dist/modules/execution/planner.js +0 -90
  86. package/dist/modules/execution/stuck-detector.js +0 -510
  87. package/dist/modules/execution/tracker.js +0 -67
  88. package/dist/modules/execution/types.js +0 -1
  89. package/dist/modules/execution/verifier.js +0 -222
  90. package/dist/modules/execution/windows-commands.js +0 -41
  91. package/dist/modules/hallucination/confidence.js +0 -66
  92. package/dist/modules/hallucination/consistency.js +0 -26
  93. package/dist/modules/hallucination/detector.js +0 -43
  94. package/dist/modules/hallucination/factual.js +0 -129
  95. package/dist/modules/hallucination/index.js +0 -5
  96. package/dist/modules/hallucination/js-identifiers.js +0 -262
  97. package/dist/modules/hallucination/llm-judge.js +0 -101
  98. package/dist/modules/index.js +0 -5
  99. package/dist/modules/indexer/cache.js +0 -40
  100. package/dist/modules/indexer/index.js +0 -3
  101. package/dist/modules/indexer/module.js +0 -245
  102. package/dist/modules/indexer/project-profile.js +0 -183
  103. package/dist/modules/indexer/walker.js +0 -101
  104. package/dist/modules/lsp/check-tool.js +0 -58
  105. package/dist/modules/lsp/client.js +0 -278
  106. package/dist/modules/lsp/command.js +0 -60
  107. package/dist/modules/lsp/config.js +0 -135
  108. package/dist/modules/lsp/index.js +0 -3
  109. package/dist/modules/lsp/module.js +0 -232
  110. package/dist/modules/lsp/probe.js +0 -76
  111. package/dist/modules/lsp/project-root.js +0 -32
  112. package/dist/modules/lsp/startup-check.js +0 -141
  113. package/dist/modules/lsp/types.js +0 -1
  114. package/dist/modules/mcp/client.js +0 -399
  115. package/dist/modules/mcp/index.js +0 -3
  116. package/dist/modules/mcp/module.js +0 -142
  117. package/dist/modules/mcp/registry.js +0 -15
  118. package/dist/modules/memory/index.js +0 -1
  119. package/dist/modules/memory/module.js +0 -96
  120. package/dist/modules/memory/search.js +0 -42
  121. package/dist/modules/memory/store.js +0 -69
  122. package/dist/modules/pipelines/engine.js +0 -60
  123. package/dist/modules/pipelines/index.js +0 -3
  124. package/dist/modules/pipelines/parser.js +0 -56
  125. package/dist/modules/pipelines/template.js +0 -14
  126. package/dist/modules/plugins/builtin/lint-on-write.js +0 -231
  127. package/dist/modules/plugins/builtin/notify.js +0 -9
  128. package/dist/modules/plugins/index.js +0 -1
  129. package/dist/modules/plugins/loader.js +0 -70
  130. package/dist/modules/plugins/manager.js +0 -217
  131. package/dist/modules/plugins/types.js +0 -1
  132. package/dist/modules/processes/detect.js +0 -34
  133. package/dist/modules/processes/index.js +0 -2
  134. package/dist/modules/processes/registry.js +0 -327
  135. package/dist/modules/processes/runner.js +0 -23
  136. package/dist/modules/registry.js +0 -47
  137. package/dist/modules/security/audit-log.js +0 -136
  138. package/dist/modules/security/audit-notifier.js +0 -292
  139. package/dist/modules/security/command-validator.js +0 -205
  140. package/dist/modules/security/content-scanner.js +0 -53
  141. package/dist/modules/security/data-sanitizer.js +0 -89
  142. package/dist/modules/security/encryption.js +0 -242
  143. package/dist/modules/security/index.js +0 -14
  144. package/dist/modules/security/network-validator.js +0 -71
  145. package/dist/modules/security/path-validator.js +0 -207
  146. package/dist/modules/security/rate-limiter.js +0 -119
  147. package/dist/modules/security/security-policies.js +0 -531
  148. package/dist/modules/security/session-encryption.js +0 -210
  149. package/dist/modules/security/session-isolation.js +0 -95
  150. package/dist/modules/session/index.js +0 -3
  151. package/dist/modules/session/manager.js +0 -172
  152. package/dist/modules/session/module.js +0 -24
  153. package/dist/modules/session/store.js +0 -222
  154. package/dist/modules/session/types.js +0 -1
  155. package/dist/modules/skills/index.js +0 -2
  156. package/dist/modules/skills/loader.js +0 -72
  157. package/dist/modules/skills/matcher.js +0 -27
  158. package/dist/modules/skills/module.js +0 -129
  159. package/dist/modules/types.js +0 -1
  160. package/dist/modules/updater/checker.js +0 -96
  161. package/dist/modules/updater/index.js +0 -2
  162. package/dist/modules/updater/module.js +0 -116
  163. package/dist/modules/user-profile/compressor.js +0 -16
  164. package/dist/modules/user-profile/index.js +0 -1
  165. package/dist/modules/user-profile/profile.js +0 -68
  166. package/dist/tools/approve.js +0 -32
  167. package/dist/tools/attach-image.js +0 -89
  168. package/dist/tools/bash.js +0 -496
  169. package/dist/tools/browser.js +0 -114
  170. package/dist/tools/chunk-query.js +0 -99
  171. package/dist/tools/create-dir.js +0 -55
  172. package/dist/tools/delete-file.js +0 -62
  173. package/dist/tools/download-file.js +0 -116
  174. package/dist/tools/edit-file.js +0 -79
  175. package/dist/tools/enable-tools.js +0 -58
  176. package/dist/tools/executor.js +0 -144
  177. package/dist/tools/file-info.js +0 -46
  178. package/dist/tools/filter-tools.js +0 -17
  179. package/dist/tools/glob-tool.js +0 -26
  180. package/dist/tools/grep-tool.js +0 -84
  181. package/dist/tools/hidden-tools-block.js +0 -37
  182. package/dist/tools/index.js +0 -78
  183. package/dist/tools/list-dir.js +0 -48
  184. package/dist/tools/load-skill.js +0 -42
  185. package/dist/tools/mcp-call.js +0 -68
  186. package/dist/tools/move-file.js +0 -85
  187. package/dist/tools/path-utils.js +0 -51
  188. package/dist/tools/pipeline-run.js +0 -144
  189. package/dist/tools/preview.js +0 -2
  190. package/dist/tools/process-kill.js +0 -29
  191. package/dist/tools/process-list.js +0 -36
  192. package/dist/tools/process-log.js +0 -45
  193. package/dist/tools/question.js +0 -140
  194. package/dist/tools/read-file.js +0 -91
  195. package/dist/tools/recall.js +0 -117
  196. package/dist/tools/registry.js +0 -47
  197. package/dist/tools/remember.js +0 -67
  198. package/dist/tools/scope-check.js +0 -30
  199. package/dist/tools/search-history.js +0 -84
  200. package/dist/tools/subagent.js +0 -196
  201. package/dist/tools/types.js +0 -1
  202. package/dist/tools/user-input.js +0 -123
  203. package/dist/tools/web-browse.js +0 -86
  204. package/dist/tools/web-fetch.js +0 -98
  205. package/dist/tools/web-search.js +0 -78
  206. package/dist/tools/write-file.js +0 -81
  207. package/dist/ui/box.js +0 -77
  208. package/dist/ui/colors.js +0 -4
  209. package/dist/ui/diff.js +0 -178
  210. package/dist/ui/index.js +0 -6
  211. package/dist/ui/line-editor.js +0 -703
  212. package/dist/ui/line-math.js +0 -69
  213. package/dist/ui/md-formatter.js +0 -212
  214. package/dist/ui/output.js +0 -13
  215. package/dist/ui/plan-view.js +0 -103
  216. package/dist/ui/renderer.js +0 -209
  217. package/dist/ui/spinner.js +0 -70
  218. package/dist/ui/table.js +0 -144
@@ -1,69 +0,0 @@
1
- import stringWidth from "string-width";
2
- const ANSI_RE = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
3
- export function stripAnsi(s) {
4
- return s.replace(ANSI_RE, "");
5
- }
6
- export function charLen(s) {
7
- return Array.from(s).length;
8
- }
9
- export function wrapLine(line, width) {
10
- const w = width > 0 ? width : 80;
11
- const chars = Array.from(line);
12
- const rows = [];
13
- let start = 0;
14
- let cells = 0;
15
- for (let i = 0; i < chars.length; i++) {
16
- const ch = chars[i];
17
- if (ch === "\n") {
18
- rows.push({ text: chars.slice(start, i).join(""), charStart: start });
19
- start = i + 1;
20
- cells = 0;
21
- continue;
22
- }
23
- const cw = stringWidth(ch);
24
- if (cells + cw > w && cells > 0) {
25
- rows.push({ text: chars.slice(start, i).join(""), charStart: start });
26
- start = i;
27
- cells = cw;
28
- }
29
- else {
30
- cells += cw;
31
- }
32
- }
33
- rows.push({ text: chars.slice(start).join(""), charStart: start });
34
- return rows;
35
- }
36
- export function buildLayout(lines, width) {
37
- const rows = [];
38
- for (let b = 0; b < lines.length; b++) {
39
- for (const r of wrapLine(lines[b], width)) {
40
- rows.push({ bufRow: b, charStart: r.charStart, text: r.text });
41
- }
42
- }
43
- return rows;
44
- }
45
- export function layoutIndexFor(rows, bufRow, col) {
46
- let idx = 0;
47
- for (let i = 0; i < rows.length; i++) {
48
- if (rows[i].bufRow === bufRow && rows[i].charStart <= col)
49
- idx = i;
50
- }
51
- return idx;
52
- }
53
- export function visualColAt(rows, idx, col) {
54
- const r = rows[idx];
55
- const upTo = col - r.charStart;
56
- return stringWidth(Array.from(r.text).slice(0, upTo).join(""));
57
- }
58
- export function charOffsetFor(rows, idx, visualCol) {
59
- const r = rows[idx];
60
- const chars = Array.from(r.text);
61
- let cells = 0;
62
- for (let i = 0; i < chars.length; i++) {
63
- const cw = stringWidth(chars[i]);
64
- if (cells + cw > visualCol)
65
- return r.charStart + i;
66
- cells += cw;
67
- }
68
- return r.charStart + chars.length;
69
- }
@@ -1,212 +0,0 @@
1
- import { pc } from "./colors";
2
- import { t } from "../i18n/index";
3
- import { formatTable, getTerminalWidth } from "./table";
4
- const 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;
5
- const STRING = /('[^']*'|"[^"]*"|`[^`]*`)/g;
6
- const COMMENT = /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|#[^\n]*)/g;
7
- const NUMBER = /\b(\d+\.?\d*)\b/g;
8
- const TAG = /<\/?([A-Z][a-zA-Z0-9]*|[a-z][a-zA-Z0-9-]*)/g;
9
- const ATTR = /\b([a-zA-Z-]+=)"([^"]*)"/g;
10
- function highlight(code, lang) {
11
- if (lang === "html" || lang === "xml" || lang === "svg") {
12
- code = code.replace(COMMENT, (m) => pc.dim(pc.green(m)));
13
- code = code.replace(ATTR, (_m, attr, val) => pc.yellow(attr) + "=" + pc.green('"' + val + '"'));
14
- code = code.replace(TAG, (_m, tag) => "<" + pc.cyan(tag));
15
- }
16
- else if (lang === "css" || lang === "scss" || lang === "less") {
17
- code = code.replace(COMMENT, (m) => pc.dim(pc.green(m)));
18
- code = code.replace(STRING, (m) => pc.green(m));
19
- code = code.replace(NUMBER, (m) => pc.yellow(m));
20
- }
21
- else if (lang === "bash" || lang === "sh" || lang === "shell" || lang === "zsh") {
22
- code = code.replace(COMMENT, (m) => pc.dim(pc.green(m)));
23
- code = code.replace(STRING, (m) => pc.green(m));
24
- }
25
- else if (lang === "json") {
26
- code = code.replace(STRING, (m) => pc.green(m));
27
- code = code.replace(NUMBER, (m) => pc.yellow(m));
28
- }
29
- else {
30
- // js, ts, jsx, tsx, and fallback
31
- code = code.replace(COMMENT, (m) => pc.dim(pc.green(m)));
32
- code = code.replace(STRING, (m) => pc.green(m));
33
- code = code.replace(KW, (m) => pc.magenta(m));
34
- code = code.replace(NUMBER, (m) => pc.yellow(m));
35
- }
36
- return code;
37
- }
38
- function isTableRow(line) {
39
- const trimmed = line.trim();
40
- if (!trimmed.startsWith("|"))
41
- return false;
42
- const pipes = trimmed.match(/\|/g);
43
- return (pipes?.length ?? 0) >= 2;
44
- }
45
- function isHorizontalRule(line) {
46
- return /^(-{3,}|\*{3,}|_{3,})\s*$/.test(line.trim());
47
- }
48
- export class FormattingStream {
49
- buffer = "";
50
- inCodeBlock = false;
51
- codeLang = "";
52
- codeLines = [];
53
- tableBuffer = [];
54
- onWrite;
55
- width;
56
- constructor(onWrite, width) {
57
- this.onWrite = onWrite;
58
- this.width = width ?? getTerminalWidth();
59
- }
60
- write(chunk) {
61
- this.buffer += chunk;
62
- let idx;
63
- while ((idx = this.buffer.indexOf("\n")) !== -1) {
64
- const line = this.buffer.slice(0, idx);
65
- this.buffer = this.buffer.slice(idx + 1);
66
- this.processLine(line);
67
- }
68
- }
69
- flush() {
70
- if (this.inCodeBlock && this.codeLines.length > 0) {
71
- this.emitCodeBlock();
72
- }
73
- if (this.tableBuffer.length > 0) {
74
- this.flushTable();
75
- }
76
- if (this.buffer.length > 0) {
77
- const line = this.buffer;
78
- this.buffer = "";
79
- if (line.trim() === "```" || line.trim().startsWith("```")) {
80
- if (this.codeLines.length > 0) {
81
- this.emitCodeBlock();
82
- }
83
- return;
84
- }
85
- this.onWrite(this.formatLine(line));
86
- }
87
- }
88
- processLine(line) {
89
- if (line.trim() === "```" || line.trim().startsWith("```")) {
90
- if (this.inCodeBlock) {
91
- this.emitCodeBlock();
92
- }
93
- else {
94
- this.inCodeBlock = true;
95
- this.codeLang = line.trim().slice(3).trim();
96
- this.codeLines = [];
97
- }
98
- return;
99
- }
100
- if (this.inCodeBlock) {
101
- this.codeLines.push(line);
102
- return;
103
- }
104
- if (isTableRow(line)) {
105
- this.tableBuffer.push(line);
106
- return;
107
- }
108
- if (this.tableBuffer.length > 0) {
109
- this.flushTable();
110
- }
111
- this.onWrite(this.formatLine(line));
112
- }
113
- flushTable() {
114
- const lines = this.tableBuffer;
115
- this.tableBuffer = [];
116
- const hasSeparator = lines.length >= 2 && /^\s*\|?[\s:|-]+\|?\s*$/.test(lines[1].trim());
117
- if (hasSeparator) {
118
- for (const l of formatTable(lines, { maxWidth: this.width })) {
119
- this.onWrite(l);
120
- }
121
- }
122
- else {
123
- for (const l of lines) {
124
- this.onWrite(this.formatLine(l));
125
- }
126
- }
127
- }
128
- emitCodeBlock() {
129
- this.inCodeBlock = false;
130
- if (this.codeLines.length > 0) {
131
- const code = this.codeLines.join("\n");
132
- const highlighted = highlight(code, this.codeLang);
133
- const lang = this.codeLang ? ` ${this.codeLang} ` : " ";
134
- const top = pc.dim(`┌─${lang}${"─".repeat(Math.max(0, this.width - 3 - lang.length))}┐`);
135
- this.onWrite(top);
136
- for (const l of highlighted.split("\n")) {
137
- this.onWrite(pc.dim("│ ") + l);
138
- }
139
- this.onWrite(pc.dim(`└${"─".repeat(Math.max(0, this.width - 1))}┘`));
140
- }
141
- this.codeLines = [];
142
- this.codeLang = "";
143
- }
144
- formatLine(line) {
145
- let result = line;
146
- const heading = result.match(/^(#{1,6})\s+(.+)$/);
147
- if (heading) {
148
- const level = heading[1].length;
149
- const content = this.formatInline(heading[2]);
150
- if (level === 1)
151
- return pc.cyan(pc.bold(pc.underline(content)));
152
- return pc.cyan(pc.bold(content));
153
- }
154
- if (isHorizontalRule(result)) {
155
- return pc.dim("─".repeat(Math.max(0, Math.min(this.width, 60))));
156
- }
157
- const quote = result.match(/^(>+)\s?(.*)$/);
158
- if (quote) {
159
- const depth = Math.min(quote[1].length, 4);
160
- const marker = pc.dim("▍".repeat(depth));
161
- return `${marker} ${this.formatInline(quote[2])}`;
162
- }
163
- const checkbox = result.match(/^[-*]\s+\[([ xX])\]\s+(.+)$/);
164
- if (checkbox) {
165
- const checked = checkbox[1].toLowerCase() === "x";
166
- const mark = checked ? pc.green("✓") : pc.dim("☐");
167
- return ` ${mark} ${this.formatInline(checkbox[2])}`;
168
- }
169
- const ordered = result.match(/^(\d+)[.)]\s+(.+)$/);
170
- if (ordered) {
171
- return ` ${pc.yellow(ordered[1])}. ${this.formatInline(ordered[2])}`;
172
- }
173
- const bullet = result.match(/^[-*]\s+(.+)$/);
174
- if (bullet) {
175
- return ` ${pc.dim("•")} ${this.formatInline(bullet[1])}`;
176
- }
177
- return this.formatInline(result);
178
- }
179
- formatInline(text) {
180
- const codeSpans = [];
181
- let result = text.replace(/`([^`]+)`/g, (_m, c) => {
182
- codeSpans.push(pc.yellow(c));
183
- return `\u0000${codeSpans.length - 1}\u0000`;
184
- });
185
- result = result.replace(/\*\*(.+?)\*\*/g, (_, s) => pc.bold(s));
186
- result = result.replace(/~~(.+?)~~/g, (_, s) => pc.strikethrough(s));
187
- result = result.replace(/\*([^*]+)\*/g, (_, s) => pc.italic(s));
188
- result = result.replace(/(^|\s)_([^_\n]+)_(?=\s|$)/g, (_m, pre, s) => pre + pc.italic(s));
189
- result = result.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_, label, url) => {
190
- const short = url.length > 80 ? url.slice(0, 77) + "…" : url;
191
- return `${pc.cyan(label)} ${pc.dim(`(${short})`)}`;
192
- });
193
- result = result.replace(/\u0000(\d+)\u0000/g, (_m, i) => codeSpans[Number(i)]);
194
- return result;
195
- }
196
- }
197
- export function formatMarkdown(text) {
198
- const lines = [];
199
- const stream = new FormattingStream((l) => lines.push(l));
200
- stream.write(text);
201
- stream.flush();
202
- return lines.join("\n");
203
- }
204
- export function formatError(text) {
205
- return pc.red(pc.bold(t("ui.error_prefix")) + text);
206
- }
207
- export function formatSuccess(text) {
208
- return pc.green(pc.bold(t("ui.success_prefix")) + text);
209
- }
210
- export function formatWarning(text) {
211
- return pc.yellow(pc.bold(t("ui.warning_prefix")) + text);
212
- }
package/dist/ui/output.js DELETED
@@ -1,13 +0,0 @@
1
- import { formatMarkdown, formatError, formatSuccess, formatWarning } from "./md-formatter";
2
- export function writeOutput(text) {
3
- process.stdout.write(formatMarkdown(text) + "\n");
4
- }
5
- export function writeError(text) {
6
- process.stderr.write(formatError(text) + "\n");
7
- }
8
- export function writeSuccess(text) {
9
- process.stdout.write(formatSuccess(text) + "\n");
10
- }
11
- export function writeWarning(text) {
12
- process.stdout.write(formatWarning(text) + "\n");
13
- }
@@ -1,103 +0,0 @@
1
- import { existsSync, readFileSync } from "fs";
2
- import { join } from "path";
3
- import { pc } from "./colors";
4
- import { extractFileLikeTokens, stripUrls } from "../modules/hallucination/js-identifiers";
5
- import { t } from "../i18n/index";
6
- export function readActivePlan(baseDir) {
7
- const p = join(baseDir, ".mma", "plans", "active.json");
8
- if (!existsSync(p))
9
- return null;
10
- try {
11
- const raw = readFileSync(p, "utf-8");
12
- if (!raw.trim())
13
- return null;
14
- const parsed = JSON.parse(raw);
15
- if (!parsed || !Array.isArray(parsed.steps))
16
- return null;
17
- return {
18
- id: parsed.id || "plan",
19
- title: parsed.title || "Plan",
20
- steps: parsed.steps,
21
- createdAt: parsed.createdAt || new Date().toISOString(),
22
- baseDir: parsed.baseDir || baseDir,
23
- name: parsed.name,
24
- };
25
- }
26
- catch {
27
- return null;
28
- }
29
- }
30
- export function currentStepIndex(plan) {
31
- const idx = plan.steps.findIndex((s) => s.status !== "done" && s.status !== "skipped");
32
- return idx === -1 ? 0 : idx;
33
- }
34
- function stepMark(step) {
35
- switch (step.status) {
36
- case "done":
37
- return pc.green("[x]");
38
- case "in_progress":
39
- return pc.yellow("[*]");
40
- case "failed":
41
- return pc.red("[!]");
42
- case "skipped":
43
- return pc.dim("[-]");
44
- default:
45
- return pc.dim("[ ]");
46
- }
47
- }
48
- export function formatPlanChecklist(plan) {
49
- const done = plan.steps.filter((s) => s.status === "done" || s.status === "skipped").length;
50
- const total = plan.steps.length;
51
- const pct = total === 0 ? 0 : Math.round((done / total) * 100);
52
- const cur = currentStepIndex(plan);
53
- const barLen = 15;
54
- const filled = Math.round((pct / 100) * barLen);
55
- const bar = pc.green("█".repeat(filled)) + pc.dim("░".repeat(barLen - filled));
56
- const title = plan.title.replace(/^\[\d+[^]]*\]\s*/, "");
57
- const lines = [
58
- `${pc.cyan(`[${plan.id}]`)} ${pc.bold(title)} ${bar} ${pc.dim(`${done}/${total} ${pct}%`)}`,
59
- ];
60
- for (let i = 0; i < plan.steps.length; i++) {
61
- const step = plan.steps[i];
62
- const active = i === cur;
63
- const desc = active ? pc.yellow(step.description) : pc.dim(step.description);
64
- lines.push(` ${stepMark(step)} ${step.id}. ${desc}`);
65
- for (const sub of step.subtasks ?? []) {
66
- lines.push(` ${sub.done ? pc.green("[x]") : pc.dim("[ ]")} ${sub.text}`);
67
- }
68
- }
69
- return lines;
70
- }
71
- const STRUCTURAL_TOOLS = new Set([
72
- "plan",
73
- "todo",
74
- "verify",
75
- "project_map",
76
- "lsp_check",
77
- "enable_tools",
78
- ]);
79
- function truncate(s, max = 48) {
80
- return s.length > max ? `${s.slice(0, max - 1)}…` : s;
81
- }
82
- export function stepContextForTool(plan, tool, args) {
83
- if (!plan || STRUCTURAL_TOOLS.has(tool))
84
- return null;
85
- const argStr = JSON.stringify(args);
86
- const callPaths = extractFileLikeTokens(stripUrls(argStr)).map((p) => p.toLowerCase());
87
- if (callPaths.length > 0) {
88
- for (const step of plan.steps) {
89
- if (step.status === "done" || step.status === "skipped")
90
- continue;
91
- const stepPaths = extractFileLikeTokens(stripUrls(step.description)).map((p) => p.toLowerCase());
92
- if (stepPaths.length > 0 &&
93
- stepPaths.some((s) => callPaths.some((c) => c.includes(s) || s.includes(c)))) {
94
- return t("ui.step_context", { id: step.id, desc: truncate(step.description) });
95
- }
96
- }
97
- }
98
- const cur = currentStepIndex(plan);
99
- const step = plan.steps[cur];
100
- if (!step)
101
- return null;
102
- return t("ui.step_context", { id: step.id, desc: truncate(step.description) });
103
- }
@@ -1,209 +0,0 @@
1
- import { pc } from "./colors";
2
- import { FormattingStream } from "./md-formatter";
3
- import { Spinner } from "./spinner";
4
- import { box, divider } from "./box";
5
- import { getTerminalWidth } from "./table";
6
- import { t } from "../i18n/index";
7
- const GUTTER = " ";
8
- /** opencode-like leading marker per tool category. */
9
- export function toolMarker(tool) {
10
- switch (tool) {
11
- case "write_file":
12
- case "edit_file":
13
- case "create_dir":
14
- case "move_file":
15
- case "delete_file":
16
- return "←";
17
- case "read_file":
18
- case "list_dir":
19
- case "file_info":
20
- return "→";
21
- case "glob":
22
- case "grep":
23
- return "✱";
24
- case "bash":
25
- return "$";
26
- default:
27
- return "⚙";
28
- }
29
- }
30
- export function isRichTerminal() {
31
- return Boolean(process.stdout.isTTY) && !process.env.CI;
32
- }
33
- /** Short human-friendly summary of tool arguments. */
34
- export function summarizeArgs(args) {
35
- const preferred = ["path", "file", "query", "url", "command", "name"];
36
- for (const key of preferred) {
37
- const value = args[key];
38
- if (typeof value === "string" && value) {
39
- return value.length > 60 ? `${value.slice(0, 57)}…` : value;
40
- }
41
- }
42
- const serialized = JSON.stringify(args);
43
- if (!serialized || serialized === "{}")
44
- return "";
45
- return serialized.length > 60 ? `${serialized.slice(0, 57)}…` : serialized;
46
- }
47
- function friendlyTool(tool) {
48
- const key = `tool.friendly.${tool}`;
49
- const value = t(key);
50
- return value !== key ? value : tool;
51
- }
52
- /**
53
- * Streams agent events to the terminal. Rich mode (TTY) adds a spinner
54
- * and boxed tool cards; plain mode falls back to simple prefixed lines.
55
- * Colors come from `colors.ts`, disabled outside a TTY, in CI, or on NO_COLOR.
56
- */
57
- export class Renderer {
58
- rich;
59
- spinner;
60
- fmt;
61
- out;
62
- err;
63
- width;
64
- toolStyle;
65
- card = null;
66
- constructor(opts = {}) {
67
- this.rich = opts.rich ?? isRichTerminal();
68
- this.out = opts.out ?? process.stdout;
69
- this.err = opts.err ?? process.stderr;
70
- this.width = opts.width ?? getTerminalWidth();
71
- this.toolStyle = opts.toolStyle ?? "inline";
72
- this.spinner = new Spinner({
73
- enabled: this.rich && (opts.spinner ?? true),
74
- stream: this.err,
75
- width: this.width,
76
- });
77
- this.fmt = new FormattingStream((line) => this.out.write(`${line}\n`), this.width);
78
- }
79
- /** Final answer streamed from the model (markdown-formatted). */
80
- text(chunk) {
81
- this.endCard();
82
- this.spinner.stop();
83
- this.fmt.write(chunk);
84
- }
85
- /** Arbitrary status/meta text (tool output, reasoning, MoE status). */
86
- meta(chunk) {
87
- this.spinner.stop();
88
- if (this.card) {
89
- if (this.toolStyle === "inline") {
90
- this.writeInlineBody(chunk);
91
- }
92
- else {
93
- this.card.body.push(chunk);
94
- }
95
- }
96
- else {
97
- this.out.write(chunk);
98
- }
99
- }
100
- /** Stream tool body lines with the gutter prefix, skipping blank lines. */
101
- writeInlineBody(chunk) {
102
- for (const line of chunk.split("\n")) {
103
- if (line.trim() === "")
104
- continue;
105
- this.out.write(`${GUTTER}${line}\n`);
106
- }
107
- }
108
- /** Dimmed reasoning stream (already colored by the agent). */
109
- reasoning(chunk) {
110
- this.spinner.stop();
111
- this.out.write(pc.dim(chunk));
112
- }
113
- /** Model is loading / generating — show the thinking spinner. */
114
- thinkingStart() {
115
- this.spinner.start(t("ui.thinking"));
116
- }
117
- /** LLM call finished; clear the thinking spinner. */
118
- thinkingEnd() {
119
- this.spinner.stop();
120
- }
121
- toolStart(tool, args, stepContext) {
122
- this.endCard();
123
- this.spinner.stop();
124
- const summary = summarizeArgs(args);
125
- const step = stepContext ? ` ${pc.cyan(`← ${stepContext}`)}` : "";
126
- if (!this.rich) {
127
- this.out.write(`\n${pc.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}${step}\n`);
128
- return;
129
- }
130
- this.card = { tool, args, body: [], start: Date.now() };
131
- if (this.toolStyle === "inline") {
132
- const marker = toolMarker(tool);
133
- this.out.write(`\n${pc.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}${step}\n`);
134
- return;
135
- }
136
- this.spinner.start(`${pc.dim("⚙")} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}${step}`);
137
- }
138
- /** Live plan checklist — prints the plan block as-is (already colored). */
139
- planBlock(lines) {
140
- this.endCard();
141
- this.spinner.stop();
142
- for (const line of lines) {
143
- this.out.write(`${line}\n`);
144
- }
145
- }
146
- toolEnd(_tool, duration, error, ctxDelta) {
147
- this.spinner.stop();
148
- if (!this.rich) {
149
- if (ctxDelta !== undefined && ctxDelta !== 0) {
150
- const deltaStr = ctxDelta > 0 ? pc.green(`+${ctxDelta}`) : pc.yellow(`${ctxDelta} ↓`);
151
- this.out.write(`${pc.dim("ctx")} ${deltaStr}\n`);
152
- }
153
- return;
154
- }
155
- if (!this.card)
156
- return;
157
- const { tool, args, body } = this.card;
158
- const marker = error ? pc.red("✗") : pc.green("✓");
159
- let footer = `${marker} ${pc.dim(`${duration}ms`)}`;
160
- if (ctxDelta !== undefined && ctxDelta !== 0) {
161
- const deltaStr = ctxDelta > 0 ? pc.green(`+${ctxDelta}`) : pc.yellow(`${ctxDelta} ↓`);
162
- footer += ` ${pc.dim("ctx")} ${deltaStr}`;
163
- }
164
- if (this.toolStyle === "inline") {
165
- this.out.write(`${GUTTER}${footer}\n`);
166
- this.out.write(`${divider(this.width)}\n`);
167
- this.card = null;
168
- return;
169
- }
170
- const lines = [];
171
- const summary = summarizeArgs(args);
172
- if (summary)
173
- lines.push(pc.dim(summary));
174
- for (const chunk of body) {
175
- for (const line of chunk.split("\n")) {
176
- if (line.trim() !== "")
177
- lines.push(line);
178
- }
179
- }
180
- lines.push(footer);
181
- const title = `${marker} ${friendlyTool(tool)}`;
182
- for (const line of box(lines, { title, width: this.width })) {
183
- this.out.write(`${line}\n`);
184
- }
185
- this.card = null;
186
- }
187
- /** Raw pre-formatted text (diff blocks, warnings). */
188
- raw(text) {
189
- this.endCard();
190
- this.spinner.stop();
191
- this.out.write(text);
192
- }
193
- error(text) {
194
- this.endCard();
195
- this.spinner.stop();
196
- this.err.write(`${pc.red(text)}\n`);
197
- }
198
- flush() {
199
- this.endCard();
200
- this.spinner.stop();
201
- this.fmt.flush();
202
- }
203
- endCard() {
204
- if (!this.card)
205
- return;
206
- const { tool, start } = this.card;
207
- this.toolEnd(tool, Date.now() - start);
208
- }
209
- }
@@ -1,70 +0,0 @@
1
- import { pc } from "./colors";
2
- import stringWidth from "string-width";
3
- import { getTerminalWidth } from "./table";
4
- const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
5
- export function isSpinnerSupported(stream) {
6
- const s = stream ?? process.stderr;
7
- return Boolean(s.isTTY) && !process.env.CI;
8
- }
9
- /**
10
- * Zero-dependency ANSI spinner. Writes to stderr using a single
11
- * overwritten line (`\r` + text + clear-to-end). Disabled automatically
12
- * when the target stream is not a TTY.
13
- */
14
- export class Spinner {
15
- timer = null;
16
- frame = 0;
17
- message = "";
18
- enabled;
19
- stream;
20
- intervalMs;
21
- width;
22
- constructor(opts = {}) {
23
- this.stream = opts.stream ?? process.stderr;
24
- this.enabled = opts.enabled ?? isSpinnerSupported(this.stream);
25
- this.intervalMs = opts.intervalMs ?? 80;
26
- this.width = opts.width ?? getTerminalWidth();
27
- }
28
- get running() {
29
- return this.timer !== null;
30
- }
31
- start(message) {
32
- if (!this.enabled)
33
- return;
34
- this.stop();
35
- this.message = this.truncate(message);
36
- this.frame = 0;
37
- this.timer = setInterval(() => this.tick(), this.intervalMs);
38
- this.tick();
39
- }
40
- setMessage(message) {
41
- this.message = this.truncate(message);
42
- if (this.timer)
43
- this.tick();
44
- }
45
- stop() {
46
- if (this.timer) {
47
- clearInterval(this.timer);
48
- this.timer = null;
49
- this.stream.write("\r\x1b[K");
50
- }
51
- }
52
- truncate(text) {
53
- if (stringWidth(text) <= this.width - 2)
54
- return text;
55
- let acc = "";
56
- for (const ch of text) {
57
- if (stringWidth(acc + ch) > this.width - 3)
58
- break;
59
- acc += ch;
60
- }
61
- return acc + "…";
62
- }
63
- tick() {
64
- if (!this.timer)
65
- return;
66
- const frame = FRAMES[this.frame % FRAMES.length];
67
- this.frame++;
68
- this.stream.write("\r" + pc.cyan(frame) + " " + this.message + "\x1b[K");
69
- }
70
- }