-
Notifications
You must be signed in to change notification settings - Fork 254
Add prompt gallery to extension #48
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
Add prompt gallery to extension #48
Conversation
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.
Pull Request Overview
This PR adds a prompt gallery feature to the VS Code extension, allowing users to manage and invoke custom POML prompt files via a dedicated view and slash commands in the chat participant.
- Introduce
PromptGalleryProviderfor persisting, listing, and updating prompt entries - Register a new activity-bar view with Add/Edit/Delete prompt commands
- Enhance chat participant to handle
/promptNameprefixes and load custom prompt files
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/poml-vscode/gallery/promptGallery.ts | New PromptGalleryProvider class and storage logic |
| packages/poml-vscode/extension.ts | Registered gallery provider and wired commands |
| packages/poml-vscode/command/promptGallery.ts | Add/Edit/Delete prompt command implementations |
| packages/poml-vscode/command/index.ts | Exported new gallery commands |
| packages/poml-vscode/chat/participant.ts | Chat handler updated to support slash‐invoked prompts |
| package.json | Contributions for view container, views, and commands |
Comments suppressed due to low confidence (3)
packages/poml-vscode/gallery/promptGallery.ts:51
- [nitpick] The
promptsgetter is an alias forentries, which may be redundant. Consider consolidating to a single public getter to reduce confusion.
get prompts(): PromptEntry[] {
packages/poml-vscode/gallery/promptGallery.ts:37
- New behavior for adding prompts is introduced here but there are no unit tests covering
addPrompt,removePrompt, orupdatePrompt. Adding tests will help guard against regressions.
addPrompt(entry: PromptEntry) {
packages/poml-vscode/gallery/promptGallery.ts:10
- [nitpick] Public API
PromptGalleryProviderwould benefit from a brief JSDoc comment explaining its purpose and the meaning of its key methods.
export class PromptGalleryProvider implements vscode.TreeDataProvider<PromptEntry> {
| const matchedPrompt = gallery.prompts.find(p => promptText.match(new RegExp(`^/${p.name}\\b`))); | ||
| if (matchedPrompt) { | ||
| promptText = promptText.replace(new RegExp(`^/${matchedPrompt.name}\\b`), '').trimStart(); |
Copilot
AI
Jul 14, 2025
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.
Since p.name is user-provided, unescaped regex special characters can lead to unexpected behavior. Consider escaping p.name before constructing the RegExp or use a plain string startsWith check and boundary test.
| const matchedPrompt = gallery.prompts.find(p => promptText.match(new RegExp(`^/${p.name}\\b`))); | |
| if (matchedPrompt) { | |
| promptText = promptText.replace(new RegExp(`^/${matchedPrompt.name}\\b`), '').trimStart(); | |
| const escapeRegex = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | |
| const matchedPrompt = gallery.prompts.find(p => promptText.match(new RegExp(`^/${escapeRegex(p.name)}\\b`))); | |
| if (matchedPrompt) { | |
| promptText = promptText.replace(new RegExp(`^/${escapeRegex(matchedPrompt.name)}\\b`), '').trimStart(); |
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.
Bug: Prompt Name Validation Fails During Edit
In EditPromptCommand, the hasPrompt(name) validation incorrectly prevents users from keeping the same name when editing an existing prompt. The check fails because it does not exclude the current prompt being edited, leading to the error "A prompt with the name already exists". This prevents legitimate edits where only the file path is changed while the prompt name remains the same.
packages/poml-vscode/command/promptGallery.ts#L79-L85
poml/packages/poml-vscode/command/promptGallery.ts
Lines 79 to 85 in a73660e
| } | |
| if (this.provider.hasPrompt(name)) { | |
| vscode.window.showErrorMessage( | |
| `A prompt with the name "${name}" already exists.` | |
| ); | |
| continue; | |
| } |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Summary
Testing
npm run build-webviewnpm run build-clinpm run lintnpm testpython -m pip install -e .[dev]python -m pytest python/testsxvfb-run -a npm run compilenpm run build-extensionxvfb-run -a npm run test-vscodehttps://chatgpt.com/codex/tasks/task_e_686e4109f910832e81ed48e4f2b20f33