takt 0.1.4 → 0.1.6

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 (82) hide show
  1. package/dist/agents/runner.d.ts +1 -1
  2. package/dist/agents/runner.d.ts.map +1 -1
  3. package/dist/agents/runner.js +13 -34
  4. package/dist/agents/runner.js.map +1 -1
  5. package/dist/claude/client.d.ts.map +1 -1
  6. package/dist/claude/client.js +4 -1
  7. package/dist/claude/client.js.map +1 -1
  8. package/dist/claude/executor.d.ts.map +1 -1
  9. package/dist/claude/executor.js +1 -0
  10. package/dist/claude/executor.js.map +1 -1
  11. package/dist/claude/types.d.ts +2 -0
  12. package/dist/claude/types.d.ts.map +1 -1
  13. package/dist/cli.d.ts +2 -3
  14. package/dist/cli.d.ts.map +1 -1
  15. package/dist/cli.js +5 -8
  16. package/dist/cli.js.map +1 -1
  17. package/dist/commands/help.d.ts.map +1 -1
  18. package/dist/commands/help.js +4 -8
  19. package/dist/commands/help.js.map +1 -1
  20. package/dist/commands/index.d.ts +1 -1
  21. package/dist/commands/index.d.ts.map +1 -1
  22. package/dist/commands/index.js.map +1 -1
  23. package/dist/commands/taskExecution.d.ts +1 -6
  24. package/dist/commands/taskExecution.d.ts.map +1 -1
  25. package/dist/commands/taskExecution.js +2 -6
  26. package/dist/commands/taskExecution.js.map +1 -1
  27. package/dist/commands/workflowExecution.d.ts +0 -2
  28. package/dist/commands/workflowExecution.d.ts.map +1 -1
  29. package/dist/commands/workflowExecution.js +34 -13
  30. package/dist/commands/workflowExecution.js.map +1 -1
  31. package/dist/mock/client.d.ts +27 -0
  32. package/dist/mock/client.d.ts.map +1 -0
  33. package/dist/mock/client.js +56 -0
  34. package/dist/mock/client.js.map +1 -0
  35. package/dist/models/schemas.d.ts +6 -0
  36. package/dist/models/schemas.d.ts.map +1 -1
  37. package/dist/models/schemas.js +4 -4
  38. package/dist/models/schemas.js.map +1 -1
  39. package/dist/models/types.d.ts +6 -4
  40. package/dist/models/types.d.ts.map +1 -1
  41. package/dist/providers/claude.d.ts +11 -0
  42. package/dist/providers/claude.d.ts.map +1 -0
  43. package/dist/providers/claude.js +37 -0
  44. package/dist/providers/claude.js.map +1 -0
  45. package/dist/providers/codex.d.ts +11 -0
  46. package/dist/providers/codex.d.ts.map +1 -0
  47. package/dist/providers/codex.js +29 -0
  48. package/dist/providers/codex.js.map +1 -0
  49. package/dist/providers/index.d.ts +39 -0
  50. package/dist/providers/index.d.ts.map +1 -0
  51. package/dist/providers/index.js +32 -0
  52. package/dist/providers/index.js.map +1 -0
  53. package/dist/providers/mock.d.ts +11 -0
  54. package/dist/providers/mock.d.ts.map +1 -0
  55. package/dist/providers/mock.js +24 -0
  56. package/dist/providers/mock.js.map +1 -0
  57. package/dist/workflow/engine.d.ts.map +1 -1
  58. package/dist/workflow/engine.js +6 -3
  59. package/dist/workflow/engine.js.map +1 -1
  60. package/dist/workflow/instruction-builder.d.ts +5 -2
  61. package/dist/workflow/instruction-builder.d.ts.map +1 -1
  62. package/dist/workflow/instruction-builder.js +4 -2
  63. package/dist/workflow/instruction-builder.js.map +1 -1
  64. package/dist/workflow/state-manager.d.ts +4 -0
  65. package/dist/workflow/state-manager.d.ts.map +1 -1
  66. package/dist/workflow/state-manager.js +10 -0
  67. package/dist/workflow/state-manager.js.map +1 -1
  68. package/package.json +1 -1
  69. package/resources/global/en/agents/default/architect.md +67 -6
  70. package/resources/global/en/agents/default/coder.md +155 -1
  71. package/resources/global/en/workflows/default.yaml +36 -16
  72. package/resources/global/en/workflows/expert-review.yaml +47 -23
  73. package/resources/global/en/workflows/magi.yaml +10 -0
  74. package/resources/global/en/workflows/research.yaml +16 -3
  75. package/resources/global/ja/agents/default/architect.md +62 -1
  76. package/resources/global/ja/agents/default/coder.md +156 -2
  77. package/resources/global/ja/agents/expert-review/cqrs-es-reviewer.md +328 -8
  78. package/resources/global/ja/agents/expert-review/frontend-reviewer.md +303 -33
  79. package/resources/global/ja/workflows/default.yaml +36 -16
  80. package/resources/global/ja/workflows/expert-review.yaml +47 -23
  81. package/resources/global/ja/workflows/magi.yaml +10 -0
  82. package/resources/global/ja/workflows/research.yaml +16 -3
