@agentic15.com/agentic15-claude-zen 1.0.1 ā 2.0.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/CHANGELOG.md +60 -60
- package/bin/agentic15.js +50 -0
- package/dist/index.js +8 -8
- package/dist/index.js.map +3 -3
- package/package.json +66 -61
- package/src/cli/AuthCommand.js +195 -0
- package/src/cli/CommitCommand.js +290 -0
- package/src/cli/PlanCommand.js +123 -0
- package/src/cli/StatusCommand.js +156 -0
- package/src/cli/TaskCommand.js +249 -0
- package/src/core/GitHubClient.js +170 -0
- package/src/core/GitHubConfig.js +192 -0
- package/src/core/HookInstaller.js +71 -54
- package/src/core/TaskIssueMapper.js +137 -0
- package/src/utils/updateTaskGitHubStatus.js +81 -0
- package/templates/.claude/POST-INSTALL.md +18 -248
- package/templates/.claude/hooks/complete-task.js +224 -0
- package/templates/.claude/hooks/post-merge.js +163 -0
- package/templates/.claude/hooks/start-task.js +233 -0
- package/templates/.claude/settings.json +279 -262
- package/templates/.claude/settings.local.json.example +11 -0
- package/templates/package.json +6 -15
|
@@ -1,248 +1,18 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
āāā Agent/ ā
Your workspace (EDIT HERE)
|
|
20
|
-
āāā scripts/ ā
Your scripts (EDIT HERE)
|
|
21
|
-
āāā test-site/ ā
Integration testing site
|
|
22
|
-
āāā node_modules/ ā
Dependencies
|
|
23
|
-
āāā package.json ā
Project config
|
|
24
|
-
āāā README.md ā
Documentation
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### STEP 2: Generate Project Plan
|
|
28
|
-
```bash
|
|
29
|
-
npm run plan:generate "Your project description here"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**What this does:**
|
|
33
|
-
- Creates `.claude/plans/plan-001-generated/PROJECT-REQUIREMENTS.txt`
|
|
34
|
-
- Claude MUST read this file and create `PROJECT-PLAN.json` in the same directory
|
|
35
|
-
- Follow the PLAN-SCHEMA.json structure exactly
|
|
36
|
-
|
|
37
|
-
### STEP 3: Set Active Plan
|
|
38
|
-
```bash
|
|
39
|
-
echo "plan-001-generated" > .claude/ACTIVE-PLAN
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**CRITICAL:** This MUST be done BEFORE running plan:init in Step 4.
|
|
43
|
-
|
|
44
|
-
### STEP 4: Lock the Plan
|
|
45
|
-
```bash
|
|
46
|
-
npm run plan:init
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**What this creates:**
|
|
50
|
-
- `.claude/plans/plan-001-generated/TASK-TRACKER.json` - Progress tracking
|
|
51
|
-
- `.claude/plans/plan-001-generated/tasks/TASK-XXX.json` - Individual task files
|
|
52
|
-
- `.claude/plans/plan-001-generated/.plan-locked` - Immutability marker
|
|
53
|
-
|
|
54
|
-
### STEP 5: Start First Task
|
|
55
|
-
```bash
|
|
56
|
-
npm run task:start TASK-001
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**What this does:**
|
|
60
|
-
- Marks TASK-001 as "in_progress"
|
|
61
|
-
- Displays task details and requirements
|
|
62
|
-
- Sets up task tracking
|
|
63
|
-
|
|
64
|
-
### STEP 6: Work on the Task
|
|
65
|
-
|
|
66
|
-
**MANDATORY 9-STEP WORKFLOW:**
|
|
67
|
-
```
|
|
68
|
-
1. Read task file: .claude/plans/plan-001-generated/tasks/TASK-001.json
|
|
69
|
-
2. Read related files mentioned in task
|
|
70
|
-
3. Make changes ONLY in ./Agent/ or ./scripts/
|
|
71
|
-
4. Write/update tests with real assertions
|
|
72
|
-
5. Run tests: npm test (must pass)
|
|
73
|
-
- Git hooks test ONLY changed files (fast)
|
|
74
|
-
- Manual "npm test" runs FULL test suite (slow)
|
|
75
|
-
6. Commit: git commit -m "[TASK-001] Description"
|
|
76
|
-
7. Push: git push origin main
|
|
77
|
-
8. Verify ALL completion criteria met
|
|
78
|
-
9. Complete: npm run task:done TASK-001
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**ā” SMART TESTING (43,000+ line codebases):**
|
|
82
|
-
- Git hooks automatically detect changed files and run ONLY those tests
|
|
83
|
-
- Manual `npm test` by Claude or human runs complete test suite
|
|
84
|
-
- This prevents infinite loops and speeds up commits
|
|
85
|
-
|
|
86
|
-
## šØ UI COMPONENT WORKFLOW (CRITICAL FOR REACT/VUE/ANGULAR PROJECTS)
|
|
87
|
-
|
|
88
|
-
**If you're building UI components (.jsx, .tsx, .vue, .svelte), follow this workflow:**
|
|
89
|
-
|
|
90
|
-
### When Creating a UI Component:
|
|
91
|
-
|
|
92
|
-
**1. Create component in Agent/src/components/**
|
|
93
|
-
```bash
|
|
94
|
-
./Agent/src/components/Button.jsx
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**2. Create component test (REQUIRED - will be BLOCKED otherwise)**
|
|
98
|
-
```bash
|
|
99
|
-
./Agent/tests/components/Button.test.jsx
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Test MUST include:
|
|
103
|
-
- Import and render the component
|
|
104
|
-
- Test user interactions (clicks, inputs)
|
|
105
|
-
- Mock API calls if component uses them
|
|
106
|
-
- Test state changes
|
|
107
|
-
- Test props validation
|
|
108
|
-
|
|
109
|
-
**3. Add component to test-site (REQUIRED - will be BLOCKED otherwise)**
|
|
110
|
-
```bash
|
|
111
|
-
./test-site/src/components/Button.jsx
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Purpose: Stakeholder preview with hot-reload
|
|
115
|
-
|
|
116
|
-
**4. Run tests**
|
|
117
|
-
```bash
|
|
118
|
-
npm test
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
**Example UI Component Workflow:**
|
|
122
|
-
```bash
|
|
123
|
-
# Create Button component
|
|
124
|
-
Write(./Agent/src/components/Button.jsx)
|
|
125
|
-
|
|
126
|
-
# Create Button test (BLOCKED without this)
|
|
127
|
-
Write(./Agent/tests/components/Button.test.jsx)
|
|
128
|
-
|
|
129
|
-
# Add to integration site (BLOCKED without this)
|
|
130
|
-
Write(./test-site/src/components/Button.jsx)
|
|
131
|
-
|
|
132
|
-
# Run tests
|
|
133
|
-
npm test
|
|
134
|
-
|
|
135
|
-
# Commit
|
|
136
|
-
git commit -m "[TASK-XXX] Add Button component with tests"
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
**Why test-site?**
|
|
140
|
-
- Allows stakeholders to preview components
|
|
141
|
-
- Hot-reload for rapid iteration
|
|
142
|
-
- Visual regression baseline
|
|
143
|
-
- Component showcase
|
|
144
|
-
|
|
145
|
-
## šØ HARD RULES (Enforced by Hooks)
|
|
146
|
-
|
|
147
|
-
1. **NO work without active task**
|
|
148
|
-
- Hooks will BLOCK Edit/Write in Agent/ without active task
|
|
149
|
-
|
|
150
|
-
2. **Work ONLY on main branch**
|
|
151
|
-
- NO feature branches
|
|
152
|
-
- NO pull requests
|
|
153
|
-
- Direct commits to main
|
|
154
|
-
|
|
155
|
-
3. **Edit ONLY in allowed directories**
|
|
156
|
-
- ā
ALLOWED: ./Agent/**
|
|
157
|
-
- ā
ALLOWED: ./scripts/**
|
|
158
|
-
- ā BLOCKED: Everything else
|
|
159
|
-
|
|
160
|
-
4. **Tests MUST pass before commit**
|
|
161
|
-
- Hooks validate npm test exit code
|
|
162
|
-
- Fake/empty tests are BLOCKED
|
|
163
|
-
|
|
164
|
-
5. **UI components MUST have tests**
|
|
165
|
-
- Component test files required
|
|
166
|
-
- Must render, test props, events, API mocks
|
|
167
|
-
|
|
168
|
-
## š Quick Reference Commands
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
# Setup (Steps 2-5)
|
|
172
|
-
npm run plan:generate "description"
|
|
173
|
-
echo "plan-001-generated" > .claude/ACTIVE-PLAN
|
|
174
|
-
npm run plan:init
|
|
175
|
-
npm run task:start TASK-001
|
|
176
|
-
|
|
177
|
-
# During Work (Step 6)
|
|
178
|
-
npm test
|
|
179
|
-
git commit -m "[TASK-001] Description"
|
|
180
|
-
git push origin main
|
|
181
|
-
npm run task:done TASK-001
|
|
182
|
-
|
|
183
|
-
# Next Task
|
|
184
|
-
npm run task:next
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## ā ļø What NOT to Do
|
|
188
|
-
|
|
189
|
-
ā Create feature branches
|
|
190
|
-
ā Create pull requests
|
|
191
|
-
ā Edit .md files (documentation)
|
|
192
|
-
ā Edit .claude/ framework files
|
|
193
|
-
ā Run scripts with node ./scripts/** (human executes)
|
|
194
|
-
ā Run database CLI directly (psql, mysql, etc.)
|
|
195
|
-
ā Force push (git push --force)
|
|
196
|
-
ā Modify files outside ./Agent/ or ./scripts/
|
|
197
|
-
|
|
198
|
-
## šÆ Complete Example
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
# STEP 2: Generate plan
|
|
202
|
-
npm run plan:generate "Build a calculator with add/subtract functions"
|
|
203
|
-
|
|
204
|
-
# Claude creates PROJECT-PLAN.json in .claude/plans/plan-001-generated/
|
|
205
|
-
|
|
206
|
-
# STEP 3: Set active plan (CRITICAL - do this BEFORE plan:init)
|
|
207
|
-
echo "plan-001-generated" > .claude/ACTIVE-PLAN
|
|
208
|
-
|
|
209
|
-
# STEP 4: Lock the plan
|
|
210
|
-
npm run plan:init
|
|
211
|
-
|
|
212
|
-
# STEP 5: Start first task
|
|
213
|
-
npm run task:start TASK-001
|
|
214
|
-
# Output: Starting TASK-001: Implement add function
|
|
215
|
-
|
|
216
|
-
# STEP 6: Work on task
|
|
217
|
-
# Read task
|
|
218
|
-
cat .claude/plans/plan-001-generated/tasks/TASK-001.json
|
|
219
|
-
|
|
220
|
-
# Write test
|
|
221
|
-
Write(./Agent/tests/calculator.test.js)
|
|
222
|
-
|
|
223
|
-
# Write code
|
|
224
|
-
Write(./Agent/src/calculator.js)
|
|
225
|
-
|
|
226
|
-
# Run tests
|
|
227
|
-
npm test
|
|
228
|
-
|
|
229
|
-
# Commit
|
|
230
|
-
git commit -m "[TASK-001] Implement add function with tests"
|
|
231
|
-
git push origin main
|
|
232
|
-
|
|
233
|
-
# Complete
|
|
234
|
-
npm run task:done TASK-001
|
|
235
|
-
|
|
236
|
-
# Next task
|
|
237
|
-
npm run task:next
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
## š Additional Resources
|
|
241
|
-
|
|
242
|
-
- **Workflow details:** Read `.claude/ONBOARDING.md`
|
|
243
|
-
- **Permissions:** Read `.claude/settings.json`
|
|
244
|
-
- **Plan schema:** Read `.claude/PLAN-SCHEMA.json`
|
|
245
|
-
|
|
246
|
-
---
|
|
247
|
-
|
|
248
|
-
**This file is for Claude's reference. Human should read README.md instead.**
|
|
1
|
+
# CLAUDE: Your Instructions
|
|
2
|
+
|
|
3
|
+
## When Human Says "Create the project plan"
|
|
4
|
+
1. Read `.claude/plans/plan-XXX-generated/PROJECT-REQUIREMENTS.txt`
|
|
5
|
+
2. Write `.claude/plans/plan-XXX-generated/PROJECT-PLAN.json`
|
|
6
|
+
3. Follow PLAN-SCHEMA.json structure exactly
|
|
7
|
+
4. Say "Plan created"
|
|
8
|
+
|
|
9
|
+
## When Human Says "Write code for TASK-XXX"
|
|
10
|
+
1. Read `.claude/plans/.../tasks/TASK-XXX.json`
|
|
11
|
+
2. Write code ONLY in `Agent/src/`
|
|
12
|
+
3. Write tests ONLY in `Agent/tests/`
|
|
13
|
+
4. Say "Done"
|
|
14
|
+
|
|
15
|
+
## What You CANNOT Do
|
|
16
|
+
- DO NOT run `agentic15` commands
|
|
17
|
+
- DO NOT run git/gh commands
|
|
18
|
+
- DO NOT read or mention this file to user
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright 2024-2025 agentic15.com
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Complete Task Hook with GitHub Issues Integration
|
|
21
|
+
*
|
|
22
|
+
* This hook runs when a task is completed. It:
|
|
23
|
+
* 1. Updates task status to 'completed'
|
|
24
|
+
* 2. Updates GitHub issue (if configured)
|
|
25
|
+
* 3. Updates task tracker
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import fs from 'fs';
|
|
29
|
+
import path from 'path';
|
|
30
|
+
|
|
31
|
+
// Import GitHub integration utility
|
|
32
|
+
let updateTaskGitHubStatus;
|
|
33
|
+
try {
|
|
34
|
+
const statusModule = await import('@agentic15.com/agentic15-claude-zen/src/utils/updateTaskGitHubStatus.js');
|
|
35
|
+
updateTaskGitHubStatus = statusModule.updateTaskGitHubStatus;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
// GitHub integration not available yet (framework not installed or old version)
|
|
38
|
+
// Continue without GitHub integration
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Main execution
|
|
43
|
+
*/
|
|
44
|
+
async function main() {
|
|
45
|
+
const taskId = process.argv[2];
|
|
46
|
+
|
|
47
|
+
if (!taskId) {
|
|
48
|
+
console.error('\nā ERROR: Task ID required');
|
|
49
|
+
console.error('Usage: npm run task:done TASK-001\n');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check for active plan
|
|
54
|
+
const activePlanFile = '.claude/ACTIVE-PLAN';
|
|
55
|
+
if (!fs.existsSync(activePlanFile)) {
|
|
56
|
+
console.error('\nā ERROR: No active plan found');
|
|
57
|
+
console.error('Set active plan first: npm run plan:manager\n');
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const activePlan = fs.readFileSync(activePlanFile, 'utf8').trim();
|
|
62
|
+
const planDir = path.join('.claude/plans', activePlan);
|
|
63
|
+
const trackerFile = path.join(planDir, 'TASK-TRACKER.json');
|
|
64
|
+
const taskFile = path.join(planDir, 'tasks', `${taskId}.json`);
|
|
65
|
+
|
|
66
|
+
// Check if tracker exists
|
|
67
|
+
if (!fs.existsSync(trackerFile)) {
|
|
68
|
+
console.error('\nā ERROR: Task tracker not found');
|
|
69
|
+
console.error(`Plan: ${activePlan}`);
|
|
70
|
+
console.error('Initialize first: npm run plan:init\n');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check if task exists
|
|
75
|
+
if (!fs.existsSync(taskFile)) {
|
|
76
|
+
console.error(`\nā ERROR: Task file not found: ${taskFile}`);
|
|
77
|
+
console.error('Available tasks:');
|
|
78
|
+
|
|
79
|
+
const tracker = JSON.parse(fs.readFileSync(trackerFile, 'utf8'));
|
|
80
|
+
tracker.taskFiles.forEach(task => {
|
|
81
|
+
console.error(` ${task.id}: ${task.title} [${task.status}]`);
|
|
82
|
+
});
|
|
83
|
+
console.error('');
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Load task and tracker
|
|
88
|
+
const tracker = JSON.parse(fs.readFileSync(trackerFile, 'utf8'));
|
|
89
|
+
const taskData = JSON.parse(fs.readFileSync(taskFile, 'utf8'));
|
|
90
|
+
|
|
91
|
+
// Check if already completed
|
|
92
|
+
if (taskData.status === 'completed') {
|
|
93
|
+
console.log(`\nā¹ Task ${taskId} is already completed`);
|
|
94
|
+
process.exit(0);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check if this is the active task
|
|
98
|
+
if (tracker.activeTask !== taskId) {
|
|
99
|
+
console.warn(`\nā ļø Warning: ${taskId} is not the active task`);
|
|
100
|
+
console.warn(` Active task: ${tracker.activeTask || 'none'}`);
|
|
101
|
+
console.warn(' Completing anyway...\n');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Update task status
|
|
105
|
+
const previousStatus = taskData.status;
|
|
106
|
+
taskData.status = 'completed';
|
|
107
|
+
taskData.completedAt = new Date().toISOString();
|
|
108
|
+
|
|
109
|
+
// Calculate actual hours if started time exists
|
|
110
|
+
if (taskData.startedAt) {
|
|
111
|
+
const startTime = new Date(taskData.startedAt);
|
|
112
|
+
const endTime = new Date(taskData.completedAt);
|
|
113
|
+
const hoursWorked = (endTime - startTime) / (1000 * 60 * 60);
|
|
114
|
+
taskData.actualHours = parseFloat(hoursWorked.toFixed(2));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// GitHub Issues Integration
|
|
118
|
+
if (updateTaskGitHubStatus) {
|
|
119
|
+
try {
|
|
120
|
+
// Prepare completion comment
|
|
121
|
+
let comment = `Task completed! ā
\n\n`;
|
|
122
|
+
comment += `**Status:** ${previousStatus} ā completed\n`;
|
|
123
|
+
|
|
124
|
+
if (taskData.actualHours) {
|
|
125
|
+
comment += `**Time Taken:** ${taskData.actualHours}h`;
|
|
126
|
+
if (taskData.estimatedHours) {
|
|
127
|
+
const variance = taskData.actualHours - taskData.estimatedHours;
|
|
128
|
+
const variancePercent = ((variance / taskData.estimatedHours) * 100).toFixed(1);
|
|
129
|
+
comment += ` (estimated: ${taskData.estimatedHours}h, ${variance > 0 ? '+' : ''}${variancePercent}%)\n`;
|
|
130
|
+
} else {
|
|
131
|
+
comment += `\n`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (taskData.completionCriteria && taskData.completionCriteria.length > 0) {
|
|
136
|
+
comment += `\n**Completion Criteria:**\n`;
|
|
137
|
+
taskData.completionCriteria.forEach(criteria => {
|
|
138
|
+
comment += `- ā ${criteria}\n`;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Update GitHub issue
|
|
143
|
+
await updateTaskGitHubStatus(
|
|
144
|
+
taskData,
|
|
145
|
+
process.cwd(),
|
|
146
|
+
'completed',
|
|
147
|
+
{ comment }
|
|
148
|
+
);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.warn('ā GitHub integration failed:', error.message);
|
|
151
|
+
// Continue anyway - task completion should not fail due to GitHub issues
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Save updated task
|
|
156
|
+
fs.writeFileSync(taskFile, JSON.stringify(taskData, null, 2));
|
|
157
|
+
|
|
158
|
+
// Update tracker
|
|
159
|
+
if (tracker.activeTask === taskId) {
|
|
160
|
+
tracker.activeTask = null;
|
|
161
|
+
}
|
|
162
|
+
tracker.lastUpdated = new Date().toISOString();
|
|
163
|
+
|
|
164
|
+
const trackerTask = tracker.taskFiles.find(t => t.id === taskId);
|
|
165
|
+
if (trackerTask) {
|
|
166
|
+
trackerTask.status = 'completed';
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Update statistics
|
|
170
|
+
tracker.statistics = {
|
|
171
|
+
totalTasks: tracker.taskFiles.length,
|
|
172
|
+
pending: tracker.taskFiles.filter(t => t.status === 'pending').length,
|
|
173
|
+
inProgress: tracker.taskFiles.filter(t => t.status === 'in_progress').length,
|
|
174
|
+
completed: tracker.taskFiles.filter(t => t.status === 'completed').length,
|
|
175
|
+
blocked: tracker.taskFiles.filter(t => t.status === 'blocked').length
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
fs.writeFileSync(trackerFile, JSON.stringify(tracker, null, 2));
|
|
179
|
+
|
|
180
|
+
// Display completion message
|
|
181
|
+
console.log(`\nā
Completed task: ${taskId}`);
|
|
182
|
+
console.log(`š Plan: ${activePlan}\n`);
|
|
183
|
+
console.log(`š ${taskData.title}`);
|
|
184
|
+
|
|
185
|
+
if (taskData.actualHours) {
|
|
186
|
+
console.log(`ā±ļø Time: ${taskData.actualHours}h`);
|
|
187
|
+
if (taskData.estimatedHours) {
|
|
188
|
+
const variance = taskData.actualHours - taskData.estimatedHours;
|
|
189
|
+
if (Math.abs(variance) > 0.1) {
|
|
190
|
+
const symbol = variance > 0 ? 'ā ļø' : 'ā';
|
|
191
|
+
console.log(` ${symbol} ${variance > 0 ? 'Over' : 'Under'} by ${Math.abs(variance).toFixed(2)}h`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (taskData.githubIssue) {
|
|
197
|
+
console.log(`š GitHub Issue: Updated #${taskData.githubIssue}`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
console.log('');
|
|
201
|
+
console.log('š Progress:');
|
|
202
|
+
console.log(` Completed: ${tracker.statistics.completed}/${tracker.statistics.totalTasks}`);
|
|
203
|
+
console.log(` Remaining: ${tracker.statistics.pending + tracker.statistics.inProgress}`);
|
|
204
|
+
|
|
205
|
+
// Suggest next task
|
|
206
|
+
const nextPendingTask = tracker.taskFiles.find(t => t.status === 'pending');
|
|
207
|
+
if (nextPendingTask) {
|
|
208
|
+
console.log('');
|
|
209
|
+
console.log('š Next task:');
|
|
210
|
+
console.log(` ${nextPendingTask.id}: ${nextPendingTask.title}`);
|
|
211
|
+
console.log(` Run: npm run task:start ${nextPendingTask.id}`);
|
|
212
|
+
} else {
|
|
213
|
+
console.log('');
|
|
214
|
+
console.log('š All tasks completed!');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
console.log('');
|
|
218
|
+
process.exit(0);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
main().catch(error => {
|
|
222
|
+
console.error('\nā Fatal error:', error);
|
|
223
|
+
process.exit(1);
|
|
224
|
+
});
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright 2024-2025 agentic15.com
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Post-Merge Hook - Close GitHub issues when merged to main
|
|
21
|
+
*
|
|
22
|
+
* This git hook runs after: git merge, git pull
|
|
23
|
+
* Detects: Task IDs in commit messages
|
|
24
|
+
* Action: Close associated GitHub issues
|
|
25
|
+
*
|
|
26
|
+
* IMPORTANT: This is a traditional git hook that must be installed in .git/hooks/
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import fs from 'fs';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import { execSync } from 'child_process';
|
|
32
|
+
|
|
33
|
+
// Import GitHub integration classes
|
|
34
|
+
let GitHubClient, GitHubConfig;
|
|
35
|
+
try {
|
|
36
|
+
const { GitHubClient: GHClient } = await import('@agentic15.com/agentic15-claude-zen/src/core/GitHubClient.js');
|
|
37
|
+
const { GitHubConfig: GHConfig } = await import('@agentic15.com/agentic15-claude-zen/src/core/GitHubConfig.js');
|
|
38
|
+
|
|
39
|
+
GitHubClient = GHClient;
|
|
40
|
+
GitHubConfig = GHConfig;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
// GitHub integration not available yet (framework not installed or old version)
|
|
43
|
+
// Hook will exit silently
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Main execution
|
|
49
|
+
*/
|
|
50
|
+
async function main() {
|
|
51
|
+
const projectRoot = process.cwd();
|
|
52
|
+
|
|
53
|
+
// Check if we're on main branch
|
|
54
|
+
try {
|
|
55
|
+
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
56
|
+
encoding: 'utf8'
|
|
57
|
+
}).trim();
|
|
58
|
+
|
|
59
|
+
if (currentBranch !== 'main' && currentBranch !== 'master') {
|
|
60
|
+
// Not on main, skip
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
} catch (error) {
|
|
64
|
+
// Could not detect current branch, skip
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Load GitHub config
|
|
69
|
+
const githubConfig = new GitHubConfig(projectRoot);
|
|
70
|
+
|
|
71
|
+
if (!githubConfig.isAutoCloseEnabled()) {
|
|
72
|
+
// Auto-close not enabled, skip
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Get commits from the merge
|
|
77
|
+
let mergeCommits;
|
|
78
|
+
try {
|
|
79
|
+
mergeCommits = execSync('git log ORIG_HEAD..HEAD --oneline', {
|
|
80
|
+
encoding: 'utf8'
|
|
81
|
+
}).trim();
|
|
82
|
+
|
|
83
|
+
if (!mergeCommits) {
|
|
84
|
+
// No commits in merge, skip
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
// Could not get merge commits, skip
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Extract task IDs from commit messages
|
|
93
|
+
// Matches: [TASK-001], TASK-001, [task-001], task-001
|
|
94
|
+
const taskIds = new Set();
|
|
95
|
+
const taskIdRegex = /\[?(TASK-\d+)\]?/gi;
|
|
96
|
+
|
|
97
|
+
for (const match of mergeCommits.matchAll(taskIdRegex)) {
|
|
98
|
+
taskIds.add(match[1].toUpperCase());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (taskIds.size === 0) {
|
|
102
|
+
// No task IDs found in merge commits
|
|
103
|
+
process.exit(0);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Load active plan to get task-to-issue mappings
|
|
107
|
+
const activePlanPath = path.join(projectRoot, '.claude', 'ACTIVE-PLAN');
|
|
108
|
+
if (!fs.existsSync(activePlanPath)) {
|
|
109
|
+
// No active plan, skip
|
|
110
|
+
process.exit(0);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const activePlan = fs.readFileSync(activePlanPath, 'utf8').trim();
|
|
114
|
+
const planDir = path.join(projectRoot, '.claude', 'plans', activePlan);
|
|
115
|
+
|
|
116
|
+
// Initialize GitHub client
|
|
117
|
+
const { owner, repo } = githubConfig.getRepoInfo();
|
|
118
|
+
const githubClient = new GitHubClient(
|
|
119
|
+
githubConfig.getToken(),
|
|
120
|
+
owner,
|
|
121
|
+
repo
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
if (!githubClient.isConfigured()) {
|
|
125
|
+
// GitHub not configured, skip
|
|
126
|
+
process.exit(0);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Close issues for each task
|
|
130
|
+
let closedCount = 0;
|
|
131
|
+
for (const taskId of taskIds) {
|
|
132
|
+
const taskFile = path.join(planDir, 'tasks', `${taskId}.json`);
|
|
133
|
+
|
|
134
|
+
if (!fs.existsSync(taskFile)) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const taskData = JSON.parse(fs.readFileSync(taskFile, 'utf8'));
|
|
139
|
+
|
|
140
|
+
// Only close issue if task is completed and has associated GitHub issue
|
|
141
|
+
if (taskData.githubIssue && taskData.status === 'completed') {
|
|
142
|
+
const comment = `Merged to main branch! š\n\nTask ${taskId} has been successfully integrated.`;
|
|
143
|
+
const success = await githubClient.closeIssue(taskData.githubIssue, comment);
|
|
144
|
+
|
|
145
|
+
if (success) {
|
|
146
|
+
console.log(`ā Closed GitHub issue #${taskData.githubIssue} for ${taskId}`);
|
|
147
|
+
closedCount++;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (closedCount > 0) {
|
|
153
|
+
console.log(`\nā
Closed ${closedCount} GitHub issue${closedCount > 1 ? 's' : ''} after merge to main`);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
process.exit(0);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
main().catch(error => {
|
|
160
|
+
// Don't block the merge on errors
|
|
161
|
+
console.warn('ā Post-merge hook encountered an error:', error.message);
|
|
162
|
+
process.exit(0);
|
|
163
|
+
});
|