claude-autopm 1.17.0 → 1.20.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.
Files changed (76) hide show
  1. package/README.md +159 -0
  2. package/autopm/.claude/agents/core/mcp-manager.md +1 -1
  3. package/autopm/.claude/commands/pm/context.md +11 -0
  4. package/autopm/.claude/commands/pm/epic-decompose.md +25 -2
  5. package/autopm/.claude/commands/pm/epic-oneshot.md +13 -0
  6. package/autopm/.claude/commands/pm/epic-start.md +19 -0
  7. package/autopm/.claude/commands/pm/epic-sync-modular.md +10 -10
  8. package/autopm/.claude/commands/pm/epic-sync.md +14 -14
  9. package/autopm/.claude/commands/pm/issue-start.md +50 -5
  10. package/autopm/.claude/commands/pm/issue-sync.md +15 -15
  11. package/autopm/.claude/commands/pm/what-next.md +11 -0
  12. package/autopm/.claude/mcp/MCP-REGISTRY.md +1 -1
  13. package/autopm/.claude/scripts/azure/active-work.js +2 -2
  14. package/autopm/.claude/scripts/azure/blocked.js +13 -13
  15. package/autopm/.claude/scripts/azure/daily.js +1 -1
  16. package/autopm/.claude/scripts/azure/dashboard.js +1 -1
  17. package/autopm/.claude/scripts/azure/feature-list.js +2 -2
  18. package/autopm/.claude/scripts/azure/feature-status.js +1 -1
  19. package/autopm/.claude/scripts/azure/next-task.js +1 -1
  20. package/autopm/.claude/scripts/azure/search.js +1 -1
  21. package/autopm/.claude/scripts/azure/setup.js +15 -15
  22. package/autopm/.claude/scripts/azure/sprint-report.js +2 -2
  23. package/autopm/.claude/scripts/azure/sync.js +1 -1
  24. package/autopm/.claude/scripts/azure/us-list.js +1 -1
  25. package/autopm/.claude/scripts/azure/us-status.js +1 -1
  26. package/autopm/.claude/scripts/azure/validate.js +13 -13
  27. package/autopm/.claude/scripts/lib/frontmatter-utils.sh +42 -7
  28. package/autopm/.claude/scripts/lib/logging-utils.sh +20 -16
  29. package/autopm/.claude/scripts/lib/validation-utils.sh +1 -1
  30. package/autopm/.claude/scripts/pm/context.js +338 -0
  31. package/autopm/.claude/scripts/pm/issue-sync/format-comment.sh +3 -3
  32. package/autopm/.claude/scripts/pm/lib/README.md +85 -0
  33. package/autopm/.claude/scripts/pm/lib/logger.js +78 -0
  34. package/autopm/.claude/scripts/pm/next.js +25 -1
  35. package/autopm/.claude/scripts/pm/what-next.js +660 -0
  36. package/bin/autopm.js +25 -0
  37. package/bin/commands/team.js +86 -0
  38. package/package.json +1 -1
  39. package/lib/agentExecutor.js.deprecated +0 -101
  40. package/lib/azure/cache.js +0 -80
  41. package/lib/azure/client.js +0 -77
  42. package/lib/azure/formatter.js +0 -177
  43. package/lib/commandHelpers.js +0 -177
  44. package/lib/context/manager.js +0 -290
  45. package/lib/documentation/manager.js +0 -528
  46. package/lib/github/workflow-manager.js +0 -546
  47. package/lib/helpers/azure-batch-api.js +0 -133
  48. package/lib/helpers/azure-cache-manager.js +0 -287
  49. package/lib/helpers/azure-parallel-processor.js +0 -158
  50. package/lib/helpers/azure-work-item-create.js +0 -278
  51. package/lib/helpers/gh-issue-create.js +0 -250
  52. package/lib/helpers/interactive-prompt.js +0 -336
  53. package/lib/helpers/output-manager.js +0 -335
  54. package/lib/helpers/progress-indicator.js +0 -258
  55. package/lib/performance/benchmarker.js +0 -429
  56. package/lib/pm/epic-decomposer.js +0 -273
  57. package/lib/pm/epic-syncer.js +0 -221
  58. package/lib/prdMetadata.js +0 -270
  59. package/lib/providers/azure/index.js +0 -234
  60. package/lib/providers/factory.js +0 -87
  61. package/lib/providers/github/index.js +0 -204
  62. package/lib/providers/interface.js +0 -73
  63. package/lib/python/scaffold-manager.js +0 -576
  64. package/lib/react/scaffold-manager.js +0 -745
  65. package/lib/regression/analyzer.js +0 -578
  66. package/lib/release/manager.js +0 -324
  67. package/lib/tailwind/manager.js +0 -486
  68. package/lib/traefik/manager.js +0 -484
  69. package/lib/utils/colors.js +0 -126
  70. package/lib/utils/config.js +0 -317
  71. package/lib/utils/filesystem.js +0 -316
  72. package/lib/utils/logger.js +0 -135
  73. package/lib/utils/prompts.js +0 -294
  74. package/lib/utils/shell.js +0 -237
  75. package/lib/validators/email-validator.js +0 -337
  76. package/lib/workflow/manager.js +0 -449
