fix: fence lone commands and give the prompt some warmth #12

Merged
adrianbonpin merged 1 commits from feat/promote-inline-commands into prod 2026-10-03 22:00:39 +00:00
Owner

Reported: asking for the terminal command to get the working directory returns a bare pwd with no code block, and every answer reads too direct.

The fence rule

promoteStandaloneCodeSpans turns a paragraph that is nothing but one inline code span into a fence, so a lone `pwd` becomes a real block with a language label and a Copy button.

The rule is narrow on purpose, a whole line that is exactly one span:

  • `pwd` on its own line becomes a fenced block
  • run `pwd` to check is untouched
  • a span-like line inside an existing fence is never rewritten

This also repairs answers already stored in a saved conversation, since the stored text is re-rendered on every open.

A real bug this uncovered

A closing ``` and an opening bare ``` are the same two lines apart from context. The old opening-fence pattern only matched bare fences, so it treated every closing fence as a new opening one and consumed the rest of the answer. Any block following a labelled block silently lost its language.

labelCodeFences now matches the optional language as part of the opening pattern, matches closing fences separately, and leaves a fence the model labelled itself exactly as written. Regression tests cover both the two-block case and c++ / objective-c tags.

The prompt

Three lines were fighting warmth:

  • No preamble
  • when the answer is a single command, the fence is the whole answer
  • an opener ban broad enough to rule out any natural remark

The second one is why the reply was a bare snippet with no words at all. Replaced with an instruction to sound like a person and to always say in one plain sentence what the code does or when to use it.

The anti-slop rules stay, narrowed to the phrasing that actually reads as filler: "Certainly", "I'd be happy to help", "Great question", "I hope this helps". Em dash and generated-text-tell bans are unchanged.

Verification

171 tests across 11 files, tsc --noEmit, eslint . and vici build -o dist all clean. Verified visually that the reported conversation now renders pwd as a bash block with the Copy button.

Reported: asking for the terminal command to get the working directory returns a bare `pwd` with no code block, and every answer reads too direct. ## The fence rule `promoteStandaloneCodeSpans` turns a paragraph that is nothing but one inline code span into a fence, so a lone `` `pwd` `` becomes a real block with a language label and a Copy button. The rule is narrow on purpose, a whole line that is exactly one span: - `` `pwd` `` on its own line becomes a fenced block - ``run `pwd` to check`` is untouched - a span-like line inside an existing fence is never rewritten This also repairs answers already stored in a saved conversation, since the stored text is re-rendered on every open. ## A real bug this uncovered A closing ` ``` ` and an opening bare ` ``` ` are the same two lines apart from context. The old opening-fence pattern only matched bare fences, so it treated every **closing** fence as a new opening one and consumed the rest of the answer. Any block following a labelled block silently lost its language. `labelCodeFences` now matches the optional language as part of the opening pattern, matches closing fences separately, and leaves a fence the model labelled itself exactly as written. Regression tests cover both the two-block case and `c++` / `objective-c` tags. ## The prompt Three lines were fighting warmth: - `No preamble` - `when the answer is a single command, the fence is the whole answer` - an opener ban broad enough to rule out any natural remark The second one is why the reply was a bare snippet with no words at all. Replaced with an instruction to sound like a person and to always say in one plain sentence what the code does or when to use it. The anti-slop rules stay, narrowed to the phrasing that actually reads as filler: "Certainly", "I'd be happy to help", "Great question", "I hope this helps". Em dash and generated-text-tell bans are unchanged. ## Verification 171 tests across 11 files, `tsc --noEmit`, `eslint .` and `vici build -o dist` all clean. Verified visually that the reported conversation now renders `pwd` as a `bash` block with the Copy button.
adrianbonpin added 1 commit 2026-10-03 22:00:34 +00:00
Two problems, one report: asking for a command returned a bare `pwd` with
no code block, and every answer read like a spec sheet.

The fence rule. Promotion now turns a paragraph that is nothing but one
inline code span into a fence, so `pwd` on its own line becomes a real
block with a Copy button. The rule is deliberately narrow, a whole line
that is exactly one span, so "run `pwd` to check" is left intact. This
also repairs answers already sitting in a saved conversation, because the
stored text is re-rendered on every open.

That work exposed a real bug in the labeller: a closing ``` and an opening
bare ``` are identical lines, so every closing fence was read as a new
opening one and swallowed the rest of the answer. Any block after a
labelled block silently lost its language. The opening-fence pattern now
carries the optional language, closing fences are matched separately, and
a fence the model labelled itself is left exactly as written.

The prompt. "No preamble" plus "when the answer is a single command, the
fence is the whole answer" is why the reply was a bare snippet with no
words at all. Replaced with a plain instruction to sound like a person and
to always say in one sentence what the code does. The anti-slop rules stay,
narrowed to the stock service-desk phrasing that actually reads as filler.

171 tests, tsc, eslint and vici build all clean.
adrianbonpin merged commit 95edbcd20b into prod 2026-10-03 22:00:39 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adrianbonpin/lam-agent-vicinae#12