From 2a9d76cb14efe3a43e108bc98e929c575e096637 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 9 Nov 2025 22:33:46 +0000 Subject: [PATCH 1/3] feat(migrate): Migrate Promptrek to latest schema version 3.1.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the migration system and all example files to use the latest schema version 3.1.0 instead of 3.0.0. Changes: - Updated migrate.py to target schema v3.1.0 for all migrations - v1.0.0 → v3.1.0 - v2.0.0 → v3.1.0 - v2.1.0 → v3.1.0 - Updated interactive.py to reference v3.1.0 in UI - workflow_migrate now prompts for v3.1 format - workflow_init_project now recommends v3.1 (Current) - Migrated all v2.1.0 example files to v3.1.0 - examples/v21-plugins/*.promptrek.yaml (5 files) - Updated v3.0.0 example file to v3.1.0 - examples/dynamic-variables/project.promptrek.yaml - Updated test_migrate.py to expect v3.1.0 schema version All migration tests pass successfully (67 tests). --- .../dynamic-variables/project.promptrek.yaml | 2 +- .../autonomous-agents.promptrek.yaml | 191 +++--- .../complete-example.promptrek.yaml | 542 ++++++++---------- .../continue-unified.promptrek.yaml | 448 +++++++-------- .../custom-commands.promptrek.yaml | 196 +++---- .../v21-plugins/mcp-servers.promptrek.yaml | 119 ++-- src/promptrek/cli/commands/migrate.py | 32 +- src/promptrek/cli/interactive.py | 6 +- tests/unit/test_migrate.py | 26 +- 9 files changed, 721 insertions(+), 841 deletions(-) diff --git a/examples/dynamic-variables/project.promptrek.yaml b/examples/dynamic-variables/project.promptrek.yaml index 1eec0c7..4340558 100644 --- a/examples/dynamic-variables/project.promptrek.yaml +++ b/examples/dynamic-variables/project.promptrek.yaml @@ -1,4 +1,4 @@ -schema_version: 3.0.0 +schema_version: 3.1.0 metadata: title: Dynamic Variables Example diff --git a/examples/v21-plugins/autonomous-agents.promptrek.yaml b/examples/v21-plugins/autonomous-agents.promptrek.yaml index e36ef28..ac3a9b6 100644 --- a/examples/v21-plugins/autonomous-agents.promptrek.yaml +++ b/examples/v21-plugins/autonomous-agents.promptrek.yaml @@ -1,12 +1,11 @@ -# yaml-language-server: $schema=https://promptrek.ai/schema/v2.1.0.json -schema_version: 2.1.0 +# yaml-language-server: $schema=https://promptrek.ai/schema/v3.1.0.json +schema_version: 3.1.0 metadata: title: Autonomous Agents Example description: Example agent configurations for automated tasks version: 1.0.0 author: PrompTrek Team tags: [agents, automation, example] - content: | # Autonomous Agents Example @@ -18,114 +17,86 @@ content: | - **full**: Agent can act without approval - **partial**: Agent requires approval for sensitive operations - **untrusted**: Agent requires approval for all operations +agents: +- name: code-reviewer + prompt: | + You are an expert code reviewer with deep knowledge of software engineering + best practices. Your role is to: -plugins: - agents: - # Code reviewer agent - reviews code automatically - - name: code-reviewer - description: Autonomous code review agent - system_prompt: | - You are an expert code reviewer with deep knowledge of software engineering - best practices. Your role is to: - - 1. Review code for quality, security, and performance issues - 2. Suggest improvements and refactorings - 3. Ensure code follows project conventions - 4. Identify potential bugs and edge cases - 5. Recommend additional tests - - Be thorough but constructive in your reviews. Explain the reasoning - behind your suggestions. - tools: - - file_read - - git_diff - - static_analysis - - run_tests - trust_level: partial - requires_approval: true - context: - review_criteria: ["code_quality", "security", "performance", "testing"] - severity_threshold: "medium" - trust_metadata: - trusted: true - trust_level: partial - source: local - - # Documentation generator agent - - name: doc-generator - description: Automatically generates and updates documentation - system_prompt: | - You are a documentation specialist. Generate clear, comprehensive - documentation that helps developers understand and use the code. - - Focus on: - - Clear explanations - - Practical examples - - Common use cases - - API references - - Troubleshooting guides - tools: - - file_read - - file_write - - analyze_code_structure - trust_level: partial - requires_approval: true - - # Test generator agent - - name: test-generator - description: Generates unit and integration tests - system_prompt: | - You are a test automation expert. Generate comprehensive tests that: - - Cover normal operations - - Test edge cases - - Handle error conditions - - Mock external dependencies - - Follow testing best practices - tools: - - file_read - - file_write - - run_tests - - analyze_coverage - trust_level: partial - requires_approval: true + 1. Review code for quality, security, and performance issues + 2. Suggest improvements and refactorings + 3. Ensure code follows project conventions + 4. Identify potential bugs and edge cases + 5. Recommend additional tests - # Bug fixer agent - highly autonomous - - name: bug-fixer - description: Automatically fixes simple bugs - system_prompt: | - You are a bug-fixing specialist. Identify and fix bugs while: - - Understanding the root cause - - Applying minimal changes - - Adding tests to prevent regression - - Documenting the fix - tools: - - file_read - - file_write - - git_commit - - run_tests - trust_level: untrusted - requires_approval: true - context: - max_files_per_fix: 3 - require_tests: true - auto_commit: false + Be thorough but constructive in your reviews. Explain the reasoning + behind your suggestions. + description: Autonomous code review agent + tools: [file_read, git_diff, static_analysis, run_tests] + trust_level: partial + requires_approval: true + context: + review_criteria: [code_quality, security, performance, testing] + severity_threshold: medium + trust_metadata: + trusted: true + trust_level: partial + requires_approval: true + source: local +- name: doc-generator + prompt: | + You are a documentation specialist. Generate clear, comprehensive + documentation that helps developers understand and use the code. - # Refactoring agent - - name: refactorer - description: Suggests and applies code refactorings - system_prompt: | - You are a refactoring expert. Improve code quality through: - - Extracting functions/classes - - Removing duplication - - Simplifying complex logic - - Improving naming - - Applying design patterns + Focus on: + - Clear explanations + - Practical examples + - Common use cases + - API references + - Troubleshooting guides + description: Automatically generates and updates documentation + tools: [file_read, file_write, analyze_code_structure] + trust_level: partial + requires_approval: true +- name: test-generator + prompt: | + You are a test automation expert. Generate comprehensive tests that: + - Cover normal operations + - Test edge cases + - Handle error conditions + - Mock external dependencies + - Follow testing best practices + description: Generates unit and integration tests + tools: [file_read, file_write, run_tests, analyze_coverage] + trust_level: partial + requires_approval: true +- name: bug-fixer + prompt: | + You are a bug-fixing specialist. Identify and fix bugs while: + - Understanding the root cause + - Applying minimal changes + - Adding tests to prevent regression + - Documenting the fix + description: Automatically fixes simple bugs + tools: [file_read, file_write, git_commit, run_tests] + trust_level: untrusted + requires_approval: true + context: + max_files_per_fix: 3 + require_tests: true + auto_commit: false +- name: refactorer + prompt: | + You are a refactoring expert. Improve code quality through: + - Extracting functions/classes + - Removing duplication + - Simplifying complex logic + - Improving naming + - Applying design patterns - Always ensure refactorings maintain existing behavior. - tools: - - file_read - - file_write - - run_tests - - static_analysis - trust_level: untrusted - requires_approval: true + Always ensure refactorings maintain existing behavior. + description: Suggests and applies code refactorings + tools: [file_read, file_write, run_tests, static_analysis] + trust_level: untrusted + requires_approval: true +allow_commands: false diff --git a/examples/v21-plugins/complete-example.promptrek.yaml b/examples/v21-plugins/complete-example.promptrek.yaml index 3feafe3..aab844d 100644 --- a/examples/v21-plugins/complete-example.promptrek.yaml +++ b/examples/v21-plugins/complete-example.promptrek.yaml @@ -1,12 +1,11 @@ -# yaml-language-server: $schema=https://promptrek.ai/schema/v2.1.0.json -schema_version: 2.1.0 +# yaml-language-server: $schema=https://promptrek.ai/schema/v3.1.0.json +schema_version: 3.1.0 metadata: title: Complete v2.1 Plugin Example description: Comprehensive example showing all v2.1 plugin features together version: 1.0.0 author: PrompTrek Team tags: [mcp, commands, agents, complete-example] - content: | # Complete PrompTrek v2.1 Plugin Configuration @@ -49,293 +48,252 @@ content: | | Agents | ⚠️ | ✅ | ⚠️ | ⚠️ | ⚠️ | ✅ = Full support | ⚠️ = Partial/Planned - -plugins: - # MCP Servers - External tools and data sources - mcp_servers: - # Filesystem access for reading/writing files - - name: filesystem - command: npx - args: - - "-y" - - "@modelcontextprotocol/server-filesystem" - - "{{{ PROJECT_ROOT }}}" - description: Provides file system access to project directory - trust_metadata: - trusted: true - trust_level: partial - requires_approval: true - source: official - verified_by: Anthropic - - # GitHub integration for repository access - - name: github - command: npx - args: - - "-y" - - "@modelcontextprotocol/server-github" - env: - GITHUB_TOKEN: "{{{ GITHUB_TOKEN }}}" - GITHUB_OWNER: "{{{ GITHUB_OWNER }}}" - description: Access GitHub repositories, issues, and PRs - trust_metadata: - trusted: true - trust_level: full - requires_approval: false - source: official - - # Web search for documentation and answers - - name: web-search - command: npx - args: - - "-y" - - "@modelcontextprotocol/server-brave-search" - env: - BRAVE_API_KEY: "{{{ BRAVE_API_KEY }}}" - description: Search the web for documentation and solutions - - # Custom Commands - Slash commands for common tasks - commands: - # Code review command - - name: review - description: Comprehensive code review with best practices - prompt: | - Perform a thorough code review focusing on: - - **Code Quality:** - - Clean code principles - - SOLID principles - - DRY (Don't Repeat Yourself) - - Proper error handling - - **Security:** - - Input validation - - SQL injection prevention - - XSS protection - - Authentication/authorization - - **Performance:** - - Algorithm efficiency - - Database query optimization - - Memory management - - Caching opportunities - - **Testing:** - - Test coverage - - Edge cases - - Error scenarios - - Integration tests - - **Documentation:** - - Code comments - - API documentation - - README updates - - Provide specific, actionable feedback with code examples. - output_format: markdown - requires_approval: false - examples: - - "/review src/api/users.ts" - - "/review --focus=security src/auth/" - trust_metadata: - trusted: true - trust_level: full - source: local - - # Test generation command - - name: test - description: Generate comprehensive unit tests - prompt: | - Generate unit tests following these guidelines: - - 1. **Test Structure:** - - Arrange, Act, Assert pattern - - Clear test names describing behavior - - One assertion per test - - 2. **Coverage:** - - Happy path scenarios - - Edge cases (empty, null, undefined) - - Error conditions - - Boundary values - - 3. **Best Practices:** - - Mock external dependencies - - Use fixtures/factories - - Avoid test interdependencies - - Fast execution - - 4. **Test Types:** - - Unit tests for functions - - Integration tests for workflows - - Property-based tests where applicable - - Use the project's testing framework and follow existing patterns. - output_format: code - requires_approval: false - examples: - - "/test src/utils/parser.ts" - - "/test --coverage=90 src/api/" - - # Documentation generation - - name: docs - description: Generate comprehensive documentation - prompt: | - Create documentation including: - - **Overview:** - - Purpose and goals - - Key features - - Architecture diagram - - **API Reference:** - - Function signatures - - Parameter descriptions - - Return values - - Usage examples - - **Guides:** - - Getting started - - Common use cases - - Best practices - - Troubleshooting - - **Additional:** - - Configuration options - - Environment variables - - Dependencies - - Contributing guidelines - - Use Markdown format with clear headings and code examples. - output_format: markdown - requires_approval: false - - # Refactoring suggestions - - name: refactor - description: Suggest code refactorings - prompt: | - Analyze code and suggest refactorings: - - - Extract functions/classes - - Remove code duplication - - Simplify complex conditions - - Improve variable naming - - Apply design patterns - - Optimize performance - - For each suggestion: - 1. Explain the issue - 2. Show before/after code - 3. Justify the change - 4. Note any risks - requires_approval: true - trust_metadata: - requires_approval: true - - # Autonomous Agents - AI agents for automated workflows - agents: - # Bug detection and fixing agent - - name: bug-hunter - description: Identifies and fixes bugs automatically - system_prompt: | - You are a bug detection and fixing specialist. Your workflow: - - 1. **Detection:** - - Analyze error logs - - Review failing tests - - Check edge cases - - Use static analysis - - 2. **Root Cause:** - - Trace the bug origin - - Identify related code - - Understand the impact - - 3. **Fix:** - - Apply minimal changes - - Maintain code style - - Add regression tests - - Update documentation - - 4. **Verification:** - - Run full test suite - - Check for side effects - - Validate fix - - Be thorough and cautious. When in doubt, ask for approval. - tools: - - file_read - - file_write - - run_tests - - git_diff - - static_analysis - trust_level: untrusted - requires_approval: true - context: - max_files_per_fix: 5 - require_tests: true - auto_commit: false - trust_metadata: - trusted: true - trust_level: untrusted - requires_approval: true - source: local - - # Code quality improvement agent - - name: quality-guardian - description: Monitors and improves code quality - system_prompt: | - You are a code quality guardian. Continuously monitor: - - - Code smells and anti-patterns - - Complexity metrics - - Code duplication - - Test coverage - - Documentation completeness - - When issues are found: - 1. Prioritize by severity - 2. Suggest improvements - 3. Provide examples - 4. Track progress - - Focus on maintainability and long-term code health. - tools: - - file_read - - static_analysis - - complexity_analysis - - coverage_analysis - trust_level: partial - requires_approval: false - trust_metadata: - trusted: true - trust_level: partial - source: local - - # Documentation maintenance agent - - name: doc-keeper - description: Keeps documentation up-to-date - system_prompt: | - You maintain documentation quality. Ensure: - - - API docs match code signatures - - Examples are tested and working - - README is comprehensive - - Changelogs are updated - - Dead links are fixed - - Update docs automatically when code changes. - Flag breaking changes for review. - tools: - - file_read - - file_write - - link_checker - - code_analyzer - trust_level: partial - requires_approval: true - variables: - PROJECT_ROOT: "/Users/username/projects/myproject" - GITHUB_TOKEN: "ghp_your_token_here" - GITHUB_OWNER: "your-username" - BRAVE_API_KEY: "BSA_your_brave_api_key" + PROJECT_ROOT: /Users/username/projects/myproject + GITHUB_TOKEN: ghp_your_token_here + GITHUB_OWNER: your-username + BRAVE_API_KEY: BSA_your_brave_api_key +mcp_servers: +- name: filesystem + command: npx + args: [-y, '@modelcontextprotocol/server-filesystem', '{{{ PROJECT_ROOT }}}'] + description: Provides file system access to project directory + trust_metadata: + trusted: true + trust_level: partial + requires_approval: true + source: official + verified_by: Anthropic +- name: github + command: npx + args: [-y, '@modelcontextprotocol/server-github'] + env: + GITHUB_TOKEN: '{{{ GITHUB_TOKEN }}}' + GITHUB_OWNER: '{{{ GITHUB_OWNER }}}' + description: Access GitHub repositories, issues, and PRs + trust_metadata: + trusted: true + trust_level: full + requires_approval: false + source: official +- name: web-search + command: npx + args: [-y, '@modelcontextprotocol/server-brave-search'] + env: + BRAVE_API_KEY: '{{{ BRAVE_API_KEY }}}' + description: Search the web for documentation and solutions +commands: +- name: review + description: Comprehensive code review with best practices + prompt: | + Perform a thorough code review focusing on: + + **Code Quality:** + - Clean code principles + - SOLID principles + - DRY (Don't Repeat Yourself) + - Proper error handling + + **Security:** + - Input validation + - SQL injection prevention + - XSS protection + - Authentication/authorization + + **Performance:** + - Algorithm efficiency + - Database query optimization + - Memory management + - Caching opportunities + + **Testing:** + - Test coverage + - Edge cases + - Error scenarios + - Integration tests + + **Documentation:** + - Code comments + - API documentation + - README updates + + Provide specific, actionable feedback with code examples. + output_format: markdown + requires_approval: false + examples: [/review src/api/users.ts, /review --focus=security src/auth/] + trust_metadata: + trusted: true + trust_level: full + requires_approval: true + source: local + multi_step: false +- name: test + description: Generate comprehensive unit tests + prompt: | + Generate unit tests following these guidelines: + + 1. **Test Structure:** + - Arrange, Act, Assert pattern + - Clear test names describing behavior + - One assertion per test + + 2. **Coverage:** + - Happy path scenarios + - Edge cases (empty, null, undefined) + - Error conditions + - Boundary values + + 3. **Best Practices:** + - Mock external dependencies + - Use fixtures/factories + - Avoid test interdependencies + - Fast execution + + 4. **Test Types:** + - Unit tests for functions + - Integration tests for workflows + - Property-based tests where applicable + + Use the project's testing framework and follow existing patterns. + output_format: code + requires_approval: false + examples: [/test src/utils/parser.ts, /test --coverage=90 src/api/] + multi_step: false +- name: docs + description: Generate comprehensive documentation + prompt: | + Create documentation including: + + **Overview:** + - Purpose and goals + - Key features + - Architecture diagram + + **API Reference:** + - Function signatures + - Parameter descriptions + - Return values + - Usage examples + + **Guides:** + - Getting started + - Common use cases + - Best practices + - Troubleshooting + + **Additional:** + - Configuration options + - Environment variables + - Dependencies + - Contributing guidelines + + Use Markdown format with clear headings and code examples. + output_format: markdown + requires_approval: false + multi_step: false +- name: refactor + description: Suggest code refactorings + prompt: | + Analyze code and suggest refactorings: + + - Extract functions/classes + - Remove code duplication + - Simplify complex conditions + - Improve variable naming + - Apply design patterns + - Optimize performance + + For each suggestion: + 1. Explain the issue + 2. Show before/after code + 3. Justify the change + 4. Note any risks + requires_approval: true + trust_metadata: + trusted: false + requires_approval: true + multi_step: false +agents: +- name: bug-hunter + prompt: | + You are a bug detection and fixing specialist. Your workflow: + + 1. **Detection:** + - Analyze error logs + - Review failing tests + - Check edge cases + - Use static analysis + + 2. **Root Cause:** + - Trace the bug origin + - Identify related code + - Understand the impact + + 3. **Fix:** + - Apply minimal changes + - Maintain code style + - Add regression tests + - Update documentation + + 4. **Verification:** + - Run full test suite + - Check for side effects + - Validate fix + + Be thorough and cautious. When in doubt, ask for approval. + description: Identifies and fixes bugs automatically + tools: [file_read, file_write, run_tests, git_diff, static_analysis] + trust_level: untrusted + requires_approval: true + context: + max_files_per_fix: 5 + require_tests: true + auto_commit: false + trust_metadata: + trusted: true + trust_level: untrusted + requires_approval: true + source: local +- name: quality-guardian + prompt: | + You are a code quality guardian. Continuously monitor: + + - Code smells and anti-patterns + - Complexity metrics + - Code duplication + - Test coverage + - Documentation completeness + + When issues are found: + 1. Prioritize by severity + 2. Suggest improvements + 3. Provide examples + 4. Track progress + + Focus on maintainability and long-term code health. + description: Monitors and improves code quality + tools: [file_read, static_analysis, complexity_analysis, coverage_analysis] + trust_level: partial + requires_approval: false + trust_metadata: + trusted: true + trust_level: partial + requires_approval: true + source: local +- name: doc-keeper + prompt: | + You maintain documentation quality. Ensure: + + - API docs match code signatures + - Examples are tested and working + - README is comprehensive + - Changelogs are updated + - Dead links are fixed + + Update docs automatically when code changes. + Flag breaking changes for review. + description: Keeps documentation up-to-date + tools: [file_read, file_write, link_checker, code_analyzer] + trust_level: partial + requires_approval: true +allow_commands: false diff --git a/examples/v21-plugins/continue-unified.promptrek.yaml b/examples/v21-plugins/continue-unified.promptrek.yaml index 9dd7dfc..0ccd8b3 100644 --- a/examples/v21-plugins/continue-unified.promptrek.yaml +++ b/examples/v21-plugins/continue-unified.promptrek.yaml @@ -1,12 +1,12 @@ -# yaml-language-server: $schema=https://promptrek.ai/schema/v2.1.0.json -schema_version: 2.1.0 +# yaml-language-server: $schema=https://promptrek.ai/schema/v3.1.0.json +schema_version: 3.1.0 metadata: title: Continue Modular Config Example - description: Example showing Continue's modular plugin configuration with individual files + description: Example showing Continue's modular plugin configuration with individual + files version: 1.0.0 author: PrompTrek Team tags: [continue, modular-config, mcp, commands, prompts] - content: | # Continue Modular Configuration Example @@ -72,235 +72,213 @@ content: | 2. **Easier Sharing**: Share individual MCP servers or commands across projects 3. **Cleaner Organization**: One file per concern, easier to navigate 4. **Continue Best Practice**: Follows Continue's official documentation recommendations - -plugins: - mcp_servers: - # Filesystem server for code access - - name: filesystem - command: npx - args: - - "-y" - - "@modelcontextprotocol/server-filesystem" - - "{{{ WORKSPACE_ROOT }}}" - description: Access project files - trust_metadata: - trusted: true - trust_level: partial - requires_approval: true - - # GitHub MCP server - - name: github - command: npx - args: - - "-y" - - "@modelcontextprotocol/server-github" - env: - GITHUB_TOKEN: "{{{ GITHUB_TOKEN }}}" - description: GitHub API integration - trust_metadata: - trusted: true - trust_level: full - - # Brave Search for web queries - - name: brave-search - command: npx - args: - - "-y" - - "@modelcontextprotocol/server-brave-search" - env: - BRAVE_API_KEY: "{{{ BRAVE_API_KEY }}}" - description: Web search capabilities - - commands: - # Code refactoring command - - name: refactor - description: Refactor selected code for better quality - prompt: | - Refactor the selected code following these principles: - - 1. **Simplification:** - - Break down complex functions - - Reduce nesting levels - - Extract reusable components - - 2. **Naming:** - - Use descriptive variable names - - Follow language conventions - - Avoid abbreviations - - 3. **DRY Principle:** - - Eliminate code duplication - - Create utility functions - - Use composition - - 4. **Performance:** - - Optimize loops - - Reduce allocations - - Cache when appropriate - - 5. **Testing:** - - Ensure tests still pass - - Add tests for new functions - - Maintain coverage - - Show before/after code and explain changes. - output_format: code - requires_approval: false - examples: - - "/refactor" - - # Explain code command - - name: explain - description: Explain how selected code works - prompt: | - Provide a clear explanation of this code: - - **Overview:** - - What does this code do? - - Why is it structured this way? - - **Details:** - - Key algorithms and data structures - - Important variables and their roles - - Control flow and logic - - **Context:** - - How it fits in the larger system - - Dependencies and relationships - - Potential edge cases - - **Examples:** - - Input/output examples - - Common use cases - - Use simple language and include diagrams if helpful. - output_format: markdown - requires_approval: false - - # Generate commit message - - name: commit - description: Generate a commit message for staged changes - prompt: | - Generate a conventional commit message for the staged changes: - - **Format:** - ``` - (): - - - -