@kody-ade/engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +322 -0
  3. package/dist/agent-runner.d.ts +4 -0
  4. package/dist/agent-runner.js +122 -0
  5. package/dist/bin/cli.js +11276 -0
  6. package/dist/ci/parse-inputs.d.ts +6 -0
  7. package/dist/ci/parse-inputs.js +76 -0
  8. package/dist/ci/parse-safety.d.ts +6 -0
  9. package/dist/ci/parse-safety.js +22 -0
  10. package/dist/cli/args.d.ts +13 -0
  11. package/dist/cli/args.js +42 -0
  12. package/dist/cli/litellm.d.ts +2 -0
  13. package/dist/cli/litellm.js +85 -0
  14. package/dist/cli/task-resolution.d.ts +2 -0
  15. package/dist/cli/task-resolution.js +41 -0
  16. package/dist/config.d.ts +49 -0
  17. package/dist/config.js +72 -0
  18. package/dist/context.d.ts +4 -0
  19. package/dist/context.js +83 -0
  20. package/dist/definitions.d.ts +3 -0
  21. package/dist/definitions.js +59 -0
  22. package/dist/entry.d.ts +1 -0
  23. package/dist/entry.js +236 -0
  24. package/dist/git-utils.d.ts +13 -0
  25. package/dist/git-utils.js +174 -0
  26. package/dist/github-api.d.ts +14 -0
  27. package/dist/github-api.js +114 -0
  28. package/dist/kody-utils.d.ts +1 -0
  29. package/dist/kody-utils.js +9 -0
  30. package/dist/learning/auto-learn.d.ts +2 -0
  31. package/dist/learning/auto-learn.js +169 -0
  32. package/dist/logger.d.ts +14 -0
  33. package/dist/logger.js +51 -0
  34. package/dist/memory.d.ts +1 -0
  35. package/dist/memory.js +20 -0
  36. package/dist/observer.d.ts +9 -0
  37. package/dist/observer.js +80 -0
  38. package/dist/pipeline/complexity.d.ts +3 -0
  39. package/dist/pipeline/complexity.js +12 -0
  40. package/dist/pipeline/executor-registry.d.ts +3 -0
  41. package/dist/pipeline/executor-registry.js +20 -0
  42. package/dist/pipeline/hooks.d.ts +17 -0
  43. package/dist/pipeline/hooks.js +110 -0
  44. package/dist/pipeline/questions.d.ts +2 -0
  45. package/dist/pipeline/questions.js +44 -0
  46. package/dist/pipeline/runner-selection.d.ts +2 -0
  47. package/dist/pipeline/runner-selection.js +13 -0
  48. package/dist/pipeline/state.d.ts +4 -0
  49. package/dist/pipeline/state.js +37 -0
  50. package/dist/pipeline.d.ts +3 -0
  51. package/dist/pipeline.js +213 -0
  52. package/dist/preflight.d.ts +1 -0
  53. package/dist/preflight.js +69 -0
  54. package/dist/retrospective.d.ts +26 -0
  55. package/dist/retrospective.js +211 -0
  56. package/dist/stages/agent.d.ts +2 -0
  57. package/dist/stages/agent.js +94 -0
  58. package/dist/stages/gate.d.ts +2 -0
  59. package/dist/stages/gate.js +32 -0
  60. package/dist/stages/review.d.ts +2 -0
  61. package/dist/stages/review.js +32 -0
  62. package/dist/stages/ship.d.ts +3 -0
  63. package/dist/stages/ship.js +154 -0
  64. package/dist/stages/verify.d.ts +2 -0
  65. package/dist/stages/verify.js +94 -0
  66. package/dist/types.d.ts +61 -0
  67. package/dist/types.js +1 -0
  68. package/dist/validators.d.ts +8 -0
  69. package/dist/validators.js +42 -0
  70. package/dist/verify-runner.d.ts +11 -0
  71. package/dist/verify-runner.js +110 -0
  72. package/kody.config.schema.json +299 -0
  73. package/package.json +39 -0
  74. package/prompts/autofix.md +52 -0
  75. package/prompts/build.md +26 -0
  76. package/prompts/decompose.md +77 -0
  77. package/prompts/plan.md +65 -0
  78. package/prompts/review-fix.md +27 -0
  79. package/prompts/review.md +115 -0
  80. package/prompts/taskify-ticket.md +122 -0
  81. package/prompts/taskify.md +70 -0
  82. package/templates/kody-watch.yml +57 -0
  83. package/templates/kody.yml +450 -0
  84. package/templates/watch-agents/branch-cleanup/agent.json +7 -0
  85. package/templates/watch-agents/branch-cleanup/agent.md +13 -0
  86. package/templates/watch-agents/dependency-checker/agent.json +7 -0
  87. package/templates/watch-agents/dependency-checker/agent.md +14 -0
  88. package/templates/watch-agents/readme-health/agent.json +7 -0
  89. package/templates/watch-agents/readme-health/agent.md +17 -0
  90. package/templates/watch-agents/stale-pr-reviewer/agent.json +7 -0
  91. package/templates/watch-agents/stale-pr-reviewer/agent.md +13 -0
  92. package/templates/watch-agents/todo-scanner/agent.json +7 -0
  93. package/templates/watch-agents/todo-scanner/agent.md +10 -0
