MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / normalizeCliErrorText

Function normalizeCliErrorText

apps/cli/src/tooling.ts:222–250  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

220};
221
222export const normalizeCliErrorText = (raw: string): string => {
223 const lines = raw.split(/\r?\n/);
224 const compacted: Array<string> = [];
225
226 for (const line of lines) {
227 const trimmed = line.trim();
228 if (trimmed.length === 0) {
229 if (compacted.length > 0 && compacted[compacted.length - 1] !== "") {
230 compacted.push("");
231 }
232 continue;
233 }
234 if (/^at\s+/.test(trimmed)) continue;
235 if (/^From previous event/.test(trimmed)) continue;
236 compacted.push(trimmed);
237 }
238
239 if (compacted.length === 0) {
240 return stripRepeatedErrorPrefix(raw);
241 }
242
243 compacted[0] = stripRepeatedErrorPrefix(compacted[0] ?? "");
244 while (compacted.length > 0 && compacted[0]?.length === 0) {
245 compacted.shift();
246 }
247
248 const limited = compacted.slice(0, 24);
249 return limited.join("\n").trim();
250};
251
252export interface PausedInteraction {
253 readonly kind: "url" | "form";

Callers 3

renderCliErrorFunction · 0.90
main.tsFile · 0.90
tools-cli.test.tsFile · 0.90

Calls 2

stripRepeatedErrorPrefixFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected