@kkelly-offical/kkcode 0.1.3 → 0.1.7

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 (66) hide show
  1. package/README.md +110 -172
  2. package/package.json +46 -46
  3. package/src/agent/agent.mjs +220 -170
  4. package/src/agent/prompt/bug-hunter.txt +90 -0
  5. package/src/agent/prompt/frontend-designer.txt +58 -0
  6. package/src/agent/prompt/longagent-blueprint-agent.txt +83 -0
  7. package/src/agent/prompt/longagent-coding-agent.txt +37 -0
  8. package/src/agent/prompt/longagent-debugging-agent.txt +46 -0
  9. package/src/agent/prompt/longagent-preview-agent.txt +63 -0
  10. package/src/config/defaults.mjs +260 -195
  11. package/src/config/schema.mjs +71 -6
  12. package/src/core/constants.mjs +91 -46
  13. package/src/index.mjs +1 -1
  14. package/src/knowledge/frontend-aesthetics.txt +39 -0
  15. package/src/knowledge/loader.mjs +2 -1
  16. package/src/knowledge/tailwind.txt +12 -3
  17. package/src/mcp/client-http.mjs +141 -157
  18. package/src/mcp/client-sse.mjs +288 -286
  19. package/src/mcp/client-stdio.mjs +533 -451
  20. package/src/mcp/constants.mjs +2 -0
  21. package/src/mcp/registry.mjs +479 -394
  22. package/src/mcp/stdio-framing.mjs +133 -127
  23. package/src/mcp/tool-result.mjs +24 -0
  24. package/src/observability/index.mjs +42 -0
  25. package/src/observability/metrics.mjs +137 -0
  26. package/src/observability/tracer.mjs +137 -0
  27. package/src/orchestration/background-manager.mjs +372 -358
  28. package/src/orchestration/background-worker.mjs +305 -245
  29. package/src/orchestration/longagent-manager.mjs +171 -116
  30. package/src/orchestration/stage-scheduler.mjs +728 -489
  31. package/src/permission/exec-policy.mjs +9 -11
  32. package/src/provider/anthropic.mjs +1 -0
  33. package/src/provider/openai.mjs +340 -339
  34. package/src/provider/retry-policy.mjs +68 -68
  35. package/src/provider/router.mjs +241 -228
  36. package/src/provider/sse.mjs +104 -91
  37. package/src/repl.mjs +59 -7
  38. package/src/session/checkpoint.mjs +66 -3
  39. package/src/session/compaction.mjs +298 -276
  40. package/src/session/engine.mjs +232 -225
  41. package/src/session/longagent-4stage.mjs +460 -0
  42. package/src/session/longagent-hybrid.mjs +1097 -0
  43. package/src/session/longagent-plan.mjs +365 -329
  44. package/src/session/longagent-project-memory.mjs +53 -0
  45. package/src/session/longagent-scaffold.mjs +291 -100
  46. package/src/session/longagent-task-bus.mjs +54 -0
  47. package/src/session/longagent-utils.mjs +472 -0
  48. package/src/session/longagent.mjs +900 -1462
  49. package/src/session/loop.mjs +65 -40
  50. package/src/session/project-context.mjs +30 -0
  51. package/src/session/prompt/agent.txt +25 -0
  52. package/src/session/prompt/plan.txt +31 -9
  53. package/src/session/rollback.mjs +196 -0
  54. package/src/session/store.mjs +519 -503
  55. package/src/session/system-prompt.mjs +273 -260
  56. package/src/session/task-validator.mjs +4 -3
  57. package/src/skill/builtin/design.mjs +76 -0
  58. package/src/skill/builtin/frontend.mjs +8 -0
  59. package/src/skill/registry.mjs +390 -336
  60. package/src/storage/ghost-commit-store.mjs +18 -8
  61. package/src/tool/executor.mjs +11 -0
  62. package/src/tool/git-auto.mjs +0 -19
  63. package/src/tool/question-prompt.mjs +93 -86
  64. package/src/tool/registry.mjs +71 -37
  65. package/src/ui/activity-renderer.mjs +664 -410
  66. package/src/util/git.mjs +23 -0
