@relipa/ai-flow-kit 0.0.4 → 0.0.5-beta.1

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 (41) hide show
  1. package/{docs/README.md → README.md} +25 -18
  2. package/bin/aiflow.js +77 -7
  3. package/custom/skills/{validate-ticket → read-study-requirement}/SKILL.md +27 -17
  4. package/custom/skills/review-plan/SKILL.md +1 -1
  5. package/custom/templates/shared/gate-workflow.md +88 -75
  6. package/custom/templates/tools/claude.md +1 -1
  7. package/custom/templates/tools/copilot.md +1 -1
  8. package/custom/templates/tools/cursor.md +1 -1
  9. package/custom/templates/tools/gemini.md +1 -1
  10. package/custom/templates/tools/generic.md +1 -1
  11. package/docs/{AIFLOW.md → common/AIFLOW.md} +462 -458
  12. package/docs/{CHANGELOG.md → common/CHANGELOG.md} +132 -100
  13. package/docs/{cli-reference.md → common/cli-reference.md} +98 -28
  14. package/docs/{troubleshooting.md → common/troubleshooting.md} +15 -0
  15. package/docs/project/ARCHITECTURE.md +28 -0
  16. package/package.json +7 -5
  17. package/scripts/context.js +1 -1
  18. package/scripts/guide.js +16 -0
  19. package/scripts/hooks/session-start.js +145 -141
  20. package/scripts/init.js +168 -44
  21. package/scripts/prompt.js +431 -402
  22. package/scripts/telemetry/cli.js +243 -0
  23. package/scripts/telemetry/config.js +91 -0
  24. package/scripts/telemetry/crypto.js +20 -0
  25. package/scripts/telemetry/flush.js +162 -0
  26. package/scripts/telemetry/record.js +138 -0
  27. package/scripts/use.js +74 -31
  28. package/upstream/skills/using-superpowers/SKILL.md +14 -0
  29. package/docs/IMPLEMENTATION_SUMMARY.md +0 -330
  30. package/docs/architecture.md +0 -394
  31. package/docs/developer-overview.md +0 -126
  32. package/upstream/tests/brainstorm-server/package-lock.json +0 -36
  33. /package/docs/{QUICK_START.md → common/QUICK_START.md} +0 -0
  34. /package/docs/{ai-integration.md → common/ai-integration.md} +0 -0
  35. /package/docs/{configuration.md → common/configuration.md} +0 -0
  36. /package/docs/{getting-started.md → common/getting-started.md} +0 -0
  37. /package/docs/{workflows → common/workflows}/bug-fix.md +0 -0
  38. /package/docs/{workflows → common/workflows}/feature.md +0 -0
  39. /package/docs/{workflows → common/workflows}/impact-analysis.md +0 -0
  40. /package/docs/{workflows → common/workflows}/investigation.md +0 -0
  41. /package/docs/{workflows → common/workflows}/refactor.md +0 -0
@@ -21,13 +21,13 @@ Developers only need a single command to load ticket context → AI automaticall
21
21
  ## Documentation & Guides
22
22
 
23
23
  > [!TIP]
24
- > After running `aiflow init`, all documentation files are automatically copied to your project root and `.aiflow/docs/` for easy access.
24
+ > After running `aiflow init`, documentation files are automatically copied to `.aiflow/docs/` in your project for easy access.
25
25
 
26
- - **[Quick Start Guide](./QUICK_START.md)** — Step-by-step instructions for developers.
27
- - **[Full Workflow (5 Gates)](./AIFLOW.md)** — In-depth look at the Gate process.
28
- - **[Developer Onboarding](./developer-overview.md)** — Presentation-ready guide for new team members.
29
- - **[Troubleshooting](./troubleshooting.md)** — Common issues and fixes.
30
- - **[Integration Guide](./ai-integration.md)** — Advanced tool setup (Claude, Cursor, Gemini).
26
+ - **[Quick Start Guide](./docs/common/QUICK_START.md)** — Step-by-step instructions for developers.
27
+ - **[Full Workflow (5 Gates)](./docs/common/AIFLOW.md)** — In-depth look at the Gate process.
28
+ - **[Troubleshooting](./docs/common/troubleshooting.md)** — Common issues and fixes.
29
+ - **[Integration Guide](./docs/common/ai-integration.md)** — Advanced tool setup (Claude, Cursor, Gemini).
30
+ - **[Changelog](./docs/common/CHANGELOG.md)** — Version history and release notes.
31
31
 
