micro-models-agent 0.61.0 → 0.62.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 +619 -595
- package/README.md +358 -358
- package/dist/certification/certifications.json +493 -493
- package/dist/cli/commands.js +447 -0
- package/dist/cli/completer.js +167 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/main.js +153 -0
- package/dist/cli/plugin-commands.js +36 -0
- package/dist/cli/repl-commands.js +761 -0
- package/dist/cli/repl.js +702 -0
- package/dist/cli/run-result.js +33 -0
- package/dist/cli/security-commands.js +164 -0
- package/dist/cli/setup.js +237 -0
- package/dist/config/config.js +276 -0
- package/dist/config/defaults.js +141 -0
- package/dist/config/domains.js +179 -0
- package/dist/config/experts.js +15 -0
- package/dist/config/index.js +4 -0
- package/dist/config/security.js +213 -0
- package/dist/config/types.js +1 -0
- package/dist/core/agent-moe.js +102 -0
- package/dist/core/agent.js +1018 -0
- package/dist/core/bootstrap.js +481 -0
- package/dist/core/crash-handler.js +51 -0
- package/dist/core/environment.js +199 -0
- package/dist/core/index.js +2 -0
- package/dist/core/prompt-builder.js +76 -0
- package/dist/core/session-logger.js +251 -0
- package/dist/core/types.js +1 -0
- package/dist/core/version.js +26 -0
- package/dist/core/workspace.js +76 -0
- package/dist/i18n/en.json +776 -757
- package/dist/i18n/index.js +46 -0
- package/dist/i18n/ru.json +776 -757
- package/dist/index.js +22 -0
- package/dist/llm/image-utils.js +143 -0
- package/dist/llm/index.js +4 -0
- package/dist/llm/model-loader.js +78 -0
- package/dist/llm/openai-compat.js +497 -0
- package/dist/llm/orchestrator.js +200 -0
- package/dist/llm/provider.js +10 -0
- package/dist/llm/response.js +39 -0
- package/dist/llm/token-counter.js +39 -0
- package/dist/llm/types.js +1 -0
- package/dist/logger/app-logger.js +189 -0
- package/dist/logger/file-log.js +151 -0
- package/dist/logger/index.js +1 -0
- package/dist/main.js +1026 -417
- package/dist/migration/backup.js +45 -0
- package/dist/migration/detect.js +50 -0
- package/dist/migration/index.js +2 -0
- package/dist/modules/artifacts/store.js +61 -0
- package/dist/modules/browser/actions.js +76 -0
- package/dist/modules/browser/bridge-client.js +199 -0
- package/dist/modules/browser/bridge-path.js +10 -0
- package/dist/modules/browser/bridge-server.mjs +219 -219
- package/dist/modules/browser/cookie-store.js +24 -0
- package/dist/modules/browser/driver.js +136 -0
- package/dist/modules/browser/index.js +7 -0
- package/dist/modules/browser/module.js +29 -0
- package/dist/modules/browser/session.js +342 -0
- package/dist/modules/browser/snapshot.js +148 -0
- package/dist/modules/browser/types.js +12 -0
- package/dist/modules/certification/cli.js +213 -0
- package/dist/modules/certification/fact-checker.js +82 -0
- package/dist/modules/certification/loader.js +106 -0
- package/dist/modules/certification/manifest.js +58 -0
- package/dist/modules/certification/runner.js +245 -0
- package/dist/modules/certification/scenarios.js +407 -0
- package/dist/modules/certification/types.js +1 -0
- package/dist/modules/context/chunk-query.js +100 -0
- package/dist/modules/context/fact-extractor.js +168 -0
- package/dist/modules/context/history.js +15 -0
- package/dist/modules/context/index.js +1 -0
- package/dist/modules/context/manager.js +440 -0
- package/dist/modules/execution/audit-runners.js +206 -0
- package/dist/modules/execution/auditor.js +218 -0
- package/dist/modules/execution/execution-plugin.js +431 -0
- package/dist/modules/execution/index.js +8 -0
- package/dist/modules/execution/module.js +625 -0
- package/dist/modules/execution/moe-executor.js +304 -0
- package/dist/modules/execution/plan-coverage.js +68 -0
- package/dist/modules/execution/plan-persister.js +46 -0
- package/dist/modules/execution/plan-store.js +196 -0
- package/dist/modules/execution/plan-tool.js +677 -0
- package/dist/modules/execution/plan-validator.js +153 -0
- package/dist/modules/execution/planner.js +94 -0
- package/dist/modules/execution/stuck-detector.js +746 -0
- package/dist/modules/execution/tracker.js +69 -0
- package/dist/modules/execution/types.js +1 -0
- package/dist/modules/execution/verifier.js +235 -0
- package/dist/modules/execution/windows-commands.js +41 -0
- package/dist/modules/hallucination/confidence.js +66 -0
- package/dist/modules/hallucination/consistency.js +26 -0
- package/dist/modules/hallucination/detector.js +47 -0
- package/dist/modules/hallucination/factual.js +169 -0
- package/dist/modules/hallucination/index.js +5 -0
- package/dist/modules/hallucination/js-identifiers.js +262 -0
- package/dist/modules/hallucination/llm-judge.js +101 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/indexer/cache.js +40 -0
- package/dist/modules/indexer/index.js +3 -0
- package/dist/modules/indexer/module.js +246 -0
- package/dist/modules/indexer/project-profile.js +183 -0
- package/dist/modules/indexer/walker.js +101 -0
- package/dist/modules/lsp/check-tool.js +58 -0
- package/dist/modules/lsp/client.js +389 -0
- package/dist/modules/lsp/command.js +60 -0
- package/dist/modules/lsp/config.js +135 -0
- package/dist/modules/lsp/index.js +3 -0
- package/dist/modules/lsp/module.js +260 -0
- package/dist/modules/lsp/probe.js +86 -0
- package/dist/modules/lsp/project-root.js +32 -0
- package/dist/modules/lsp/startup-check.js +144 -0
- package/dist/modules/lsp/types.js +1 -0
- package/dist/modules/mcp/client.js +399 -0
- package/dist/modules/mcp/index.js +3 -0
- package/dist/modules/mcp/module.js +142 -0
- package/dist/modules/mcp/registry.js +15 -0
- package/dist/modules/memory/index.js +1 -0
- package/dist/modules/memory/module.js +96 -0
- package/dist/modules/memory/search.js +42 -0
- package/dist/modules/memory/store.js +69 -0
- package/dist/modules/pipelines/engine.js +60 -0
- package/dist/modules/pipelines/index.js +3 -0
- package/dist/modules/pipelines/parser.js +56 -0
- package/dist/modules/pipelines/template.js +14 -0
- package/dist/modules/plugins/builtin/lint-on-write.js +334 -0
- package/dist/modules/plugins/builtin/notify.js +9 -0
- package/dist/modules/plugins/index.js +1 -0
- package/dist/modules/plugins/loader.js +70 -0
- package/dist/modules/plugins/manager.js +261 -0
- package/dist/modules/plugins/types.js +1 -0
- package/dist/modules/pricing/index.js +61 -0
- package/dist/modules/pricing/prices.js +129 -0
- package/dist/modules/processes/detect.js +34 -0
- package/dist/modules/processes/index.js +2 -0
- package/dist/modules/processes/registry.js +327 -0
- package/dist/modules/processes/runner.js +23 -0
- package/dist/modules/providers/create.js +22 -0
- package/dist/modules/providers/fallback.js +79 -0
- package/dist/modules/providers/health.js +46 -0
- package/dist/modules/providers/index.js +5 -0
- package/dist/modules/providers/manager.js +161 -0
- package/dist/modules/providers/presets.js +128 -0
- package/dist/modules/providers/registry.js +22 -0
- package/dist/modules/providers/types.js +1 -0
- package/dist/modules/registry.js +48 -0
- package/dist/modules/security/audit-log.js +136 -0
- package/dist/modules/security/audit-notifier.js +292 -0
- package/dist/modules/security/command-validator.js +219 -0
- package/dist/modules/security/content-scanner.js +53 -0
- package/dist/modules/security/data-sanitizer.js +89 -0
- package/dist/modules/security/encryption.js +242 -0
- package/dist/modules/security/index.js +14 -0
- package/dist/modules/security/network-validator.js +88 -0
- package/dist/modules/security/path-validator.js +203 -0
- package/dist/modules/security/rate-limiter.js +119 -0
- package/dist/modules/security/security-policies.js +531 -0
- package/dist/modules/security/session-encryption.js +210 -0
- package/dist/modules/security/session-isolation.js +95 -0
- package/dist/modules/session/index.js +3 -0
- package/dist/modules/session/manager.js +172 -0
- package/dist/modules/session/module.js +24 -0
- package/dist/modules/session/store.js +222 -0
- package/dist/modules/session/types.js +1 -0
- package/dist/modules/skills/index.js +2 -0
- package/dist/modules/skills/loader.js +72 -0
- package/dist/modules/skills/matcher.js +27 -0
- package/dist/modules/skills/module.js +129 -0
- package/dist/modules/types.js +1 -0
- package/dist/modules/updater/checker.js +96 -0
- package/dist/modules/updater/index.js +2 -0
- package/dist/modules/updater/module.js +116 -0
- package/dist/modules/user-profile/compressor.js +16 -0
- package/dist/modules/user-profile/index.js +1 -0
- package/dist/modules/user-profile/profile.js +68 -0
- package/dist/skills/builtin/git.md +36 -36
- package/dist/skills/builtin/typescript.md +35 -35
- package/dist/tools/approve.js +33 -0
- package/dist/tools/attach-image.js +101 -0
- package/dist/tools/bash.js +519 -0
- package/dist/tools/browser.js +115 -0
- package/dist/tools/chunk-query.js +100 -0
- package/dist/tools/create-dir.js +56 -0
- package/dist/tools/delete-file.js +63 -0
- package/dist/tools/download-file.js +117 -0
- package/dist/tools/edit-file.js +80 -0
- package/dist/tools/enable-tools.js +59 -0
- package/dist/tools/executor.js +154 -0
- package/dist/tools/file-info.js +47 -0
- package/dist/tools/filter-tools.js +17 -0
- package/dist/tools/glob-tool.js +27 -0
- package/dist/tools/grep-tool.js +125 -0
- package/dist/tools/hidden-tools-block.js +37 -0
- package/dist/tools/index.js +78 -0
- package/dist/tools/list-dir.js +49 -0
- package/dist/tools/load-skill.js +43 -0
- package/dist/tools/mcp-call.js +69 -0
- package/dist/tools/move-file.js +86 -0
- package/dist/tools/path-utils.js +101 -0
- package/dist/tools/pipeline-run.js +145 -0
- package/dist/tools/preview.js +2 -0
- package/dist/tools/process-kill.js +40 -0
- package/dist/tools/process-list.js +37 -0
- package/dist/tools/process-log.js +54 -0
- package/dist/tools/question.js +141 -0
- package/dist/tools/read-file.js +179 -0
- package/dist/tools/recall.js +118 -0
- package/dist/tools/registry.js +47 -0
- package/dist/tools/remember.js +68 -0
- package/dist/tools/scope-check.js +32 -0
- package/dist/tools/search-history.js +85 -0
- package/dist/tools/subagent.js +196 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/user-input.js +123 -0
- package/dist/tools/web-browse.js +87 -0
- package/dist/tools/web-fetch.js +119 -0
- package/dist/tools/web-search.js +105 -0
- package/dist/tools/write-file.js +82 -0
- package/dist/ui/box.js +77 -0
- package/dist/ui/colors.js +4 -0
- package/dist/ui/diff.js +178 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/line-editor.js +822 -0
- package/dist/ui/line-math.js +73 -0
- package/dist/ui/md-formatter.js +212 -0
- package/dist/ui/output.js +13 -0
- package/dist/ui/plan-view.js +103 -0
- package/dist/ui/renderer.js +259 -0
- package/dist/ui/spinner.js +70 -0
- package/dist/ui/table.js +144 -0
- package/package.json +51 -51
|
@@ -0,0 +1,73 @@
|
|
|
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, firstRowWidth) {
|
|
10
|
+
const w = width > 0 ? width : 80;
|
|
11
|
+
// Only the FIRST visual row shares its screen line with something else
|
|
12
|
+
// (e.g. the prompt); every continuation row uses the full width.
|
|
13
|
+
let limit = firstRowWidth !== undefined && firstRowWidth > 0 ? firstRowWidth : w;
|
|
14
|
+
const chars = Array.from(line);
|
|
15
|
+
const rows = [];
|
|
16
|
+
let start = 0;
|
|
17
|
+
let cells = 0;
|
|
18
|
+
for (let i = 0; i < chars.length; i++) {
|
|
19
|
+
const ch = chars[i];
|
|
20
|
+
if (ch === "\n") {
|
|
21
|
+
rows.push({ text: chars.slice(start, i).join(""), charStart: start });
|
|
22
|
+
start = i + 1;
|
|
23
|
+
cells = 0;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const cw = stringWidth(ch);
|
|
27
|
+
if (cells + cw > limit && cells > 0) {
|
|
28
|
+
rows.push({ text: chars.slice(start, i).join(""), charStart: start });
|
|
29
|
+
start = i;
|
|
30
|
+
cells = cw;
|
|
31
|
+
limit = w;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
cells += cw;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
rows.push({ text: chars.slice(start).join(""), charStart: start });
|
|
38
|
+
return rows;
|
|
39
|
+
}
|
|
40
|
+
export function buildLayout(lines, width, firstRowWidth) {
|
|
41
|
+
const rows = [];
|
|
42
|
+
for (let b = 0; b < lines.length; b++) {
|
|
43
|
+
for (const r of wrapLine(lines[b], width, b === 0 ? firstRowWidth : undefined)) {
|
|
44
|
+
rows.push({ bufRow: b, charStart: r.charStart, text: r.text });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return rows;
|
|
48
|
+
}
|
|
49
|
+
export function layoutIndexFor(rows, bufRow, col) {
|
|
50
|
+
let idx = 0;
|
|
51
|
+
for (let i = 0; i < rows.length; i++) {
|
|
52
|
+
if (rows[i].bufRow === bufRow && rows[i].charStart <= col)
|
|
53
|
+
idx = i;
|
|
54
|
+
}
|
|
55
|
+
return idx;
|
|
56
|
+
}
|
|
57
|
+
export function visualColAt(rows, idx, col) {
|
|
58
|
+
const r = rows[idx];
|
|
59
|
+
const upTo = col - r.charStart;
|
|
60
|
+
return stringWidth(Array.from(r.text).slice(0, upTo).join(""));
|
|
61
|
+
}
|
|
62
|
+
export function charOffsetFor(rows, idx, visualCol) {
|
|
63
|
+
const r = rows[idx];
|
|
64
|
+
const chars = Array.from(r.text);
|
|
65
|
+
let cells = 0;
|
|
66
|
+
for (let i = 0; i < chars.length; i++) {
|
|
67
|
+
const cw = stringWidth(chars[i]);
|
|
68
|
+
if (cells + cw > visualCol)
|
|
69
|
+
return r.charStart + i;
|
|
70
|
+
cells += cw;
|
|
71
|
+
}
|
|
72
|
+
return r.charStart + chars.length;
|
|
73
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,259 @@
|
|
|
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
|
+
import { formatCost } from "../modules/pricing/prices";
|
|
8
|
+
import { isAbsolute, relative, sep } from "path";
|
|
9
|
+
function formatUsd(cost) {
|
|
10
|
+
return formatCost(cost);
|
|
11
|
+
}
|
|
12
|
+
/** Tools whose `path` argument is shown in the header. */
|
|
13
|
+
const PATH_TOOLS = new Set([
|
|
14
|
+
"read_file",
|
|
15
|
+
"write_file",
|
|
16
|
+
"edit_file",
|
|
17
|
+
"delete_file",
|
|
18
|
+
"create_dir",
|
|
19
|
+
"move_file",
|
|
20
|
+
"list_dir",
|
|
21
|
+
"file_info",
|
|
22
|
+
]);
|
|
23
|
+
function toDisplayPath(baseDir, p) {
|
|
24
|
+
if (!baseDir || !isAbsolute(p))
|
|
25
|
+
return p;
|
|
26
|
+
const rel = relative(baseDir, p);
|
|
27
|
+
// Outside baseDir (../ prefix) or another drive (absolute result) → keep as-is.
|
|
28
|
+
if (!rel || rel.startsWith("..") || isAbsolute(rel))
|
|
29
|
+
return p;
|
|
30
|
+
return rel.split(sep).join("/");
|
|
31
|
+
}
|
|
32
|
+
const GUTTER = " ";
|
|
33
|
+
/** Tools that show a busy spinner while running (inline mode). */
|
|
34
|
+
const BUSY_TOOLS = new Set(["lsp_check"]);
|
|
35
|
+
/** opencode-like leading marker per tool category. */
|
|
36
|
+
export function toolMarker(tool) {
|
|
37
|
+
switch (tool) {
|
|
38
|
+
case "write_file":
|
|
39
|
+
case "edit_file":
|
|
40
|
+
case "create_dir":
|
|
41
|
+
case "move_file":
|
|
42
|
+
case "delete_file":
|
|
43
|
+
return "←";
|
|
44
|
+
case "read_file":
|
|
45
|
+
case "list_dir":
|
|
46
|
+
case "file_info":
|
|
47
|
+
return "→";
|
|
48
|
+
case "glob":
|
|
49
|
+
case "grep":
|
|
50
|
+
return "✱";
|
|
51
|
+
case "bash":
|
|
52
|
+
return "$";
|
|
53
|
+
default:
|
|
54
|
+
return "⚙";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function isRichTerminal() {
|
|
58
|
+
return Boolean(process.stdout.isTTY) && !process.env.CI;
|
|
59
|
+
}
|
|
60
|
+
/** Short human-friendly summary of tool arguments. */
|
|
61
|
+
export function summarizeArgs(args) {
|
|
62
|
+
const preferred = ["path", "file", "query", "url", "command", "name"];
|
|
63
|
+
for (const key of preferred) {
|
|
64
|
+
const value = args[key];
|
|
65
|
+
if (typeof value === "string" && value) {
|
|
66
|
+
return value.length > 60 ? `${value.slice(0, 57)}…` : value;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const serialized = JSON.stringify(args);
|
|
70
|
+
if (!serialized || serialized === "{}")
|
|
71
|
+
return "";
|
|
72
|
+
return serialized.length > 60 ? `${serialized.slice(0, 57)}…` : serialized;
|
|
73
|
+
}
|
|
74
|
+
function friendlyTool(tool) {
|
|
75
|
+
const key = `tool.friendly.${tool}`;
|
|
76
|
+
const value = t(key);
|
|
77
|
+
return value !== key ? value : tool;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Streams agent events to the terminal. Rich mode (TTY) adds a spinner
|
|
81
|
+
* and boxed tool cards; plain mode falls back to simple prefixed lines.
|
|
82
|
+
* Colors come from `colors.ts`, disabled outside a TTY, in CI, or on NO_COLOR.
|
|
83
|
+
*/
|
|
84
|
+
export class Renderer {
|
|
85
|
+
rich;
|
|
86
|
+
spinner;
|
|
87
|
+
fmt;
|
|
88
|
+
out;
|
|
89
|
+
err;
|
|
90
|
+
width;
|
|
91
|
+
toolStyle;
|
|
92
|
+
baseDir;
|
|
93
|
+
card = null;
|
|
94
|
+
constructor(opts = {}) {
|
|
95
|
+
this.rich = opts.rich ?? isRichTerminal();
|
|
96
|
+
this.out = opts.out ?? process.stdout;
|
|
97
|
+
this.err = opts.err ?? process.stderr;
|
|
98
|
+
this.width = opts.width ?? getTerminalWidth();
|
|
99
|
+
this.toolStyle = opts.toolStyle ?? "inline";
|
|
100
|
+
this.baseDir = opts.baseDir;
|
|
101
|
+
this.spinner = new Spinner({
|
|
102
|
+
enabled: this.rich && (opts.spinner ?? true),
|
|
103
|
+
stream: this.err,
|
|
104
|
+
width: this.width,
|
|
105
|
+
});
|
|
106
|
+
this.fmt = new FormattingStream((line) => this.out.write(`${line}\n`), this.width);
|
|
107
|
+
}
|
|
108
|
+
/** Final answer streamed from the model (markdown-formatted). */
|
|
109
|
+
text(chunk) {
|
|
110
|
+
this.endCard();
|
|
111
|
+
this.spinner.stop();
|
|
112
|
+
this.fmt.write(chunk);
|
|
113
|
+
}
|
|
114
|
+
/** Arbitrary status/meta text (tool output, reasoning, MoE status). */
|
|
115
|
+
meta(chunk) {
|
|
116
|
+
this.spinner.stop();
|
|
117
|
+
if (this.card) {
|
|
118
|
+
if (this.toolStyle === "inline") {
|
|
119
|
+
this.writeInlineBody(chunk);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.card.body.push(chunk);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
this.out.write(chunk);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/** Stream tool body lines with the gutter prefix, skipping blank lines. */
|
|
130
|
+
writeInlineBody(chunk) {
|
|
131
|
+
for (const line of chunk.split("\n")) {
|
|
132
|
+
if (line.trim() === "")
|
|
133
|
+
continue;
|
|
134
|
+
this.out.write(`${GUTTER}${line}\n`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Dimmed reasoning stream (already colored by the agent). */
|
|
138
|
+
reasoning(chunk) {
|
|
139
|
+
this.spinner.stop();
|
|
140
|
+
this.out.write(pc.dim(chunk));
|
|
141
|
+
}
|
|
142
|
+
/** Model is loading / generating — show the thinking spinner. */
|
|
143
|
+
thinkingStart() {
|
|
144
|
+
this.spinner.start(t("ui.thinking"));
|
|
145
|
+
}
|
|
146
|
+
/** LLM call finished; clear the thinking spinner. */
|
|
147
|
+
thinkingEnd() {
|
|
148
|
+
this.spinner.stop();
|
|
149
|
+
}
|
|
150
|
+
toolStart(tool, args, stepContext, icon) {
|
|
151
|
+
this.endCard();
|
|
152
|
+
this.spinner.stop();
|
|
153
|
+
const displayArgs = PATH_TOOLS.has(tool) && typeof args.path === "string"
|
|
154
|
+
? { ...args, path: toDisplayPath(this.baseDir, args.path) }
|
|
155
|
+
: args;
|
|
156
|
+
const summary = summarizeArgs(displayArgs);
|
|
157
|
+
const step = stepContext ? ` ${pc.cyan(`← ${stepContext}`)}` : "";
|
|
158
|
+
const marker = icon || toolMarker(tool);
|
|
159
|
+
if (!this.rich) {
|
|
160
|
+
this.out.write(`\n${pc.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}${step}\n`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.card = { tool, args, body: [], start: Date.now() };
|
|
164
|
+
if (this.toolStyle === "inline") {
|
|
165
|
+
this.out.write(`\n${pc.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}${step}\n`);
|
|
166
|
+
if (BUSY_TOOLS.has(tool)) {
|
|
167
|
+
this.spinner.start(t("ui.tool_running", { tool: friendlyTool(tool) }));
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.spinner.start(`${pc.dim(marker)} ${friendlyTool(tool)}${summary ? ` ${pc.dim(summary)}` : ""}${step}`);
|
|
172
|
+
}
|
|
173
|
+
/** Live plan checklist — prints the plan block as-is (already colored). */
|
|
174
|
+
planBlock(lines) {
|
|
175
|
+
this.endCard();
|
|
176
|
+
this.spinner.stop();
|
|
177
|
+
for (const line of lines) {
|
|
178
|
+
this.out.write(`${line}\n`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
toolEnd(_tool, duration, error, ctxDelta, costUsd, provider, model) {
|
|
182
|
+
this.spinner.stop();
|
|
183
|
+
const prov = provider && model ? `${pc.dim(`${provider}·${model}`)}` : undefined;
|
|
184
|
+
if (!this.rich) {
|
|
185
|
+
const parts = [];
|
|
186
|
+
if (ctxDelta !== undefined && ctxDelta !== 0) {
|
|
187
|
+
const deltaStr = ctxDelta > 0 ? pc.green(`+${ctxDelta}`) : pc.yellow(`${ctxDelta} ↓`);
|
|
188
|
+
parts.push(`${pc.dim("ctx")} ${deltaStr}`);
|
|
189
|
+
}
|
|
190
|
+
if (costUsd !== undefined && costUsd > 0) {
|
|
191
|
+
parts.push(`${pc.dim("cost")} ${pc.yellow(formatUsd(costUsd))}`);
|
|
192
|
+
}
|
|
193
|
+
if (prov)
|
|
194
|
+
parts.push(prov);
|
|
195
|
+
if (parts.length > 0)
|
|
196
|
+
this.out.write(`${parts.join(" ")}\n`);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (!this.card)
|
|
200
|
+
return;
|
|
201
|
+
const { tool, args, body } = this.card;
|
|
202
|
+
const marker = error ? pc.red("✗") : pc.green("✓");
|
|
203
|
+
let footer = `${marker} ${pc.dim(`${duration}ms`)}`;
|
|
204
|
+
if (ctxDelta !== undefined && ctxDelta !== 0) {
|
|
205
|
+
const deltaStr = ctxDelta > 0 ? pc.green(`+${ctxDelta}`) : pc.yellow(`${ctxDelta} ↓`);
|
|
206
|
+
footer += ` ${pc.dim("ctx")} ${deltaStr}`;
|
|
207
|
+
}
|
|
208
|
+
if (costUsd !== undefined && costUsd > 0) {
|
|
209
|
+
footer += ` ${pc.dim("cost")} ${pc.yellow(formatUsd(costUsd))}`;
|
|
210
|
+
}
|
|
211
|
+
if (prov) {
|
|
212
|
+
footer += ` ${pc.dim("via")} ${prov}`;
|
|
213
|
+
}
|
|
214
|
+
if (this.toolStyle === "inline") {
|
|
215
|
+
this.out.write(`${GUTTER}${footer}\n`);
|
|
216
|
+
this.out.write(`${divider(this.width)}\n`);
|
|
217
|
+
this.card = null;
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const lines = [];
|
|
221
|
+
const summary = summarizeArgs(args);
|
|
222
|
+
if (summary)
|
|
223
|
+
lines.push(pc.dim(summary));
|
|
224
|
+
for (const chunk of body) {
|
|
225
|
+
for (const line of chunk.split("\n")) {
|
|
226
|
+
if (line.trim() !== "")
|
|
227
|
+
lines.push(line);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
lines.push(footer);
|
|
231
|
+
const title = `${marker} ${friendlyTool(tool)}`;
|
|
232
|
+
for (const line of box(lines, { title, width: this.width })) {
|
|
233
|
+
this.out.write(`${line}\n`);
|
|
234
|
+
}
|
|
235
|
+
this.card = null;
|
|
236
|
+
}
|
|
237
|
+
/** Raw pre-formatted text (diff blocks, warnings). */
|
|
238
|
+
raw(text) {
|
|
239
|
+
this.endCard();
|
|
240
|
+
this.spinner.stop();
|
|
241
|
+
this.out.write(text);
|
|
242
|
+
}
|
|
243
|
+
error(text) {
|
|
244
|
+
this.endCard();
|
|
245
|
+
this.spinner.stop();
|
|
246
|
+
this.err.write(`${pc.red(text)}\n`);
|
|
247
|
+
}
|
|
248
|
+
flush() {
|
|
249
|
+
this.endCard();
|
|
250
|
+
this.spinner.stop();
|
|
251
|
+
this.fmt.flush();
|
|
252
|
+
}
|
|
253
|
+
endCard() {
|
|
254
|
+
if (!this.card)
|
|
255
|
+
return;
|
|
256
|
+
const { tool, start } = this.card;
|
|
257
|
+
this.toolEnd(tool, Date.now() - start);
|
|
258
|
+
}
|
|
259
|
+
}
|