Skip to content

Commit 2261282

Browse files
author
Lukas Geiger
committed
style: left-align logo, use raw github url for npmjs support, fix tip noise
1 parent b6a68b9 commit 2261282

4 files changed

Lines changed: 51 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# companion-for-agy
22

3-
<p align="center">
4-
<img src="assets/logo.jpg" alt="companion-for-agy Banner" width="800" />
3+
<p align="left">
4+
<img src="https://raw.githubusercontent.com/dev-bricks/companion-for-agy/master/assets/logo.jpg" alt="companion-for-agy Banner" width="800" />
55
</p>
66

77
[![npm](https://img.shields.io/npm/v/companion-for-agy)](https://www.npmjs.com/package/companion-for-agy)

README_de.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# companion-for-agy
22

3-
<p align="center">
4-
<img src="assets/logo.png" alt="companion-for-agy Logo" width="200" height="200" />
3+
<p align="left">
4+
<img src="https://raw.githubusercontent.com/dev-bricks/companion-for-agy/master/assets/logo.jpg" alt="companion-for-agy Banner" width="800" />
55
</p>
66

77
[![English](https://img.shields.io/badge/lang-English-blue)](README.md)

_tests/unit.test.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
33
import {
44
stripAnsi, isNoiseLine, extractByResponseColor,
55
sanitizeForPty, extractResponse, escapeRegex, stripPromptEcho,
6+
cleanColorExtracted,
67
PERMISSION_PRESETS, TRUST_DIALOG_PATTERN, BANNER_MODEL_PATTERN,
78
STARTUP_DONE_PATTERNS, INIT_DONE_PATTERNS,
89
DEFAULT_MODEL, findAgyPath, AGY_PATH,
@@ -107,6 +108,12 @@ describe('isNoiseLine', () => {
107108
assert.equal(isNoiseLine('Reading file.txt'), true);
108109
assert.equal(isNoiseLine('Searching for results'), true);
109110
assert.equal(isNoiseLine('Executing command'), true);
111+
assert.equal(isNoiseLine('Verifying the Constraints'), true);
112+
});
113+
114+
it('filters TUI tip lines (└ prefix)', () => {
115+
assert.equal(isNoiseLine('└ Tip: Press ? to see keyboard shortcuts.'), true);
116+
assert.equal(isNoiseLine('└ 42 tokens used'), true);
110117
});
111118

112119
it('filters email addresses (privacy)', () => {
@@ -507,6 +514,29 @@ describe('findAgyPath', () => {
507514
});
508515
});
509516

517+
// ---------- cleanColorExtracted ----------
518+
519+
describe('cleanColorExtracted', () => {
520+
it('removes noise lines from color-extracted text', () => {
521+
const text = '└ Tip: Press ? to see keyboard shortcuts.\nVerifying the Constraints\n4\n└ Tip: Press ? to see keyboard shortcuts.';
522+
assert.equal(cleanColorExtracted(text), '4');
523+
});
524+
525+
it('returns null for all-noise input', () => {
526+
assert.equal(cleanColorExtracted('└ Tip: shortcuts\nVerifying stuff'), null);
527+
});
528+
529+
it('preserves multi-line responses', () => {
530+
const text = 'Line one.\nLine two.\nLine three.';
531+
assert.equal(cleanColorExtracted(text), 'Line one.\nLine two.\nLine three.');
532+
});
533+
534+
it('returns null for empty/null input', () => {
535+
assert.equal(cleanColorExtracted(''), null);
536+
assert.equal(cleanColorExtracted(null), null);
537+
});
538+
});
539+
510540
// ---------- Constants ----------
511541

512542
describe('DEFAULT_MODEL', () => {

src/agy-companion.mjs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ export function isNoiseLine(line, promptFilter = '') {
158158
if (/^Gemini \d/.test(t)) return true;
159159
if (/^\d+\s*tokens$/.test(t)) return true;
160160
if (/^\s/.test(t)) return true;
161-
if (/^(Checking|Reading|Writing|Searching|Fetching|Analyzing|Executing)\b/i.test(t)) return true;
161+
if (/^(Checking|Reading|Writing|Searching|Fetching|Analyzing|Executing|Verifying)\b/i.test(t)) return true;
162+
if (/^\s/.test(t)) return true;
162163
if (t.includes('@googlemail.com') || t.includes('@gmail.com')) return true;
163164
if (promptFilter && t.includes(promptFilter.slice(0, 20))) return true;
164165
return false;
@@ -231,20 +232,30 @@ export function stripPromptEcho(text, filter) {
231232
return clean.length > 0 ? clean : '';
232233
}
233234

235+
export function cleanColorExtracted(text, promptFilter = '') {
236+
if (!text) return null;
237+
const lines = text.split('\n');
238+
const cleaned = lines.filter(l => !isNoiseLine(l, promptFilter));
239+
const result = cleaned.join('\n').trim();
240+
return result.length > 0 ? result : null;
241+
}
242+
234243
export function extractResponse(stripped, rawSection, promptFilter = '', effectiveFilter = '') {
235244
if (rawSection) {
236245
const colorResult = extractByResponseColor(rawSection);
237246
if (colorResult && colorResult.length > 0) {
247+
let result = colorResult;
238248
const echoFilter = effectiveFilter || promptFilter;
239249
if (echoFilter) {
240-
const cleaned = stripPromptEcho(colorResult, echoFilter);
241-
if (cleaned !== null) return cleaned || null;
250+
const cleaned = stripPromptEcho(result, echoFilter);
251+
if (cleaned !== null) result = cleaned || '';
242252
}
243253
if (promptFilter && promptFilter !== echoFilter) {
244-
const cleaned = stripPromptEcho(colorResult, promptFilter);
245-
if (cleaned !== null) return cleaned || null;
254+
const cleaned = stripPromptEcho(result, promptFilter);
255+
if (cleaned !== null) result = cleaned || '';
246256
}
247-
return colorResult;
257+
const final = cleanColorExtracted(result, promptFilter);
258+
return final;
248259
}
249260
}
250261

0 commit comments

Comments
 (0)