kimi-cli 0.44__py3-none-any.whl → 0.78__py3-none-any.whl

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.

Potentially problematic release.


This version of kimi-cli might be problematic. Click here for more details.

Files changed (137) hide show
  1. kimi_cli/CHANGELOG.md +349 -40
  2. kimi_cli/__init__.py +6 -0
  3. kimi_cli/acp/AGENTS.md +91 -0
  4. kimi_cli/acp/__init__.py +13 -0
  5. kimi_cli/acp/convert.py +111 -0
  6. kimi_cli/acp/kaos.py +270 -0
  7. kimi_cli/acp/mcp.py +46 -0
  8. kimi_cli/acp/server.py +335 -0
  9. kimi_cli/acp/session.py +445 -0
  10. kimi_cli/acp/tools.py +158 -0
  11. kimi_cli/acp/types.py +13 -0
  12. kimi_cli/agents/default/agent.yaml +4 -4
  13. kimi_cli/agents/default/sub.yaml +2 -1
  14. kimi_cli/agents/default/system.md +79 -21
  15. kimi_cli/agents/okabe/agent.yaml +17 -0
  16. kimi_cli/agentspec.py +53 -25
  17. kimi_cli/app.py +180 -52
  18. kimi_cli/cli/__init__.py +595 -0
  19. kimi_cli/cli/__main__.py +8 -0
  20. kimi_cli/cli/info.py +63 -0
  21. kimi_cli/cli/mcp.py +349 -0
  22. kimi_cli/config.py +153 -17
  23. kimi_cli/constant.py +3 -0
  24. kimi_cli/exception.py +23 -2
  25. kimi_cli/flow/__init__.py +117 -0
  26. kimi_cli/flow/d2.py +376 -0
  27. kimi_cli/flow/mermaid.py +218 -0
  28. kimi_cli/llm.py +129 -23
  29. kimi_cli/metadata.py +32 -7
  30. kimi_cli/platforms.py +262 -0
  31. kimi_cli/prompts/__init__.py +2 -0
  32. kimi_cli/prompts/compact.md +4 -5
  33. kimi_cli/session.py +223 -31
  34. kimi_cli/share.py +2 -0
  35. kimi_cli/skill.py +145 -0
  36. kimi_cli/skills/kimi-cli-help/SKILL.md +55 -0
  37. kimi_cli/skills/skill-creator/SKILL.md +351 -0
  38. kimi_cli/soul/__init__.py +51 -20
  39. kimi_cli/soul/agent.py +213 -85
  40. kimi_cli/soul/approval.py +86 -17
  41. kimi_cli/soul/compaction.py +64 -53
  42. kimi_cli/soul/context.py +38 -5
  43. kimi_cli/soul/denwarenji.py +2 -0
  44. kimi_cli/soul/kimisoul.py +442 -60
  45. kimi_cli/soul/message.py +54 -54
  46. kimi_cli/soul/slash.py +72 -0
  47. kimi_cli/soul/toolset.py +387 -6
  48. kimi_cli/toad.py +74 -0
  49. kimi_cli/tools/AGENTS.md +5 -0
  50. kimi_cli/tools/__init__.py +42 -34
  51. kimi_cli/tools/display.py +25 -0
  52. kimi_cli/tools/dmail/__init__.py +10 -10
  53. kimi_cli/tools/dmail/dmail.md +11 -9
  54. kimi_cli/tools/file/__init__.py +1 -3
  55. kimi_cli/tools/file/glob.py +20 -23
  56. kimi_cli/tools/file/grep.md +1 -1
  57. kimi_cli/tools/file/{grep.py → grep_local.py} +51 -23
  58. kimi_cli/tools/file/read.md +24 -6
  59. kimi_cli/tools/file/read.py +134 -50
  60. kimi_cli/tools/file/replace.md +1 -1
  61. kimi_cli/tools/file/replace.py +36 -29
  62. kimi_cli/tools/file/utils.py +282 -0
  63. kimi_cli/tools/file/write.py +43 -22
  64. kimi_cli/tools/multiagent/__init__.py +7 -0
  65. kimi_cli/tools/multiagent/create.md +11 -0
  66. kimi_cli/tools/multiagent/create.py +50 -0
  67. kimi_cli/tools/{task/__init__.py → multiagent/task.py} +48 -53
  68. kimi_cli/tools/shell/__init__.py +120 -0
  69. kimi_cli/tools/{bash → shell}/bash.md +1 -2
  70. kimi_cli/tools/shell/powershell.md +25 -0
  71. kimi_cli/tools/test.py +4 -4
  72. kimi_cli/tools/think/__init__.py +2 -2
  73. kimi_cli/tools/todo/__init__.py +14 -8
  74. kimi_cli/tools/utils.py +64 -24
  75. kimi_cli/tools/web/fetch.py +68 -13
  76. kimi_cli/tools/web/search.py +10 -12
  77. kimi_cli/ui/acp/__init__.py +65 -412
  78. kimi_cli/ui/print/__init__.py +37 -49
  79. kimi_cli/ui/print/visualize.py +179 -0
  80. kimi_cli/ui/shell/__init__.py +141 -84
  81. kimi_cli/ui/shell/console.py +2 -0
  82. kimi_cli/ui/shell/debug.py +28 -23
  83. kimi_cli/ui/shell/keyboard.py +5 -1
  84. kimi_cli/ui/shell/prompt.py +220 -194
  85. kimi_cli/ui/shell/replay.py +111 -46
  86. kimi_cli/ui/shell/setup.py +89 -82
  87. kimi_cli/ui/shell/slash.py +422 -0
  88. kimi_cli/ui/shell/update.py +4 -2
  89. kimi_cli/ui/shell/usage.py +271 -0
  90. kimi_cli/ui/shell/visualize.py +574 -72
  91. kimi_cli/ui/wire/__init__.py +267 -0
  92. kimi_cli/ui/wire/jsonrpc.py +142 -0
  93. kimi_cli/ui/wire/protocol.py +1 -0
  94. kimi_cli/utils/__init__.py +0 -0
  95. kimi_cli/utils/aiohttp.py +2 -0
  96. kimi_cli/utils/aioqueue.py +72 -0
  97. kimi_cli/utils/broadcast.py +37 -0
  98. kimi_cli/utils/changelog.py +12 -7
  99. kimi_cli/utils/clipboard.py +12 -0
  100. kimi_cli/utils/datetime.py +37 -0
  101. kimi_cli/utils/environment.py +58 -0
  102. kimi_cli/utils/envvar.py +12 -0
  103. kimi_cli/utils/frontmatter.py +44 -0
  104. kimi_cli/utils/logging.py +7 -6
  105. kimi_cli/utils/message.py +9 -14
  106. kimi_cli/utils/path.py +99 -9
  107. kimi_cli/utils/pyinstaller.py +6 -0
  108. kimi_cli/utils/rich/__init__.py +33 -0
  109. kimi_cli/utils/rich/columns.py +99 -0
  110. kimi_cli/utils/rich/markdown.py +961 -0
  111. kimi_cli/utils/rich/markdown_sample.md +108 -0
  112. kimi_cli/utils/rich/markdown_sample_short.md +2 -0
  113. kimi_cli/utils/signals.py +2 -0
  114. kimi_cli/utils/slashcmd.py +124 -0
  115. kimi_cli/utils/string.py +2 -0
  116. kimi_cli/utils/term.py +168 -0
  117. kimi_cli/utils/typing.py +20 -0
  118. kimi_cli/wire/__init__.py +98 -29
  119. kimi_cli/wire/serde.py +45 -0
  120. kimi_cli/wire/types.py +299 -0
  121. kimi_cli-0.78.dist-info/METADATA +200 -0
  122. kimi_cli-0.78.dist-info/RECORD +135 -0
  123. kimi_cli-0.78.dist-info/entry_points.txt +4 -0
  124. kimi_cli/cli.py +0 -250
  125. kimi_cli/soul/runtime.py +0 -96
  126. kimi_cli/tools/bash/__init__.py +0 -99
  127. kimi_cli/tools/file/patch.md +0 -8
  128. kimi_cli/tools/file/patch.py +0 -143
  129. kimi_cli/tools/mcp.py +0 -85
  130. kimi_cli/ui/shell/liveview.py +0 -386
  131. kimi_cli/ui/shell/metacmd.py +0 -262
  132. kimi_cli/wire/message.py +0 -91
  133. kimi_cli-0.44.dist-info/METADATA +0 -188
  134. kimi_cli-0.44.dist-info/RECORD +0 -89
  135. kimi_cli-0.44.dist-info/entry_points.txt +0 -3
  136. /kimi_cli/tools/{task → multiagent}/task.md +0 -0
  137. {kimi_cli-0.44.dist-info → kimi_cli-0.78.dist-info}/WHEEL +0 -0