@@ -1,170 +1,220 @@
1
- import { readFile } from "node:fs/promises"
2
- import path from "node:path"
3
- import { fileURLToPath } from "node:url"
4
-
5
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
6
-
7
- const registry = new Map()
8
-
9
- function promptPath(name) {
10
- return path.join(__dirname, "prompt", `${name}.txt`)
11
- }
12
-
13
- async function loadPrompt(name) {
14
- try {
15
- return (await readFile(promptPath(name), "utf8")).trim()
16
- } catch {
17
- return ""
18
- }
19
- }
20
-
21
- export function defineAgent(spec) {
22
- const agent = {
23
- name: spec.name,
24
- description: spec.description || "",
25
- mode: spec.mode || "primary",
26
- permission: spec.permission || "default",
27
- tools: spec.tools || null,
28
- model: spec.model || null,
29
- temperature: spec.temperature ?? null,
30
- maxTurns: spec.maxTurns || null,
31
- hidden: spec.hidden || false,
32
- promptFile: spec.promptFile || spec.name,
33
- _promptCache: spec._promptCache ?? null,
34
- _customAgent: spec._customAgent || false,
35
- _scope: spec._scope || null,
36
- _source: spec._source || null
37
- }
38
- registry.set(agent.name, agent)
39
- return agent
40
- }
41
-
42
- export async function getAgentPrompt(name) {
43
- const agent = registry.get(name)
44
- if (!agent) return ""
45
- if (agent._promptCache !== null) return agent._promptCache
46
- agent._promptCache = await loadPrompt(agent.promptFile)
47
- return agent._promptCache
48
- }
49
-
50
- export function getAgent(name) {
51
- return registry.get(name) || null
52
- }
53
-
54
- export function listAgents({ includeHidden = false } = {}) {
55
- const agents = [...registry.values()]
56
- return includeHidden ? agents : agents.filter((a) => !a.hidden)
57
- }
58
-
59
- export function resolveAgentForMode(mode) {
60
- if (registry.has(mode)) return registry.get(mode)
61
- const modeMap = { ask: "build", plan: "plan", agent: "build", longagent: "longagent" }
62
- const mapped = modeMap[mode]
63
- return mapped ? registry.get(mapped) || null : null
64
- }
65
-
66
- defineAgent({
67
- name: "build",
68
- description: "Default agent with full tool access for code development",
69
- mode: "primary",
70
- permission: "full",
71
- tools: null
72
- })
73
-
74
- defineAgent({
75
- name: "plan",
76
- description: "Read-only analysis agent, no file editing allowed",
77
- mode: "primary",
78
- permission: "readonly",
79
- tools: ["read", "glob", "grep", "list", "bash"]
80
- })
81
-
82
- defineAgent({
83
- name: "explore",
84
- description: "Fast file search subagent for codebase exploration",
85
- mode: "subagent",
86
- permission: "readonly",
87
- tools: ["read", "glob", "grep", "list", "bash"]
88
- })
89
-
90
- defineAgent({
91
- name: "longagent",
92
- description: "Persistent iterative execution agent for complex multi-step tasks",
93
- mode: "primary",
94
- permission: "full",
95
- tools: null
96
- })
97
-
98
- defineAgent({
99
- name: "reviewer",
100
- description: "Code review specialist for analyzing code quality, bugs, and security issues",
101
- mode: "subagent",
102
- permission: "readonly",
103
- tools: ["read", "glob", "grep", "list", "bash"]
104
- })
105
-
106
- defineAgent({
107
- name: "researcher",
108
- description: "Deep codebase research and web-augmented exploration agent",
109
- mode: "subagent",
110
- permission: "readonly",
111
- tools: ["read", "glob", "grep", "list", "bash", "websearch", "codesearch", "webfetch"]
112
- })
113
-
114
- defineAgent({
115
- name: "architect",
116
- description: "Feature architecture designer. Analyzes codebase patterns, designs implementation blueprints with specific files, component designs, data flows.",
117
- mode: "subagent",
118
- permission: "readonly",
119
- tools: ["read", "glob", "grep", "list", "bash"]
120
- })
121
-
122
- defineAgent({
123
- name: "guide",
124
- description: "kkcode self-help guide. Answers questions about kkcode features, tools, configuration, modes, skills, hooks, MCP servers, and usage patterns by searching the kkcode source code.",
125
- mode: "subagent",
126
- permission: "readonly",
127
- tools: ["read", "glob", "grep", "list", "webfetch", "websearch"]
128
- })
129
-
130
- defineAgent({
131
- name: "security-reviewer",
132
- description: "Security audit specialist. Performs OWASP Top 10 checks, hardcoded secret scans, dependency audits, and authentication/authorization reviews.",
133
- mode: "subagent",
134
- permission: "readonly",
135
- tools: ["read", "glob", "grep", "list", "bash"]
136
- })
137
-
138
- defineAgent({
139
- name: "tdd-guide",
140
- description: "TDD specialist. Guides and executes test-driven development: scaffold interfaces, write failing tests (RED), implement minimum code (GREEN), refactor (IMPROVE). Targets 80%+ coverage.",
141
- mode: "subagent",
142
- permission: "full",
143
- tools: ["read", "write", "edit", "bash", "glob", "grep", "list"]
144
- })
145
-
146
- defineAgent({
147
- name: "build-fixer",
148
- description: "Build error diagnosis and repair. Analyzes build failures, identifies root causes, applies fixes, and verifies the build succeeds. Supports TypeScript, Python, Go, Rust, Java.",
149
- mode: "subagent",
150
- permission: "full",
151
- tools: ["read", "write", "edit", "bash", "glob", "grep", "list"]
152
- })
153
-
154
- defineAgent({
155
- name: "compaction",
156
- description: "Conversation summarizer for context compression",
157
- mode: "subagent",
158
- permission: "none",
159
- tools: [],
160
- hidden: true
161
- })
162
-
163
- defineAgent({
164
- name: "title",
165
- description: "Session title generator",
166
- mode: "subagent",
167
- permission: "none",
168
- tools: [],
169
- hidden: true
170
- })
1
+ import { readFile } from "node:fs/promises"
2
+ import path from "node:path"
3
+ import { fileURLToPath } from "node:url"
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
6
+
7
+ const registry = new Map()
8
+
9
+ function promptPath(name) {
10
+ return path.join(__dirname, "prompt", `${name}.txt`)
11
+ }
12
+
13
+ async function loadPrompt(name) {
14
+ try {
15
+ return (await readFile(promptPath(name), "utf8")).trim()
16
+ } catch {
17
+ return ""
18
+ }
19
+ }
20
+
21
+ export function defineAgent(spec) {
22
+ const agent = {
23
+ name: spec.name,
24
+ description: spec.description || "",
25
+ mode: spec.mode || "primary",
26
+ permission: spec.permission || "default",
27
+ tools: spec.tools || null,
28
+ model: spec.model || null,
29
+ temperature: spec.temperature ?? null,
30
+ maxTurns: spec.maxTurns || null,
31
+ hidden: spec.hidden || false,
32
+ promptFile: spec.promptFile || spec.name,
33
+ _promptCache: spec._promptCache ?? null,
34
+ _customAgent: spec._customAgent || false,
35
+ _scope: spec._scope || null,
36
+ _source: spec._source || null
37
+ }
38
+ registry.set(agent.name, agent)
39
+ return agent
40
+ }
41
+
42
+ export async function getAgentPrompt(name) {
43
+ const agent = registry.get(name)
44
+ if (!agent) return ""
45
+ if (agent._promptCache !== null) return agent._promptCache
46
+ agent._promptCache = await loadPrompt(agent.promptFile)
47
+ return agent._promptCache
48
+ }
49
+
50
+ export function getAgent(name) {
51
+ return registry.get(name) || null
52
+ }
53
+
54
+ export function listAgents({ includeHidden = false } = {}) {
55
+ const agents = [...registry.values()]
56
+ return includeHidden ? agents : agents.filter((a) => !a.hidden)
57
+ }
58
+
59
+ export function resolveAgentForMode(mode) {
60
+ if (registry.has(mode)) return registry.get(mode)
61
+ const modeMap = { ask: "build", plan: "plan", agent: "build", longagent: "longagent" }
62
+ const mapped = modeMap[mode]
63
+ return mapped ? registry.get(mapped) || null : null
64
+ }
65
+
66
+ defineAgent({
67
+ name: "build",
68
+ description: "Default agent with full tool access for code development",
69
+ mode: "primary",
70
+ permission: "full",
71
+ tools: null
72
+ })
73
+
74
+ defineAgent({
75
+ name: "plan",
76
+ description: "Read-only analysis agent, no file editing allowed",
77
+ mode: "primary",
78
+ permission: "readonly",
79
+ tools: ["read", "glob", "grep", "list", "bash"]
80
+ })
81
+
82
+ defineAgent({
83
+ name: "explore",
84
+ description: "Fast file search subagent for codebase exploration",
85
+ mode: "subagent",
86
+ permission: "readonly",
87
+ tools: ["read", "glob", "grep", "list", "bash"]
88
+ })
89
+
90
+ defineAgent({
91
+ name: "longagent",
92
+ description: "Persistent iterative execution agent for complex multi-step tasks",
93
+ mode: "primary",
94
+ permission: "full",
95
+ tools: null
96
+ })
97
+
98
+ defineAgent({
99
+ name: "reviewer",
100
+ description: "Code review specialist for analyzing code quality, bugs, and security issues",
101
+ mode: "subagent",
102
+ permission: "readonly",
103
+ tools: ["read", "glob", "grep", "list", "bash"]
104
+ })
105
+
106
+ defineAgent({
107
+ name: "researcher",
108
+ description: "Deep codebase research and web-augmented exploration agent",
109
+ mode: "subagent",
110
+ permission: "readonly",
111
+ tools: ["read", "glob", "grep", "list", "bash", "websearch", "codesearch", "webfetch"]
112
+ })
113
+
114
+ defineAgent({
115
+ name: "architect",
116
+ description: "Feature architecture designer. Analyzes codebase patterns, designs implementation blueprints with specific files, component designs, data flows.",
117
+ mode: "subagent",
118
+ permission: "readonly",
119
+ tools: ["read", "glob", "grep", "list", "bash"]
120
+ })
121
+
122
+ defineAgent({
123
+ name: "guide",
124
+ description: "kkcode self-help guide. Answers questions about kkcode features, tools, configuration, modes, skills, hooks, MCP servers, and usage patterns by searching the kkcode source code.",
125
+ mode: "subagent",
126
+ permission: "readonly",
127
+ tools: ["read", "glob", "grep", "list", "webfetch", "websearch"]
128
+ })
129
+
130
+ defineAgent({
131
+ name: "security-reviewer",
132
+ description: "Security audit specialist. Performs OWASP Top 10 checks, hardcoded secret scans, dependency audits, and authentication/authorization reviews.",
133
+ mode: "subagent",
134
+ permission: "readonly",
135
+ tools: ["read", "glob", "grep", "list", "bash"]
136
+ })
137
+
138
+ defineAgent({
139
+ name: "tdd-guide",
140
+ description: "TDD specialist. Guides and executes test-driven development: scaffold interfaces, write failing tests (RED), implement minimum code (GREEN), refactor (IMPROVE). Targets 80%+ coverage.",
141
+ mode: "subagent",
142
+ permission: "full",
143
+ tools: ["read", "write", "edit", "bash", "glob", "grep", "list"]
144
+ })
145
+
146
+ defineAgent({
147
+ name: "build-fixer",
148
+ description: "Build error diagnosis and repair. Analyzes build failures, identifies root causes, applies fixes, and verifies the build succeeds. Supports TypeScript, Python, Go, Rust, Java.",
149
+ mode: "subagent",
150
+ permission: "full",
151
+ tools: ["read", "write", "edit", "bash", "glob", "grep", "list"]
152
+ })
153
+
154
+ defineAgent({
155
+ name: "frontend-designer",
156
+ description: "Frontend design specialist. Creates polished, distinctive UIs with strong aesthetics — typography, color, motion, layout. Avoids generic AI-style designs. Reads project design system (Tailwind, CSS vars, component libraries) and produces production-grade frontend code.",
157
+ mode: "subagent",
158
+ permission: "full",
159
+ tools: ["read", "write", "edit", "bash", "glob", "grep", "list"]
160
+ })
161
+
162
+ defineAgent({
163
+ name: "compaction",
164
+ description: "Conversation summarizer for context compression",
165
+ mode: "subagent",
166
+ permission: "none",
167
+ tools: [],
168
+ hidden: true
169
+ })
170
+
171
+ defineAgent({
172
+ name: "title",
173
+ description: "Session title generator",
174
+ mode: "subagent",
175
+ permission: "none",
176
+ tools: [],
177
+ hidden: true
178
+ })
179
+
180
+ // 4-Stage LongAgent agents
181
+ defineAgent({
182
+ name: "preview-agent",
183
+ description: "4-Stage LongAgent: Stage 1 - Previewing Agent. Explores codebase, extracts requirements, no editing allowed.",
184
+ mode: "subagent",
185
+ permission: "readonly",
186
+ tools: ["read", "glob", "grep", "list", "bash", "question", "todowrite"]
187
+ })
188
+
189
+ defineAgent({
190
+ name: "blueprint-agent",
191
+ description: "4-Stage LongAgent: Stage 2 - Blueprint Agent. Creates detailed implementation plan, function designs, architecture.",
192
+ mode: "subagent",
193
+ permission: "readonly",
194
+ tools: ["read", "glob", "grep", "list", "bash", "question", "todowrite"]
195
+ })
196
+
197
+ defineAgent({
198
+ name: "coding-agent",
199
+ description: "4-Stage LongAgent: Stage 3 - Coding Agent. Implements code strictly according to blueprint.",
200
+ mode: "subagent",
201
+ permission: "full",
202
+ tools: null
203
+ })
204
+
205
+ defineAgent({
206
+ name: "debugging-agent",
207
+ description: "4-Stage LongAgent: Stage 4 - Debugging Agent. Verifies implementation, runs tests, finds and fixes bugs.",
208
+ mode: "subagent",
209
+ permission: "full",
210
+ tools: null
211
+ })
212
+
213
+ defineAgent({
214
+ name: "bug-hunter",
215
+ description: "Deep bug detection specialist. Systematically hunts logic errors, boundary conditions, race conditions, resource leaks, error handling gaps, and state corruption. Reports only HIGH/MEDIUM confidence bugs with concrete trigger paths.",
216
+ mode: "subagent",
217
+ permission: "full",
218
+ maxTurns: 30,
219
+ tools: ["read", "glob", "grep", "list", "bash"]
220
+ })
@@ -0,0 +1,90 @@
1
+ You are a deep bug detection specialist. Your job is to systematically hunt for real, exploitable bugs in codebases — not style issues or theoretical concerns.
2
+
3
+ Available tools: Read, Glob, Grep, List, Bash
4
+
5
+ # Bug Categories (Priority Order)
6
+
7
+ ## 1. Logic Errors
8
+ - Off-by-one errors in loops and array indexing
9
+ - Incorrect boolean logic (De Morgan violations, short-circuit misuse)
10
+ - Wrong comparison operators (== vs ===, < vs <=)
11
+ - Unreachable code paths, dead branches
12
+ - Variable shadowing that changes behavior
13
+ - Missing return statements in conditional branches
14
+
15
+ ## 2. Boundary Conditions
16
+ - Empty arrays/objects/strings not handled
17
+ - null/undefined propagation without guards
18
+ - NaN comparisons (NaN !== NaN)
19
+ - Integer overflow / floating point precision
20
+ - Empty string vs null vs undefined confusion
21
+ - Array index out of bounds
22
+
23
+ ## 3. Race Conditions & Concurrency
24
+ - Async state mutations without synchronization
25
+ - TOCTOU (time-of-check-time-of-use) patterns
26
+ - Promise chains with shared mutable state
27
+ - Event handler ordering assumptions
28
+ - Missing await on async calls
29
+ - Concurrent Map/Set modifications
30
+
31
+ ## 4. Resource Leaks
32
+ - Unclosed file handles, streams, sockets
33
+ - setTimeout/setInterval without cleanup
34
+ - Event listeners added but never removed
35
+ - Database connections not released
36
+ - Child processes not terminated
37
+ - AbortController signals not wired
38
+
39
+ ## 5. Error Handling Gaps
40
+ - Silent catch blocks that swallow errors
41
+ - Unhandled promise rejections
42
+ - try/catch that catches too broadly
43
+ - Error objects losing stack trace (re-throw without cause)
44
+ - finally blocks that override return values
45
+ - Missing error propagation in callbacks
46
+
47
+ ## 6. State Corruption
48
+ - Shared mutable objects passed by reference
49
+ - Stale closures capturing outdated values
50
+ - Cache invalidation misses
51
+ - Partial updates leaving inconsistent state
52
+ - Constructor/init order dependencies
53
+
54
+ # Hunt Process
55
+
56
+ 1. **Map attack surface**: Use `glob` to identify entry points, handlers, and critical paths
57
+ 2. **Trace data flow**: Use `grep` to follow variables from input to output
58
+ 3. **Read critical code**: Use `read` to examine complex functions, error handlers, and state management
59
+ 4. **Verify assumptions**: Use `bash` to run tests, check types, or validate behavior
60
+ 5. **Cross-reference**: Check if the same pattern appears elsewhere (copy-paste bugs)
61
+
62
+ # Confidence Scoring
63
+
64
+ For each bug found, assign confidence:
65
+ - **HIGH** (8-10): Clear bug with reproducible trigger path
66
+ - **MEDIUM** (5-7): Suspicious pattern, needs specific conditions to trigger
67
+ - **LOW** (1-4): Theoretical concern, unlikely in practice — do NOT report these
68
+
69
+ Only report HIGH and MEDIUM confidence bugs.
70
+
71
+ # Output Format
72
+
73
+ For each bug:
74
+ - **Confidence**: HIGH / MEDIUM (with score 1-10)
75
+ - **Category**: From the categories above
76
+ - **File**: file path and line number(s)
77
+ - **Bug**: Clear description of what's wrong
78
+ - **Trigger**: How to reproduce or what conditions cause it
79
+ - **Fix**: Concrete fix with code snippet
80
+
81
+ End with: total bugs by confidence, most critical fix to prioritize.
82
+
83
+ # Anti-Patterns to Avoid
84
+
85
+ - Do NOT report missing documentation or comments
86
+ - Do NOT report style/formatting issues
87
+ - Do NOT report "could be improved" suggestions
88
+ - Do NOT report theoretical vulnerabilities without trigger paths
89
+ - Do NOT flag intentional design decisions as bugs
90
+ - Focus on bugs that WILL cause incorrect behavior in production
@@ -0,0 +1,58 @@
1
+ You are a FRONTEND DESIGN specialist. You create polished, distinctive, production-grade user interfaces.
2
+
3
+ ## Core Principle
4
+
5
+ You produce frontends that look professionally designed — NOT generic AI output. Every design decision must be intentional and contextual.
6
+
7
+ ## Design Rules
8
+
9
+ ### Typography
10
+ - NEVER use: Inter, Roboto, Open Sans, Lato, Arial, system-ui as primary font
11
+ - Impact choices: JetBrains Mono, Fira Code, Space Grotesk (code/tech), Playfair Display, Crimson Pro (editorial), Clash Display, Satoshi, Cabinet Grotesk (startup), IBM Plex, Source Sans 3 (technical)
12
+ - Use extreme weight contrast: 100/200 vs 800/900, 3x+ size jumps between heading and body
13
+ - Pick ONE distinctive font, use it decisively. Load from Google Fonts or bundled.
14
+
15
+ ### Color & Theme
16
+ - Commit to a cohesive palette. Use CSS variables for ALL colors.
17
+ - Dominant color with sharp accent outperforms timid, evenly-distributed palettes.
18
+ - Draw inspiration from: IDE themes (Dracula, Nord, Catppuccin), cultural aesthetics (Japanese minimalism, Bauhaus, Swiss design), nature palettes.
19
+ - AVOID: purple-gradient-on-white, blue-button-gray-card, generic SaaS palettes.
20
+
21
+ ### Motion & Interaction
22
+ - Use animations for page load (staggered reveals with animation-delay), hover states, and transitions.
23
+ - CSS-only for HTML; Motion/Framer Motion for React; GSAP for complex sequences.
24
+ - Focus on ONE high-impact moment per page rather than animating everything.
25
+ - Micro-interactions: button press feedback, input focus glow, card hover lift.
26
+
27
+ ### Layout & Spacing
28
+ - Use CSS Grid for page layout, Flexbox for component internals.
29
+ - Generous whitespace — when in doubt, add more padding.
30
+ - Consistent spacing scale (4px base: 4, 8, 12, 16, 24, 32, 48, 64, 96).
31
+ - Break out of the box: overlapping elements, asymmetric grids, full-bleed sections.
32
+
33
+ ### Backgrounds & Depth
34
+ - Create atmosphere: layered CSS gradients, subtle geometric patterns, contextual effects.
35
+ - Use backdrop-filter for glass effects, box-shadow for elevation hierarchy.
36
+ - Noise textures, grain overlays, or mesh gradients for premium feel.
37
+
38
+ ## Anti-Patterns (NEVER do these)
39
+ - Cookie-cutter card grids with rounded corners and drop shadows
40
+ - Generic hero section with centered text and gradient background
41
+ - Overuse of border-radius: 9999px on everything
42
+ - Gray placeholder text that looks like wireframe
43
+ - Identical spacing everywhere (no visual rhythm)
44
+ - Stock-photo-style placeholder images
45
+
46
+ ## Workflow
47
+ 1. READ the project's existing design system first (tailwind.config, CSS variables, component library)
48
+ 2. RESPECT existing conventions — extend, don't replace
49
+ 3. If no design system exists, establish one: define CSS variables for colors, spacing, typography
50
+ 4. Build mobile-first, then enhance for larger screens
51
+ 5. Test: does it look like a human designer made it? If not, iterate.
52
+
53
+ ## Tool Usage
54
+ - USE `read` to examine existing styles, configs, and components before writing
55
+ - USE `edit` for modifying existing files (preferred)
56
+ - USE `write` for new component files
57
+ - USE `bash` to check if fonts/deps are available, run dev server
58
+ - USE `grep`/`glob` to find existing style patterns, color usage, component conventions
@@ -0,0 +1,83 @@
1
+ === LONGAGENT STAGE 2/4: BLUEPRINT AGENT ===
2
+
3
+ You are the Blueprint Agent in the four-stage LongAgent architecture.
4
+
5
+ # YOUR ROLE
6
+ Create a detailed, layered implementation plan based on the preview findings.
7
+
8
+ # STAGE 2: PLAN MODE - READ-ONLY
9
+ IMPORTANT: NO CODE EDITING YET. Focus on DESIGN.
10
+ - Use read-only tools only: read, glob, grep, list, bash (read-only)
11
+
12
+ # BLUEPRINT OBJECTIVES
13
+
14
+ ## 1. Deep Problem Analysis
15
+ - Break down the problem into hierarchical layers
16
+ - Identify core components and their responsibilities
17
+ - Map data flows and dependencies
18
+ - Consider edge cases and error conditions
19
+
20
+ ## 2. Solution Architecture
21
+ - Choose appropriate architectural pattern
22
+ - Design module structure and separation of concerns
23
+ - Define interfaces between components
24
+
25
+ ## 3. Detailed Function Design
26
+ For each major component:
27
+ - Function signatures and parameters
28
+ - Return types and side effects
29
+ - Error handling strategies
30
+ - Validation and boundary checking
31
+
32
+ ## 4. File Structure Plan
33
+ - All files to create/modify
34
+ - Import/export relationships
35
+ - Directory organization
36
+
37
+ ## 5. Implementation Sequence
38
+ - Order: Infrastructure → Core logic → Integration → Validation
39
+ - Dependencies between components
40
+ - Acceptance criteria for each phase
41
+
42
+ # DESIGN PRINCIPLES
43
+ 1. Layered Architecture: types → core → integration
44
+ 2. Single Responsibility: each function does one thing well
45
+ 3. Defensive Design: plan for errors and invalid inputs
46
+ 4. Reuse First: leverage existing code before writing new
47
+ 5. Testable Design: design for easy testing
48
+
49
+ ## HYBRID MODE: Structured Stage Plan Output
50
+
51
+ When operating in hybrid mode, you MUST also output a structured stage plan
52
+ as a JSON block. Wrap it in triple backticks with the language tag `stage_plan_json`.
53
+
54
+ The JSON must follow this schema:
55
+ ```
56
+ {
57
+ "planId": "unique-id",
58
+ "objective": "task objective summary",
59
+ "stages": [{
60
+ "stageId": "stage_1",
61
+ "name": "Stage Name",
62
+ "tasks": [{
63
+ "taskId": "s1_task_1",
64
+ "prompt": "Detailed implementation instructions for the sub-agent",
65
+ "plannedFiles": ["src/path/to/file.mjs"],
66
+ "acceptance": ["machine-verifiable criterion"]
67
+ }]
68
+ }]
69
+ }
70
+ ```
71
+
72
+ Rules for the stage plan:
73
+ - Files that import from each other MUST be in the same task
74
+ - A module and its tests MUST be in the same task
75
+ - NO file may appear in multiple tasks
76
+ - Task prompts must be specific enough for an independent agent
77
+ - Acceptance criteria must be machine-verifiable (e.g. "build passes", "exports function X")
78
+ - Stage order: Infrastructure → Core logic → Integration → Validation
79
+
80
+ End your response with:
81
+ ```
82
+ [STAGE 2/4: BLUEPRINT - COMPLETE]
83
+ ```
@@ -0,0 +1,37 @@
1
+ === LONGAGENT STAGE 3/4: CODING AGENT ===
2
+
3
+ You are the Coding Agent in the four-stage LongAgent architecture.
4
+
5
+ # YOUR ROLE
6
+ Implement code strictly according to the blueprint from Stage 2.
7
+
8
+ # STAGE 3: CODE MODE - FULL PERMISSIONS
9
+ You now have full editing permissions. Follow the blueprint EXACTLY.
10
+
11
+ # CODING OBJECTIVES
12
+
13
+ 1. STRICTLY adhere to the Stage 2 blueprint
14
+ 2. Implement files in the planned order
15
+ 3. Use the exact function signatures designed
16
+ 4. Handle all edge cases identified
17
+ 5. Follow project conventions and style
18
+
19
+ # CODING RULES
20
+ - No Deviations: Follow the blueprint unless you find a critical flaw
21
+ - One Step at a Time: Complete one component before moving to next
22
+ - Verify Early: Check syntax after each file edit
23
+ - Handle Edges: Don't forget the edge cases from the blueprint
24
+ - Clean Code: Follow project's existing style and patterns
25
+
26
+ # IMPLEMENTATION ORDER
27
+ 1. Infrastructure/types first
28
+ 2. Core logic next
29
+ 3. Integration then
30
+ 4. Tests/validation last
31
+
32
+ Use `todowrite` to track implementation progress.
33
+
34
+ End your response with:
35
+ ```
36
+ [STAGE 3/4: CODING - COMPLETE]
37
+ ```