fix: stop gen-skill-docs from truncating descriptions with embedded periods#2171
Open
sneakygriff wants to merge 1 commit into
Open
fix: stop gen-skill-docs from truncating descriptions with embedded periods#2171sneakygriff wants to merge 1 commit into
sneakygriff wants to merge 1 commit into
Conversation
…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>
|
Merging to
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
splitCatalogDescriptioninscripts/gen-skill-docs.tsextracts 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 likeTODOS.md/CLAUDE.md, a URL, or a version number likev1.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:
(The diagram source description was also reworded to split an overlong first sentence.)
Verification
bun test test/catalog-trim.test.ts— 23 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.ts— 741 pass, 0 fail.🤖 Generated with Claude Code