@ywldan/kiro 0.2.9 → 0.2.11
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 +12 -4
- package/dist/agent/skills.js +185 -72
- package/dist/index.js +9 -0
- package/dist/tools/skill.js +5 -1
- package/dist/ui/App.js +69 -15
- package/dist/ui/Input.js +2 -2
- package/dist/ui/commands.js +33 -5
- package/dist/version.js +1 -1
- package/package.json +1 -1
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
|
|
|
@@ -333,7 +334,8 @@ Slash commands:
|
|
|
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 |
|
|
335
336
|
| `/skills` | List installed skills, their source, and any skipped entries |
|
|
336
|
-
| `/skill <name
|
|
337
|
+
| `/skill <name> [request]` | Load a skill, optionally with your request in the same line |
|
|
338
|
+
| `/<skill name> [request]` | Call an installed skill directly, e.g. `/anti-slop rewrite this paragraph` |
|
|
337
339
|
| `/compact` | Summarize older turns now, keeping the last four user turns verbatim |
|
|
338
340
|
| `/sessions` | List saved sessions for this working directory |
|
|
339
341
|
| `/resume <n\|id>` | Resume a session by list number or id (prefixes work) |
|
|
@@ -442,9 +444,15 @@ description: Remove AI-slop patterns from prose before answering.
|
|
|
442
444
|
Delete "delve", "tapestry", and stacked em dashes. Prefer concrete nouns.
|
|
443
445
|
```
|
|
444
446
|
|
|
445
|
-
Only
|
|
447
|
+
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.
|
|
446
448
|
|
|
447
|
-
|
|
449
|
+
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.
|
|
450
|
+
|
|
451
|
+
`/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.
|
|
452
|
+
|
|
453
|
+
Every installed skill is also a slash command: `/anti-slop rewrite this paragraph` is the same turn as `/skill anti-slop rewrite this paragraph`. Skill names appear in the `/` menu (filtered as you type, `↑`/`↓` to choose, `Tab` to complete) labelled `skill · <description>`, and `/help` mentions the form rather than listing every skill. Built-in commands win a name clash, so a skill called `model` is reachable only as `/skill model` and `/skills` flags it. The command list refreshes after every turn, so a skill you add mid-session appears without a restart.
|
|
454
|
+
|
|
455
|
+
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.
|
|
448
456
|
|
|
449
457
|
## How it works
|
|
450
458
|
|
|
@@ -480,7 +488,7 @@ The suite covers streaming, multiple tool calls per response, approvals and deni
|
|
|
480
488
|
|
|
481
489
|
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.
|
|
482
490
|
|
|
483
|
-
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`,
|
|
491
|
+
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, skill names becoming slash commands with built-in clashes, `--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`.
|
|
484
492
|
|
|
485
493
|
## Project layout
|
|
486
494
|
|
package/dist/agent/skills.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import { readdir, readFile, stat } from 'node:fs/promises';
|
|
1
|
+
import { readdir, readFile, realpath, stat } from 'node:fs/promises';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
export const MAX_SKILLS_IN_PROMPT = 30;
|
|
5
5
|
export const MAX_SKILL_DESCRIPTION_CHARS = 300;
|
|
6
|
+
export const MAX_SKILL_SHORT_DESCRIPTION_CHARS = 60;
|
|
6
7
|
export const MAX_SKILL_BODY_CHARS = 50_000;
|
|
7
8
|
export const MAX_SKILL_FILE_BYTES = 200_000;
|
|
8
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;
|
|
9
12
|
const MAX_SKILL_NAME_CHARS = 64;
|
|
13
|
+
const MAX_SKILL_DIRS_PER_ROOT = 500;
|
|
10
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
|
+
}
|
|
11
24
|
/** `.claude/skills` is read too, so skills installed for other CLIs work unchanged. */
|
|
12
25
|
export function skillRoots(cwd) {
|
|
13
26
|
const roots = [
|
|
@@ -107,8 +120,24 @@ export function parseSkillFile(raw) {
|
|
|
107
120
|
value: { name: meta.get('name')?.trim() || undefined, description, body },
|
|
108
121
|
};
|
|
109
122
|
}
|
|
110
|
-
async function
|
|
111
|
-
|
|
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');
|
|
112
141
|
let info;
|
|
113
142
|
try {
|
|
114
143
|
info = await stat(file);
|
|
@@ -117,14 +146,14 @@ async function readSkillDir(root, source, entry) {
|
|
|
117
146
|
const code = error.code;
|
|
118
147
|
if (code === 'ENOENT' || code === 'ENOTDIR')
|
|
119
148
|
return {};
|
|
120
|
-
return { invalid: { name:
|
|
149
|
+
return { invalid: { name: folder, file, reason: error.message } };
|
|
121
150
|
}
|
|
122
151
|
if (!info.isFile())
|
|
123
152
|
return {};
|
|
124
153
|
if (info.size > MAX_SKILL_FILE_BYTES) {
|
|
125
154
|
return {
|
|
126
155
|
invalid: {
|
|
127
|
-
name:
|
|
156
|
+
name: folder,
|
|
128
157
|
file,
|
|
129
158
|
reason: `SKILL.md is larger than ${MAX_SKILL_FILE_BYTES.toLocaleString()} bytes`,
|
|
130
159
|
},
|
|
@@ -135,12 +164,12 @@ async function readSkillDir(root, source, entry) {
|
|
|
135
164
|
raw = await readFile(file, 'utf8');
|
|
136
165
|
}
|
|
137
166
|
catch (error) {
|
|
138
|
-
return { invalid: { name:
|
|
167
|
+
return { invalid: { name: folder, file, reason: error.message } };
|
|
139
168
|
}
|
|
140
169
|
const parsed = parseSkillFile(raw);
|
|
141
170
|
if (!parsed.ok)
|
|
142
|
-
return { invalid: { name:
|
|
143
|
-
const name = parsed.value.name ??
|
|
171
|
+
return { invalid: { name: folder, file, reason: parsed.reason } };
|
|
172
|
+
const name = parsed.value.name ?? folder;
|
|
144
173
|
if (name.length > MAX_SKILL_NAME_CHARS || !SKILL_NAME_PATTERN.test(name)) {
|
|
145
174
|
return {
|
|
146
175
|
invalid: {
|
|
@@ -155,64 +184,126 @@ async function readSkillDir(root, source, entry) {
|
|
|
155
184
|
name,
|
|
156
185
|
description: parsed.value.description,
|
|
157
186
|
body: parsed.value.body,
|
|
158
|
-
dir
|
|
187
|
+
dir,
|
|
159
188
|
file,
|
|
160
189
|
},
|
|
161
190
|
};
|
|
162
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
|
+
}
|
|
163
286
|
/** Project roots win over user roots; the first definition of a name is kept. */
|
|
164
287
|
export async function loadSkills(cwd) {
|
|
165
288
|
const roots = skillRoots(cwd);
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (code !== 'ENOENT' && code !== 'ENOTDIR') {
|
|
177
|
-
invalid.push({
|
|
178
|
-
name: path.basename(root),
|
|
179
|
-
file: root,
|
|
180
|
-
source,
|
|
181
|
-
reason: `cannot read the directory: ${error.message}`,
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
const names = entries
|
|
187
|
-
.filter((entry) => entry.isDirectory() && !entry.name.startsWith('.'))
|
|
188
|
-
.map((entry) => entry.name)
|
|
189
|
-
.sort((a, b) => a.localeCompare(b, 'en'));
|
|
190
|
-
for (const entryName of names) {
|
|
191
|
-
const result = await readSkillDir(root, source, entryName);
|
|
192
|
-
if (result.invalid) {
|
|
193
|
-
invalid.push({ ...result.invalid, source });
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
const skill = result.skill;
|
|
197
|
-
if (!skill)
|
|
198
|
-
continue;
|
|
199
|
-
const existing = byName.get(skill.name.toLowerCase());
|
|
200
|
-
if (existing) {
|
|
201
|
-
invalid.push({
|
|
202
|
-
name: skill.name,
|
|
203
|
-
file: skill.file,
|
|
204
|
-
source,
|
|
205
|
-
reason: `duplicate name; ${existing.file} already defines it`,
|
|
206
|
-
});
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
const complete = { ...skill, source };
|
|
210
|
-
skills.push(complete);
|
|
211
|
-
byName.set(skill.name.toLowerCase(), complete);
|
|
212
|
-
}
|
|
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);
|
|
213
299
|
}
|
|
214
|
-
skills.sort((a, b) => a.name.localeCompare(b.name, 'en'));
|
|
215
|
-
return {
|
|
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
|
+
};
|
|
216
307
|
}
|
|
217
308
|
export function findSkill(skills, name) {
|
|
218
309
|
const needle = name.trim().toLowerCase();
|
|
@@ -238,26 +329,46 @@ function clipDescription(description, max) {
|
|
|
238
329
|
export function formatSkillIndex(skills) {
|
|
239
330
|
if (skills.length === 0)
|
|
240
331
|
return '';
|
|
241
|
-
const
|
|
332
|
+
const header = [
|
|
242
333
|
'# Skills',
|
|
243
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.',
|
|
244
335
|
];
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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)
|
|
250
347
|
break;
|
|
251
|
-
lines.push(line);
|
|
252
348
|
used += line.length + 1;
|
|
253
|
-
|
|
349
|
+
kept.push(line);
|
|
254
350
|
}
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
return
|
|
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');
|
|
259
355
|
}
|
|
260
|
-
|
|
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, reserved = []) {
|
|
368
|
+
if (inventory.disabled) {
|
|
369
|
+
return 'Skills are disabled for this run (--no-skills or KIRO_NO_SKILLS).';
|
|
370
|
+
}
|
|
371
|
+
const taken = new Set(reserved);
|
|
261
372
|
const lines = [];
|
|
262
373
|
if (inventory.skills.length === 0) {
|
|
263
374
|
lines.push('No skills installed.');
|
|
@@ -271,8 +382,10 @@ export function formatSkillList(inventory, cwd) {
|
|
|
271
382
|
lines.push(`Installed skills (${counts}):`);
|
|
272
383
|
const width = Math.min(28, Math.max(...inventory.skills.map((skill) => skill.name.length)));
|
|
273
384
|
for (const skill of inventory.skills) {
|
|
385
|
+
const shadowed = taken.has(skill.name.toLowerCase());
|
|
274
386
|
lines.push(` ${skill.name.padEnd(width)} ${clipDescription(skill.description, 80)} ` +
|
|
275
|
-
`[${skill.source}] (${shortPath(skill.dir, cwd)})`
|
|
387
|
+
`[${skill.source}] (${shortPath(skill.dir, cwd)})` +
|
|
388
|
+
(shadowed ? ` · /${skill.name} is a built-in, use /skill ${skill.name}` : ''));
|
|
276
389
|
}
|
|
277
390
|
}
|
|
278
391
|
lines.push('', `Looked in: ${inventory.roots.map((root) => shortPath(root, cwd)).join(', ')}`);
|
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,
|
package/dist/tools/skill.js
CHANGED
|
@@ -21,6 +21,9 @@ const readSkillTool = {
|
|
|
21
21
|
async run(input, ctx) {
|
|
22
22
|
const name = stringArg(input, 'name');
|
|
23
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
|
+
}
|
|
24
27
|
if (inventory.skills.length === 0) {
|
|
25
28
|
return toolError('No skills are installed. Add one at .kiro/skills/<name>/SKILL.md or ~/.kiro/skills/<name>/SKILL.md.');
|
|
26
29
|
}
|
|
@@ -33,7 +36,8 @@ const readSkillTool = {
|
|
|
33
36
|
`${MAX_SKILL_BODY_CHARS.toLocaleString()} characters; read the rest with read_file on ${skill.file}]`
|
|
34
37
|
: skill.body;
|
|
35
38
|
return ok(`# Skill: ${skill.name}\n\n${clipped}\n\n` +
|
|
36
|
-
`[
|
|
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}`);
|
|
37
41
|
},
|
|
38
42
|
};
|
|
39
43
|
export const skillTools = [readSkillTool];
|
package/dist/ui/App.js
CHANGED
|
@@ -4,7 +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,
|
|
7
|
+
import { findSkill, formatSkillList, loadSkills, shortPath, skillInvocationMessage, } from '../agent/skills.js';
|
|
8
8
|
import { runAgentTurn } from '../agent/loop.js';
|
|
9
9
|
import { COMPACT_KEEP_USER_TURNS, COMPACT_THRESHOLD, compactMessages, shouldCompact, } from '../agent/compact.js';
|
|
10
10
|
import { estimateMessagesTokens, formatPercent, formatTokens } from '../agent/tokens.js';
|
|
@@ -15,7 +15,7 @@ import { createProvider } from '../providers/index.js';
|
|
|
15
15
|
import { dropIncompleteToolCalls, formatSessionTime, isSessionId, listSessions, loadSession, newSessionId, projectSessionsDir, saveSession, titleFromMessages, } from '../sessions.js';
|
|
16
16
|
import { ApprovalPrompt } from './ApprovalPrompt.js';
|
|
17
17
|
import { ApprovalPolicy } from './approval-policy.js';
|
|
18
|
-
import { slashHelpLines } from './commands.js';
|
|
18
|
+
import { builtinCommandNames, buildSkillCommands, SLASH_COMMANDS, slashHelpLines, } from './commands.js';
|
|
19
19
|
import { defaultExportPath, renderTranscriptMarkdown } from './export.js';
|
|
20
20
|
import { buildResumedView } from './history.js';
|
|
21
21
|
import { Input } from './Input.js';
|
|
@@ -122,6 +122,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
122
122
|
const busyRef = useRef(false);
|
|
123
123
|
const abortRef = useRef(null);
|
|
124
124
|
const cancelRequestedRef = useRef(false);
|
|
125
|
+
const projectSkillNotedRef = useRef(false);
|
|
125
126
|
const quitArmedRef = useRef(false);
|
|
126
127
|
const quitTimerRef = useRef(null);
|
|
127
128
|
const [approvalPolicy] = useState(() => new ApprovalPolicy(yolo));
|
|
@@ -471,6 +472,32 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
471
472
|
approvalPolicy.clear();
|
|
472
473
|
setAutoAllowed([]);
|
|
473
474
|
}, [approvalPolicy]);
|
|
475
|
+
const [skillCommands, setSkillCommands] = useState([]);
|
|
476
|
+
const refreshSkillCommands = useCallback(async () => {
|
|
477
|
+
const inventory = await loadSkills(cwd);
|
|
478
|
+
setSkillCommands(buildSkillCommands(inventory.skills));
|
|
479
|
+
}, [cwd]);
|
|
480
|
+
useEffect(() => {
|
|
481
|
+
void refreshSkillCommands();
|
|
482
|
+
}, [refreshSkillCommands]);
|
|
483
|
+
/** Mentions once per run when the model pulls instructions that came from the repo. */
|
|
484
|
+
const noteProjectSkill = useCallback(async (rawArguments) => {
|
|
485
|
+
let name;
|
|
486
|
+
try {
|
|
487
|
+
name = JSON.parse(rawArguments || '{}').name;
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (typeof name !== 'string')
|
|
493
|
+
return;
|
|
494
|
+
const inventory = await loadSkills(cwd);
|
|
495
|
+
const skill = findSkill(inventory.skills, name);
|
|
496
|
+
if (skill?.source !== 'project')
|
|
497
|
+
return;
|
|
498
|
+
addNotice('muted', `"${skill.name}" was loaded from this repository (${shortPath(skill.dir, cwd)}), not your ` +
|
|
499
|
+
'~/.kiro settings. Its text steers the model; tool approvals still apply.');
|
|
500
|
+
}, [addNotice, cwd]);
|
|
474
501
|
const sendTurn = useCallback(async (rawInput, alreadyDisplayed = false, displayText) => {
|
|
475
502
|
if (busyRef.current || transitioningRef.current)
|
|
476
503
|
return;
|
|
@@ -599,6 +626,12 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
599
626
|
return next;
|
|
600
627
|
});
|
|
601
628
|
recomputeContext();
|
|
629
|
+
if (event.toolCall.function.name === 'read_skill' &&
|
|
630
|
+
event.result.status === 'ok' &&
|
|
631
|
+
!projectSkillNotedRef.current) {
|
|
632
|
+
projectSkillNotedRef.current = true;
|
|
633
|
+
void noteProjectSkill(event.toolCall.function.arguments);
|
|
634
|
+
}
|
|
602
635
|
// The next model round starts once the tools for this one finish.
|
|
603
636
|
roundStartedAtRef.current = Date.now();
|
|
604
637
|
roundCompletionTokensRef.current = null;
|
|
@@ -651,6 +684,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
651
684
|
resolveApproval('deny');
|
|
652
685
|
recomputeContext();
|
|
653
686
|
void persistSession();
|
|
687
|
+
void refreshSkillCommands();
|
|
654
688
|
if (!quittingRef.current) {
|
|
655
689
|
if (cancelRequestedRef.current && queuedRef.current.length > 0) {
|
|
656
690
|
queuedRef.current = [];
|
|
@@ -668,7 +702,9 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
668
702
|
cwd,
|
|
669
703
|
finalizeAssistant,
|
|
670
704
|
flushText,
|
|
705
|
+
noteProjectSkill,
|
|
671
706
|
persistSession,
|
|
707
|
+
refreshSkillCommands,
|
|
672
708
|
profileName,
|
|
673
709
|
queueText,
|
|
674
710
|
recomputeContext,
|
|
@@ -761,11 +797,13 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
761
797
|
return;
|
|
762
798
|
const [command, ...rest] = input.trim().split(/\s+/);
|
|
763
799
|
const argument = rest[0];
|
|
800
|
+
if (!command)
|
|
801
|
+
return;
|
|
764
802
|
switch (command) {
|
|
765
803
|
case '/help': {
|
|
766
804
|
addNotice('info', [
|
|
767
805
|
'Commands (type / to open the menu, ↑↓ to choose, Enter to run):',
|
|
768
|
-
...slashHelpLines(),
|
|
806
|
+
...slashHelpLines(skillCommands.length),
|
|
769
807
|
'',
|
|
770
808
|
' Model subcommands: /model <name> · /model add · /model edit [name] ·',
|
|
771
809
|
' /model remove [name] · /model test [name] · /model list --remote',
|
|
@@ -876,26 +914,31 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
876
914
|
return;
|
|
877
915
|
}
|
|
878
916
|
const inventory = await loadSkills(cwd);
|
|
879
|
-
addNotice(inventory.skills.length === 0 && inventory.invalid.length === 0 ? 'muted' : 'info', formatSkillList(inventory, cwd));
|
|
917
|
+
addNotice(inventory.skills.length === 0 && inventory.invalid.length === 0 ? 'muted' : 'info', formatSkillList(inventory, cwd, builtinCommandNames()));
|
|
880
918
|
return;
|
|
881
919
|
}
|
|
882
920
|
case '/skill': {
|
|
883
|
-
if (!argument
|
|
884
|
-
addNotice('error', 'Usage: /skill <name
|
|
921
|
+
if (!argument) {
|
|
922
|
+
addNotice('error', 'Usage: /skill <name> [request]. Run /skills to list installed skills.');
|
|
885
923
|
return;
|
|
886
924
|
}
|
|
925
|
+
const line = input.trim();
|
|
926
|
+
const request = line
|
|
927
|
+
.slice(command.length)
|
|
928
|
+
.trim()
|
|
929
|
+
.slice(argument.length)
|
|
930
|
+
.trim();
|
|
887
931
|
const inventory = await loadSkills(cwd);
|
|
888
932
|
const skill = findSkill(inventory.skills, argument);
|
|
889
933
|
if (!skill) {
|
|
890
|
-
addNotice('error', inventory.
|
|
891
|
-
? '
|
|
892
|
-
:
|
|
934
|
+
addNotice('error', inventory.disabled
|
|
935
|
+
? 'Skills are disabled for this run (--no-skills).'
|
|
936
|
+
: inventory.skills.length === 0
|
|
937
|
+
? 'No skills installed. Add one at .kiro/skills/<name>/SKILL.md.'
|
|
938
|
+
: `Unknown skill "${argument}". Installed: ${inventory.skills.map((entry) => entry.name).join(', ')}.`);
|
|
893
939
|
return;
|
|
894
940
|
}
|
|
895
|
-
|
|
896
|
-
? `${skill.body.slice(0, MAX_SKILL_BODY_CHARS)}\n\n[Skill truncated; the rest is in ${skill.file}]`
|
|
897
|
-
: skill.body;
|
|
898
|
-
void sendTurn(`Use the "${skill.name}" skill. Its instructions follow; apply them to what I ask next.\n\n${body}`, false, `/skill ${skill.name}`);
|
|
941
|
+
void sendTurn(skillInvocationMessage(skill, request), false, line);
|
|
899
942
|
return;
|
|
900
943
|
}
|
|
901
944
|
case '/compact': {
|
|
@@ -1151,8 +1194,19 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1151
1194
|
case '/exit':
|
|
1152
1195
|
quit();
|
|
1153
1196
|
return;
|
|
1154
|
-
default:
|
|
1197
|
+
default: {
|
|
1198
|
+
const skillName = command.startsWith('/') ? command.slice(1) : '';
|
|
1199
|
+
if (skillName) {
|
|
1200
|
+
const inventory = await loadSkills(cwd);
|
|
1201
|
+
const skill = findSkill(inventory.skills, skillName);
|
|
1202
|
+
if (skill) {
|
|
1203
|
+
const line = input.trim();
|
|
1204
|
+
void sendTurn(skillInvocationMessage(skill, line.slice(command.length).trim()), false, line);
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1155
1208
|
addNotice('error', `Unknown command "${command}". Type /help for commands.`);
|
|
1209
|
+
}
|
|
1156
1210
|
}
|
|
1157
1211
|
}, [
|
|
1158
1212
|
addNotice,
|
|
@@ -1319,7 +1373,7 @@ export function App({ config, baseConfig, overrides, configPath, configCreated,
|
|
|
1319
1373
|
const viewportHeight = Math.max(3, rows - 5 - (pendingApproval ? 12 : 0) - (pickerInline ? PICKER_INLINE_ROWS : 0));
|
|
1320
1374
|
const showUsageCard = usageCardEnabled && shouldShowUsageCard(columns, viewportHeight);
|
|
1321
1375
|
const chatWidth = showUsageCard ? Math.max(40, width - USAGE_CARD_WIDTH - USAGE_CARD_GAP) : width;
|
|
1322
|
-
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", alignItems: "flex-end", width: width, children: [_jsx(MessageList, { items: items, width: chatWidth, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, palette: palette, interactive: !pendingApproval && !pickerOpen && !wizardActive && wizardPrompt === null }), showUsageCard ? (_jsx(Box, { marginLeft: USAGE_CARD_GAP, flexShrink: 0, children: _jsx(UsageCard, { usage: sessionUsage, contextTokens: contextTokens, contextWindow: contextWindow, contextEstimated: usageRef.current === null, lastReply: lastReply, busy: busy }) })) : null] }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) : pickerInline ? (_jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: width, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) })) : (_jsx(Input, { disabled: pickerOpen, width: width, mask: wizardPrompt?.mask, allowEmpty: wizardPrompt?.allowEmpty, history: wizardPrompt || wizardActive ? undefined : promptHistory, onPaletteChange: setPalette, placeholder: pickerOpen
|
|
1376
|
+
return (_jsxs(Box, { flexDirection: "column", width: columns, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", alignItems: "flex-end", width: width, children: [_jsx(MessageList, { items: items, width: chatWidth, height: viewportHeight, resetSignal: resetSignal, expandedToolId: expandedToolId, palette: palette, interactive: !pendingApproval && !pickerOpen && !wizardActive && wizardPrompt === null }), showUsageCard ? (_jsx(Box, { marginLeft: USAGE_CARD_GAP, flexShrink: 0, children: _jsx(UsageCard, { usage: sessionUsage, contextTokens: contextTokens, contextWindow: contextWindow, contextEstimated: usageRef.current === null, lastReply: lastReply, busy: busy }) })) : null] }), pendingApproval ? (_jsx(ApprovalPrompt, { request: pendingApproval, width: width, onDecision: resolveApproval })) : pickerInline ? (_jsx(ModelPicker, { config: runtimeConfig, activeProfile: profileName, width: width, onSelect: (name, model) => void selectModel(name, model), onRefresh: refreshProfileModels, onCancel: () => setPickerOpen(false) })) : (_jsx(Input, { disabled: pickerOpen, width: width, mask: wizardPrompt?.mask, allowEmpty: wizardPrompt?.allowEmpty, history: wizardPrompt || wizardActive ? undefined : promptHistory, slashCommands: [...SLASH_COMMANDS, ...skillCommands], onPaletteChange: setPalette, placeholder: pickerOpen
|
|
1323
1377
|
? 'Model picker open · Esc to close'
|
|
1324
1378
|
: wizardPrompt
|
|
1325
1379
|
? wizardPrompt.defaultValue && !wizardPrompt.mask
|
package/dist/ui/Input.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isMouseSequence } from './mouse.js';
|
|
|
7
7
|
import { applyInputOps, parseEditSequence, parseInputChunk, } from './text.js';
|
|
8
8
|
const MAX_INPUT_CHARS = 20_000;
|
|
9
9
|
const MAX_MENU_ROWS = 6;
|
|
10
|
-
export function Input({ disabled, placeholder, width, mask = false, allowEmpty = false, slashMenu = true, history, onSubmit, onCancel, onPaletteChange, }) {
|
|
10
|
+
export function Input({ disabled, placeholder, width, mask = false, allowEmpty = false, slashMenu = true, slashCommands, history, onSubmit, onCancel, onPaletteChange, }) {
|
|
11
11
|
const { stdin } = useStdin();
|
|
12
12
|
const [state, setState] = useState({ chars: [], cursor: 0 });
|
|
13
13
|
const [selected, setSelected] = useState(0);
|
|
@@ -22,7 +22,7 @@ export function Input({ disabled, placeholder, width, mask = false, allowEmpty =
|
|
|
22
22
|
setHistoryIndex(null);
|
|
23
23
|
}
|
|
24
24
|
}, [historyIndex, recalled, text]);
|
|
25
|
-
const matches = slashMenu && !mask && !disabled ? filterSlashCommands(text) : [];
|
|
25
|
+
const matches = slashMenu && !mask && !disabled ? filterSlashCommands(text, slashCommands) : [];
|
|
26
26
|
const menuOpen = matches.length > 0;
|
|
27
27
|
const activeIndex = Math.min(selected, Math.max(0, matches.length - 1));
|
|
28
28
|
const menuStart = Math.max(0, Math.min(activeIndex - Math.floor(MAX_MENU_ROWS / 2), matches.length - MAX_MENU_ROWS));
|
package/dist/ui/commands.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
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' },
|
|
5
|
+
{ name: '/skill', usage: '<name> [request]', description: 'load a skill and apply it to your next request' },
|
|
6
6
|
{ name: '/context', description: 'show approximate context usage' },
|
|
7
7
|
{ name: '/usage', description: 'show or hide the usage card' },
|
|
8
8
|
{ name: '/compact', description: 'summarize older turns to free context' },
|
|
@@ -15,20 +15,48 @@ export const SLASH_COMMANDS = [
|
|
|
15
15
|
{ name: '/allow', usage: '[clear]', description: 'manage tools that skip approval' },
|
|
16
16
|
{ name: '/exit', description: 'quit Kiro' },
|
|
17
17
|
];
|
|
18
|
+
/** A skill called `/model` would be unreachable, so built-in names are claimed. */
|
|
19
|
+
export function builtinCommandNames() {
|
|
20
|
+
return SLASH_COMMANDS.map((command) => command.name.slice(1).toLowerCase());
|
|
21
|
+
}
|
|
22
|
+
function shorten(text, max) {
|
|
23
|
+
return text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
24
|
+
}
|
|
25
|
+
/** Skills become slash commands: `/anti-slop rewrite this`. Built-ins win a clash. */
|
|
26
|
+
export function buildSkillCommands(skills, reserved = builtinCommandNames()) {
|
|
27
|
+
const taken = new Set(reserved);
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
const commands = [];
|
|
30
|
+
for (const skill of skills) {
|
|
31
|
+
const key = skill.name.toLowerCase();
|
|
32
|
+
if (taken.has(key) || seen.has(key))
|
|
33
|
+
continue;
|
|
34
|
+
seen.add(key);
|
|
35
|
+
commands.push({ name: `/${skill.name}`, description: `skill · ${shorten(skill.description, 60)}` });
|
|
36
|
+
}
|
|
37
|
+
return commands;
|
|
38
|
+
}
|
|
18
39
|
/** Matches only while the user is still typing the command name, before any space. */
|
|
19
|
-
export function filterSlashCommands(query) {
|
|
40
|
+
export function filterSlashCommands(query, commands = SLASH_COMMANDS) {
|
|
20
41
|
const text = query.trimStart();
|
|
21
42
|
if (!text.startsWith('/') || /\s/.test(text))
|
|
22
43
|
return [];
|
|
23
44
|
const needle = text.toLowerCase();
|
|
24
|
-
return
|
|
45
|
+
return commands.filter((command) => command.name.toLowerCase().startsWith(needle));
|
|
25
46
|
}
|
|
26
47
|
export function slashCommandLabel(command) {
|
|
27
48
|
return command.usage ? `${command.name} ${command.usage}` : command.name;
|
|
28
49
|
}
|
|
29
|
-
export function slashHelpLines() {
|
|
50
|
+
export function slashHelpLines(skillCount = 0) {
|
|
30
51
|
const labels = SLASH_COMMANDS.map((command) => ` ${slashCommandLabel(command)}`);
|
|
52
|
+
if (skillCount > 0) {
|
|
53
|
+
labels.push(` /<skill> [request]`);
|
|
54
|
+
}
|
|
31
55
|
const width = Math.max(...labels.map((label) => label.length)) + 2;
|
|
32
|
-
|
|
56
|
+
const lines = SLASH_COMMANDS.map((command, index) => `${labels[index].padEnd(width)}${command.description}`);
|
|
57
|
+
if (skillCount > 0) {
|
|
58
|
+
lines.push(`${labels[labels.length - 1].padEnd(width)}run one of your ${skillCount} installed skill${skillCount === 1 ? '' : 's'}`);
|
|
59
|
+
}
|
|
60
|
+
return lines;
|
|
33
61
|
}
|
|
34
62
|
//# sourceMappingURL=commands.js.map
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.11';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|