@@ -0,0 +1,351 @@
1
+ ---
2
+ name: skill-creator
3
+ description: Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Kimi's capabilities with specialized knowledge, workflows, or tool integrations.
4
+ ---
5
+
6
+ # Skill Creator
7
+
8
+ This skill provides guidance for creating effective skills.
9
+
10
+ ## About Skills
11
+
12
+ Skills are modular, self-contained packages that extend Kimi's capabilities by providing
13
+ specialized knowledge, workflows, and tools. Think of them as "onboarding guides" for specific
14
+ domains or tasks—they transform Kimi from a general-purpose agent into a specialized agent
15
+ equipped with procedural knowledge that no model can fully possess.
16
+
17
+ ### What Skills Provide
18
+
19
+ 1. Specialized workflows - Multi-step procedures for specific domains
20
+ 2. Tool integrations - Instructions for working with specific file formats or APIs
21
+ 3. Domain expertise - Company-specific knowledge, schemas, business logic
22
+ 4. Bundled resources - Scripts, references, and assets for complex and repetitive tasks
23
+
24
+ ## Core Principles
25
+
26
+ ### Concise is Key
27
+
28
+ The context window is a public good. Skills share the context window with everything else Kimi needs: system prompt, conversation history, other Skills' metadata, and the actual user request.
29
+
30
+ **Default assumption: Kimi is already very smart.** Only add context Kimi doesn't already have. Challenge each piece of information: "Does Kimi really need this explanation?" and "Does this paragraph justify its token cost?"
31
+
32
+ Prefer concise examples over verbose explanations.
33
+
34
+ ### Set Appropriate Degrees of Freedom
35
+
36
+ Match the level of specificity to the task's fragility and variability:
37
+
38
+ **High freedom (text-based instructions)**: Use when multiple approaches are valid, decisions depend on context, or heuristics guide the approach.
39
+
40
+ **Medium freedom (pseudocode or scripts with parameters)**: Use when a preferred pattern exists, some variation is acceptable, or configuration affects behavior.
41
+
42
+ **Low freedom (specific scripts, few parameters)**: Use when operations are fragile and error-prone, consistency is critical, or a specific sequence must be followed.
43
+
44
+ Think of Kimi as exploring a path: a narrow bridge with cliffs needs specific guardrails (low freedom), while an open field allows many routes (high freedom).
45
+
46
+ ### Anatomy of a Skill
47
+
48
+ Every skill consists of a required SKILL.md file and optional bundled resources:
49
+
50
+ ```
51
+ skill-name/
52
+ ├── SKILL.md (required)
53
+ │ ├── YAML frontmatter metadata (required)
54
+ │ │ ├── name: (required)
55
+ │ │ └── description: (required)
56
+ │ └── Markdown instructions (required)
57
+ └── Bundled Resources (optional)
58
+ ├── scripts/ - Executable code (Python/Bash/etc.)
59
+ ├── references/ - Documentation intended to be loaded into context as needed
60
+ └── assets/ - Files used in output (templates, icons, fonts, etc.)
61
+ ```
62
+
63
+ #### SKILL.md (required)
64
+
65
+ Every SKILL.md consists of:
66
+
67
+ - **Frontmatter** (YAML): Contains `name` and `description` fields. These are the only fields that Kimi reads to determine when the skill gets used, thus it is very important to be clear and comprehensive in describing what the skill is, and when it should be used.
68
+ - **Body** (Markdown): Instructions and guidance for using the skill. Only loaded AFTER the skill triggers (if at all).
69
+
70
+ #### Bundled Resources (optional)
71
+
72
+ ##### Scripts (`scripts/`)
73
+
74
+ Executable code (Python/Bash/etc.) for tasks that require deterministic reliability or are repeatedly rewritten.
75
+
76
+ - **When to include**: When the same code is being rewritten repeatedly or deterministic reliability is needed
77
+ - **Example**: `scripts/rotate_pdf.py` for PDF rotation tasks
78
+ - **Benefits**: Token efficient, deterministic, may be executed without loading into context
79
+ - **Note**: Scripts may still need to be read by Kimi for patching or environment-specific adjustments
80
+
81
+ ##### References (`references/`)
82
+
83
+ Documentation and reference material intended to be loaded as needed into context to inform Kimi's process and thinking.
84
+
85
+ - **When to include**: For documentation that Kimi should reference while working
86
+ - **Examples**: `references/finance.md` for financial schemas, `references/mnda.md` for company NDA template, `references/policies.md` for company policies, `references/api_docs.md` for API specifications
87
+ - **Use cases**: Database schemas, API documentation, domain knowledge, company policies, detailed workflow guides
88
+ - **Benefits**: Keeps SKILL.md lean, loaded only when Kimi determines it's needed
89
+ - **Best practice**: If files are large (>10k words), include grep search patterns in SKILL.md
90
+ - **Avoid duplication**: Information should live in either SKILL.md or references files, not both. Prefer references files for detailed information unless it's truly core to the skill—this keeps SKILL.md lean while making information discoverable without hogging the context window. Keep only essential procedural instructions and workflow guidance in SKILL.md; move detailed reference material, schemas, and examples to references files.
91
+
92
+ ##### Assets (`assets/`)
93
+
94
+ Files not intended to be loaded into context, but rather used within the output Kimi produces.
95
+
96
+ - **When to include**: When the skill needs files that will be used in the final output
97
+ - **Examples**: `assets/logo.png` for brand assets, `assets/slides.pptx` for PowerPoint templates, `assets/frontend-template/` for HTML/React boilerplate, `assets/font.ttf` for typography
98
+ - **Use cases**: Templates, images, icons, boilerplate code, fonts, sample documents that get copied or modified
99
+ - **Benefits**: Separates output resources from documentation, enables Kimi to use files without loading them into context
100
+
101
+ #### What to Not Include in a Skill
102
+
103
+ A skill should only contain essential files that directly support its functionality. Do NOT create extraneous documentation or auxiliary files, including:
104
+
105
+ - README.md
106
+ - INSTALLATION_GUIDE.md
107
+ - QUICK_REFERENCE.md
108
+ - CHANGELOG.md
109
+ - etc.
110
+
111
+ The skill should only contain the information needed for an AI agent to do the job at hand. It should not contain auxiliary context about the process that went into creating it, setup and testing procedures, user-facing documentation, etc. Creating additional documentation files just adds clutter and confusion.
112
+
113
+ ### Progressive Disclosure Design Principle
114
+
115
+ Skills use a three-level loading system to manage context efficiently:
116
+
117
+ 1. **Metadata (name + description)** - Always in context (~100 words)
118
+ 2. **SKILL.md body** - When skill triggers (<5k words)
119
+ 3. **Bundled resources** - As needed by Kimi (Unlimited because scripts can be executed without reading into context window)
120
+
121
+ #### Progressive Disclosure Patterns
122
+
123
+ Keep SKILL.md body to the essentials and under 500 lines to minimize context bloat. Split content into separate files when approaching this limit. When splitting out content into other files, it is very important to reference them from SKILL.md and describe clearly when to read them, to ensure the reader of the skill knows they exist and when to use them.
124
+
125
+ **Key principle:** When a skill supports multiple variations, frameworks, or options, keep only the core workflow and selection guidance in SKILL.md. Move variant-specific details (patterns, examples, configuration) into separate reference files.
126
+
127
+ **Pattern 1: High-level guide with references**
128
+
129
+ ```markdown
130
+ # PDF Processing
131
+
132
+ ## Quick start
133
+
134
+ Extract text with pdfplumber:
135
+ [code example]
136
+
137
+ ## Advanced features
138
+
139
+ - **Form filling**: See [FORMS.md](FORMS.md) for complete guide
140
+ - **API reference**: See [REFERENCE.md](REFERENCE.md) for all methods
141
+ - **Examples**: See [EXAMPLES.md](EXAMPLES.md) for common patterns
142
+ ```
143
+
144
+ Kimi loads FORMS.md, REFERENCE.md, or EXAMPLES.md only when needed.
145
+
146
+ **Pattern 2: Domain-specific organization**
147
+
148
+ For Skills with multiple domains, organize content by domain to avoid loading irrelevant context:
149
+
150
+ ```
151
+ bigquery-skill/
152
+ ├── SKILL.md (overview and navigation)
153
+ └── reference/
154
+ ├── finance.md (revenue, billing metrics)
155
+ ├── sales.md (opportunities, pipeline)
156
+ ├── product.md (API usage, features)
157
+ └── marketing.md (campaigns, attribution)
158
+ ```
159
+
160
+ When a user asks about sales metrics, Kimi only reads sales.md.
161
+
162
+ Similarly, for skills supporting multiple frameworks or variants, organize by variant:
163
+
164
+ ```
165
+ cloud-deploy/
166
+ ├── SKILL.md (workflow + provider selection)
167
+ └── references/
168
+ ├── aws.md (AWS deployment patterns)
169
+ ├── gcp.md (GCP deployment patterns)
170
+ └── azure.md (Azure deployment patterns)
171
+ ```
172
+
173
+ When the user chooses AWS, Kimi only reads aws.md.
174
+
175
+ **Pattern 3: Conditional details**
176
+
177
+ Show basic content, link to advanced content:
178
+
179
+ ```markdown
180
+ # DOCX Processing
181
+
182
+ ## Creating documents
183
+
184
+ Use docx-js for new documents. See [DOCX-JS.md](DOCX-JS.md).
185
+
186
+ ## Editing documents
187
+
188
+ For simple edits, modify the XML directly.
189
+
190
+ **For tracked changes**: See [REDLINING.md](REDLINING.md)
191
+ **For OOXML details**: See [OOXML.md](OOXML.md)
192
+ ```
193
+
194
+ Kimi reads REDLINING.md or OOXML.md only when the user needs those features.
195
+
196
+ **Important guidelines:**
197
+
198
+ - **Avoid deeply nested references** - Keep references one level deep from SKILL.md. All reference files should link directly from SKILL.md.
199
+ - **Structure longer reference files** - For files longer than 100 lines, include a table of contents at the top so Kimi can see the full scope when previewing.
200
+
201
+ ## Skill Creation Process
202
+
203
+ Skill creation involves these steps:
204
+
205
+ 1. Understand the skill with concrete examples
206
+ 2. Plan reusable skill contents (scripts, references, assets)
207
+ 3. Initialize the skill (run init_skill.py)
208
+ 4. Edit the skill (implement resources and write SKILL.md)
209
+ 5. Package the skill (run package_skill.py)
210
+ 6. Iterate based on real usage
211
+
212
+ Follow these steps in order, skipping only if there is a clear reason why they are not applicable.
213
+
214
+ ### Skill Naming
215
+
216
+ - Use lowercase letters, digits, and hyphens only; normalize user-provided titles to hyphen-case (e.g., "Plan Mode" -> `plan-mode`).
217
+ - When generating names, generate a name under 64 characters (letters, digits, hyphens).
218
+ - Prefer short, verb-led phrases that describe the action.
219
+ - Namespace by tool when it improves clarity or triggering (e.g., `gh-address-comments`, `linear-address-issue`).
220
+ - Name the skill folder exactly after the skill name.
221
+
222
+ ### Step 1: Understanding the Skill with Concrete Examples
223
+
224
+ Skip this step only when the skill's usage patterns are already clearly understood. It remains valuable even when working with an existing skill.
225
+
226
+ To create an effective skill, clearly understand concrete examples of how the skill will be used. This understanding can come from either direct user examples or generated examples that are validated with user feedback.
227
+
228
+ For example, when building an image-editor skill, relevant questions include:
229
+
230
+ - "What functionality should the image-editor skill support? Editing, rotating, anything else?"
231
+ - "Can you give some examples of how this skill would be used?"
232
+ - "I can imagine users asking for things like 'Remove the red-eye from this image' or 'Rotate this image'. Are there other ways you imagine this skill being used?"
233
+ - "What would a user say that should trigger this skill?"
234
+
235
+ To avoid overwhelming users, avoid asking too many questions in a single message. Start with the most important questions and follow up as needed for better effectiveness.
236
+
237
+ Conclude this step when there is a clear sense of the functionality the skill should support.
238
+
239
+ ### Step 2: Planning the Reusable Skill Contents
240
+
241
+ To turn concrete examples into an effective skill, analyze each example by:
242
+
243
+ 1. Considering how to execute on the example from scratch
244
+ 2. Identifying what scripts, references, and assets would be helpful when executing these workflows repeatedly
245
+
246
+ Example: When building a `pdf-editor` skill to handle queries like "Help me rotate this PDF," the analysis shows:
247
+
248
+ 1. Rotating a PDF requires re-writing the same code each time
249
+ 2. A `scripts/rotate_pdf.py` script would be helpful to store in the skill
250
+
251
+ Example: When designing a `frontend-webapp-builder` skill for queries like "Build me a todo app" or "Build me a dashboard to track my steps," the analysis shows:
252
+
253
+ 1. Writing a frontend webapp requires the same boilerplate HTML/React each time
254
+ 2. An `assets/hello-world/` template containing the boilerplate HTML/React project files would be helpful to store in the skill
255
+
256
+ Example: When building a `big-query` skill to handle queries like "How many users have logged in today?" the analysis shows:
257
+
258
+ 1. Querying BigQuery requires re-discovering the table schemas and relationships each time
259
+ 2. A `references/schema.md` file documenting the table schemas would be helpful to store in the skill
260
+
261
+ To establish the skill's contents, analyze each concrete example to create a list of the reusable resources to include: scripts, references, and assets.
262
+
263
+ ### Step 3: Initializing the Skill
264
+
265
+ At this point, it is time to actually create the skill.
266
+
267
+ Skip this step only if the skill being developed already exists, and iteration or packaging is needed. In this case, continue to the next step.
268
+
269
+ When creating a new skill from scratch, create a new skill directory with a required `SKILL.md`
270
+ file and any optional resource directories that the skill needs (`scripts/`, `references/`,
271
+ `assets/`). Create only the directories you intend to populate.
272
+
273
+ After initialization, customize the SKILL.md and add resources as needed.
274
+
275
+ ### Step 4: Edit the Skill
276
+
277
+ When editing the (newly-generated or existing) skill, remember that the skill is being created for another instance of Kimi to use. Include information that would be beneficial and non-obvious to Kimi. Consider what procedural knowledge, domain-specific details, or reusable assets would help another Kimi instance execute these tasks more effectively.
278
+
279
+ #### Learn Proven Design Patterns
280
+
281
+ Capture proven design patterns directly in this SKILL.md:
282
+
283
+ - **Multi-step processes**: Clearly describe sequential workflows and conditional branches, including triggers, decision points, and expected outputs at each step.
284
+ - **Specific output formats or quality standards**: Document required output shapes, templates, and examples directly in this SKILL.md so they are easy to follow.
285
+
286
+ #### Start with Reusable Skill Contents
287
+
288
+ To begin implementation, start with the reusable resources identified above: `scripts/`, `references/`, and `assets/` files. Note that this step may require user input. For example, when implementing a `brand-guidelines` skill, the user may need to provide brand assets or templates to store in `assets/`, or documentation to store in `references/`.
289
+
290
+ Added scripts must be tested by actually running them to ensure there are no bugs and that the output matches what is expected. If there are many similar scripts, only a representative sample needs to be tested to ensure confidence that they all work while balancing time to completion.
291
+
292
+ Delete any placeholder files that are not needed for the skill. Only create resource directories that are actually required.
293
+
294
+ #### Update SKILL.md
295
+
296
+ **Writing Guidelines:** Always use imperative/infinitive form.
297
+
298
+ ##### Frontmatter
299
+
300
+ Write the YAML frontmatter with `name` and `description`:
301
+
302
+ - `name`: The skill name
303
+ - `description`: This is the primary triggering mechanism for your skill, and helps Kimi understand when to use the skill.
304
+ - Include both what the Skill does and specific triggers/contexts for when to use it.
305
+ - Include all "when to use" information here - Not in the body. The body is only loaded after triggering, so "When to Use This Skill" sections in the body are not helpful to Kimi.
306
+ - Example description for a `docx` skill: "Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. Use when Kimi needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks"
307
+
308
+ Do not include any other fields in YAML frontmatter.
309
+
310
+ ##### Body
311
+
312
+ Write instructions for using the skill and its bundled resources.
313
+
314
+ ### Step 5: Packaging a Skill
315
+
316
+ Once development of the skill is complete, package it into a distributable `.skill` file (a zip
317
+ archive). Before packaging, validate that the skill meets all requirements:
318
+
319
+ 1. **Validate** the skill, checking:
320
+
321
+ - YAML frontmatter format and required fields
322
+ - Skill naming conventions and directory structure
323
+ - Description completeness and quality
324
+ - File organization and resource references
325
+
326
+ 2. **Package** the skill if validation passes:
327
+
328
+ - Create an archive of the skill's root folder (the folder containing `SKILL.md` and all related files).
329
+ - Ensure the archive preserves the internal directory structure.
330
+ - Name the archive `<skill-name>.skill` (for example, `my-skill.skill`). The `.skill` file is a zip file with a `.skill` extension.
331
+
332
+ Example packaging command:
333
+
334
+ ```bash
335
+ cd <skills-root>
336
+ zip -r my-skill.skill my-skill
337
+ ```
338
+
339
+ If validation fails (for example, due to malformed frontmatter, missing files, or an incomplete
340
+ description), fix the issues and repackage the skill.
341
+
342
+ ### Step 6: Iterate
343
+
344
+ After testing the skill, users may request improvements. Often this happens right after using the skill, with fresh context of how the skill performed.
345
+
346
+ **Iteration workflow:**
347
+
348
+ 1. Use the skill on real tasks
349
+ 2. Notice struggles or inefficiencies
350
+ 3. Identify how SKILL.md or bundled resources should be updated
351
+ 4. Implement changes and test again
kimi_cli/soul/__init__.py CHANGED
@@ -1,32 +1,39 @@
1
+ from __future__ import annotations
2
+
1
3
  import asyncio