32
32
  ---
33
33
 
@@ -50,8 +50,10 @@ Developers only need a single command to load ticket context → AI automaticall
50
50
  │ .claude/ │
51
51
  │ ├── skills/ ← superpowers + custom│
52
52
  │ ├── hooks/ ← SessionStart hook │
53
- ├── settings.json ← hook config │
54
- └── context/ ← ticket context
53
+ └── settings.json ← hook config │
54
+ .aiflow/
55
+ │ ├── context/ ← ticket context │
56
+ │ └── versions/ ← versioned skills │
55
57
  │ .rules/ ← team rules (java/) │
56
58
  │ CLAUDE.md ← framework template │
57
59
  │ .mcp.json ← MCP adapter config │
@@ -122,6 +124,7 @@ npm uninstall -g @relipa/ai-flow-kit
122
124
  | `aiflow init` | Setup framework, adapters, and multi-AI rules. |
123
125
  | `aiflow use <ticket>` | Load ticket context (Backlog/Jira). |
124
126
  | `aiflow prompt` | Generate tool-optimized prompts (`--env cursor`). |
127
+ | `aiflow telemetry` | Manage telemetry tracking (enable/disable/status). |
125
128
  | `aiflow guide` | View integrated multi-AI integration guide. |
126
129
 
127
130
  ### `aiflow init`
@@ -228,9 +231,9 @@ aiflow validate src/Payment.java --ruleset strict
228
231
  Save/search team knowledge.
229
232
 
230
233
  ```bash
231
- aiflow memory --save "payment-flow" "Payment flow description..."
232
- aiflow memory --search "payment"
233
- aiflow memory --list
234
+ aiflow memory save "payment-flow" "Payment flow description..."
235
+ aiflow memory search "payment"
236
+ aiflow memory list
234
237
  ```
235
238
 
236
239
  ---
@@ -280,13 +283,17 @@ aiflow memory --list
280
283
 
281
284
  ```
282
285
  ai-flow-kit/
286
+ ├── README.md # Main documentation
283
287
  ├── bin/aiflow.js # CLI entry
284
- ├── docs/ # Documentation and Guides
285
- │ ├── README.md # Main documentation
286
- │ ├── QUICK_START.md # Quick start guide
287
- │ ├── AIFLOW.md # Workflow (5 Gates) detail
288
- │ ├── CHANGELOG.md # Version history
289
- └── ... # Other guides
288
+ ├── docs/
289
+ │ ├── common/ # Published with package
290
+ ├── QUICK_START.md # Quick start guide
291
+ ├── AIFLOW.md # Workflow (5 Gates) detail
292
+ ├── CHANGELOG.md # Version history
293
+ │ ├── cli-reference.md # Full CLI reference
294
+ │ │ └── workflows/ # Per-task workflow guides
295
+ │ └── project/ # Project template files
296
+ │ └── ARCHITECTURE.md # Architecture doc template
290
297
  ├── scripts/
291
298
  │ ├── init.js # Project initialization
292
299
  │ ├── update.js # Version management
@@ -352,4 +359,4 @@ aiflow init --adapter backlog
352
359
  aiflow doctor
353
360
  ```
354
361
 
355
- See more: [docs/troubleshooting.md](./troubleshooting.md)
362
+ See more: [docs/common/troubleshooting.md](./docs/common/troubleshooting.md)
package/bin/aiflow.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const { program } = require('commander');
4
4
  const chalk = require('chalk');
@@ -14,11 +14,45 @@ const contextCommand = require('../scripts/context');
14
14
  const promptCommand = require('../scripts/prompt');
15
15
  const removeCommand = require('../scripts/remove');
16
16
  const guideCommand = require('../scripts/guide');
17
+ const telemetryCommand= require('../scripts/telemetry/cli');
18
+ const { record } = require('../scripts/telemetry/record');
17
19
 
18
20
  program
19
21
  .version(packageJson.version)
20
22
  .description('AI Flow Kit CLI - AI-powered development workflows for teams');
21
23
 
