-
Notifications
You must be signed in to change notification settings - Fork 60
Add a skill for linter #74
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
82505fd
Add a skill in the location and format of https://pub.dev/packages/sk…
reidbaker 71861b0
Change example to ensure the validation is a success
reidbaker 41725c7
fix the wrong version in the readme
reidbaker d500099
use feedback after getting token to improve skill
reidbaker 9263bb8
Revert yaml for custom skills integration
reidbaker 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,10 @@ | ||
| # Skills shipped with dart_skills_lint | ||
|
|
||
| The skills in this directory are shipped with the `dart_skills_lint` package. | ||
| They are intended for users of the package to help them use it effectively. | ||
|
|
||
| To install these skills into your IDE, you can use the [skills](https://pub.dev/packages/skills) package on pub: | ||
| ```bash | ||
| dart pub global activate skills | ||
| skills get | ||
| ``` |
154 changes: 154 additions & 0 deletions
154
tool/dart_skills_lint/skills/dart-skills-lint-validation/SKILL.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,154 @@ | ||
| --- | ||
| name: dart-skills-lint-validation | ||
| description: |- | ||
| Use this skill when you need to validate that AI agent skills meet the specification. | ||
| This includes generic validation of any skills for users that have Dart installed, | ||
| as well as integrating dart_skills_lint into a Dart project as a dev_dependency | ||
| to automate skill validation in tests or CI/CD. | ||
| --- | ||
|
|
||
| # Validating Skills with dart_skills_lint | ||
|
|
||
| ## Contents | ||
| - [Usage for Agents (CLI)](#usage-for-agents-cli) | ||
| - [Setup for Dart Developers](#setup-for-dart-developers) | ||
| - [Authoring Custom Rules](#authoring-custom-rules) | ||
| - [Workflow: Validating Skills](#workflow-validating-skills) | ||
| - [Specification Reference](#specification-reference) | ||
|
|
||
| ## Usage for Agents (CLI) | ||
| Use the `dart_skills_lint` CLI to validate skills. Choose the appropriate workflow based on your environment: | ||
|
|
||
| ### Scenario A: The package is in your project dependencies | ||
| Use this method if you are working within a project that has `dart_skills_lint` listed in `pubspec.yaml`. | ||
| Run: | ||
| ```bash | ||
| dart run dart_skills_lint -d .agents/skills | ||
| ``` | ||
|
|
||
| ### Scenario B: The package is activated globally | ||
| Use this method if you want to validate skills across multiple projects without adding a dependency to each one. | ||
| Run: | ||
| ```bash | ||
| dart pub global run dart_skills_lint -d .agents/skills | ||
| ``` | ||
|
|
||
| ### Common Flags | ||
| - `-d`, `--skills-directory`: Specifies a root directory containing sub-folders of skills to validate. Can be passed multiple times. | ||
| - `-s`, `--skill`: Specifies an individual skill directory to validate directly. Can be passed multiple times. | ||
| - `-q`, `--quiet`: Hide non-error validation output. | ||
| - `-w`, `--print-warnings`: Enable printing of warning messages. | ||
| - `--fast-fail`: Halt execution immediately on the error. | ||
| - `--ignore-config`: Ignore the YAML configuration file entirely. | ||
|
|
||
| ## Setup for Dart Developers | ||
| Setup validation in your Dart project: | ||
|
|
||
| 1. Add `dart_skills_lint` to your `pubspec.yaml` as a `dev_dependency`: | ||
| ```yaml | ||
| dev_dependencies: | ||
| dart_skills_lint: ^0.2.0 | ||
| ``` | ||
|
|
||
| 2. Integrate the linter into your automated tests by importing the package and calling `validateSkills`. This ensures your skills are automatically validated whenever you run `dart test`. | ||
|
|
||
| Example `test/lint_skills_test.dart`: | ||
| ```dart | ||
| import 'package:dart_skills_lint/dart_skills_lint.dart'; | ||
| import 'package:test/test.dart'; | ||
|
|
||
| void main() { | ||
| test('Run skills linter', () async { | ||
| final isValid = await validateSkills( | ||
| skillDirPaths: ['.agents/skills'], | ||
| ); | ||
| expect(isValid, isTrue); | ||
| }); | ||
| } | ||
| ``` | ||
|
|
||
| 3. (Optional) Create a configuration file `dart_skills_lint.yaml` in the root of your project to customize rules and directories for the CLI: | ||
| **Note:** If you use `validateSkills` directly in tests, the `dart_skills_lint.yaml` file is ignored by default, and you should pass configuration programmatically if needed. | ||
| ```yaml | ||
| dart_skills_lint: | ||
| rules: | ||
| check-relative-paths: error | ||
| check-absolute-paths: error | ||
| directories: | ||
| - path: ".agents/skills" | ||
| ``` | ||
|
|
||
| ## Authoring Custom Rules | ||
| To author custom rules, extend the `SkillRule` class and pass them to `validateSkills`. | ||
|
|
||
| Example: | ||
| ```dart | ||
| import 'package:dart_skills_lint/dart_skills_lint.dart'; | ||
|
|
||
| class MyCustomRule extends SkillRule { | ||
| @override | ||
| final String name = 'my-custom-rule'; | ||
|
|
||
| @override | ||
| final AnalysisSeverity severity = AnalysisSeverity.warning; | ||
|
|
||
| @override | ||
| Future<List<ValidationError>> validate(SkillContext context) async { | ||
| final errors = <ValidationError>[]; | ||
| final yaml = context.parsedYaml; | ||
| if (yaml == null) return errors; | ||
|
|
||
| if (yaml['metadata']?['deprecated'] == true) { | ||
| errors.add(ValidationError( | ||
| ruleId: name, | ||
| severity: severity, | ||
| file: 'SKILL.md', | ||
| message: 'This skill is marked as deprecated.', | ||
| )); | ||
| } | ||
| return errors; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Use it in your test: | ||
| ```dart | ||
| await validateSkills( | ||
| skillDirPaths: ['.agents/skills'], | ||
| customRules: [MyCustomRule()], | ||
| ); | ||
| ``` | ||
|
|
||
| ## Workflow: Validating Skills | ||
| Follow this workflow to validate skills: | ||
|
|
||
| 1. **Run the validator**: Execute the linter on your skills directory. | ||
| ```bash | ||
| dart run dart_skills_lint -d .agents/skills | ||
| ``` | ||
| 2. **Review errors**: Check the output for any errors or warnings. | ||
| 3. **Fix violations**: Edit the `SKILL.md` or directory structure to resolve issues. | ||
| 4. **Verify**: Re-run the validator to ensure all checks pass. | ||
|
|
||
| ### Task Progress | ||
| - [ ] Run validator | ||
| - [ ] Review errors | ||
| - [ ] Fix violations | ||
| - [ ] Verify clean run | ||
|
|
||
| ## Specification Reference | ||
| <details> | ||
| <summary>View Skill Specification Constraints</summary> | ||
|
|
||
| ### Directory and File Structure | ||
| - Mandatory `SKILL.md` file at the root of the skill folder. | ||
| - Directories starting with a dot `.` (e.g., `.dart_tool`) are ignored. | ||
|
|
||
| ### Metadata (YAML Frontmatter) | ||
| - Required fields: `name` and `description`. | ||
|
|
||
| ### Field Constraints | ||
| - **Name**: Max 64 characters, lowercase alphanumeric and hyphens only. Must match the parent directory name. | ||
| - **Description**: Max 1024 characters. | ||
| - **Compatibility**: Max 500 characters. | ||
| </details> | ||
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.