@ywldan/kiro 0.2.8 → 0.2.10

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.
package/README.md CHANGED
@@ -248,6 +248,7 @@ kiro [options]
248
248
  --mouse Mouse reporting (on by default): wheel scrolls the transcript
249
249
  --no-mouse Disable mouse reporting so plain click-drag selection works
250
250
  --no-alt-screen Do not switch to the terminal's alternate screen
251
+ --no-skills Do not read skill folders at all (KIRO_NO_SKILLS=1 does the same)
251
252
  -h, --help Show help
252
253
  -v, --version Show version
253
254
 
@@ -332,6 +333,8 @@ Slash commands:
332
333
  | `/model list --remote` | List models offered by the active endpoint's `GET /models` |
333
334
  | `/context` | Show approximate context use by message role plus session token totals |
334
335
  | `/usage` | Show or hide the Usage card, giving the transcript the full width |
336
+ | `/skills` | List installed skills, their source, and any skipped entries |
337
+ | `/skill <name> [request]` | Load a skill, optionally with your request in the same line |
335
338
  | `/compact` | Summarize older turns now, keeping the last four user turns verbatim |
336
339
  | `/sessions` | List saved sessions for this working directory |
337
340
  | `/resume <n\|id>` | Resume a session by list number or id (prefixes work) |
@@ -420,6 +423,34 @@ Checkpoints are best effort: if a snapshot cannot be taken, the tool still runs.
420
423
 
421
424
  If an `AGENTS.md` file exists in the working directory, its contents are appended to the system prompt for every turn, so project-specific instructions apply immediately, including after edits.
422
425
 
426
+ ## Skills
427
+
428
+ A skill is a folder of instructions that Kiro loads only when it is needed. Kiro looks in four places, in this order, and the first definition of a name wins:
429
+
430
+ 1. `<cwd>/.kiro/skills/`
431
+ 2. `<cwd>/.claude/skills/`, so skills installed for Claude Code work unchanged
432
+ 3. `~/.kiro/skills/`
433
+ 4. `~/.claude/skills/`
434
+
435
+ Each skill is a directory with a `SKILL.md`:
436
+
437
+ ```md
438
+ ---
439
+ name: anti-slop
440
+ description: Remove AI-slop patterns from prose before answering.
441
+ ---
442
+
443
+ Delete "delve", "tapestry", and stacked em dashes. Prefer concrete nouns.
444
+ ```
445
+
446
+ Only `name` and `description` are read from the frontmatter; `allowed-tools`, `license`, and any other key are ignored, and a skill can never skip an approval prompt. A folder is a skill when it holds `SKILL.md`, searched two levels deep, so `skills/<name>/SKILL.md` and `skills/<group>/<name>/SKILL.md` both work, and symlinked skill folders are followed (loops are detected). Supporting files inside the folder — references, templates, scripts — are read or run like any other file, so `read_file` and `run_command` rules still apply.
447
+
448
+ Only the name and description reach the system prompt. Every installed skill is listed by name: up to 30 keep a full description, more than that clip theirs to 60 characters, and an enormous collection falls back to bare names so the prompt always stays bounded. When a request matches, the model calls `read_skill` to load the body, so fifty installed skills cost a few hundred tokens instead of their full text. `read_skill` is read-only: it needs no approval and can run alongside other reads, and it says whether the skill came from the project or your user folder.
449
+
450
+ `/skills` lists what was found, whether it came from the project or the user, and any folder that was skipped with the reason (no `SKILL.md`, a `SKILL.md` sitting loose in the skills root, a missing description, a duplicate name, an oversized file). `/skill anti-slop` loads a skill for your next message; `/skill anti-slop rewrite this paragraph` loads it and sends the request in the same turn. Either way the transcript keeps the compact command line you typed while the model receives the full instructions. The first time the model pulls a skill that came from the repository you are in, Kiro says so once in the transcript.
451
+
452
+ The index is rebuilt every turn, so edits to `SKILL.md` apply on the next message. Set `KIRO_SKILLS_DIR` to replace both user roots, and `--no-skills` or `KIRO_NO_SKILLS=1` (which can live in `~/.kiro/.env`) to skip skill folders entirely.
453
+
423
454
  ## How it works
424
455
 
425
456
  - The OpenAI provider posts to `{baseUrl}/chat/completions` with `stream: true`, parses SSE incrementally, and assembles tool-call deltas by index. It also accepts a plain JSON response from servers that ignore streaming, and reads `usage` when the endpoint sends it.
@@ -454,7 +485,7 @@ The suite covers streaming, multiple tool calls per response, approvals and deni
454
485
 
