ai-workflow-init 1.3.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.
@@ -71,19 +71,56 @@ Auto-name feature:
71
71
  - Example: "Login Page (HTML/CSS)" → `feature-login-page`.
72
72
  - If a file with the same name already exists, append a numeric suffix: `feature-{name}-2`, `feature-{name}-3`, ...
73
73
 
74
- Create the following files automatically and populate initial content:
74
+ ### 3a: Generate Planning Doc
75
75
 
76
- - `docs/ai/planning/feature-{name}.md` - Use structure from `feature-template.md`
77
- - `docs/ai/implementation/feature-{name}.md` - Use structure from `docs/ai/implementation/feature-template.md` (read this template before writing)
78
-
79
- Notify the user when done.
76
+ Produce a Markdown doc following `docs/ai/planning/feature-template.md`:
80
77
 
81
- Produce a Markdown doc following the template structure:
82
-
83
- - Match sections from `docs/ai/planning/feature-template.md`
78
+ - Match sections from template
84
79
  - Fill in content from Q&A inputs
85
80
  - Ensure all required sections are present
86
81
 
82
+ ### 3b: Generate Implementation Doc with Phases
83
+
84
+ Before creating implementation doc, read `docs/ai/implementation/feature-template.md` to understand phase structure.
85
+
86
+ **Estimate phase scope**:
87
+ - Count total tasks from planning doc
88
+ - If tasks ≤ 5: use single phase named "Core Implementation"
89
+ - If tasks 6–12: suggest 2–3 phases (group by feature area or dependency order)
90
+ - If tasks > 12: suggest 3–5 phases; prioritize logical grouping
91
+
92
+ **For each phase, generate**:
93
+ - Phase name (descriptive, e.g., "Database Schema Setup", "API Endpoints", "UI Components")
94
+ - Tasks list: `[ ] [ACTION] path/to/file — Summary`
95
+ - Pseudo-code outline (show logic structure, not real code):
96
+ ```
97
+ Pseudo-code:
98
+ - [Step 1]: what will be done
99
+ - [Step 2]: validation or check
100
+ - [Step 3]: data storage/return
101
+ ```
102
+
103
+ **Pseudo-code guidelines**:
104
+ - Keep to 3–5 lines per task
105
+ - Show inputs, key logic, outputs
106
+ - Use natural language, not actual syntax
107
+ - Example for "Create user endpoint":
108
+ ```
109
+ Pseudo-code:
110
+ - Parse username + password from request
111
+ - Validate password strength
112
+ - Hash password with bcrypt
113
+ - Store user in database
114
+ - Return success + user ID
115
+ ```
116
+
117
+ Create the following files automatically:
118
+
119
+ - `docs/ai/planning/feature-{name}.md` - Use structure from `feature-template.md`
120
+ - `docs/ai/implementation/feature-{name}.md` - Use phase structure with pseudo-code per task
121
+
122
+ Notify the user when done with summary: "Created plan with X phases: Phase 1 (name), Phase 2 (name), ..."
123
+
87
124
  ## Step 4: Next Actions
88
125
 
89
126
  Suggest running `execute-plan` to begin task execution. Implementation work will be driven from `docs/ai/implementation/feature-{name}.md` as the task source.
@@ -21,15 +21,39 @@ Execute the feature plan by implementing tasks from the implementation doc and p
21
21
  - Load implementation doc: `docs/ai/implementation/feature-{name}.md`.
22
22
  - **Load template:** Read `docs/ai/implementation/feature-template.md` to understand required structure.
23
23
 
24
+ ### 1a: Phase Progress Detection
25
+
26
+ If implementation doc exists, scan for phase markers (`### Phase X:`):
27
+
28
+ - **Count total phases** in the document
29
+ - **Detect last completed phase**: Find the highest phase where ALL tasks (checkbox `[x]`) are marked complete
30
+ - **Detect current phase**: Find the first phase with incomplete tasks (`[ ]` marks)
31
+ - **Show summary to user**:
32
+
33
+ ```
34
+ Found 3 phases.
35
+ - Phase 1 (Database Setup): Complete [x]
36
+ - Phase 2 (API Endpoints): In Progress [2/4 tasks done]
37
+ - Phase 3 (Frontend): Not Started
38
+
39
+ Resuming Phase 2...
40
+ ```
41
+
42
+ If no phases detected (old format):
43
+
44
+ - Treat entire "Changes" section as single phase (backward compatible)
45
+
24
46
  ## Step 2: Build Task Queue
25
47
 
26
- - Parse tasks (checkboxes `[ ]`, `[x]`) from the implementation doc:
27
- - Primary source: `## Changes` section with `[ ] [ACTION] ...` entries.
48
+ - Parse tasks (checkboxes `[ ]`, `[x]`) from **current phase only** (from phase detection in Step 1a):
49
+ - Primary source: Tasks under `### Phase X:` with `[ ] [ACTION] ...` entries (incomplete only).
28
50
  - For `[MODIFIED]` files, parse sub-bullets representing distinct logic items with line ranges.
29
- - Optionally include other `[ ]` sections (e.g., `## Follow-ups`) if designated in-scope.
51
+ - **Skip completed phases** entirely (do not re-execute)
30
52
  - Build prioritized task queue (top-to-bottom unless dependencies block).
31
53
  - Identify blocked tasks and note reasons.
32
54
 
55
+ Note: Do not include Follow-ups section unless explicitly in current phase.
56
+
33
57
  ## Step 3: Implement Iteratively (per task)
34
58
 
35
59
  For each task in queue:
@@ -92,14 +116,37 @@ After completing Step 4 for each task batch:
92
116
  - Go/Rust/Java: rely on compiler/type system via build step
93
117
  - Parallelize lint and type-check when safe; fix issues (up to 3 attempts) before proceeding.
94
118
 
95
- ## Step 6: Next Actions
119
+ ## Step 6: Phase Completion Check (NEW)
120
+
121
+ After completing all tasks in current phase:
122
+
123
+ 1. **Mark phase complete** in implementation doc (optional visual marker)
124
+ 2. **Check remaining phases**:
125
+ - If more incomplete phases exist:
126
+ ```
127
+ ✓ Phase 2 complete!
128
+ Ready for Phase 3 (Frontend)?
129
+ Run: /execute-plan
130
+ ```
131
+ - If this is final phase:
132
+ ```
133
+ ✓ All phases complete!
134
+ Ready for code review?
135
+ Run: /code-review
136
+ ```
96
137
 
97
- After completing tasks:
138
+ ## Step 7: Next Actions
139
+
140
+ After all phases complete:
98
141
 
99
142
  - Suggest running `code-review` to verify against standards
100
143
  - Suggest running `writing-test` if edge cases need coverage
101
144
  - Suggest running `check-implementation` to validate alignment with implementation entries
102
145
 
146
+ If phases remain:
147
+
148
+ - User runs `/execute-plan` again; Phase detection (Step 1a) will resume correctly
149
+
103
150
  ## Notes
104
151
 
105
152
  - Keep code changes minimal and focused on implementation tasks
