-
Notifications
You must be signed in to change notification settings - Fork 5.8k
feat: add --agent-skills switch to init command #1561
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
Open
dhilipkumars
wants to merge
1
commit into
github:main
Choose a base branch
from
dhilipkumars:agent-skills
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+170
−1
Open
Changes from all commits
Commits
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
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |||||||
| import shutil | ||||||||
| import shlex | ||||||||
| import json | ||||||||
| import yaml | ||||||||
| from pathlib import Path | ||||||||
| from typing import Optional, Tuple | ||||||||
|
|
||||||||
|
|
@@ -942,6 +943,134 @@ def ensure_executable_scripts(project_path: Path, tracker: StepTracker | None = | |||||||
| for f in failures: | ||||||||
| console.print(f" - {f}") | ||||||||
|
|
||||||||
|
|
||||||||
| def install_agent_skills(project_path: Path, tracker: StepTracker = None) -> bool: | ||||||||
| """ | ||||||||
| Install Prompt.MD files from templates/commands/ as agent skills per agentskills.io spec. | ||||||||
|
|
||||||||
| Args: | ||||||||
| project_path: Target project directory | ||||||||
| tracker: Optional progress tracker | ||||||||
|
|
||||||||
| Returns: | ||||||||
| True if installation successful, False otherwise | ||||||||
| """ | ||||||||
| # Find the spec-kit templates directory | ||||||||
| # The templates are bundled with the package, so look relative to this file | ||||||||
| script_dir = Path(__file__).parent.parent.parent # Go up from src/specify_cli/ to repo root | ||||||||
| templates_dir = script_dir / "templates" / "commands" | ||||||||
|
|
||||||||
| if not templates_dir.exists(): | ||||||||
| if tracker: | ||||||||
| tracker.error("agent-skills", "templates/commands not found") | ||||||||
| else: | ||||||||
| console.print("[yellow]Warning: templates/commands directory not found, skipping skills installation[/yellow]") | ||||||||
| return False | ||||||||
|
|
||||||||
| # Get all markdown files | ||||||||
| command_files = list(templates_dir.glob("*.md")) | ||||||||
| if not command_files: | ||||||||
| if tracker: | ||||||||
| tracker.skip("agent-skills", "no command templates found") | ||||||||
| else: | ||||||||
| console.print("[yellow]No command templates found to install[/yellow]") | ||||||||
| return False | ||||||||
|
|
||||||||
| # Create skills directory | ||||||||
| skills_dir = project_path / ".agent" / "skills" | ||||||||
| skills_dir.mkdir(parents=True, exist_ok=True) | ||||||||
|
|
||||||||
| if tracker: | ||||||||
| tracker.add("agent-skills", f"Install {len(command_files)} agent skills") | ||||||||
| tracker.start("agent-skills") | ||||||||
|
|
||||||||
| installed_count = 0 | ||||||||
| for command_file in command_files: | ||||||||
| try: | ||||||||
| # Read the template file | ||||||||
| with open(command_file, 'r', encoding='utf-8') as f: | ||||||||
| content = f.read() | ||||||||
|
|
||||||||
| # Parse YAML frontmatter | ||||||||
| if content.startswith('---'): | ||||||||
| parts = content.split('---', 2) | ||||||||
| if len(parts) >= 3: | ||||||||
| frontmatter = yaml.safe_load(parts[1]) | ||||||||
| body = parts[2].strip() | ||||||||
| else: | ||||||||
| frontmatter = {} | ||||||||
| body = content | ||||||||
| else: | ||||||||
| frontmatter = {} | ||||||||
| body = content | ||||||||
|
|
||||||||
| # Generate skill name: speckit-<command-name> | ||||||||
| command_name = command_file.stem | ||||||||
| skill_name = f"speckit-{command_name}" | ||||||||
|
|
||||||||
| # Create skill directory | ||||||||
| skill_dir = skills_dir / skill_name | ||||||||
| skill_dir.mkdir(parents=True, exist_ok=True) | ||||||||
|
|
||||||||
| # Generate enhanced description | ||||||||
| original_desc = frontmatter.get('description', '') | ||||||||
| if command_name == 'specify': | ||||||||
| enhanced_desc = "Create or update feature specifications from natural language descriptions. Use when starting new features or refining requirements. Generates spec.md with user stories, functional requirements, and acceptance criteria following spec-driven development methodology." | ||||||||
| elif command_name == 'plan': | ||||||||
| enhanced_desc = "Generate technical implementation plans from feature specifications. Use after creating a spec to define architecture, tech stack, and implementation phases. Creates plan.md with detailed technical design." | ||||||||
| elif command_name == 'tasks': | ||||||||
| enhanced_desc = "Break down implementation plans into actionable task lists. Use after planning to create a structured task breakdown. Generates tasks.md with ordered, dependency-aware tasks." | ||||||||
| elif command_name == 'implement': | ||||||||
| enhanced_desc = "Execute all tasks from the task breakdown to build the feature. Use after task generation to systematically implement the planned solution following TDD approach where applicable." | ||||||||
| elif command_name == 'analyze': | ||||||||
| enhanced_desc = "Perform cross-artifact consistency analysis across spec.md, plan.md, and tasks.md. Use after task generation to identify gaps, duplications, and inconsistencies before implementation." | ||||||||
| elif command_name == 'clarify': | ||||||||
| enhanced_desc = "Structured clarification workflow for underspecified requirements. Use before planning to resolve ambiguities through coverage-based questioning. Records answers in spec clarifications section." | ||||||||
| elif command_name == 'constitution': | ||||||||
| enhanced_desc = "Create or update project governing principles and development guidelines. Use at project start to establish code quality, testing standards, and architectural constraints that guide all development." | ||||||||
| elif command_name == 'checklist': | ||||||||
| enhanced_desc = "Generate custom quality checklists for validating requirements completeness and clarity. Use to create unit tests for English that ensure spec quality before implementation." | ||||||||
| elif command_name == 'taskstoissues': | ||||||||
| enhanced_desc = "Convert tasks from tasks.md into GitHub issues. Use after task breakdown to track work items in GitHub project management." | ||||||||
| else: | ||||||||
| enhanced_desc = original_desc or f"Spec-kit workflow command: {command_name}" | ||||||||
|
|
||||||||
| # Create SKILL.md following agentskills.io spec | ||||||||
| skill_content = f"""--- | ||||||||
| name: {skill_name} | ||||||||
| description: {enhanced_desc} | ||||||||
| compatibility: Requires git and spec-kit project structure with .specify/ directory | ||||||||
| --- | ||||||||
|
|
||||||||
| # Speckit {command_name.title()} Skill | ||||||||
|
|
||||||||
| {body} | ||||||||
| """ | ||||||||
|
|
||||||||
| # Write SKILL.md | ||||||||
| skill_file = skill_dir / "SKILL.md" | ||||||||
| with open(skill_file, 'w', encoding='utf-8') as f: | ||||||||
| f.write(skill_content) | ||||||||
|
|
||||||||
| installed_count += 1 | ||||||||
|
|
||||||||
| except Exception as e: | ||||||||
| console.print(f"[yellow]Warning: Failed to install skill {command_name}: {e}[/yellow]") | ||||||||
|
||||||||
| console.print(f"[yellow]Warning: Failed to install skill {command_name}: {e}[/yellow]") | |
| skill_label = command_name if 'command_name' in locals() else command_file.stem | |
| console.print(f"[yellow]Warning: Failed to install skill {skill_label}: {e}[/yellow]") |
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.
Inconsistent naming: the directory is referred to as
.specify/here but the actual skills are installed to.agent/directory. This should be clarified or corrected to avoid confusion.