Skip to content

Commit 3dcbf8a

Browse files
authored
Simplify the ai-tools CLI (#58066)
1 parent 81753ec commit 3dcbf8a

File tree

8 files changed

+198
-234
lines changed

8 files changed

+198
-234
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"exports": "./src/frame/server.ts",
1313
"scripts": {
1414
"add-content-type": "tsx src/content-render/scripts/add-content-type.ts",
15-
"ai-edit": "tsx src/ai-editors/scripts/ai-edit.ts",
15+
"ai-tools": "tsx src/ai-tools/scripts/ai-tools.ts",
1616
"all-documents": "tsx src/content-render/scripts/all-documents/cli.ts",
1717
"analyze-text": "tsx src/search/scripts/analyze-text.ts",
1818
"analyze-comment": "tsx src/events/scripts/analyze-comment-cli.ts",

src/ai-editors/prompts/versioning-editor.prompt.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/ai-editors/scripts/ai-edit.ts

Lines changed: 0 additions & 195 deletions
This file was deleted.
Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
# AI-powered editors
1+
# AI-powered tools
22

33
A CLI tool for using AI to edit documentation according to defined prompts.
44

5-
This tool runs an AI review of content files based on an (extensible) set of prompt-driven guidelines. The default is versioning. In the future we might add: scannability, readability, style, technical accuracy.
5+
This tool refines content files using AI based on an (extensible) set of prompt-driven guidelines. The default is versioning refinement. In the future we might add: scannability, readability, style, technical accuracy.
66

77
This script calls the [Models API](https://docs.github.com/en/rest/models/inference?apiVersion=2022-11-28#run-an-inference-request). It requires a personal access token with Models scopes in your `.env` file.
88

99
## Usage
1010

1111
```sh
12-
tsx src/ai-editors/scripts/ai-edit.js --editor <type> --response <type> --files <file1.md>
12+
# Direct command
13+
tsx src/ai-tools/scripts/ai-tools.ts --refine <type> --files <file1.md>
14+
15+
# Or via npm script
16+
npm run ai-tools -- --refine <type> --files <file1.md>
1317
```
1418

1519
* `--files, -f`: One or more content file paths to process (required).
16-
* `--response, -r`: Specify the AI response format. Options: `rewrite` (default), `list`, `json`.
17-
* `--editor, -e`: Specify one or more editor types (default: `versioning`).
20+
* `--refine, -r`: Specify one or more refinement types (default: `versioning`).
1821

19-
**Example:**
22+
**Examples:**
2023

2124
```sh
22-
tsx src/ai-editors/scripts/ai-edit.js --files content/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo.md --editor versioning --response list
25+
# Direct command
26+
tsx src/ai-tools/scripts/ai-tools.ts --files content/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo.md --refine versioning
27+
28+
# Via npm script
29+
npm run ai-tools -- --files content/copilot/tutorials/coding-agent/get-the-best-results.md --refine intro
2330
```
2431

2532
## Requirements
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
messages:
2+
- role: system
3+
content: >-
4+
{{markdownPrompt}}
5+
- role: user
6+
content: >-
7+
Review this content file according to the provided system prompt.
8+
{{input}}
9+
model: openai/gpt-5

src/ai-tools/prompts/versioning.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Your task is to remove the conditional markup from content files that looks like {% ifversion fpt or ghec %}Foo{% endif %}.
2+
3+
You need to first try to write the content without any versioning at all, so it still makes sense to customers without causing confusion. If you need to explain versioning differences, do so using prose.
4+
5+
Here are the prose guidelines to follow:
6+
7+
* For versioning at the article level:
8+
- When the feature is only available in certain products, use the "Who can
9+
use this feature?" box to convey the content of this article applies only
10+
to XYZ products.
11+
- When an article only exists before the functionality is in older versions
12+
of GHES (and not dotcom and newer versions of GHES), just remove that article.
13+
(This is akin to declining to document a feature.)
14+
15+
* For versioning at the heading level:
16+
- Use prose similar to the "Who can use this feature?" to convey that the
17+
content of this section applies only to XYZ products.
18+
19+
* For versioning the paragraph or sentence level:
20+
- Use one of the following content strategies:
21+
- If you're briefly introducing a feature and then linking to an article,
22+
there's no need to specify versioning. Let folks learn availability when
23+
they follow the link, via the "Who can use this feature?" box.
24+
- When necessary, start sentences with "With GitHub Enterprise Cloud...",
25+
"On GitHub.com", "With GitHub Enterprise Server 3.15+..." etc.
26+
- End list items with "(GitHub Enterprise Cloud only)", "(GitHub.com only)", etc.
27+
28+
Review this content according to the versioning guideline above. Edit the versioning only.
29+
30+
**IMPORTANT OUTPUT FORMAT:**
31+
- Return the complete, updated file content (including frontmatter)
32+
- Make ONLY the versioning changes specified above
33+
- Do NOT add explanatory text before or after the content
34+
- Do NOT wrap the output in markdown code blocks
35+
- Output should be ready to write directly to the original file

0 commit comments

Comments
 (0)