@@ -0,0 +1,190 @@
1
+ ## Goal
2
+
3
+ Modify a feature plan after partial/full implementation. Support reverting to a previous git state or applying new requirement changes with both code and documentation sync.
4
+
5
+ ## Prerequisites
6
+
7
+ - Feature name (kebab-case, e.g., `user-authentication`)
8
+ - Planning doc exists: `docs/ai/planning/feature-{name}.md`
9
+ - Implementation doc exists: `docs/ai/implementation/feature-{name}.md`
10
+ - Git repo initialized (for tracking code state)
11
+
12
+ ## Workflow Alignment
13
+
14
+ - Provide brief status updates (1–3 sentences) before/after important actions.
15
+ - Update both planning and implementation docs when making changes.
16
+ - Do NOT auto-commit; user reviews all changes before pushing.
17
+
18
+ ## Step 1: Load Current State
19
+
20
+ Ask for feature name (must be kebab-case).
21
+
22
+ Load and summarize:
23
+
24
+ 1. **Planning doc**: Current goal, scope, tasks overview
25
+ 2. **Implementation doc**: Current phases, completion status, files affected
26
+
27
+ Display summary:
28
+
29
+ ```
30
+ Feature: user-authentication
31
+ Plan: Create user login + registration endpoints
32
+
33
+ Implementation Progress:
34
+ - Phase 1 (Database): Complete [x]
35
+ Files: src/db/schema.ts
36
+ - Phase 2 (API Endpoints): In Progress [3/4]
37
+ Files: src/api/users.ts, src/api/auth.ts
38
+ - Phase 3 (Frontend): Not Started [ ]
39
+ Files: src/components/Login.tsx
40
+
41
+ Total files touched: 4
42
+ ```
43
+
44
+ ## Step 2: Scope of Change (Q&A)
45
+
46
+ Ask user what's changing:
47
+
48
+ **1. Type of modification:**
49
+ a) Modify goal/scope (entire plan changes)
50
+ b) Modify specific phase(s) (tactical change)
51
+ c) Revert to previous approach (manual revert)
52
+ d) Other (describe)
53
+
54
+ **2a. If modifying goal/scope:**
55
+ - What's the new goal/scope?
56
+ - How does it impact existing tasks?
57
+
58
+ **2b. If modifying specific phase(s):**
59
+ - Which phase(s)? (list by name)
60
+ - What requirement/approach is changing?
61
+
62
+ **2c. If reverting approach:**
63
+ - Which phase to revert?
64
+ - Or revert all code changes after phase X?
65
+
66
+ ## Step 3: Apply Changes
67
+
68
+ ### Option A: Revert to Previous Approach (Manual)
69
+
70
+ If user selects revert:
71
+
72
+ 1. **Identify affected files & changes**:
73
+ - Parse implementation doc; list all files modified in affected phase(s)
74
+ - Show file list that needs reverting:
75
+ ```
76
+ Files to revert (manual):
77
+ - src/api/users.ts (lines 45–120)
78
+ - src/db/schema.ts (lines 10–30)
79
+ - tests/api.test.ts (delete entire file)
80
+ ```
81
+
82
+ 2. **Manual revert guidance**:
83
+ - For MODIFIED files: show current state vs. target state (code snippets/line ranges)
84
+ - For DELETED files: ask user to delete manually
85
+ - Ask: "Ready to manually revert these files?"
86
+
87
+ 3. **If user confirms**:
88
+ - User manually reverts files (copy-paste old code back, undo in IDE, etc.)
89
+ - Update implementation doc:
90
+ - Mark affected phases/tasks `[ ]` (reset to pending)
91
+ - Add "Modification History" entry:
92
+ ```
93
+ ## Modification History
94
+
95
+ ### Revert [Date]: {Reason}
96
+ - **Reverted phases**: Phase X, Y
97
+ - **Reason**: [user provided]
98
+ - **Files manually reverted**: [list]
99
+ - **Affected tasks reset**: [ ] Task 1, [ ] Task 2, ...
100
+ ```
101
+
102
+ 4. **Result**: Docs updated; tasks reset; ready to re-implement with new approach
103
+
104
+ ### Option B: Apply New Changes
105
+
106
+ If user selects new approach:
107
+
108
+ 1. **Update planning doc**:
109
+ - Modify goal/scope section if changed
110
+ - Update affected task(s) with new approach
111
+ - Add "Modification History" section:
112
+ ```
113
+ ## Modification History
114
+
115
+ ### Change [Date]: {Title}
116
+ - **Previous approach**: [original details]
117
+ - **New approach**: [new details]
118
+ - **Reason**: [user provided]
119
+ - **Affected phases**: Phase X, Y
120
+ ```
121
+
122
+ 2. **Update implementation doc**:
123
+ - For affected phases:
124
+ - Modify pseudo-code to match new approach
125
+ - Reset incomplete tasks `[ ]` (if approach changed significantly)
126
+ - Keep completed tasks as-is (do not re-implement)
127
+ - Update "Changes" section with new structure (files/logic outline)
128
+
129
+ 3. **Show git impact**:
130
+ - Highlight files that may need re-editing
131
+ - Ask: "Ready to re-implement with new approach?" (yes/no)
132
+
133
+ ## Step 4: Confirmation & Audit Trail
134
+
135
+ Before finalizing, show:
136
+
137
+ 1. **Updated planning doc** snippet (modified sections)
138
+ 2. **Updated implementation doc** snippet (phase changes, pseudo-code)
139
+ 3. **Files affected** (files that will be changed)
140
+
141
+ Ask: **"Apply changes and update docs?"** (yes/no)
142
+
143
+ If **yes**:
144
+ - Save updated docs
145
+ - If revert: User manually reverts files (code state updated)
146
+ - If new approach: docs updated; ready for re-implementation
147
+
148
+ If **no**:
149
+ - Rollback changes to docs
150
+ - Discard any temporary changes
151
+
152
+ ## Step 5: Next Actions
153
+
154
+ **After manual revert**:
155
+ - "Docs updated. Affected tasks reset to `[ ]`. Run `/execute-plan` to re-implement Phase X with new approach."
156
+
157
+ **After apply new approach**:
158
+ - If only pseudo-code/docs changed (no code revert needed): "Continue current phase with `/execute-plan`."
159
+ - If code changes needed (revert old approach + implement new): "Manually update code files first, then run `/execute-plan`."
160
+ - "When done, run `/code-review` to validate standards."
161
+
162
+ ## Important Notes
163
+
164
+ - **Manual revert**: User manually reverts code files (no git reset); AI guides the process
165
+ - **Multi-feature safe**: Works when implementing multiple features simultaneously (selective revert possible)
166
+ - **Backward compatible**: Works with both phase-based and non-phase-based implementation docs
167
+ - **Audit trail**: "Modification History" section preserves decision rationale and affected files
168
+ - **Idempotent**: Safe to re-run; modification history accumulates
169
+ - **Safe defaults**: Asks confirmation before any changes; user always has final say
170
+
171
+ ## Example Flow
172
+
173
+ ```
174
+ User: I want to modify plan
175
+ Agent: Load state, show summary
176
+
177
+ User: Revert Phase 2 (API Endpoints) - use different auth approach
178
+ Agent: Identify affected files (src/api/users.ts, src/api/auth.ts)
179
+ Show current state vs. target state (pseudo-code + old implementation)
180
+ Ask: Ready to manually revert these files?
181
+
182
+ User: Yes, I'll manually revert
183
+ Agent: (User manually copies old code back or undoes changes in IDE)
184
+ Update implementation doc:
185
+ - Mark Phase 2 tasks [ ] (reset)
186
+ - Add Modification History: Phase 2 reverted, reason: better auth strategy
187
+
188
+ Agent: Phase 2 reset. Ready to re-implement with new auth approach?
189
+ Run: /execute-plan
190
+ ```
package/cli.js CHANGED
@@ -171,9 +171,10 @@ function askIDE() {
171
171
  console.log("\n🤖 Which AI tool(s) do you want to setup?");
172
172
  console.log("1. Cursor");
173
173
  console.log("2. GitHub Copilot");
174
- console.log("3. Both");
174
+ console.log("3. Claude Code");
175
+ console.log("4. All");
175
176
 
176
- rl.question("\nEnter your choice (1-3): ", (answer) => {
177
+ rl.question("\nEnter your choice (1-4): ", (answer) => {
177
178
  rl.close();
178
179
  resolve(answer.trim());
179
180
  });
@@ -182,11 +183,12 @@ function askIDE() {
182
183
 
183
184
  async function main() {
184
185
  const choice = await askIDE();
185
- const installCursor = ["1", "3"].includes(choice);
186
- const installCopilot = ["2", "3"].includes(choice);
186
+ const installCursor = ["1", "4"].includes(choice);
187
+ const installCopilot = ["2", "4"].includes(choice);
188
+ const installClaudeCode = ["3", "4"].includes(choice);
187
189
 
188
- if (!["1", "2", "3"].includes(choice)) {
189
- console.error("❌ Invalid choice. Please enter 1, 2, or 3.");
190
+ if (!["1", "2", "3", "4"].includes(choice)) {
191
+ console.error("❌ Invalid choice. Please enter 1, 2, 3, or 4.");
190
192
  process.exit(1);
191
193
  }
192
194
 
@@ -212,6 +214,15 @@ async function main() {
212
214
  run(`npx degit ${REPO}/.github/prompts .github/prompts --force`);
213
215
  }
214
216
 
217
+ // Clone Claude Code commands (luôn ghi đè)
218
+ if (installClaudeCode) {
219
+ if (!existsSync(".claude/commands")) {
220
+ mkdirSync(".claude/commands", { recursive: true });
221
+ }
222
+ step("🚚 Downloading Claude Code commands (.claude/commands)...");
223
+ run(`npx degit ${REPO}/.claude/commands .claude/commands --force`);
224
+ }
225
+
215
226
  // Clone Cursor prompts (luôn ghi đè)
216
227
  if (installCursor) {
217
228
  if (!existsSync(".cursor/prompts")) {
@@ -8,13 +8,35 @@ Note: All content in this document must be written in English.
8
8
 
9
9
  ## Changes
10
10
 
11
+ ### Phase 1: [Phase Name]
12
+
11
13
  - [ ] [ACTION] path/to/file (lines: x–y) — Summary of change
14
+ ```
15
+ Pseudo-code:
16
+ - function/logic outline
17
+ - key variables/state
18
+ ```
12
19
  - [ ] [ACTION] path/to/file (lines: a–b) — Summary of change
20
+ ```
21
+ Pseudo-code:
22
+ - logic structure
23
+ ```
24
+
25
+ ### Phase 2: [Phase Name]
26
+
27
+ - [ ] [ACTION] path/to/file — Summary of change
28
+ ```
29
+ Pseudo-code:
30
+ - ...
31
+ ```
13
32
 
14
33
  Notes:
15
34
 
16
35
  - ACTION must be one of: ADDED | MODIFIED | DELETED | RENAMED
17
36
  - For MODIFIED files, use sub-bullets for each distinct logic change and include line ranges.
37
+ - Pseudo-code shows logic structure and key steps, not actual implementation code.
38
+ - Each phase groups related tasks; phases execute sequentially.
39
+ - Use only one phase for small features (≤ 5 tasks); use multiple phases for larger features.
18
40
 
19
41
  ## Edge Cases
20
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-workflow-init",
3
- "version": "1.3.1",
3
+ "version": "2.0.0",
4
4
  "description": "Initialize AI workflow docs & commands into any repo with one command",
5
5
  "bin": {
6
6
  "ai-workflow-init": "./cli.js"