@kkelly-offical/kkcode 0.1.2 → 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 (58) hide show
  1. package/README.md +120 -178
  2. package/package.json +46 -46
  3. package/src/agent/agent.mjs +41 -0
  4. package/src/agent/prompt/frontend-designer.txt +58 -0
  5. package/src/agent/prompt/longagent-blueprint-agent.txt +83 -0
  6. package/src/agent/prompt/longagent-coding-agent.txt +37 -0
  7. package/src/agent/prompt/longagent-debugging-agent.txt +46 -0
  8. package/src/agent/prompt/longagent-preview-agent.txt +63 -0
  9. package/src/config/defaults.mjs +260 -195
  10. package/src/config/schema.mjs +71 -6
  11. package/src/core/constants.mjs +91 -46
  12. package/src/index.mjs +1 -1
  13. package/src/knowledge/frontend-aesthetics.txt +39 -0
  14. package/src/knowledge/loader.mjs +2 -1
  15. package/src/knowledge/tailwind.txt +12 -3
  16. package/src/mcp/client-http.mjs +141 -157
  17. package/src/mcp/client-sse.mjs +288 -286
  18. package/src/mcp/client-stdio.mjs +533 -451
  19. package/src/mcp/constants.mjs +2 -0
  20. package/src/mcp/registry.mjs +479 -394
  21. package/src/mcp/stdio-framing.mjs +133 -127
  22. package/src/mcp/tool-result.mjs +24 -0
  23. package/src/observability/index.mjs +42 -0
  24. package/src/observability/metrics.mjs +137 -0
  25. package/src/observability/tracer.mjs +137 -0
  26. package/src/orchestration/background-manager.mjs +372 -358
  27. package/src/orchestration/background-worker.mjs +305 -245
  28. package/src/orchestration/longagent-manager.mjs +171 -116
  29. package/src/orchestration/stage-scheduler.mjs +728 -489
  30. package/src/permission/exec-policy.mjs +9 -11
  31. package/src/provider/anthropic.mjs +1 -0
  32. package/src/provider/openai.mjs +340 -339
  33. package/src/provider/retry-policy.mjs +68 -68
  34. package/src/provider/router.mjs +241 -228
  35. package/src/provider/sse.mjs +104 -91
  36. package/src/repl.mjs +1 -1
  37. package/src/session/checkpoint.mjs +66 -3
  38. package/src/session/engine.mjs +227 -225
  39. package/src/session/longagent-4stage.mjs +460 -0
  40. package/src/session/longagent-hybrid.mjs +1081 -0
  41. package/src/session/longagent-plan.mjs +365 -329
  42. package/src/session/longagent-project-memory.mjs +53 -0
  43. package/src/session/longagent-scaffold.mjs +291 -100
  44. package/src/session/longagent-task-bus.mjs +54 -0
  45. package/src/session/longagent-utils.mjs +472 -0
  46. package/src/session/longagent.mjs +884 -1462
  47. package/src/session/project-context.mjs +30 -0
  48. package/src/session/store.mjs +510 -503
  49. package/src/session/task-validator.mjs +4 -3
  50. package/src/skill/builtin/design.mjs +76 -0
  51. package/src/skill/builtin/frontend.mjs +8 -0
  52. package/src/skill/registry.mjs +390 -336
  53. package/src/storage/ghost-commit-store.mjs +18 -8
  54. package/src/tool/executor.mjs +11 -0
  55. package/src/tool/git-auto.mjs +0 -19
  56. package/src/tool/registry.mjs +71 -37
  57. package/src/ui/activity-renderer.mjs +664 -410
  58. package/src/util/git.mjs +23 -0
@@ -1,9 +1,10 @@
1
- import { exec as execCb } from "node:child_process"
1
+ import { exec as execCb, execFile as execFileCb } from "node:child_process"
2
2
  import { promisify } from "node:util"
3
3
  import { access, readFile } from "node:fs/promises"
4
4
  import path from "node:path"
5
5
 
6
6
  const exec = promisify(execCb)
7
+ const execFile = promisify(execFileCb)
7
8
 