2
4
  import contextlib
3
5
  from collections.abc import Callable, Coroutine
4
6
  from contextvars import ContextVar
5
- from typing import Any, NamedTuple, Protocol, runtime_checkable
6
-
7
- from kosong.base.message import ContentPart
7
+ from dataclasses import dataclass
8
+ from pathlib import Path
9
+ from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable
8
10
 
9
- from kimi_cli.llm import LLM
11
+ from kimi_cli.utils.aioqueue import QueueShutDown
10
12
  from kimi_cli.utils.logging import logger
11
- from kimi_cli.wire import Wire, WireUISide
12
- from kimi_cli.wire.message import WireMessage
13
+ from kimi_cli.wire import Wire
14
+ from kimi_cli.wire.types import ContentPart, WireMessage
15
+
16
+ if TYPE_CHECKING:
17
+ from kimi_cli.llm import LLM, ModelCapability
18
+ from kimi_cli.utils.slashcmd import SlashCommand
13
19
 
14
20
 
15
21
  class LLMNotSet(Exception):
16
22
  """Raised when the LLM is not set."""
17
23
 
18
- pass
24
+ def __init__(self) -> None:
25
+ super().__init__("LLM not set")
19
26
 
20
27
 
21
28
  class LLMNotSupported(Exception):
22
29
  """Raised when the LLM does not have required capabilities."""
