-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add proofread_markdown skill and Dart wrapper script #13258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+181
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ef616a0
Add proofread_markdown skill and Dart wrapper script
antfitch e44ca0e
Address PR comments: fix path, use regex for lists, and preserve inde…
antfitch b0b1021
Update proofread skill with heading IDs and conciseness prompt
antfitch 6f3d0fb
added semantic line break script
antfitch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| --- | ||
| name: proofread-markdown | ||
| description: Proofreads Markdown files against Google guidelines. | ||
| --- | ||
|
|
||
| # Proofreading Markdown | ||
|
|
||
| ## Overview | ||
|
|
||
| Help us transform technical text into clear, concise, | ||
| and machine-readable Markdown. We follow the | ||
| Google Developer Documentation Style Guide. | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### 1. Check line length | ||
|
|
||
| - [ ] Wrap lines semantically and keep them generally under 80 characters using | ||
| [scripts/wrap_lines.dart](scripts/wrap_lines.dart) | ||
| - [ ] Verify that the file was wrapped correctly, preserving headings and | ||
| code blocks | ||
|
|
||
| ### 2. Fix voice and tone | ||
|
|
||
| - [ ] Use active voice. | ||
| - [ ] Use present tense. | ||
| - [ ] Use second person ("you"). No "we". | ||
|
|
||
| ### 3. Check word choice | ||
|
|
||
| - [ ] Replace forbidden terms: "e.g.", "i.e.", "etc.", "should", "would", | ||
| "could". | ||
| - [ ] Use Oxford comma and American spelling. | ||
|
|
||
| ### 4. Check style of headings | ||
|
|
||
| - [ ] Use Sentence case for headings. | ||
| - If you change a heading, add an id after the heading like this: | ||
| "## Configure the project {: #project-configuration }" | ||
| - [ ] Put a blank line after all headings. | ||
|
|
||
| ### 5. Check style of lists | ||
|
|
||
| - [ ] Numbered lists MUST use `1.` for every item to allow easy reordering. | ||
| - [ ] How-to sections must have active voice in headings. | ||
| - No: "## Project Configuration" | ||
| - Yes: "## Configure the project" | ||
|
|
||
| ### 6. Use less words in sections with steps | ||
|
|
||
| - [ ] Ask the user if they would like the steps to be more concise. | ||
| If yes, update the steps to be brief. Keep it short, simple, and | ||
| accurate. |
128 changes: 128 additions & 0 deletions
128
.agents/skills/proofread_markdown/scripts/wrap_lines.dart
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| import 'dart:io'; | ||
|
|
||
| /// A script to wrap markdown lines at 80 columns, preserving headings and code blocks. | ||
| void main(List<String> arguments) { | ||
| if (arguments.isEmpty) { | ||
| print('Usage: dart wrap_lines.dart <file_path>'); | ||
| exit(1); | ||
| } | ||
|
|
||
| final filePath = arguments[0]; | ||
| final file = File(filePath); | ||
|
|
||
| if (!file.existsSync()) { | ||
| print('File not found: $filePath'); | ||
| exit(1); | ||
| } | ||
|
|
||
| final content = file.readAsStringSync(); | ||
| final wrappedContent = wrapMarkdown(content); | ||
| file.writeAsStringSync(wrappedContent); | ||
|
|
||
| print('Successfully wrapped markdown for $filePath'); | ||
| } | ||
|
|
||
| String wrapMarkdown(String content, {int width = 80}) { | ||
| final lines = content.split('\n'); | ||
| final output = <String>[]; | ||
| bool inCodeBlock = false; | ||
|
|
||
| for (final line in lines) { | ||
| final stripped = line.trim(); | ||
|
|
||
| // Handle code blocks | ||
| if (stripped.startsWith('```') || stripped.startsWith('~~~')) { | ||
| inCodeBlock = !inCodeBlock; | ||
| output.add(line); | ||
| continue; | ||
| } | ||
|
|
||
| if (inCodeBlock) { | ||
| output.add(line); | ||
| continue; | ||
| } | ||
|
|
||
| // Handle headings | ||
| if (stripped.startsWith('#')) { | ||
| output.add(line); | ||
| continue; | ||
| } | ||
|
|
||
| // Handle empty lines | ||
| if (stripped.isEmpty) { | ||
| output.add(''); | ||
| continue; | ||
| } | ||
|
|
||
| // Handle lists or quotes (matching python script's simple approach) | ||
| if (stripped.startsWith('-') || | ||
| stripped.startsWith('*') || | ||
| RegExp(r'^\d+\.').hasMatch(stripped)) { | ||
| output.addAll(wrapText(line, width)); | ||
| continue; | ||
| } | ||
|
|
||
| // Normal text paragraph | ||
| output.addAll(wrapText(line, width)); | ||
| } | ||
|
|
||
| return output.join('\n'); | ||
| } | ||
|
|
||
| List<String> wrapText(String text, int width) { | ||
| final leadingSpace = RegExp(r'^\s*').stringMatch(text) ?? ''; | ||
| final content = text.trim(); | ||
|
|
||
| if (content.isEmpty) return [leadingSpace]; | ||
|
|
||
| // Split by spaces that follow punctuation (.,;:!?) | ||
| // We use a lookbehind to keep the punctuation with the preceding chunk. | ||
| final chunks = content.split(RegExp(r'(?<=[.,;:!?])\s+')); | ||
| final lines = <String>[]; | ||
| var currentLine = leadingSpace; | ||
|
|
||
| for (final chunk in chunks) { | ||
| // If the chunk itself is longer than width, fallback to word wrapping for this chunk | ||
| if (chunk.length > width) { | ||
| // Flush current line if not empty | ||
| if (currentLine != leadingSpace) { | ||
| lines.add(currentLine); | ||
| currentLine = leadingSpace; | ||
| } | ||
|
|
||
| // Word wrap the chunk | ||
| final words = chunk.split(RegExp(r'\s+')); | ||
| for (final word in words) { | ||
| final space = currentLine == leadingSpace ? '' : ' '; | ||
| if ((currentLine.length + space.length + word.length) > width) { | ||
| if (currentLine != leadingSpace) { | ||
| lines.add(currentLine); | ||
| currentLine = leadingSpace + word; | ||
| } else { | ||
| lines.add(leadingSpace + word); | ||
| currentLine = leadingSpace; | ||
| } | ||
| } else { | ||
| currentLine += space + word; | ||
| } | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| final space = currentLine == leadingSpace ? '' : ' '; | ||
| if ((currentLine.length + space.length + chunk.length) > width) { | ||
| if (currentLine != leadingSpace) { | ||
| lines.add(currentLine); | ||
| } | ||
| currentLine = leadingSpace + chunk; | ||
| } else { | ||
| currentLine += space + chunk; | ||
| } | ||
| } | ||
|
|
||
| if (currentLine != leadingSpace) { | ||
| lines.add(currentLine); | ||
| } | ||
|
|
||
| return lines; | ||
| } | ||
|
antfitch marked this conversation as resolved.
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.