pmp-gywd 3.3.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 (126) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +567 -0
  3. package/bin/install.js +348 -0
  4. package/commands/gywd/add-phase.md +207 -0
  5. package/commands/gywd/anticipate.md +271 -0
  6. package/commands/gywd/bootstrap.md +336 -0
  7. package/commands/gywd/challenge.md +344 -0
  8. package/commands/gywd/check-drift.md +144 -0
  9. package/commands/gywd/complete-milestone.md +106 -0
  10. package/commands/gywd/consider-issues.md +202 -0
  11. package/commands/gywd/context.md +93 -0
  12. package/commands/gywd/create-roadmap.md +115 -0
  13. package/commands/gywd/deps.md +169 -0
  14. package/commands/gywd/digest.md +138 -0
  15. package/commands/gywd/discuss-milestone.md +47 -0
  16. package/commands/gywd/discuss-phase.md +60 -0
  17. package/commands/gywd/execute-plan.md +161 -0
  18. package/commands/gywd/extract-decisions.md +325 -0
  19. package/commands/gywd/health.md +150 -0
  20. package/commands/gywd/help.md +556 -0
  21. package/commands/gywd/history.md +278 -0
  22. package/commands/gywd/impact.md +317 -0
  23. package/commands/gywd/init.md +95 -0
  24. package/commands/gywd/insert-phase.md +227 -0
  25. package/commands/gywd/list-phase-assumptions.md +50 -0
  26. package/commands/gywd/map-codebase.md +84 -0
  27. package/commands/gywd/memory.md +159 -0
  28. package/commands/gywd/new-milestone.md +59 -0
  29. package/commands/gywd/new-project.md +315 -0
  30. package/commands/gywd/pause-work.md +123 -0
  31. package/commands/gywd/plan-fix.md +205 -0
  32. package/commands/gywd/plan-phase.md +93 -0
  33. package/commands/gywd/preview-plan.md +139 -0
  34. package/commands/gywd/profile.md +363 -0
  35. package/commands/gywd/progress.md +317 -0
  36. package/commands/gywd/remove-phase.md +338 -0
  37. package/commands/gywd/research-phase.md +91 -0
  38. package/commands/gywd/resume-work.md +40 -0
  39. package/commands/gywd/rollback.md +179 -0
  40. package/commands/gywd/status.md +42 -0
  41. package/commands/gywd/sync-github.md +234 -0
  42. package/commands/gywd/verify-work.md +71 -0
  43. package/commands/gywd/why.md +251 -0
  44. package/docs/COMMANDS.md +722 -0
  45. package/docs/CONTRIBUTING.md +342 -0
  46. package/docs/EXAMPLES.md +535 -0
  47. package/docs/GETTING-STARTED.md +262 -0
  48. package/docs/README.md +55 -0
  49. package/docs/RELEASING.md +159 -0
  50. package/get-your-work-done/core/agent-patterns.md +331 -0
  51. package/get-your-work-done/core/architecture.md +334 -0
  52. package/get-your-work-done/core/context-model-schema.json +154 -0
  53. package/get-your-work-done/core/decisions-schema.json +193 -0
  54. package/get-your-work-done/core/learning-state-schema.json +133 -0
  55. package/get-your-work-done/core/profile-schema.json +257 -0
  56. package/get-your-work-done/references/adaptive-decomposition.md +175 -0
  57. package/get-your-work-done/references/checkpoints.md +287 -0
  58. package/get-your-work-done/references/confidence-scoring.md +169 -0
  59. package/get-your-work-done/references/continuation-format.md +255 -0
  60. package/get-your-work-done/references/git-integration.md +254 -0
  61. package/get-your-work-done/references/plan-format.md +428 -0
  62. package/get-your-work-done/references/principles.md +157 -0
  63. package/get-your-work-done/references/questioning.md +162 -0
  64. package/get-your-work-done/references/research-pitfalls.md +215 -0
  65. package/get-your-work-done/references/scope-estimation.md +172 -0
  66. package/get-your-work-done/references/tdd.md +263 -0
  67. package/get-your-work-done/templates/codebase/architecture.md +255 -0
  68. package/get-your-work-done/templates/codebase/concerns.md +310 -0
  69. package/get-your-work-done/templates/codebase/conventions.md +307 -0
  70. package/get-your-work-done/templates/codebase/integrations.md +280 -0
  71. package/get-your-work-done/templates/codebase/stack.md +186 -0
  72. package/get-your-work-done/templates/codebase/structure.md +285 -0
  73. package/get-your-work-done/templates/codebase/testing.md +480 -0
  74. package/get-your-work-done/templates/config.json +18 -0
  75. package/get-your-work-done/templates/context.md +161 -0
  76. package/get-your-work-done/templates/continue-here.md +78 -0
  77. package/get-your-work-done/templates/discovery.md +146 -0
  78. package/get-your-work-done/templates/issues.md +32 -0
  79. package/get-your-work-done/templates/milestone-archive.md +123 -0
  80. package/get-your-work-done/templates/milestone-context.md +93 -0
  81. package/get-your-work-done/templates/milestone.md +115 -0
  82. package/get-your-work-done/templates/phase-prompt.md +303 -0
  83. package/get-your-work-done/templates/project.md +184 -0
  84. package/get-your-work-done/templates/research.md +529 -0
  85. package/get-your-work-done/templates/roadmap.md +196 -0
  86. package/get-your-work-done/templates/state.md +210 -0
  87. package/get-your-work-done/templates/summary.md +273 -0
  88. package/get-your-work-done/templates/uat-issues.md +143 -0
  89. package/get-your-work-done/workflows/complete-milestone.md +643 -0
  90. package/get-your-work-done/workflows/create-milestone.md +416 -0
  91. package/get-your-work-done/workflows/create-roadmap.md +481 -0
  92. package/get-your-work-done/workflows/discovery-phase.md +293 -0
  93. package/get-your-work-done/workflows/discuss-milestone.md +236 -0
  94. package/get-your-work-done/workflows/discuss-phase.md +247 -0
  95. package/get-your-work-done/workflows/execute-phase.md +1625 -0
  96. package/get-your-work-done/workflows/list-phase-assumptions.md +178 -0
  97. package/get-your-work-done/workflows/map-codebase.md +434 -0
  98. package/get-your-work-done/workflows/plan-phase.md +488 -0
  99. package/get-your-work-done/workflows/research-phase.md +436 -0
  100. package/get-your-work-done/workflows/resume-project.md +287 -0
  101. package/get-your-work-done/workflows/transition.md +580 -0
  102. package/get-your-work-done/workflows/verify-work.md +202 -0
  103. package/lib/automation/dependency-analyzer.js +635 -0
  104. package/lib/automation/doc-generator.js +643 -0
  105. package/lib/automation/index.js +42 -0
  106. package/lib/automation/test-generator.js +628 -0
  107. package/lib/context/context-analyzer.js +554 -0
  108. package/lib/context/context-cache.js +426 -0
  109. package/lib/context/context-predictor.js +622 -0
  110. package/lib/context/index.js +44 -0
  111. package/lib/memory/confidence-calibrator.js +484 -0
  112. package/lib/memory/feedback-collector.js +551 -0
  113. package/lib/memory/global-memory.js +465 -0
  114. package/lib/memory/index.js +75 -0
  115. package/lib/memory/pattern-aggregator.js +487 -0
  116. package/lib/memory/team-sync.js +501 -0
  117. package/lib/profile/index.js +24 -0
  118. package/lib/profile/pattern-learner.js +303 -0
  119. package/lib/profile/profile-manager.js +445 -0
  120. package/lib/questioning/index.js +49 -0
  121. package/lib/questioning/question-engine.js +311 -0
  122. package/lib/questioning/question-templates.js +315 -0
  123. package/lib/validators/command-validator.js +188 -0
  124. package/lib/validators/index.js +29 -0
  125. package/lib/validators/schema-validator.js +183 -0
  126. package/package.json +61 -0
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: GYWD:discuss-milestone
3
+ description: Gather context for next milestone through adaptive questioning
4
+ ---
5
+
6
+ <objective>
7
+ Help you figure out what to build in the next milestone through collaborative thinking.
8
+
9
+ Purpose: After completing a milestone, explore what features you want to add, improve, or fix. Features first — scope and phases derive from what you want to build.
10
+ Output: Context gathered, then routes to /gywd:new-milestone
11
+ </objective>
12
+
13
+ <execution_context>
14
+ @~/.claude/get-your-work-done/workflows/discuss-milestone.md
15
+ </execution_context>
16
+
17
+ <context>
18
+ **Load project state first:**
19
+ @.planning/STATE.md
20
+
21
+ **Load roadmap:**
22
+ @.planning/ROADMAP.md
23
+
24
+ **Load milestones (if exists):**
25
+ @.planning/MILESTONES.md
26
+ </context>
27
+
28
+ <process>
29
+ 1. Verify previous milestone complete (or acknowledge active milestone)
30
+ 2. Present context from previous milestone (accomplishments, phase count)
31
+ 3. Follow discuss-milestone.md workflow with **ALL questions using AskUserQuestion**:
32
+ - Use AskUserQuestion: "What do you want to add, improve, or fix?" with feature categories
33
+ - Use AskUserQuestion to dig into features they mention
34
+ - Use AskUserQuestion to help them articulate what matters most
35
+ - Use AskUserQuestion for decision gate (ready / ask more / let me add context)
36
+ 4. Hand off to /gywd:new-milestone with gathered context
37
+
38
+ **CRITICAL: ALL questions use AskUserQuestion. Never ask inline text questions.**
39
+ </process>
40
+
41
+ <success_criteria>
42
+
43
+ - Project state loaded and presented
44
+ - Previous milestone context summarized
45
+ - Milestone scope gathered through adaptive questioning
46
+ - Context handed off to /gywd:new-milestone
47
+ </success_criteria>
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: GYWD:discuss-phase
3
+ description: Gather phase context through adaptive questioning before planning
4
+ argument-hint: "[phase]"
5
+ ---
6
+
7
+ <objective>
8
+ Help the user articulate their vision for a phase through collaborative thinking.
9
+
10
+ Purpose: Understand HOW the user imagines this phase working — what it looks like, what's essential, what's out of scope. You're a thinking partner helping them crystallize their vision, not an interviewer gathering technical requirements.
11
+
12
+ Output: {phase}-CONTEXT.md capturing the user's vision for the phase
13
+ </objective>
14
+
15
+ <execution_context>
16
+ @~/.claude/get-your-work-done/workflows/discuss-phase.md
17
+ @~/.claude/get-your-work-done/templates/context.md
18
+ </execution_context>
19
+
20
+ <context>
21
+ Phase number: $ARGUMENTS (required)
22
+
23
+ **Load project state first:**
24
+ @.planning/STATE.md
25
+
26
+ **Load roadmap:**
27
+ @.planning/ROADMAP.md
28
+ </context>
29
+
30
+ <process>
31
+ 1. Validate phase number argument (error if missing or invalid)
32
+ 2. Check if phase exists in roadmap
33
+ 3. Check if CONTEXT.md already exists (offer to update if yes)
34
+ 4. Follow discuss-phase.md workflow with **ALL questions using AskUserQuestion**:
35
+ - Present phase from roadmap
36
+ - Use AskUserQuestion: "How do you imagine this working?" with interpretation options
37
+ - Use AskUserQuestion to follow their thread — probe what excites them
38
+ - Use AskUserQuestion to sharpen the core — what's essential for THIS phase
39
+ - Use AskUserQuestion to find boundaries — what's explicitly out of scope
40
+ - Use AskUserQuestion for decision gate (ready / ask more / let me add context)
41
+ - Create CONTEXT.md capturing their vision
42
+ 5. Offer next steps (research or plan the phase)
43
+
44
+ **CRITICAL: ALL questions use AskUserQuestion. Never ask inline text questions.**
45
+
46
+ User is the visionary, you are the builder:
47
+ - Ask about vision, feel, essential outcomes
48
+ - DON'T ask about technical risks (you figure those out)
49
+ - DON'T ask about codebase patterns (you read the code)
50
+ - DON'T ask about success metrics (too corporate)
51
+ - DON'T interrogate about constraints they didn't mention
52
+ </process>
53
+
54
+ <success_criteria>
55
+
56
+ - Phase validated against roadmap
57
+ - Vision gathered through collaborative thinking (not interrogation)
58
+ - CONTEXT.md captures: how it works, what's essential, what's out of scope
59
+ - User knows next steps (research or plan the phase)
60
+ </success_criteria>
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: GYWD:execute-plan
3
+ description: Execute a PLAN.md file (supports partial execution with --tasks)
4
+ argument-hint: "[path-to-PLAN.md] [--tasks 1-3 or --tasks 2,4,5]"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ - Task
13
+ - AskUserQuestion
14
+ - SlashCommand
15
+ ---
16
+
17
+ <objective>
18
+ Execute a PLAN.md file with per-task atomic commits, create SUMMARY.md, update project state.
19
+
20
+ Commit strategy:
21
+ - Each task → 1 commit immediately after completion (feat/fix/test/refactor)
22
+ - Plan completion → 1 metadata commit (docs: SUMMARY + STATE + ROADMAP)
23
+
24
+ Uses intelligent segmentation:
25
+ - Plans without checkpoints → spawn subagent for full autonomous execution
26
+ - Plans with verify checkpoints → segment execution, pause at checkpoints
27
+ - Plans with decision checkpoints → execute in main context
28
+ </objective>
29
+
30
+ <execution_context>
31
+ @~/.claude/get-your-work-done/workflows/execute-phase.md
32
+ @~/.claude/get-your-work-done/templates/summary.md
33
+ @~/.claude/get-your-work-done/references/checkpoints.md
34
+ @~/.claude/get-your-work-done/references/tdd.md
35
+ </execution_context>
36
+
37
+ <context>
38
+ Plan path and options: $ARGUMENTS
39
+
40
+ **Argument parsing:**
41
+ - Path: First argument (required) - path to PLAN.md
42
+ - --tasks: Optional task filter
43
+ - Range format: `--tasks 1-3` (tasks 1, 2, 3)
44
+ - List format: `--tasks 2,4,5` (specific tasks)
45
+ - Single: `--tasks 3` (just task 3)
46
+
47
+ **Examples:**
48
+ - `/gywd:execute-plan .planning/phases/01-foundation/01-01-PLAN.md`
49
+ - `/gywd:execute-plan .planning/phases/01-foundation/01-01-PLAN.md --tasks 1-3`
50
+ - `/gywd:execute-plan --tasks 4,5` (uses current plan from STATE.md)
51
+
52
+ **Load project state first:**
53
+ @.planning/STATE.md
54
+
55
+ **Load workflow config:**
56
+ @.planning/config.json
57
+ </context>
58
+
59
+ <process>
60
+ 1. Parse arguments:
61
+ - Extract plan path (or auto-detect from STATE.md)
62
+ - Parse --tasks flag if present:
63
+ - `--tasks 1-3` → [1, 2, 3]
64
+ - `--tasks 2,4,5` → [2, 4, 5]
65
+ - `--tasks 3` → [3]
66
+ - If no --tasks flag: execute all tasks
67
+
68
+ 2. Check .planning/ directory exists (error if not - user should run /gywd:new-project)
69
+
70
+ 3. Verify plan exists
71
+
72
+ 4. If --tasks specified (partial execution):
73
+ - Show: "Partial execution: Tasks {list}"
74
+ - Skip tasks not in the list
75
+ - Mark partial completion in STATE.md
76
+ - Create partial SUMMARY.md with note about which tasks were executed
77
+ - DO NOT mark plan as complete unless all tasks done
78
+
79
+ 5. If no --tasks (full execution):
80
+ - Check if SUMMARY.md already exists (plan already executed?)
81
+
82
+ 6. Load workflow config for mode (interactive/yolo)
83
+
84
+ 7. Follow execute-phase.md workflow:
85
+ - Parse plan and determine execution strategy (A/B/C)
86
+ - Execute tasks (via subagent or main context as appropriate)
87
+ - Handle checkpoints and deviations
88
+ - Create SUMMARY.md
89
+ - Update STATE.md
90
+ - Commit changes
91
+ </process>
92
+
93
+ <execution_strategies>
94
+ **Strategy A: Fully Autonomous** (no checkpoints)
95
+
96
+ - Spawn subagent to execute entire plan
97
+ - Subagent creates SUMMARY.md and commits
98
+ - Main context: orchestration only (~5% usage)
99
+
100
+ **Strategy B: Segmented** (has verify-only checkpoints)
101
+
102
+ - Execute in segments between checkpoints
103
+ - Subagent for autonomous segments
104
+ - Main context for checkpoints
105
+ - Aggregate results → SUMMARY → commit
106
+
107
+ **Strategy C: Decision-Dependent** (has decision checkpoints)
108
+
109
+ - Execute in main context
110
+ - Decision outcomes affect subsequent tasks
111
+ - Quality maintained through small scope (2-3 tasks per plan)
112
+ </execution_strategies>
113
+
114
+ <deviation_rules>
115
+ During execution, handle discoveries automatically:
116
+
117
+ 1. **Auto-fix bugs** - Fix immediately, document in Summary
118
+ 2. **Auto-add critical** - Security/correctness gaps, add and document
119
+ 3. **Auto-fix blockers** - Can't proceed without fix, do it and document
120
+ 4. **Ask about architectural** - Major structural changes, stop and ask user
121
+ 5. **Log enhancements** - Nice-to-haves, log to ISSUES.md, continue
122
+
123
+ Only rule 4 requires user intervention.
124
+ </deviation_rules>
125
+
126
+ <commit_rules>
127
+ **Per-Task Commits:**
128
+
129
+ After each task completes:
130
+ 1. Stage only files modified by that task
131
+ 2. Commit with format: `{type}({phase}-{plan}): {task-name}`
132
+ 3. Types: feat, fix, test, refactor, perf, chore
133
+ 4. Record commit hash for SUMMARY.md
134
+
135
+ **Plan Metadata Commit:**
136
+
137
+ After all tasks complete:
138
+ 1. Stage planning artifacts only: PLAN.md, SUMMARY.md, STATE.md, ROADMAP.md
139
+ 2. Commit with format: `docs({phase}-{plan}): complete [plan-name] plan`
140
+ 3. NO code files (already committed per-task)
141
+
142
+ **NEVER use:**
143
+ - `git add .`
144
+ - `git add -A`
145
+ - `git add src/` or any broad directory
146
+
147
+ **Always stage files individually.**
148
+
149
+ See ~/.claude/get-your-work-done/references/git-integration.md for full commit strategy.
150
+ </commit_rules>
151
+
152
+ <success_criteria>
153
+
154
+ - [ ] All tasks executed
155
+ - [ ] Each task committed individually (feat/fix/test/refactor)
156
+ - [ ] SUMMARY.md created with substantive content and commit hashes
157
+ - [ ] STATE.md updated (position, decisions, issues, session)
158
+ - [ ] ROADMAP updated (plan count, phase status)
159
+ - [ ] Metadata committed with docs({phase}-{plan}): complete [plan-name] plan
160
+ - [ ] User informed of next steps
161
+ </success_criteria>
@@ -0,0 +1,325 @@
1
+ ---
2
+ name: GYWD:extract-decisions
3
+ description: Extract decision graph from codebase history
4
+ argument-hint: "[--depth shallow|deep] [--since <date>] [--path <dir>]"
5
+ allowed-tools:
6
+ - Read
7
+ - Bash
8
+ - Write
9
+ - Glob
10
+ - Grep
11
+ - Task
12
+ ---
13
+
14
+ <objective>
15
+ Parse git history, PR descriptions, code comments, and documentation to extract a **decision graph** - a structured representation of WHY code exists, not just WHAT it does.
16
+
17
+ This is the foundation for decision-aware AI assistance.
18
+ </objective>
19
+
20
+ <philosophy>
21
+ Code is not text. Code is crystallized decisions.
22
+
23
+ Every line represents:
24
+ - A decision made with context we may have lost
25
+ - Trade-offs that were considered
26
+ - Alternatives that were rejected
27
+ - Constraints that were respected
28
+
29
+ By extracting these decisions explicitly, we enable:
30
+ - "Why does this exist?" queries with real answers
31
+ - Change impact analysis based on decision dependencies
32
+ - Drift detection between intent and implementation
33
+ - AI suggestions that respect decision coherence
34
+ </philosophy>
35
+
36
+ <decision_schema>
37
+ Each extracted decision follows this structure:
38
+
39
+ ```yaml
40
+ decision:
41
+ id: "DEC-001"
42
+ title: "Use Result<T,E> pattern for error handling"
43
+ type: "architectural|implementation|convention|constraint"
44
+
45
+ # When and who
46
+ date: "2024-03-15"
47
+ author: "@developer"
48
+ source: "commit:abc123|pr:47|comment:file.ts:42|doc:ARCHITECTURE.md"
49
+
50
+ # The decision itself
51
+ choice: "Adopted Result pattern from utils/result.ts"
52
+ context: "Needed error propagation without exceptions in async code"
53
+
54
+ # What was considered
55
+ alternatives:
56
+ - option: "try-catch blocks"
57
+ rejected_because: "Verbose, loses type information"
58
+ - option: "null returns"
59
+ rejected_because: "Ambiguous, null means multiple things"
60
+
61
+ trade_offs:
62
+ - gain: "Type-safe error handling"
63
+ cost: "More verbose call sites"
64
+ - gain: "Explicit error paths"
65
+ cost: "Learning curve for new developers"
66
+
67
+ # Confidence in extraction
68
+ confidence: 94 # percent
69
+ confidence_factors:
70
+ - "Explicitly documented in PR description (+40)"
71
+ - "Consistent usage across codebase (+30)"
72
+ - "Author comment explaining rationale (+24)"
73
+
74
+ # What this affects
75
+ affects:
76
+ files: ["src/services/*.ts", "src/utils/result.ts"]
77
+ decisions: ["DEC-003", "DEC-007"] # downstream
78
+ depends_on: ["DEC-000"] # upstream
79
+
80
+ # Metadata
81
+ status: "active|superseded|reverted"
82
+ superseded_by: null
83
+ tags: ["error-handling", "typescript", "patterns"]
84
+ ```
85
+ </decision_schema>
86
+
87
+ <extraction_sources>
88
+ ## Source Priority (highest to lowest confidence)
89
+
90
+ ### 1. Explicit Documentation (90-100% confidence)
91
+ - Architecture Decision Records (ADRs)
92
+ - DECISIONS.md or similar files
93
+ - Inline comments with "Decision:", "Why:", "Rationale:"
94
+ - PR descriptions with explicit reasoning
95
+
96
+ ### 2. Commit Messages (60-85% confidence)
97
+ - Commits starting with "feat:", "refactor:", "fix:"
98
+ - Commit bodies explaining reasoning
99
+ - Breaking change annotations
100
+ - References to issues/discussions
101
+
102
+ ### 3. Code Patterns (40-70% confidence)
103
+ - Consistent usage implying convention
104
+ - Deviation from language defaults
105
+ - Custom abstractions that replace standard patterns
106
+ - Configuration choices
107
+
108
+ ### 4. Temporal Inference (30-50% confidence)
109
+ - Refactoring patterns (A→B→C evolution)
110
+ - Reverted commits (tried and rejected)
111
+ - File co-evolution (always changed together)
112
+ </extraction_sources>
113
+
114
+ <process>
115
+ ## Phase 1: Source Collection
116
+
117
+ 1. **Parse arguments:**
118
+ - `--depth shallow`: Last 100 commits only
119
+ - `--depth deep`: Full history (default)
120
+ - `--since <date>`: Start from date
121
+ - `--path <dir>`: Focus on specific directory
122
+
123
+ 2. **Gather explicit sources:**
124
+ ```bash
125
+ # Find ADRs and decision docs
126
+ find . -name "*.md" | xargs grep -l -i "decision\|rationale\|why we"
127
+
128
+ # Find annotated comments
129
+ grep -r "Decision:\|Why:\|Rationale:\|DECISION:" --include="*.ts" --include="*.js" --include="*.py"
130
+ ```
131
+
132
+ 3. **Parse git history:**
133
+ ```bash
134
+ # Commits with context
135
+ git log --format="%H|%an|%ad|%s" --date=short
136
+
137
+ # PR merge commits
138
+ git log --merges --format="%H|%s|%b"
139
+
140
+ # Refactoring commits
141
+ git log --grep="refactor" --format="%H|%s|%b"
142
+ ```
143
+
144
+ ## Phase 2: Decision Extraction
145
+
146
+ For each source, use LLM to extract structured decisions:
147
+
148
+ **Prompt template:**
149
+ ```
150
+ Analyze this [commit/PR/comment/doc] and extract any decisions made.
151
+
152
+ Source:
153
+ {content}
154
+
155
+ For each decision found, provide:
156
+ 1. What was decided
157
+ 2. Why (context, constraints, goals)
158
+ 3. What alternatives were considered (if mentioned)
159
+ 4. What trade-offs were accepted (if mentioned)
160
+ 5. Confidence level in this extraction (1-100)
161
+
162
+ Focus on:
163
+ - Architectural choices (patterns, structures, dependencies)
164
+ - Convention choices (naming, organization, style)
165
+ - Technology choices (libraries, tools, frameworks)
166
+ - Constraint choices (what we deliberately don't do)
167
+ ```
168
+
169
+ ## Phase 3: Graph Construction
170
+
171
+ 1. **Link decisions:**
172
+ - Parse "affects" from file paths
173
+ - Detect decision dependencies (A required B)
174
+ - Find supersession chains (A replaced by B)
175
+
176
+ 2. **Calculate aggregate confidence:**
177
+ - Multiple sources confirming = higher confidence
178
+ - Contradictory sources = flag for review
179
+ - No sources but strong pattern = inferred decision
180
+
181
+ 3. **Identify gaps:**
182
+ - Code with no traceable decisions
183
+ - Decisions with no code (orphaned)
184
+ - Conflicting decisions
185
+
186
+ ## Phase 4: Output Generation
187
+
188
+ Create `.planning/decisions/` structure:
189
+
190
+ ```
191
+ .planning/decisions/
192
+ ├── DECISIONS.md # Human-readable summary
193
+ ├── decision-graph.json # Machine-readable graph
194
+ ├── confidence-report.md # Extraction quality metrics
195
+ └── gaps.md # Identified gaps for review
196
+ ```
197
+ </process>
198
+
199
+ <output_format>
200
+ ## DECISIONS.md Structure
201
+
202
+ ```markdown
203
+ # Decision Graph: {project-name}
204
+
205
+ **Extracted:** {date}
206
+ **Commits analyzed:** {count}
207
+ **Decisions found:** {count}
208
+ **Average confidence:** {percent}
209
+
210
+ ---
211
+
212
+ ## Architectural Decisions
213
+
214
+ ### DEC-001: Result Pattern for Error Handling [94%]
215
+
216
+ **Decided:** 2024-03-15 by @developer
217
+ **Source:** PR #47, commit abc123
218
+
219
+ **Choice:** Use `Result<T,E>` pattern from `utils/result.ts`
220
+
221
+ **Context:**
222
+ > Needed error propagation without exceptions. Async code made try-catch unwieldy.
223
+
224
+ **Alternatives Considered:**
225
+ | Option | Rejected Because |
226
+ |--------|------------------|
227
+ | try-catch | Verbose, loses type info |
228
+ | null returns | Ambiguous semantics |
229
+
230
+ **Trade-offs:**
231
+ - ✅ Type-safe errors
232
+ - ✅ Explicit error paths
233
+ - ⚠️ Verbose call sites
234
+ - ⚠️ Learning curve
235
+
236
+ **Affects:** 47 files in src/services/, src/utils/
237
+
238
+ ---
239
+
240
+ ### DEC-002: ...
241
+
242
+ ---
243
+
244
+ ## Convention Decisions
245
+
246
+ ### DEC-010: ...
247
+
248
+ ---
249
+
250
+ ## Inferred Decisions (Lower Confidence)
251
+
252
+ These decisions were inferred from patterns, not explicit sources.
253
+ Review recommended.
254
+
255
+ ### DEC-050: Barrel exports in each module [45%]
256
+
257
+ **Inferred from:** Consistent pattern across 23 modules
258
+ **No explicit source found**
259
+
260
+ ---
261
+
262
+ ## Decision Gaps
263
+
264
+ The following code areas have no traceable decisions:
265
+
266
+ | Path | Lines | Risk |
267
+ |------|-------|------|
268
+ | src/legacy/ | 2,400 | High - no history |
269
+ | src/utils/crypto.ts | 180 | Medium - security-sensitive |
270
+
271
+ ---
272
+
273
+ ## Graph Statistics
274
+
275
+ - Total decisions: 67
276
+ - Architectural: 12
277
+ - Implementation: 34
278
+ - Convention: 15
279
+ - Constraint: 6
280
+
281
+ - High confidence (>80%): 23
282
+ - Medium confidence (50-80%): 31
283
+ - Low confidence (<50%): 13
284
+
285
+ - Decision chains (A→B→C): 8
286
+ - Superseded decisions: 5
287
+ - Reverted decisions: 2
288
+ ```
289
+ </output_format>
290
+
291
+ <integration>
292
+ ## How Decision Graph Integrates with GYWD
293
+
294
+ ### During Planning (/gywd:plan-phase)
295
+ - Load relevant decisions for the phase
296
+ - Ensure plan respects existing decisions
297
+ - Flag when plan conflicts with decisions
298
+ - Suggest decisions to document
299
+
300
+ ### During Execution (/gywd:execute-plan)
301
+ - Validate changes against decision constraints
302
+ - Auto-document new decisions from commits
303
+ - Detect decision drift
304
+
305
+ ### During Review (/gywd:challenge)
306
+ - Adversarial agents reference decisions
307
+ - "This violates DEC-012" as concrete feedback
308
+ - Decision coherence scoring
309
+
310
+ ### Queries
311
+ - `/gywd:why <file/function>` → Trace to decisions
312
+ - `/gywd:impact <decision>` → Show downstream effects
313
+ - `/gywd:conflicts` → Find contradictory decisions
314
+ </integration>
315
+
316
+ <success_criteria>
317
+ - [ ] Parses git history for decision signals
318
+ - [ ] Extracts ADRs and explicit documentation
319
+ - [ ] Infers decisions from code patterns
320
+ - [ ] Calculates confidence scores
321
+ - [ ] Links decisions into graph structure
322
+ - [ ] Creates queryable DECISIONS.md
323
+ - [ ] Identifies gaps for review
324
+ - [ ] Generates machine-readable JSON
325
+ </success_criteria>