ai-workflow-init 1.3.0 → 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/README.md CHANGED
@@ -7,24 +7,44 @@ Initialize standardized AI workflow docs and command templates into ANY reposito
7
7
  > Requires: [Node.js](https://nodejs.org/) (>= 14)
8
8
 
9
9
  Run in the root of your target project:
10
+
10
11
  ```bash
11
12
  npx ai-workflow-init
12
13
  ```
13
- This will automatically fetch and place:
14
+
15
+ The installer will prompt you to select which AI tool(s) to configure:
16
+
17
+ - **1. Cursor** → installs `.cursor/commands` and `.cursor/prompts`
18
+ - **2. GitHub Copilot** → installs `.github/prompts`
19
+ - **3. Both** → installs both command sets and prompts
20
+
21
+ All installations include:
22
+
14
23
  - `docs/ai` (planning, implementation, testing, project standards)
15
- - `.cursor/commands` (AI agent commands)
16
- - `AGENTS.md`
24
+ - `AGENTS.md` with rules and workflow overview
25
+
26
+ ## Smart Installation Features
27
+
28
+ - **Protected Files**: Core documentation files (`CODE_CONVENTIONS.md`, `PROJECT_STRUCTURE.md`) are never overwritten if they already exist
29
+ - **Selective Updates**: Only `template-feature.md` and `README.md` files are updated in each documentation subfolder
30
+ - **Safe Cloning**: Uses temporary directories to ensure no data loss
17
31
 
18
32
  ## Notes
33
+
19
34
  - Works on Windows (PowerShell/CMD/Git Bash), macOS, and Linux.
20
- - If the destination folders already exist, the installer will overwrite files as needed.
21
35
  - After installation, commit the new files to your repository so your team can use them.
22
36
 
23
37
  ## What gets installed
24
- - Documentation templates and guides under `docs/ai/`
25
- - AI agent commands under `.cursor/commands/`
26
- - `AGENTS.md` with rules and workflow overview
38
+
39
+ - **Always installed**:
40
+ - Documentation templates and guides under `docs/ai/`
41
+ - `AGENTS.md` with rules and workflow overview
42
+ - **Based on your choice**:
43
+ - `.cursor/commands/` and `.cursor/prompts/` (if Cursor is selected)
44
+ - `.github/prompts/` (if GitHub Copilot is selected)
27
45
 
28
46
  ## Troubleshooting
47
+
29
48
  - Ensure Node.js is installed and accessible in your PATH.
30
49
  - If your network blocks npm registry calls, try again on a different network or with a VPN.
50
+ - Ensure you have write permissions in your project directory.
package/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { execSync } = require("child_process");
4
- const { existsSync, mkdirSync } = require("fs");
4
+ const { existsSync, mkdirSync, rmSync, cpSync, readdirSync } = require("fs");
5
5
  const readline = require("readline");
6
+ const path = require("path");
6
7
 
7
8
  // Repo workflow gốc của bạn
8
9
  const REPO = "phananhtuan09/ai-agent-workflow";
@@ -23,20 +24,157 @@ function run(cmd) {
23
24
  }
24
25
  }
25
26
 
