|
|
@@ -1,4 +1,5 @@
|
|
|
-import { mkdir } from "node:fs/promises"
|
|
|
+import { mkdir, writeFile } from "node:fs/promises"
|
|
|
+import { homedir } from "node:os"
|
|
|
import { join } from "node:path"
|
|
|
import { app } from "electron"
|
|
|
import { getStore } from "./store"
|
|
|
@@ -6,6 +7,129 @@ import { FIRST_LAUNCH_ONBOARDING_COMPLETE_KEY } from "./store-keys"
|
|
|
import { write as writeLog } from "./logging"
|
|
|
|
|
|
const DEFAULT_PROJECT_DIR = "New KirinCode Project"
|
|
|
+const MODES_DIR = join(homedir(), ".config", "kirincode", "modes")
|
|
|
+
|
|
|
+const DEFAULT_MODES: Record<string, string> = {
|
|
|
+ "debug.md": `---
|
|
|
+description: Debug mode — diagnose bugs, trace errors, and analyze failures without making code changes. Use when investigating error messages, stack traces, unexpected behavior, test failures, or performance issues. Read-only except for safe diagnostic bash commands.
|
|
|
+temperature: 0.1
|
|
|
+color: "#F39C12"
|
|
|
+permission:
|
|
|
+ edit: deny
|
|
|
+ write: deny
|
|
|
+ apply_patch: deny
|
|
|
+ bash:
|
|
|
+ "*": ask
|
|
|
+ "npm test *": allow
|
|
|
+ "npm run test *": allow
|
|
|
+ "bun test *": allow
|
|
|
+ "git log *": allow
|
|
|
+ "git diff *": allow
|
|
|
+ "git status *": allow
|
|
|
+ "git blame *": allow
|
|
|
+ "git show *": allow
|
|
|
+ "curl *": ask
|
|
|
+ "grep *": allow
|
|
|
+ "rg *": allow
|
|
|
+ "cat *": allow
|
|
|
+ "head *": allow
|
|
|
+ "tail *": allow
|
|
|
+ "wc *": allow
|
|
|
+ "ls *": allow
|
|
|
+ "find *": allow
|
|
|
+ "echo *": allow
|
|
|
+ read: allow
|
|
|
+ grep: allow
|
|
|
+ glob: allow
|
|
|
+ list: allow
|
|
|
+ webfetch: allow
|
|
|
+ websearch: allow
|
|
|
+ lsp: allow
|
|
|
+ task: allow
|
|
|
+ question: ask
|
|
|
+---
|
|
|
+
|
|
|
+You are in DEBUG mode. Your job is to diagnose problems, NOT to fix them.
|
|
|
+
|
|
|
+## Core Rules
|
|
|
+
|
|
|
+1. **NEVER edit, write, or modify any files.** You are a diagnostic tool.
|
|
|
+2. Trace the full chain of causality — from symptom to root cause.
|
|
|
+3. Run tests to reproduce and confirm issues.
|
|
|
+4. Search across the entire codebase for related patterns.
|
|
|
+
|
|
|
+## Output Format
|
|
|
+
|
|
|
+\`\`\`
|
|
|
+## Diagnostic Report
|
|
|
+
|
|
|
+### Symptom
|
|
|
+[What the user sees]
|
|
|
+
|
|
|
+### Root Cause
|
|
|
+[The actual problem, with file:line references]
|
|
|
+
|
|
|
+### Evidence
|
|
|
+[Supporting code, logs, test output]
|
|
|
+
|
|
|
+### Fix Recommendation
|
|
|
+[Suggested fix — but DO NOT apply it]
|
|
|
+\`\`\`
|
|
|
+`,
|
|
|
+ "solo.md": `---
|
|
|
+description: Solo mode — autonomous execution. You independently plan, implement, and verify tasks without asking the user for approval. Use for complex multi-step features, refactoring, or end-to-end implementations where the user wants you to drive the entire workflow.
|
|
|
+temperature: 0.3
|
|
|
+color: "#8E44AD"
|
|
|
+permission:
|
|
|
+ edit: allow
|
|
|
+ write: allow
|
|
|
+ bash: allow
|
|
|
+ read: allow
|
|
|
+ grep: allow
|
|
|
+ glob: allow
|
|
|
+ list: allow
|
|
|
+ webfetch: allow
|
|
|
+ websearch: allow
|
|
|
+ lsp: allow
|
|
|
+ task: allow
|
|
|
+ todowrite: allow
|
|
|
+ question: deny
|
|
|
+ plan_enter: deny
|
|
|
+ plan_exit: deny
|
|
|
+---
|
|
|
+
|
|
|
+You are in SOLO mode. You operate autonomously. Do not ask the user for permission or clarification unless absolutely blocked.
|
|
|
+
|
|
|
+## Core Rules
|
|
|
+
|
|
|
+1. **Self-drive**: Plan → Execute → Verify → Repeat. Do not wait for the user.
|
|
|
+2. **Minimize interruptions**: Do not ask "should I proceed?" — just proceed.
|
|
|
+3. **Create todo lists**: Use TodoWrite to plan and track your work.
|
|
|
+4. **Verify your work**: Run tests, typecheck, lint after every significant change.
|
|
|
+5. **Report only on completion**: Summarize what you did when finished.
|
|
|
+
|
|
|
+## Workflow
|
|
|
+
|
|
|
+1. **Plan**: Break task into sub-tasks, create TodoWrite list
|
|
|
+2. **Execute**: Read → Implement → Verify → Fix → Next (autonomous loop)
|
|
|
+3. **Verify**: Run tests, typecheck, lint. Fix all failures.
|
|
|
+4. **Report**: Concise summary of changes + verification results
|
|
|
+
|
|
|
+## Anti-patterns
|
|
|
+
|
|
|
+- ❌ "I'll wait for your confirmation..."
|
|
|
+- ❌ "Would you like me to..."
|
|
|
+- ✅ Just do it, verify, and report.
|
|
|
+`,
|
|
|
+}
|
|
|
+
|
|
|
+async function installDefaultModes() {
|
|
|
+ await mkdir(MODES_DIR, { recursive: true })
|
|
|
+ for (const [filename, content] of Object.entries(DEFAULT_MODES)) {
|
|
|
+ await writeFile(join(MODES_DIR, filename), content, "utf-8")
|
|
|
+ }
|
|
|
+ writeLog("onboarding", "default modes installed", { dir: MODES_DIR })
|
|
|
+}
|
|
|
|
|
|
export function isFirstLaunchOnboardingPending() {
|
|
|
const pending = getStore().get(FIRST_LAUNCH_ONBOARDING_COMPLETE_KEY) !== true
|
|
|
@@ -22,6 +146,8 @@ export async function finishFirstLaunchOnboarding(createDefaultProject: boolean)
|
|
|
const defaultProject = createDefaultProject ? join(app.getPath("documents"), DEFAULT_PROJECT_DIR) : null
|
|
|
if (defaultProject) await mkdir(defaultProject, { recursive: true })
|
|
|
|
|
|
+ await installDefaultModes()
|
|
|
+
|
|
|
getStore().set(FIRST_LAUNCH_ONBOARDING_COMPLETE_KEY, true)
|
|
|
writeLog("onboarding", "first launch onboarding completed", { createDefaultProject, defaultProject })
|
|
|
return defaultProject
|