23
30
 
24
- def __init__(self, llm: LLM, capabilities: list[str]):
31
+ def __init__(self, llm: LLM, capabilities: list[ModelCapability]):
25
32
  self.llm = llm
26
33
  self.capabilities = capabilities
27
34
  capabilities_str = "capability" if len(capabilities) == 1 else "capabilities"
28
35
  super().__init__(
29
- f"The LLM model '{llm.model_name}' does not support required {capabilities_str}: "
36
+ f"LLM model '{llm.model_name}' does not support required {capabilities_str}: "
30
37
  f"{', '.join(capabilities)}."
31
38
  )
32
39
 
@@ -38,12 +45,16 @@ class MaxStepsReached(Exception):
38
45
  """The number of steps that have been taken."""
39
46
 
40
47
  def __init__(self, n_steps: int):
48
+ super().__init__(f"Max number of steps reached: {n_steps}")
41
49
  self.n_steps = n_steps
42
50
 
43
51
 
44
- class StatusSnapshot(NamedTuple):
52
+ @dataclass(frozen=True, slots=True)
53
+ class StatusSnapshot:
45
54
  context_usage: float
46
55
  """The usage of the context, in percentage."""
56
+ yolo_enabled: bool = False
57
+ """Whether YOLO (auto-approve) mode is enabled."""
47
58
 
