@kkelly-offical/kkcode 0.1.2

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 (196) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +445 -0
  3. package/package.json +46 -0
  4. package/src/agent/agent.mjs +170 -0
  5. package/src/agent/custom-agent-loader.mjs +158 -0
  6. package/src/agent/generator.mjs +115 -0
  7. package/src/agent/prompt/architect.txt +36 -0
  8. package/src/agent/prompt/build-fixer.txt +71 -0
  9. package/src/agent/prompt/build.txt +101 -0
  10. package/src/agent/prompt/compaction.txt +12 -0
  11. package/src/agent/prompt/explore.txt +29 -0
  12. package/src/agent/prompt/guide.txt +40 -0
  13. package/src/agent/prompt/longagent.txt +178 -0
  14. package/src/agent/prompt/plan.txt +50 -0
  15. package/src/agent/prompt/researcher.txt +23 -0
  16. package/src/agent/prompt/reviewer.txt +44 -0
  17. package/src/agent/prompt/security-reviewer.txt +62 -0
  18. package/src/agent/prompt/tdd-guide.txt +84 -0
  19. package/src/agent/prompt/title.txt +8 -0
  20. package/src/command/custom-commands.mjs +57 -0
  21. package/src/commands/agent.mjs +71 -0
  22. package/src/commands/audit.mjs +77 -0
  23. package/src/commands/background.mjs +86 -0
  24. package/src/commands/chat.mjs +114 -0
  25. package/src/commands/command.mjs +41 -0
  26. package/src/commands/config.mjs +44 -0
  27. package/src/commands/doctor.mjs +148 -0
  28. package/src/commands/hook.mjs +29 -0
  29. package/src/commands/init.mjs +141 -0
  30. package/src/commands/longagent.mjs +100 -0
  31. package/src/commands/mcp.mjs +89 -0
  32. package/src/commands/permission.mjs +36 -0
  33. package/src/commands/prompt.mjs +42 -0
  34. package/src/commands/review.mjs +266 -0
  35. package/src/commands/rule.mjs +34 -0
  36. package/src/commands/session.mjs +235 -0
  37. package/src/commands/theme.mjs +98 -0
  38. package/src/commands/usage.mjs +91 -0
  39. package/src/config/defaults.mjs +195 -0
  40. package/src/config/import-config.mjs +76 -0
  41. package/src/config/load-config.mjs +76 -0
  42. package/src/config/schema.mjs +509 -0
  43. package/src/context.mjs +40 -0
  44. package/src/core/constants.mjs +46 -0
  45. package/src/core/errors.mjs +57 -0
  46. package/src/core/events.mjs +29 -0
  47. package/src/core/types.mjs +57 -0
  48. package/src/github/api.mjs +78 -0
  49. package/src/github/auth.mjs +286 -0
  50. package/src/github/flow.mjs +298 -0
  51. package/src/github/workspace.mjs +212 -0
  52. package/src/index.mjs +82 -0
  53. package/src/knowledge/api-design.txt +9 -0
  54. package/src/knowledge/cpp.txt +10 -0
  55. package/src/knowledge/docker.txt +10 -0
  56. package/src/knowledge/dotnet.txt +9 -0
  57. package/src/knowledge/electron.txt +10 -0
  58. package/src/knowledge/flutter.txt +10 -0
  59. package/src/knowledge/go.txt +9 -0
  60. package/src/knowledge/graphql.txt +10 -0
  61. package/src/knowledge/java.txt +9 -0
  62. package/src/knowledge/kotlin.txt +10 -0
  63. package/src/knowledge/loader.mjs +125 -0
  64. package/src/knowledge/next.txt +8 -0
  65. package/src/knowledge/node.txt +8 -0
  66. package/src/knowledge/nuxt.txt +9 -0
  67. package/src/knowledge/php.txt +10 -0
  68. package/src/knowledge/python.txt +10 -0
  69. package/src/knowledge/react-native.txt +10 -0
  70. package/src/knowledge/react.txt +9 -0
  71. package/src/knowledge/ruby.txt +11 -0
  72. package/src/knowledge/rust.txt +9 -0
  73. package/src/knowledge/svelte.txt +9 -0
  74. package/src/knowledge/swift.txt +10 -0
  75. package/src/knowledge/tailwind.txt +10 -0
  76. package/src/knowledge/testing.txt +8 -0
  77. package/src/knowledge/typescript.txt +8 -0
  78. package/src/knowledge/vue.txt +9 -0
  79. package/src/mcp/client-http.mjs +157 -0
  80. package/src/mcp/client-sse.mjs +286 -0
  81. package/src/mcp/client-stdio.mjs +451 -0
  82. package/src/mcp/registry.mjs +394 -0
  83. package/src/mcp/stdio-framing.mjs +127 -0
  84. package/src/orchestration/background-manager.mjs +358 -0
  85. package/src/orchestration/background-worker.mjs +245 -0
  86. package/src/orchestration/longagent-manager.mjs +116 -0
  87. package/src/orchestration/stage-scheduler.mjs +489 -0
  88. package/src/orchestration/subagent-router.mjs +62 -0
  89. package/src/orchestration/task-scheduler.mjs +74 -0
  90. package/src/permission/engine.mjs +92 -0
  91. package/src/permission/exec-policy.mjs +372 -0
  92. package/src/permission/prompt.mjs +39 -0
  93. package/src/permission/rules.mjs +120 -0
  94. package/src/permission/workspace-trust.mjs +44 -0
  95. package/src/plugin/builtin-hooks/console-warn.mjs +41 -0
  96. package/src/plugin/builtin-hooks/extract-patterns.mjs +75 -0
  97. package/src/plugin/builtin-hooks/post-edit-format.mjs +57 -0
  98. package/src/plugin/builtin-hooks/post-edit-typecheck.mjs +61 -0
  99. package/src/plugin/builtin-hooks/strategic-compaction.mjs +38 -0
  100. package/src/plugin/hook-bus.mjs +154 -0
  101. package/src/provider/anthropic.mjs +389 -0
  102. package/src/provider/ollama.mjs +236 -0
  103. package/src/provider/openai-compatible.mjs +1 -0
  104. package/src/provider/openai.mjs +339 -0
  105. package/src/provider/retry-policy.mjs +68 -0
  106. package/src/provider/router.mjs +228 -0
  107. package/src/provider/sse.mjs +91 -0
  108. package/src/repl.mjs +2929 -0
  109. package/src/review/diff-parser.mjs +36 -0
  110. package/src/review/rejection-queue.mjs +62 -0
  111. package/src/review/review-store.mjs +21 -0
  112. package/src/review/risk-score.mjs +61 -0
  113. package/src/rules/load-rules.mjs +64 -0
  114. package/src/runtime.mjs +1 -0
  115. package/src/session/checkpoint.mjs +239 -0
  116. package/src/session/compaction.mjs +276 -0
  117. package/src/session/engine.mjs +225 -0
  118. package/src/session/instinct-manager.mjs +172 -0
  119. package/src/session/instruction-loader.mjs +25 -0
  120. package/src/session/longagent-plan.mjs +329 -0
  121. package/src/session/longagent-scaffold.mjs +100 -0
  122. package/src/session/longagent.mjs +1462 -0
  123. package/src/session/loop.mjs +905 -0
  124. package/src/session/memory-loader.mjs +75 -0
  125. package/src/session/project-context.mjs +367 -0
  126. package/src/session/prompt/anthropic.txt +151 -0
  127. package/src/session/prompt/beast.txt +37 -0
  128. package/src/session/prompt/max-steps.txt +6 -0
  129. package/src/session/prompt/plan.txt +9 -0
  130. package/src/session/prompt/qwen.txt +46 -0
  131. package/src/session/prompt-loader.mjs +18 -0
  132. package/src/session/recovery.mjs +52 -0
  133. package/src/session/store.mjs +503 -0
  134. package/src/session/system-prompt.mjs +260 -0
  135. package/src/session/task-validator.mjs +266 -0
  136. package/src/session/usability-gates.mjs +379 -0
  137. package/src/skill/builtin/backend-patterns.mjs +123 -0
  138. package/src/skill/builtin/commit.mjs +64 -0
  139. package/src/skill/builtin/debug.mjs +45 -0
  140. package/src/skill/builtin/frontend-patterns.mjs +120 -0
  141. package/src/skill/builtin/frontend.mjs +188 -0
  142. package/src/skill/builtin/init.mjs +220 -0
  143. package/src/skill/builtin/review.mjs +49 -0
  144. package/src/skill/builtin/security-checklist.mjs +80 -0
  145. package/src/skill/builtin/tdd.mjs +54 -0
  146. package/src/skill/generator.mjs +113 -0
  147. package/src/skill/registry.mjs +336 -0
  148. package/src/storage/audit-store.mjs +83 -0
  149. package/src/storage/event-log.mjs +82 -0
  150. package/src/storage/ghost-commit-store.mjs +235 -0
  151. package/src/storage/json-store.mjs +53 -0
  152. package/src/storage/paths.mjs +148 -0
  153. package/src/theme/color.mjs +64 -0
  154. package/src/theme/default-theme.mjs +29 -0
  155. package/src/theme/load-theme.mjs +71 -0
  156. package/src/theme/markdown.mjs +135 -0
  157. package/src/theme/schema.mjs +45 -0
  158. package/src/theme/status-bar.mjs +158 -0
  159. package/src/tool/audit-wrapper.mjs +38 -0
  160. package/src/tool/edit-transaction.mjs +126 -0
  161. package/src/tool/executor.mjs +109 -0
  162. package/src/tool/file-lock-manager.mjs +85 -0
  163. package/src/tool/git-auto.mjs +545 -0
  164. package/src/tool/git-full-auto.mjs +478 -0
  165. package/src/tool/image-util.mjs +276 -0
  166. package/src/tool/prompt/background_cancel.txt +1 -0
  167. package/src/tool/prompt/background_output.txt +1 -0
  168. package/src/tool/prompt/bash.txt +71 -0
  169. package/src/tool/prompt/codesearch.txt +18 -0
  170. package/src/tool/prompt/edit.txt +27 -0
  171. package/src/tool/prompt/enter_plan.txt +74 -0
  172. package/src/tool/prompt/exit_plan.txt +62 -0
  173. package/src/tool/prompt/glob.txt +33 -0
  174. package/src/tool/prompt/grep.txt +43 -0
  175. package/src/tool/prompt/list.txt +8 -0
  176. package/src/tool/prompt/multiedit.txt +20 -0
  177. package/src/tool/prompt/notebookedit.txt +21 -0
  178. package/src/tool/prompt/patch.txt +24 -0
  179. package/src/tool/prompt/question.txt +44 -0
  180. package/src/tool/prompt/read.txt +40 -0
  181. package/src/tool/prompt/task.txt +83 -0
  182. package/src/tool/prompt/todowrite.txt +117 -0
  183. package/src/tool/prompt/webfetch.txt +38 -0
  184. package/src/tool/prompt/websearch.txt +43 -0
  185. package/src/tool/prompt/write.txt +38 -0
  186. package/src/tool/prompt-loader.mjs +18 -0
  187. package/src/tool/question-prompt.mjs +86 -0
  188. package/src/tool/registry.mjs +1309 -0
  189. package/src/tool/task-tool.mjs +28 -0
  190. package/src/ui/activity-renderer.mjs +410 -0
  191. package/src/ui/repl-dashboard.mjs +357 -0
  192. package/src/usage/pricing.mjs +121 -0
  193. package/src/usage/usage-meter.mjs +113 -0
  194. package/src/util/git.mjs +496 -0
  195. package/src/util/template.mjs +10 -0
  196. package/src/util/yaml.mjs +100 -0
@@ -0,0 +1,120 @@
1
+ export const name = "frontend-patterns"
2
+ export const description = "Frontend development patterns reference: React/Vue/Svelte components, state management, performance, accessibility"
3
+
4
+ export async function run(ctx) {
5
+ const topic = (ctx.args || "").trim().toLowerCase()
6
+
7
+ const sections = {
8
+ components: `## Component Patterns
9
+
10
+ ### Single Responsibility
11
+ Each component does ONE thing. Split when:
12
+ - Component exceeds ~150 lines
13
+ - It has multiple unrelated state variables
14
+ - It renders multiple distinct UI sections
15
+
16
+ ### Composition over Inheritance
17
+ \`\`\`jsx
18
+ // BAD: prop drilling
19
+ <App user={user} theme={theme} locale={locale}>
20
+ <Page user={user} theme={theme} locale={locale}>
21
+ <Widget user={user} theme={theme} locale={locale} />
22
+
23
+ // GOOD: composition + context
24
+ <UserProvider><ThemeProvider><LocaleProvider>
25
+ <App><Page><Widget /></Page></App>
26
+ </LocaleProvider></ThemeProvider></UserProvider>
27
+ \`\`\`
28
+
29
+ ### Container vs Presentational
30
+ - **Container**: fetches data, manages state, passes props down
31
+ - **Presentational**: renders UI from props, no side effects, easily testable
32
+
33
+ ### Naming Conventions
34
+ - Components: PascalCase (UserProfile, SearchBar)
35
+ - Hooks: camelCase with "use" prefix (useAuth, useDebounce)
36
+ - Utils: camelCase (formatDate, parseQuery)
37
+ - Constants: UPPER_SNAKE_CASE (MAX_RETRIES, API_BASE_URL)`,
38
+
39
+ state: `## State Management
40
+
41
+ ### Local State First
42
+ Use component state (useState/ref) until you NEED to share:
43
+ - Form inputs, toggles, UI state → local
44
+ - User session, theme, locale → global context
45
+ - Server data → query cache (React Query / SWR / TanStack Query)
46
+
47
+ ### State Categories
48
+ 1. **UI State**: modals, tabs, scroll position → component state
49
+ 2. **Form State**: input values, validation → form library (react-hook-form, vee-validate)
50
+ 3. **Server State**: API responses → query cache with stale-while-revalidate
51
+ 4. **URL State**: filters, pagination → URL search params (source of truth)
52
+ 5. **Global State**: auth, theme → Context API or lightweight store (Zustand, Pinia)
53
+
54
+ ### Anti-Patterns
55
+ - Don't put everything in global store
56
+ - Don't duplicate server state in client store
57
+ - Don't derive state that can be computed from existing state
58
+ - Don't sync state between components — lift it to common parent`,
59
+
60
+ performance: `## Performance Patterns
61
+
62
+ ### Rendering
63
+ - **Memoize expensive computations**: useMemo / computed
64
+ - **Prevent unnecessary re-renders**: React.memo, shouldComponentUpdate
65
+ - **Virtualize long lists**: react-window, vue-virtual-scroller (1000+ items)
66
+ - **Lazy load routes and heavy components**: React.lazy, defineAsyncComponent
67
+
68
+ ### Network
69
+ - **Debounce search inputs**: 300ms delay before API call
70
+ - **Cache API responses**: stale-while-revalidate pattern
71
+ - **Prefetch next page**: on hover or intersection observer
72
+ - **Compress images**: WebP/AVIF, srcset for responsive, lazy loading
73
+
74
+ ### Bundle
75
+ - **Code split by route**: dynamic import() for each route
76
+ - **Tree shake**: use ESM imports, avoid barrel re-exports
77
+ - **Analyze bundle**: webpack-bundle-analyzer, vite-plugin-visualizer
78
+ - **External large deps**: load from CDN if rarely changing`,
79
+
80
+ a11y: `## Accessibility (a11y)
81
+
82
+ ### Semantic HTML First
83
+ - Use \`<button>\` not \`<div onClick>\`
84
+ - Use \`<nav>\`, \`<main>\`, \`<aside>\`, \`<article>\` landmarks
85
+ - Use \`<label>\` with \`htmlFor\` for form inputs
86
+ - Use heading hierarchy (h1 → h2 → h3, don't skip levels)
87
+
88
+ ### ARIA When Needed
89
+ - \`aria-label\` for icon-only buttons
90
+ - \`aria-expanded\` for accordions/dropdowns
91
+ - \`aria-live="polite"\` for dynamic content updates
92
+ - \`role="alert"\` for error messages
93
+
94
+ ### Keyboard Navigation
95
+ - All interactive elements must be focusable (tab order)
96
+ - Escape closes modals/dropdowns
97
+ - Enter/Space activates buttons
98
+ - Arrow keys navigate within lists/menus
99
+ - Visible focus indicators (never \`outline: none\` without replacement)
100
+
101
+ ### Testing
102
+ - aXe browser extension for automated checks
103
+ - Screen reader testing (VoiceOver, NVDA)
104
+ - Keyboard-only navigation testing
105
+ - Color contrast ratio: 4.5:1 for text, 3:1 for large text`
106
+ }
107
+
108
+ if (topic && sections[topic]) {
109
+ return sections[topic]
110
+ }
111
+
112
+ const overview = Object.values(sections).join("\n\n---\n\n")
113
+ return `# Frontend Development Patterns
114
+
115
+ Use \`/frontend-patterns <topic>\` for a specific section: components, state, performance, a11y
116
+
117
+ ---
118
+
119
+ ${overview}`
120
+ }
@@ -0,0 +1,188 @@
1
+ import { readFile } from "node:fs/promises"
2
+ import path from "node:path"
3
+
4
+ export const name = "frontend"
5
+ export const description = "Frontend development guidance with framework awareness (usage: /frontend <task description>)"
6
+
7
+ async function detectCurrentFramework(cwd) {
8
+ try {
9
+ const pkg = JSON.parse(await readFile(path.join(cwd, "package.json"), "utf8"))
10
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
11
+ if (deps.next) return "next"
12
+ if (deps.nuxt) return "nuxt"
13
+ if (deps["@sveltejs/kit"] || deps.svelte) return "svelte"
14
+ if (deps["@angular/core"]) return "angular"
15
+ if (deps.vue) return "vue"
16
+ if (deps.react) return "react"
17
+ } catch { /* no package.json */ }
18
+ return null
19
+ }
20
+
21
+ const FRAMEWORK_GUIDES = {
22
+ vue: `## Vue 3 Frontend Development Guide
23
+
24
+ ### Component Architecture
25
+ - Break UI into small, focused single-file components (.vue)
26
+ - Use <script setup lang="ts"> for all components
27
+ - Props: defineProps<{ title: string }>()
28
+ - Events: defineEmits<{ (e: 'update', value: string): void }>()
29
+ - Slots: use <slot> for content projection
30
+
31
+ ### State Management (Pinia)
32
+ - One store per domain (useUserStore, useCartStore)
33
+ - Use setup syntax: export const useXxxStore = defineStore('xxx', () => { ... })
34
+ - Access stores in components: const store = useXxxStore()
35
+
36
+ ### Routing (Vue Router)
37
+ - Define routes in src/router/index.ts
38
+ - Use <RouterView> and <RouterLink>
39
+ - Lazy-load pages: () => import('../views/About.vue')
40
+ - Use route params: useRoute().params
41
+
42
+ ### Styling
43
+ - <style scoped> for component styles (default)
44
+ - CSS variables for theming
45
+ - If Tailwind/UnoCSS is installed, use utility classes
46
+ - If Element Plus / Ant Design Vue is installed, use their components
47
+
48
+ ### Data Fetching
49
+ - Use composables: useFetch(), useApi()
50
+ - Handle loading/error states in the component
51
+ - Use onMounted() or watchEffect() for side effects`,
52
+
53
+ react: `## React Frontend Development Guide
54
+
55
+ ### Component Architecture
56
+ - Functional components only (no class components)
57
+ - One component per file, named export
58
+ - Props interface: interface Props { title: string }
59
+ - Use React.memo() for expensive pure components
60
+
61
+ ### State Management
62
+ - Local state: useState()
63
+ - Complex state: useReducer()
64
+ - Global state: React Context or Zustand/Jotai
65
+ - Server state: TanStack Query (React Query)
66
+
67
+ ### Routing (React Router v6)
68
+ - createBrowserRouter with route objects
69
+ - Use <Outlet> for nested routes
70
+ - useParams(), useSearchParams(), useNavigate()
71
+ - Lazy routes: lazy(() => import('./pages/About'))
72
+
73
+ ### Styling
74
+ - CSS Modules (.module.css) or Tailwind CSS
75
+ - Styled-components if already in deps
76
+ - Avoid inline styles for complex styling
77
+
78
+ ### Data Fetching
79
+ - Use useEffect + fetch for simple cases
80
+ - Use TanStack Query for caching and deduplication
81
+ - Handle loading/error/success states`,
82
+
83
+ next: `## Next.js Frontend Development Guide
84
+
85
+ ### App Router Architecture
86
+ - Server Components by default (no 'use client')
87
+ - Add 'use client' ONLY for: useState, useEffect, onClick, onChange, etc.
88
+ - Layouts: app/layout.tsx (shared UI, persistent across navigation)
89
+ - Pages: app/page.tsx, app/[slug]/page.tsx
90
+
91
+ ### Data Fetching
92
+ - Server Components: async function + direct fetch/db calls
93
+ - Client Components: use SWR or TanStack Query
94
+ - Server Actions: 'use server' functions for mutations
95
+
96
+ ### Styling
97
+ - Tailwind CSS (default with create-next-app)
98
+ - CSS Modules for component-scoped styles
99
+ - Use next/font for optimized font loading
100
+
101
+ ### Performance
102
+ - Use next/image for optimized images
103
+ - Use next/link for client-side navigation
104
+ - Use loading.tsx for streaming/suspense
105
+ - Use generateStaticParams for static generation`,
106
+
107
+ nuxt: `## Nuxt 3 Frontend Development Guide
108
+
109
+ ### Auto-imports
110
+ - No need to import: ref, computed, watch, onMounted, etc.
111
+ - No need to import components from components/ directory
112
+ - No need to import composables from composables/ directory
113
+
114
+ ### Pages & Routing
115
+ - File-based: pages/index.vue, pages/users/[id].vue
116
+ - definePageMeta({ layout: 'admin', middleware: 'auth' })
117
+ - Use NuxtLink for navigation
118
+ - Use useRoute() for route params
119
+
120
+ ### Data Fetching
121
+ - useFetch('/api/users') — SSR-friendly, auto-cached
122
+ - useAsyncData('key', () => $fetch('/api/data'))
123
+ - useLazyFetch for client-only fetching
124
+
125
+ ### State
126
+ - useState('key', () => defaultValue) for SSR-safe state
127
+ - Pinia with @pinia/nuxt for complex state
128
+
129
+ ### Server
130
+ - server/api/ for API routes
131
+ - server/middleware/ for server middleware
132
+ - defineEventHandler() for route handlers`,
133
+
134
+ svelte: `## SvelteKit Frontend Development Guide
135
+
136
+ ### Runes (Svelte 5)
137
+ - let count = $state(0) for reactive state
138
+ - let doubled = $derived(count * 2) for computed values
139
+ - $effect(() => { ... }) for side effects
140
+ - $props() for component props
141
+
142
+ ### Routing
143
+ - src/routes/+page.svelte for pages
144
+ - src/routes/+layout.svelte for layouts
145
+ - src/routes/+page.server.ts for server-side data loading
146
+ - [param] for dynamic routes
147
+
148
+ ### Data Loading
149
+ - +page.server.ts: export const load = async ({ params }) => { ... }
150
+ - Access in page: let { data } = $props()
151
+
152
+ ### Styling
153
+ - <style> is scoped by default in Svelte
154
+ - Use Tailwind if installed
155
+ - Use CSS variables for theming`,
156
+ }
157
+
158
+ export async function run(ctx) {
159
+ const task = (ctx.args || "").trim()
160
+ const cwd = ctx.cwd || process.cwd()
161
+ const framework = await detectCurrentFramework(cwd)
162
+
163
+ const parts = []
164
+
165
+ if (task) {
166
+ parts.push(`Task: ${task}`)
167
+ parts.push("")
168
+ }
169
+
170
+ if (framework && FRAMEWORK_GUIDES[framework]) {
171
+ parts.push(FRAMEWORK_GUIDES[framework])
172
+ } else if (framework) {
173
+ parts.push(`Detected framework: ${framework}. Use its standard conventions and idioms.`)
174
+ } else {
175
+ parts.push(`No framework detected in this project. If you need to create a frontend project, use /init <framework> first.`)
176
+ parts.push("")
177
+ parts.push("For a quick single-page app without a framework, consider using Vite:")
178
+ parts.push(" npm create vite@latest . -- --template vanilla-ts")
179
+ }
180
+
181
+ if (task) {
182
+ parts.push("")
183
+ parts.push("Now implement the task described above using the project's framework and conventions.")
184
+ parts.push("Break the work into components, create proper file structure, and use the framework's idioms.")
185
+ }
186
+
187
+ return parts.join("\n")
188
+ }
@@ -0,0 +1,220 @@
1
+ export const name = "init"
2
+ export const description = "Initialize a new project with framework scaffolding (usage: /init <framework>)"
3
+
4
+ const GUIDES = {
5
+ vue: `Initialize a Vue 3 project with Vite. Follow these steps exactly:
6
+
7
+ 1. Run: npm create vite@latest . -- --template vue-ts
8
+ (If the directory is not empty, create in a subdirectory or confirm overwrite)
9
+
10
+ 2. Install dependencies: npm install
11
+
12
+ 3. Install common extras:
13
+ npm install vue-router@4 pinia
14
+ npm install -D @vitejs/plugin-vue
15
+
16
+ 4. Create the standard directory structure:
17
+ src/
18
+ ├── components/ # Reusable UI components
19
+ ├── views/ # Page-level components (routed)
20
+ ├── stores/ # Pinia stores
21
+ ├── router/ # Vue Router config
22
+ ├── composables/ # Shared composition functions
23
+ ├── assets/ # Static assets (images, fonts)
24
+ ├── styles/ # Global styles
25
+ ├── App.vue # Root component
26
+ └── main.ts # Entry point
27
+
28
+ 5. Code conventions:
29
+ - Use <script setup lang="ts"> in all .vue files
30
+ - Use Composition API (ref, reactive, computed, watch)
31
+ - Use defineProps<T>() and defineEmits<T>() for component interfaces
32
+ - Use <style scoped> for component styles
33
+ - Use Pinia for state management (defineStore with setup syntax)
34
+ - Use vue-router with typed route params
35
+
36
+ 6. Set up router in src/router/index.ts with createRouter + createWebHistory
37
+
38
+ 7. Set up a root Pinia store in src/main.ts with createPinia()
39
+
40
+ After scaffolding, verify with: npm run dev (tell user to run manually)`,
41
+
42
+ react: `Initialize a React project with Vite. Follow these steps exactly:
43
+
44
+ 1. Run: npm create vite@latest . -- --template react-ts
45
+
46
+ 2. Install dependencies: npm install
47
+
48
+ 3. Install common extras:
49
+ npm install react-router-dom
50
+ npm install -D @types/react @types/react-dom
51
+
52
+ 4. Create the standard directory structure:
53
+ src/
54
+ ├── components/ # Reusable UI components
55
+ ├── pages/ # Page-level components (routed)
56
+ ├── hooks/ # Custom React hooks
57
+ ├── contexts/ # React context providers
58
+ ├── services/ # API calls and external services
59
+ ├── assets/ # Static assets
60
+ ├── styles/ # Global styles
61
+ ├── App.tsx # Root component
62
+ └── main.tsx # Entry point
63
+
64
+ 5. Code conventions:
65
+ - Use functional components with TypeScript
66
+ - Use hooks (useState, useEffect, useMemo, useCallback)
67
+ - Use React.FC<Props> or explicit return types
68
+ - Prefer named exports for components
69
+ - Use React Router v6 with createBrowserRouter
70
+
71
+ After scaffolding, verify with: npm run dev (tell user to run manually)`,
72
+
73
+ next: `Initialize a Next.js project. Follow these steps exactly:
74
+
75
+ 1. Run: npx create-next-app@latest . --typescript --tailwind --eslint --app --src-dir --import-alias "@/*"
76
+
77
+ 2. Directory structure (App Router):
78
+ src/
79
+ ├── app/
80
+ │ ├── layout.tsx # Root layout
81
+ │ ├── page.tsx # Home page
82
+ │ ├── globals.css # Global styles
83
+ │ └── [feature]/
84
+ │ └── page.tsx # Feature pages
85
+ ├── components/ # Shared components
86
+ ├── lib/ # Utility functions
87
+ └── types/ # TypeScript types
88
+
89
+ 3. Code conventions:
90
+ - Server Components by default (no 'use client' unless needed)
91
+ - Add 'use client' only for interactive components (useState, onClick, etc.)
92
+ - Use Next.js Image, Link, and metadata APIs
93
+ - Use Route Handlers (app/api/) for API endpoints
94
+
95
+ After scaffolding, verify with: npm run dev (tell user to run manually)`,
96
+
97
+ nuxt: `Initialize a Nuxt 3 project. Follow these steps exactly:
98
+
99
+ 1. Run: npx nuxi@latest init .
100
+
101
+ 2. Install dependencies: npm install
102
+
103
+ 3. Directory structure:
104
+ ├── pages/ # File-based routing (auto-registered)
105
+ ├── components/ # Auto-imported components
106
+ ├── composables/ # Auto-imported composables
107
+ ├── layouts/ # Layout components
108
+ ├── stores/ # Pinia stores (install @pinia/nuxt)
109
+ ├── server/ # Server routes and middleware
110
+ ├── assets/ # Build-processed assets
111
+ ├── public/ # Static files
112
+ └── nuxt.config.ts # Nuxt configuration
113
+
114
+ 4. Code conventions:
115
+ - Auto-imports: no need to import ref, computed, useState, etc.
116
+ - Pages auto-register routes based on file structure
117
+ - Components auto-register based on file name
118
+ - Use useFetch() or useAsyncData() for data fetching
119
+ - Use definePageMeta() for page-level metadata
120
+
121
+ After scaffolding, verify with: npm run dev (tell user to run manually)`,
122
+
123
+ svelte: `Initialize a SvelteKit project. Follow these steps exactly:
124
+
125
+ 1. Run: npx sv create . (select skeleton project + TypeScript)
126
+
127
+ 2. Install dependencies: npm install
128
+
129
+ 3. Directory structure:
130
+ src/
131
+ ├── routes/ # File-based routing
132
+ │ ├── +layout.svelte
133
+ │ ├── +page.svelte
134
+ │ └── [feature]/
135
+ │ └── +page.svelte
136
+ ├── lib/
137
+ │ ├── components/ # Shared components
138
+ │ └── server/ # Server-only modules
139
+ └── app.html # HTML template
140
+
141
+ 4. Code conventions:
142
+ - Use +page.svelte for pages, +layout.svelte for layouts
143
+ - Use +page.server.ts for server-side data loading
144
+ - Use $state, $derived, $effect runes (Svelte 5)
145
+ - Use <script lang="ts"> for TypeScript
146
+
147
+ After scaffolding, verify with: npm run dev (tell user to run manually)`,
148
+
149
+ node: `Initialize a Node.js project. Follow these steps exactly:
150
+
151
+ 1. Run: npm init -y
152
+
153
+ 2. Update package.json: set "type": "module" for ESM
154
+
155
+ 3. Install TypeScript (recommended):
156
+ npm install -D typescript @types/node tsx
157
+ npx tsc --init
158
+
159
+ 4. Directory structure:
160
+ src/
161
+ ├── index.ts # Entry point
162
+ ├── lib/ # Core logic
163
+ ├── utils/ # Utility functions
164
+ └── types/ # TypeScript types
165
+
166
+ 5. Add scripts to package.json:
167
+ "dev": "tsx watch src/index.ts",
168
+ "build": "tsc",
169
+ "start": "node dist/index.js"`,
170
+
171
+ express: `Initialize an Express.js API project. Follow these steps exactly:
172
+
173
+ 1. Run: npm init -y
174
+
175
+ 2. Update package.json: set "type": "module"
176
+
177
+ 3. Install dependencies:
178
+ npm install express cors
179
+ npm install -D typescript @types/node @types/express tsx
180
+
181
+ 4. Initialize TypeScript: npx tsc --init
182
+
183
+ 5. Directory structure:
184
+ src/
185
+ ├── index.ts # Server entry + app.listen()
186
+ ├── routes/ # Route handlers
187
+ ├── middleware/ # Custom middleware
188
+ ├── controllers/ # Request handlers
189
+ ├── services/ # Business logic
190
+ ├── models/ # Data models
191
+ └── types/ # TypeScript types
192
+
193
+ 6. Add scripts:
194
+ "dev": "tsx watch src/index.ts",
195
+ "build": "tsc",
196
+ "start": "node dist/index.js"`,
197
+ }
198
+
199
+ const AVAILABLE = Object.keys(GUIDES)
200
+
201
+ export async function run(ctx) {
202
+ const arg = (ctx.args || "").trim().toLowerCase()
203
+
204
+ if (!arg) {
205
+ return `Please specify a framework to initialize. Available options:
206
+
207
+ ${AVAILABLE.map(f => `- /init ${f}`).join("\n")}
208
+
209
+ Example: /init vue`
210
+ }
211
+
212
+ const guide = GUIDES[arg]
213
+ if (!guide) {
214
+ return `Unknown framework "${arg}". Available options: ${AVAILABLE.join(", ")}
215
+
216
+ Example: /init vue`
217
+ }
218
+
219
+ return guide
220
+ }
@@ -0,0 +1,49 @@
1
+ export const name = "review"
2
+ export const description = "Review code changes for bugs, security issues, and quality (usage: /review [file or path])"
3
+
4
+ export async function run(ctx) {
5
+ const target = (ctx.args || "").trim()
6
+
7
+ const scope = target
8
+ ? `Focus on: ${target}`
9
+ : `Review all uncommitted changes (git diff)`
10
+
11
+ return `Perform a thorough code review.
12
+
13
+ ${scope}
14
+
15
+ Steps:
16
+ 1. Run \`git diff\` to see all uncommitted changes. If a specific file/path was given, use \`git diff -- <path>\`.
17
+ 2. If no uncommitted changes, run \`git diff HEAD~1\` to review the last commit.
18
+ 3. For each changed file, analyze:
19
+
20
+ **Correctness**
21
+ - Logic errors, off-by-one, null/undefined access
22
+ - Missing error handling or edge cases
23
+ - Race conditions or async issues
24
+
25
+ **Security**
26
+ - Injection vulnerabilities (SQL, XSS, command injection)
27
+ - Hardcoded secrets or credentials
28
+ - Unsafe deserialization or eval usage
29
+ - Missing input validation at system boundaries
30
+
31
+ **Quality**
32
+ - Naming clarity and code readability
33
+ - Unnecessary complexity or dead code
34
+ - Missing or misleading comments
35
+ - Consistent style with surrounding code
36
+
37
+ **Performance**
38
+ - N+1 queries or unnecessary loops
39
+ - Missing memoization for expensive operations
40
+ - Large allocations in hot paths
41
+
42
+ 4. Output findings grouped by severity:
43
+ - 🔴 Critical: bugs or security issues that must be fixed
44
+ - 🟡 Warning: potential issues worth addressing
45
+ - 🟢 Suggestion: improvements that are nice to have
46
+
47
+ 5. For each finding, show the exact file and line, explain the issue, and suggest a fix.
48
+ 6. End with a brief summary: total findings by severity, overall assessment.`
49
+ }
@@ -0,0 +1,80 @@
1
+ export const name = "security-checklist"
2
+ export const description = "Security review checklist: OWASP Top 10, dependency audit, secret management, authentication"
3
+
4
+ export async function run(ctx) {
5
+ const scope = (ctx.args || "").trim()
6
+
7
+ return `# Security Review Checklist
8
+ ${scope ? `\nScope: ${scope}\n` : ""}
9
+ Run through each category below. For each item, check the codebase and report findings.
10
+
11
+ ## 1. Injection (OWASP A03)
12
+ - [ ] SQL queries use parameterized statements (never string concatenation)
13
+ - [ ] NoSQL queries avoid operator injection (\`$gt\`, \`$ne\` in user input)
14
+ - [ ] Shell commands avoid user input (or use \`execFile\` with explicit args, never \`exec\` with template strings)
15
+ - [ ] LDAP queries are properly escaped
16
+ - [ ] Path traversal: \`path.resolve\` + verify result is within allowed directory
17
+
18
+ ## 2. Authentication (OWASP A07)
19
+ - [ ] Passwords hashed with bcrypt/argon2 (NOT MD5/SHA1/SHA256)
20
+ - [ ] Rate limiting on login endpoint (e.g., 5 attempts per minute)
21
+ - [ ] Session/JWT expires (access: 15min, refresh: 7d max)
22
+ - [ ] Password reset tokens are single-use and time-limited
23
+ - [ ] Multi-factor authentication available for sensitive operations
24
+
25
+ ## 3. Access Control (OWASP A01)
26
+ - [ ] Every endpoint checks authorization (not just authentication)
27
+ - [ ] No IDOR: users cannot access other users' resources by changing ID
28
+ - [ ] Admin endpoints require admin role verification
29
+ - [ ] CORS configured with explicit allowed origins (not \`*\` in production)
30
+ - [ ] File uploads validate type, size, and scan for malware
31
+
32
+ ## 4. Sensitive Data (OWASP A02)
33
+ - [ ] HTTPS enforced (HSTS header set)
34
+ - [ ] Sensitive data encrypted at rest (database, backups)
35
+ - [ ] PII never logged (emails, passwords, tokens, SSN)
36
+ - [ ] API responses don't leak internal errors or stack traces
37
+ - [ ] Cookies: HttpOnly, Secure, SameSite=Strict/Lax
38
+
39
+ ## 5. Secrets Management
40
+ - [ ] No hardcoded API keys, passwords, or tokens in source code
41
+ - [ ] \`.env\` files listed in \`.gitignore\`
42
+ - [ ] Secrets loaded from environment variables or secret manager
43
+ - [ ] Different secrets for dev/staging/production
44
+ - [ ] Run: \`grep -rn "password\\|secret\\|api.key\\|token" --include="*.{js,ts,py,go}" .\`
45
+
46
+ ## 6. Dependencies
47
+ - [ ] Run \`npm audit\` / \`pip audit\` / \`cargo audit\` / \`go mod tidy\`
48
+ - [ ] No critical/high severity vulnerabilities unresolved
49
+ - [ ] Lock file committed and up to date
50
+ - [ ] No deprecated packages with known CVEs
51
+ - [ ] Dependabot or Renovate configured for automated updates
52
+
53
+ ## 7. XSS Prevention (OWASP A03)
54
+ - [ ] User input escaped before rendering in HTML
55
+ - [ ] No \`dangerouslySetInnerHTML\` / \`v-html\` with user content
56
+ - [ ] No \`eval()\`, \`new Function()\`, or \`innerHTML\` with user data
57
+ - [ ] Content-Security-Policy header set
58
+ - [ ] SVG uploads sanitized (can contain scripts)
59
+
60
+ ## 8. CSRF Protection
61
+ - [ ] State-changing requests require CSRF token
62
+ - [ ] SameSite cookie attribute set
63
+ - [ ] Custom headers required for API calls (e.g., X-Requested-With)
64
+
65
+ ## 9. Infrastructure
66
+ - [ ] Docker containers don't run as root
67
+ - [ ] No secrets in Dockerfile or docker-compose.yml
68
+ - [ ] CI/CD secrets stored in platform secret manager (not in config files)
69
+ - [ ] Production: debug mode disabled, verbose errors disabled
70
+ - [ ] Logging: audit trail for auth events, data access, admin actions
71
+
72
+ ## 10. Summary Template
73
+
74
+ After review, fill in:
75
+ - **Critical Issues**: (must fix before deploy)
76
+ - **High Issues**: (fix within this sprint)
77
+ - **Medium Issues**: (plan to fix)
78
+ - **Low Issues**: (nice to have)
79
+ - **Overall Risk**: LOW / MEDIUM / HIGH / CRITICAL`
80
+ }