@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
|
@@ -0,0 +1,233 @@
|
|
|
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
|
+
* Start Task Hook with GitHub Issues Integration
|
|
21
|
+
*
|
|
22
|
+
* This hook runs when a task is started. It:
|
|
23
|
+
* 1. Updates task status to 'in_progress'
|
|
24
|
+
* 2. Creates a 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 classes
|
|
32
|
+
// These classes are bundled with the framework
|
|
33
|
+
let GitHubClient, GitHubConfig, TaskIssueMapper;
|
|
34
|
+
try {
|
|
35
|
+
// Try to import from node_modules (after framework is installed)
|
|
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
|
+
const { TaskIssueMapper: GHMapper } = await import('@agentic15.com/agentic15-claude-zen/src/core/TaskIssueMapper.js');
|
|
39
|
+
|
|
40
|
+
GitHubClient = GHClient;
|
|
41
|
+
GitHubConfig = GHConfig;
|
|
42
|
+
TaskIssueMapper = GHMapper;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// GitHub integration not available yet (framework not installed or old version)
|
|
45
|
+
// Continue without GitHub integration
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Main execution
|
|
50
|
+
*/
|
|
51
|
+
async function main() {
|
|
52
|
+
const taskId = process.argv[2];
|
|
53
|
+
|
|
54
|
+
if (!taskId) {
|
|
55
|
+
console.error('\n❌ ERROR: Task ID required');
|
|
56
|
+
console.error('Usage: npm run task:start TASK-001\n');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Check for active plan
|
|
61
|
+
const activePlanFile = '.claude/ACTIVE-PLAN';
|
|
62
|
+
if (!fs.existsSync(activePlanFile)) {
|
|
63
|
+
console.error('\n❌ ERROR: No active plan found');
|
|
64
|
+
console.error('Set active plan first: npm run plan:manager\n');
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const activePlan = fs.readFileSync(activePlanFile, 'utf8').trim();
|
|
69
|
+
const planDir = path.join('.claude/plans', activePlan);
|
|
70
|
+
const trackerFile = path.join(planDir, 'TASK-TRACKER.json');
|
|
71
|
+
const taskFile = path.join(planDir, 'tasks', `${taskId}.json`);
|
|
72
|
+
|
|
73
|
+
// Check if tracker exists
|
|
74
|
+
if (!fs.existsSync(trackerFile)) {
|
|
75
|
+
console.error('\n❌ ERROR: Task tracker not found');
|
|
76
|
+
console.error(`Plan: ${activePlan}`);
|
|
77
|
+
console.error('Initialize first: npm run plan:init\n');
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Check if task exists
|
|
82
|
+
if (!fs.existsSync(taskFile)) {
|
|
83
|
+
console.error(`\n❌ ERROR: Task file not found: ${taskFile}`);
|
|
84
|
+
console.error('Available tasks:');
|
|
85
|
+
|
|
86
|
+
const tracker = JSON.parse(fs.readFileSync(trackerFile, 'utf8'));
|
|
87
|
+
tracker.taskFiles.forEach(task => {
|
|
88
|
+
console.error(` ${task.id}: ${task.title} [${task.status}]`);
|
|
89
|
+
});
|
|
90
|
+
console.error('');
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Load task and tracker
|
|
95
|
+
const tracker = JSON.parse(fs.readFileSync(trackerFile, 'utf8'));
|
|
96
|
+
const taskData = JSON.parse(fs.readFileSync(taskFile, 'utf8'));
|
|
97
|
+
|
|
98
|
+
// Check if already completed
|
|
99
|
+
if (taskData.status === 'completed') {
|
|
100
|
+
console.error(`\n❌ ERROR: Task ${taskId} is already completed`);
|
|
101
|
+
console.error('Cannot restart a completed task\n');
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Pause any currently active task
|
|
106
|
+
if (tracker.activeTask && tracker.activeTask !== taskId) {
|
|
107
|
+
const activeTaskFile = path.join(planDir, 'tasks', `${tracker.activeTask}.json`);
|
|
108
|
+
if (fs.existsSync(activeTaskFile)) {
|
|
109
|
+
const activeTask = JSON.parse(fs.readFileSync(activeTaskFile, 'utf8'));
|
|
110
|
+
console.log(`\n⚠️ Pausing task ${activeTask.id}: ${activeTask.title}`);
|
|
111
|
+
activeTask.status = 'pending';
|
|
112
|
+
fs.writeFileSync(activeTaskFile, JSON.stringify(activeTask, null, 2));
|
|
113
|
+
|
|
114
|
+
// Update in tracker
|
|
115
|
+
const trackerTask = tracker.taskFiles.find(t => t.id === tracker.activeTask);
|
|
116
|
+
if (trackerTask) {
|
|
117
|
+
trackerTask.status = 'pending';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Update task status
|
|
123
|
+
taskData.status = 'in_progress';
|
|
124
|
+
taskData.startedAt = new Date().toISOString();
|
|
125
|
+
|
|
126
|
+
// GitHub Issues Integration
|
|
127
|
+
if (GitHubConfig && GitHubClient && TaskIssueMapper) {
|
|
128
|
+
try {
|
|
129
|
+
const githubConfig = new GitHubConfig(process.cwd());
|
|
130
|
+
|
|
131
|
+
if (githubConfig.isAutoCreateEnabled()) {
|
|
132
|
+
const { owner, repo } = githubConfig.getRepoInfo();
|
|
133
|
+
const githubClient = new GitHubClient(
|
|
134
|
+
githubConfig.getToken(),
|
|
135
|
+
owner,
|
|
136
|
+
repo
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
// Only create issue if not already created
|
|
140
|
+
if (!taskData.githubIssue) {
|
|
141
|
+
const title = TaskIssueMapper.taskToIssueTitle(taskData);
|
|
142
|
+
const body = TaskIssueMapper.taskToIssueBody(taskData);
|
|
143
|
+
const labels = TaskIssueMapper.taskStatusToLabels(taskData.status, taskData.phase);
|
|
144
|
+
|
|
145
|
+
const issueNumber = await githubClient.createIssue(title, body, labels);
|
|
146
|
+
|
|
147
|
+
if (issueNumber) {
|
|
148
|
+
taskData.githubIssue = issueNumber;
|
|
149
|
+
console.log(`✓ Created GitHub issue #${issueNumber}`);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
console.log(`ℹ Task already linked to GitHub issue #${taskData.githubIssue}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.warn('⚠ GitHub integration failed:', error.message);
|
|
157
|
+
// Continue anyway - task creation should not fail due to GitHub issues
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Save updated task
|
|
162
|
+
fs.writeFileSync(taskFile, JSON.stringify(taskData, null, 2));
|
|
163
|
+
|
|
164
|
+
// Update tracker
|
|
165
|
+
tracker.activeTask = taskId;
|
|
166
|
+
tracker.lastUpdated = new Date().toISOString();
|
|
167
|
+
|
|
168
|
+
const trackerTask = tracker.taskFiles.find(t => t.id === taskId);
|
|
169
|
+
if (trackerTask) {
|
|
170
|
+
trackerTask.status = 'in_progress';
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Update statistics
|
|
174
|
+
tracker.statistics = {
|
|
175
|
+
totalTasks: tracker.taskFiles.length,
|
|
176
|
+
pending: tracker.taskFiles.filter(t => t.status === 'pending').length,
|
|
177
|
+
inProgress: tracker.taskFiles.filter(t => t.status === 'in_progress').length,
|
|
178
|
+
completed: tracker.taskFiles.filter(t => t.status === 'completed').length,
|
|
179
|
+
blocked: tracker.taskFiles.filter(t => t.status === 'blocked').length
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
fs.writeFileSync(trackerFile, JSON.stringify(tracker, null, 2));
|
|
183
|
+
|
|
184
|
+
// Display task info
|
|
185
|
+
console.log(`\n✅ Started task: ${taskId}`);
|
|
186
|
+
console.log(`📋 Plan: ${activePlan}\n`);
|
|
187
|
+
console.log(`📌 ${taskData.title}`);
|
|
188
|
+
|
|
189
|
+
if (taskData.description) {
|
|
190
|
+
console.log(`📝 ${taskData.description}`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
console.log('');
|
|
194
|
+
|
|
195
|
+
if (taskData.phase) {
|
|
196
|
+
console.log(`🔧 Phase: ${taskData.phase}`);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (taskData.githubIssue) {
|
|
200
|
+
const { owner, repo } = new GitHubConfig(process.cwd()).getRepoInfo();
|
|
201
|
+
const issueUrl = `https://github.com/${owner}/${repo}/issues/${taskData.githubIssue}`;
|
|
202
|
+
console.log(`🔗 GitHub Issue: ${issueUrl}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (taskData.completionCriteria && taskData.completionCriteria.length > 0) {
|
|
206
|
+
console.log('\n✓ Completion criteria:');
|
|
207
|
+
taskData.completionCriteria.forEach((criteria, index) => {
|
|
208
|
+
console.log(` ${index + 1}. ${criteria}`);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (taskData.testCases && taskData.testCases.length > 0) {
|
|
213
|
+
console.log('\n🧪 Test cases:');
|
|
214
|
+
taskData.testCases.forEach((test, index) => {
|
|
215
|
+
console.log(` ${index + 1}. ${test}`);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
console.log(`\n📂 Task file: ${taskFile}`);
|
|
220
|
+
console.log('\n📝 WORKFLOW:');
|
|
221
|
+
console.log(' 1. Make your changes on main branch');
|
|
222
|
+
console.log(' 2. Commit frequently with task reference:');
|
|
223
|
+
console.log(` git commit -m "[${taskId}] Description of changes"`);
|
|
224
|
+
console.log(' 3. When finished:');
|
|
225
|
+
console.log(` npm run task:done ${taskId}`);
|
|
226
|
+
|
|
227
|
+
process.exit(0);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
main().catch(error => {
|
|
231
|
+
console.error('\n❌ Fatal error:', error);
|
|
232
|
+
process.exit(1);
|
|
233
|
+
});
|