Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Recaps keep code and underscores inside words (#1199)

Dee9b60697acdcd
diff --git a/cli/src/lib/deviceRecap.spec.ts b/cli/src/lib/deviceRecap.spec.ts
index 00a5c171e..51b6126e0 100644
--- a/cli/src/lib/deviceRecap.spec.ts
+++ b/cli/src/lib/deviceRecap.spec.ts
@@ -36,6 +36,11 @@ describe('deriveLongRecap', () => {
it('strips markdown and collapses whitespace', () => {
expect(deriveLongRecap('## Kết quả\n\n- **SJC**: 149 triệu\n\n```sh\nls\n```\nDone.')).toBe('Kết quả SJC: 149 triệu Done.')
})
+ it('keeps code and the underscores inside words, and drops only the emphasis around them', () => {
+ expect(deriveLongRecap('Name it `MAX_SIZE`, not *max_size*; see __init__ and _this_ word.'))
+ .toBe('Name it MAX_SIZE, not max_size; see init and this word.')
+ expect(deriveLongRecap('Set AI_AGENT and `__init__.py` stays as it is.')).toBe('Set AI_AGENT and __init__.py stays as it is.')
+ })
it('clips long text at a word boundary with an ellipsis, within the char and byte caps', () => {
const long = Array.from({ length: 600 }, (_, i) => `từ${i}`).join(' ')
const out = deriveLongRecap(long)!
diff --git a/cli/src/lib/deviceRecap.ts b/cli/src/lib/deviceRecap.ts
index 82bd00e4c..c85f0d32b 100644
--- a/cli/src/lib/deviceRecap.ts
+++ b/cli/src/lib/deviceRecap.ts
@@ -90,7 +90,12 @@ function stripMarkdown(text: string): string {
.replace(/^\s*\d+\.\s+/gm, '') // ordered-list markers
.replace(/^\s*>\s?/gm, '') // block quotes
.replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1') // links and images → their label
- .replace(/[*_~`]/g, '') // emphasis and inline code marks
+ // Emphasis marks go, but never from inside code or a word: an agent's "name it `MAX_SIZE`" read back as
+ // "name it MAXSIZE" in `harness ps` (2026-10-11, in a clean VM), and agents act on what they read there.
+ .split(/(`[^`\n]*`)/)
+ .map((part) => part.startsWith('`') && part.endsWith('`') && part.length > 1 ? part.slice(1, -1)
+ : part.replace(/[*~`]/g, '').replace(/(?<![\p{L}\p{N}])_+|_+(?![\p{L}\p{N}])/gu, ''))
+ .join('')
.replace(/[ \t]+/g, ' ')
.trim()
}