@@ -0,0 +1,660 @@
1
+ const fs = require('fs');
2
+ const fsPromises = require('fs').promises;
3
+ const path = require('path');
4
+ const { logError, logWarning, logDebug } = require('./lib/logger');
5
+
6
+ /**
7
+ * PM What-Next Script
8
+ * Intelligent context-aware suggestions for next steps
9
+ */
10
+
11
+ // ============================================================================
12
+ // Configuration Constants
13
+ // ============================================================================
14
+
15
+ // Task file naming pattern (e.g., 001.md, 002.md)
16
+ const TASK_FILE_PATTERN = /^\d{3}\.md$/;
17
+
18
+ // Epic complexity detection thresholds
19
+ const COMPLEXITY_THRESHOLDS = {
20
+ // Content length threshold (characters)
21
+ LARGE_EPIC_SIZE: parseInt(process.env.PM_LARGE_EPIC_SIZE) || 5000,
22
+
23
+ // Task count thresholds
24
+ MANY_TASKS: parseInt(process.env.PM_MANY_TASKS) || 20,
25
+
26
+ // Keywords indicating multi-layer architecture
27
+ ARCHITECTURE_KEYWORDS: {
28
+ frontend: ['frontend', 'ui', 'client', 'react', 'vue', 'angular'],
29
+ backend: ['backend', 'api', 'server', 'service'],
30
+ database: ['database', 'db', 'postgres', 'mysql', 'mongodb'],
31
+ infrastructure: ['infrastructure', 'deploy', 'k8s', 'kubernetes', 'docker', 'ci/cd'],
32
+ integration: ['integration', 'third-party', 'external api', 'webhook']
33
+ }
34
+ };
35
+
36
+ async function whatNext() {
37
+ console.log('');
38
+ console.log('🎯 What Should I Do Next?');
39
+ console.log('='.repeat(60));
40
+ console.log('');
41
+
42
+ // Analyze current project state
43
+ const state = await analyzeProjectState();
44
+
45
+ // Generate contextual suggestions
46
+ const suggestions = generateSuggestions(state);
47
+
48
+ // Display project status
49
+ displayProjectStatus(state);
50
+ console.log('');
51
+
52
+ // Display suggestions
53
+ displaySuggestions(suggestions, state);
54
+
55
+ console.log('');
56
+ console.log('💡 Tip: Run /pm:context to see detailed project status');
57
+ console.log('');
58
+ }
59
+
60
+ // Analyze current project state
61
+ async function analyzeProjectState() {
62
+ const state = {
63
+ hasPRDs: false,
64
+ prdCount: 0,
65
+ prds: [],
66
+ hasEpics: false,
67
+ epicCount: 0,
68
+ epics: [],
69
+ hasConfig: false,
70
+ provider: null,
71
+ hasActiveTasks: false,
72
+ activeTaskCount: 0,
73
+ completedTaskCount: 0,
74
+ totalTaskCount: 0,
75
+ inProgressTasks: [],
76
+ openTasks: []
77
+ };
78
+
79
+ // Check for PRDs
80
+ if (fs.existsSync('.claude/prds')) {
81
+ const prdFiles = fs.readdirSync('.claude/prds')
82
+ .filter(f => f.endsWith('.md') && !f.startsWith('.'));
83
+ state.hasPRDs = prdFiles.length > 0;
84
+ state.prdCount = prdFiles.length;
85
+ state.prds = prdFiles.map(f => f.replace('.md', ''));
86
+ }
87
+
88
+ // Check for epics
89
+ if (fs.existsSync('.claude/epics')) {
90
+ const epicDirs = fs.readdirSync('.claude/epics', { withFileTypes: true })
91
+ .filter(d => d.isDirectory())
92
+ .map(d => d.name);
93
+
94
+ state.hasEpics = epicDirs.length > 0;
95
+ state.epicCount = epicDirs.length;
96
+
97
+ // Analyze all epics in parallel for better performance
98
+ // This prevents blocking when projects have many epics/tasks
99
+ // Example: 10 epics × 50 tasks = 500 files processed in parallel
100
+ const epicAnalysisPromises = epicDirs.map(epicName => {
101
+ const epicPath = path.join('.claude/epics', epicName);
102
+ return analyzeEpicAsync(epicPath, epicName)
103
+ .catch(err => {
104
+ logWarning(`Failed to analyze epic "${epicName}": ${err.message}`);
105
+ logDebug(err.stack);
106
+ // Return a minimal fallback object to prevent Promise.all from failing
107
+ return {
108
+ name: epicName,
109
+ path: epicPath,
110
+ hasTasks: false,
111
+ taskCount: 0,
112
+ completedCount: 0,
113
+ inProgressCount: 0,
114
+ openCount: 0,
115
+ inProgressTasks: [],
116
+ openTasks: [],
117
+ isComplex: false,
118
+ hasArchitecture: false,
119
+ analysisFailed: true
120
+ };
121
+ });
122
+ });
123
+
124
+ const epicInfos = await Promise.all(epicAnalysisPromises);
125
+
126
+ // Aggregate results
127
+ for (const epicInfo of epicInfos) {
128
+ state.epics.push(epicInfo);
129
+
130
+ // Count tasks
131
+ state.totalTaskCount += epicInfo.taskCount;
132
+ state.completedTaskCount += epicInfo.completedCount;
133
+ state.activeTaskCount += epicInfo.inProgressCount;
134
+
135
+ // Collect tasks
136
+ state.inProgressTasks.push(...epicInfo.inProgressTasks);
137
+ state.openTasks.push(...epicInfo.openTasks);
138
+ }
139
+
140
+ state.hasActiveTasks = state.activeTaskCount > 0;
141
+ }
142
+
143
+ // Check configuration
144
+ if (fs.existsSync('.claude/config.json')) {
145
+ try {
146
+ const config = JSON.parse(fs.readFileSync('.claude/config.json', 'utf8'));
147
+ state.hasConfig = true;
148
+ state.provider = config.provider || null;
149
+ } catch (err) {
150
+ // Ignore config errors
151
+ }
152
+ }
153
+
154
+ return state;
155
+ }
156
+
157
+ // Analyze single epic (async version for parallel processing)
158
+ async function analyzeEpicAsync(epicPath, epicName) {
159
+ const info = {
160
+ name: epicName,
161
+ hasEpicFile: false,
162
+ hasTasks: false,
163
+ taskCount: 0,
164
+ completedCount: 0,
165
+ inProgressCount: 0,
166
+ openCount: 0,
167
+ syncedToGitHub: false,
168
+ inProgressTasks: [],
169
+ openTasks: []
170
+ };
171
+
172
+ // Check for epic.md
173
+ const epicFile = path.join(epicPath, 'epic.md');
174
+ try {
175
+ await fsPromises.access(epicFile);
176
+ info.hasEpicFile = true;
177
+
178
+ const content = await fsPromises.readFile(epicFile, 'utf8');
179
+ info.syncedToGitHub = /^github:/m.test(content);
180
+ } catch (err) {
181
+ // File doesn't exist or can't be read
182
+ }
183
+
184
+ // Check for task files
185
+ try {
186
+ const files = await fsPromises.readdir(epicPath);
187
+ const taskFiles = files.filter(f => TASK_FILE_PATTERN.test(f));
188
+
189
+ info.hasTasks = taskFiles.length > 0;
190
+ info.taskCount = taskFiles.length;
191
+
192
+ // Analyze all tasks in parallel
193
+ const taskAnalysisPromises = taskFiles.map(async (taskFile) => {
194
+ const taskPath = path.join(epicPath, taskFile);
195
+ try {
196
+ const content = await fsPromises.readFile(taskPath, 'utf8');
197
+ const statusMatch = content.match(/^status:\s*(.+)$/m);
198
+ const status = statusMatch ? statusMatch[1].trim().toLowerCase() : 'open';
199
+
200
+ const nameMatch = content.match(/^name:\s*(.+)$/m);
201
+ const taskName = nameMatch ? nameMatch[1].trim() : taskFile;
202
+
203
+ const taskNum = taskFile.replace('.md', '');
204
+
205
+ return { status, taskName, taskNum };
206
+ } catch (err) {
207
+ // Ignore task read errors
208
+ return null;
209
+ }
210
+ });
211
+
212
+ const taskResults = await Promise.all(taskAnalysisPromises);
213
+
214
+ // Aggregate task results
215
+ for (const result of taskResults) {
216
+ if (!result) continue;
217
+
218
+ const { status, taskName, taskNum } = result;
219
+
220
+ if (status === 'completed' || status === 'done' || status === 'closed') {
221
+ info.completedCount++;
222
+ } else if (status === 'in-progress' || status === 'in_progress') {
223
+ info.inProgressCount++;
224
+ info.inProgressTasks.push({ epicName, taskNum, name: taskName });
225
+ } else {
226
+ info.openCount++;
227
+ info.openTasks.push({ epicName, taskNum, name: taskName });
228
+ }
229
+ }
230
+ } catch (err) {
231
+ // Ignore directory read errors
232
+ }
233
+
234
+ return info;
235
+ }
236
+
237
+ // Analyze single epic (synchronous - kept for backward compatibility)
238
+ function analyzeEpic(epicPath, epicName) {
239
+ const info = {
240
+ name: epicName,
241
+ hasEpicFile: false,
242
+ hasTasks: false,
243
+ taskCount: 0,
244
+ completedCount: 0,
245
+ inProgressCount: 0,
246
+ openCount: 0,
247
+ syncedToGitHub: false,
248
+ inProgressTasks: [],
249
+ openTasks: []
250
+ };
251
+
252
+ // Check for epic.md
253
+ const epicFile = path.join(epicPath, 'epic.md');
254
+ info.hasEpicFile = fs.existsSync(epicFile);
255
+
256
+ if (info.hasEpicFile) {
257
+ try {
258
+ const content = fs.readFileSync(epicFile, 'utf8');
259
+ info.syncedToGitHub = /^github:/m.test(content);
260
+ } catch (err) {
261
+ // Ignore read errors
262
+ }
263
+ }
264
+
265
+ // Check for task files
266
+ try {
267
+ const taskFiles = fs.readdirSync(epicPath)
268
+ .filter(f => TASK_FILE_PATTERN.test(f));
269
+
270
+ info.hasTasks = taskFiles.length > 0;
271
+ info.taskCount = taskFiles.length;
272
+
273
+ // Analyze each task
274
+ for (const taskFile of taskFiles) {
275
+ const taskPath = path.join(epicPath, taskFile);
276
+ try {
277
+ const content = fs.readFileSync(taskPath, 'utf8');
278
+ const statusMatch = content.match(/^status:\s*(.+)$/m);
279
+ const status = statusMatch ? statusMatch[1].trim().toLowerCase() : 'open';
280
+
281
+ const nameMatch = content.match(/^name:\s*(.+)$/m);
282
+ const taskName = nameMatch ? nameMatch[1].trim() : taskFile;
283
+
284
+ const taskNum = taskFile.replace('.md', '');
285
+
286
+ if (status === 'completed' || status === 'done' || status === 'closed') {
287
+ info.completedCount++;
288
+ } else if (status === 'in-progress' || status === 'in_progress') {
289
+ info.inProgressCount++;
290
+ info.inProgressTasks.push({ epicName, taskNum, name: taskName });
291
+ } else {
292
+ info.openCount++;
293
+ info.openTasks.push({ epicName, taskNum, name: taskName });
294
+ }
295
+ } catch (err) {
296
+ // Ignore task read errors
297
+ }
298
+ }
299
+ } catch (err) {
300
+ // Ignore directory read errors
301
+ }
302
+
303
+ return info;
304
+ }
305
+
306
+ // ============================================================================
307
+ // Epic Complexity Detection
308
+ // ============================================================================
309
+
310
+ /**
311
+ * Detect if an epic is complex enough to warrant splitting into sub-epics
312
+ *
313
+ * @param {string} epicContent - Content of the epic.md file
314
+ * @param {object} epicInfo - Epic metadata (taskCount, etc.)
315
+ * @returns {object} { isComplex: boolean, reasons: string[] }
316
+ */
317
+ function detectEpicComplexity(epicContent, epicInfo = {}) {
318
+ const reasons = [];
319
+
320
+ if (!epicContent) {
321
+ return { isComplex: false, reasons: [] };
322
+ }
323
+
324
+ const contentLower = epicContent.toLowerCase();
325
+
326
+ // 1. Check for multi-layer architecture (frontend + backend)
327
+ const hasMultipleLayers = detectMultipleArchitectureLayers(contentLower);
328
+ if (hasMultipleLayers.detected) {
329
+ reasons.push(`Multiple architecture layers: ${hasMultipleLayers.layers.join(', ')}`);
330
+ }
331
+
332
+ // 2. Check for large content size
333
+ if (epicContent.length > COMPLEXITY_THRESHOLDS.LARGE_EPIC_SIZE) {
334
+ reasons.push(`Large epic size: ${epicContent.length} characters (threshold: ${COMPLEXITY_THRESHOLDS.LARGE_EPIC_SIZE})`);
335
+ }
336
+
337
+ // 3. Check for high estimated task count (if available)
338
+ if (epicInfo.taskCount && epicInfo.taskCount > COMPLEXITY_THRESHOLDS.MANY_TASKS) {
339
+ reasons.push(`Many tasks: ${epicInfo.taskCount} (threshold: ${COMPLEXITY_THRESHOLDS.MANY_TASKS})`);
340
+ }
341
+
342
+ // 4. Check for infrastructure/deployment complexity
343
+ const hasInfrastructure = COMPLEXITY_THRESHOLDS.ARCHITECTURE_KEYWORDS.infrastructure
344
+ .some(keyword => contentLower.includes(keyword));
345
+ if (hasInfrastructure) {
346
+ reasons.push('Contains infrastructure/deployment components');
347
+ }
348
+
349
+ // 5. Check for external integrations
350
+ const hasIntegrations = COMPLEXITY_THRESHOLDS.ARCHITECTURE_KEYWORDS.integration
351
+ .some(keyword => contentLower.includes(keyword));
352
+ if (hasIntegrations) {
353
+ reasons.push('Contains external service integrations');
354
+ }
355
+
356
+ return {
357
+ isComplex: reasons.length >= 2, // At least 2 complexity indicators
358
+ reasons
359
+ };
360
+ }
361
+
362
+ /**
363
+ * Detect multiple architecture layers in epic content
364
+ *
365
+ * @param {string} contentLower - Lowercase epic content
366
+ * @returns {object} { detected: boolean, layers: string[] }
367
+ */
368
+ function detectMultipleArchitectureLayers(contentLower) {
369
+ const layers = [];
370
+ const keywords = COMPLEXITY_THRESHOLDS.ARCHITECTURE_KEYWORDS;
371
+
372
+ // Check each layer
373
+ for (const [layerName, layerKeywords] of Object.entries(keywords)) {
374
+ if (layerName === 'integration') continue; // Skip integration layer
375
+
376
+ const hasLayer = layerKeywords.some(keyword => contentLower.includes(keyword));
377
+ if (hasLayer) {
378
+ layers.push(layerName);
379
+ }
380
+ }
381
+
382
+ // Complex if has 2+ distinct layers (e.g., frontend + backend)
383
+ return {
384
+ detected: layers.length >= 2,
385
+ layers
386
+ };
387
+ }
388
+
389
+ // Generate suggestions based on state
390
+ function generateSuggestions(state) {
391
+ const suggestions = [];
392
+
393
+ // Scenario 1: No PRDs yet
394
+ if (!state.hasPRDs) {
395
+ suggestions.push({
396
+ priority: 'high',
397
+ recommended: true,
398
+ title: 'Create Your First PRD',
399
+ description: 'Start by defining what you want to build',
400
+ commands: [
401
+ { cmd: '/pm:prd-new my-feature', note: 'Replace "my-feature" with your feature name' }
402
+ ],
403
+ why: 'PRDs define requirements and guide the entire development process'
404
+ });
405
+ return suggestions; // Stop here, nothing else makes sense yet
406
+ }
407
+
408
+ // Scenario 2: Have PRDs but no epics
409
+ if (state.hasPRDs && !state.hasEpics) {
410
+ for (const prd of state.prds) {
411
+ suggestions.push({
412
+ priority: 'high',
413
+ recommended: true,
414
+ title: `Parse PRD: "${prd}"`,
415
+ description: 'Convert your requirements into an executable epic',
416
+ commands: [
417
+ { cmd: `/pm:prd-parse ${prd}`, note: 'Analyzes PRD and creates epic structure' }
418
+ ],
419
+ why: 'This creates the epic structure needed for task breakdown'
420
+ });
421
+ }
422
+ return suggestions;
423
+ }
424
+
425
+ // Scenario 3: Have epics that need decomposition
426
+ const epicsNeedingDecomposition = state.epics.filter(e => e.hasEpicFile && !e.hasTasks);
427
+ if (epicsNeedingDecomposition.length > 0) {
428
+ for (const epic of epicsNeedingDecomposition) {
429
+ // Check if this is a complex epic that should be split
430
+ const epicContent = tryReadFile(path.join('.claude/epics', epic.name, 'epic.md'));
431
+ const complexityResult = detectEpicComplexity(epicContent, epic);
432
+ const isComplex = complexityResult.isComplex;
433
+
434
+ if (isComplex) {
435
+ suggestions.push({
436
+ priority: 'high',
437
+ recommended: true,
438
+ title: `Split Epic: "${epic.name}" (Complex Project)`,
439
+ description: 'Break into multiple sub-epics for parallel work',
440
+ commands: [
441
+ { cmd: `/pm:epic-split ${epic.name}`, note: 'Creates multiple sub-epics (frontend, backend, etc.)' },
442
+ { cmd: `# Then decompose each sub-epic:`, note: '' },
443
+ { cmd: `/pm:epic-decompose ${epic.name}/01-*`, note: 'Repeat for each sub-epic' }
444
+ ],
445
+ why: 'Large projects work better when split into focused components'
446
+ });
447
+ } else {
448
+ suggestions.push({
449
+ priority: 'high',
450
+ recommended: true,
451
+ title: `Decompose Epic: "${epic.name}"`,
452
+ description: 'Break epic into actionable tasks',
453
+ commands: [
454
+ { cmd: `/pm:epic-decompose ${epic.name}`, note: 'Creates numbered task files' }
455
+ ],
456
+ why: 'Tasks are the actual work items that get implemented'
457
+ });
458
+ }
459
+ }
460
+ return suggestions;
461
+ }
462
+
463
+ // Scenario 4: Have tasks but not synced to GitHub
464
+ const epicsNeedingSync = state.epics.filter(e => e.hasTasks && !e.syncedToGitHub);
465
+ if (epicsNeedingSync.length > 0) {
466
+ for (const epic of epicsNeedingSync) {
467
+ suggestions.push({
468
+ priority: 'high',
469
+ recommended: true,
470
+ title: `Sync Epic: "${epic.name}" to GitHub`,
471
+ description: 'Create GitHub issues for tracking',
472
+ commands: [
473
+ { cmd: `/pm:epic-sync ${epic.name}`, note: 'Creates epic + task issues on GitHub' }
474
+ ],
475
+ why: 'GitHub issues enable team collaboration and progress tracking'
476
+ });
477
+ }
478
+ return suggestions;
479
+ }
480
+
481
+ // Scenario 5: Have synced tasks - ready to work
482
+ if (state.openTasks.length > 0) {
483
+ suggestions.push({
484
+ priority: 'high',
485
+ recommended: true,
486
+ title: 'Start Working on Tasks',
487
+ description: `You have ${state.openTasks.length} tasks ready to work on`,
488
+ commands: [
489
+ { cmd: '/pm:next', note: 'Shows highest priority available tasks' },
490
+ { cmd: `/pm:issue-start ${state.openTasks[0].taskNum}`, note: `Start: "${state.openTasks[0].name}"` }
491
+ ],
492
+ why: 'Begin implementation with TDD approach'
493
+ });
494
+ }
495
+
496
+ // Scenario 6: Have tasks in progress
497
+ if (state.inProgressTasks.length > 0) {
498
+ suggestions.push({
499
+ priority: 'medium',
500
+ recommended: state.openTasks.length === 0,
501
+ title: 'Continue In-Progress Work',
502
+ description: `You have ${state.inProgressTasks.length} tasks currently in progress`,
503
+ commands: state.inProgressTasks.slice(0, 3).map(t => ({
504
+ cmd: `/pm:issue-show ${t.taskNum}`,
505
+ note: `"${t.name}"`
506
+ })),
507
+ why: 'Finish what you started before starting new work'
508
+ });
509
+ }
510
+
511
+ // Scenario 7: Everything done, suggest new features
512
+ if (state.completedTaskCount === state.totalTaskCount && state.totalTaskCount > 0) {
513
+ suggestions.push({
514
+ priority: 'medium',
515
+ recommended: true,
516
+ title: 'All Tasks Complete! 🎉',
517
+ description: 'Time to plan your next feature',
518
+ commands: [
519
+ { cmd: '/pm:prd-new next-feature', note: 'Start a new PRD for your next feature' },
520
+ { cmd: '/pm:standup', note: 'Generate summary of completed work' }
521
+ ],
522
+ why: 'Document achievements and plan ahead'
523
+ });
524
+ }
525
+
526
+ // Always available: Check status and context
527
+ suggestions.push({
528
+ priority: 'low',
529
+ recommended: false,
530
+ title: 'Check Project Status',
531
+ description: 'View detailed project information',
532
+ commands: [
533
+ { cmd: '/pm:context', note: 'Full project context and progress' },
534
+ { cmd: '/pm:status', note: 'Project health and configuration' },
535
+ { cmd: '/pm:standup', note: 'Daily standup summary' }
536
+ ],
537
+ why: 'Stay informed about project state'
538
+ });
539
+
540
+ return suggestions;
541
+ }
542
+
543
+ // Display project status summary
544
+ function displayProjectStatus(state) {
545
+ console.log('📊 Current Project Status:');
546
+ console.log('');
547
+
548
+ if (!state.hasPRDs && !state.hasEpics) {
549
+ console.log(' 🆕 New project - Ready to start!');
550
+ return;
551
+ }
552
+
553
+ if (state.hasPRDs) {
554
+ console.log(` 📄 PRDs: ${state.prdCount} (${state.prds.join(', ')})`);
555
+ }
556
+
557
+ if (state.hasEpics) {
558
+ console.log(` 📚 Epics: ${state.epicCount}`);
559
+ console.log(` ✅ Tasks: ${state.completedTaskCount} / ${state.totalTaskCount} completed`);
560
+
561
+ if (state.activeTaskCount > 0) {
562
+ console.log(` 🔄 In Progress: ${state.activeTaskCount} tasks`);
563
+ }
564
+
565
+ if (state.openTasks.length > 0) {
566
+ console.log(` 📋 Ready: ${state.openTasks.length} tasks waiting`);
567
+ }
568
+ }
569
+
570
+ if (state.hasConfig && state.provider) {
571
+ console.log(` ⚙️ Provider: ${state.provider.charAt(0).toUpperCase() + state.provider.slice(1)}`);
572
+ }
573
+ }
574
+
575
+ // Display suggestions
576
+ function displaySuggestions(suggestions, state) {
577
+ console.log('💡 Suggested Next Steps:');
578
+ console.log('');
579
+
580
+ const highPriority = suggestions.filter(s => s.priority === 'high');
581
+ const mediumPriority = suggestions.filter(s => s.priority === 'medium');
582
+ const lowPriority = suggestions.filter(s => s.priority === 'low');
583
+
584
+ let stepNum = 1;
585
+
586
+ // High priority suggestions
587
+ for (const suggestion of highPriority) {
588
+ displaySuggestion(suggestion, stepNum++);
589
+ }
590
+
591
+ // Medium priority suggestions
592
+ if (mediumPriority.length > 0) {
593
+ console.log('');
594
+ console.log(' Also Available:');
595
+ console.log(' ' + '-'.repeat(56));
596
+ console.log('');
597
+ for (const suggestion of mediumPriority) {
598
+ displaySuggestion(suggestion, stepNum++, ' ');
599
+ }
600
+ }
601
+
602
+ // Low priority suggestions (info only)
603
+ if (lowPriority.length > 0 && highPriority.length === 0) {
604
+ console.log('');
605
+ console.log(' Information Commands:');
606
+ console.log(' ' + '-'.repeat(56));
607
+ console.log('');
608
+ for (const suggestion of lowPriority) {
609
+ displaySuggestion(suggestion, stepNum++, ' ');
610
+ }
611
+ }
612
+ }
613
+
614
+ // Display single suggestion
615
+ function displaySuggestion(suggestion, stepNum, indent = '') {
616
+ const marker = suggestion.recommended ? '⭐' : '○';
617
+
618
+ console.log(`${indent}${stepNum}. ${marker} ${suggestion.title}`);
619
+ console.log(`${indent} ${suggestion.description}`);
620
+ console.log('');
621
+
622
+ for (const cmd of suggestion.commands) {
623
+ if (cmd.cmd.startsWith('#')) {
624
+ console.log(`${indent} ${cmd.cmd}`);
625
+ } else {
626
+ console.log(`${indent} ${cmd.cmd}`);
627
+ if (cmd.note) {
628
+ console.log(`${indent} → ${cmd.note}`);
629
+ }
630
+ }
631
+ }
632
+
633
+ if (suggestion.why) {
634
+ console.log(`${indent} 💭 ${suggestion.why}`);
635
+ }
636
+
637
+ console.log('');
638
+ }
639
+
640
+ // Helper: Try to read file, return null on error
641
+ function tryReadFile(filePath) {
642
+ try {
643
+ return fs.readFileSync(filePath, 'utf8');
644
+ } catch (err) {
645
+ if (err.code !== 'ENOENT') {
646
+ console.error(`Error reading file "${filePath}":`, err.message);
647
+ }
648
+ return null;
649
+ }
650
+ }
651
+
652
+ // Run if called directly
653
+ if (require.main === module) {
654
+ whatNext().catch(err => {
655
+ logError('Error executing what-next command', err);
656
+ process.exit(1);
657
+ });
658
+ }
659
+
660
+ module.exports = whatNext;
package/bin/autopm.js CHANGED
@@ -291,7 +291,9 @@ function main() {
291
291
  autopm team reset # Reset to default team
292
292
 
293
293
  💡 Claude Code PM Commands:
294
+ /pm:what-next # ⭐ Smart suggestions for what to do next
294
295
  /pm:status # Project overview and health
296
+ /pm:context # Show current project context and progress
295
297
  /pm:validate # Validate configuration
296
298
  /pm:prd-new feature-name # Create new Product Requirements Document
297
299
  /pm:prd-parse feature-name # Parse PRD into epic structure
@@ -305,6 +307,29 @@ function main() {
305
307
  /pm:search keyword # Search across PRDs and epics
306
308
  /pm:help # Show all PM commands
307
309
 
310
+ 📋 PM Workflow Decision Guide:
311
+
312
+ WHEN TO USE ONE EPIC (/pm:epic-decompose):
313
+ ✅ Simple feature (1-2 weeks)
314
+ ✅ Single component (frontend OR backend)
315
+ ✅ One developer
316
+ Examples: "User profile page", "REST API endpoint"
317
+
318
+ WHEN TO USE MULTIPLE EPICS (/pm:epic-split):
319
+ ✅ Complex project (2+ months)
320
+ ✅ Multiple components (frontend + backend + infra)
321
+ ✅ Multiple teams working in parallel
322
+ Examples: "E-commerce platform", "Social dashboard"
323
+
324
+ SIMPLE FEATURE FLOW:
325
+ /pm:prd-new feature → /pm:prd-parse feature → /pm:epic-decompose feature
326
+
327
+ COMPLEX PROJECT FLOW:
328
+ /pm:prd-new project → /pm:prd-parse project → /pm:epic-split project
329
+ → /pm:epic-decompose project/01-epic1 → /pm:epic-decompose project/02-epic2 ...
330
+
331
+ 📖 Full Guide: See PM-WORKFLOW-GUIDE.md
332
+
308
333
  🚀 Complete Workflows:
309
334
 
310
335
  === GITHUB WORKFLOW (PRD → Epic → Issues) ===