Sfoglia il codice sorgente

feat: add debug + solo primary modes, auto-install on first launch

- .kirincode/modes/debug.md — diagnostic mode (read-only + safe bash)
- .kirincode/modes/solo.md — autonomous execution (full access + self-drive)
- onboarding.ts: installs default modes to ~/.config/kirincode/modes/ on first launch
- Version: 0.2.0
KirinCode 1 mese fa
parent
commit
5092b76796

+ 78 - 0
.kirincode/modes/debug.md

@@ -0,0 +1,78 @@
+---
+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
+    "cargo test *": allow
+    "go test *": allow
+    "pytest *": 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.
+
+## Workflow
+
+When given an error or bug report:
+
+1. **Reproduce**: Run the failing test or command to see the error firsthand
+2. **Trace Backwards**: Follow the stack trace or error chain to find origin
+3. **Search Broadly**: Use grep/glob to find all related code paths
+4. **Analyze Dependencies**: Check imports, types, configurations
+5. **Report**: Output a structured diagnostic report
+
+## 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 with code snippet — but DO NOT apply it]
+```

+ 62 - 0
.kirincode/modes/solo.md

@@ -0,0 +1,62 @@
+---
+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** (internal, brief): Break task into sub-tasks, create TodoWrite list
+2. **Execute** (autonomous loop): Read → Implement → Verify → Fix → Next
+3. **Verify** (comprehensive): Run tests, typecheck, lint. Fix all failures.
+4. **Report** (concise): Summary of changes + verification results
+
+## Output Format
+
+```
+## Solo Mode Complete
+
+### What was done
+- [Bullet list of changes]
+
+### Verification
+- typecheck: ✅ / ❌
+- tests: ✅ / ❌  
+- lint: ✅ / ❌
+
+### Files changed
+- path/to/file.ts — [reason]
+```
+
+## Anti-patterns
+
+- ❌ "I'll wait for your confirmation..."
+- ❌ "Would you like me to..."
+- ❌ "Should I run the tests?"
+- ✅ Just do it, verify, and report.

+ 1 - 1
packages/app/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/app",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "description": "",
   "type": "module",
   "exports": {

+ 1 - 1
packages/cli/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/cli",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "bin": {

+ 1 - 1
packages/codemode/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/codemode",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "description": "Effect-native confined code execution over schema-described tools",
   "private": true,
   "type": "module",

+ 1 - 1
packages/console/app/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/console-app",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "scripts": {

+ 1 - 1
packages/console/core/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/console-core",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/console/function/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/console-function",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "$schema": "https://json.schemastore.org/package.json",
   "private": true,
   "type": "module",

+ 1 - 1
packages/console/mail/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/console-mail",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "dependencies": {
     "@jsx-email/all": "2.2.3",
     "@jsx-email/cli": "1.4.3",

+ 1 - 1
packages/console/support/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/console-support",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "scripts": {

+ 1 - 1
packages/core/package.json

@@ -1,6 +1,6 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "name": "@kirincode-ai/core",
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/desktop/package.json

@@ -1,7 +1,7 @@
 {
   "name": "@kirincode-ai/desktop",
   "private": true,
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "homepage": "https://kirincode.ai",

+ 127 - 1
packages/desktop/src/main/onboarding.ts

@@ -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

+ 1 - 1
packages/effect-drizzle-sqlite/package.json

@@ -1,6 +1,6 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "name": "@kirincode-ai/effect-drizzle-sqlite",
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/effect-sqlite-node/package.json

@@ -1,6 +1,6 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "name": "@kirincode-ai/effect-sqlite-node",
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/enterprise/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/enterprise",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/function/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/function",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "$schema": "https://json.schemastore.org/package.json",
   "private": true,
   "type": "module",

+ 1 - 1
packages/http-recorder/package.json

@@ -1,6 +1,6 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "name": "@kirincode-ai/http-recorder",
   "description": "Record and replay Effect HTTP client traffic with deterministic cassettes",
   "type": "module",

+ 1 - 1
packages/kirincode/package.json

@@ -1,6 +1,6 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "name": "kirincode",
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/llm/package.json

@@ -1,6 +1,6 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "name": "@kirincode-ai/llm",
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/plugin/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/plugin",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "scripts": {

+ 1 - 1
packages/sdk/js/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/sdk",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "scripts": {

+ 1 - 1
packages/server/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/server",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/session-ui/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/session-ui",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/slack/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/slack",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "scripts": {

+ 1 - 1
packages/stats/app/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/stats-app",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/stats/core/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/stats-core",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/stats/server/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/stats-server",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/tui/package.json

@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@kirincode-ai/tui",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "private": true,
   "type": "module",
   "license": "MIT",

+ 1 - 1
packages/ui/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@kirincode-ai/ui",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "type": "module",
   "license": "MIT",
   "repository": {

+ 1 - 1
packages/web/package.json

@@ -2,7 +2,7 @@
   "name": "@kirincode-ai/web",
   "type": "module",
   "license": "MIT",
-  "version": "1.17.18",
+  "version": "0.2.0",
   "scripts": {
     "dev": "astro dev",
     "dev:remote": "VITE_API_URL=https://api.kirincode.ai astro dev",