-
Notifications
You must be signed in to change notification settings - Fork 18
Template-based Prompt Extension System #181
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 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a9a511
feat: implement composite variable replacement processor and update v…
butschster 8a0522d
fix: add null check for imports before rendering in GenerateCommand
butschster ea042a6
feat(mcp): implement template-based prompt extension system
butschster 7ae8782
CS fix
butschster 33f61a7
Cover MCP prompts with feature tests
butschster 825af46
Add feature tests for tools
butschster 96fe621
Add feature tests for file source
butschster 86c7dcf
Fix psalm
butschster 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,75 @@ | ||
| prompts: | ||
| # Template for issues | ||
| - id: template-issue | ||
| description: Template for creating issues | ||
| type: template | ||
| messages: | ||
| - role: user | ||
| content: "Create a new issue with the following title and description: {{title}} {{description}}" | ||
|
|
||
| # Template for bug issues, extending the base issue template | ||
| - id: bug-issue | ||
| description: Create a new bug issue | ||
| type: prompt | ||
| extend: | ||
| - id: template-issue | ||
| arguments: | ||
| title: 'Bug: {{title}}' | ||
| description: '{{description}}' | ||
| schema: | ||
| properties: | ||
| title: | ||
| description: The title of the bug | ||
| description: | ||
| description: The description of the bug | ||
| required: | ||
| - title | ||
| - description | ||
|
|
||
| # Template for feature issues, extending the base issue template | ||
| - id: feature-issue | ||
| description: Create a new feature issue | ||
| type: prompt | ||
| extend: | ||
| - id: template-issue | ||
| arguments: | ||
| title: 'Feature: {{title}}' | ||
| description: '{{description}}' | ||
| schema: | ||
| properties: | ||
| title: | ||
| description: The title of the feature | ||
| description: | ||
| description: The description of the feature | ||
| required: | ||
| - title | ||
| - description | ||
|
|
||
| # More complex template example, extending another template | ||
| - id: template-complex-issue | ||
| type: template | ||
| description: Template for complex issues with priority | ||
| extend: | ||
| - id: template-issue | ||
| arguments: | ||
| title: '{{type}}: {{title}}' | ||
| description: '{{description}} \n\n**Priority**: {{priority}}' | ||
|
|
||
| # Priority bug issue using the complex template | ||
| - id: priority-bug-issue | ||
| description: Create a new priority bug issue | ||
| type: prompt | ||
| extend: | ||
| - id: template-complex-issue | ||
| arguments: | ||
| type: 'Bug' | ||
| priority: 'High' | ||
| schema: | ||
| properties: | ||
| title: | ||
| description: The title of the bug | ||
| description: | ||
| description: The description of the bug | ||
| required: | ||
| - title | ||
| - description |
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,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Butschster\ContextGenerator\Lib\Variable; | ||
|
|
||
| final readonly class CompositeProcessor implements VariableReplacementProcessorInterface | ||
| { | ||
| /** | ||
| * @param VariableReplacementProcessor[] $processors | ||
| */ | ||
| public function __construct( | ||
| public array $processors = [], | ||
| ) {} | ||
|
|
||
| public function process(string $text): string | ||
| { | ||
| foreach ($this->processors as $processor) { | ||
| $text = $processor->process($text); | ||
| } | ||
|
|
||
| return $text; | ||
| } | ||
| } |
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
16 changes: 16 additions & 0 deletions
16
src/Lib/Variable/VariableReplacementProcessorInterface.php
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,16 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Butschster\ContextGenerator\Lib\Variable; | ||
|
|
||
| interface VariableReplacementProcessorInterface | ||
| { | ||
| /** | ||
| * Process text by replacing variable references | ||
| * | ||
| * @param string $text Text containing variable references | ||
| * @return string Text with variables replaced | ||
| */ | ||
| public function process(string $text): string; | ||
| } |
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.