26
- // Hỏi user chọn IDE
27
- const rl = readline.createInterface({
28
- input: process.stdin,
29
- output: process.stdout,
30
- });
27
+ // Clone folder luôn ghi đè
28
+ function cloneFolderForce(source, dest) {
29
+ mkdirSync(path.dirname(dest), { recursive: true });
30
+ const tempDir = path.join(dest, ".temp-clone");
31
+
32
+ // Xóa temp folder nếu tồn tại
33
+ if (existsSync(tempDir)) {
34
+ rmSync(tempDir, { recursive: true, force: true });
35
+ }
36
+
37
+ run(`npx degit ${source} ${tempDir} --force`);
38
+
39
+ // Tạo dest folder nếu chưa có
40
+ if (!existsSync(dest)) {
41
+ mkdirSync(dest, { recursive: true });
42
+ }
43
+
44
+ // Copy tất cả files từ temp vào dest (ghi đè toàn bộ)
45
+ const filesToCopy = execSync(`find ${tempDir} -type f`, { encoding: "utf8" })
46
+ .trim()
47
+ .split("\n")
48
+ .filter(Boolean);
49
+
50
+ for (const file of filesToCopy) {
51
+ const relativePath = path.relative(tempDir, file);
52
+ const destFile = path.join(dest, relativePath);
53
+
54
+ // Tạo folder nếu cần
55
+ mkdirSync(path.dirname(destFile), { recursive: true });
56
+
57
+ // Copy file với ghi đè
58
+ cpSync(file, destFile, { force: true });
59
+ }
60
+
61
+ // Xóa temp folder
62
+ rmSync(tempDir, { recursive: true, force: true });
63
+ }
64
+
65
+ // Clone folder docs/ai một cách an toàn
66
+ function cloneDocsAI(source, dest) {
67
+ mkdirSync(dest, { recursive: true });
68
+ const tempDir = path.join(dest, ".temp-clone");
69
+
70
+ // Xóa temp folder nếu tồn tại
71
+ if (existsSync(tempDir)) {
72
+ rmSync(tempDir, { recursive: true, force: true });
73
+ }
74
+
75
+ run(`npx degit ${source} ${tempDir} --force`);
76
+
77
+ // Xử lý từng subfolder
78
+ const subfolders = ["implementation", "planning", "testing"];
79
+
80
+ // Xử lý folders: implementation, planning, testing
81
+ for (const subfolder of subfolders) {
82
+ const tempSubfolder = path.join(tempDir, subfolder);
83
+ const destSubfolder = path.join(dest, subfolder);
84
+
85
+ if (existsSync(tempSubfolder)) {
86
+ mkdirSync(destSubfolder, { recursive: true });
87
+
88
+ // Chỉ copy file template và README.md
89
+ const filesToCopy = ["README.md", "feature-template.md"];
90
+
91
+ for (const file of filesToCopy) {
92
+ const srcFile = path.join(tempSubfolder, file);
93
+ const destFile = path.join(destSubfolder, file);
31
94
 
95
+ if (existsSync(srcFile)) {
96
+ cpSync(srcFile, destFile, { force: true });
97
+ }
98
+ }
99
+ }
100
+ }
101
+
102
+ // Xử lý folder: project
103
+ const tempProject = path.join(tempDir, "project");
104
+ const destProject = path.join(dest, "project");
105
+
106
+ if (existsSync(tempProject)) {
107
+ mkdirSync(destProject, { recursive: true });
108
+
109
+ // 1. Chỉ tạo CODE_CONVENTIONS.md và PROJECT_STRUCTURE.md nếu chưa có
110
+ const protectedFiles = [
111
+ "CODE_CONVENTIONS.md",
112
+ "PROJECT_STRUCTURE.md",
113
+ "README.md",
114
+ ];
115
+
116
+ for (const file of protectedFiles) {
117
+ const srcFile = path.join(tempProject, file);
118
+ const destFile = path.join(destProject, file);
119
+
120
+ if (existsSync(srcFile)) {
121
+ // Nếu là CODE_CONVENTIONS.md hoặc PROJECT_STRUCTURE.md, chỉ tạo nếu chưa có
122
+ if (
123
+ (file === "CODE_CONVENTIONS.md" || file === "PROJECT_STRUCTURE.md") &&
124
+ existsSync(destFile)
125
+ ) {
126
+ console.log(`⏭️ Skipping (already exists): docs/ai/project/${file}`);
127
+ continue;
128
+ }
129
+
130
+ // Các file khác luôn ghi đè
131
+ cpSync(srcFile, destFile, { force: true });
132
+ }
133
+ }
134
+
135
+ // 2. Ghi đè folder template-convention
136
+ const tempTemplateConvention = path.join(
137
+ tempProject,
138
+ "template-convention"
139
+ );
140
+ const destTemplateConvention = path.join(
141
+ destProject,
142
+ "template-convention"
143
+ );
144
+
145
+ if (existsSync(tempTemplateConvention)) {
146
+ // Xóa folder cũ nếu tồn tại
147
+ if (existsSync(destTemplateConvention)) {
148
+ rmSync(destTemplateConvention, { recursive: true, force: true });
149
+ }
150
+
151
+ // Copy folder mới
152
+ cpSync(tempTemplateConvention, destTemplateConvention, {
153
+ recursive: true,
154
+ force: true,
155
+ });
156
+ }
157
+ }
158
+
159
+ // Xóa temp folder
160
+ rmSync(tempDir, { recursive: true, force: true });
161
+ }
162
+
163
+ // Hỏi user chọn IDE
32
164
  function askIDE() {
165
+ const rl = readline.createInterface({
166
+ input: process.stdin,
167
+ output: process.stdout,
168
+ });
169
+
33
170
  return new Promise((resolve) => {
34
171
  console.log("\n🤖 Which AI tool(s) do you want to setup?");
35
172
  console.log("1. Cursor");
36
173
  console.log("2. GitHub Copilot");
37
- console.log("3. Both");
174
+ console.log("3. Claude Code");
175
+ console.log("4. All");
38
176
 
39
- rl.question("\nEnter your choice (1-3): ", (answer) => {
177
+ rl.question("\nEnter your choice (1-4): ", (answer) => {
40
178
  rl.close();
41
179
  resolve(answer.trim());
42
180
  });
@@ -45,23 +183,20 @@ function askIDE() {
45
183
 
46
184
  async function main() {
47
185
  const choice = await askIDE();
48
- const installCursor = ["1", "3"].includes(choice);
49
- 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);
50
189
 
51
- if (!["1", "2", "3"].includes(choice)) {
52
- 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.");
53
192
  process.exit(1);
54
193
  }
55
194
 
56
- // Kiểm tra tạo folder nếu chưa
57
- if (!existsSync("docs/ai")) {
58
- mkdirSync("docs/ai", { recursive: true });
59
- }
60
-
195
+ // Clone docs/ai một cách an toàn, bảo vệ các file quan trọng
61
196
  step("🚚 Downloading workflow template (docs/ai)...");
62
- run(`npx degit ${REPO}/docs/ai docs/ai --force`);
197
+ cloneDocsAI(`${REPO}/docs/ai`, "docs/ai");
63
198
 
64
- // Clone Cursor commands
199
+ // Clone Cursor commands (luôn ghi đè)
65
200
  if (installCursor) {
66
201
  if (!existsSync(".cursor/commands")) {
67
202
  mkdirSync(".cursor/commands", { recursive: true });
@@ -70,16 +205,35 @@ async function main() {
70
205
  run(`npx degit ${REPO}/.cursor/commands .cursor/commands --force`);
71
206
  }
72
207
 
73
- // Clone GitHub Copilot commands (nếu folder khác)
208
+ // Clone GitHub Copilot prompts (luôn ghi đè)
74
209
  if (installCopilot) {
75
- if (!existsSync(".copilot/commands")) {
76
- mkdirSync(".copilot/commands", { recursive: true });
210
+ if (!existsSync(".github/prompts")) {
211
+ mkdirSync(".github/prompts", { recursive: true });
212
+ }
213
+ step("🚚 Downloading GitHub Copilot prompts (.github/prompts)...");
214
+ run(`npx degit ${REPO}/.github/prompts .github/prompts --force`);
215
+ }
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
+
226
+ // Clone Cursor prompts (luôn ghi đè)
227
+ if (installCursor) {
228
+ if (!existsSync(".cursor/prompts")) {
229
+ mkdirSync(".cursor/prompts", { recursive: true });
77
230
  }
78
- step("🚚 Downloading GitHub Copilot agent commands (.copilot/commands)...");
79
- run(`npx degit ${REPO}/.copilot/commands .copilot/commands --force`);
231
+ step("🚚 Downloading Cursor prompts (.cursor/prompts)...");
232
+ run(`npx degit ${REPO}/.cursor/prompts .cursor/prompts --force`);
80
233
  }
81
234
 
82
- step("🚚 Downloading AGENTS.md ...");
235
+ // Download AGENTS.md (luôn ghi đè)
236
+ step("🚚 Downloading AGENTS.md...");
83
237
  try {
84
238
  run(`curl -fsSL ${RAW_BASE}/AGENTS.md -o AGENTS.md`);
85
239
  } catch (_) {
@@ -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.0",
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"