@@ -0,0 +1,299 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Kody Engine Lite Configuration",
4
+ "description": "Configuration for the Kody autonomous SDLC pipeline. See https://github.com/aharonyaircohen/Kody-Engine-Lite",
5
+ "type": "object",
6
+ "properties": {
7
+ "quality": {
8
+ "type": "object",
9
+ "description": "Quality gate commands run during the verify stage. Leave empty string to skip.",
10
+ "properties": {
11
+ "typecheck": {
12
+ "type": "string",
13
+ "description": "TypeScript type checking command (e.g., 'pnpm typecheck', 'pnpm tsc --noEmit')",
14
+ "default": "pnpm -s tsc --noEmit"
15
+ },
16
+ "lint": {
17
+ "type": "string",
18
+ "description": "Lint command (e.g., 'pnpm lint'). Empty to skip.",
19
+ "default": ""
20
+ },
21
+ "lintFix": {
22
+ "type": "string",
23
+ "description": "Auto-fix lint command, run when verify fails (e.g., 'pnpm lint:fix')",
24
+ "default": ""
25
+ },
26
+ "formatFix": {
27
+ "type": "string",
28
+ "description": "Auto-fix format command, run when verify fails (e.g., 'pnpm format')",
29
+ "default": ""
30
+ },
31
+ "testUnit": {
32
+ "type": "string",
33
+ "description": "Unit test command. Use test:unit to exclude integration/e2e tests (e.g., 'pnpm test:unit')",
34
+ "default": "pnpm -s test"
35
+ }
36
+ },
37
+ "additionalProperties": false
38
+ },
39
+ "git": {
40
+ "type": "object",
41
+ "description": "Git configuration",
42
+ "properties": {
43
+ "defaultBranch": {
44
+ "type": "string",
45
+ "description": "Default branch for PR base and branch syncing (e.g., 'main', 'dev')",
46
+ "default": "dev"
47
+ }
48
+ },
49
+ "additionalProperties": false
50
+ },
51
+ "github": {
52
+ "type": "object",
53
+ "description": "GitHub repository settings. Auto-detected from git remote by init.",
54
+ "properties": {
55
+ "owner": {
56
+ "type": "string",
57
+ "description": "GitHub organization or username (e.g., 'my-org')"
58
+ },
59
+ "repo": {
60
+ "type": "string",
61
+ "description": "GitHub repository name (e.g., 'my-repo')"
62
+ },
63
+ "postSummary": {
64
+ "type": "boolean",
65
+ "description": "Post a structured pipeline summary comment on the issue after completion. Default: true in CI, false locally.",
66
+ "default": true
67
+ }
68
+ },
69
+ "additionalProperties": false
70
+ },
71
+ "timeouts": {
72
+ "type": "object",
73
+ "description": "Per-stage timeout overrides in seconds. Defaults: taskify=600, plan=600, build=2400, verify=300, review=600, review-fix=1200, ship=240",
74
+ "properties": {
75
+ "taskify": { "type": "number", "description": "Taskify stage timeout in seconds", "default": 600 },
76
+ "plan": { "type": "number", "description": "Plan stage timeout in seconds", "default": 600 },
77
+ "build": { "type": "number", "description": "Build stage timeout in seconds", "default": 2400 },
78
+ "verify": { "type": "number", "description": "Verify stage timeout in seconds", "default": 300 },
79
+ "review": { "type": "number", "description": "Review stage timeout in seconds", "default": 600 },
80
+ "review-fix": { "type": "number", "description": "Review-fix stage timeout in seconds", "default": 1200 },
81
+ "ship": { "type": "number", "description": "Ship stage timeout in seconds", "default": 240 }
82
+ },
83
+ "additionalProperties": false
84
+ },
85
+ "agent": {
86
+ "type": "object",
87
+ "description": "Agent execution configuration",
88
+ "properties": {
89
+ "modelMap": {
90
+ "type": "object",
91
+ "description": "Maps model tiers to actual model names. When provider is set, values should be the provider's model names.",
92
+ "properties": {
93
+ "cheap": {
94
+ "type": "string",
95
+ "description": "Fast/cheap model for taskify stage (e.g., 'haiku' or provider model name)",
96
+ "default": "haiku"
97
+ },
98
+ "mid": {
99
+ "type": "string",
100
+ "description": "Mid-tier model for build, review-fix, autofix (e.g., 'sonnet' or provider model name)",
101
+ "default": "sonnet"
102
+ },
103
+ "strong": {
104
+ "type": "string",
105
+ "description": "Strongest model for plan, review — deep reasoning (e.g., 'opus' or provider model name)",
106
+ "default": "opus"
107
+ }
108
+ },
109
+ "additionalProperties": false
110
+ },
111
+ "provider": {
112
+ "type": "string",
113
+ "description": "LLM provider name. When set (and not 'anthropic'), engine auto-starts LiteLLM proxy and routes model calls to this provider. modelMap values should be the provider's model names.",
114
+ "examples": ["anthropic", "minimax", "openai", "google"]
115
+ },
116
+ "defaultRunner": {
117
+ "type": "string",
118
+ "description": "Name of the default runner when multiple runners are configured (advanced)",
119
+ "default": "claude"
120
+ },
121
+ "runners": {
122
+ "type": "object",
123
+ "description": "Named runner definitions (advanced)",
124
+ "additionalProperties": {
125
+ "type": "object",
126
+ "properties": {
127
+ "type": {
128
+ "type": "string",
129
+ "enum": ["claude-code"]
130
+ }
131
+ },
132
+ "required": ["type"]
133
+ }
134
+ },
135
+ "stageRunners": {
136
+ "type": "object",
137
+ "description": "Per-stage runner assignment (advanced). Maps stage name to runner name.",
138
+ "properties": {
139
+ "taskify": { "type": "string" },
140
+ "plan": { "type": "string" },
141
+ "build": { "type": "string" },
142
+ "autofix": { "type": "string" },
143
+ "review": { "type": "string" },
144
+ "review-fix": { "type": "string" }
145
+ },
146
+ "additionalProperties": false
147
+ },
148
+ "default": {
149
+ "type": "object",
150
+ "description": "Default provider + model for all stages. Overridden by per-stage entries in 'stages'.",
151
+ "properties": {
152
+ "provider": {
153
+ "type": "string",
154
+ "description": "Provider name: 'claude' for direct Anthropic API, anything else routes through LiteLLM proxy",
155
+ "examples": ["claude", "minimax", "openai", "google"]
156
+ },
157
+ "model": {
158
+ "type": "string",
159
+ "description": "Full model ID (e.g., 'claude-sonnet-4-6', 'gpt-4o')"
160
+ }
161
+ },
162
+ "required": ["provider", "model"],
163
+ "additionalProperties": false
164
+ },
165
+ "stages": {
166
+ "type": "object",
167
+ "description": "Per-stage provider + model overrides. Takes precedence over 'default' and 'modelMap'.",
168
+ "properties": {
169
+ "taskify": { "$ref": "#/properties/agent/properties/default" },
170
+ "plan": { "$ref": "#/properties/agent/properties/default" },
171
+ "build": { "$ref": "#/properties/agent/properties/default" },
172
+ "verify": { "$ref": "#/properties/agent/properties/default" },
173
+ "review": { "$ref": "#/properties/agent/properties/default" },
174
+ "review-fix": { "$ref": "#/properties/agent/properties/default" },
175
+ "ship": { "$ref": "#/properties/agent/properties/default" }
176
+ },
177
+ "additionalProperties": false
178
+ },
179
+ "escalateOnTimeout": {
180
+ "type": "boolean",
181
+ "description": "Escalate to a stronger model tier when a stage times out and retries. Default: true.",
182
+ "default": true
183
+ }
184
+ },
185
+ "additionalProperties": false
186
+ },
187
+ "watch": {
188
+ "type": "object",
189
+ "description": "Kody Watch — periodic health monitoring. Runs every 30 minutes via GitHub Actions to check pipeline health, security, and configuration.",
190
+ "properties": {
191
+ "enabled": {
192
+ "type": "boolean",
193
+ "description": "Enable Kody Watch periodic monitoring",
194
+ "default": false
195
+ },
196
+ "digestIssue": {
197
+ "type": "number",
198
+ "description": "GitHub issue number for posting digest reports. Auto-created by bootstrap."
199
+ },
200
+ "model": {
201
+ "type": "string",
202
+ "description": "Model for watch agents. When provider is set in agent config, this should be the provider's model name. Falls back to agent.modelMap.cheap if not set.",
203
+ "examples": ["claude-sonnet-4-6", "claude-haiku-4-5-20251001", "MiniMax-M1"]
204
+ }
205
+ },
206
+ "additionalProperties": false
207
+ },
208
+ "mcp": {
209
+ "type": "object",
210
+ "description": "MCP (Model Context Protocol) server configuration. Enables external tools like browser automation.",
211
+ "properties": {
212
+ "enabled": {
213
+ "type": "boolean",
214
+ "description": "Enable MCP server integration",
215
+ "default": false
216
+ },
217
+ "servers": {
218
+ "type": "object",
219
+ "description": "Named MCP server definitions. Each key is a server name.",
220
+ "additionalProperties": {
221
+ "type": "object",
222
+ "properties": {
223
+ "command": {
224
+ "type": "string",
225
+ "description": "Command to start the MCP server (e.g., 'npx')"
226
+ },
227
+ "args": {
228
+ "type": "array",
229
+ "items": { "type": "string" },
230
+ "description": "Command arguments"
231
+ },
232
+ "env": {
233
+ "type": "object",
234
+ "additionalProperties": { "type": "string" },
235
+ "description": "Environment variables for the server process"
236
+ }
237
+ },
238
+ "required": ["command"]
239
+ }
240
+ },
241
+ "stages": {
242
+ "type": "array",
243
+ "items": { "type": "string" },
244
+ "description": "Stages that can use MCP tools. Defaults to [\"build\", \"verify\", \"review\", \"review-fix\"]",
245
+ "default": ["build", "verify", "review", "review-fix"]
246
+ },
247
+ "devServer": {
248
+ "type": "object",
249
+ "description": "DEPRECATED: Use top-level devServer instead. Kept for backward compatibility.",
250
+ "properties": {
251
+ "command": {
252
+ "type": "string",
253
+ "description": "Command to start the dev server (e.g., 'pnpm dev')"
254
+ },
255
+ "url": {
256
+ "type": "string",
257
+ "description": "URL where the dev server will be accessible (e.g., 'http://localhost:3000')"
258
+ },
259
+ "readyPattern": {
260
+ "type": "string",
261
+ "description": "Regex pattern to match in stdout when server is ready. Default: 'Ready in|compiled|started server|Local:'"
262
+ },
263
+ "readyTimeout": {
264
+ "type": "number",
265
+ "description": "Seconds to wait for the server to be ready. Default: 180"
266
+ }
267
+ },
268
+ "required": ["command", "url"]
269
+ }
270
+ },
271
+ "required": ["enabled", "servers"],
272
+ "additionalProperties": false
273
+ },
274
+ "devServer": {
275
+ "type": "object",
276
+ "description": "Dev server configuration for browser tool verification. Works with any provider (MCP or CLI-based).",
277
+ "properties": {
278
+ "command": {
279
+ "type": "string",
280
+ "description": "Command to start the dev server (e.g., 'pnpm dev')"
281
+ },
282
+ "url": {
283
+ "type": "string",
284
+ "description": "URL where the dev server will be accessible (e.g., 'http://localhost:3000')"
285
+ },
286
+ "readyPattern": {
287
+ "type": "string",
288
+ "description": "Regex pattern to match in stdout when server is ready. Default: 'Ready in|compiled|started server|Local:'"
289
+ },
290
+ "readyTimeout": {
291
+ "type": "number",
292
+ "description": "Seconds to wait for the server to be ready. Default: 180"
293
+ }
294
+ },
295
+ "required": ["command", "url"]
296
+ }
297
+ },
298
+ "additionalProperties": false
299
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@kody-ade/engine",
3
+ "version": "0.1.0",
4
+ "description": "Kody ADE — the free, autonomous development engine. Issue to tested, reviewed PR.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "kody-engine": "./dist/bin/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "prompts",
13
+ "templates",
14
+ "kody.config.schema.json"
15
+ ],
16
+ "scripts": {
17
+ "kody": "tsx src/entry.ts",
18
+ "claude": "tsx scripts/kody.ts",
19
+ "build": "tsup",
20
+ "test": "vitest run",
21
+ "typecheck": "tsc --noEmit",
22
+ "prepublishOnly": "pnpm build",
23
+ "release": "npm publish --access public && bash scripts/wait-for-npm.sh"
24
+ },
25
+ "dependencies": {
26
+ "dotenv": "^16.4.7",
27
+ "yaml": "^2.8.3"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.5.4",
31
+ "tsup": "^8.5.1",
32
+ "tsx": "^4.21.0",
33
+ "typescript": "~5.7.0",
34
+ "vitest": "^4.1.1"
35
+ },
36
+ "engines": {
37
+ "node": ">=22"
38
+ }
39
+ }
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: autofix
3
+ description: Investigate root cause then fix verification errors (typecheck, lint, test failures)
4
+ mode: primary
5
+ tools: [read, write, edit, bash, glob, grep]
6
+ ---
7
+
8
+ You are an autofix agent following the Superpowers Systematic Debugging methodology. The verification stage failed. Fix the errors below.
9
+
10
+ IRON LAW: NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST. If you haven't completed Phase 1, you cannot propose fixes.
11
+
12
+ ## Phase 1 — Root Cause Investigation (BEFORE any edits)
13
+ 1. Read the full error output — what exactly failed? Full stack traces, line numbers, error codes.
14
+ 2. Identify the affected files — Read them to understand context.
15
+ 3. Check recent changes: run `git diff HEAD~1` to see what changed.
16
+ 4. Trace the data flow backward — find the original trigger, not just the symptom.
17
+ 5. Classify the failure pattern:
18
+ - **Type error**: mismatched types, missing properties, wrong generics
19
+ - **Test failure**: assertion mismatch, missing mock, changed behavior
20
+ - **Lint error**: style violation, unused import, naming convention
21
+ - **Runtime error**: null reference, missing dependency, config issue
22
+ - **Integration failure**: API contract mismatch, schema drift
23
+ 6. Identify root cause — is this a direct error in new code, or a side effect of a change elsewhere?
24
+
25
+ ## Phase 2 — Pattern Analysis
26
+ 1. Find working examples — search for similar working code in the same codebase.
27
+ 2. Compare against the working version — what's different?
28
+ 3. Form a single hypothesis: "I think X is the root cause because Y."
29
+
30
+ ## Phase 3 — Fix (only after root cause is clear)
31
+ 1. Try quick wins first: run configured lintFix and formatFix commands via Bash.
32
+ 2. Implement a single fix — ONE change at a time, not multiple changes at once.
33
+ 3. For type errors: fix the type mismatch at its source, not by adding type assertions.
34
+ 4. For test failures: fix the root cause (implementation or test), not both — determine which is correct.
35
+ 5. For lint errors: apply the specific fix the linter suggests.
36
+ 6. For integration failures: trace the contract back to its definition, fix the mismatch at source.
37
+ 7. After EACH fix, re-run the failing command to verify it passes.
38
+ 8. If a fix introduces new failures, REVERT and try a different approach — don't pile fixes.
39
+ 9. Do NOT commit or push — the orchestrator handles git.
40
+
41
+ ## Red Flags — STOP and return to Phase 1 if you catch yourself:
42
+ - "Quick fix for now, investigate later"
43
+ - "Just try changing X and see"
44
+ - "I don't fully understand but this might work"
45
+ - Proposing solutions before tracing the data flow
46
+
47
+ ## Rules
48
+ - Fix ONLY the reported errors. Do NOT make unrelated changes.
49
+ - Minimal diff — use Edit for surgical changes, not Write for rewrites.
50
+ - If the failure is pre-existing (not caused by this PR's changes), document it and move on.
51
+
52
+ {{TASK_CONTEXT}}
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: build
3
+ description: Implement code changes following Superpowers Executing Plans methodology
4
+ mode: primary
5
+ tools: [read, write, edit, bash, glob, grep]
6
+ ---
7
+
8
+ You are a code implementation agent following the Superpowers Executing Plans methodology.
9
+
10
+ CRITICAL RULES:
11
+ 1. Follow the plan EXACTLY — step by step, in order. Do not skip or reorder steps.
12
+ 2. Read existing code BEFORE modifying (use Read tool first, always).
13
+ 3. Verify each step after completion (use Bash to run tests/typecheck).
14
+ 4. Write COMPLETE, working code — no stubs, no TODOs, no placeholders.
15
+ 5. Do NOT commit or push — the orchestrator handles git.
16
+ 6. If the plan says to write tests first, write tests first.
17
+ 7. Document any deviations from the plan (if absolutely necessary).
18
+
19
+ Implementation discipline:
20
+ - Use Edit for surgical changes to existing files (prefer over Write for modifications)
21
+ - Use Write only for new files
22
+ - Run `pnpm test` after each logical group of changes
23
+ - Run `pnpm tsc --noEmit` periodically to catch type errors early
24
+ - If a test fails after your change, fix it immediately — don't continue
25
+
26
+ {{TASK_CONTEXT}}
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: decompose
3
+ description: Analyze implementation plan and decompose into parallel sub-tasks
4
+ mode: primary
5
+ tools: [read, glob, grep]
6
+ ---
7
+
8
+ You are a task decomposition agent. You analyze an implementation plan and determine whether it can be split into independent sub-tasks that can be built in parallel.
9
+
10
+ ## Input
11
+
12
+ You receive the full implementation plan (plan.md) and task classification (task.json) via the task context below.
13
+
14
+ ## Analysis Process
15
+
16
+ 1. **Parse plan steps** — identify each `## Step N` or numbered implementation step with its target files
17
+ 2. **Map file dependencies** — for each step, identify which files it reads from vs writes to
18
+ 3. **Detect coupling** — steps that share files, or where one step's output is another's input, are coupled
19
+ 4. **Cluster into groups** — group tightly-coupled steps together; independent groups become sub-tasks
20
+ 5. **Score complexity** — rate 1-10 based on: file count, directory spread, inter-step coupling, risk level
21
+
22
+ ## Scoring Guide
23
+
24
+ | Score | Description | Decompose? |
25
+ |-------|-------------|------------|
26
+ | 1-3 | Simple: few files, single area | No |
27
+ | 4-5 | Moderate: several files, some coupling | Usually no |
28
+ | 6-7 | Complex: many files, multiple areas, manageable coupling | Yes (2 sub-tasks) |
29
+ | 8-9 | Very complex: many files, multiple domains, some coupling | Yes (2-3 sub-tasks) |
30
+ | 10 | Extremely complex: cross-cutting, many domains | Yes (3-4 sub-tasks) |
31
+
32
+ ## Rules
33
+
34
+ - Maximum 4 sub-tasks (more causes merge complexity that outweighs parallelism benefit)
35
+ - Each sub-task MUST have exclusive file ownership — no file appears in two sub-tasks' scope
36
+ - Each plan step MUST be assigned to exactly one sub-task — no step in two sub-tasks' plan_steps
37
+ - If steps are tightly coupled (shared files, import chains), they MUST be in the same sub-task
38
+ - Set `decomposable: false` when: score < 6, fewer than 4 files total, or all steps are tightly coupled
39
+ - `depends_on` should reference sub-task IDs that must complete first (empty = fully independent)
40
+ - `shared_context` describes what this sub-task needs to know about sibling sub-tasks' work
41
+
42
+ ## Output
43
+
44
+ Output ONLY valid JSON. No markdown fences. No explanation. No extra text before or after the JSON.
45
+
46
+ ```json
47
+ {
48
+ "decomposable": true,
49
+ "reason": "Plan steps cluster into N independent groups by file ownership...",
50
+ "complexity_score": 7,
51
+ "recommended_subtasks": 2,
52
+ "sub_tasks": [
53
+ {
54
+ "id": "part-1",
55
+ "title": "Short descriptive title",
56
+ "description": "What this sub-task implements and why",
57
+ "scope": ["src/path/file1.ts", "src/path/file2.ts"],
58
+ "plan_steps": [1, 2, 3],
59
+ "depends_on": [],
60
+ "shared_context": "Uses TypeFoo defined in part-2's scope — import will resolve after merge"
61
+ }
62
+ ]
63
+ }
64
+ ```
65
+
66
+ When not decomposable:
67
+ ```json
68
+ {
69
+ "decomposable": false,
70
+ "reason": "All plan steps share src/core/main.ts — cannot split without file conflicts",
71
+ "complexity_score": 4,
72
+ "recommended_subtasks": 1,
73
+ "sub_tasks": []
74
+ }
75
+ ```
76
+
77
+ {{TASK_CONTEXT}}
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: plan
3
+ description: Create a step-by-step implementation plan following Superpowers Writing Plans methodology
4
+ mode: primary
5
+ tools: [read, glob, grep]
6
+ ---
7
+
8
+ You are a planning agent following the Superpowers Writing Plans methodology.
9
+
10
+ ## MANDATORY: Pattern Discovery Before Planning
11
+
12
+ Before writing ANY plan, you MUST search for existing patterns in the codebase:
13
+
14
+ 1. **Find similar implementations** — Grep/Glob for how the same problem is already solved elsewhere. E.g., if the task involves localization, search for how other collections handle localization. If adding auth, find existing auth patterns.
15
+ 2. **Reuse existing patterns** — If the codebase already solves a similar problem, your plan MUST follow that pattern unless there's a strong reason not to (document the reason in Questions).
16
+ 3. **Check decisions.md** — If `.kody/memory/decisions.md` exists, read it for prior architectural decisions that may apply.
17
+ 4. **Never invent when you can reuse** — Proposing a new pattern when an existing one covers the use case is a planning failure.
18
+
19
+ After pattern discovery, examine the codebase to understand existing code structure, patterns, and conventions. Use Read, Glob, and Grep.
20
+
21
+ Output a markdown plan. Start with the steps, then optionally add a Questions section at the end.
22
+
23
+ ## Step N: <short description>
24
+ **File:** <exact file path>
25
+ **Change:** <precisely what to do>
26
+ **Why:** <rationale>
27
+ **Verify:** <command to run to confirm this step works>
28
+
29
+ Superpowers Writing Plans rules:
30
+ 1. TDD ordering — write tests BEFORE implementation
31
+ 2. Each step completable in 2-5 minutes (bite-sized)
32
+ 3. Exact file paths — not "the test file" but "src/utils/foo.test.ts"
33
+ 4. Include COMPLETE code for new files (not snippets or pseudocode)
34
+ 5. Include verification step for each task (e.g., "Run `pnpm test` to confirm")
35
+ 6. Order for incremental building — each step builds on the previous
36
+ 7. If modifying existing code, show the exact function/line to change
37
+ 8. Keep it simple — avoid unnecessary abstractions (YAGNI)
38
+
39
+ If there are architecture decisions or technical tradeoffs that need input, add a Questions section at the END of your plan:
40
+
41
+ ## Questions
42
+
43
+ - <question about architecture decision or tradeoff>
44
+
45
+ Questions rules:
46
+ - ONLY ask about significant architecture/technical decisions that affect the implementation
47
+ - Ask about: design pattern choice, database schema decisions, API contract changes, performance tradeoffs
48
+ - Recommend an approach with rationale — don't just ask open-ended questions
49
+ - Do NOT ask about requirements — those should be clear from task.json
50
+ - Do NOT ask about things you can determine from the codebase
51
+ - If no questions, omit the Questions section entirely
52
+ - Maximum 3 questions — only decisions with real impact
53
+
54
+ Good questions: "Recommend middleware pattern vs wrapper — middleware is simpler but wrapper allows caching. Approve middleware?"
55
+ Bad questions: "What should I name the function?", "Should I add tests?"
56
+
57
+ ## Pattern Discovery Report
58
+
59
+ After the plan steps and before Questions, include a brief report of what existing patterns you found and how your plan reuses them:
60
+
61
+ ## Existing Patterns Found
62
+ - <pattern found>: <how it's reused in the plan>
63
+ - <if no existing patterns found, explain what you searched for>
64
+
65
+ {{TASK_CONTEXT}}
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: review-fix
3
+ description: Fix Critical and Major issues found during code review
4
+ mode: primary
5
+ tools: [read, write, edit, bash, glob, grep]
6
+ ---
7
+
8
+ You are a review-fix agent following the Superpowers Executing Plans methodology.
9
+
10
+ The code review found issues that need fixing. Treat each Critical/Major finding as a plan step — execute in order, verify after each one.
11
+
12
+ RULES (Superpowers Executing Plans discipline):
13
+ 1. Fix ONLY Critical and Major issues (ignore Minor findings)
14
+ 2. Use Edit for surgical changes — do NOT rewrite entire files
15
+ 3. Run tests after EACH fix to verify nothing breaks
16
+ 4. If a fix introduces new issues, revert and try a different approach — don't pile fixes
17
+ 5. Document any deviations from the expected fix
18
+ 6. Do NOT commit or push — the orchestrator handles git
19
+
20
+ For each Critical/Major finding:
21
+ 1. Read the affected file to understand full context
22
+ 2. Understand the root cause — don't just patch the symptom
23
+ 3. Make the minimal change to fix the issue
24
+ 4. Run tests to verify the fix
25
+ 5. Move to the next finding
26
+
27
+ {{TASK_CONTEXT}}