From ebb86b24e077e49f7a52665791e28abd373912ef Mon Sep 17 00:00:00 2001 From: pete Date: Fri, 9 Jan 2026 15:15:19 -0500 Subject: [PATCH 1/4] Added dependencies so prompt editor could be integrated with results analysis page --- package-lock.json | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index e8fc661..3f82e64 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@peerverity/ai-delegate", - "version": "0.2.4", + "version": "0.3.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@peerverity/ai-delegate", - "version": "0.2.4", + "version": "0.3.3", "license": "MIT", "dependencies": { "@anthropic-ai/sdk": "^0.71.0", @@ -421,7 +421,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -448,7 +447,6 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -604,7 +602,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.25", "caniuse-lite": "^1.0.30001754", @@ -2099,7 +2096,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -2172,7 +2168,6 @@ "integrity": "sha512-HU1JOuV1OavsZ+mfigY0j8d1TgQgbZ6M+J75zDkpEAwYeXjWSqrGJtgnPblJjd/mAyTNQ7ygw0MiKOn6etz8yw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.8", @@ -2222,7 +2217,6 @@ "integrity": "sha512-MfwFQ6SfwinsUVi0rNJm7rHZ31GyTcpVE5pgVA3hwFRb7COD4TzjUUwhGWKfO50+xdc2MQPuEBBJoqIMGt3JDw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@discoveryjs/json-ext": "^0.6.1", "@webpack-cli/configtest": "^3.0.1", -- GitLab From 17fce97af8cbca0fa222f27b2de5c011872da01d Mon Sep 17 00:00:00 2001 From: pete Date: Fri, 9 Jan 2026 17:08:59 -0500 Subject: [PATCH 2/4] Added tagging and explanations to results-analysis AI prompt editor so user knows which prompts pertain specifically to results analysis --- src/core/AiDelegate.ts | 5 ++- src/index.ts | 5 ++- src/types/prompts.ts | 4 ++ src/ui/PromptEditorUI.ts | 82 +++++++++++++++++++++++++++++++++++++--- 4 files changed, 87 insertions(+), 9 deletions(-) diff --git a/src/core/AiDelegate.ts b/src/core/AiDelegate.ts index 77a5c64..e4a3881 100644 --- a/src/core/AiDelegate.ts +++ b/src/core/AiDelegate.ts @@ -597,10 +597,11 @@ export class AiDelegate { /** * Open the prompt editor UI + * @param options - Optional configuration for filtering/highlighting prompts */ - async openPromptEditor(): Promise { + async openPromptEditor(options?: { filterTags?: string[] }): Promise { await this.ensureWorkerInitialized(); - await PromptEditorUI.open(this); + await PromptEditorUI.open(this, options); } /** diff --git a/src/index.ts b/src/index.ts index 2962b3d..b315318 100644 --- a/src/index.ts +++ b/src/index.ts @@ -212,9 +212,10 @@ const api = { /** * Open the prompt editor UI + * @param options - Optional configuration for filtering/highlighting prompts */ - openPromptEditor: (): Promise => { - return AiDelegate.getInstance().openPromptEditor(); + openPromptEditor: (options?: { filterTags?: string[] }): Promise => { + return AiDelegate.getInstance().openPromptEditor(options); } }; diff --git a/src/types/prompts.ts b/src/types/prompts.ts index 04d45bf..a35c34a 100644 --- a/src/types/prompts.ts +++ b/src/types/prompts.ts @@ -31,6 +31,10 @@ export interface PromptDefinition { role?: MessageRole; /** Default model weight for this prompt (defaults to 'moderate') */ weight?: Weight; + /** Human-readable description of what this prompt does */ + description?: string; + /** Tags for categorizing/filtering prompts (e.g., ['conversational-assistant', 'results-analysis']) */ + tags?: string[]; } /** diff --git a/src/ui/PromptEditorUI.ts b/src/ui/PromptEditorUI.ts index b5108b4..dbee7d7 100644 --- a/src/ui/PromptEditorUI.ts +++ b/src/ui/PromptEditorUI.ts @@ -23,6 +23,14 @@ interface PromptAPI { * - Resetting modified prompts to upstream * - Deleting custom prompts */ +/** + * Options for opening the prompt editor + */ +export interface PromptEditorOptions { + /** Filter to show only prompts with these tags */ + filterTags?: string[]; +} + export class PromptEditorUI { private static isModalOpen = false; private static api: PromptAPI | null = null; @@ -30,16 +38,20 @@ export class PromptEditorUI { private static overlay: HTMLDivElement | null = null; private static originalTemplate: string = ''; private static originalWeight: string = ''; + private static filterTags: string[] | null = null; /** * Open the prompt editor + * @param api - The prompt API interface + * @param options - Optional configuration for filtering prompts */ - static async open(api: PromptAPI): Promise { + static async open(api: PromptAPI, options?: PromptEditorOptions): Promise { if (this.isModalOpen) { return; } this.api = api; + this.filterTags = options?.filterTags || null; this.isModalOpen = true; // Create modal overlay @@ -88,13 +100,36 @@ export class PromptEditorUI { this.api = null; } + /** + * Check if a prompt matches the current filter tags + */ + private static promptMatchesFilter(prompt: StoredPrompt): boolean { + if (!this.filterTags || this.filterTags.length === 0) { + return true; // No filter, show all + } + const promptTags = prompt.tags || []; + return this.filterTags.some(tag => promptTags.includes(tag)); + } + /** * Render the prompt list view */ private static async renderPromptList(modal: HTMLDivElement): Promise { if (!this.api) return; - const prompts = await this.api.listPrompts(); + const allPrompts = await this.api.listPrompts(); + + // Filter prompts if filterTags is set + const prompts = this.filterTags + ? allPrompts.filter(p => this.promptMatchesFilter(p)) + : allPrompts; + + const filterInfo = this.filterTags + ? `
+ Showing prompts for: ${this.filterTags.join(', ')} + +
` + : ''; modal.innerHTML = `
@@ -105,9 +140,11 @@ export class PromptEditorUI {
+ ${filterInfo} + ${prompts.length === 0 ? `
- No prompts registered yet. + ${this.filterTags ? 'No prompts match the current filter.' : 'No prompts registered yet.'}
` : `
@@ -120,6 +157,12 @@ export class PromptEditorUI { // Setup event handlers modal.querySelector('#ai-delegate-close-btn')?.addEventListener('click', () => this.close()); + // Clear filter button + modal.querySelector('#ai-delegate-clear-filter')?.addEventListener('click', () => { + this.filterTags = null; + this.renderPromptList(modal); + }); + // Setup prompt item click handlers prompts.forEach(prompt => { const item = modal.querySelector(`[data-prompt-name="${prompt.name}"]`); @@ -135,6 +178,18 @@ export class PromptEditorUI { ? 'Modified' : ''; + // Show description if available, otherwise fall back to template preview + const description = prompt.description + ? this.escapeHtml(prompt.description) + : `${this.escapeHtml(prompt.template.substring(0, 100))}${prompt.template.length > 100 ? '...' : ''}`; + + // Render tags if present + const tagsHtml = prompt.tags && prompt.tags.length > 0 + ? `
+ ${prompt.tags.map(tag => `${this.escapeHtml(tag)}`).join('')} +
` + : ''; + return `
v${this.escapeHtml(prompt.version)} ${modifiedBadge}
-
- ${this.escapeHtml(prompt.template.substring(0, 100))}${prompt.template.length > 100 ? '...' : ''} +
+ ${description}
+ ${tagsHtml}
`; } @@ -216,6 +272,22 @@ export class PromptEditorUI {
+ ${prompt.description ? ` +
+ +
${this.escapeHtml(prompt.description)}
+
+ ` : ''} + + ${prompt.tags && prompt.tags.length > 0 ? ` +
+ +
+ ${prompt.tags.map(tag => `${this.escapeHtml(tag)}`).join('')} +
+
+ ` : ''} +