24
+ // ── GLOBAL TELEMETRY HOOK ────────────────────────────────────
25
+ // We intercept raw argv here so we can catch --version, --help,
26
+ // and invalid commands *before* Commander exits the process.
27
+ (() => {
28
+ const args = process.argv.slice(2);
29
+ let cmd = 'help';
30
+ if (args.length > 0) {
31
+ const first = args[0];
32
+ if (['-V', '-v', '--version'].includes(first)) {
33
+ cmd = 'version';
34
+ } else if (['-h', '--help'].includes(first)) {
35
+ cmd = 'help';
36
+ } else if (first.startsWith('-')) {
37
+ cmd = 'unknown_flag';
38
+ if (args.includes('--help') || args.includes('-h')) cmd = 'help';
39
+ } else if (first === 'memory') {
40
+ const sec = args[1];
41
+ cmd = (sec && !sec.startsWith('-')) ? `memory.${sec}` : 'memory';
42
+ } else {
43
+ cmd = first;
44
+ if (args.includes('--help') || args.includes('-h')) {
45
+ cmd = `${first}.help`;
46
+ }
47
+ }
48
+ }
49
+ // Record everything except telemetry and gate actions (gate records its own rich event)
50
+ if (cmd !== 'telemetry' && !cmd.startsWith('telemetry.') && cmd !== 'gate') {
51
+ record('command.invoked', { command: cmd });
52
+ }
53
+ })();
54
+
55
+
22
56
  // ── init ──────────────────────────────────────────────────────
23
57
  program
24
58
  .command('init')
@@ -37,6 +71,7 @@ program
37
71
  ? options.env.split(',').map(s => s.trim()).filter(Boolean)
38
72
  : Object.keys(require('../scripts/init').AI_TOOL_FILES || {});
39
73
 
74
+ record('command.invoked', { command: 'init' });
40
75
  initCommand(options);
41
76
  });
42
77
 
@@ -51,6 +86,7 @@ program
51
86
  .option('--comments-last <n>', 'load only the last N comments', parseInt)
52
87
  .option('--comments-from <n>', 'load comments from index N onward (0-based)', parseInt)
53
88
  .action((target, options) => {
89
+ record('command.invoked', { command: 'use' });
54
90
  useCommand(target, options);
55
91
  });
56
92
 
@@ -63,6 +99,7 @@ program
63
99
  .option('--lang <lang>', 'language: english (default) or vietnamese')
64
100
  .option('--detail <level>', 'detail level: minimal | standard (default) | comprehensive')
65
101
  .action((type, options) => {
102
+ record('command.invoked', { command: 'prompt' });
66
103
  promptCommand(type, options);
67
104
  });
68
105
 
@@ -73,6 +110,7 @@ program
73
110
  .option('-v, --verbose', 'show detection details')
74
111
  .option('-t, --threshold <number>', 'confidence threshold (0-100)')
