myaidev-method 0.2.2 → 0.2.4

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.
@@ -0,0 +1,313 @@
1
+ /**
2
+ * MyAIDev Method - Task Manager
3
+ * Simple priority-based task queue with JSON persistence
4
+ * Version: 1.0.0
5
+ */
6
+
7
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, unlinkSync } from 'fs';
8
+ import { join } from 'path';
9
+
10
+ export class TaskManager {
11
+ constructor(workingDir = process.cwd()) {
12
+ this.workingDir = workingDir;
13
+ this.myaidevDir = join(workingDir, '.myaidev-method');
14
+ this.tasksDir = join(this.myaidevDir, 'tasks');
15
+
16
+ this.initializeDirectories();
17
+ }
18
+
19
+ /**
20
+ * Initialize task directories
21
+ */
22
+ initializeDirectories() {
23
+ if (!existsSync(this.tasksDir)) {
24
+ mkdirSync(this.tasksDir, { recursive: true });
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Create a new task
30
+ * @param {string} description - Task description
31
+ * @param {Object} options - Task options
32
+ * @returns {Object} Created task object
33
+ */
34
+ createTask(description, options = {}) {
35
+ const task = {
36
+ id: `task_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
37
+ description,
38
+ type: options.type || 'development',
39
+ priority: this.validatePriority(options.priority),
40
+ status: 'queued',
41
+ assignTo: options.assignTo || null,
42
+ createdAt: new Date().toISOString(),
43
+ updatedAt: new Date().toISOString(),
44
+ metadata: options.metadata || {},
45
+ dependencies: options.dependencies || [],
46
+ outputs: []
47
+ };
48
+
49
+ const taskFile = join(this.tasksDir, `${task.id}.json`);
50
+ writeFileSync(taskFile, JSON.stringify(task, null, 2), 'utf8');
51
+
52
+ console.log(`✅ Task created: ${task.id}`);
53
+ console.log(` Description: ${description}`);
54
+ console.log(` Priority: ${task.priority}`);
55
+ console.log(` Type: ${task.type}`);
56
+
57
+ return task;
58
+ }
59
+
60
+ /**
61
+ * Validate priority value (1-10)
62
+ * @param {number} priority - Priority value
63
+ * @returns {number} Validated priority (default: 5)
64
+ */
65
+ validatePriority(priority) {
66
+ if (typeof priority !== 'number') return 5;
67
+ return Math.max(1, Math.min(10, Math.floor(priority)));
68
+ }
69
+
70
+ /**
71
+ * Get task by ID
72
+ * @param {string} taskId - Task identifier
73
+ * @returns {Object|null} Task object or null if not found
74
+ */
75
+ getTask(taskId) {
76
+ const taskFile = join(this.tasksDir, `${taskId}.json`);
77
+ if (!existsSync(taskFile)) {
78
+ return null;
79
+ }
80
+ return JSON.parse(readFileSync(taskFile, 'utf8'));
81
+ }
82
+
83
+ /**
84
+ * Update task
85
+ * @param {string} taskId - Task identifier
86
+ * @param {Object} updates - Fields to update
87
+ * @returns {Object} Updated task object
88
+ */
89
+ updateTask(taskId, updates) {
90
+ const task = this.getTask(taskId);
91
+ if (!task) {
92
+ throw new Error(`Task not found: ${taskId}`);
93
+ }
94
+
95
+ // Merge updates
96
+ Object.assign(task, updates, {
97
+ updatedAt: new Date().toISOString()
98
+ });
99
+
100
+ // Validate priority if updated
101
+ if (updates.priority !== undefined) {
102
+ task.priority = this.validatePriority(updates.priority);
103
+ }
104
+
105
+ const taskFile = join(this.tasksDir, `${taskId}.json`);
106
+ writeFileSync(taskFile, JSON.stringify(task, null, 2), 'utf8');
107
+
108
+ return task;
109
+ }
110
+
111
+ /**
112
+ * Update task status
113
+ * @param {string} taskId - Task identifier
114
+ * @param {string} status - New status (queued, running, completed, failed)
115
+ * @returns {Object} Updated task
116
+ */
117
+ updateStatus(taskId, status) {
118
+ const validStatuses = ['queued', 'running', 'completed', 'failed', 'cancelled'];
119
+ if (!validStatuses.includes(status)) {
120
+ throw new Error(`Invalid status: ${status}. Must be one of: ${validStatuses.join(', ')}`);
121
+ }
122
+
123
+ return this.updateTask(taskId, { status });
124
+ }
125
+
126
+ /**
127
+ * Add output to task
128
+ * @param {string} taskId - Task identifier
129
+ * @param {string} output - Output file path or description
130
+ * @returns {Object} Updated task
131
+ */
132
+ addOutput(taskId, output) {
133
+ const task = this.getTask(taskId);
134
+ if (!task) {
135
+ throw new Error(`Task not found: ${taskId}`);
136
+ }
137
+
138
+ task.outputs.push({
139
+ path: output,
140
+ timestamp: new Date().toISOString()
141
+ });
142
+
143
+ return this.updateTask(taskId, { outputs: task.outputs });
144
+ }
145
+
146
+ /**
147
+ * List tasks with optional filtering
148
+ * @param {Object} filter - Filter criteria
149
+ * @returns {Array} Array of tasks
150
+ */
151
+ listTasks(filter = {}) {
152
+ if (!existsSync(this.tasksDir)) {
153
+ return [];
154
+ }
155
+
156
+ const taskFiles = readdirSync(this.tasksDir).filter(f => f.endsWith('.json'));
157
+ let tasks = taskFiles.map(file =>
158
+ JSON.parse(readFileSync(join(this.tasksDir, file), 'utf8'))
159
+ );
160
+
161
+ // Apply filters
162
+ if (filter.status) {
163
+ tasks = tasks.filter(t => t.status === filter.status);
164
+ }
165
+ if (filter.assignTo) {
166
+ tasks = tasks.filter(t => t.assignTo === filter.assignTo);
167
+ }
168
+ if (filter.type) {
169
+ tasks = tasks.filter(t => t.type === filter.type);
170
+ }
171
+ if (filter.priority) {
172
+ tasks = tasks.filter(t => t.priority === filter.priority);
173
+ }
174
+
175
+ // Sort by priority (descending) then by creation time
176
+ tasks.sort((a, b) => {
177
+ if (b.priority !== a.priority) {
178
+ return b.priority - a.priority;
179
+ }
180
+ return new Date(b.createdAt) - new Date(a.createdAt);
181
+ });
182
+
183
+ return tasks;
184
+ }
185
+
186
+ /**
187
+ * Get next task in queue (highest priority, queued status)
188
+ * @returns {Object|null} Next task or null if queue is empty
189
+ */
190
+ getNextTask() {
191
+ const queuedTasks = this.listTasks({ status: 'queued' });
192
+ return queuedTasks.length > 0 ? queuedTasks[0] : null;
193
+ }
194
+
195
+ /**
196
+ * Delete task
197
+ * @param {string} taskId - Task identifier
198
+ * @returns {boolean} True if deleted, false if not found
199
+ */
200
+ deleteTask(taskId) {
201
+ const taskFile = join(this.tasksDir, `${taskId}.json`);
202
+ if (existsSync(taskFile)) {
203
+ unlinkSync(taskFile);
204
+ console.log(`✅ Task deleted: ${taskId}`);
205
+ return true;
206
+ }
207
+ return false;
208
+ }
209
+
210
+ /**
211
+ * Clear all completed tasks
212
+ * @returns {number} Number of tasks cleared
213
+ */
214
+ clearCompleted() {
215
+ const completedTasks = this.listTasks({ status: 'completed' });
216
+ let count = 0;
217
+
218
+ for (const task of completedTasks) {
219
+ if (this.deleteTask(task.id)) {
220
+ count++;
221
+ }
222
+ }
223
+
224
+ console.log(`✅ Cleared ${count} completed tasks`);
225
+ return count;
226
+ }
227
+
228
+ /**
229
+ * Get task queue summary
230
+ * @returns {Object} Queue statistics
231
+ */
232
+ getQueueSummary() {
233
+ const allTasks = this.listTasks();
234
+
235
+ const summary = {
236
+ total: allTasks.length,
237
+ queued: allTasks.filter(t => t.status === 'queued').length,
238
+ running: allTasks.filter(t => t.status === 'running').length,
239
+ completed: allTasks.filter(t => t.status === 'completed').length,
240
+ failed: allTasks.filter(t => t.status === 'failed').length,
241
+ cancelled: allTasks.filter(t => t.status === 'cancelled').length
242
+ };
243
+
244
+ return summary;
245
+ }
246
+
247
+ /**
248
+ * Print queue summary
249
+ */
250
+ printQueueSummary() {
251
+ const summary = this.getQueueSummary();
252
+
253
+ console.log('\n📊 MyAIDev Method - Task Queue Summary');
254
+ console.log('═'.repeat(40));
255
+ console.log(`Total Tasks: ${summary.total}`);
256
+ console.log(` ⏳ Queued: ${summary.queued}`);
257
+ console.log(` 🔄 Running: ${summary.running}`);
258
+ console.log(` ✅ Completed: ${summary.completed}`);
259
+ console.log(` ❌ Failed: ${summary.failed}`);
260
+ console.log(` 🚫 Cancelled: ${summary.cancelled}`);
261
+ console.log('');
262
+ }
263
+
264
+ /**
265
+ * Export tasks to JSON file
266
+ * @param {string} outputPath - Output file path
267
+ * @returns {string} Path to exported file
268
+ */
269
+ exportTasks(outputPath) {
270
+ const tasks = this.listTasks();
271
+ const exportData = {
272
+ exportedAt: new Date().toISOString(),
273
+ taskCount: tasks.length,
274
+ tasks
275
+ };
276
+
277
+ writeFileSync(outputPath, JSON.stringify(exportData, null, 2), 'utf8');
278
+ console.log(`✅ Exported ${tasks.length} tasks to: ${outputPath}`);
279
+
280
+ return outputPath;
281
+ }
282
+
283
+ /**
284
+ * Import tasks from JSON file
285
+ * @param {string} inputPath - Input file path
286
+ * @returns {number} Number of tasks imported
287
+ */
288
+ importTasks(inputPath) {
289
+ if (!existsSync(inputPath)) {
290
+ throw new Error(`Import file not found: ${inputPath}`);
291
+ }
292
+
293
+ const importData = JSON.parse(readFileSync(inputPath, 'utf8'));
294
+ const tasks = importData.tasks || [];
295
+
296
+ let count = 0;
297
+ for (const task of tasks) {
298
+ // Create new task with imported data
299
+ this.createTask(task.description, {
300
+ type: task.type,
301
+ priority: task.priority,
302
+ assignTo: task.assignTo,
303
+ metadata: task.metadata
304
+ });
305
+ count++;
306
+ }
307
+
308
+ console.log(`✅ Imported ${count} tasks`);
309
+ return count;
310
+ }
311
+ }
312
+
313
+ export default TaskManager;
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MyAIDev Method - Architecture Design CLI
5
+ *
6
+ * Invokes the dev-architect agent to design system architecture,
7
+ * create API specifications, and plan technology stack.
8
+ *
9
+ * Usage:
10
+ * npx myaidev-method dev:architect "Design authentication system"
11
+ * npx myaidev-method dev:architect "Create e-commerce platform" --tech-stack "node,postgres,redis"
12
+ */
13
+
14
+ import { SparcWorkflow } from '../lib/dev-workflow/sparc-workflow.js';
15
+ import { getAgentByPhase } from '../lib/dev-workflow/agent-types.js';
16
+
17
+ async function main() {
18
+ const args = process.argv.slice(2);
19
+
20
+ if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
21
+ console.log(`
22
+ 🏗️ MyAIDev Method - Architecture Design
23
+
24
+ Usage:
25
+ npx myaidev-method dev:architect "Design authentication system"
26
+ npx myaidev-method dev:architect "Create API endpoints" --tech-stack "node,express"
27
+
28
+ Options:
29
+ --tech-stack <stack> Preferred technology stack (comma-separated)
30
+ --existing-code Analyze existing codebase before designing
31
+ --output-dir <path> Custom output directory (default: .myaidev-method/sparc/)
32
+ --help, -h Show this help message
33
+
34
+ Examples:
35
+ npx myaidev-method dev:architect "Design real-time chat app"
36
+ npx myaidev-method dev:architect "Review current architecture" --existing-code
37
+ npx myaidev-method dev:architect "Design microservices" --tech-stack "node,kubernetes,mongodb"
38
+
39
+ Output:
40
+ .myaidev-method/sparc/architecture.md
41
+
42
+ Next Phase:
43
+ After architecture is complete, run:
44
+ npx myaidev-method dev:code "Implement [feature]"
45
+ `);
46
+ process.exit(0);
47
+ }
48
+
49
+ const taskDescription = args[0];
50
+
51
+ // Parse options
52
+ const options = {
53
+ workingDir: process.cwd(),
54
+ };
55
+
56
+ for (let i = 1; i < args.length; i++) {
57
+ if (args[i] === '--tech-stack' && args[i + 1]) {
58
+ options.techStack = args[i + 1];
59
+ i++;
60
+ } else if (args[i] === '--existing-code') {
61
+ options.analyzeExisting = true;
62
+ } else if (args[i] === '--output-dir' && args[i + 1]) {
63
+ options.outputDir = args[i + 1];
64
+ i++;
65
+ }
66
+ }
67
+
68
+ try {
69
+ console.log('🏗️ MyAIDev Method - Architecture Design');
70
+ console.log('📋 Task:', taskDescription);
71
+ if (options.techStack) {
72
+ console.log('🔧 Tech Stack:', options.techStack);
73
+ }
74
+ console.log('');
75
+
76
+ const workflow = new SparcWorkflow(taskDescription, options);
77
+ const agent = getAgentByPhase('architecture');
78
+
79
+ console.log(`🚀 Invoking ${agent.emoji} ${agent.name}...`);
80
+ console.log('');
81
+
82
+ const result = await workflow.runPhase('architecture');
83
+
84
+ console.log('');
85
+ console.log('✅ Architecture design complete!');
86
+ console.log('📄 Output:', result.outputFile);
87
+ console.log('');
88
+ console.log('📌 Next Steps:');
89
+ console.log(' 1. Review architecture.md in .myaidev-method/sparc/');
90
+ console.log(' 2. Run: npx myaidev-method dev:code "Implement [feature]"');
91
+ console.log('');
92
+
93
+ } catch (error) {
94
+ console.error('❌ Error:', error.message);
95
+ process.exit(1);
96
+ }
97
+ }
98
+
99
+ main();
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MyAIDev Method - Code Implementation CLI
5
+ *
6
+ * Invokes the dev-coder agent to implement features based on
7
+ * architecture specifications using SOLID principles and best practices.
8
+ *
9
+ * Usage:
10
+ * npx myaidev-method dev:code "Implement user authentication"
11
+ * npx myaidev-method dev:code "Build payment processing" --test-driven
12
+ */
13
+
14
+ import { SparcWorkflow } from '../lib/dev-workflow/sparc-workflow.js';
15
+ import { getAgentByPhase } from '../lib/dev-workflow/agent-types.js';
16
+
17
+ async function main() {
18
+ const args = process.argv.slice(2);
19
+
20
+ if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
21
+ console.log(`
22
+ 💻 MyAIDev Method - Code Implementation
23
+
24
+ Usage:
25
+ npx myaidev-method dev:code "Implement authentication"
26
+ npx myaidev-method dev:code "Build API endpoints" --test-driven
27
+
28
+ Options:
29
+ --architecture <file> Path to architecture spec (default: .myaidev-method/sparc/architecture.md)
30
+ --test-driven Use TDD approach (write tests first)
31
+ --output-dir <path> Custom output directory (default: .myaidev-method/sparc/code-output/)
32
+ --help, -h Show this help message
33
+
34
+ Examples:
35
+ npx myaidev-method dev:code "Implement JWT authentication"
36
+ npx myaidev-method dev:code "Create REST API for users" --test-driven
37
+ npx myaidev-method dev:code "Refactor database queries" --architecture custom-arch.md
38
+
39
+ Code Quality Standards:
40
+ - SOLID Principles (Single Responsibility, DRY, KISS)
41
+ - Security best practices (OWASP Top 10)
42
+ - Error handling and input validation
43
+ - Inline documentation (JSDoc, etc.)
44
+ - 80%+ test coverage target
45
+
46
+ Output:
47
+ .myaidev-method/sparc/code-output/
48
+
49
+ Next Phase:
50
+ After implementation, run:
51
+ npx myaidev-method dev:test "Test [feature]"
52
+ `);
53
+ process.exit(0);
54
+ }
55
+
56
+ const taskDescription = args[0];
57
+
58
+ // Parse options
59
+ const options = {
60
+ workingDir: process.cwd(),
61
+ };
62
+
63
+ for (let i = 1; i < args.length; i++) {
64
+ if (args[i] === '--architecture' && args[i + 1]) {
65
+ options.architectureFile = args[i + 1];
66
+ i++;
67
+ } else if (args[i] === '--test-driven') {
68
+ options.testDriven = true;
69
+ } else if (args[i] === '--output-dir' && args[i + 1]) {
70
+ options.outputDir = args[i + 1];
71
+ i++;
72
+ }
73
+ }
74
+
75
+ try {
76
+ console.log('💻 MyAIDev Method - Code Implementation');
77
+ console.log('📋 Task:', taskDescription);
78
+ if (options.testDriven) {
79
+ console.log('🧪 Mode: Test-Driven Development (TDD)');
80
+ }
81
+ console.log('');
82
+
83
+ const workflow = new SparcWorkflow(taskDescription, options);
84
+ const agent = getAgentByPhase('implementation');
85
+
86
+ console.log(`🚀 Invoking ${agent.emoji} ${agent.name}...`);
87
+ console.log('');
88
+
89
+ const result = await workflow.runPhase('implementation');
90
+
91
+ console.log('');
92
+ console.log('✅ Implementation complete!');
93
+ console.log('📁 Output:', result.outputDir);
94
+ console.log('');
95
+ console.log('📌 Next Steps:');
96
+ console.log(' 1. Review code in .myaidev-method/sparc/code-output/');
97
+ console.log(' 2. Run: npx myaidev-method dev:test "Test [feature]"');
98
+ console.log('');
99
+
100
+ } catch (error) {
101
+ console.error('❌ Error:', error.message);
102
+ process.exit(1);
103
+ }
104
+ }
105
+
106
+ main();
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MyAIDev Method - Documentation Generation CLI
5
+ *
6
+ * Invokes the dev-documenter agent to generate comprehensive
7
+ * API documentation, user guides, and technical specifications.
8
+ *
9
+ * Usage:
10
+ * npx myaidev-method dev:docs "Document authentication API"
11
+ * npx myaidev-method dev:docs "Create user guide" --type user-guide
12
+ */
13
+
14
+ import { SparcWorkflow } from '../lib/dev-workflow/sparc-workflow.js';
15
+ import { getAgentByPhase } from '../lib/dev-workflow/agent-types.js';
16
+
17
+ async function main() {
18
+ const args = process.argv.slice(2);
19
+
20
+ if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
21
+ console.log(`
22
+ 📚 MyAIDev Method - Documentation
23
+
24
+ Usage:
25
+ npx myaidev-method dev:docs "Document authentication API"
26
+ npx myaidev-method dev:docs "Create user guide" --type user-guide --format html
27
+
28
+ Options:
29
+ --type <type> Documentation type: api, user-guide, architecture, technical
30
+ --format <format> Output format: markdown, html, openapi, swagger
31
+ --output-dir <path> Custom output directory (default: .myaidev-method/sparc/documentation/)
32
+ --help, -h Show this help message
33
+
34
+ Examples:
35
+ npx myaidev-method dev:docs "Document REST API endpoints"
36
+ npx myaidev-method dev:docs "Create user guide for checkout flow" --type user-guide
37
+ npx myaidev-method dev:docs "Generate OpenAPI spec" --format openapi
38
+ npx myaidev-method dev:docs "Document system architecture" --type architecture
39
+
40
+ Documentation Standards:
41
+ - Clarity: Simple language, clear examples, visual aids
42
+ - Completeness: All public APIs documented
43
+ - Accuracy: Code examples tested and verified
44
+ - Accessibility: Multiple formats, searchable
45
+ - Maintenance: Version-controlled, synchronized with code
46
+
47
+ Output:
48
+ .myaidev-method/sparc/documentation/
49
+
50
+ Completion:
51
+ This is the final phase of the SPARC workflow.
52
+ All phases complete! 🎉
53
+ `);
54
+ process.exit(0);
55
+ }
56
+
57
+ const taskDescription = args[0];
58
+
59
+ // Parse options
60
+ const options = {
61
+ workingDir: process.cwd(),
62
+ };
63
+
64
+ for (let i = 1; i < args.length; i++) {
65
+ if (args[i] === '--type' && args[i + 1]) {
66
+ options.docType = args[i + 1];
67
+ i++;
68
+ } else if (args[i] === '--format' && args[i + 1]) {
69
+ options.format = args[i + 1];
70
+ i++;
71
+ } else if (args[i] === '--output-dir' && args[i + 1]) {
72
+ options.outputDir = args[i + 1];
73
+ i++;
74
+ }
75
+ }
76
+
77
+ try {
78
+ console.log('📚 MyAIDev Method - Documentation');
79
+ console.log('📋 Task:', taskDescription);
80
+ if (options.docType) {
81
+ console.log('📖 Type:', options.docType);
82
+ }
83
+ if (options.format) {
84
+ console.log('📄 Format:', options.format);
85
+ }
86
+ console.log('');
87
+
88
+ const workflow = new SparcWorkflow(taskDescription, options);
89
+ const agent = getAgentByPhase('documentation');
90
+
91
+ console.log(`🚀 Invoking ${agent.emoji} ${agent.name}...`);
92
+ console.log('');
93
+
94
+ const result = await workflow.runPhase('documentation');
95
+
96
+ console.log('');
97
+ console.log('✅ Documentation complete!');
98
+ console.log('📁 Output:', result.outputDir);
99
+ console.log('');
100
+ console.log('🎉 SPARC Workflow Complete!');
101
+ console.log('');
102
+ console.log('📌 Final Deliverables:');
103
+ console.log(' ✅ Architecture: .myaidev-method/sparc/architecture.md');
104
+ console.log(' ✅ Code: .myaidev-method/sparc/code-output/');
105
+ console.log(' ✅ Tests: .myaidev-method/sparc/test-results/');
106
+ console.log(' ✅ Review: .myaidev-method/sparc/review-report.md');
107
+ console.log(' ✅ Documentation: .myaidev-method/sparc/documentation/');
108
+ console.log('');
109
+ console.log('📌 Next Steps:');
110
+ console.log(' 1. Review all deliverables in .myaidev-method/sparc/');
111
+ console.log(' 2. Address any review findings');
112
+ console.log(' 3. Integrate code into your project');
113
+ console.log(' 4. Deploy with confidence! 🚀');
114
+ console.log('');
115
+
116
+ } catch (error) {
117
+ console.error('❌ Error:', error.message);
118
+ process.exit(1);
119
+ }
120
+ }
121
+
122
+ main();