-
Notifications
You must be signed in to change notification settings - Fork 11
feat: support AGENTS.md #63
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
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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,6 @@ | ||
| ## Tools | ||
|
|
||
| ### Biome | ||
| - Run `npm run lint` to lint your code | ||
| - Run `npm run format` to format your code | ||
| - Configuration file: `biome.json` | ||
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,6 @@ | ||
| ## Tools | ||
|
|
||
| ### ESLint | ||
| - Run `npm run lint` to lint your code | ||
| - Configuration file: `eslint.config.mjs` | ||
| - Supports JavaScript and TypeScript |
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,5 @@ | ||
| ## Tools | ||
|
|
||
| ### Prettier | ||
| - Run `npm run format` to format your code | ||
| - Configuration in `.prettierrc` |
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,118 @@ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { assert, beforeEach, test } from '@rstest/core'; | ||
| import { create } from '../dist/index.js'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const testDir = path.join(__dirname, 'temp'); | ||
| const fixturesDir = path.join(__dirname, 'fixtures', 'agents-md'); | ||
|
|
||
| beforeEach(() => { | ||
| // Clean up test directory before each test | ||
| if (fs.existsSync(testDir)) { | ||
| fs.rmSync(testDir, { recursive: true }); | ||
| } | ||
| fs.mkdirSync(testDir, { recursive: true }); | ||
|
|
||
| // Store original argv | ||
| const originalArgv = process.argv; | ||
|
|
||
| // Return cleanup function | ||
| return () => { | ||
| // Restore original argv and clean up | ||
| process.argv = originalArgv; | ||
| if (fs.existsSync(testDir)) { | ||
| fs.rmSync(testDir, { recursive: true }); | ||
| } | ||
| }; | ||
| }); | ||
|
|
||
| test('should generate AGENTS.md with no tools selected', async () => { | ||
| const projectDir = path.join(testDir, 'no-tools'); | ||
| process.argv = ['node', 'test', '--dir', projectDir, '--template', 'vanilla']; | ||
|
|
||
| await create({ | ||
| name: 'test', | ||
| root: fixturesDir, | ||
| templates: ['vanilla'], | ||
| getTemplateName: async () => 'vanilla', | ||
| mapESLintTemplate: () => null, | ||
| }); | ||
|
|
||
| const agentsPath = path.join(projectDir, 'AGENTS.md'); | ||
| assert.strictEqual(fs.existsSync(agentsPath), true); | ||
|
|
||
| const content = fs.readFileSync(agentsPath, 'utf-8'); | ||
| assert.match(content, /## Template Info/); | ||
| assert.match(content, /## Development/); | ||
| // template-common has Tools section | ||
| assert.match(content, /## Tools/); | ||
| assert.match(content, /### Common Tools/); | ||
| }); | ||
|
|
||
| test('should generate AGENTS.md with single tool selected', async () => { | ||
| const projectDir = path.join(testDir, 'single-tool'); | ||
| process.argv = [ | ||
| 'node', | ||
| 'test', | ||
| '--dir', | ||
| projectDir, | ||
| '--template', | ||
| 'vanilla', | ||
| '--tools', | ||
| 'biome', | ||
| ]; | ||
|
|
||
| await create({ | ||
| name: 'test', | ||
| root: fixturesDir, | ||
| templates: ['vanilla'], | ||
| getTemplateName: async () => 'vanilla', | ||
| mapESLintTemplate: () => null, | ||
| }); | ||
|
|
||
| const agentsPath = path.join(projectDir, 'AGENTS.md'); | ||
| assert.strictEqual(fs.existsSync(agentsPath), true); | ||
|
|
||
| const content = fs.readFileSync(agentsPath, 'utf-8'); | ||
| assert.match(content, /## Template Info/); | ||
| assert.match(content, /## Development/); | ||
| assert.match(content, /## Tools/); | ||
| assert.match(content, /### Common Tools/); // from template-common | ||
| assert.match(content, /### Biome/); // from template-biome | ||
| }); | ||
|
|
||
| test('should generate AGENTS.md with eslint tool and template mapping', async () => { | ||
| const projectDir = path.join(testDir, 'eslint-tool'); | ||
| process.argv = [ | ||
| 'node', | ||
| 'test', | ||
| '--dir', | ||
| projectDir, | ||
| '--template', | ||
| 'vanilla', | ||
| '--tools', | ||
| 'eslint', | ||
| ]; | ||
|
|
||
| await create({ | ||
| name: 'test', | ||
| root: fixturesDir, | ||
| templates: ['vanilla'], | ||
| getTemplateName: async () => 'vanilla', | ||
| mapESLintTemplate: (templateName) => { | ||
| if (templateName === 'vanilla') return 'vanilla-ts'; | ||
| return null; | ||
| }, | ||
| }); | ||
|
|
||
| const agentsPath = path.join(projectDir, 'AGENTS.md'); | ||
| assert.strictEqual(fs.existsSync(agentsPath), true); | ||
|
|
||
| const content = fs.readFileSync(agentsPath, 'utf-8'); | ||
| assert.match(content, /## Template Info/); | ||
| assert.match(content, /## Development/); | ||
| assert.match(content, /## Tools/); | ||
| assert.match(content, /### ESLint/); // from template-eslint/AGENTS.md | ||
| }); |
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,4 @@ | ||
| { | ||
| "name": "test-fixtures-agents-md", | ||
| "version": "1.0.0" | ||
| } |
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,10 @@ | ||
| ## Development | ||
|
|
||
| ### Common Development | ||
| - Common development instructions | ||
| - Available in all templates | ||
|
|
||
| ## Tools | ||
|
|
||
| ### Common Tools | ||
| - Tools that apply to all templates |
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,4 @@ | ||
| { | ||
| "name": "test-common", | ||
| "version": "1.0.0" | ||
| } |
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,5 @@ | ||
| ## Template Info | ||
|
|
||
| ### Vanilla Template | ||
| - This is vanilla template specific content | ||
| - Only available in vanilla template |
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,4 @@ | ||
| { | ||
| "name": "test-vanilla", | ||
| "version": "1.0.0" | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we tell agent this information? I suppose the agents already knows about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense. I've removed the prompts for the location of configuration.