8
9
  async function fileExists(p) {
9
10
  try { await access(p); return true } catch { return false }
@@ -50,7 +51,7 @@ export class TaskValidator {
50
51
  const errors = []
51
52
  for (const file of jsFiles.slice(0, 20)) {
52
53
  try {
53
- await exec(`node --check "${file}"`, { cwd: this.cwd, timeout: 10000 })
54
+ await execFile("node", ["--check", file], { cwd: this.cwd, timeout: 10000 })
54
55
  } catch (error) {
55
56
  errors.push(`${file}: ${(error.stderr || error.message || "").trim()}`)
56
57
  }
@@ -101,7 +102,7 @@ export class TaskValidator {
101
102
  const errors = []
102
103
  for (const file of pyFiles.slice(0, 20)) {
103
104
  try {
104
- await exec(`python -m py_compile "${file}"`, { cwd: this.cwd, timeout: 10000 })
105
+ await execFile("python", ["-m", "py_compile", file], { cwd: this.cwd, timeout: 10000 })
105
106
  } catch (error) {
106
107
  errors.push(`${file}: ${(error.stderr || error.message || "").trim()}`)
107
108
  }
@@ -0,0 +1,76 @@
1
+ import { readFile } from "node:fs/promises"
2
+ import path from "node:path"
3
+
4
+ export const name = "design"
5
+ export const description = "Frontend design mode — generates polished, distinctive UI with strong aesthetics (usage: /design <task>)"
6
+
7
+ async function detectDesignContext(cwd) {
8
+ try {
9
+ const pkg = JSON.parse(await readFile(path.join(cwd, "package.json"), "utf8"))
10
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
11
+ const ctx = {}
12
+ // Framework
13
+ if (deps.next) ctx.framework = "next"
14
+ else if (deps.nuxt) ctx.framework = "nuxt"
15
+ else if (deps.vue) ctx.framework = "vue"
16
+ else if (deps.react) ctx.framework = "react"
17
+ else if (deps.svelte || deps["@sveltejs/kit"]) ctx.framework = "svelte"
18
+ // CSS
19
+ if (deps.tailwindcss) ctx.css = "tailwind"
20
+ else if (deps.unocss) ctx.css = "unocss"
21
+ else if (deps["styled-components"]) ctx.css = "styled-components"
22
+ // Component lib
23
+ if (deps.antd) ctx.lib = "antd"
24
+ else if (deps["element-plus"]) ctx.lib = "element-plus"
25
+ else if (deps["@mui/material"]) ctx.lib = "mui"
26
+ else if (deps["@chakra-ui/react"]) ctx.lib = "chakra-ui"
27
+ else if (deps["@mantine/core"]) ctx.lib = "mantine"
28
+ else if (deps["naive-ui"]) ctx.lib = "naive-ui"
29
+ return ctx
30
+ } catch { return {} }
31
+ }
32
+
33
+ const AESTHETICS_PROMPT = `<frontend_aesthetics>
34
+ You are in DESIGN MODE. Create polished, distinctive frontends — NOT generic AI output.
35
+
36
+ Typography: Avoid Inter/Roboto/Arial. Use distinctive fonts (Space Grotesk, Playfair Display, Satoshi, IBM Plex). Extreme weight contrast (200 vs 800), 3x+ size jumps.
37
+
38
+ Color: CSS variables for ALL colors. Dominant color + sharp accent. Draw from IDE themes (Nord, Catppuccin), cultural aesthetics. AVOID purple-gradient-on-white.
39
+
40
+ Motion: One high-impact staggered reveal per page. Micro-interactions on hover/focus/press. CSS transitions + animation-delay.
41
+
42
+ Layout: CSS Grid for pages, Flexbox for components. Generous whitespace. Consistent 4px spacing scale. Mobile-first.
43
+
44
+ Depth: Layered gradients, backdrop-filter glass, box-shadow elevation hierarchy.
45
+
46
+ NEVER: cookie-cutter card grids, generic hero sections, border-radius:9999px everywhere, gray wireframe text, no visual rhythm.
47
+ </frontend_aesthetics>`
48
+
49
+ export async function run(ctx) {
50
+ const task = (ctx.args || "").trim()
51
+ const cwd = ctx.cwd || process.cwd()
52
+ const design = await detectDesignContext(cwd)
53
+
54
+ const parts = [AESTHETICS_PROMPT, ""]
55
+
56
+ if (Object.keys(design).length) {
57
+ parts.push("## Project Design Context")
58
+ if (design.framework) parts.push(`- Framework: ${design.framework}`)
59
+ if (design.css) parts.push(`- CSS: ${design.css}`)
60
+ if (design.lib) parts.push(`- Component Library: ${design.lib}`)
61
+ parts.push("")
62
+ parts.push("Read the project's existing styles/theme before writing new code. Extend, don't replace.")
63
+ parts.push("")
64
+ }
65
+
66
+ if (task) {
67
+ parts.push(`## Task`)
68
+ parts.push(task)
69
+ parts.push("")
70
+ parts.push("Implement this with production-grade design quality. Make it look like a professional designer built it.")
71
+ } else {
72
+ parts.push("No task specified. Usage: /design <description of what to build>")
73
+ }
74
+
75
+ return parts.join("\n")
76
+ }
@@ -178,6 +178,14 @@ export async function run(ctx) {
178
178
  parts.push(" npm create vite@latest . -- --template vanilla-ts")
179
179
  }
180
180
 
181
+ parts.push("")
182
+ parts.push("## Design Quality")
183
+ parts.push("- Read existing styles/theme/config before writing new CSS")
184
+ parts.push("- Use CSS variables for colors. Prefer project's design tokens over hardcoded values")
185
+ parts.push("- Add transitions for interactive elements (hover, focus, active states)")
186
+ parts.push("- Consistent spacing scale. Generous whitespace.")
187
+ parts.push("- For new UI: use /design for full design mode with aesthetics guidance")
188
+
181
189
  if (task) {
182
190
  parts.push("")
183
191
  parts.push("Now implement the task described above using the project's framework and conventions.")