MCPcopy
hub / github.com/bombshell-dev/clack / clear

Function clear

packages/prompts/src/task-log.ts:70–107  ·  view source on GitHub ↗
(clearTitle: boolean)

Source from the content-addressed store, hash-verified

68 let lastMessageWasRaw = false;
69
70 const clear = (clearTitle: boolean): void => {
71 if (buffers.length === 0) {
72 return;
73 }
74
75 let lines = 0;
76
77 if (clearTitle) {
78 lines += spacing + 2;
79 }
80
81 for (const buffer of buffers) {
82 const { value, result } = buffer;
83 let text = result?.message ?? value;
84
85 if (text.length === 0) {
86 continue;
87 }
88
89 if (result === undefined && buffer.header !== undefined && buffer.header !== '') {
90 text += `\n${buffer.header}`;
91 }
92
93 const bufferHeight = text.split('\n').reduce((count, line) => {
94 if (line === '') {
95 return count + 1;
96 }
97 return count + Math.ceil((line.length + barSize) / columns);
98 }, 0);
99
100 lines += bufferHeight;
101 }
102
103 if (lines > 0) {
104 lines += 1;
105 output.write(erase.lines(lines));
106 }
107 };
108 const printBuffer = (buffer: BufferEntry, messageSpacing?: number, full?: boolean): void => {
109 const messages = full ? `${buffer.full}\n${buffer.value}` : buffer.value;
110 if (buffer.header !== undefined && buffer.header !== '') {

Callers 4

messageFunction · 0.70
completeBufferFunction · 0.70
errorFunction · 0.70
successFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected