@bretwardjames/ghp-core 0.4.0 → 0.6.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/README.md +47 -3
- package/dist/index.cjs +1230 -186
- package/dist/index.d.cts +795 -31
- package/dist/index.d.ts +795 -31
- package/dist/index.js +1209 -185
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -32,6 +32,38 @@ const linker = new BranchLinker(api);
|
|
|
32
32
|
await linker.linkBranch(issueNumber, branchName);
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
### Workflows
|
|
36
|
+
|
|
37
|
+
High-level workflow functions that combine operations with automatic hook firing. These are used by CLI, MCP, and VS Code extension to ensure consistent behavior.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import {
|
|
41
|
+
createIssueWorkflow,
|
|
42
|
+
startIssueWorkflow,
|
|
43
|
+
createPRWorkflow,
|
|
44
|
+
createWorktreeWorkflow,
|
|
45
|
+
removeWorktreeWorkflow,
|
|
46
|
+
} from '@bretwardjames/ghp-core';
|
|
47
|
+
|
|
48
|
+
// Start working on an issue (creates branch, fires hooks)
|
|
49
|
+
const result = await startIssueWorkflow(api, {
|
|
50
|
+
repo: { owner: 'user', name: 'repo', fullName: 'user/repo' },
|
|
51
|
+
issueNumber: 123,
|
|
52
|
+
issueTitle: 'Add new feature',
|
|
53
|
+
branchPattern: '{user}/{number}-{title}',
|
|
54
|
+
username: 'developer',
|
|
55
|
+
parallel: true,
|
|
56
|
+
worktreePath: '/path/to/worktree',
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
if (result.success) {
|
|
60
|
+
console.log(`Working on branch ${result.branch}`);
|
|
61
|
+
if (result.worktree) {
|
|
62
|
+
console.log(`Worktree at ${result.worktree.path}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
35
67
|
### Event Hooks
|
|
36
68
|
|
|
37
69
|
Register and execute lifecycle event hooks:
|
|
@@ -53,13 +85,25 @@ addEventHook({
|
|
|
53
85
|
// Execute hooks for an event
|
|
54
86
|
const payload: IssueStartedPayload = {
|
|
55
87
|
repo: 'owner/repo',
|
|
56
|
-
issue: { number: 123, title: 'Fix bug', body: '', url: '...' },
|
|
88
|
+
issue: { number: 123, title: 'Fix bug', body: 'Issue description here...', url: '...' },
|
|
57
89
|
branch: 'feature/123-fix-bug',
|
|
58
90
|
};
|
|
59
|
-
|
|
91
|
+
|
|
92
|
+
// Hooks can execute in a specific directory (e.g., inside a worktree)
|
|
93
|
+
const results = await executeHooksForEvent('issue-started', payload, {
|
|
94
|
+
cwd: '/path/to/worktree',
|
|
95
|
+
});
|
|
60
96
|
```
|
|
61
97
|
|
|
62
|
-
Available events:
|
|
98
|
+
Available events:
|
|
99
|
+
- `issue-created` - Fired when a new issue is created
|
|
100
|
+
- `issue-started` - Fired when starting work on an issue
|
|
101
|
+
- `pre-pr` - Fired before PR creation begins (for validation/linting)
|
|
102
|
+
- `pr-creating` - Fired just before GitHub API call (for suggesting title/body)
|
|
103
|
+
- `pr-created` - Fired when a pull request is created
|
|
104
|
+
- `pr-merged` - Fired when a pull request is merged
|
|
105
|
+
- `worktree-created` - Fired when a worktree is created
|
|
106
|
+
- `worktree-removed` - Fired when a worktree is removed
|
|
63
107
|
|
|
64
108
|
## License
|
|
65
109
|
|