pupt 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +517 -0
- package/dist/annotations/annotation-analyzer.d.ts +17 -0
- package/dist/annotations/annotation-analyzer.d.ts.map +1 -0
- package/dist/annotations/annotation-analyzer.js +145 -0
- package/dist/annotations/annotation-analyzer.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +375 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +149 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/annotate.d.ts +2 -0
- package/dist/commands/annotate.d.ts.map +1 -0
- package/dist/commands/annotate.js +223 -0
- package/dist/commands/annotate.js.map +1 -0
- package/dist/commands/base-command.d.ts +23 -0
- package/dist/commands/base-command.d.ts.map +1 -0
- package/dist/commands/base-command.js +41 -0
- package/dist/commands/base-command.js.map +1 -0
- package/dist/commands/edit.d.ts +2 -0
- package/dist/commands/edit.d.ts.map +1 -0
- package/dist/commands/edit.js +31 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +25 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/history.d.ts +9 -0
- package/dist/commands/history.d.ts.map +1 -0
- package/dist/commands/history.js +232 -0
- package/dist/commands/history.js.map +1 -0
- package/dist/commands/init-refactored.d.ts +19 -0
- package/dist/commands/init-refactored.d.ts.map +1 -0
- package/dist/commands/init-refactored.js +141 -0
- package/dist/commands/init-refactored.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +124 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +10 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +224 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/review.d.ts +3 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +158 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +28 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +340 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/config/config-manager.d.ts +19 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +386 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/config/migration.d.ts +11 -0
- package/dist/config/migration.d.ts.map +1 -0
- package/dist/config/migration.js +153 -0
- package/dist/config/migration.js.map +1 -0
- package/dist/history/enhanced-history-manager.d.ts +25 -0
- package/dist/history/enhanced-history-manager.d.ts.map +1 -0
- package/dist/history/enhanced-history-manager.js +88 -0
- package/dist/history/enhanced-history-manager.js.map +1 -0
- package/dist/history/history-manager.d.ts +33 -0
- package/dist/history/history-manager.d.ts.map +1 -0
- package/dist/history/history-manager.js +176 -0
- package/dist/history/history-manager.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/input-types/file-prompt.d.ts +12 -0
- package/dist/prompts/input-types/file-prompt.d.ts.map +1 -0
- package/dist/prompts/input-types/file-prompt.js +166 -0
- package/dist/prompts/input-types/file-prompt.js.map +1 -0
- package/dist/prompts/input-types/file-search-prompt.d.ts +12 -0
- package/dist/prompts/input-types/file-search-prompt.d.ts.map +1 -0
- package/dist/prompts/input-types/file-search-prompt.js +54 -0
- package/dist/prompts/input-types/file-search-prompt.js.map +1 -0
- package/dist/prompts/input-types/review-file-prompt.d.ts +4 -0
- package/dist/prompts/input-types/review-file-prompt.d.ts.map +1 -0
- package/dist/prompts/input-types/review-file-prompt.js +10 -0
- package/dist/prompts/input-types/review-file-prompt.js.map +1 -0
- package/dist/prompts/prompt-manager.d.ts +12 -0
- package/dist/prompts/prompt-manager.d.ts.map +1 -0
- package/dist/prompts/prompt-manager.js +102 -0
- package/dist/prompts/prompt-manager.js.map +1 -0
- package/dist/pupt-1.2.0.tgz +0 -0
- package/dist/schemas/config-schema.d.ts +1268 -0
- package/dist/schemas/config-schema.d.ts.map +1 -0
- package/dist/schemas/config-schema.js +100 -0
- package/dist/schemas/config-schema.js.map +1 -0
- package/dist/schemas/prompt-schema.d.ts +927 -0
- package/dist/schemas/prompt-schema.d.ts.map +1 -0
- package/dist/schemas/prompt-schema.js +110 -0
- package/dist/schemas/prompt-schema.js.map +1 -0
- package/dist/search/file-search-engine.d.ts +36 -0
- package/dist/search/file-search-engine.d.ts.map +1 -0
- package/dist/search/file-search-engine.js +184 -0
- package/dist/search/file-search-engine.js.map +1 -0
- package/dist/search/search-engine.d.ts +8 -0
- package/dist/search/search-engine.d.ts.map +1 -0
- package/dist/search/search-engine.js +52 -0
- package/dist/search/search-engine.js.map +1 -0
- package/dist/services/auto-annotation-service.d.ts +39 -0
- package/dist/services/auto-annotation-service.d.ts.map +1 -0
- package/dist/services/auto-annotation-service.js +203 -0
- package/dist/services/auto-annotation-service.js.map +1 -0
- package/dist/services/file-system-service.d.ts +42 -0
- package/dist/services/file-system-service.d.ts.map +1 -0
- package/dist/services/file-system-service.js +269 -0
- package/dist/services/file-system-service.js.map +1 -0
- package/dist/services/git-service.d.ts +27 -0
- package/dist/services/git-service.d.ts.map +1 -0
- package/dist/services/git-service.js +157 -0
- package/dist/services/git-service.js.map +1 -0
- package/dist/services/logging-service.d.ts +50 -0
- package/dist/services/logging-service.d.ts.map +1 -0
- package/dist/services/logging-service.js +203 -0
- package/dist/services/logging-service.js.map +1 -0
- package/dist/services/output-capture-service.d.ts +25 -0
- package/dist/services/output-capture-service.d.ts.map +1 -0
- package/dist/services/output-capture-service.js +277 -0
- package/dist/services/output-capture-service.js.map +1 -0
- package/dist/services/pattern-detector.d.ts +15 -0
- package/dist/services/pattern-detector.d.ts.map +1 -0
- package/dist/services/pattern-detector.js +219 -0
- package/dist/services/pattern-detector.js.map +1 -0
- package/dist/services/prompt-service.d.ts +30 -0
- package/dist/services/prompt-service.d.ts.map +1 -0
- package/dist/services/prompt-service.js +278 -0
- package/dist/services/prompt-service.js.map +1 -0
- package/dist/services/review-data-builder.d.ts +22 -0
- package/dist/services/review-data-builder.d.ts.map +1 -0
- package/dist/services/review-data-builder.js +263 -0
- package/dist/services/review-data-builder.js.map +1 -0
- package/dist/services/suggestion-generator.d.ts +11 -0
- package/dist/services/suggestion-generator.d.ts.map +1 -0
- package/dist/services/suggestion-generator.js +146 -0
- package/dist/services/suggestion-generator.js.map +1 -0
- package/dist/services/ui-service.d.ts +49 -0
- package/dist/services/ui-service.d.ts.map +1 -0
- package/dist/services/ui-service.js +183 -0
- package/dist/services/ui-service.js.map +1 -0
- package/dist/template/helpers/index.d.ts +4 -0
- package/dist/template/helpers/index.d.ts.map +1 -0
- package/dist/template/helpers/index.js +132 -0
- package/dist/template/helpers/index.js.map +1 -0
- package/dist/template/template-context.d.ts +26 -0
- package/dist/template/template-context.d.ts.map +1 -0
- package/dist/template/template-context.js +65 -0
- package/dist/template/template-context.js.map +1 -0
- package/dist/template/template-engine.d.ts +13 -0
- package/dist/template/template-engine.d.ts.map +1 -0
- package/dist/template/template-engine.js +83 -0
- package/dist/template/template-engine.js.map +1 -0
- package/dist/types/annotations.d.ts +49 -0
- package/dist/types/annotations.d.ts.map +1 -0
- package/dist/types/annotations.js +2 -0
- package/dist/types/annotations.js.map +1 -0
- package/dist/types/config.d.ts +49 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +8 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/history.d.ts +32 -0
- package/dist/types/history.d.ts.map +1 -0
- package/dist/types/history.js +2 -0
- package/dist/types/history.js.map +1 -0
- package/dist/types/patterns.d.ts +24 -0
- package/dist/types/patterns.d.ts.map +1 -0
- package/dist/types/patterns.js +2 -0
- package/dist/types/patterns.js.map +1 -0
- package/dist/types/prompt.d.ts +23 -0
- package/dist/types/prompt.d.ts.map +1 -0
- package/dist/types/prompt.js +2 -0
- package/dist/types/prompt.js.map +1 -0
- package/dist/types/review.d.ts +76 -0
- package/dist/types/review.d.ts.map +1 -0
- package/dist/types/review.js +2 -0
- package/dist/types/review.js.map +1 -0
- package/dist/ui/console-ui.d.ts +35 -0
- package/dist/ui/console-ui.d.ts.map +1 -0
- package/dist/ui/console-ui.js +83 -0
- package/dist/ui/console-ui.js.map +1 -0
- package/dist/ui/interactive-search.d.ts +8 -0
- package/dist/ui/interactive-search.d.ts.map +1 -0
- package/dist/ui/interactive-search.js +29 -0
- package/dist/ui/interactive-search.js.map +1 -0
- package/dist/utils/date-formatter.d.ts +10 -0
- package/dist/utils/date-formatter.d.ts.map +1 -0
- package/dist/utils/date-formatter.js +43 -0
- package/dist/utils/date-formatter.js.map +1 -0
- package/dist/utils/editor.d.ts +13 -0
- package/dist/utils/editor.d.ts.map +1 -0
- package/dist/utils/editor.js +62 -0
- package/dist/utils/editor.js.map +1 -0
- package/dist/utils/errors.d.ts +55 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +248 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/file-utils.d.ts +18 -0
- package/dist/utils/file-utils.d.ts.map +1 -0
- package/dist/utils/file-utils.js +88 -0
- package/dist/utils/file-utils.js.map +1 -0
- package/dist/utils/git-info.d.ts +8 -0
- package/dist/utils/git-info.d.ts.map +1 -0
- package/dist/utils/git-info.js +41 -0
- package/dist/utils/git-info.js.map +1 -0
- package/dist/utils/gitignore.d.ts +10 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +72 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/handlebars-extensions.d.ts +4 -0
- package/dist/utils/handlebars-extensions.d.ts.map +1 -0
- package/dist/utils/handlebars-extensions.js +87 -0
- package/dist/utils/handlebars-extensions.js.map +1 -0
- package/dist/utils/logger.d.ts +39 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +143 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/platform.d.ts +9 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +44 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/security.d.ts +5 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +57 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/tool-detection.d.ts +11 -0
- package/dist/utils/tool-detection.d.ts.map +1 -0
- package/dist/utils/tool-detection.js +32 -0
- package/dist/utils/tool-detection.js.map +1 -0
- package/dist/utils/trie.d.ts +18 -0
- package/dist/utils/trie.d.ts.map +1 -0
- package/dist/utils/trie.js +84 -0
- package/dist/utils/trie.js.map +1 -0
- package/package.json +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Adam Powers
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
# Prompt Tool (pt)
|
|
2
|
+
|
|
3
|
+
A powerful CLI tool for managing and using AI prompts with template support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔍 **Interactive Search** - Quickly find prompts with fuzzy search
|
|
8
|
+
- 📝 **Template Support** - Use Handlebars templates with user input
|
|
9
|
+
- 📁 **Multi-directory Support** - Organize prompts across multiple directories
|
|
10
|
+
- 🔧 **Cross-platform** - Works on Windows, macOS, and Linux
|
|
11
|
+
- 📊 **History Tracking** - Keep track of generated prompts and re-run them
|
|
12
|
+
- 🎯 **Variable Definitions** - Define variables with types and validation
|
|
13
|
+
- 🚀 **External Tool Integration** - Run prompts with any command-line tool
|
|
14
|
+
- ✏️ **Prompt Management** - Create, edit, and organize prompts easily
|
|
15
|
+
- 🏷️ **Annotations** - Add notes and tags to your prompt history
|
|
16
|
+
- ⚡ **Enhanced Error Messages** - Helpful suggestions and clear guidance
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -g cli-prompt-tool
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
1. Initialize your configuration:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pt init
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
2. Create your first prompt:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pt add
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. Run the tool:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pt
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Commands
|
|
45
|
+
|
|
46
|
+
### `pt`
|
|
47
|
+
Interactive prompt selection and generation. This is the default command that lets you:
|
|
48
|
+
- Search through all your prompts with fuzzy search
|
|
49
|
+
- Preview prompt content before selection
|
|
50
|
+
- Fill in template variables interactively
|
|
51
|
+
- View the generated result
|
|
52
|
+
|
|
53
|
+
### `pt init`
|
|
54
|
+
Initialize configuration interactively. Sets up:
|
|
55
|
+
- Prompt directories
|
|
56
|
+
- History tracking (optional)
|
|
57
|
+
- Annotation support (optional)
|
|
58
|
+
- Default coding tool configuration
|
|
59
|
+
|
|
60
|
+
### `pt add`
|
|
61
|
+
Create a new prompt interactively. Features:
|
|
62
|
+
- Guided prompt creation with metadata
|
|
63
|
+
- Automatic author detection from git
|
|
64
|
+
- Label/tag support
|
|
65
|
+
- Opens in your editor automatically
|
|
66
|
+
|
|
67
|
+
### `pt edit`
|
|
68
|
+
Edit existing prompts in your configured editor. Features:
|
|
69
|
+
- Interactive prompt selection
|
|
70
|
+
- Automatic editor detection ($VISUAL or $EDITOR)
|
|
71
|
+
- Fallback to common editors if not configured
|
|
72
|
+
|
|
73
|
+
### `pt run [tool] [args...]`
|
|
74
|
+
Execute prompts with external tools. Examples:
|
|
75
|
+
```bash
|
|
76
|
+
pt run # Use configured default tool
|
|
77
|
+
pt run claude # Send to Claude
|
|
78
|
+
pt run code - # Open in VS Code
|
|
79
|
+
pt run cat # Output to terminal
|
|
80
|
+
pt run -- --continue # Pass args to configured tool
|
|
81
|
+
pt run -h 3 # Re-run history entry #3
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### `pt history [options]`
|
|
85
|
+
View prompt execution history. Options:
|
|
86
|
+
- `-l, --limit <number>` - Number of entries to show (default: 20)
|
|
87
|
+
- `-a, --all` - Show all history entries
|
|
88
|
+
|
|
89
|
+
### `pt annotate [history-number]`
|
|
90
|
+
Add notes to history entries. Features:
|
|
91
|
+
- Mark prompts as success/failure/partial
|
|
92
|
+
- Add searchable tags
|
|
93
|
+
- Write detailed notes in your editor
|
|
94
|
+
- Multiple annotations per history entry
|
|
95
|
+
|
|
96
|
+
### `pt example`
|
|
97
|
+
Generate an example prompt file to help you get started.
|
|
98
|
+
|
|
99
|
+
## Prompt Files
|
|
100
|
+
|
|
101
|
+
### What is a Prompt File?
|
|
102
|
+
|
|
103
|
+
A prompt file is a markdown file that serves as a template for generating AI prompts. These files can contain:
|
|
104
|
+
- Static text that appears in every generated prompt
|
|
105
|
+
- Dynamic content using Handlebars template syntax
|
|
106
|
+
- Variable definitions that specify what inputs to collect from users
|
|
107
|
+
- Metadata to help organize and find prompts
|
|
108
|
+
|
|
109
|
+
Prompt files allow you to create reusable templates for common AI interactions, ensuring consistency and saving time.
|
|
110
|
+
|
|
111
|
+
### Prompt File Structure
|
|
112
|
+
|
|
113
|
+
```markdown
|
|
114
|
+
---
|
|
115
|
+
title: Your Prompt Title
|
|
116
|
+
labels: [tag1, tag2, tag3]
|
|
117
|
+
variables:
|
|
118
|
+
- name: variableName
|
|
119
|
+
type: input
|
|
120
|
+
message: "What to ask the user"
|
|
121
|
+
default: "Default value"
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
Your prompt content goes here with {{variableName}} substitution.
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Frontmatter Properties
|
|
128
|
+
|
|
129
|
+
The frontmatter section (between `---` markers) is optional and uses YAML format. Available properties:
|
|
130
|
+
|
|
131
|
+
#### `title` (string)
|
|
132
|
+
- **Purpose**: Display name for the prompt in the search interface
|
|
133
|
+
- **Default**: Filename without extension
|
|
134
|
+
- **Example**: `title: "API Documentation Generator"`
|
|
135
|
+
|
|
136
|
+
#### `labels` (array of strings)
|
|
137
|
+
- **Purpose**: Tags for categorizing and searching prompts
|
|
138
|
+
- **Default**: Empty array
|
|
139
|
+
- **Example**: `labels: [api, documentation, typescript]`
|
|
140
|
+
|
|
141
|
+
#### `variables` (array of objects)
|
|
142
|
+
- **Purpose**: Define user inputs required by the template
|
|
143
|
+
- **Default**: Empty array
|
|
144
|
+
- **Structure**: Each variable can have these properties:
|
|
145
|
+
- `name` (required): Variable identifier used in template
|
|
146
|
+
- `type`: Input type (`input`, `select`, `multiselect`, `confirm`, `editor`, `password`)
|
|
147
|
+
- `message`: Question to ask the user
|
|
148
|
+
- `default`: Default value
|
|
149
|
+
- `choices`: Array of options (for `select` and `multiselect` types)
|
|
150
|
+
- `validate`: Regex pattern for validation (as string)
|
|
151
|
+
|
|
152
|
+
### Complete Example Prompt File
|
|
153
|
+
|
|
154
|
+
```markdown
|
|
155
|
+
---
|
|
156
|
+
title: REST API Client Generator
|
|
157
|
+
labels: [api, client, typescript, generator]
|
|
158
|
+
variables:
|
|
159
|
+
- name: serviceName
|
|
160
|
+
type: input
|
|
161
|
+
message: "What is the name of your API service?"
|
|
162
|
+
default: "MyAPI"
|
|
163
|
+
validate: "^[A-Za-z][A-Za-z0-9]*$"
|
|
164
|
+
|
|
165
|
+
- name: baseUrl
|
|
166
|
+
type: input
|
|
167
|
+
message: "What is the base URL?"
|
|
168
|
+
default: "https://api.example.com"
|
|
169
|
+
|
|
170
|
+
- name: authType
|
|
171
|
+
type: select
|
|
172
|
+
message: "Choose authentication type:"
|
|
173
|
+
choices: ["none", "api-key", "bearer-token", "basic-auth"]
|
|
174
|
+
|
|
175
|
+
- name: methods
|
|
176
|
+
type: multiselect
|
|
177
|
+
message: "Which HTTP methods will you use?"
|
|
178
|
+
choices: ["GET", "POST", "PUT", "DELETE", "PATCH"]
|
|
179
|
+
|
|
180
|
+
- name: includeTests
|
|
181
|
+
type: confirm
|
|
182
|
+
message: "Generate test files?"
|
|
183
|
+
default: true
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
# {{serviceName}} API Client
|
|
187
|
+
|
|
188
|
+
Generate a TypeScript API client for {{serviceName}}.
|
|
189
|
+
|
|
190
|
+
## Configuration
|
|
191
|
+
- Base URL: {{baseUrl}}
|
|
192
|
+
- Authentication: {{authType}}
|
|
193
|
+
- Methods: {{methods}}
|
|
194
|
+
|
|
195
|
+
## Implementation Requirements
|
|
196
|
+
|
|
197
|
+
Create a fully typed TypeScript client with:
|
|
198
|
+
1. Type-safe request/response handling
|
|
199
|
+
2. Error handling with custom error classes
|
|
200
|
+
3. Retry logic with exponential backoff
|
|
201
|
+
4. Request/response interceptors
|
|
202
|
+
{{#if includeTests}}
|
|
203
|
+
5. Comprehensive test suite using Jest
|
|
204
|
+
6. Mock server for testing
|
|
205
|
+
{{/if}}
|
|
206
|
+
|
|
207
|
+
## Code Structure
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
export class {{serviceName}}Client {
|
|
211
|
+
private baseUrl = '{{baseUrl}}';
|
|
212
|
+
|
|
213
|
+
constructor(private auth: AuthConfig) {}
|
|
214
|
+
|
|
215
|
+
// Implement methods for: {{methods}}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Generated on {{date}} at {{time}} by {{username}}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Template Helpers
|
|
223
|
+
|
|
224
|
+
### Static Helpers
|
|
225
|
+
|
|
226
|
+
These helpers provide system information and are evaluated when the prompt is generated:
|
|
227
|
+
|
|
228
|
+
#### `{{date}}`
|
|
229
|
+
- **Returns**: Current date in local format (e.g., "3/15/2024")
|
|
230
|
+
- **Example**: `Generated on {{date}}`
|
|
231
|
+
|
|
232
|
+
#### `{{time}}`
|
|
233
|
+
- **Returns**: Current time in local format (e.g., "2:30:45 PM")
|
|
234
|
+
- **Example**: `Created at {{time}}`
|
|
235
|
+
|
|
236
|
+
#### `{{datetime}}`
|
|
237
|
+
- **Returns**: Current date and time in local format
|
|
238
|
+
- **Example**: `Timestamp: {{datetime}}`
|
|
239
|
+
|
|
240
|
+
#### `{{timestamp}}`
|
|
241
|
+
- **Returns**: Unix timestamp in milliseconds
|
|
242
|
+
- **Example**: `Build: {{timestamp}}`
|
|
243
|
+
|
|
244
|
+
#### `{{uuid}}`
|
|
245
|
+
- **Returns**: A new UUID v4
|
|
246
|
+
- **Example**: `Request ID: {{uuid}}`
|
|
247
|
+
|
|
248
|
+
#### `{{username}}`
|
|
249
|
+
- **Returns**: Current system username
|
|
250
|
+
- **Example**: `Author: {{username}}`
|
|
251
|
+
|
|
252
|
+
#### `{{hostname}}`
|
|
253
|
+
- **Returns**: Machine hostname
|
|
254
|
+
- **Example**: `Generated on {{hostname}}`
|
|
255
|
+
|
|
256
|
+
#### `{{cwd}}`
|
|
257
|
+
- **Returns**: Current working directory path
|
|
258
|
+
- **Example**: `Project path: {{cwd}}`
|
|
259
|
+
|
|
260
|
+
### Input Helpers
|
|
261
|
+
|
|
262
|
+
These helpers collect information from users interactively:
|
|
263
|
+
|
|
264
|
+
#### `{{input "name" "message"}}`
|
|
265
|
+
- **Purpose**: Collect text input
|
|
266
|
+
- **Parameters**:
|
|
267
|
+
- `name`: Variable name to store the value
|
|
268
|
+
- `message` (optional): Prompt message
|
|
269
|
+
- **Example**: `{{input "projectName" "What is your project name?"}}`
|
|
270
|
+
|
|
271
|
+
#### `{{select "name" "message"}}`
|
|
272
|
+
- **Purpose**: Single choice selection
|
|
273
|
+
- **Parameters**:
|
|
274
|
+
- `name`: Variable name
|
|
275
|
+
- `message` (optional): Prompt message
|
|
276
|
+
- **Note**: Choices come from variable definition
|
|
277
|
+
- **Example**: `{{select "language" "Choose a language:"}}`
|
|
278
|
+
|
|
279
|
+
#### `{{multiselect "name" "message"}}`
|
|
280
|
+
- **Purpose**: Multiple choice selection
|
|
281
|
+
- **Parameters**: Same as select
|
|
282
|
+
- **Returns**: Comma-separated values
|
|
283
|
+
- **Example**: `{{multiselect "features" "Select features:"}}`
|
|
284
|
+
|
|
285
|
+
#### `{{confirm "name" "message"}}`
|
|
286
|
+
- **Purpose**: Yes/no question
|
|
287
|
+
- **Parameters**: Same as input
|
|
288
|
+
- **Returns**: `true` or `false`
|
|
289
|
+
- **Example**: `{{confirm "useTypeScript" "Use TypeScript?"}}`
|
|
290
|
+
|
|
291
|
+
#### `{{editor "name" "message"}}`
|
|
292
|
+
- **Purpose**: Open text editor for multi-line input
|
|
293
|
+
- **Parameters**: Same as input
|
|
294
|
+
- **Example**: `{{editor "description" "Enter description:"}}`
|
|
295
|
+
|
|
296
|
+
#### `{{password "name" "message"}}`
|
|
297
|
+
- **Purpose**: Masked password input
|
|
298
|
+
- **Parameters**: Same as input
|
|
299
|
+
- **Note**: Values are masked in history
|
|
300
|
+
- **Example**: `{{password "apiKey" "Enter API key:"}}`
|
|
301
|
+
|
|
302
|
+
### Variable Substitution
|
|
303
|
+
|
|
304
|
+
Once a variable is defined (either through frontmatter or input helpers), it can be referenced anywhere in the template:
|
|
305
|
+
|
|
306
|
+
```markdown
|
|
307
|
+
Project: {{projectName}}
|
|
308
|
+
Path: /src/{{projectName}}/index.ts
|
|
309
|
+
Welcome to {{projectName}}!
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Variables are cached, so asking for the same variable multiple times will reuse the first value.
|
|
313
|
+
|
|
314
|
+
## Configuration File
|
|
315
|
+
|
|
316
|
+
### Overview
|
|
317
|
+
|
|
318
|
+
The configuration file (`.pt-config.json`, `.pt-config.yaml`, or `.pt-config.js`) controls how the prompt tool behaves. The tool searches for configuration files in:
|
|
319
|
+
1. Current directory and all parent directories
|
|
320
|
+
2. Your home directory
|
|
321
|
+
3. Platform-specific config directories
|
|
322
|
+
|
|
323
|
+
Multiple config files are merged, with closer files taking precedence.
|
|
324
|
+
|
|
325
|
+
### Configuration Format
|
|
326
|
+
|
|
327
|
+
```json
|
|
328
|
+
{
|
|
329
|
+
"promptDirs": ["./.prompts", "~/my-prompts"],
|
|
330
|
+
"historyDir": "~/.pt/history",
|
|
331
|
+
"annotationDir": "~/.pt/history",
|
|
332
|
+
"codingTool": "claude",
|
|
333
|
+
"codingToolArgs": ["--model", "claude-3"],
|
|
334
|
+
"codingToolOptions": {
|
|
335
|
+
"Continue with context?": "--continue",
|
|
336
|
+
"Use verbose output?": "--verbose"
|
|
337
|
+
},
|
|
338
|
+
"partials": {
|
|
339
|
+
"header": {
|
|
340
|
+
"type": "inline",
|
|
341
|
+
"value": "Generated by {{username}} on {{date}}"
|
|
342
|
+
},
|
|
343
|
+
"footer": {
|
|
344
|
+
"type": "file",
|
|
345
|
+
"path": "~/.pt/partials/footer.md"
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
"version": "2.0.0"
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Configuration Fields
|
|
353
|
+
|
|
354
|
+
#### `promptDirs` (array of strings)
|
|
355
|
+
- **Purpose**: Directories to search for prompt files
|
|
356
|
+
- **Default**: `["./.prompts"]`
|
|
357
|
+
- **Notes**:
|
|
358
|
+
- Searches recursively for `.md` files
|
|
359
|
+
- Supports `~` for home directory
|
|
360
|
+
- Relative paths are resolved from config file location
|
|
361
|
+
- **Example**: `["./.prompts", "~/global-prompts", "/usr/share/pt/prompts"]`
|
|
362
|
+
|
|
363
|
+
#### `historyDir` (string, optional)
|
|
364
|
+
- **Purpose**: Directory to save generated prompts history
|
|
365
|
+
- **Default**: None (history disabled)
|
|
366
|
+
- **Notes**:
|
|
367
|
+
- Creates timestamped files with metadata
|
|
368
|
+
- Sensitive values (passwords, API keys) are automatically masked
|
|
369
|
+
- Supports `~` for home directory
|
|
370
|
+
- **Example**: `"~/.pt/history"`
|
|
371
|
+
|
|
372
|
+
#### `annotationDir` (string, optional)
|
|
373
|
+
- **Purpose**: Directory to save annotations for history entries
|
|
374
|
+
- **Default**: None (annotations disabled)
|
|
375
|
+
- **Notes**:
|
|
376
|
+
- Requires history to be enabled
|
|
377
|
+
- Stores notes, tags, and success/failure status
|
|
378
|
+
- Supports `~` for home directory
|
|
379
|
+
- **Example**: `"~/.pt/history"`
|
|
380
|
+
|
|
381
|
+
#### `codingTool` (string, optional)
|
|
382
|
+
- **Purpose**: Default tool to use with `pt run`
|
|
383
|
+
- **Default**: `"claude"`
|
|
384
|
+
- **Notes**:
|
|
385
|
+
- Can be any command-line tool that accepts stdin
|
|
386
|
+
- Override with `pt run <tool>`
|
|
387
|
+
- **Example**: `"claude"`, `"gpt"`, `"code -"`
|
|
388
|
+
|
|
389
|
+
#### `codingToolArgs` (array of strings, optional)
|
|
390
|
+
- **Purpose**: Default arguments for the coding tool
|
|
391
|
+
- **Default**: `[]`
|
|
392
|
+
- **Notes**:
|
|
393
|
+
- Always passed to the tool
|
|
394
|
+
- Additional args can be added with `pt run -- <args>`
|
|
395
|
+
- **Example**: `["--model", "claude-3-opus"]`
|
|
396
|
+
|
|
397
|
+
#### `codingToolOptions` (object, optional)
|
|
398
|
+
- **Purpose**: Interactive options to prompt for when running
|
|
399
|
+
- **Default**: `{ "Continue with last context?": "--continue" }`
|
|
400
|
+
- **Structure**: Object where keys are questions and values are arguments
|
|
401
|
+
- **Notes**:
|
|
402
|
+
- User is prompted for each option
|
|
403
|
+
- Arguments added only if user answers "yes"
|
|
404
|
+
- **Example**:
|
|
405
|
+
```json
|
|
406
|
+
{
|
|
407
|
+
"Continue with context?": "--continue",
|
|
408
|
+
"Use verbose output?": "--verbose",
|
|
409
|
+
"Enable debug mode?": "--debug"
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### `partials` (object, optional)
|
|
414
|
+
- **Purpose**: Define reusable template fragments
|
|
415
|
+
- **Default**: None
|
|
416
|
+
- **Structure**: Object where keys are partial names and values define the partial:
|
|
417
|
+
- `type`: Either "inline" or "file"
|
|
418
|
+
- `value`: Template content (for inline type)
|
|
419
|
+
- `path`: Path to file (for file type)
|
|
420
|
+
- **Usage**: Reference in templates with `{{> partialName}}`
|
|
421
|
+
- **Example**:
|
|
422
|
+
```json
|
|
423
|
+
{
|
|
424
|
+
"partials": {
|
|
425
|
+
"copyright": {
|
|
426
|
+
"type": "inline",
|
|
427
|
+
"value": "Copyright (c) {{year}} {{company}}"
|
|
428
|
+
},
|
|
429
|
+
"header": {
|
|
430
|
+
"type": "file",
|
|
431
|
+
"path": "~/.pt/partials/header.md"
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### Configuration Examples
|
|
438
|
+
|
|
439
|
+
#### Minimal Configuration
|
|
440
|
+
```json
|
|
441
|
+
{
|
|
442
|
+
"promptDirs": ["./.prompts"]
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
#### Development Team Configuration
|
|
447
|
+
```json
|
|
448
|
+
{
|
|
449
|
+
"promptDirs": [
|
|
450
|
+
"./.prompts",
|
|
451
|
+
"~/team-prompts",
|
|
452
|
+
"/shared/company-prompts"
|
|
453
|
+
],
|
|
454
|
+
"historyDir": "~/.pt/history",
|
|
455
|
+
"annotationDir": "~/.pt/history",
|
|
456
|
+
"codingTool": "claude",
|
|
457
|
+
"codingToolArgs": ["--model", "claude-3-opus"],
|
|
458
|
+
"codingToolOptions": {
|
|
459
|
+
"Continue with context?": "--continue",
|
|
460
|
+
"Use company guidelines?": "--guidelines=/shared/guidelines.md"
|
|
461
|
+
},
|
|
462
|
+
"partials": {
|
|
463
|
+
"companyHeader": {
|
|
464
|
+
"type": "inline",
|
|
465
|
+
"value": "/* Company Confidential - {{date}} */"
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
"version": "2.0.0"
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
#### Personal Configuration
|
|
473
|
+
```yaml
|
|
474
|
+
promptDirs:
|
|
475
|
+
- ~/my-prompts
|
|
476
|
+
- ~/work-prompts
|
|
477
|
+
- ~/personal-prompts
|
|
478
|
+
historyDir: ~/.pt/history
|
|
479
|
+
annotationDir: ~/.pt/annotations
|
|
480
|
+
codingTool: gpt
|
|
481
|
+
codingToolArgs:
|
|
482
|
+
- --temperature
|
|
483
|
+
- "0.7"
|
|
484
|
+
version: "2.0.0"
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
#### Minimal Configuration with History
|
|
488
|
+
```json
|
|
489
|
+
{
|
|
490
|
+
"promptDirs": ["./.prompts"],
|
|
491
|
+
"historyDir": "./.pthistory",
|
|
492
|
+
"version": "2.0.0"
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
## Development
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
# Install dependencies
|
|
500
|
+
npm install
|
|
501
|
+
|
|
502
|
+
# Run tests
|
|
503
|
+
npm test
|
|
504
|
+
|
|
505
|
+
# Run tests with coverage
|
|
506
|
+
npm run test:coverage
|
|
507
|
+
|
|
508
|
+
# Build
|
|
509
|
+
npm run build
|
|
510
|
+
|
|
511
|
+
# Run locally
|
|
512
|
+
node dist/cli.js
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
## License
|
|
516
|
+
|
|
517
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnnotationMetadata, ParsedAnnotation, IssueIdentified, AnnotationAnalysisSummary } from '../types/annotations.js';
|
|
2
|
+
interface RawAnnotation extends AnnotationMetadata {
|
|
3
|
+
notes?: string;
|
|
4
|
+
annotationPath?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class AnnotationAnalyzer {
|
|
7
|
+
private patternRules;
|
|
8
|
+
parseAnnotations(annotations: RawAnnotation[]): ParsedAnnotation[];
|
|
9
|
+
extractPatterns(annotations: ParsedAnnotation[]): string[];
|
|
10
|
+
categorizeIssues(annotations: ParsedAnnotation[]): Record<string, IssueIdentified[]>;
|
|
11
|
+
calculatePatternFrequency(annotations: ParsedAnnotation[]): Record<string, number>;
|
|
12
|
+
getAnalysisSummary(annotations: ParsedAnnotation[]): AnnotationAnalysisSummary;
|
|
13
|
+
private detectPatternsInText;
|
|
14
|
+
private extractPromptName;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=annotation-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-analyzer.d.ts","sourceRoot":"","sources":["../../src/annotations/annotation-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AAEjC,UAAU,aAAc,SAAQ,kBAAkB;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,YAAY,CAiClB;IAEF,gBAAgB,CAAC,WAAW,EAAE,aAAa,EAAE,GAAG,gBAAgB,EAAE;IA4BlE,eAAe,CAAC,WAAW,EAAE,gBAAgB,EAAE,GAAG,MAAM,EAAE;IAmB1D,gBAAgB,CAAC,WAAW,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IAiBpF,yBAAyB,CAAC,WAAW,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAqBlF,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,EAAE,GAAG,yBAAyB;IA8B9E,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,iBAAiB;CAM1B"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export class AnnotationAnalyzer {
|
|
2
|
+
patternRules = {
|
|
3
|
+
verification_gap: [
|
|
4
|
+
/test.*fail.*(?:after|despite).*(?:claim|said).*(?:success|complete|done)/i,
|
|
5
|
+
/(?:claim|said).*(?:success|complete|done).*but.*test.*fail/i,
|
|
6
|
+
/test.*still.*fail/i,
|
|
7
|
+
/AI.*(?:said|claimed).*(?:success|complete|done).*but.*(?:test|build).*fail/i,
|
|
8
|
+
/(?:claim|said).*complet.*but.*error.*remain/i,
|
|
9
|
+
/test.*(?:were|was).*fail.*despite.*(?:success|completion).*claim/i,
|
|
10
|
+
/test.*fail.*despite.*complet.*claim/i
|
|
11
|
+
],
|
|
12
|
+
incomplete_task: [
|
|
13
|
+
/stopped?\s+at\s+first\s+error/i,
|
|
14
|
+
/only\s+(?:fixed|completed|did)\s+(?:one|1|part)/i,
|
|
15
|
+
/incomplete\s+implementation/i,
|
|
16
|
+
/partial(?:ly)?\s+complet/i,
|
|
17
|
+
/did\s+not\s+finish\s+all/i,
|
|
18
|
+
/(?:fixed|completed)\s+\d+\s+(?:of|out\s+of)\s+\d+/i,
|
|
19
|
+
/left\s+(?:some|other)\s+(?:error|issue|task)/i
|
|
20
|
+
],
|
|
21
|
+
ambiguous_instruction: [
|
|
22
|
+
/unclear\s+(?:what|requirement|instruction|expectation)/i,
|
|
23
|
+
/ambiguous\s+(?:requirement|instruction|prompt)/i,
|
|
24
|
+
/prompt\s+(?:was|is)\s+(?:not\s+)?(?:specific|clear)/i,
|
|
25
|
+
/instruction.*vague/i,
|
|
26
|
+
/confusing\s+prompt/i,
|
|
27
|
+
/(?:not|wasn't)\s+(?:sure|clear)\s+what\s+(?:to|was\s+expected)/i
|
|
28
|
+
],
|
|
29
|
+
missing_constraint: [
|
|
30
|
+
/(?:no|missing)\s+(?:requirement|constraint|specification)\s+(?:for|about)/i,
|
|
31
|
+
/(?:didn't|did\s+not)\s+(?:specify|mention)\s+(?:requirement|constraint)/i,
|
|
32
|
+
/(?:forgot|missed)\s+to\s+(?:include|specify|mention)/i,
|
|
33
|
+
/(?:performance|security|error\s+handling).*(?:not\s+specified|missing)/i
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
parseAnnotations(annotations) {
|
|
37
|
+
return annotations.map(ann => {
|
|
38
|
+
const parsed = {
|
|
39
|
+
historyFile: ann.historyFile,
|
|
40
|
+
timestamp: ann.timestamp,
|
|
41
|
+
status: ann.status,
|
|
42
|
+
tags: ann.tags || [],
|
|
43
|
+
notes: ann.notes || '',
|
|
44
|
+
promptName: this.extractPromptName(ann.historyFile),
|
|
45
|
+
annotationPath: ann.annotationPath || ''
|
|
46
|
+
};
|
|
47
|
+
if (ann.structured_outcome) {
|
|
48
|
+
parsed.structured_outcome = ann.structured_outcome;
|
|
49
|
+
}
|
|
50
|
+
if (ann.issues_identified) {
|
|
51
|
+
parsed.issues_identified = ann.issues_identified;
|
|
52
|
+
}
|
|
53
|
+
if (ann.auto_detected !== undefined) {
|
|
54
|
+
parsed.auto_detected = ann.auto_detected;
|
|
55
|
+
}
|
|
56
|
+
return parsed;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
extractPatterns(annotations) {
|
|
60
|
+
const patterns = new Set();
|
|
61
|
+
annotations.forEach(ann => {
|
|
62
|
+
// Extract from structured issues
|
|
63
|
+
if (ann.issues_identified) {
|
|
64
|
+
ann.issues_identified.forEach(issue => {
|
|
65
|
+
patterns.add(issue.category);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
// Extract from notes text
|
|
69
|
+
const textPatterns = this.detectPatternsInText(ann.notes);
|
|
70
|
+
textPatterns.forEach(p => patterns.add(p));
|
|
71
|
+
});
|
|
72
|
+
return Array.from(patterns);
|
|
73
|
+
}
|
|
74
|
+
categorizeIssues(annotations) {
|
|
75
|
+
const categorized = {};
|
|
76
|
+
annotations.forEach(ann => {
|
|
77
|
+
if (ann.issues_identified) {
|
|
78
|
+
ann.issues_identified.forEach(issue => {
|
|
79
|
+
if (!categorized[issue.category]) {
|
|
80
|
+
categorized[issue.category] = [];
|
|
81
|
+
}
|
|
82
|
+
categorized[issue.category].push(issue);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
return categorized;
|
|
87
|
+
}
|
|
88
|
+
calculatePatternFrequency(annotations) {
|
|
89
|
+
const frequency = {};
|
|
90
|
+
annotations.forEach(ann => {
|
|
91
|
+
// Count from structured issues
|
|
92
|
+
if (ann.issues_identified) {
|
|
93
|
+
ann.issues_identified.forEach(issue => {
|
|
94
|
+
frequency[issue.category] = (frequency[issue.category] || 0) + 1;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Count from text patterns
|
|
98
|
+
const textPatterns = this.detectPatternsInText(ann.notes);
|
|
99
|
+
textPatterns.forEach(pattern => {
|
|
100
|
+
frequency[pattern] = (frequency[pattern] || 0) + 1;
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
return frequency;
|
|
104
|
+
}
|
|
105
|
+
getAnalysisSummary(annotations) {
|
|
106
|
+
const statusDistribution = {
|
|
107
|
+
success: 0,
|
|
108
|
+
partial: 0,
|
|
109
|
+
failure: 0
|
|
110
|
+
};
|
|
111
|
+
const tagCounts = {};
|
|
112
|
+
annotations.forEach(ann => {
|
|
113
|
+
statusDistribution[ann.status]++;
|
|
114
|
+
ann.tags.forEach(tag => {
|
|
115
|
+
tagCounts[tag] = (tagCounts[tag] || 0) + 1;
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const commonTags = Object.entries(tagCounts)
|
|
119
|
+
.sort((a, b) => b[1] - a[1])
|
|
120
|
+
.map(([tag]) => tag);
|
|
121
|
+
return {
|
|
122
|
+
totalAnnotations: annotations.length,
|
|
123
|
+
statusDistribution,
|
|
124
|
+
patternFrequency: this.calculatePatternFrequency(annotations),
|
|
125
|
+
commonTags,
|
|
126
|
+
issuesByCategory: this.categorizeIssues(annotations)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
detectPatternsInText(text) {
|
|
130
|
+
const detected = [];
|
|
131
|
+
Object.entries(this.patternRules).forEach(([pattern, rules]) => {
|
|
132
|
+
if (rules.some(rule => rule.test(text))) {
|
|
133
|
+
detected.push(pattern);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return detected;
|
|
137
|
+
}
|
|
138
|
+
extractPromptName(historyFile) {
|
|
139
|
+
// Extract prompt name from history filename pattern
|
|
140
|
+
// Format: history_YYYY-MM-DDTHH-MM-SSZ_promptname.json
|
|
141
|
+
const match = historyFile.match(/history_.*?_(.+)\.json$/);
|
|
142
|
+
return match ? match[1] : 'unknown';
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=annotation-analyzer.js.map
|