75
112
  .action((description, options) => {
113
+ record('command.invoked', { command: 'detect' });
76
114
  const detector = new TaskDetector();
77
115
  const threshold = options.threshold ? parseInt(options.threshold) / 100 : 0.8;
78
116
  const result = detector.detect(description, threshold);
@@ -90,6 +128,7 @@ program
90
128
  .option('--clear', 'clear all saved contexts')
91
129
  .option('--show', 'show current context')
92
130
  .action((action, options) => {
131
+ record('command.invoked', { command: 'context' });
93
132
  contextCommand(action, options);
94
133
  });
95
134
 
@@ -101,6 +140,7 @@ program
101
140
  .option('-v, --verbose', 'detailed report')
102
141
  .option('--fix', 'auto-fix trailing whitespace')
103
142
  .action((file, options) => {
143
+ record('command.invoked', { command: 'validate' });
104
144
  validateCommand(file, {
105
145
  ruleset: options.ruleset,
106
146
  verbose: options.verbose,
@@ -115,32 +155,32 @@ const memCmd = program.command('memory').description('Manage team knowledge and
115
155
  memCmd
116
156
  .command('save <key> <value>')
117
157
  .description('Save a memory entry')
118
- .action((key, value) => memoryCommand('save', { key, value }));
158
+ .action((key, value) => { record('command.invoked', { command: 'memory.save' }); memoryCommand('save', { key, value }); });
119
159
 
120
160
  memCmd
121
161
  .command('get <key>')
122
162
  .description('Retrieve a memory entry')
123
- .action((key) => memoryCommand('get', { key }));
163
+ .action((key) => { record('command.invoked', { command: 'memory.get' }); memoryCommand('get', { key }); });
124
164
 
125
165
  memCmd
126
166
  .command('list')
127
167
  .description('List all memories')
128
- .action(() => memoryCommand('list'));
168
+ .action(() => { record('command.invoked', { command: 'memory.list' }); memoryCommand('list'); });
129
169
 
130
170
  memCmd
131
171
  .command('search <query>')
132
172
  .description('Search memories by keyword')
133
- .action((query) => memoryCommand('search', { query }));
173
+ .action((query) => { record('command.invoked', { command: 'memory.search' }); memoryCommand('search', { query }); });
134
174
 
135
175
  memCmd
136
176
  .command('delete <key>')
137
177
  .description('Delete a memory entry')
138
- .action((key) => memoryCommand('delete', { key }));
178
+ .action((key) => { record('command.invoked', { command: 'memory.delete' }); memoryCommand('delete', { key }); });
139
179
 
140
180
  memCmd
141
181
  .command('clear')
142
182
  .description('Clear all memories')
143
- .action(() => memoryCommand('clear'));
183
+ .action(() => { record('command.invoked', { command: 'memory.clear' }); memoryCommand('clear'); });
144
184
 
145
185
  // ── guide ─────────────────────────────────────────────────────
146
186
  program
@@ -149,9 +189,28 @@ program
149
189
  .option('--flow', 'show architecture & flow diagram only')
150
190
  .option('--commands', 'show command reference only')
151
191
  .action((options) => {
192
+ record('command.invoked', { command: 'guide' });
152
193
  guideCommand(options);
153
194
  });
154
195
 
196
+ // ── gate (telemetry for gate workflow events) ─────────────────
197
+ program
198
+ .command('gate <number> <action>')
199
+ .description('Log a gate workflow event (start|approved) — called by AI during gate workflow')
200
+ .option('--ticket <id>', 'ticket ID')
201
+ .option('--ai-tool <tool>', 'AI tool name')
202
+ .action((number, action, options) => {
203
+ const gateNum = parseInt(number);
204
+ if (isNaN(gateNum) || gateNum < 1 || gateNum > 5) return;
205
+ if (!['start', 'approved'].includes(action)) return;
206
+ record(`gate.${action}`, {
207
+ gate: gateNum,
208
+ ticket_id: options.ticket || '',
209
+ command: `gate${gateNum}.${action}`,
210
+ ai_tool: options.aiTool || ''
211
+ });
212
+ });
213
+
155
214
  // ── remove ────────────────────────────────────────────────────
156
215
  program
157
216
  .command('remove')
@@ -159,6 +218,7 @@ program
159
218
  .option('--version <ver>', 'remove a specific cached version from .aiflow/versions/')
160
219
  .option('--global', 'uninstall the global npm package (removes `aiflow` command)')
161
220
  .action((options) => {
221
+ record('command.invoked', { command: 'remove' });
162
222
  removeCommand(options);
163
223
  });
164
224
 
@@ -168,6 +228,7 @@ program
168
228
  .description('Update to latest version')
169
229
  .option('--force', 'force update even if already on latest')
170
230
  .action((options) => {
231
+ record('command.invoked', { command: 'update' });
171
232
  updateCommand(options);
172
233
  });
173
234
 
@@ -177,7 +238,16 @@ program
177
238
  .description('Health check of AI Flow Kit setup')
178
239
  .option('-v, --verbose', 'detailed output')
179
240
  .action(() => {
241
+ record('command.invoked', { command: 'doctor' });
180
242
  doctorCommand();
181
243
  });
182
244
 
245
+ // ── telemetry ──────────────────────────────────────────────────
246
+ program
247
+ .command('telemetry [action]')
248
+ .description('Manage telemetry logging (enable|disable|status)')
249
+ .action((action) => {
250
+ telemetryCommand(action || 'status');
251
+ });
252
+
183
253
  program.parse(process.argv);
@@ -1,7 +1,7 @@
1
1
  ---
2
- name: validate-ticket
3
- description: Gate 1 — AI reads ticket from Backlog/Jira + reads source code, then uses superpowers:brainstorming for collaborative Q&A and solution proposal. Adds impact analysis and effort estimate. Outputs requirement.md for DEV to approve.
4
- keywords: ticket, validate, context, requirement, backlog, jira, analyze, understand, solution, estimate
2
+ name: read-study-requirement
3
+ description: Gate 1 — AI reads ticket from Backlog/Jira + reads source code, then uses collaborative Q&A and solution proposal. Adds impact analysis and effort estimate. Outputs requirement.md for DEV to approve.
4
+ keywords: ticket, requirement, study, read, context, backlog, jira, analyze, understand, solution, estimate
5
5
  ---
6
6
 
7
7
  # Analyze Requirement — Gate 1
@@ -19,31 +19,40 @@ keywords: ticket, validate, context, requirement, backlog, jira, analyze, unders
19
19
  1. Read `.aiflow/context/current.json` — ticket info from Backlog/Jira
20
20
  2. Read `CLAUDE.md` — understand project architecture, tech stack, conventions
21
21
  3. Read related source files — trace data flow, identify patterns, dependencies
22
+ - **If task is a Bug Fix:** Invoke `superpowers:systematic-debugging` to trace root cause before proposing fixes.
22
23
  4. Read ticket comments — additional context from PM/team
23
24
 
24
25
  Do this investigation **before** asking any questions. Come prepared.
25
26
 
26
27
  ---
27
28
 
28
- ### Step 2: Clarify Requirements via Brainstorming
29
+ ### Step 2: Clarify Requirements via Q&A
29
30
 
30
- **INVOKE: `superpowers:brainstorming`**
31
+ Ask clarifying questions directly — **one question at a time**, wait for the developer's response before asking the next.
31
32
 
32
- Use brainstorming's collaborative Q&A process to:
33
- - Ask clarifying questions **one at a time** — never batch multiple questions
34
- - Understand purpose, constraints, and success criteria from the developer
35
- - Propose **2–3 solution approaches** with trade-offs and a recommendation
36
- - Present the proposed design and get developer confirmation
33
+ **When to ask:**
34
+ - Business requirements are vague or ambiguous
35
+ - Acceptance criteria are not measurable
36
+ - Edge cases discovered in source code need input
37
+ - Multiple approaches exist and the developer's preference matters
37
38
 
38
- Brainstorming handles the full Q&A loop automatically. Let it run until the developer has confirmed the design direction.
39
+ **When NOT to ask:**
40
+ - The ticket and source code together make the intent clear → proceed directly
39
41
 
40
- **Do NOT proceed to Step 3 until brainstorming confirms the design is approved.**
42
+ Once you have sufficient clarity, propose **2–3 solution approaches** with trade-offs and a recommendation:
43
+ - Present options conversationally, lead with your recommendation
44
+ - Get developer confirmation on the chosen approach
45
+
46
+ **Do NOT proceed to Step 3 until the developer has confirmed the design direction.**
47
+
48
+ > ⚠️ **DO NOT invoke `superpowers:brainstorming`** — brainstorming's terminal state invokes
49
+ > `writing-plans` (Gate 2), which would bypass Gate 1's approval gate. All Q&A happens here.
41
50
 
42
51
  ---
43
52
 
44
53
  ### Step 3: Extend with Impact Analysis & Effort Estimate
45
54
 
46
- After brainstorming completes, add what brainstorming does not cover:
55
+ After the developer confirms the design direction (Step 2), extend with:
47
56
 
48
57
  **Impact Analysis:**
49
58
  - Which services, modules, and jobs are affected?
@@ -219,8 +228,8 @@ Please review the requirement document.
219
228
 
220
229
  | Concern | Handled by |
221
230
  |---------|-----------|
222
- | Q&A loop (one question at a time) | `superpowers:brainstorming` |
223
- | Propose 2–3 solution approaches | `superpowers:brainstorming` |
231
+ | Q&A loop (one question at a time) | This skill (inline) |
232
+ | Propose 2–3 solution approaches | This skill (inline) |
224
233
  | Root cause tracing (bug tasks) | `superpowers:systematic-debugging` |
225
234
  | Impact analysis | This skill |
226
235
  | Effort estimate | This skill |
@@ -231,10 +240,11 @@ Please review the requirement document.
231
240
 
232
241
  ## Mandatory Rules
233
242
 
234
- - ❌ **DO NOT** skip invoking `superpowers:brainstorming` — it owns the Q&A loop
243
+ - ❌ **DO NOT** invoke `superpowers:brainstorming` — its terminal state calls `writing-plans` and bypasses Gate 1 approval
244
+ - ❌ **DO NOT** invoke `superpowers:writing-plans` — that belongs to Gate 2 (`generate-spec` skill)
235
245
  - ❌ **DO NOT** proceed past Step 2 if design is not confirmed by developer
236
246
  - ❌ **DO NOT** write code at any point in this skill
237
247
  - ❌ **DO NOT** skip impact analysis and effort estimate
238
- - ✅ **MUST** read source code before brainstorming begins
248
+ - ✅ **MUST** read source code before Q&A begins
239
249
  - ✅ **MUST** save `plan/[ticket-id]/requirement.md`
240
250
  - ✅ **MUST** display Gate 1 prompt and wait for `APPROVED`
@@ -128,7 +128,7 @@ Summary: plan/[ticket-id]/summary.md
128
128
 
129
129
  ✅ If OK: type **"APPROVED"**
130
130
  🐛 If there are bugs: type **"BUG: [description]"**
131
- → If a requirement bug: I will return to Gate 2
131
+ → If a requirement bug: I will return to Gate 1
132
132
  → If a coding bug: I will fix and repeat Gate 4
133
133
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
134
134
  ```
@@ -1,75 +1,88 @@
1
- ## MANDATORY: Strict Gate Workflow
2
-
3
- > **Absolute Rule: Complete Gate N before entering Gate N+1.**
4
- > **Do not skip, shorten, or merge Gates.**
5
-
6
- You have superpowers. When a ticket context exists in `.aiflow/context/current.json`:
7
- - **Consult the "AI Skill Registry"** below to find instructions for each skill (`SKILL.md`).
8
- - **AUTO-START Gate 1 immediately** — do NOT wait for the developer to ask.
9
- - Read instructions and follow the gate sequence below — NO EXCEPTIONS.
10
-
11
- ---
12
-
13
- ### GATE 1 — AI Analyze Requirement (auto-start)
14
-
15
- **INVOKE:** `validate-ticket` skill
16
-
17
- AI actively reads ticket + source code to understand the requirement:
18
- 1. Read `.aiflow/context/current.json` — ticket info
19
- 2. Read source code — architecture, related files, data flow
20
- 3. If anything is unclear — ask ONE question at a time, wait for reply
21
- 4. Output `plan/[ticket-id]/requirement.md` with:
22
- - Requirements summary, source code analysis
23
- - Proposed solution and approach
24
- - Impact analysis, effort estimate, testing plan
25
- 5. Display "GATE 1: Requirement doc ready" → wait for **APPROVED**
26
-
27
- > **Tip:** If auto-start doesn't trigger, the developer can start this gate by typing: **"start"**, **"Gate 1"** or **"Analyze ticket"**.
28
-
29
- DO NOT just check format — **understand the content and propose solutions**.
30
-
31
- ---
32
-
33
- ### GATE 2 — Implementation Plan (wait for APPROVED)
34
-
35
- **INVOKE:** `generate-spec` skill, then `superpowers:writing-plans`
36
-
37
- - Create a detailed TDD implementation plan based on the approved requirement.
38
- - Display: "GATE 2 PAUSED: type APPROVED to start coding".
39
- - CODE WILL NOT BE GENERATED until "APPROVED" is received.
40
-
41
- ---
42
-
43
- ### GATE 3 — Code Generation (TDD only)
44
-
45
- Only runs after Gate 2 has been APPROVED.
46
-
47
- **INVOKE:** `superpowers:test-driven-development`
48
- - Complex feature (3+ files): `superpowers:subagent-driven-development`
49
- - Write tests FIRST run to confirm FAIL -> implement -> PASS.
50
- - Bug fix EXTRA: `superpowers:systematic-debugging` + `investigate-bug` skill first.
51
-
52
- ---
53
-
54
- ### GATE 4 AI Self-Review (wait for APPROVED)
55
-
56
- **INVOKE:** `review-plan` skill
57
-
58
- Mandatory order:
59
- 1. `superpowers:verification-before-completion` — all tests must PASS
60
- 2. `impact-analysis` skill — check for breaking changes
61
- 3. Tick `custom/rules/review-checklist.md`
62
- 4. Create `plan/[ticket-id]/summary.md`
63
-
64
- Then: "GATE 4 PAUSED: type APPROVED or BUG: [description]"
65
- - Coding bug -> fix -> repeat Gate 4.
66
- - Requirement bug -> return to Gate 1.
67
-
68
- ---
69
-
70
- ### GATE 5 — Peer Review and Done
71
-
72
- Only runs after Gate 4 has been APPROVED.
73
-
74
- **INVOKE:** `superpowers:requesting-code-review`
75
- Guide on creating a Pull Request with the ticket link.
1
+ ## MANDATORY: Strict Gate Workflow
2
+
3
+ > **Absolute Rule: Complete Gate N before entering Gate N+1.**
4
+ > **Do not skip, shorten, or merge Gates.**
5
+
6
+ You have superpowers. When a ticket context exists in `.aiflow/context/current.json`:
7
+ - **Consult the "AI Skill Registry"** below to find instructions for each skill (`SKILL.md`).
8
+ - **AUTO-START Gate 1 immediately** — do NOT wait for the developer to ask.
9
+ - Read instructions and follow the gate sequence below — NO EXCEPTIONS.
10
+
11
+ ---
12
+
13
+ ### GATE 1 — AI Analyze Requirement (auto-start)
14
+
15
+ **INVOKE:** `read-study-requirement` skill
16
+
17
+ AI actively reads ticket + source code to understand the requirement:
18
+ 1. Read `.aiflow/context/current.json` — ticket info
19
+ 2. Read source code — architecture, related files, data flow
20
+ 3. If anything is unclear — ask ONE question at a time, wait for reply
21
+ 4. Output `plan/[ticket-id]/requirement.md` with:
22
+ - Requirements summary, source code analysis
23
+ - Proposed solution and approach
24
+ - Impact analysis, effort estimate, testing plan
25
+ 5. Display "GATE 1: Requirement doc ready" → wait for **APPROVED**
26
+
27
+ > **Tip:** If auto-start doesn't trigger, the developer can start this gate by typing: **"start"**, **"Gate 1"** or **"Analyze ticket"**.
28
+
29
+ DO NOT just check format — **understand the content and propose solutions**.
30
+
31
+ > **Telemetry:** Run `aiflow gate 1 start --ticket [ticket-id]` when starting this gate (auto-start or when developer types "start"/"Gate 1").
32
+ > Run `aiflow gate 1 approved --ticket [ticket-id]` immediately when APPROVED is received.
33
+
34
+ ---
35
+
36
+ ### GATE 2 — Implementation Plan (wait for APPROVED)
37
+
38
+ **INVOKE:** `generate-spec` skill, then `superpowers:writing-plans`
39
+
40
+ - Create a detailed TDD implementation plan based on the approved requirement.
41
+ - Display: "GATE 2 PAUSED: type APPROVED to start coding".
42
+ - CODE WILL NOT BE GENERATED until "APPROVED" is received.
43
+
44
+ > **Telemetry:** Run `aiflow gate 2 start --ticket [ticket-id]` when starting this gate.
45
+ > Run `aiflow gate 2 approved --ticket [ticket-id]` immediately when APPROVED is received.
46
+
47
+ ---
48
+
49
+ ### GATE 3Code Generation (TDD only)
50
+
51
+ Only runs after Gate 2 has been APPROVED.
52
+
53
+ **INVOKE:** `superpowers:test-driven-development`
54
+ - Complex feature (3+ files): `superpowers:subagent-driven-development`
55
+ - Write tests FIRST — run to confirm FAIL -> implement -> PASS.
56
+ - Bug fix EXTRA: `superpowers:systematic-debugging` + `investigate-bug` skill first.
57
+
58
+ > **Telemetry:** Run `aiflow gate 3 start --ticket [ticket-id]` when starting this gate.
59
+
60
+ ---
61
+
62
+ ### GATE 4 AI Self-Review (wait for APPROVED)
63
+
64
+ **INVOKE:** `review-plan` skill
65
+
66
+ Mandatory order:
67
+ 1. `superpowers:verification-before-completion` — all tests must PASS
68
+ 2. `impact-analysis` skill — check for breaking changes
69
+ 3. Tick `custom/rules/review-checklist.md`
70
+ 4. Create `plan/[ticket-id]/summary.md`
71
+
72
+ Then: "GATE 4 PAUSED: type APPROVED or BUG: [description]"
73
+ - Coding bug -> fix -> repeat Gate 4.
74
+ - Requirement bug -> return to Gate 1.
75
+
76
+ > **Telemetry:** Run `aiflow gate 4 start --ticket [ticket-id]` when starting this gate.
77
+ > Run `aiflow gate 4 approved --ticket [ticket-id]` immediately when APPROVED is received.
78
+
79
+ ---
80
+
81
+ ### GATE 5 — Peer Review and Done
82
+
83
+ Only runs after Gate 4 has been APPROVED.
84
+
85
+ **INVOKE:** `superpowers:requesting-code-review`
86
+ Guide on creating a Pull Request with the ticket link.
87
+
88
+ > **Telemetry:** Run `aiflow gate 5 start --ticket [ticket-id]` when starting this gate.
@@ -8,6 +8,6 @@ If Gate 1 does not auto-start, wait for the developer to type **"start"**, **"Ga
8
8
 
9
9
  ## Interaction Rules:
10
10
 
11
- - **COLLABORATIVE SKILLS:** When a skill (like `brainstorming`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
11
+ - **COLLABORATIVE SKILLS:** When a skill (like `read-study-requirement`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
12
12
  - **NEVER BATCH QUESTIONS:** Only ask one question per message.
13
13
  - **WAIT FOR APPROVAL:** Do not move to the next Gate until you receive "APPROVED".
@@ -7,6 +7,6 @@ You are an expert AI assistant specialized in this project's stack. Follow the G
7
7
  If the Gate Workflow hasn't started, wait for the developer to type **"start"** or **"Gate 1"**.
8
8
 
9
9
  ## Interaction Rules:
10
- - **COLLABORATIVE SKILLS:** When a skill (like `brainstorming`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
10
+ - **COLLABORATIVE SKILLS:** When a skill (like `read-study-requirement`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
11
11
  - **NEVER BATCH QUESTIONS:** Only ask one question per message.
12
12
  - **WAIT FOR APPROVAL:** Do not move to the next Gate until you receive "APPROVED".
@@ -7,6 +7,6 @@ You are an expert AI assistant specialized in this project's stack. Follow the G
7
7
  If Gate 1 doesn't auto-start, wait for the developer to type **"start"**, **"Gate 1"** or **"Analyze ticket"**.
8
8
 
9
9
  ## Interaction Rules:
10
- - **COLLABORATIVE SKILLS:** When a skill (like `brainstorming`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
10
+ - **COLLABORATIVE SKILLS:** When a skill (like `read-study-requirement`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
11
11
  - **NEVER BATCH QUESTIONS:** Only ask one question per message.
12
12
  - **WAIT FOR APPROVAL:** Do not move to the next Gate until you receive "APPROVED".
@@ -7,6 +7,6 @@ You are an expert AI assistant specialized in this project's stack. Follow the G
7
7
  If no instructions are automatically followed, wait for the developer to type **"start"** or **"Gate 1"** to start the analysis.
8
8
 
9
9
  ## Interaction Rules:
10
- - **COLLABORATIVE SKILLS:** When a skill (like `brainstorming`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
10
+ - **COLLABORATIVE SKILLS:** When a skill (like `read-study-requirement`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
11
11
  - **NEVER BATCH QUESTIONS:** Only ask one question per message.
12
12
  - **WAIT FOR APPROVAL:** Do not move to the next Gate until you receive "APPROVED".
@@ -12,6 +12,6 @@ Follow the gated workflow and rules defined below.
12
12
  If Gate 1 does not start automatically, please start it when the developer types **"Gate 1"**.
13
13
 
14
14
  ## Interaction Rules:
15
- - **COLLABORATIVE SKILLS:** When a skill (like `brainstorming`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
15
+ - **COLLABORATIVE SKILLS:** When a skill (like `read-study-requirement`) says to "ask one question at a time", you MUST stop and wait for the developer's reply before proceeding.
16
16
  - **NEVER BATCH QUESTIONS:** Only ask one question per message.
17
17
  - **WAIT FOR APPROVAL:** Do not move to the next Gate until you receive "APPROVED".