455
486
  Model workflow tests use a temp `$HOME` so the real `~/.kiro` is never touched. They cover atomic config saves that preserve unknown fields, profile-name and URL validation, corrupt-config backup/recovery, `.env` parsing and real-environment precedence, `0600` writes, masking, the exact preset list, discovery success/401/missing-`/models`/timeout, the connection test, and wizard add/edit/select/remove/last-profile refusal/cancel/manual-model fallback. Scripted `kiro model add`, `list`, `use`, `test`, and `remove` run through the real CLI against the in-process mock; a failed test saves nothing, keys never appear in `config.json`, and generated keys land in `.env`. The wizard screen renderer is unit-tested against a fake stream: alternate-screen enter/leave, a new menu replacing the previous one, the breadcrumb of answered prompts (menu title instead of `Choose`, the value kept by pressing Enter, confirmation of a `Y/n` default, and the reset on Escape or a return to the root menu), stale errors dropped at a step change, log trimming to the terminal height with the prompt always visible, keyboard scrolling of an over-long list (page, top, bottom, clamping, reset on new output), and replaying results after the screen is restored. `/model` groups profiles by endpoint so several models behind one base URL are listed as siblings.
456
487
 
457
- The newer paths have their own coverage: `max_completion_tokens` selection for reasoning models and recovery from a `max_tokens` rejection, `reasoning_content` deltas reaching the agent and collapsing in the renderer, the stream idle timeout, checkpoint edit/create undo with backup files outside the manifest, and prompt-history dedupe/capping/redaction. A spawned `kiro -p` test runs a tool with `--yolo`, checks the reply and saved session, feeds a piped prompt through `-p -`, and verifies the non-TTY hint without `-p`.
488
+ The newer paths have their own coverage: `max_completion_tokens` selection for reasoning models and recovery from a `max_tokens` rejection, `reasoning_content` deltas reaching the agent and collapsing in the renderer, the stream idle timeout, checkpoint edit/create undo with backup files outside the manifest, and prompt-history dedupe/capping/redaction. Skills are covered from the file to the model: frontmatter with quoted and continued values, CRLF input, `.kiro` overriding `.claude`, symlinked and nested skill folders, skipped folders reported with their reason, an index that keeps every name while clipping descriptions, an invocation message that carries the user's request, `--no-skills`, and the read-only `read_skill` tool. A spawned `kiro -p` test runs a tool with `--yolo`, checks the reply and saved session, feeds a piped prompt through `-p -`, and verifies the non-TTY hint without `-p`.
458
489
 
459
490
  ## Project layout
460
491
 
@@ -468,8 +499,8 @@ src/
468
499
  sessions.ts atomic session save/load/list
469
500
  model/ presets, discovery/test, context-window inference, shared wizard, CLI + screen renderer
470
501
  providers/ Provider interface, OpenAI-compatible implementation
471
- agent/ system prompt, agent loop, token estimates, compaction
472
- tools/ tool registry, fs/search/patch/shell tools, checkpoints, glob/gitignore matching
502
+ agent/ system prompt, skill discovery/parsing, agent loop, token estimates, compaction
503
+ tools/ tool registry, fs/search/patch/shell/skill tools, checkpoints, glob/gitignore matching
473
504
  ui/ Ink app, markdown, command palette, prompt history, scrolling, approvals, status bar, export
474
505
  test/
475
506
  mock-server.ts scripted OpenAI-compatible SSE server + /models variants
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { platform, release } from 'node:os';
3
3
  import path from 'node:path';
4
+ import { formatSkillIndex, loadSkills } from './skills.js';
4
5
  const MAX_AGENTS_MD_BYTES = 200_000;
5
6
  function osName() {
6
7
  switch (platform()) {
@@ -12,6 +13,21 @@ function osName() {
12
13
  return `${platform()} (${release()})`;
13
14
  }
14
15
  }
16
+ async function readAgentsSection(cwd) {
17
+ const agentsPath = path.join(cwd, 'AGENTS.md');
18
+ try {
19
+ const content = await readFile(agentsPath, 'utf8');
20
+ const clipped = content.length > MAX_AGENTS_MD_BYTES
21
+ ? content.slice(0, MAX_AGENTS_MD_BYTES) + '\n\n[AGENTS.md truncated by Kiro]'
22
+ : content;
23
+ return `# Project instructions from AGENTS.md\n\n${clipped.trimEnd()}`;
24
+ }
25
+ catch (error) {
26
+ if (error.code === 'ENOENT')
27
+ return '';
28
+ return `[Could not read AGENTS.md: ${error.message}]`;
29
+ }
30
+ }
15
31
  export async function buildSystemPrompt(cwd) {
16
32
  const base = [
17
33
  'You are Kiro, a terminal-based coding agent working in the user\'s current directory.',
@@ -36,18 +52,8 @@ export async function buildSystemPrompt(cwd) {
36
52
  '',
37
53
  'You have these tools: read_file, write_file, edit_file, multi_edit, apply_patch, list_dir, glob, grep, run_command.',
38
54
  ].join('\n');
39
- const agentsPath = path.join(cwd, 'AGENTS.md');
40
- try {
41
- const content = await readFile(agentsPath, 'utf8');
42
- const clipped = content.length > MAX_AGENTS_MD_BYTES
43
- ? content.slice(0, MAX_AGENTS_MD_BYTES) + '\n\n[AGENTS.md truncated by Kiro]'
44
- : content;
45
- return `${base}\n\n# Project instructions from AGENTS.md\n\n${clipped.trimEnd()}\n`;
46
- }
47
- catch (error) {
48
- if (error.code === 'ENOENT')
49
- return base;
50
- return `${base}\n\n[Could not read AGENTS.md: ${error.message}]\n`;
51
- }
55
+ const [agents, inventory] = await Promise.all([readAgentsSection(cwd), loadSkills(cwd)]);
56
+ const sections = [base, agents, formatSkillIndex(inventory.skills)].filter(Boolean);
57
+ return sections.length === 1 ? base : `${sections.join('\n\n')}\n`;
52
58
  }
53
59
  //# sourceMappingURL=prompt.js.map
@@ -0,0 +1,404 @@
1
+ import { readdir, readFile, realpath, stat } from 'node:fs/promises';
2
+ import { homedir } from 'node:os';
3
+ import path from 'node:path';
4
+ export const MAX_SKILLS_IN_PROMPT = 30;
5
+ export const MAX_SKILL_DESCRIPTION_CHARS = 300;
6
+ export const MAX_SKILL_SHORT_DESCRIPTION_CHARS = 60;
7
+ export const MAX_SKILL_BODY_CHARS = 50_000;
8
+ export const MAX_SKILL_FILE_BYTES = 200_000;
9
+ export const MAX_SKILLS_INDEX_CHARS = 8_000;
10
+ /** Skills are found at <root>/<name>/SKILL.md and <root>/<group>/<name>/SKILL.md. */
11
+ export const MAX_SKILL_DEPTH = 2;
12
+ const MAX_SKILL_NAME_CHARS = 64;
13
+ const MAX_SKILL_DIRS_PER_ROOT = 500;
14
+ const SKILL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
15
+ const SKIP_DIR_NAMES = new Set(['node_modules', '.git']);
16
+ let skillsEnabled = true;
17
+ /** Turned off by --no-skills or KIRO_NO_SKILLS; nothing is read from disk then. */
18
+ export function setSkillsEnabled(enabled) {
19
+ skillsEnabled = enabled;
20
+ }
21
+ export function skillsAreEnabled() {
22
+ return skillsEnabled;
23
+ }
24
+ /** `.claude/skills` is read too, so skills installed for other CLIs work unchanged. */
25
+ export function skillRoots(cwd) {
26
+ const roots = [
27
+ { root: path.join(cwd, '.kiro', 'skills'), source: 'project' },
28
+ { root: path.join(cwd, '.claude', 'skills'), source: 'project' },
29
+ ];
30
+ const override = process.env.KIRO_SKILLS_DIR?.trim();
31
+ if (override) {
32
+ roots.push({ root: path.resolve(override), source: 'user' });
33
+ }
34
+ else {
35
+ const home = homedir();
36
+ roots.push({ root: path.join(home, '.kiro', 'skills'), source: 'user' });
37
+ roots.push({ root: path.join(home, '.claude', 'skills'), source: 'user' });
38
+ }
39
+ const seen = new Set();
40
+ return roots.filter(({ root }) => {
41
+ if (seen.has(root))
42
+ return false;
43
+ seen.add(root);
44
+ return true;
45
+ });
46
+ }
47
+ function cleanValue(raw) {
48
+ const value = raw.trim();
49
+ if (value.length >= 2) {
50
+ const first = value[0];
51
+ const last = value[value.length - 1];
52
+ if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
53
+ return value.slice(1, -1).trim();
54
+ }
55
+ }
56
+ return value;
57
+ }
58
+ /** Reads the simple `key: value` frontmatter skills use; nested YAML is ignored. */
59
+ function parseMeta(lines) {
60
+ const meta = new Map();
61
+ let key = null;
62
+ let continuation = [];
63
+ const commit = () => {
64
+ if (key !== null && continuation.length > 0)
65
+ meta.set(key, cleanValue(continuation.join(' ')));
66
+ key = null;
67
+ continuation = [];
68
+ };
69
+ for (const line of lines) {
70
+ const match = /^([A-Za-z][A-Za-z0-9_-]*)\s*:\s*(.*)$/.exec(line);
71
+ if (match) {
72
+ commit();
73
+ const name = match[1].toLowerCase();
74
+ const value = (match[2] ?? '').trim();
75
+ const quote = value[0];
76
+ const quotedOpen = (quote === '"' || quote === "'") &&
77
+ !(value.length > 1 && value.endsWith(quote));
78
+ if (value === '' || /^[>|][+-]?$/.test(value) || quotedOpen) {
79
+ key = name;
80
+ continuation = value === '' || /^[>|][+-]?$/.test(value) ? [] : [value];
81
+ }
82
+ else {
83
+ meta.set(name, cleanValue(value));
84
+ }
85
+ continue;
86
+ }
87
+ if (key !== null && /^\s+\S/.test(line)) {
88
+ continuation.push(line.trim());
89
+ continue;
90
+ }
91
+ commit();
92
+ }
93
+ commit();
94
+ return meta;
95
+ }
96
+ export function parseSkillFile(raw) {
97
+ const text = raw.replace(/^\uFEFF/, '').replace(/\r\n?/g, '\n');
98
+ const lines = text.split('\n');
99
+ if (lines[0]?.trim() !== '---') {
100
+ return { ok: false, reason: 'missing frontmatter: the file must start with ---' };
101
+ }
102
+ let close = -1;
103
+ for (let index = 1; index < lines.length; index++) {
104
+ if (lines[index]?.trim() === '---') {
105
+ close = index;
106
+ break;
107
+ }
108
+ }
109
+ if (close === -1)
110
+ return { ok: false, reason: 'unterminated frontmatter block' };
111
+ const meta = parseMeta(lines.slice(1, close));
112
+ const description = (meta.get('description') ?? '').replace(/\s+/g, ' ').trim();
113
+ if (!description)
114
+ return { ok: false, reason: 'frontmatter is missing a description' };
115
+ const body = lines.slice(close + 1).join('\n').trim();
116
+ if (!body)
117
+ return { ok: false, reason: 'the skill has no instructions after the frontmatter' };
118
+ return {
119
+ ok: true,
120
+ value: { name: meta.get('name')?.trim() || undefined, description, body },
121
+ };
122
+ }
123
+ async function isFile(target) {
124
+ try {
125
+ return (await stat(target)).isFile();
126
+ }
127
+ catch {
128
+ return false;
129
+ }
130
+ }
131
+ async function isDirectory(target) {
132
+ try {
133
+ return (await stat(target)).isDirectory();
134
+ }
135
+ catch {
136
+ return false;
137
+ }
138
+ }
139
+ async function readSkillAt(dir, folder) {
140
+ const file = path.join(dir, 'SKILL.md');
141
+ let info;
142
+ try {
143
+ info = await stat(file);
144
+ }
145
+ catch (error) {
146
+ const code = error.code;
147
+ if (code === 'ENOENT' || code === 'ENOTDIR')
148
+ return {};
149
+ return { invalid: { name: folder, file, reason: error.message } };
150
+ }
151
+ if (!info.isFile())
152
+ return {};
153
+ if (info.size > MAX_SKILL_FILE_BYTES) {
154
+ return {
155
+ invalid: {
156
+ name: folder,
157
+ file,
158
+ reason: `SKILL.md is larger than ${MAX_SKILL_FILE_BYTES.toLocaleString()} bytes`,
159
+ },
160
+ };
161
+ }
162
+ let raw;
163
+ try {
164
+ raw = await readFile(file, 'utf8');
165
+ }
166
+ catch (error) {
167
+ return { invalid: { name: folder, file, reason: error.message } };
168
+ }
169
+ const parsed = parseSkillFile(raw);
170
+ if (!parsed.ok)
171
+ return { invalid: { name: folder, file, reason: parsed.reason } };
172
+ const name = parsed.value.name ?? folder;
173
+ if (name.length > MAX_SKILL_NAME_CHARS || !SKILL_NAME_PATTERN.test(name)) {
174
+ return {
175
+ invalid: {
176
+ name,
177
+ file,
178
+ reason: 'the name may only contain letters, digits, dots, dashes, and underscores',
179
+ },
180
+ };
181
+ }
182
+ return {
183
+ skill: {
184
+ name,
185
+ description: parsed.value.description,
186
+ body: parsed.value.body,
187
+ dir,
188
+ file,
189
+ },
190
+ };
191
+ }
192
+ function addSkill(ctx, skill, source) {
193
+ const existing = ctx.byName.get(skill.name.toLowerCase());
194
+ if (existing) {
195
+ ctx.invalid.push({
196
+ name: skill.name,
197
+ file: skill.file,
198
+ source,
199
+ reason: `duplicate name; ${existing.file} already defines it`,
200
+ });
201
+ return;
202
+ }
203
+ const complete = { ...skill, source };
204
+ ctx.skills.push(complete);
205
+ ctx.byName.set(skill.name.toLowerCase(), complete);
206
+ }
207
+ /** Returns true when a skill was found at or below dir. */
208
+ async function walk(ctx, dir, depth, source) {
209
+ let resolved;
210
+ try {
211
+ resolved = await realpath(dir);
212
+ }
213
+ catch {
214
+ return false;
215
+ }
216
+ if (ctx.visited.has(resolved))
217
+ return false;
218
+ ctx.visited.add(resolved);
219
+ if (depth >= 1 && (await isFile(path.join(dir, 'SKILL.md')))) {
220
+ const result = await readSkillAt(dir, path.basename(dir));
221
+ if (result.invalid)
222
+ ctx.invalid.push({ ...result.invalid, source });
223
+ else if (result.skill)
224
+ addSkill(ctx, result.skill, source);
225
+ return true;
226
+ }
227
+ if (depth === 0 && (await isFile(path.join(dir, 'SKILL.md')))) {
228
+ ctx.invalid.push({
229
+ name: path.basename(dir),
230
+ file: path.join(dir, 'SKILL.md'),
231
+ source,
232
+ reason: 'SKILL.md must sit in its own folder (<skills>/<name>/SKILL.md)',
233
+ });
234
+ }
235
+ if (depth >= MAX_SKILL_DEPTH)
236
+ return false;
237
+ let entries;
238
+ try {
239
+ entries = await readdir(dir, { withFileTypes: true });
240
+ }
241
+ catch (error) {
242
+ const code = error.code;
243
+ if (depth === 0 && code !== 'ENOENT' && code !== 'ENOTDIR') {
244
+ ctx.invalid.push({
245
+ name: path.basename(dir),
246
+ file: dir,
247
+ source,
248
+ reason: `cannot read the directory: ${error.message}`,
249
+ });
250
+ }
251
+ return false;
252
+ }
253
+ const names = entries
254
+ .filter((entry) => !entry.name.startsWith('.') &&
255
+ !SKIP_DIR_NAMES.has(entry.name) &&
256
+ (entry.isDirectory() || entry.isSymbolicLink()))
257
+ .map((entry) => entry.name)
258
+ .sort((a, b) => a.localeCompare(b, 'en'));
259
+ let found = false;
260
+ for (const name of names) {
261
+ if (ctx.dirs++ >= MAX_SKILL_DIRS_PER_ROOT) {
262
+ ctx.invalid.push({
263
+ name: path.basename(dir),
264
+ file: dir,
265
+ source,
266
+ reason: `stopped after ${MAX_SKILL_DIRS_PER_ROOT} folders in this skills root`,
267
+ });
268
+ break;
269
+ }
270
+ const child = path.join(dir, name);
271
+ if (!(await isDirectory(child)))
272
+ continue;
273
+ if (await walk(ctx, child, depth + 1, source))
274
+ found = true;
275
+ }
276
+ if (!found && depth >= 1) {
277
+ ctx.invalid.push({
278
+ name: path.basename(dir),
279
+ file: dir,
280
+ source,
281
+ reason: 'no SKILL.md in this folder (or one level deeper)',
282
+ });
283
+ }
284
+ return found;
285
+ }
286
+ /** Project roots win over user roots; the first definition of a name is kept. */
287
+ export async function loadSkills(cwd) {
288
+ const roots = skillRoots(cwd);
289
+ const ctx = {
290
+ skills: [],
291
+ invalid: [],
292
+ byName: new Map(),
293
+ visited: new Set(),
294
+ dirs: 0,
295
+ };
296
+ if (skillsEnabled) {
297
+ for (const { root, source } of roots)
298
+ await walk(ctx, root, 0, source);
299
+ }
300
+ ctx.skills.sort((a, b) => a.name.localeCompare(b.name, 'en'));
301
+ return {
302
+ skills: ctx.skills,
303
+ invalid: ctx.invalid,
304
+ roots: roots.map(({ root }) => root),
305
+ disabled: !skillsEnabled,
306
+ };
307
+ }
308
+ export function findSkill(skills, name) {
309
+ const needle = name.trim().toLowerCase();
310
+ return skills.find((skill) => skill.name.toLowerCase() === needle);
311
+ }
312
+ export function shortPath(target, cwd) {
313
+ const relative = path.relative(cwd, target);
314
+ if (relative === '')
315
+ return '.';
316
+ if (!relative.startsWith('..') && !path.isAbsolute(relative))
317
+ return relative;
318
+ const home = homedir();
319
+ if (target === home)
320
+ return '~';
321
+ if (target.startsWith(`${home}${path.sep}`))
322
+ return `~${target.slice(home.length)}`;
323
+ return target;
324
+ }
325
+ function clipDescription(description, max) {
326
+ return description.length > max ? `${description.slice(0, max - 1)}…` : description;
327
+ }
328
+ /** Name and description only; the body stays on disk until read_skill loads it. */
329
+ export function formatSkillIndex(skills) {
330
+ if (skills.length === 0)
331
+ return '';
332
+ const header = [
333
+ '# Skills',
334
+ 'Installed skills extend how you work. When a request matches one, call the read_skill tool with the exact name first and follow the instructions it returns. Do not guess what a skill contains.',
335
+ ];
336
+ const budget = MAX_SKILLS_INDEX_CHARS - header.join('\n').length - 1;
337
+ const descriptionLimit = skills.length > MAX_SKILLS_IN_PROMPT
338
+ ? MAX_SKILL_SHORT_DESCRIPTION_CHARS
339
+ : MAX_SKILL_DESCRIPTION_CHARS;
340
+ let lines = skills.map((skill) => `- ${skill.name}: ${clipDescription(skill.description, descriptionLimit)}`);
341
+ if (lines.join('\n').length > budget)
342
+ lines = skills.map((skill) => `- ${skill.name}`);
343
+ const kept = [];
344
+ let used = 0;
345
+ for (const line of lines) {
346
+ if (kept.length > 0 && used + line.length + 1 > budget)
347
+ break;
348
+ used += line.length + 1;
349
+ kept.push(line);
350
+ }
351
+ const omitted = skills.length - kept.length;
352
+ if (omitted > 0)
353
+ kept.push(`(+${omitted} more skills; run /skills to list all.)`);
354
+ return [...header, ...kept].join('\n');
355
+ }
356
+ /** The user message /skill produces: full instructions plus, when given, the request. */
357
+ export function skillInvocationMessage(skill, request = '') {
358
+ const body = skill.body.length > MAX_SKILL_BODY_CHARS
359
+ ? `${skill.body.slice(0, MAX_SKILL_BODY_CHARS)}\n\n[Skill truncated; the rest is in ${skill.file}]`
360
+ : skill.body;
361
+ const ask = request.trim();
362
+ if (ask) {
363
+ return `Use the "${skill.name}" skill for this request.\n\n${body}\n\nRequest: ${ask}`;
364
+ }
365
+ return `Use the "${skill.name}" skill. Its instructions follow; apply them to what I ask next.\n\n${body}`;
366
+ }
367
+ export function formatSkillList(inventory, cwd) {
368
+ if (inventory.disabled) {
369
+ return 'Skills are disabled for this run (--no-skills or KIRO_NO_SKILLS).';
370
+ }
371
+ const lines = [];
372
+ if (inventory.skills.length === 0) {
373
+ lines.push('No skills installed.');
374
+ }
375
+ else {
376
+ const project = inventory.skills.filter((skill) => skill.source === 'project').length;
377
+ const user = inventory.skills.length - project;
378
+ const counts = [project > 0 ? `${project} project` : '', user > 0 ? `${user} user` : '']
379
+ .filter(Boolean)
380
+ .join(', ');
381
+ lines.push(`Installed skills (${counts}):`);
382
+ const width = Math.min(28, Math.max(...inventory.skills.map((skill) => skill.name.length)));
383
+ for (const skill of inventory.skills) {
384
+ lines.push(` ${skill.name.padEnd(width)} ${clipDescription(skill.description, 80)} ` +
385
+ `[${skill.source}] (${shortPath(skill.dir, cwd)})`);
386
+ }
387
+ }
388
+ lines.push('', `Looked in: ${inventory.roots.map((root) => shortPath(root, cwd)).join(', ')}`);
389
+ if (inventory.invalid.length > 0) {
390
+ const label = inventory.invalid.length === 1 ? '1 entry' : `${inventory.invalid.length} entries`;
391
+ lines.push(`Skipped ${label}:`);
392
+ for (const bad of inventory.invalid.slice(0, 10)) {
393
+ lines.push(` ${bad.name}: ${bad.reason} (${shortPath(bad.file, cwd)})`);
394
+ }
395
+ if (inventory.invalid.length > 10) {
396
+ lines.push(` … and ${inventory.invalid.length - 10} more`);
397
+ }
398
+ }
399
+ if (inventory.skills.length === 0) {
400
+ lines.push('Add one at .kiro/skills/<name>/SKILL.md with name and description frontmatter.');
401
+ }
402
+ return lines.join('\n');
403
+ }
404
+ //# sourceMappingURL=skills.js.map
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { render } from 'ink';
4
4
  import { applyOverrides, configPath, ConfigError, loadConfig, recoverConfig, } from './config.js';
5
+ import { setSkillsEnabled } from './agent/skills.js';
5
6
  import { loadEnvFile } from './env.js';
6
7
  import { runModelCli } from './model/cli.js';
7
8
  import { readLine } from './model/cli-ui.js';
@@ -32,6 +33,8 @@ Options:
32
33
  transcript, Shift+drag selects text for copying.
33
34
  --no-mouse Disable mouse reporting so plain click-drag selection works.
34
35
  --no-alt-screen Do not switch to the terminal's alternate screen
36
+ --no-skills Do not load skills from .kiro/skills, .claude/skills, or
37
+ ~/.kiro/skills (KIRO_NO_SKILLS=1 does the same)
35
38
  -h, --help Show this help
36
39
  -v, --version Show the version
37
40
 
@@ -86,6 +89,7 @@ function parseArgs(argv) {
86
89
  yolo: false,
87
90
  mouse: true,
88
91
  altScreen: true,
92
+ skills: true,
89
93
  help: false,
90
94
  version: false,
91
95
  };
@@ -119,6 +123,10 @@ function parseArgs(argv) {
119
123
  options.altScreen = false;
120
124
  continue;
121
125
  }
126
+ if (arg === '--no-skills') {
127
+ options.skills = false;
128
+ continue;
129
+ }
122
130
  const equals = arg.indexOf('=');
123
131
  const flag = equals === -1 ? arg : arg.slice(0, equals);
124
132
  if (flag === '--profile' ||
@@ -234,6 +242,7 @@ async function main() {
234
242
  }
235
243
  }
236
244
  await loadEnvFile();
245
+ setSkillsEnabled(options.skills && process.env.KIRO_NO_SKILLS !== '1');
237
246
  const { loaded, backup } = await loadConfigWithRecovery();
238
247
  const overrides = {
239
248
  profile: options.profile,
@@ -3,9 +3,10 @@ import { fsTools } from './fs.js';
3
3
  import { patchTools } from './patch.js';
4
4
  import { searchTools } from './search.js';
5
5
  import { runCommandTool } from './shell.js';
6
+ import { skillTools } from './skill.js';
6
7
  import { toolError } from './types.js';
7
8
  export const MAX_TOOL_RESULT_CHARS = 60_000;
8
- export const tools = [...fsTools, ...searchTools, ...patchTools, runCommandTool];
9
+ export const tools = [...fsTools, ...searchTools, ...patchTools, runCommandTool, ...skillTools];
9
10
  export const toolDefinitions = tools.map((tool) => tool.definition);
10
11
  const byName = new Map(tools.map((tool) => [tool.definition.function.name, tool]));
11
12
  export function isReadOnlyTool(name) {
@@ -0,0 +1,44 @@
1
+ import { findSkill, loadSkills, MAX_SKILL_BODY_CHARS } from '../agent/skills.js';
2
+ import { stringArg } from './paths.js';
3
+ import { ok, toolError } from './types.js';
4
+ const readSkillTool = {
5
+ readOnly: true,
6
+ definition: {
7
+ type: 'function',
8
+ function: {
9
+ name: 'read_skill',
10
+ description: 'Load the full instructions of an installed skill by name. Use it when a request matches a skill listed in the system prompt, then follow the returned instructions.',
11
+ parameters: {
12
+ type: 'object',
13
+ properties: {
14
+ name: { type: 'string', description: 'Exact skill name, e.g. "anti-slop".' },
15
+ },
16
+ required: ['name'],
17
+ additionalProperties: false,
18
+ },
19
+ },
20
+ },
21
+ async run(input, ctx) {
22
+ const name = stringArg(input, 'name');
23
+ const inventory = await loadSkills(ctx.cwd);
24
+ if (inventory.disabled) {
25
+ return toolError('Skills are disabled for this run (--no-skills), so nothing can be loaded.');
26
+ }
27
+ if (inventory.skills.length === 0) {
28
+ return toolError('No skills are installed. Add one at .kiro/skills/<name>/SKILL.md or ~/.kiro/skills/<name>/SKILL.md.');
29
+ }
30
+ const skill = findSkill(inventory.skills, name);
31
+ if (!skill) {
32
+ return toolError(`Unknown skill "${name}". Available skills: ${inventory.skills.map((entry) => entry.name).join(', ')}.`);
33
+ }
34
+ const clipped = skill.body.length > MAX_SKILL_BODY_CHARS
35
+ ? `${skill.body.slice(0, MAX_SKILL_BODY_CHARS)}\n\n… [skill truncated after ` +
36
+ `${MAX_SKILL_BODY_CHARS.toLocaleString()} characters; read the rest with read_file on ${skill.file}]`
37
+ : skill.body;
38
+ return ok(`# Skill: ${skill.name}\n\n${clipped}\n\n` +
39
+ `[${skill.source} skill · directory: ${skill.dir}. ` +
40
+ 'Read supporting files with read_file or run bundled scripts with run_command.]', `read_skill ${skill.name}`);
41
+ },
42
+ };
43
+ export const skillTools = [readSkillTool];
44
+ //# sourceMappingURL=skill.js.map
package/dist/ui/App.js CHANGED
@@ -4,6 +4,7 @@ import { Box, useApp, useInput, useStdout } from 'ink';
4
4
  import { mkdir, writeFile } from 'node:fs/promises';
5
5
  import path from 'node:path';
6
6
  import { buildSystemPrompt } from '../agent/prompt.js';
7
+ import { findSkill, formatSkillList, loadSkills, shortPath, skillInvocationMessage, } from '../agent/skills.js';
7
8
  import { runAgentTurn } from '../agent/loop.js';
8
9
  import { COMPACT_KEEP_USER_TURNS, COMPACT_THRESHOLD, compactMessages, shouldCompact, } from '../agent/compact.js';
9
10
  import { estimateMessagesTokens, formatPercent, formatTokens } from '../agent/tokens.js';
@@ -121,6 +122,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
121
122
  const busyRef = useRef(false);
122
123
  const abortRef = useRef(null);
123
124
  const cancelRequestedRef = useRef(false);
125
+ const projectSkillNotedRef = useRef(false);
124
126
  const quitArmedRef = useRef(false);
125
127
  const quitTimerRef = useRef(null);
126
128
  const [approvalPolicy] = useState(() => new ApprovalPolicy(yolo));
@@ -470,12 +472,31 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
470
472
  approvalPolicy.clear();
471
473
  setAutoAllowed([]);
472
474
  }, [approvalPolicy]);
473
- const sendTurn = useCallback(async (rawInput, alreadyDisplayed = false) => {
475
+ /** Mentions once per run when the model pulls instructions that came from the repo. */
476
+ const noteProjectSkill = useCallback(async (rawArguments) => {
477
+ let name;
478
+ try {
479
+ name = JSON.parse(rawArguments || '{}').name;
480
+ }
481
+ catch {
482
+ return;
483
+ }
484
+ if (typeof name !== 'string')
485
+ return;
486
+ const inventory = await loadSkills(cwd);
487
+ const skill = findSkill(inventory.skills, name);
488
+ if (skill?.source !== 'project')
489
+ return;
490
+ addNotice('muted', `"${skill.name}" was loaded from this repository (${shortPath(skill.dir, cwd)}), not your ` +
491
+ '~/.kiro settings. Its text steers the model; tool approvals still apply.');
492
+ }, [addNotice, cwd]);
493
+ const sendTurn = useCallback(async (rawInput, alreadyDisplayed = false, displayText) => {
474
494
  if (busyRef.current || transitioningRef.current)
475
495
  return;
476
496
  const text = rawInput.trim();
477
497
  if (!text)
478
498
  return;
499
+ const shown = displayText ?? text;
479
500
  busyRef.current = true;
480
501
  cancelRequestedRef.current = false;
481
502
  setBusy(true);
@@ -489,11 +510,11 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
489
510
  if (!alreadyDisplayed) {
490
511
  setItems((current) => [
491
512
  ...current,
492
- { kind: 'user', id: nextItemIdRef.current++, text },
513
+ { kind: 'user', id: nextItemIdRef.current++, text: shown },
493
514
  ]);
494
515
  }
495
516
  messagesRef.current.push({ role: 'user', content: text });
496
- void recordPrompt(cwd, text).then(setPromptHistory);
517
+ void recordPrompt(cwd, shown).then(setPromptHistory);
497
518
  recomputeContext();
498
519
  void persistSession();
499
520
  const controller = new AbortController();
@@ -597,6 +618,12 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
597
618
  return next;
598
619
  });
599
620
  recomputeContext();
621
+ if (event.toolCall.function.name === 'read_skill' &&
622
+ event.result.status === 'ok' &&
623
+ !projectSkillNotedRef.current) {
624
+ projectSkillNotedRef.current = true;
625
+ void noteProjectSkill(event.toolCall.function.arguments);
626
+ }
600
627
  // The next model round starts once the tools for this one finish.
601
628
  roundStartedAtRef.current = Date.now();
602
629
  roundCompletionTokensRef.current = null;
@@ -666,6 +693,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
666
693
  cwd,
667
694
  finalizeAssistant,
668
695
  flushText,
696
+ noteProjectSkill,
669
697
  persistSession,
670
698
  profileName,
671
699
  queueText,
@@ -868,6 +896,39 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
868
896
  : 'Usage card hidden; the transcript gets the full width. Use /usage to show it again.');
869
897
  return;
870
898
  }
899
+ case '/skills': {
900
+ if (argument) {
901
+ addNotice('error', 'Usage: /skills');
902
+ return;
903
+ }
904
+ const inventory = await loadSkills(cwd);
905
+ addNotice(inventory.skills.length === 0 && inventory.invalid.length === 0 ? 'muted' : 'info', formatSkillList(inventory, cwd));
906
+ return;
907
+ }
908
+ case '/skill': {
909
+ if (!argument) {
910
+ addNotice('error', 'Usage: /skill <name> [request]. Run /skills to list installed skills.');
911
+ return;
912
+ }
913
+ const line = input.trim();
914
+ const request = line
915
+ .slice(command.length)
916
+ .trim()
917
+ .slice(argument.length)
918
+ .trim();
919
+ const inventory = await loadSkills(cwd);
920
+ const skill = findSkill(inventory.skills, argument);
921
+ if (!skill) {
922
+ addNotice('error', inventory.disabled
923
+ ? 'Skills are disabled for this run (--no-skills).'
924
+ : inventory.skills.length === 0
925
+ ? 'No skills installed. Add one at .kiro/skills/<name>/SKILL.md.'
926
+ : `Unknown skill "${argument}". Installed: ${inventory.skills.map((entry) => entry.name).join(', ')}.`);
927
+ return;
928
+ }
929
+ void sendTurn(skillInvocationMessage(skill, request), false, line);
930
+ return;
931
+ }
871
932
  case '/compact': {
872
933
  if (messagesRef.current.length === 0) {
873
934
  addNotice('muted', 'There is no conversation to compact yet.');
@@ -1137,6 +1198,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
1137
1198
  resetAutoAllowed,
1138
1199
  runModelFlow,
1139
1200
  runProfileTest,
1201
+ sendTurn,
1140
1202
  updateContextTokens,
1141
1203
  usageCardEnabled,
1142
1204
  version,
@@ -1,6 +1,8 @@
1
1
  export const SLASH_COMMANDS = [
2
2
  { name: '/help', description: 'show this help' },
3
3
  { name: '/model', usage: '[name | add | edit | remove | test | list]', description: 'list or switch models' },
4
+ { name: '/skills', description: 'list installed skills and where they were found' },
5
+ { name: '/skill', usage: '<name>', description: 'load a skill and apply it to your next request' },
4
6
  { name: '/context', description: 'show approximate context usage' },
5
7
  { name: '/usage', description: 'show or hide the usage card' },
6
8
  { name: '/compact', description: 'summarize older turns to free context' },
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.2.8';
1
+ export const VERSION = '0.2.10';
2
2
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywldan/kiro",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "A small terminal coding agent with your own OpenAI-compatible endpoint",
5
5
  "keywords": [
6
6
  "ai",