48
59
 
49
60
  @runtime_checkable
@@ -54,8 +65,21 @@ class Soul(Protocol):
54
65
  ...
55
66
 
56
67
  @property
57
- def model(self) -> str:
58
- """The LLM model used by the soul. Empty string indicates no LLM configured."""
68
+ def model_name(self) -> str:
69
+ """The name of the LLM model used by the soul. Empty string if LLM is not set."""
70
+ ...
71
+
72
+ @property
73
+ def model_capabilities(self) -> set[ModelCapability] | None:
74
+ """The capabilities of the LLM model used by the soul. None if LLM is not set."""
75
+ ...
76
+
77
+ @property
78
+ def thinking(self) -> bool | None:
79
+ """
80
+ Whether thinking mode is currently enabled.
81
+ None if LLM is not set or thinking mode is not set explicitly.
82
+ """
59
83
  ...
60
84
 
61
85
  @property
@@ -63,12 +87,18 @@ class Soul(Protocol):
63
87
  """The current status of the soul. The returned value is immutable."""
64
88
  ...
65
89
 
90
+ @property
91
+ def available_slash_commands(self) -> list[SlashCommand[Any]]:
92
+ """List of available slash commands supported by the soul."""
93
+ ...
94
+
66
95
  async def run(self, user_input: str | list[ContentPart]):
