Skip to content

fix: stop gen-skill-docs from truncating descriptions with embedded periods#2171

Open
sneakygriff wants to merge 1 commit into
garrytan:mainfrom
sneakygriff:fix/skill-docs-embedded-period-truncation
Open

fix: stop gen-skill-docs from truncating descriptions with embedded periods#2171
sneakygriff wants to merge 1 commit into
garrytan:mainfrom
sneakygriff:fix/skill-docs-embedded-period-truncation

Conversation

@sneakygriff

Copy link
Copy Markdown

Problem

splitCatalogDescription in scripts/gen-skill-docs.ts extracts the lead (first) sentence of each skill description with the regex ^([^.!?]*[.!?])(?:\s|$). The [^.!?]* class is greedy and cannot backtrack across a period, so when the first sentence contains an embedded terminator — a filename like TODOS.md / CLAUDE.md, a URL, or a version number like v1.45.0.0 — the regex fails to match a real sentence boundary. On failure the code falls back to a blind first-20-words cut, producing a lead that either stops mid-token or runs past the true sentence end into the next clause.

Fix

Rewrite the lead regex to ^((?:[^.!?]|[.!?](?!\s|$))*[.!?])(?:\s|$). A terminator that is not followed by whitespace/end-of-text (an embedded period) is consumed by the second, disjoint alternative and no longer ends the sentence; a terminator followed by a real boundary still closes the lead. The two alternatives match disjoint inputs, so there is no ambiguity and no catastrophic-backtracking risk.

This re-renders two previously mis-split skill descriptions:

  • diagram — lead now runs to "…and rendered SVG + PNG." instead of truncating at "you can open".
  • sync-gbrain — lead now stops at "…guidance in CLAUDE.md." instead of spilling the next clause in via the 20-word fallback.

(The diagram source description was also reworded to split an overlong first sentence.)

Verification

  • bun test test/catalog-trim.test.ts23 pass, 0 fail (adds regression cases for embedded periods, URLs, and a >200-char first sentence with embedded periods).
  • bun test test/gen-skill-docs.test.ts test/skill-validation.test.ts test/llms-txt-shape.test.ts741 pass, 0 fail.

🤖 Generated with Claude Code

…bedded period

The catalog-description splitter used the sentence regex
`^([^.!?]*[.!?])(?:\s|$)` to find the lead (first) sentence. The `[^.!?]*`
class is greedy and cannot backtrack across a period, so any first sentence
containing an embedded terminator — "TODOS.md" / "CLAUDE.md", a URL, or a
version number like "v1.45.0.0" — failed to match a real sentence boundary.
When the match failed, the code silently fell back to a blind 20-word cut,
producing leads that either stopped mid-token or ran past the true sentence
end into the next clause.

The fix rewrites the lead regex to
`^((?:[^.!?]|[.!?](?!\s|$))*[.!?])(?:\s|$)`: a terminator that is NOT followed
by whitespace/end-of-text (an embedded period) is consumed by the second,
disjoint alternative and no longer ends the sentence, while a terminator
followed by a boundary still closes the lead. The two alternatives cover
disjoint inputs, so there is no ambiguity or catastrophic-backtracking risk.

Adds regression coverage in test/catalog-trim.test.ts for embedded periods,
URLs, and a >200-char first sentence with embedded periods (ellipsis path,
not the word-count fallback).

Re-renders the two skill descriptions that were previously mis-split:
- diagram: lead now runs to "...and rendered SVG + PNG." instead of
  truncating at "you can open".
- sync-gbrain: lead now stops at "...guidance in CLAUDE.md." instead of
  spilling the next clause in via the 20-word fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Jul 4, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant