@bretwardjames/ghp-cli 0.2.0-beta.1 → 0.2.0-beta.10
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/README.md +253 -27
- package/dist/ai-feedback.d.ts +43 -0
- package/dist/ai-feedback.d.ts.map +1 -0
- package/dist/ai-feedback.js +154 -0
- package/dist/ai-feedback.js.map +1 -0
- package/dist/branch-linker.d.ts +2 -10
- package/dist/branch-linker.d.ts.map +1 -1
- package/dist/branch-linker.js +3 -24
- package/dist/branch-linker.js.map +1 -1
- package/dist/claude-runner.d.ts +43 -0
- package/dist/claude-runner.d.ts.map +1 -0
- package/dist/claude-runner.js +239 -0
- package/dist/claude-runner.js.map +1 -0
- package/dist/commands/add-issue.d.ts +18 -0
- package/dist/commands/add-issue.d.ts.map +1 -1
- package/dist/commands/add-issue.js +225 -4
- package/dist/commands/add-issue.js.map +1 -1
- package/dist/commands/agents.d.ts +29 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +312 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +119 -15
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/dashboard-hooks.d.ts +39 -0
- package/dist/commands/dashboard-hooks.d.ts.map +1 -0
- package/dist/commands/dashboard-hooks.js +149 -0
- package/dist/commands/dashboard-hooks.js.map +1 -0
- package/dist/commands/dashboard.d.ts +24 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +255 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/install-commands.d.ts +17 -0
- package/dist/commands/install-commands.d.ts.map +1 -0
- package/dist/commands/install-commands.js +138 -0
- package/dist/commands/install-commands.js.map +1 -0
- package/dist/commands/label.d.ts +6 -0
- package/dist/commands/label.d.ts.map +1 -0
- package/dist/commands/label.js +65 -0
- package/dist/commands/label.js.map +1 -0
- package/dist/commands/mcp.d.ts +2 -0
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +76 -3
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/plan-epic.d.ts +15 -0
- package/dist/commands/plan-epic.d.ts.map +1 -0
- package/dist/commands/plan-epic.js +280 -0
- package/dist/commands/plan-epic.js.map +1 -0
- package/dist/commands/plan.d.ts.map +1 -1
- package/dist/commands/plan.js +31 -2
- package/dist/commands/plan.js.map +1 -1
- package/dist/commands/pr.d.ts +1 -0
- package/dist/commands/pr.d.ts.map +1 -1
- package/dist/commands/pr.js +141 -6
- package/dist/commands/pr.js.map +1 -1
- package/dist/commands/progress.d.ts +8 -0
- package/dist/commands/progress.d.ts.map +1 -0
- package/dist/commands/progress.js +170 -0
- package/dist/commands/progress.js.map +1 -0
- package/dist/commands/set-parent.d.ts +7 -0
- package/dist/commands/set-parent.d.ts.map +1 -0
- package/dist/commands/set-parent.js +66 -0
- package/dist/commands/set-parent.js.map +1 -0
- package/dist/commands/start.d.ts +10 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +223 -6
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/stop.d.ts +7 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +75 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/switch.d.ts +8 -0
- package/dist/commands/switch.d.ts.map +1 -1
- package/dist/commands/switch.js +90 -2
- package/dist/commands/switch.js.map +1 -1
- package/dist/commands/update.d.ts +12 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +187 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/work.d.ts +1 -0
- package/dist/commands/work.d.ts.map +1 -1
- package/dist/commands/work.js +27 -2
- package/dist/commands/work.js.map +1 -1
- package/dist/commands/worktree.d.ts +4 -1
- package/dist/commands/worktree.d.ts.map +1 -1
- package/dist/commands/worktree.js +28 -2
- package/dist/commands/worktree.js.map +1 -1
- package/dist/config.d.ts +134 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +177 -2
- package/dist/config.js.map +1 -1
- package/dist/conventions.d.ts +14 -0
- package/dist/conventions.d.ts.map +1 -0
- package/dist/conventions.js +49 -0
- package/dist/conventions.js.map +1 -0
- package/dist/editor.d.ts +12 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +48 -0
- package/dist/editor.js.map +1 -0
- package/dist/github-api.d.ts +1 -1
- package/dist/github-api.d.ts.map +1 -1
- package/dist/github-api.js.map +1 -1
- package/dist/index.js +229 -11
- package/dist/index.js.map +1 -1
- package/dist/table.d.ts +1 -1
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +19 -0
- package/dist/table.js.map +1 -1
- package/dist/terminal-utils.d.ts +101 -0
- package/dist/terminal-utils.d.ts.map +1 -0
- package/dist/terminal-utils.js +450 -0
- package/dist/terminal-utils.js.map +1 -0
- package/dist/types.d.ts +25 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/worktree-utils.d.ts +2 -1
- package/dist/worktree-utils.d.ts.map +1 -1
- package/dist/worktree-utils.js +4 -3
- package/dist/worktree-utils.js.map +1 -1
- package/package.json +4 -3
- package/slash-commands/claude/create-pr.md +11 -0
- package/slash-commands/claude/ghp-plan.md +142 -0
- package/slash-commands/claude/handoff.md +11 -0
- package/slash-commands/claude/nudge.md +38 -0
- package/slash-commands/claude/save.md +7 -0
- package/slash-commands/claude/start.md +7 -0
package/README.md
CHANGED
|
@@ -28,69 +28,289 @@ ghp start 123
|
|
|
28
28
|
|
|
29
29
|
## Commands
|
|
30
30
|
|
|
31
|
-
###
|
|
31
|
+
### Authentication
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ghp auth # Check authentication status
|
|
35
|
+
ghp auth --status # Display auth status and setup guide
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Viewing Work
|
|
32
39
|
|
|
33
40
|
```bash
|
|
34
41
|
ghp work # Your assigned items
|
|
35
|
-
ghp work --
|
|
42
|
+
ghp work --all # All items (not just yours)
|
|
43
|
+
ghp work --status "In Progress" # Filter by status
|
|
44
|
+
ghp work --hide-done # Hide completed items
|
|
36
45
|
ghp work --group priority # Group by field
|
|
46
|
+
ghp work --sort -priority # Sort (prefix - for descending)
|
|
47
|
+
ghp work --slice type=Bug # Filter by field value
|
|
48
|
+
ghp work --list # Simple list format
|
|
49
|
+
ghp work --flat # Flat table format
|
|
50
|
+
ghp work --json # JSON output for scripts/AI tools
|
|
51
|
+
```
|
|
37
52
|
|
|
38
|
-
|
|
39
|
-
ghp plan
|
|
40
|
-
ghp plan --
|
|
53
|
+
```bash
|
|
54
|
+
ghp plan # Project board view
|
|
55
|
+
ghp plan --mine # Only items assigned to you
|
|
56
|
+
ghp plan --unassigned # Only unassigned items
|
|
57
|
+
ghp plan --status "Backlog" # Filter by status (repeatable)
|
|
58
|
+
ghp plan --slice type=Bug # Filter by field value (repeatable)
|
|
59
|
+
ghp plan --view "Sprint 1" # Filter by project view
|
|
60
|
+
ghp plan --group status # Group by field
|
|
61
|
+
ghp plan --sort priority # Sort by field
|
|
62
|
+
ghp plan --all # Include done items
|
|
63
|
+
ghp plan --hide-done # Exclude completed items
|
|
64
|
+
ghp plan --list # Simple list format
|
|
65
|
+
ghp plan --json # JSON output for scripts/AI tools
|
|
41
66
|
ghp plan bugs # Use configured shortcut
|
|
42
67
|
```
|
|
43
68
|
|
|
69
|
+
```bash
|
|
70
|
+
ghp slice # Interactive field filtering
|
|
71
|
+
ghp slice -f Priority -v High # Filter by specific field/value
|
|
72
|
+
ghp slice --list-fields # List all available fields
|
|
73
|
+
```
|
|
74
|
+
|
|
44
75
|
### Issue Management
|
|
45
76
|
|
|
46
77
|
```bash
|
|
47
|
-
|
|
48
|
-
ghp add
|
|
49
|
-
ghp
|
|
78
|
+
# Create issues
|
|
79
|
+
ghp add "Issue title" # Create issue (shorthand)
|
|
80
|
+
ghp add issue "Issue title" # Create issue (explicit)
|
|
81
|
+
ghp add issue "Title" --body "desc" # With description
|
|
82
|
+
ghp add issue "Title" -e # Open editor for body
|
|
83
|
+
ghp add issue "Title" --template bug # Use specific template
|
|
84
|
+
ghp add issue "Title" --ai # AI-expand brief title
|
|
85
|
+
ghp add issue "Title" --status "Backlog" # Set initial status
|
|
86
|
+
ghp add issue "Title" --labels "bug,urgent" # Apply labels
|
|
87
|
+
ghp add issue "Title" --assign # Assign yourself
|
|
88
|
+
ghp add issue "Title" --parent 42 # Create as sub-issue
|
|
89
|
+
|
|
90
|
+
# Create epics
|
|
91
|
+
ghp add epic "Epic title" # Create epic (issue with epic label)
|
|
92
|
+
ghp add epic "Auth system" --ai # AI breakdown into sub-issues
|
|
93
|
+
ghp add epic "Title" --ai -x # Execute AI plan (create issues)
|
|
94
|
+
ghp add epic "Title" --ai -c "context" # Provide additional context
|
|
95
|
+
|
|
96
|
+
ghp add --list-templates # List available templates
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ghp open 123 # View issue details in terminal
|
|
50
101
|
ghp open 123 --browser # Open in browser
|
|
51
|
-
|
|
52
|
-
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
ghp edit 123 # Edit issue in $EDITOR
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
ghp comment 123 # Add comment (opens editor)
|
|
110
|
+
ghp comment 123 -m "message" # Add comment inline
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
ghp move 123 "In Review" # Change issue status
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
ghp set-field 123 Priority High # Set any project field
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
ghp assign 123 # Assign yourself
|
|
123
|
+
ghp assign 123 @user1 @user2 # Assign specific users
|
|
124
|
+
ghp assign 123 --remove @user # Remove assignee
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
ghp label 123 bug urgent # Add labels
|
|
129
|
+
ghp label 123 bug --remove # Remove label
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Parent/Child Relationships (Sub-Issues)
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
ghp set-parent 123 --parent 42 # Set parent issue
|
|
136
|
+
ghp set-parent 123 --remove # Remove parent
|
|
137
|
+
ghp progress 42 # Show epic progress with sub-issues
|
|
53
138
|
```
|
|
54
139
|
|
|
55
140
|
### Workflow
|
|
56
141
|
|
|
57
142
|
```bash
|
|
58
|
-
ghp start 123 #
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
143
|
+
ghp start 123 # Start working on issue
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The `start` command:
|
|
147
|
+
- Creates or links a branch
|
|
148
|
+
- Updates issue status to "In Progress"
|
|
149
|
+
- Assigns you if not already assigned
|
|
150
|
+
- Applies the active label
|
|
151
|
+
|
|
152
|
+
**Options:**
|
|
153
|
+
| Option | Description |
|
|
154
|
+
|--------|-------------|
|
|
155
|
+
| `--parallel` | Create worktree instead of switching branches |
|
|
156
|
+
| `--worktree-path <path>` | Custom worktree location |
|
|
157
|
+
| `--branch-action <action>` | `create`, `link`, or `skip` |
|
|
158
|
+
| `--assign <action>` | `reassign`, `add`, or `skip` |
|
|
159
|
+
| `--from-main` | Create branch from main (when not on main) |
|
|
160
|
+
| `--force` | Proceed with uncommitted changes |
|
|
161
|
+
| `--force-defaults` | Non-interactive mode |
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
ghp done 123 # Mark issue as done
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Removes active label and offers to clean up worktree if one exists.
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
ghp pr # Show PR status for current branch
|
|
171
|
+
ghp pr 123 # Show PR for specific issue
|
|
172
|
+
ghp pr --create # Create PR for current branch
|
|
173
|
+
ghp pr --open # Open PR in browser
|
|
62
174
|
```
|
|
63
175
|
|
|
64
176
|
### Branch Management
|
|
65
177
|
|
|
66
178
|
```bash
|
|
67
|
-
ghp switch 123 # Switch to issue's branch
|
|
179
|
+
ghp switch 123 # Switch to issue's linked branch
|
|
180
|
+
ghp switch 123 --parallel # Open in worktree instead
|
|
181
|
+
ghp switch 123 --worktree-path /custom/path
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```bash
|
|
68
185
|
ghp link-branch 123 # Link current branch to issue
|
|
69
|
-
ghp
|
|
70
|
-
ghp sync # Sync active label with branch
|
|
186
|
+
ghp link-branch 123 feature/x # Link specific branch
|
|
71
187
|
```
|
|
72
188
|
|
|
73
|
-
|
|
189
|
+
```bash
|
|
190
|
+
ghp unlink-branch 123 # Remove branch link from issue
|
|
191
|
+
```
|
|
74
192
|
|
|
75
193
|
```bash
|
|
76
|
-
ghp
|
|
77
|
-
ghp config # Edit user config
|
|
78
|
-
ghp config -w # Edit workspace config (shared)
|
|
79
|
-
ghp config sync # Sync with VS Code/Cursor
|
|
194
|
+
ghp sync # Sync active label with current branch
|
|
80
195
|
```
|
|
81
196
|
|
|
82
|
-
|
|
197
|
+
### Parallel Work Mode (Worktrees)
|
|
83
198
|
|
|
84
|
-
|
|
199
|
+
Work on multiple issues simultaneously:
|
|
85
200
|
|
|
86
201
|
```bash
|
|
202
|
+
ghp start 123 --parallel # Create worktree for issue
|
|
203
|
+
ghp switch 456 --parallel # Open existing issue in worktree
|
|
204
|
+
ghp worktree list # List all active worktrees
|
|
205
|
+
ghp worktree list --json # JSON output for scripts/AI tools
|
|
206
|
+
ghp worktree remove 123 # Remove worktree for issue
|
|
207
|
+
ghp worktree remove 123 --force # Force remove (uncommitted changes)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Branch Dashboard
|
|
211
|
+
|
|
212
|
+
View comprehensive branch changes with extensible hook system:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
ghp dashboard # Full dashboard (commits, files, stats, hooks)
|
|
216
|
+
ghp dashboard --diff # Show full unified diff
|
|
217
|
+
ghp dashboard --commits # Commit history only
|
|
218
|
+
ghp dashboard --files # Changed files only
|
|
219
|
+
ghp dashboard --stats # Diff statistics only
|
|
220
|
+
ghp dashboard --json # JSON output for scripts/tools
|
|
221
|
+
ghp dashboard --base main # Compare against specific base branch
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Dashboard Hooks** - Integrate external tools (AI context, test results, etc.):
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
ghp dashboard hooks list # List registered hooks
|
|
228
|
+
ghp dashboard hooks add <name> # Register a new hook
|
|
229
|
+
--command <cmd> # Command to execute
|
|
230
|
+
--category <cat> # Category for grouping (optional)
|
|
231
|
+
--display-name <name> # Display name (optional)
|
|
232
|
+
--timeout <ms> # Timeout in milliseconds (default: 5000)
|
|
233
|
+
ghp dashboard hooks remove <name> # Remove a hook
|
|
234
|
+
ghp dashboard hooks enable <name> # Enable a hook
|
|
235
|
+
ghp dashboard hooks disable <name> # Disable a hook
|
|
236
|
+
ghp dashboard hooks show <name> # Show hook details
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Hook commands receive `--branch` and `--repo` arguments and return JSON:
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"success": true,
|
|
243
|
+
"data": {
|
|
244
|
+
"title": "Section Title",
|
|
245
|
+
"items": [{ "label": "Item", "value": "Description" }]
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
See [docs/hooks/README.md](../../docs/hooks/README.md) for the full hook API.
|
|
251
|
+
|
|
252
|
+
### Agent Management
|
|
253
|
+
|
|
254
|
+
Manage Claude agents running in parallel worktrees:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
ghp agents list # List all running agents
|
|
258
|
+
ghp agents list --json # JSON output for scripts/AI tools
|
|
259
|
+
ghp agents stop 123 # Stop agent for specific issue
|
|
260
|
+
ghp agents stop --all # Stop all agents
|
|
261
|
+
ghp agents watch # Real-time agent dashboard
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### AI-Assisted Features
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
ghp add issue "Fix login" --ai # Expand brief title into full issue
|
|
268
|
+
ghp add epic "Auth system" --ai # Break down epic into sub-issues
|
|
269
|
+
ghp add epic "Title" --ai -x # Execute plan (create issues)
|
|
270
|
+
ghp pr --ai-description # Generate PR description from changes
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
> **Note:** `ghp plan-epic` is deprecated. Use `ghp add epic --ai` instead.
|
|
274
|
+
|
|
275
|
+
### Configuration
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
ghp config # Open config in editor
|
|
279
|
+
ghp config --show # Display all settings with sources
|
|
280
|
+
ghp config -w # Edit workspace config (shared with team)
|
|
281
|
+
ghp config -u # Edit user config (personal)
|
|
282
|
+
ghp config sync # Sync settings with VS Code/Cursor
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### MCP Server
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
ghp mcp # Show MCP configuration
|
|
289
|
+
ghp mcp --config # Show config JSON
|
|
87
290
|
ghp mcp --install # Auto-configure Claude Desktop
|
|
88
|
-
ghp mcp --config # Show config JSON to copy manually
|
|
89
291
|
```
|
|
90
292
|
|
|
293
|
+
## Configuration
|
|
294
|
+
|
|
91
295
|
**Config files:**
|
|
92
296
|
- User: `~/.config/ghp-cli/config.json`
|
|
93
|
-
- Workspace: `.ghp/config.json` (commit this)
|
|
297
|
+
- Workspace: `.ghp/config.json` (commit this for team settings)
|
|
298
|
+
|
|
299
|
+
Settings are merged: defaults → workspace → user (later overrides earlier).
|
|
300
|
+
|
|
301
|
+
### All Options
|
|
302
|
+
|
|
303
|
+
| Option | Default | Description |
|
|
304
|
+
|--------|---------|-------------|
|
|
305
|
+
| `mainBranch` | `"main"` | Main branch name |
|
|
306
|
+
| `branchPattern` | `"{user}/{number}-{title}"` | Branch naming. Tokens: `{user}`, `{number}`, `{title}` |
|
|
307
|
+
| `startWorkingStatus` | `"In Progress"` | Status when starting work |
|
|
308
|
+
| `doneStatus` | `"Done"` | Status when marking done |
|
|
309
|
+
| `worktreePath` | `"~/.ghp/worktrees"` | Base directory for worktrees |
|
|
310
|
+
| `worktreeCopyFiles` | `[".env", ".env.local"]` | Files copied to new worktrees |
|
|
311
|
+
| `worktreeSetupCommand` | `"pnpm install"` | Setup command for new worktrees |
|
|
312
|
+
| `worktreeAutoSetup` | `true` | Auto-run setup in new worktrees |
|
|
313
|
+
| `shortcuts` | `{}` | Named filter combinations |
|
|
94
314
|
|
|
95
315
|
### Example Config
|
|
96
316
|
|
|
@@ -100,8 +320,13 @@ ghp mcp --config # Show config JSON to copy manually
|
|
|
100
320
|
"branchPattern": "{user}/{number}-{title}",
|
|
101
321
|
"startWorkingStatus": "In Progress",
|
|
102
322
|
"doneStatus": "Done",
|
|
323
|
+
"worktreePath": "~/dev/worktrees",
|
|
324
|
+
"worktreeCopyFiles": [".env", ".env.local", ".env.test"],
|
|
325
|
+
"worktreeSetupCommand": "npm ci",
|
|
326
|
+
"worktreeAutoSetup": true,
|
|
103
327
|
"shortcuts": {
|
|
104
|
-
"bugs": { "status": "Backlog", "slice": ["type=Bug"] }
|
|
328
|
+
"bugs": { "status": "Backlog", "slice": ["type=Bug"] },
|
|
329
|
+
"mine": { "mine": true, "status": "In Progress" }
|
|
105
330
|
}
|
|
106
331
|
}
|
|
107
332
|
```
|
|
@@ -109,6 +334,7 @@ ghp mcp --config # Show config JSON to copy manually
|
|
|
109
334
|
## Requirements
|
|
110
335
|
|
|
111
336
|
- Node.js >= 18
|
|
337
|
+
- GitHub CLI (`gh`) authenticated, or `GITHUB_TOKEN` environment variable
|
|
112
338
|
- GitHub account with Projects access
|
|
113
339
|
|
|
114
340
|
## License
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Feedback Loop UI
|
|
3
|
+
*
|
|
4
|
+
* Provides a reusable feedback mechanism for AI-generated content.
|
|
5
|
+
* Users can accept, edit, or regenerate with feedback.
|
|
6
|
+
*/
|
|
7
|
+
/** Error thrown when user cancels the feedback loop */
|
|
8
|
+
export declare class UserCancelledError extends Error {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export interface FeedbackResult {
|
|
12
|
+
/** The final accepted content */
|
|
13
|
+
content: string;
|
|
14
|
+
/** Whether the user edited the content */
|
|
15
|
+
wasEdited: boolean;
|
|
16
|
+
/** Number of regeneration attempts */
|
|
17
|
+
regenerationCount: number;
|
|
18
|
+
/** Whether the user cancelled */
|
|
19
|
+
cancelled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface FeedbackOptions {
|
|
22
|
+
/** Type of content being generated (for display) */
|
|
23
|
+
contentType: string;
|
|
24
|
+
/** Initial generated content */
|
|
25
|
+
initialContent: string;
|
|
26
|
+
/** Function to regenerate content with feedback */
|
|
27
|
+
regenerate: (feedback: string) => Promise<string>;
|
|
28
|
+
/** File extension for editor (default: .md) */
|
|
29
|
+
fileExtension?: string;
|
|
30
|
+
/** Whether to show a preview (default: true) */
|
|
31
|
+
showPreview?: boolean;
|
|
32
|
+
/** Maximum regeneration attempts (default: 5) */
|
|
33
|
+
maxRegenerations?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Run the feedback loop for AI-generated content
|
|
37
|
+
*/
|
|
38
|
+
export declare function runFeedbackLoop(options: FeedbackOptions): Promise<FeedbackResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Simple confirmation prompt
|
|
41
|
+
*/
|
|
42
|
+
export declare function confirmContent(content: string, contentType: string): Promise<boolean>;
|
|
43
|
+
//# sourceMappingURL=ai-feedback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-feedback.d.ts","sourceRoot":"","sources":["../src/ai-feedback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,uDAAuD;AACvD,qBAAa,kBAAmB,SAAQ,KAAK;;CAK5C;AAED,MAAM,WAAW,cAAc;IAC3B,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,sCAAsC;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iCAAiC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC5B,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClD,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iDAAiD;IACjD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAsCD;;GAEG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CA0GvF;AAED;;GAEG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC,CAUlB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Feedback Loop UI
|
|
3
|
+
*
|
|
4
|
+
* Provides a reusable feedback mechanism for AI-generated content.
|
|
5
|
+
* Users can accept, edit, or regenerate with feedback.
|
|
6
|
+
*/
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { createInterface } from 'readline';
|
|
9
|
+
import { isInteractive } from './prompts.js';
|
|
10
|
+
import { openEditor } from './editor.js';
|
|
11
|
+
/** Error thrown when user cancels the feedback loop */
|
|
12
|
+
export class UserCancelledError extends Error {
|
|
13
|
+
constructor() {
|
|
14
|
+
super('User cancelled');
|
|
15
|
+
this.name = 'UserCancelledError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Prompt user for a single line of input
|
|
20
|
+
*/
|
|
21
|
+
function promptLine(question) {
|
|
22
|
+
const rl = createInterface({
|
|
23
|
+
input: process.stdin,
|
|
24
|
+
output: process.stdout,
|
|
25
|
+
});
|
|
26
|
+
return new Promise((resolve) => {
|
|
27
|
+
rl.question(question, (answer) => {
|
|
28
|
+
rl.close();
|
|
29
|
+
resolve(answer.trim());
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Display content preview with line numbers
|
|
35
|
+
*/
|
|
36
|
+
function displayPreview(content, maxLines = 30) {
|
|
37
|
+
const lines = content.split('\n');
|
|
38
|
+
const displayLines = lines.slice(0, maxLines);
|
|
39
|
+
console.log();
|
|
40
|
+
console.log(chalk.dim('─'.repeat(60)));
|
|
41
|
+
for (const line of displayLines) {
|
|
42
|
+
console.log(line);
|
|
43
|
+
}
|
|
44
|
+
if (lines.length > maxLines) {
|
|
45
|
+
console.log(chalk.dim(`... (${lines.length - maxLines} more lines)`));
|
|
46
|
+
}
|
|
47
|
+
console.log(chalk.dim('─'.repeat(60)));
|
|
48
|
+
console.log();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Run the feedback loop for AI-generated content
|
|
52
|
+
*/
|
|
53
|
+
export async function runFeedbackLoop(options) {
|
|
54
|
+
const { contentType, initialContent, regenerate, fileExtension = '.md', showPreview = true, maxRegenerations = 5, } = options;
|
|
55
|
+
let currentContent = initialContent;
|
|
56
|
+
let regenerationCount = 0;
|
|
57
|
+
let wasEdited = false;
|
|
58
|
+
// Non-interactive mode: just return the initial content
|
|
59
|
+
if (!isInteractive()) {
|
|
60
|
+
return {
|
|
61
|
+
content: currentContent,
|
|
62
|
+
wasEdited: false,
|
|
63
|
+
regenerationCount: 0,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
while (true) {
|
|
67
|
+
// Show preview if enabled
|
|
68
|
+
if (showPreview) {
|
|
69
|
+
console.log(chalk.bold(`Generated ${contentType}:`));
|
|
70
|
+
displayPreview(currentContent);
|
|
71
|
+
}
|
|
72
|
+
// Show options
|
|
73
|
+
console.log('Options:');
|
|
74
|
+
console.log(` ${chalk.cyan('a')} - Accept and continue`);
|
|
75
|
+
console.log(` ${chalk.cyan('e')} - Edit in $EDITOR`);
|
|
76
|
+
if (regenerationCount < maxRegenerations) {
|
|
77
|
+
console.log(` ${chalk.cyan('r')} - Regenerate with feedback`);
|
|
78
|
+
}
|
|
79
|
+
console.log(` ${chalk.cyan('q')} - Cancel`);
|
|
80
|
+
console.log();
|
|
81
|
+
const choice = await promptLine('Choice [a/e/r/q]: ');
|
|
82
|
+
switch (choice.toLowerCase()) {
|
|
83
|
+
case 'a':
|
|
84
|
+
case 'accept':
|
|
85
|
+
case '':
|
|
86
|
+
// Accept current content
|
|
87
|
+
return {
|
|
88
|
+
content: currentContent,
|
|
89
|
+
wasEdited,
|
|
90
|
+
regenerationCount,
|
|
91
|
+
};
|
|
92
|
+
case 'e':
|
|
93
|
+
case 'edit':
|
|
94
|
+
// Edit in editor
|
|
95
|
+
try {
|
|
96
|
+
const edited = await openEditor(currentContent, fileExtension);
|
|
97
|
+
if (edited.trim() !== currentContent.trim()) {
|
|
98
|
+
currentContent = edited;
|
|
99
|
+
wasEdited = true;
|
|
100
|
+
console.log(chalk.green('Content updated.'));
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
console.log(chalk.dim('No changes made.'));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
console.error(chalk.red('Error opening editor:'), err);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case 'r':
|
|
111
|
+
case 'regenerate':
|
|
112
|
+
if (regenerationCount >= maxRegenerations) {
|
|
113
|
+
console.log(chalk.yellow(`Maximum regenerations (${maxRegenerations}) reached.`));
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
// Get feedback
|
|
117
|
+
console.log();
|
|
118
|
+
console.log(chalk.dim('What would you like to change? (or press Enter to regenerate without feedback)'));
|
|
119
|
+
const feedback = await promptLine('Feedback: ');
|
|
120
|
+
console.log();
|
|
121
|
+
console.log(chalk.dim('Regenerating...'));
|
|
122
|
+
try {
|
|
123
|
+
currentContent = await regenerate(feedback || 'Please try again with a different approach.');
|
|
124
|
+
regenerationCount++;
|
|
125
|
+
console.log(chalk.green('Regenerated.'));
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
console.error(chalk.red('Error regenerating:'), err);
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
case 'q':
|
|
132
|
+
case 'quit':
|
|
133
|
+
case 'cancel':
|
|
134
|
+
console.log(chalk.yellow('Cancelled.'));
|
|
135
|
+
throw new UserCancelledError();
|
|
136
|
+
default:
|
|
137
|
+
console.log(chalk.yellow('Invalid choice. Please enter a, e, r, or q.'));
|
|
138
|
+
}
|
|
139
|
+
console.log();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Simple confirmation prompt
|
|
144
|
+
*/
|
|
145
|
+
export async function confirmContent(content, contentType) {
|
|
146
|
+
if (!isInteractive()) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
console.log(chalk.bold(`Generated ${contentType}:`));
|
|
150
|
+
displayPreview(content);
|
|
151
|
+
const answer = await promptLine('Accept? [Y/n]: ');
|
|
152
|
+
return answer.toLowerCase() !== 'n';
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=ai-feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-feedback.js","sourceRoot":"","sources":["../src/ai-feedback.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,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;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,OAAe,EACf,WAAmB;IAEnB,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,WAAW,GAAG,CAAC,CAAC,CAAC;IACrD,cAAc,CAAC,OAAO,CAAC,CAAC;IAExB,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC;AACxC,CAAC"}
|
package/dist/branch-linker.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This allows links to be shared between CLI and VSCode extension.
|
|
8
8
|
*/
|
|
9
|
-
import { type RepoInfo } from '@bretwardjames/ghp-core';
|
|
9
|
+
import { extractIssueNumberFromBranch, type RepoInfo } from '@bretwardjames/ghp-core';
|
|
10
10
|
/**
|
|
11
11
|
* Link a branch to an issue by storing the link in the issue body.
|
|
12
12
|
*/
|
|
@@ -20,15 +20,7 @@ export declare function unlinkBranch(repo: RepoInfo, issueNumber: number): Promi
|
|
|
20
20
|
* Get the branch linked to an issue by reading the issue body.
|
|
21
21
|
*/
|
|
22
22
|
export declare function getBranchForIssue(repo: RepoInfo, issueNumber: number): Promise<string | null>;
|
|
23
|
-
|
|
24
|
-
* Extract issue number from a branch name.
|
|
25
|
-
* Supports common patterns:
|
|
26
|
-
* - user/123-feature-name
|
|
27
|
-
* - feature/123-something
|
|
28
|
-
* - 123-fix-bug
|
|
29
|
-
* - fix-123-something
|
|
30
|
-
*/
|
|
31
|
-
export declare function extractIssueNumberFromBranch(branchName: string): number | null;
|
|
23
|
+
export { extractIssueNumberFromBranch };
|
|
32
24
|
/**
|
|
33
25
|
* Result of finding an issue for a branch.
|
|
34
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-linker.d.ts","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIH,KAAK,QAAQ,EAChB,MAAM,yBAAyB,CAAC;AAGjC;;GAEG;AACH,wBAAsB,UAAU,CAC5B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACnC,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;
|
|
1
|
+
{"version":3,"file":"branch-linker.d.ts","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIH,4BAA4B,EAC5B,KAAK,QAAQ,EAChB,MAAM,yBAAyB,CAAC;AAGjC;;GAEG;AACH,wBAAsB,UAAU,CAC5B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAC9B,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACnC,IAAI,EAAE,QAAQ,EACd,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAGD,OAAO,EAAE,4BAA4B,EAAE,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACnC,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CA4BjC"}
|
package/dist/branch-linker.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This allows links to be shared between CLI and VSCode extension.
|
|
8
8
|
*/
|
|
9
|
-
import { parseBranchLink, setBranchLinkInBody, removeBranchLinkFromBody, } from '@bretwardjames/ghp-core';
|
|
9
|
+
import { parseBranchLink, setBranchLinkInBody, removeBranchLinkFromBody, extractIssueNumberFromBranch, } from '@bretwardjames/ghp-core';
|
|
10
10
|
import { api } from './github-api.js';
|
|
11
11
|
/**
|
|
12
12
|
* Link a branch to an issue by storing the link in the issue body.
|
|
@@ -56,29 +56,8 @@ export async function getBranchForIssue(repo, issueNumber) {
|
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
* Supports common patterns:
|
|
62
|
-
* - user/123-feature-name
|
|
63
|
-
* - feature/123-something
|
|
64
|
-
* - 123-fix-bug
|
|
65
|
-
* - fix-123-something
|
|
66
|
-
*/
|
|
67
|
-
export function extractIssueNumberFromBranch(branchName) {
|
|
68
|
-
const patterns = [
|
|
69
|
-
/\/(\d+)-/, // user/123-title
|
|
70
|
-
/^(\d+)-/, // 123-title
|
|
71
|
-
/-(\d+)-/, // feature-123-title
|
|
72
|
-
/[/#](\d+)$/, // ends with #123 or /123
|
|
73
|
-
];
|
|
74
|
-
for (const pattern of patterns) {
|
|
75
|
-
const match = branchName.match(pattern);
|
|
76
|
-
if (match) {
|
|
77
|
-
return parseInt(match[1], 10);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
59
|
+
// Re-export from core for backwards compatibility
|
|
60
|
+
export { extractIssueNumberFromBranch };
|
|
82
61
|
/**
|
|
83
62
|
* Find the issue linked to a branch.
|
|
84
63
|
* This first extracts the issue number from the branch name pattern,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"branch-linker.js","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACH,eAAe,EACf,mBAAmB,EACnB,wBAAwB,
|
|
1
|
+
{"version":3,"file":"branch-linker.js","sourceRoot":"","sources":["../src/branch-linker.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACH,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,GAE/B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC5B,IAAc,EACd,WAAmB,EACnB,MAAc;IAEd,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC7D,MAAM,WAAW,GAAG,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;QACxC,MAAM,OAAO,GAAG,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACzD,OAAO,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,IAAc,EACd,WAAmB;IAEnB,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,EAA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