67
96
  """
68
97
  Run the agent with the given user input until the max steps or no more tool calls.
69
98
 
70
99
  Args:
71
100
  user_input (str | list[ContentPart]): The user input to the agent.
101
+ Can be a slash command call or natural language input.
72
102
 
73
103
  Raises:
74
104
  LLMNotSet: When the LLM is not set.
@@ -80,7 +110,7 @@ class Soul(Protocol):
80
110
  ...
81
111
 
82
112
 
83
- type UILoopFn = Callable[[WireUISide], Coroutine[Any, Any, None]]
113
+ type UILoopFn = Callable[[Wire], Coroutine[Any, Any, None]]
84
114
  """A long-running async function to visualize the agent behavior."""
85
115
 
86
116
 
@@ -89,13 +119,14 @@ class RunCancelled(Exception):
89
119
 
90
120
 
91
121
  async def run_soul(
92
- soul: "Soul",
122
+ soul: Soul,
93
123
  user_input: str | list[ContentPart],
94
124
  ui_loop_fn: UILoopFn,
95
125
  cancel_event: asyncio.Event,
126
+ wire_file: Path | None = None,
96
127
  ) -> None:
97
128
  """
98
- Run the soul with the given user input, connecting it to the UI loop with a wire.
129
+ Run the soul with the given user input, connecting it to the UI loop with a `Wire`.
99
130
 
