Skip to content

Commit 0426f33

Browse files
Add a Skill to create release notes (#9711)
1 parent 2056445 commit 0426f33

3 files changed

Lines changed: 161 additions & 2 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
name: adding-release-notes
3+
description: Adds user-facing change descriptions to DevTools release notes. Use when documenting improvements, fixes, or new features in the NEXT_RELEASE_NOTES.md file.
4+
---
5+
6+
# Adding Release Notes
7+
8+
This skill helps automate adding release notes to `packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md`.
9+
10+
## Workflow
11+
Copy this checklist into your response to track progress:
12+
13+
```markdown
14+
Release Notes Progress:
15+
- [ ] Step 1: Formulate the entry (past tense)
16+
- [ ] Step 2: Find the PR number (if not already known)
17+
- [ ] Step 3: Determine the section (Inspector, Memory, etc.)
18+
- [ ] Step 4: Add the entry (use scripts/add_note.dart)
19+
- [ ] Step 5: Add images (if applicable)
20+
```
21+
22+
## Guidelines
23+
24+
### 1. Identify the PR Number
25+
If the PR number is unknown, use the following methods to find it:
26+
- **Local Branch**: Identify the branch name using `git branch` or `git log`. If the branch is pushed to origin, it often has a linked PR.
27+
- **GitHub CLI (`gh`)**: Use the GitHub CLI to find the PR associated with the current branch.
28+
- **IMPORTANT**: Always use `PAGER=cat` to prevent `gh` from hanging in non-interactive terminals.
29+
- Command: `PAGER=cat gh pr list --head <branch_name> --json number,title`
30+
- **Search by Change Description**: Search open PRs using keywords from your change title or description.
31+
- Command: `PAGER=cat gh pr list --search "<keywords>" --limit 5`
32+
- **Web Search**: If CLI tools fail, use `search_web` to find the PR on GitHub:
33+
- Query: `site:github.com/flutter/devtools "Add support for searching within the log details view"`
34+
35+
### 2. Formulate the Entry
36+
- **Tense**: Always use **past tense** (e.g., "Added", "Improved", "Fixed").
37+
- **Punctuation**: Always end entries with a **period**.
38+
- **Template**: `* <Description>. [#<PR_NUMBER>](https://github.com/flutter/devtools/pull/<PR_NUMBER>)`
39+
- **Placeholder**: Use `TODO` if you have exhausted all search methods and the PR has not been created yet.
40+
- **Images**: If adding an image, indent it by two spaces to align with the bullet point, and ensure there is only one newline between the text and the image.
41+
- Correct Format:
42+
```markdown
43+
- Added support for XYZ. [#TODO](https://github.com/flutter/devtools/pull/TODO)
44+
![](images/my_feature.png)
45+
```
46+
- **Examples**:
47+
- `* Added support for XYZ. [#12345](https://github.com/flutter/devtools/pull/12345)`
48+
- `* Fixed a crash in the ABC screen. [#67890](https://github.com/flutter/devtools/pull/67890)`
49+
50+
### 3. User-Facing Changes Only
51+
- **Criteria**: Focus on **what** changed for the user, not **how** it was implemented.
52+
- **Avoid**: Technical details like "Implemented XYZ with a new controller", "Updated the build method", or naming internal classes.
53+
- **Example (Bad)**: `* Implemented log details search using SearchControllerMixin. [#TODO](https://github.com/flutter/devtools/pull/TODO)`
54+
- **Example (Good)**: `* Added search support to the log details view. [#TODO](https://github.com/flutter/devtools/pull/TODO)`
55+
56+
### 4. Determine Section
57+
Match the change to the section in `NEXT_RELEASE_NOTES.md`:
58+
- `General updates`
59+
- `Inspector updates`
60+
- `Performance updates`
61+
- `CPU profiler updates`
62+
- `Memory updates`
63+
- `Debugger updates`
64+
- `Network profiler updates`
65+
- `Logging updates`
66+
- `App size tool updates`
67+
- `Deep links tool updates`
68+
- `VS Code sidebar updates`
69+
- `DevTools extension updates`
70+
- `Advanced developer mode updates`
71+
72+
### 5. Add to NEXT_RELEASE_NOTES.md
73+
Use the provided utility script to insert the note safely. The script handles replacing the TODO placeholder if it's the first entry in that section.
74+
75+
```bash
76+
dart .agents/skills/adding-release-notes/scripts/add_note.dart "Inspector updates" "Added XYZ support" TODO
77+
```
78+
79+
### 6. Optional: Images
80+
Add images to `packages/devtools_app/release_notes/images/` and reference them:
81+
```markdown
82+
![Accessible description](images/screenshot.png "Hover description")
83+
```
84+
**Constraint**: Use **dark mode** for screenshots.
85+
86+
## Resources
87+
- [README.md](../../packages/devtools_app/release_notes/README.md): Official project guidance.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright 2019 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
4+
5+
import 'dart:io';
6+
7+
void main(List<String> args) {
8+
if (args.length < 3) {
9+
print('Usage: dart add_note.dart <section> <note> <pr_number>');
10+
exit(1);
11+
}
12+
13+
final section = args[0].trim();
14+
final note = args[1].trim();
15+
final pr = args[2].trim();
16+
17+
final prLink = pr == 'TODO'
18+
? '[TODO](https://github.com/flutter/devtools/pull/TODO)'
19+
: '[#$pr](https://github.com/flutter/devtools/pull/$pr)';
20+
21+
final filePath = 'packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md';
22+
final file = File(filePath);
23+
24+
if (!file.existsSync()) {
25+
print('Error: $filePath not found.');
26+
exit(1);
27+
}
28+
29+
var content = file.readAsStringSync();
30+
31+
if (!content.contains('## $section')) {
32+
print("Error: Section '$section' not found.");
33+
exit(1);
34+
}
35+
36+
final noteWithPeriod = note.endsWith('.') ? note : '$note.';
37+
final newEntry = '- $noteWithPeriod $prLink\n';
38+
39+
// Check for TODO placeholder.
40+
const todoText = 'TODO: Remove this section if there are not any updates.';
41+
final todoPattern = RegExp(
42+
'## ${RegExp.escape(section)}\\s*\\n\\s*${RegExp.escape(todoText)}\\s*\\n*',
43+
);
44+
45+
if (todoPattern.hasMatch(content)) {
46+
content = content.replaceFirst(todoPattern, '## $section\n\n$newEntry\n');
47+
} else {
48+
// Append to existing list in the section.
49+
final sectionHeader = '## $section';
50+
final sectionStart = content.indexOf(sectionHeader);
51+
52+
// Find the next section start or the end of the file.
53+
var nextSectionStart = content.indexOf('\n## ', sectionStart + 1);
54+
if (nextSectionStart == -1) {
55+
nextSectionStart =
56+
content.indexOf('\n# Full commit history', sectionStart + 1);
57+
}
58+
if (nextSectionStart == -1) {
59+
nextSectionStart = content.length;
60+
}
61+
62+
var sectionContent =
63+
content.substring(sectionStart, nextSectionStart).trimRight();
64+
sectionContent += '\n$newEntry';
65+
66+
content =
67+
'${content.substring(0, sectionStart)}$sectionContent\n${content.substring(nextSectionStart).trimLeft()}';
68+
}
69+
70+
file.writeAsStringSync(content);
71+
print('Successfully added note to $section.');
72+
}

pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,10 @@ packages:
758758
dependency: transitive
759759
description:
760760
name: source_gen
761-
sha256: "1d562a3c1f713904ebbed50d2760217fd8a51ca170ac4b05b0db490699dbac17"
761+
sha256: adc962c96fffb2de1728ef396a995aaedcafbe635abdca13d2a987ce17e57751
762762
url: "https://pub.dev"
763763
source: hosted
764-
version: "4.2.0"
764+
version: "4.2.1"
765765
source_map_stack_trace:
766766
dependency: transitive
767767
description:

0 commit comments

Comments
 (0)