generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 33
feat(tools): add reference integrity, size validation, and skill scaffolding #87
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
6 commits
Select commit
Hold shift + click to select a range
8925696
feat(tools): add reference integrity, size validation, and skill scaf…
theagenticguy 66b7789
feat(tools): add URL liveness checker and size validator with extract…
theagenticguy 16b458f
fix(tools): address Copilot review feedback on PR #87
theagenticguy 7d10160
fix(tools): clamp resolve_ref candidates to repository root
theagenticguy 89ba0e9
security(tools): scope GitHub token to GitHub domains only, harden in…
theagenticguy 9ac56b9
fix(tools): add uv to mise.toml managed tools
theagenticguy 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,20 @@ | ||
| # URL patterns to skip during liveness checks. | ||
| # Each line is a substring match — if the URL contains this string, it's skipped. | ||
|
|
||
| # Localhost / example / placeholder URLs | ||
| https://localhost | ||
| https://127.0.0.1 | ||
| https://example.com | ||
| https://your- | ||
| https://my- | ||
| https://myapp. | ||
|
|
||
| # CloudFormation / SAM template variables in URLs | ||
| ${AWS:: | ||
|
|
||
| # API endpoints (not browsable) | ||
| https://maps.geo. | ||
| https://places.geo. | ||
| https://routes.geo. | ||
| https://geofencing.geo. | ||
| https://tracking.geo. |
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
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
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
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,129 @@ | ||
| # /// script | ||
| # requires-python = ">=3.12" | ||
| # dependencies = [] | ||
| # /// | ||
| """Scaffold a new skill directory with correct SKILL.md template.""" | ||
|
|
||
| import re | ||
| import sys | ||
| from pathlib import Path | ||
| from string import Template | ||
|
|
||
| ROOT = Path(__file__).resolve().parent.parent | ||
| PLUGINS_DIR = ROOT / "plugins" | ||
| NAME_RE = re.compile(r"^[a-z][a-z0-9-]*$") | ||
|
|
||
| SKILL_TEMPLATE = Template("""\ | ||
| --- | ||
| name: $name | ||
| description: > | ||
| $description | ||
| --- | ||
|
|
||
| # $title | ||
|
|
||
| ## When to Use | ||
|
|
||
| [FILL: Describe the specific scenarios and contexts where this skill applies.] | ||
|
|
||
| ## Core Concepts | ||
|
|
||
| [FILL: Key concepts, terminology, and mental models.] | ||
|
|
||
| ## Quick Reference | ||
|
|
||
| [FILL: The most commonly needed patterns, commands, or code snippets.] | ||
|
|
||
| ## Anti-Patterns | ||
|
|
||
| [FILL: Common mistakes and what to do instead.] | ||
|
|
||
| ## References | ||
|
|
||
| - `references/` — [FILL: Describe what detailed reference material is available.] | ||
| """) | ||
|
|
||
|
|
||
| def main() -> int: | ||
| if len(sys.argv) < 4: | ||
| print(f"Usage: uv run {sys.argv[0]} <plugin-name> <skill-name> <description>") | ||
| print( | ||
| f"Example: uv run {sys.argv[0]} deploy-on-aws my-skill" | ||
| " 'Brief description. Use when the user asks to...'" | ||
| ) | ||
| return 1 | ||
|
|
||
| plugin_name = sys.argv[1] | ||
| skill_name = sys.argv[2] | ||
| description = sys.argv[3] | ||
|
|
||
| # Validate plugin exists and is under PLUGINS_DIR (no path traversal) | ||
| plugin_dir = (PLUGINS_DIR / plugin_name).resolve() | ||
| if not plugin_dir.is_relative_to(PLUGINS_DIR.resolve()): | ||
| print(f"Error: plugin name must not contain path traversal: '{plugin_name}'") | ||
| return 1 | ||
| if not plugin_dir.is_dir(): | ||
| print(f"Error: plugin '{plugin_name}' not found at {plugin_dir}") | ||
| available = sorted( | ||
| d.name for d in PLUGINS_DIR.iterdir() if d.is_dir() and not d.name.startswith(".") | ||
| ) | ||
| if available: | ||
| print(f"Available plugins: {', '.join(available)}") | ||
| return 1 | ||
|
|
||
| # Validate skill name format | ||
| if not NAME_RE.match(skill_name): | ||
| print(f"Error: '{skill_name}' is not a valid skill name") | ||
| print("Must be kebab-case (lowercase letters, digits, hyphens)") | ||
| return 1 | ||
|
|
||
| if len(skill_name) > 64: | ||
| print(f"Error: skill name exceeds 64 characters (current: {len(skill_name)})") | ||
| return 1 | ||
|
|
||
| if "--" in skill_name: | ||
| print(f"Error: '{skill_name}' contains consecutive hyphens") | ||
| return 1 | ||
|
|
||
| # Check reserved words | ||
| if re.search(r"\b(anthropic|claude)\b", skill_name, re.IGNORECASE): | ||
| print(f"Error: '{skill_name}' contains reserved word") | ||
| return 1 | ||
|
|
||
| # Check skill doesn't already exist | ||
| skills_dir = plugin_dir / "skills" | ||
| skill_dir = skills_dir / skill_name | ||
| if skill_dir.exists(): | ||
| print(f"Error: skill '{skill_name}' already exists at {skill_dir}") | ||
| return 1 | ||
|
|
||
| # Warn about trigger phrase | ||
| if "Use when" not in description and "Use this" not in description: | ||
| print("Warning: description should contain 'Use when' or 'Use this' trigger phrase") | ||
|
|
||
| # Create structure | ||
| title = skill_name.replace("-", " ").title() | ||
| skill_dir.mkdir(parents=True) | ||
| (skill_dir / "SKILL.md").write_text( | ||
| SKILL_TEMPLATE.safe_substitute(name=skill_name, description=description, title=title), | ||
| encoding="utf-8", | ||
| ) | ||
theagenticguy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| refs_dir = skill_dir / "references" | ||
| refs_dir.mkdir() | ||
| (refs_dir / ".gitkeep").touch() | ||
|
|
||
| rel_path = skill_dir.relative_to(ROOT) | ||
| print(f"Created skill '{skill_name}' in plugin '{plugin_name}':") | ||
| print(f" {rel_path}/SKILL.md") | ||
| print(f" {rel_path}/references/.gitkeep") | ||
| print() | ||
| print("Next steps:") | ||
| print(f" 1. Edit {rel_path}/SKILL.md — fill in the [FILL] sections") | ||
| print(f" 2. Add reference files to {rel_path}/references/") | ||
| print(f" 3. Run: mise run validate") | ||
|
|
||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) | ||
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
Oops, something went wrong.
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.