100
131
  `cancel_event` is a outside handle that can be used to cancel the run. When the
101
132
  event is set, the run will be gracefully stopped and a `RunCancelled` will be raised.
@@ -107,11 +138,11 @@ async def run_soul(
107
138
  MaxStepsReached: When the maximum number of steps is reached.
108
139
  RunCancelled: When the run is cancelled by the cancel event.
109
140
  """
110
- wire = Wire()
141
+ wire = Wire(file_backend=wire_file)
111
142
  wire_token = _current_wire.set(wire)
112
143
 
113
144
  logger.debug("Starting UI loop with function: {ui_loop_fn}", ui_loop_fn=ui_loop_fn)
114
- ui_task = asyncio.create_task(ui_loop_fn(wire.ui_side))
145
+ ui_task = asyncio.create_task(ui_loop_fn(wire))
115
146
 
116
147
  logger.debug("Starting soul run")
117
148
  soul_task = asyncio.create_task(soul.run(user_input))
@@ -142,13 +173,13 @@ async def run_soul(
142
173
  wire.shutdown()
143
174
  try:
144
175
  await asyncio.wait_for(ui_task, timeout=0.5)
145
- except asyncio.QueueShutDown:
176
+ except QueueShutDown:
146
177
  logger.debug("UI loop shut down")
147
178
  pass
148
179
  except TimeoutError:
149
180
  logger.warning("UI loop timed out")
150
-
151
- _current_wire.reset(wire_token)
181
+ finally:
182
+ _current_wire.reset(wire_token)
152
183
 
153
184
 
154
185
  _current_wire = ContextVar[Wire | None]("current_wire", default=None)