@@ -1 +1 @@
1
- {"version":3,"file":"instruction-builder.d.ts","sourceRoot":"","sources":["../../src/workflow/instruction-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGtE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,wCAAwC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CA4CR"}
1
+ {"version":3,"file":"instruction-builder.d.ts","sourceRoot":"","sources":["../../src/workflow/instruction-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGtE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,aAAa,EAAE,MAAM,CAAC;IACtB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,8CAA8C;IAC9C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,wCAAwC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AASD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CA6CR"}
@@ -16,8 +16,9 @@ function escapeTemplateChars(str) {
16
16
  *
17
17
  * Supported placeholders:
18
18
  * - {task} - The main task/prompt
19
- * - {iteration} - Current iteration number
19
+ * - {iteration} - Current iteration number (workflow-wide turn count)
20
20
  * - {max_iterations} - Maximum iterations allowed
21
+ * - {step_iteration} - Current step's iteration number (how many times this step has been executed)
21
22
  * - {previous_response} - Output from previous step (if passPreviousResponse is true)
22
23
  * - {git_diff} - Current git diff output
23
24
  * - {user_inputs} - Accumulated user inputs
@@ -27,9 +28,10 @@ export function buildInstruction(step, context) {
27
28
  let instruction = step.instructionTemplate;
28
29
  // Replace {task}
29
30
  instruction = instruction.replace(/\{task\}/g, escapeTemplateChars(context.task));
30
- // Replace {iteration} and {max_iterations}
31
+ // Replace {iteration}, {max_iterations}, and {step_iteration}
31
32
  instruction = instruction.replace(/\{iteration\}/g, String(context.iteration));
32
33
  instruction = instruction.replace(/\{max_iterations\}/g, String(context.maxIterations));
34
+ instruction = instruction.replace(/\{step_iteration\}/g, String(context.stepIteration));
33
35
  // Replace {previous_response}
34
36
  if (step.passPreviousResponse) {
35
37
  if (context.previousOutput) {
@@ -1 +1 @@
1
- {"version":3,"file":"instruction-builder.js","sourceRoot":"","sources":["../../src/workflow/instruction-builder.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAsBjD;;GAEG;AACH,SAAS,mBAAmB,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,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AA8B;IAC9B,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,WAAW,GAAG,WAAW,CAAC,OAAO,CAC/B,wBAAwB,EACxB,mBAAmB,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CACpD,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,qBAAqB;IACrB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IAE5D,wBAAwB;IACxB,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,WAAW,GAAG,WAAW,CAAC,OAAO,CAC/B,kBAAkB,EAClB,mBAAmB,CAAC,aAAa,CAAC,CACnC,CAAC;IAEF,uBAAuB;IACvB,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1E,CAAC;IAED,wCAAwC;IACxC,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC3B,WAAW,GAAG,GAAG,WAAW,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC9D,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -10,6 +10,10 @@ import type { WorkflowEngineOptions } from './types.js';
10
10
  * Create initial workflow state from config and options.
11
11
  */
12
12
  export declare function createInitialState(config: WorkflowConfig, options: WorkflowEngineOptions): WorkflowState;
13
+ /**
14
+ * Increment the iteration counter for a step and return the new value.
15
+ */
16
+ export declare function incrementStepIteration(state: WorkflowState, stepName: string): number;
13
17
  /**
14
18
  * Add user input to state with truncation and limit handling.
15
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"state-manager.d.ts","sourceRoot":"","sources":["../../src/workflow/state-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,qBAAqB,GAC7B,aAAa,CAuBf;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAGjF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,IAAI,CAMN"}
1
+ {"version":3,"file":"state-manager.d.ts","sourceRoot":"","sources":["../../src/workflow/state-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,qBAAqB,GAC7B,aAAa,CAwBf;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKrF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAMtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAGjF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,aAAa,GACtB,IAAI,CAMN"}
@@ -27,9 +27,19 @@ export function createInitialState(config, options) {
27
27
  stepOutputs: new Map(),
28
28
  userInputs,
29
29
  agentSessions,
30
+ stepIterations: new Map(),
30
31
  status: 'running',
31
32
  };
32
33
  }
34
+ /**
35
+ * Increment the iteration counter for a step and return the new value.
36
+ */
37
+ export function incrementStepIteration(state, stepName) {
38
+ const current = state.stepIterations.get(stepName) ?? 0;
39
+ const next = current + 1;
40
+ state.stepIterations.set(stepName, next);
41
+ return next;
42
+ }
33
43
  /**
34
44
  * Add user input to state with truncation and limit handling.
35
45
  */
@@ -1 +1 @@
1
- {"version":3,"file":"state-manager.js","sourceRoot":"","sources":["../../src/workflow/state-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,eAAe,EACf,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAGxB;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAsB,EACtB,OAA8B;IAE9B,kDAAkD;IAClD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;QAC5B,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;YACzE,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IAED,kDAAkD;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,iBAAiB;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U,YAAY,CAAC,KAAoB,EAAE,KAAa;IAC9D,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,IAAI,eAAe,EAAE,CAAC;QAC/C,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,gBAAgB;IAC5C,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACnD,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAoB;IACpD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IACvD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAoB,EACpB,QAAgB,EAChB,SAAiB,EACjB,QAAuB;IAEvB,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE1C,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;QACvB,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "takt",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "TAKT: Task Agent Koordination Tool - AI Agent Workflow Orchestration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -159,7 +159,68 @@ Prohibited patterns:
159
159
  | Hidden Dependencies | Child components implicitly calling APIs etc. |
160
160
  | Non-idiomatic | Custom implementation ignoring language/FW conventions |
161
161
 
162
- ### 6. Unnecessary Backward Compatibility Code Detection
162
+ ### 6. Abstraction Level Evaluation
163
+
164
+ **Conditional Branch Proliferation Detection:**
165
+
166
+ | Pattern | Judgment |
167
+ |---------|----------|
168
+ | Same if-else pattern in 3+ places | Abstract with polymorphism → **REJECT** |
169
+ | switch/case with 5+ branches | Consider Strategy/Map pattern |
170
+ | Flag arguments changing behavior | Split into separate functions → **REJECT** |
171
+ | Type-based branching (instanceof/typeof) | Replace with polymorphism → **REJECT** |
172
+ | Nested conditionals (3+ levels) | Early return or extract → **REJECT** |
173
+
174
+ **Abstraction Level Mismatch Detection:**
175
+
176
+ | Pattern | Problem | Fix |
177
+ |---------|---------|-----|
178
+ | Low-level details in high-level processing | Hard to read | Extract details to functions |
179
+ | Mixed abstraction levels in one function | Cognitive load | Align to same granularity |
180
+ | DB operations mixed with business logic | Responsibility violation | Separate to Repository layer |
181
+ | Config values mixed with processing logic | Hard to change | Externalize configuration |
182
+
183
+ **Good Abstraction Examples:**
184
+
185
+ ```typescript
186
+ // ❌ Proliferating conditionals
187
+ function process(type: string) {
188
+ if (type === 'A') { /* process A */ }
189
+ else if (type === 'B') { /* process B */ }
190
+ else if (type === 'C') { /* process C */ }
191
+ // ...continues
192
+ }
193
+
194
+ // ✅ Abstract with Map pattern
195
+ const processors: Record<string, () => void> = {
196
+ A: processA,
197
+ B: processB,
198
+ C: processC,
199
+ };
200
+ function process(type: string) {
201
+ processors[type]?.();
202
+ }
203
+ ```
204
+
205
+ ```typescript
206
+ // ❌ Mixed abstraction levels
207
+ function createUser(data: UserData) {
208
+ // High level: business logic
209
+ validateUser(data);
210
+ // Low level: DB operation details
211
+ const conn = await pool.getConnection();
212
+ await conn.query('INSERT INTO users...');
213
+ conn.release();
214
+ }
215
+
216
+ // ✅ Aligned abstraction levels
217
+ function createUser(data: UserData) {
218
+ validateUser(data);
219
+ await userRepository.save(data); // Details hidden
220
+ }
221
+ ```
222
+
223
+ ### 7. Unnecessary Backward Compatibility Code Detection
163
224
 
164
225
  **AI tends to leave unnecessary code "for backward compatibility." Don't overlook this.**
165
226
 
@@ -188,7 +249,7 @@ Code that should be kept:
188
249
 
189
250
  **Be suspicious when AI says "for backward compatibility."** Verify if it's really needed.
190
251
 
191
- ### 7. Workaround Detection
252
+ ### 8. Workaround Detection
192
253
 
193
254
  **Don't overlook compromises made to "just make it work."**
194
255
 
@@ -203,7 +264,7 @@ Code that should be kept:
203
264
 
204
265
  **Always point these out.** Temporary fixes become permanent.
205
266
 
206
- ### 8. Quality Attributes
267
+ ### 9. Quality Attributes
207
268
 
208
269
  | Attribute | Review Point |
209
270
  |-----------|--------------|
@@ -211,7 +272,7 @@ Code that should be kept:
211
272
  | Maintainability | Easy to modify and fix |
212
273
  | Observability | Logging and monitoring enabled |
213
274
 
214
- ### 9. Big Picture
275
+ ### 10. Big Picture
215
276
 
216
277
  **Caution**: Don't get lost in minor "clean code" nitpicks.
217
278
 
@@ -222,7 +283,7 @@ Verify:
222
283
  - Does it align with business requirements
223
284
  - Is naming consistent with the domain
224
285
 
225
- ### 10. Change Scope Assessment
286
+ ### 11. Change Scope Assessment
226
287
 
227
288
  **Check change scope and include in report (non-blocking).**
228
289
 
@@ -241,7 +302,7 @@ Verify:
241
302
  **Include as suggestions (non-blocking):**
242
303
  - If splittable, present splitting proposal
243
304
 
244
- ### 11. Circular Review Detection
305
+ ### 12. Circular Review Detection
245
306
 
246
307
  When review count is provided (e.g., "Review count: 3rd"), adjust judgment accordingly.
247
308
 
@@ -105,7 +105,45 @@ Perform self-check after implementation.
105
105
  | Boy Scout | Leave touched areas slightly improved |
106
106
  | Fail Fast | Detect errors early. Don't swallow them |
107
107
 
108
- **When in doubt**: Choose Simple. Abstraction can come later.
108
+ **When in doubt**: Choose Simple.
109
+
110
+ ## Abstraction Principles
111
+
112
+ **Before adding conditional branches, consider:**
113
+ - Does this condition exist elsewhere? → Abstract with a pattern
114
+ - Will more branches be added? → Use Strategy/Map pattern
115
+ - Branching on type? → Replace with polymorphism
116
+
117
+ ```typescript
118
+ // ❌ Adding more conditionals
119
+ if (type === 'A') { ... }
120
+ else if (type === 'B') { ... }
121
+ else if (type === 'C') { ... } // Yet another one
122
+
123
+ // ✅ Abstract with Map
124
+ const handlers = { A: handleA, B: handleB, C: handleC };
125
+ handlers[type]?.();
126
+ ```
127
+
128
+ **Align abstraction levels:**
129
+ - Keep same granularity of operations within one function
130
+ - Extract detailed processing to separate functions
131
+ - Don't mix "what to do" with "how to do it"
132
+
133
+ ```typescript
134
+ // ❌ Mixed abstraction levels
135
+ function processOrder(order) {
136
+ validateOrder(order); // High level
137
+ const conn = pool.getConnection(); // Low level detail
138
+ conn.query('INSERT...'); // Low level detail
139
+ }
140
+
141
+ // ✅ Aligned abstraction levels
142
+ function processOrder(order) {
143
+ validateOrder(order);
144
+ saveOrder(order); // Details hidden
145
+ }
146
+ ```
109
147
 
110
148
  **Follow language/framework conventions:**
111
149
  - Be Pythonic in Python, Kotlin-like in Kotlin
@@ -134,6 +172,121 @@ Perform self-check after implementation.
134
172
  - Children don't modify state directly (notify parent via events)
135
173
  - State flows in one direction
136
174
 
175
+ ## Error Handling
176
+
177
+ **Principle: Centralize error handling. Don't scatter try-catch everywhere.**
178
+
179
+ ```typescript
180
+ // ❌ Try-catch everywhere
181
+ async function createUser(data) {
182
+ try {
183
+ const user = await userService.create(data)
184
+ return user
185
+ } catch (e) {
186
+ console.error(e)
187
+ throw new Error('Failed to create user')
188
+ }
189
+ }
190
+
191
+ // ✅ Centralized handling at upper layer
192
+ // Catch at Controller/Handler layer
193
+ // Or use @ControllerAdvice / ErrorBoundary
194
+ async function createUser(data) {
195
+ return await userService.create(data) // Let exceptions propagate
196
+ }
197
+ ```
198
+
199
+ **Error handling placement:**
200
+
201
+ | Layer | Responsibility |
202
+ |-------|----------------|
203
+ | Domain/Service layer | Throw exceptions on business rule violations |
204
+ | Controller/Handler layer | Catch exceptions and convert to response |
205
+ | Global handler | Handle common exceptions (NotFound, auth errors, etc.) |
206
+
207
+ ## Transformation Placement
208
+
209
+ **Principle: Put conversion methods on DTOs.**
210
+
211
+ ```typescript
212
+ // ✅ Request/Response DTOs have conversion methods
213
+ interface CreateUserRequest {
214
+ name: string
215
+ email: string
216
+ }
217
+
218
+ function toUseCaseInput(req: CreateUserRequest): CreateUserInput {
219
+ return { name: req.name, email: req.email }
220
+ }
221
+
222
+ // Controller
223
+ const input = toUseCaseInput(request)
224
+ const output = await useCase.execute(input)
225
+ return UserResponse.from(output)
226
+ ```
227
+
228
+ **Conversion direction:**
229
+ ```
230
+ Request → toInput() → UseCase/Service → Output → Response.from()
231
+ ```
232
+
233
+ ## Extraction Decisions
234
+
235
+ **Rule of Three:**
236
+ - 1st time: Write it inline
237
+ - 2nd time: Don't extract yet (wait and see)
238
+ - 3rd time: Consider extraction
239
+
240
+ **Should extract:**
241
+ - Same logic in 3+ places
242
+ - Same style/UI pattern
243
+ - Same validation logic
244
+ - Same formatting logic
245
+
246
+ **Should NOT extract:**
247
+ - Similar but slightly different (forced generalization adds complexity)
248
+ - Used in only 1-2 places
249
+ - Based on "might use later" predictions
250
+
251
+ ```typescript
252
+ // ❌ Over-generalization
253
+ function formatValue(value, type, options) {
254
+ if (type === 'currency') { ... }
255
+ else if (type === 'date') { ... }
256
+ else if (type === 'percentage') { ... }
257
+ }
258
+
259
+ // ✅ Separate functions by purpose
260
+ function formatCurrency(amount: number): string { ... }
261
+ function formatDate(date: Date): string { ... }
262
+ function formatPercentage(value: number): string { ... }
263
+ ```
264
+
265
+ ## Writing Tests
266
+
267
+ **Principle: Structure tests with "Given-When-Then".**
268
+
269
+ ```typescript
270
+ test('returns NotFound error when user does not exist', async () => {
271
+ // Given: non-existent user ID
272
+ const nonExistentId = 'non-existent-id'
273
+
274
+ // When: attempt to get user
275
+ const result = await getUser(nonExistentId)
276
+
277
+ // Then: NotFound error is returned
278
+ expect(result.error).toBe('NOT_FOUND')
279
+ })
280
+ ```
281
+
282
+ **Test priority:**
283
+
284
+ | Priority | Target |
285
+ |----------|--------|
286
+ | High | Business logic, state transitions |
287
+ | Medium | Edge cases, error handling |
288
+ | Low | Simple CRUD, UI appearance |
289
+
137
290
  ## Prohibited
138
291
 
139
292
  - **Fallback value overuse** - Don't hide problems with `?? 'unknown'`, `|| 'default'`
@@ -143,4 +296,5 @@ Perform self-check after implementation.
143
296
  - **Direct object/array mutation** - Create new with spread operator
144
297
  - **console.log** - Don't leave in production code
145
298
  - **Hardcoded secrets**
299
+ - **Scattered try-catch** - Centralize error handling at upper layer
146
300
 
@@ -1,5 +1,15 @@
1
1
  # Default TAKT Workflow
2
2
  # Plan -> Coder -> Architect Review -> AI Review -> Security Review -> Supervisor Approval
3
+ #
4
+ # Template Variables:
5
+ # {iteration} - Workflow-wide turn count (total steps executed across all agents)
6
+ # {max_iterations} - Maximum iterations allowed for the workflow
7
+ # {step_iteration} - Per-step iteration count (how many times THIS step has been executed)
8
+ # {task} - Original user request
9
+ # {previous_response} - Output from the previous step
10
+ # {git_diff} - Current uncommitted changes (git diff)
11
+ # {user_inputs} - Accumulated user inputs during workflow
12
+ # {report_dir} - Report directory name (e.g., "20250126-143052-task-summary")
3
13
 
4
14
  name: default
5
15
  description: Standard development workflow with planning and specialized reviews
@@ -55,7 +65,8 @@ steps:
55
65
  ```
56
66
  instruction_template: |
57
67
  ## Workflow Context
58
- - Iteration: {iteration}/{max_iterations}
68
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
69
+ - Step Iteration: {step_iteration} (times this step has run)
59
70
  - Step: plan (Task Analysis)
60
71
  - Report Directory: .takt/reports/{report_dir}/
61
72
  - Report File: .takt/reports/{report_dir}/00-plan.md
@@ -79,7 +90,7 @@ steps:
79
90
 
80
91
  **Report output:** Output to the `Report File` specified above.
81
92
  - If file does not exist: Create new file
82
- - If file exists: Append with `## Iteration {iteration}` section
93
+ - If file exists: Append with `## Iteration {step_iteration}` section
83
94
 
84
95
  **Report format:**
85
96
  ```markdown
@@ -155,7 +166,8 @@ steps:
155
166
  ```
156
167
  instruction_template: |
157
168
  ## Workflow Context
158
- - Iteration: {iteration}/{max_iterations}
169
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
170
+ - Step Iteration: {step_iteration} (times this step has run)
159
171
  - Step: implement
160
172
  - Report Directory: .takt/reports/{report_dir}/
161
173
  - Report Files:
@@ -174,7 +186,7 @@ steps:
174
186
 
175
187
  **Report output:** Output to the `Report Files` specified above.
176
188
  - If file does not exist: Create new file
177
- - If file exists: Append with `## Iteration {iteration}` section
189
+ - If file exists: Append with `## Iteration {step_iteration}` section
178
190
 
179
191
  **Scope report format (create at implementation start):**
180
192
  ```markdown
@@ -279,7 +291,8 @@ steps:
279
291
  ```
280
292
  instruction_template: |
281
293
  ## Workflow Context
282
- - Iteration: {iteration}/{max_iterations}
294
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
295
+ - Step Iteration: {step_iteration} (times this step has run)
283
296
  - Step: review (Architecture Review)
284
297
  - Report Directory: .takt/reports/{report_dir}/
285
298
  - Report File: .takt/reports/{report_dir}/03-architect-review.md
@@ -299,7 +312,7 @@ steps:
299
312
 
300
313
  **Report output:** Output to the `Report File` specified above.
301
314
  - If file does not exist: Create new file
302
- - If file exists: Append with `## Iteration {iteration}` section
315
+ - If file exists: Append with `## Iteration {step_iteration}` section
303
316
 
304
317
  **Report format:**
305
318
  ```markdown
@@ -382,7 +395,8 @@ steps:
382
395
  ```
383
396
  instruction_template: |
384
397
  ## Workflow Context
385
- - Iteration: {iteration}/{max_iterations}
398
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
399
+ - Step Iteration: {step_iteration} (times this step has run)
386
400
  - Step: improve
387
401
 
388
402
  ## Architect Feedback (This is the latest instruction - prioritize this)
@@ -463,7 +477,8 @@ steps:
463
477
  ```
464
478
  instruction_template: |
465
479
  ## Workflow Context
466
- - Iteration: {iteration}/{max_iterations}
480
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
481
+ - Step Iteration: {step_iteration} (times this step has run)
467
482
  - Step: ai_review (AI-Generated Code Review)
468
483
  - Report Directory: .takt/reports/{report_dir}/
469
484
  - Report File: .takt/reports/{report_dir}/04-ai-review.md
@@ -485,7 +500,7 @@ steps:
485
500
 
486
501
  **Report output:** Output to the `Report File` specified above.
487
502
  - If file does not exist: Create new file
488
- - If file exists: Append with `## Iteration {iteration}` section
503
+ - If file exists: Append with `## Iteration {step_iteration}` section
489
504
 
490
505
  **Report format:**
491
506
  ```markdown
@@ -564,7 +579,8 @@ steps:
564
579
  ```
565
580
  instruction_template: |
566
581
  ## Workflow Context
567
- - Iteration: {iteration}/{max_iterations}
582
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
583
+ - Step Iteration: {step_iteration} (times this step has run)
568
584
  - Step: ai_fix
569
585
 
570
586
  ## AI Review Feedback (This is the latest instruction - prioritize this)
@@ -640,7 +656,8 @@ steps:
640
656
  ```
641
657
  instruction_template: |
642
658
  ## Workflow Context
643
- - Iteration: {iteration}/{max_iterations}
659
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
660
+ - Step Iteration: {step_iteration} (times this step has run)
644
661
  - Step: security_review
645
662
  - Report Directory: .takt/reports/{report_dir}/
646
663
  - Report File: .takt/reports/{report_dir}/05-security-review.md
@@ -662,7 +679,7 @@ steps:
662
679
 
663
680
  **Report output:** Output to the `Report File` specified above.
664
681
  - If file does not exist: Create new file
665
- - If file exists: Append with `## Iteration {iteration}` section
682
+ - If file exists: Append with `## Iteration {step_iteration}` section
666
683
 
667
684
  **Report format:**
668
685
  ```markdown
@@ -744,7 +761,8 @@ steps:
744
761
  ```
745
762
  instruction_template: |
746
763
  ## Workflow Context
747
- - Iteration: {iteration}/{max_iterations}
764
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
765
+ - Step Iteration: {step_iteration} (times this step has run)
748
766
  - Step: security_fix
749
767
 
750
768
  ## Security Review Feedback (This is the latest instruction - prioritize this)
@@ -813,7 +831,8 @@ steps:
813
831
  ```
814
832
  instruction_template: |
815
833
  ## Workflow Context
816
- - Iteration: {iteration}/{max_iterations}
834
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
835
+ - Step Iteration: {step_iteration} (times this step has run)
817
836
  - Step: fix
818
837
 
819
838
  ## Architect Feedback (This is the latest instruction - prioritize this)
@@ -893,7 +912,8 @@ steps:
893
912
  ```
894
913
  instruction_template: |
895
914
  ## Workflow Context
896
- - Iteration: {iteration}/{max_iterations}
915
+ - Iteration: {iteration}/{max_iterations} (workflow-wide)
916
+ - Step Iteration: {step_iteration} (times this step has run)
897
917
  - Step: supervise (final verification)
898
918
  - Report Directory: .takt/reports/{report_dir}/
899
919
  - Report Files:
@@ -921,7 +941,7 @@ steps:
921
941
 
922
942
  **Report output:** Output to the `Report Files` specified above.
923
943
  - If file does not exist: Create new file
924
- - If file exists: Append with `## Iteration {iteration}` section
944
+ - If file exists: Append with `## Iteration {step_iteration}` section
925
945
 
926
946
  **Validation report format:**
927
947
  ```markdown