@meowlynxsea/koi 0.1.0

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 (109) hide show
  1. package/LICENSE +34 -0
  2. package/NOTICE +35 -0
  3. package/README.md +15 -0
  4. package/bin/koi +12 -0
  5. package/dist/highlights-eq9cgrbb.scm +604 -0
  6. package/dist/highlights-ghv9g403.scm +205 -0
  7. package/dist/highlights-hk7bwhj4.scm +284 -0
  8. package/dist/highlights-r812a2qc.scm +150 -0
  9. package/dist/highlights-x6tmsnaa.scm +115 -0
  10. package/dist/injections-73j83es3.scm +27 -0
  11. package/dist/main.js +489918 -0
  12. package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
  13. package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
  14. package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
  15. package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
  16. package/dist/tree-sitter-zig-e78zbjpm.wasm +0 -0
  17. package/package.json +51 -0
  18. package/src/agent/check-permissions.ts +239 -0
  19. package/src/agent/hooks/message-utils.ts +305 -0
  20. package/src/agent/hooks/types.ts +32 -0
  21. package/src/agent/hooks.ts +1560 -0
  22. package/src/agent/mode.ts +163 -0
  23. package/src/agent/monitor-registry.ts +308 -0
  24. package/src/agent/permission-ui.ts +71 -0
  25. package/src/agent/plan-ui.ts +74 -0
  26. package/src/agent/question-ui.ts +58 -0
  27. package/src/agent/session-fork.ts +299 -0
  28. package/src/agent/session-snapshots.ts +216 -0
  29. package/src/agent/session-store.ts +649 -0
  30. package/src/agent/session-tasks.ts +305 -0
  31. package/src/agent/session.ts +27 -0
  32. package/src/agent/subagent-registry.ts +176 -0
  33. package/src/agent/subagent.ts +194 -0
  34. package/src/agent/tool-orchestration.ts +55 -0
  35. package/src/agent/tools.ts +8 -0
  36. package/src/cli/args.ts +6 -0
  37. package/src/cli/commands.ts +5 -0
  38. package/src/commands/skills/index.ts +23 -0
  39. package/src/config/models.ts +6 -0
  40. package/src/config/settings.ts +392 -0
  41. package/src/main.tsx +64 -0
  42. package/src/services/mcp/client.ts +194 -0
  43. package/src/services/mcp/config.ts +232 -0
  44. package/src/services/mcp/connection-manager.ts +258 -0
  45. package/src/services/mcp/index.ts +80 -0
  46. package/src/services/mcp/mcp-commands.ts +114 -0
  47. package/src/services/mcp/stdio-transport.ts +246 -0
  48. package/src/services/mcp/types.ts +155 -0
  49. package/src/skills/SkillsMenu.tsx +370 -0
  50. package/src/skills/bundled/batch.ts +106 -0
  51. package/src/skills/bundled/debug.ts +86 -0
  52. package/src/skills/bundled/loremIpsum.ts +101 -0
  53. package/src/skills/bundled/remember.ts +97 -0
  54. package/src/skills/bundled/simplify.ts +100 -0
  55. package/src/skills/bundled/skillify.ts +123 -0
  56. package/src/skills/bundled/stuck.ts +101 -0
  57. package/src/skills/bundled/updateConfig.ts +228 -0
  58. package/src/skills/bundled.ts +46 -0
  59. package/src/skills/frontmatter.ts +179 -0
  60. package/src/skills/index.ts +87 -0
  61. package/src/skills/invoke.ts +231 -0
  62. package/src/skills/loader.ts +710 -0
  63. package/src/skills/substitution.ts +169 -0
  64. package/src/skills/types.ts +201 -0
  65. package/src/tools/agent.ts +143 -0
  66. package/src/tools/ask-user-question.ts +46 -0
  67. package/src/tools/bash.ts +148 -0
  68. package/src/tools/edit.ts +164 -0
  69. package/src/tools/glob.ts +102 -0
  70. package/src/tools/grep.ts +248 -0
  71. package/src/tools/index.ts +73 -0
  72. package/src/tools/list-mcp-resources.ts +74 -0
  73. package/src/tools/ls.ts +85 -0
  74. package/src/tools/mcp.ts +76 -0
  75. package/src/tools/monitor.ts +159 -0
  76. package/src/tools/plan-mode.ts +134 -0
  77. package/src/tools/read-mcp-resource.ts +79 -0
  78. package/src/tools/read.ts +137 -0
  79. package/src/tools/skill.ts +176 -0
  80. package/src/tools/task.ts +349 -0
  81. package/src/tools/types.ts +52 -0
  82. package/src/tools/webfetch-domains.ts +239 -0
  83. package/src/tools/webfetch.ts +533 -0
  84. package/src/tools/write.ts +101 -0
  85. package/src/tui/app.tsx +1178 -0
  86. package/src/tui/components/chat-panel.tsx +1071 -0
  87. package/src/tui/components/command-panel.tsx +261 -0
  88. package/src/tui/components/confirm-modal.tsx +135 -0
  89. package/src/tui/components/connect-modal.tsx +435 -0
  90. package/src/tui/components/connecting-modal.tsx +167 -0
  91. package/src/tui/components/edit-pending-modal.tsx +103 -0
  92. package/src/tui/components/exit-modal.tsx +131 -0
  93. package/src/tui/components/fork-modal.tsx +377 -0
  94. package/src/tui/components/image-preview-modal.tsx +141 -0
  95. package/src/tui/components/image-utils.ts +128 -0
  96. package/src/tui/components/info-bar.tsx +103 -0
  97. package/src/tui/components/input-box.tsx +352 -0
  98. package/src/tui/components/mcp/MCPSettings.tsx +386 -0
  99. package/src/tui/components/mcp/index.ts +7 -0
  100. package/src/tui/components/model-modal.tsx +310 -0
  101. package/src/tui/components/pending-area.tsx +88 -0
  102. package/src/tui/components/rename-modal.tsx +119 -0
  103. package/src/tui/components/session-modal.tsx +233 -0
  104. package/src/tui/components/side-bar.tsx +349 -0
  105. package/src/tui/components/tool-output.ts +6 -0
  106. package/src/tui/hooks/user-prompt-history.ts +114 -0
  107. package/src/tui/theme.ts +63 -0
  108. package/src/types/commands.ts +80 -0
  109. package/src/types/cross-spawn.d.ts +24 -0
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Remember Skill
3
+ *
4
+ * Review and organize session memory and project context.
5
+ * Adapted from Claude Code's remember skill.
6
+ */
7
+
8
+ import { registerBundledSkill } from "../bundled.js";
9
+
10
+ const REMEMBER_PROMPT = `# Memory Review
11
+
12
+ ## Goal
13
+
14
+ Review the session memory and project context. Produce a clear report of proposed changes, grouped by action type. Do NOT apply changes — present proposals for user approval.
15
+
16
+ ## Steps
17
+
18
+ ### 1. Gather All Memory Layers
19
+
20
+ Check for these memory files in the project root:
21
+
22
+ | File | Purpose | Should Commit |
23
+ |------|---------|---------------|
24
+ | CLAUDE.md | Project conventions for all contributors | Yes |
25
+ | CLAUDE.local.md | Personal preferences, not for others | .gitignore |
26
+ | .claude/commands/ | Custom slash commands | Yes |
27
+
28
+ **Success criteria**: You have found and read all relevant memory files.
29
+
30
+ ### 2. Classify Each Entry
31
+
32
+ For each piece of context or memory, determine the best destination:
33
+
34
+ | Destination | What belongs there | Examples |
35
+ |-------------|-------------------|----------|
36
+ | **CLAUDE.md** | Project-wide conventions | "use bun not npm", "API routes use kebab-case", "test command is bun test" |
37
+ | **CLAUDE.local.md** | Personal preferences for this user only | "I prefer concise responses", "always explain trade-offs" |
38
+ | **.claude/commands/** | Custom slash commands | Custom /deploy, /test commands |
39
+ | **Stay in memory** | Session-specific or temporary | One-time observations, uncertain patterns |
40
+
41
+ **Important distinctions:**
42
+ - CLAUDE.md and CLAUDE.local.md contain instructions for the agent, not user preferences for external tools
43
+ - Workflow practices (PR conventions, merge strategies) are ambiguous — ask the user if they're personal or team-wide
44
+ - When unsure, ask rather than guess
45
+
46
+ **Success criteria**: Each entry has a proposed destination or is flagged as ambiguous.
47
+
48
+ ### 3. Identify Cleanup Opportunities
49
+
50
+ Scan across all layers for:
51
+
52
+ - **Duplicates**: Memory entries already captured in CLAUDE.md or CLAUDE.local.md
53
+ - **Outdated**: Older entries contradicted by newer information
54
+ - **Conflicts**: Contradictions between any two layers
55
+ - **Stale**: Information that was true before but is no longer relevant
56
+
57
+ **Success criteria**: All cross-layer issues identified.
58
+
59
+ ### 4. Present the Report
60
+
61
+ Output a structured report grouped by action type:
62
+
63
+ **1. Promotions** — entries to move, with destination and rationale
64
+ **2. Cleanup** — duplicates, outdated entries, conflicts to resolve
65
+ **3. Ambiguous** — entries where you need the user's input on destination
66
+ **4. No action needed** — brief note on entries that should stay put
67
+
68
+ If no memory files exist, say so and offer to help create CLAUDE.md.
69
+
70
+ **Success criteria**: User can review and approve/reject each proposal individually.
71
+
72
+ ## Rules
73
+
74
+ - Present ALL proposals before making any changes
75
+ - Do NOT modify files without explicit user approval
76
+ - Do NOT create new files unless the target doesn't exist yet
77
+ - Ask about ambiguous entries — don't guess
78
+ - Focus on actionable, useful memory rather than comprehensive documentation
79
+ `;
80
+
81
+ export function registerRememberSkill(): void {
82
+ registerBundledSkill({
83
+ name: "remember",
84
+ description:
85
+ "Review session memory and project context. Propose promotions to CLAUDE.md, CLAUDE.local.md, or custom commands. Also detects outdated, conflicting, and duplicate entries.",
86
+ whenToUse:
87
+ "Use when the user wants to review, organize, or persist their session memory. Also useful for cleaning up outdated or conflicting context.",
88
+ userInvocable: true,
89
+ async getPromptForCommand(args) {
90
+ let prompt = REMEMBER_PROMPT;
91
+ if (args) {
92
+ prompt += `\n\n## Additional Context\n\n${args}`;
93
+ }
94
+ return [{ type: "text", text: prompt }];
95
+ },
96
+ });
97
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Simplify Skill
3
+ *
4
+ * Review changed code for reuse, quality, and efficiency.
5
+ * Adapted from Claude Code's simplify skill.
6
+ */
7
+
8
+ import { registerBundledSkill } from "../bundled.js";
9
+
10
+ const SIMPLIFY_PROMPT = `# Simplify: Code Review and Cleanup
11
+
12
+ Review changed files for reuse, quality, and efficiency. Fix any issues found.
13
+
14
+ ## Phase 1: Identify Changes
15
+
16
+ Use \`git diff\` (or \`git diff HEAD\` if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that were edited earlier in this conversation.
17
+
18
+ ## Phase 2: Code Review
19
+
20
+ For each change, review for the following issues:
21
+
22
+ ### Code Reuse
23
+ - **Search for existing utilities** that could replace newly written code
24
+ - Look in common locations: utility directories, shared modules, adjacent files
25
+ - **Flag duplicate functionality** - suggest using existing functions instead
26
+ - **Flag inline logic** that could use existing utilities:
27
+ - String manipulation
28
+ - Path handling
29
+ - Environment checks
30
+ - Type guards
31
+ - Custom helpers
32
+
33
+ ### Code Quality
34
+ - **Redundant state**: duplicate state, cached values that could be derived
35
+ - **Parameter sprawl**: adding parameters instead of generalizing
36
+ - **Copy-paste with variation**: near-duplicate blocks that should be unified
37
+ - **Leaky abstractions**: exposing internal details that should be encapsulated
38
+ - **Stringly-typed code**: raw strings where constants, enums, or branded types exist
39
+ - **Unnecessary nesting**: wrapper elements/components that add no value
40
+ - **Unnecessary comments**: comments explaining WHAT (well-named code does that) - delete; keep only non-obvious WHY comments
41
+
42
+ ### Efficiency
43
+ - **Unnecessary work**: redundant computations, repeated reads, duplicate calls, N+1 patterns
44
+ - **Missed concurrency**: sequential operations that could run in parallel
45
+ - **Hot-path bloat**: blocking work added to startup or per-request paths
46
+ - **Recurring no-op updates**: state updates in loops/intervals that fire unconditionally
47
+ - **Unnecessary existence checks**: pre-checking before operating (TOCTOU anti-pattern)
48
+ - **Memory issues**: unbounded data structures, missing cleanup, event listener leaks
49
+ - **Overly broad operations**: reading entire files when only part is needed
50
+
51
+ ## Phase 3: Fix Issues
52
+
53
+ Fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on.
54
+
55
+ When done, briefly summarize what was fixed (or confirm the code was already clean).
56
+
57
+ ## Guidelines
58
+
59
+ - Focus on substantive improvements, not style preferences
60
+ - Preserve the original behavior - this is refactoring, not rewriting
61
+ - Make one logical change at a time
62
+ - Run tests after changes if available
63
+ - Keep commits focused
64
+
65
+ ## Output Format
66
+
67
+ Present findings in this format:
68
+
69
+ \`\`\`
70
+ ## Issues Found
71
+
72
+ ### [Category] - File:path
73
+ **Problem**: Description of the issue
74
+ **Fix**: What was changed
75
+ \`\`\`
76
+
77
+ Or if no issues:
78
+
79
+ \`\`\`
80
+ ## Summary
81
+
82
+ No significant issues found. The code is clean.
83
+ \`\`\`
84
+ `;
85
+
86
+ export function registerSimplifySkill(): void {
87
+ registerBundledSkill({
88
+ name: "simplify",
89
+ description:
90
+ "Review changed code for reuse, quality, and efficiency, then fix any issues found.",
91
+ userInvocable: true,
92
+ async getPromptForCommand(args) {
93
+ let prompt = SIMPLIFY_PROMPT;
94
+ if (args) {
95
+ prompt += `\n\n## Additional Focus\n\n${args}`;
96
+ }
97
+ return [{ type: "text", text: prompt }];
98
+ },
99
+ });
100
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Skillify Skill
3
+ *
4
+ * Capture this session's repeatable process into a reusable skill.
5
+ * Adapted from Claude Code's skillify skill.
6
+ */
7
+
8
+ import { registerBundledSkill } from "../bundled.js";
9
+
10
+ const SKILLIFY_PROMPT = `# Skillify
11
+
12
+ Capture this session's repeatable process as a reusable skill.
13
+
14
+ ## Your Task
15
+
16
+ ### Step 1: Analyze the Session
17
+
18
+ Before asking questions, analyze what happened in this session:
19
+ - What repeatable process was performed?
20
+ - What were the inputs/parameters?
21
+ - What were the distinct steps (in order)?
22
+ - What tools and permissions were needed?
23
+ - What proved the process succeeded?
24
+
25
+ ### Step 2: Interview the User
26
+
27
+ Use AskUserQuestion to understand what they want to automate.
28
+
29
+ **Round 1: High-level confirmation**
30
+ - Suggest a name and description based on your analysis
31
+ - Confirm the goal and success criteria
32
+
33
+ **Round 2: Details**
34
+ - Present the high-level steps you identified
35
+ - Suggest arguments if the skill needs parameters
36
+ - Ask where to save: repo-specific (\`.claude/skills/\`) or personal (\`~/.config/koi/skills/\`)
37
+
38
+ **Round 3: Step details**
39
+ For each major step, clarify:
40
+ - What does this step produce that later steps need?
41
+ - What proves this step succeeded?
42
+ - Should the user confirm before proceeding?
43
+ - Are any steps independent and could run in parallel?
44
+
45
+ **Round 4: Final questions**
46
+ - Confirm when this skill should be invoked
47
+ - Ask for trigger phrases (e.g., "cherry-pick to release", "hotfix")
48
+
49
+ ### Step 3: Write the SKILL.md
50
+
51
+ Create the skill file at the chosen location.
52
+
53
+ Use this format:
54
+
55
+ \`\`\`markdown
56
+ ---
57
+ name: skill-name
58
+ description: One-line description of what this skill does
59
+ allowed-tools:
60
+ - ToolName
61
+ - Bash(specific:command)
62
+ when_to_use: When to auto-invoke this skill
63
+ argument-hint: "<arg1> <arg2>"
64
+ ---
65
+
66
+ # Skill Title
67
+
68
+ Description of skill
69
+
70
+ ## Goal
71
+ Clearly stated goal
72
+
73
+ ## Steps
74
+
75
+ ### 1. Step Name
76
+ What to do
77
+
78
+ **Success criteria**: How to know this step is done
79
+
80
+ ### 2. Step Name
81
+ ...
82
+
83
+ ## Notes
84
+ - Gotchas to watch out for
85
+ - User corrections from this session
86
+ \`\`\`
87
+
88
+ ### Step 4: Confirm and Save
89
+
90
+ Before writing, output the complete SKILL.md for review. Ask for confirmation using AskUserQuestion.
91
+
92
+ After writing, tell the user:
93
+ - Where the skill was saved
94
+ - How to invoke it: \`/skill-name [arguments]\`
95
+ - That they can edit the SKILL.md directly to refine it
96
+ `;
97
+
98
+ export function registerSkillifySkill(): void {
99
+ registerBundledSkill({
100
+ name: "skillify",
101
+ description:
102
+ "Capture this session's repeatable process into a reusable skill.",
103
+ allowedTools: [
104
+ "Read",
105
+ "Write",
106
+ "Edit",
107
+ "Glob",
108
+ "Grep",
109
+ "AskUserQuestion",
110
+ "Bash(mkdir:*)",
111
+ ],
112
+ userInvocable: true,
113
+ disableModelInvocation: true,
114
+ argumentHint: "[description of the process to capture]",
115
+ async getPromptForCommand(args) {
116
+ let prompt = SKILLIFY_PROMPT;
117
+ if (args) {
118
+ prompt += `\n\n## User Description\n\nThe user wants to capture: "${args}"`;
119
+ }
120
+ return [{ type: "text", text: prompt }];
121
+ },
122
+ });
123
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Stuck Skill
3
+ *
4
+ * Diagnose frozen or slow Koi sessions.
5
+ */
6
+
7
+ import { registerBundledSkill } from "../bundled.js";
8
+
9
+ const STUCK_PROMPT = `# /stuck — Diagnose Frozen/Slow Sessions
10
+
11
+ The user thinks a Koi session is frozen, stuck, or very slow. Investigate and diagnose.
12
+
13
+ ## What to Look For
14
+
15
+ Signs of a stuck session:
16
+ - **High CPU (≥90%) sustained** — likely an infinite loop or heavy processing
17
+ - **High Memory (≥4GB)** — possible memory leak
18
+ - **Network timeout** — API requests taking too long
19
+ - **Process not responding** — UI frozen but process running
20
+
21
+ ## Investigation Steps
22
+
23
+ ### 1. Check Running Processes
24
+ \`\`\`
25
+ ps aux | grep -E "(koi|node)" | grep -v grep
26
+ \`\`\`
27
+
28
+ ### 2. Check System Resources
29
+ \`\`\`
30
+ top -l 1 | head -20
31
+ \`\`\`
32
+
33
+ ### 3. Check Network Activity
34
+ \`\`\`
35
+ # Is the API responding?
36
+ curl -s --max-time 5 https://api.openai.com/v1/models 2>&1 || echo "API timeout or error"
37
+ \`\`\`
38
+
39
+ ### 4. Check Logs
40
+ Look for error messages in:
41
+ - Terminal output
42
+ - Any log files
43
+
44
+ ### 5. Common Causes
45
+
46
+ **High CPU:**
47
+ - Model is generating a very long response
48
+ - Infinite loop in tool execution
49
+ - Heavy regex or processing
50
+
51
+ **High Memory:**
52
+ - Context window getting full
53
+ - Large file being processed
54
+ - Memory leak in process
55
+
56
+ **Not Responding:**
57
+ - API rate limiting
58
+ - Network connectivity issues
59
+ - Model taking too long to respond
60
+
61
+ ## Report
62
+
63
+ Present findings in this format:
64
+
65
+ \`\`\`
66
+ ## Diagnosis
67
+
68
+ **Issue**: [What appears to be wrong]
69
+ **Cause**: [Likely reason]
70
+ **Impact**: [Effect on session]
71
+
72
+ ## Recommendations
73
+
74
+ 1. [Action to take]
75
+ 2. [Action to take]
76
+ \`\`\`
77
+
78
+ ## Suggested Fixes
79
+
80
+ Based on the diagnosis:
81
+ - If API timeout: Try again or switch to a faster model
82
+ - If memory issue: Start a new session
83
+ - If infinite loop: Cancel current operation and try different approach
84
+ - If rate limited: Wait and retry, or use different API key
85
+ `;
86
+
87
+ export function registerStuckSkill(): void {
88
+ registerBundledSkill({
89
+ name: "stuck",
90
+ description:
91
+ "Diagnose frozen, stuck, or slow Koi sessions. Investigate CPU, memory, network, and API issues.",
92
+ userInvocable: true,
93
+ async getPromptForCommand(args) {
94
+ let prompt = STUCK_PROMPT;
95
+ if (args) {
96
+ prompt += `\n\n## User Context\n\n${args}`;
97
+ }
98
+ return [{ type: "text", text: prompt }];
99
+ },
100
+ });
101
+ }
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Update Config Skill
3
+ *
4
+ * Configure Koi settings via settings.json.
5
+ * Adapted from Claude Code's update-config skill to fit Koi's architecture.
6
+ */
7
+
8
+ import { registerBundledSkill } from "../bundled.js";
9
+
10
+ const UPDATE_CONFIG_PROMPT = `# Update Config Skill
11
+
12
+ Modify Koi configuration by editing settings.json files.
13
+
14
+ ## Settings File Locations
15
+
16
+ | File | Scope | Purpose |
17
+ |------|-------|---------|
18
+ | \`~/.config/koi/settings.json\` | Global | Koi user settings (providers, models) |
19
+ | \`~/.config/koi/pi/settings.json\` | Global | Pi agent runtime settings |
20
+ | \`~/.config/koi/pi/models.json\` | Global | Pi model registry |
21
+ | \`~/.config/koi/pi/auth.json\` | Global | Pi authentication storage |
22
+
23
+ ## Koi Settings Schema
24
+
25
+ \`\`\`json
26
+ {
27
+ "version": 1,
28
+ "sessionTitle": "Session Name",
29
+ "providers": {
30
+ "provider-name": {
31
+ "provider": "provider-name",
32
+ "authMethod": "apikey" | "oauth",
33
+ "credential": "sk-..."
34
+ }
35
+ },
36
+ "currentModel": {
37
+ "provider": "openai",
38
+ "modelId": "gpt-4o"
39
+ },
40
+ "auxiliaryModel": {
41
+ "provider": "anthropic",
42
+ "modelId": "claude-sonnet-4-7-20250514"
43
+ }
44
+ }
45
+ \`\`\`
46
+
47
+ ## Available Configuration Options
48
+
49
+ ### Provider Configuration
50
+ \`\`\`json
51
+ {
52
+ "providers": {
53
+ "provider-name": {
54
+ "provider": "provider-name",
55
+ "authMethod": "apikey" | "oauth",
56
+ "credential": "your-api-key-or-token"
57
+ }
58
+ }
59
+ }
60
+ \`\`\`
61
+
62
+ Supported providers: openai, anthropic, google, ollama, groq, mistral, etc.
63
+
64
+ ### Model Configuration
65
+ \`\`\`json
66
+ {
67
+ "currentModel": {
68
+ "provider": "openai",
69
+ "modelId": "gpt-4o"
70
+ },
71
+ "auxiliaryModel": {
72
+ "provider": "anthropic",
73
+ "modelId": "claude-sonnet-4-7-20250514"
74
+ }
75
+ }
76
+ \`\`\`
77
+
78
+ The auxiliary model is used for secondary tasks like reflection or critique.
79
+
80
+ ### Session Configuration
81
+ \`\`\`json
82
+ {
83
+ "sessionTitle": "My Project"
84
+ }
85
+ \`\`\`
86
+
87
+ ## CRITICAL: Read Before Write
88
+
89
+ **Always read the existing settings file before making changes.** Merge new settings with existing ones - never replace the entire file unless explicitly asked.
90
+
91
+ ## Workflow
92
+
93
+ 1. **Read existing file** - Use Read tool on the target settings file
94
+ 2. **Analyze current state** - Understand what's already configured
95
+ 3. **Merge carefully** - Preserve existing settings, especially nested objects
96
+ 4. **Edit file** - Use Edit tool for modifications
97
+ 5. **Confirm** - Tell user what was changed
98
+
99
+ ## Merging Objects (Important!)
100
+
101
+ When adding new fields to existing objects, **merge with existing**, don't replace:
102
+
103
+ **WRONG** (replaces existing providers):
104
+ \`\`\`json
105
+ { "providers": { "openai": { ... } } }
106
+ \`\`\`
107
+
108
+ **RIGHT** (preserves existing + adds new):
109
+ \`\`\`json
110
+ {
111
+ "providers": {
112
+ "existing-provider": { ... },
113
+ "openai": { ... }
114
+ }
115
+ }
116
+ \`\`\`
117
+
118
+ ## Common Tasks
119
+
120
+ ### Adding a Provider
121
+
122
+ User: "add OpenAI provider" or "configure OpenAI"
123
+
124
+ 1. Read \`~/.config/koi/settings.json\`
125
+ 2. Add provider to the providers object
126
+ 3. Validate by attempting a test request
127
+
128
+ ### Switching the Current Model
129
+
130
+ User: "switch to gpt-4o" or "use claude as the main model"
131
+
132
+ 1. Read current settings
133
+ 2. Update the currentModel field with new provider and modelId
134
+ 3. Confirm the switch
135
+
136
+ ### Configuring an Auxiliary Model
137
+
138
+ User: "set up auxiliary model" or "add a critique model"
139
+
140
+ 1. Read current settings
141
+ 2. Add or update auxiliaryModel field
142
+ 3. The auxiliary model will be used for secondary tasks
143
+
144
+ ### Changing Session Title
145
+
146
+ User: "rename this session"
147
+
148
+ 1. Read settings file
149
+ 2. Update sessionTitle field
150
+
151
+ ## File Paths Reference
152
+
153
+ - Koi Settings: \`~/.config/koi/settings.json\`
154
+ - Pi Settings: \`~/.config/koi/pi/settings.json\`
155
+ - Pi Models: \`~/.config/koi/pi/models.json\`
156
+ - Pi Auth: \`~/.config/koi/pi/auth.json\`
157
+
158
+ ## Troubleshooting
159
+
160
+ If configuration changes don't take effect:
161
+
162
+ 1. **Check JSON syntax** - Invalid JSON silently fails
163
+ 2. **Verify provider name** - Must match exactly (case-sensitive)
164
+ 3. **Validate API key** - Try a simple API request
165
+ 4. **Check file permissions** - Settings file should be readable
166
+ 5. **Restart if needed** - Some settings require a new session
167
+
168
+ ## Example Workflows
169
+
170
+ ### Adding a New Provider
171
+
172
+ User: "add the anthropic provider with my API key"
173
+
174
+ 1. Read \`~/.config/koi/settings.json\`
175
+ 2. Merge new provider with existing providers:
176
+ \`\`\`json
177
+ {
178
+ "providers": {
179
+ "existing-provider": { ... },
180
+ "anthropic": {
181
+ "provider": "anthropic",
182
+ "authMethod": "apikey",
183
+ "credential": "sk-ant-..."
184
+ }
185
+ }
186
+ }
187
+ \`\`\`
188
+ 3. Tell user the provider was added
189
+
190
+ ### Switching Models
191
+
192
+ User: "use claude-sonnet as my main model"
193
+
194
+ 1. Read settings
195
+ 2. Update currentModel:
196
+ \`\`\`json
197
+ {
198
+ "currentModel": {
199
+ "provider": "anthropic",
200
+ "modelId": "claude-sonnet-4-7-20250514"
201
+ }
202
+ }
203
+ \`\`\`
204
+
205
+ ## Notes
206
+
207
+ - Provider names are case-sensitive
208
+ - Model IDs must match the exact format returned by the provider
209
+ - Changes to settings.json take effect immediately for new operations
210
+ - Some changes may require starting a new session
211
+ `;
212
+
213
+ export function registerUpdateConfigSkill(): void {
214
+ registerBundledSkill({
215
+ name: "update-config",
216
+ description:
217
+ "Configure Koi settings including providers, models, and Pi agent settings. Use for: adding API providers, switching models, configuring auxiliary models, changing session title, or modifying settings.json files.",
218
+ allowedTools: ["Read"],
219
+ userInvocable: true,
220
+ async getPromptForCommand(args) {
221
+ let prompt = UPDATE_CONFIG_PROMPT;
222
+ if (args) {
223
+ prompt += `\n\n## User Request\n\n${args}`;
224
+ }
225
+ return [{ type: "text", text: prompt }];
226
+ },
227
+ });
228
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Bundled Skills Registry
3
+ *
4
+ * Built-in skills that are always available.
5
+ * Ported from Claude Code's skills system, adapted for Koi.
6
+ */
7
+
8
+ import {
9
+ registerBundledSkill as registerSkill,
10
+ getBundledSkillDefinitions,
11
+ } from "./loader.js";
12
+ import type { BundledSkillDefinition } from "./types.js";
13
+
14
+ // Re-export for bundled skill files
15
+ export function registerBundledSkill(definition: BundledSkillDefinition): void {
16
+ registerSkill(definition);
17
+ }
18
+
19
+ export { getBundledSkillDefinitions };
20
+
21
+ // =============================================================================
22
+ // Bundled Skills
23
+ // =============================================================================
24
+
25
+ import { registerUpdateConfigSkill } from "./bundled/updateConfig.js";
26
+ import { registerDebugSkill } from "./bundled/debug.js";
27
+ import { registerLoremIpsumSkill } from "./bundled/loremIpsum.js";
28
+ import { registerSkillifySkill } from "./bundled/skillify.js";
29
+ import { registerRememberSkill } from "./bundled/remember.js";
30
+ import { registerSimplifySkill } from "./bundled/simplify.js";
31
+ import { registerBatchSkill } from "./bundled/batch.js";
32
+ import { registerStuckSkill } from "./bundled/stuck.js";
33
+
34
+ /**
35
+ * Initialize all bundled skills.
36
+ */
37
+ export function initBundledSkills(): void {
38
+ registerUpdateConfigSkill();
39
+ registerDebugSkill();
40
+ registerLoremIpsumSkill();
41
+ registerSkillifySkill();
42
+ registerRememberSkill();
43
+ registerSimplifySkill();
44
+ registerBatchSkill();
45
+ registerStuckSkill();
46
+ }