@groeponline/pi-wishcraft 0.26.0 → 0.27.1
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/AGENTS.md +2 -0
- package/CHANGELOG.md +10 -0
- package/ROADMAP.md +40 -39
- package/docs/commands.md +3 -3
- package/package.json +1 -1
- package/queue/store.ts +39 -1
- package/queue/types.ts +11 -0
- package/src/extension/commands/queue-commands.ts +9 -2
- package/src/extension/queue/idea-review.ts +330 -0
- package/src/extension/queue/queue-integration.ts +4 -5
- package/src/extension/settings/wishcraft-config.ts +54 -55
- package/src/extension/skills/inline-invocation.ts +9 -9
- package/src/extension/skills/skill-manager.ts +49 -53
- package/src/extension/skills/skill-registry.ts +47 -28
- package/src/extension/ui/overlay-chrome.ts +1 -1
- package/src/extension/welcome/welcome-integration.ts +9 -0
- package/src/welcome/banner.ts +2 -0
- package/src/welcome/overlay.ts +2 -0
- package/src/welcome/types.ts +1 -0
- package/src/welcome/widgets/queue-widget.ts +13 -3
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* wishcraft-config.ts
|
|
3
3
|
* ---------------------------------------------------------------------------
|
|
4
|
-
* `/wishcraft` —
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* rendert en bewerkt ze generiek.
|
|
4
|
+
* `/wishcraft` — one configuration TUI for every wishcraft setting:
|
|
5
|
+
* grouped, directly editable (toggle, choice, text, number), written live
|
|
6
|
+
* to settings and visible immediately. Data-driven: settings are declared
|
|
7
|
+
* as ConfigItem[]; the overlay renders and edits them generically.
|
|
9
8
|
* ---------------------------------------------------------------------------
|
|
10
9
|
*/
|
|
11
10
|
|
|
@@ -24,17 +23,17 @@ import { parsePowerlineConfig } from "../../config/powerline-config.ts";
|
|
|
24
23
|
export type ConfigValue = boolean | string | number | null;
|
|
25
24
|
|
|
26
25
|
export interface ConfigItem {
|
|
27
|
-
/** Label in
|
|
26
|
+
/** Label in the list. */
|
|
28
27
|
label: string;
|
|
29
|
-
/**
|
|
28
|
+
/** Path inside settings ("powerline.placement", "wishcraft.hooksEnabled", ...). */
|
|
30
29
|
path: string;
|
|
31
|
-
/**
|
|
30
|
+
/** Edit kind. */
|
|
32
31
|
kind: "toggle" | "select" | "text" | "number";
|
|
33
|
-
/**
|
|
32
|
+
/** For select: the choices. */
|
|
34
33
|
choices?: string[];
|
|
35
|
-
/**
|
|
34
|
+
/** Hint under the group. */
|
|
36
35
|
hint?: string;
|
|
37
|
-
/**
|
|
36
|
+
/** Detail explanation (optional). */
|
|
38
37
|
description?: string;
|
|
39
38
|
}
|
|
40
39
|
|
|
@@ -43,7 +42,7 @@ export interface ConfigGroup {
|
|
|
43
42
|
items: ConfigItem[];
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
/**
|
|
45
|
+
/** Nested read: "wishcraft.hooksEnabled" → settings.wishcraft.hooksEnabled. */
|
|
47
46
|
export function readConfigPath(settings: Record<string, unknown>, path: string): ConfigValue {
|
|
48
47
|
let cur: unknown = settings;
|
|
49
48
|
for (const part of path.split(".")) {
|
|
@@ -130,61 +129,61 @@ const SEPARATORS = [
|
|
|
130
129
|
"star",
|
|
131
130
|
];
|
|
132
131
|
|
|
133
|
-
/**
|
|
132
|
+
/** Build groups from current settings (values shown live). */
|
|
134
133
|
export function buildConfigGroups(settings: Record<string, unknown>): ConfigGroup[] {
|
|
135
134
|
return [
|
|
136
135
|
{
|
|
137
|
-
title: "
|
|
136
|
+
title: "Status bar",
|
|
138
137
|
items: [
|
|
139
138
|
{ label: "Preset", path: "powerline.preset", kind: "select", choices: ["default", "minimal", "compact", "full", "nerd", "ascii", "chef"] },
|
|
140
139
|
{ label: "Separator", path: "powerline.separator", kind: "select", choices: SEPARATORS },
|
|
141
|
-
{ label: "
|
|
142
|
-
{ label: "
|
|
143
|
-
{ label: "
|
|
144
|
-
{ label: "
|
|
145
|
-
{ label: "
|
|
146
|
-
{ label: "Git host
|
|
140
|
+
{ label: "Placement", path: "powerline.placement", kind: "select", choices: ["above", "below"] },
|
|
141
|
+
{ label: "Path mode", path: "powerline.segmentOptions.path.mode", kind: "select", choices: ["basename", "abbreviated", "full"] },
|
|
142
|
+
{ label: "Path max length", path: "powerline.segmentOptions.path.maxLength", kind: "number", hint: "0 = unlimited" },
|
|
143
|
+
{ label: "Time format", path: "powerline.segmentOptions.time.format", kind: "select", choices: ["12h", "24h"] },
|
|
144
|
+
{ label: "Time seconds", path: "powerline.segmentOptions.time.showSeconds", kind: "toggle" },
|
|
145
|
+
{ label: "Git host icons", path: "powerline.segmentOptions.git.hostIcon", kind: "toggle" },
|
|
147
146
|
{ label: "Git ahead/behind", path: "powerline.segmentOptions.git.showAheadBehind", kind: "toggle" },
|
|
148
|
-
{ label: "Git
|
|
149
|
-
{ label: "Context
|
|
150
|
-
{ label: "Cache-read
|
|
151
|
-
{ label: "
|
|
152
|
-
{ label: "
|
|
153
|
-
{ label: "Ports
|
|
154
|
-
{ label: "TPS
|
|
155
|
-
{ label: "TPS
|
|
156
|
-
{ label: "TPS label", path: "powerline.segmentLabels.tps", kind: "text", hint: "
|
|
147
|
+
{ label: "Git latest commit", path: "powerline.segmentOptions.git.showCommit", kind: "toggle" },
|
|
148
|
+
{ label: "Context format", path: "powerline.segmentOptions.context.format", kind: "select", choices: ["full", "percent"] },
|
|
149
|
+
{ label: "Cache-read format", path: "powerline.segmentOptions.cache_read.format", kind: "select", choices: ["tokens", "percent", "both"] },
|
|
150
|
+
{ label: "Cost display", path: "powerline.segmentOptions.cost.subscriptionDisplay", kind: "select", choices: ["subscription", "reported-cost", "both"] },
|
|
151
|
+
{ label: "Currency", path: "powerline.segmentOptions.cost.currency", kind: "text" },
|
|
152
|
+
{ label: "Ports include UDP", path: "powerline.segmentOptions.openPorts.includeUdp", kind: "toggle" },
|
|
153
|
+
{ label: "TPS window (ms)", path: "powerline.segmentOptions.tps.windowMs", kind: "number", hint: "default 1000" },
|
|
154
|
+
{ label: "TPS mode", path: "powerline.segmentOptions.tps.mode", kind: "select", choices: ["both", "out", "in"] },
|
|
155
|
+
{ label: "TPS label", path: "powerline.segmentLabels.tps", kind: "text", hint: "empty = no label" },
|
|
157
156
|
],
|
|
158
157
|
},
|
|
159
158
|
{
|
|
160
|
-
title: "
|
|
159
|
+
title: "Welcome & vibes",
|
|
161
160
|
items: [
|
|
162
|
-
{ label: "Welcome overlay", path: "powerline.welcome", kind: "toggle", hint: "
|
|
163
|
-
{ label: "
|
|
161
|
+
{ label: "Welcome overlay", path: "powerline.welcome", kind: "toggle", hint: "on = overlay at startup, off = no welcome" },
|
|
162
|
+
{ label: "Animate wishcraft lantern", path: "wishcraft.welcome.animateLantern", kind: "toggle", hint: "flicker on the lantern" },
|
|
164
163
|
],
|
|
165
164
|
},
|
|
166
165
|
{
|
|
167
166
|
title: "Skills",
|
|
168
167
|
items: [
|
|
169
|
-
{ label: "Inline
|
|
168
|
+
{ label: "Inline expand /command and $skill", path: "wishcraft.inlineSkills", kind: "toggle", hint: "needs a restart to take effect" },
|
|
170
169
|
{ label: "Read hints", path: "wishcraft.readHints", kind: "toggle", hint: "off = no continuation hint after partial reads" },
|
|
171
170
|
],
|
|
172
171
|
},
|
|
173
172
|
{
|
|
174
|
-
title: "Hooks & repairs (harness
|
|
173
|
+
title: "Hooks & repairs (harness)",
|
|
175
174
|
items: [
|
|
176
|
-
{ label: "Hooks
|
|
175
|
+
{ label: "Hooks enabled", path: "wishcraft.hooksEnabled", kind: "toggle", hint: "preToolUse / postToolUse / sessionStart command hooks" },
|
|
177
176
|
{ label: "Tool-input repairs", path: "wishcraft.repairsEnabled", kind: "toggle", hint: "null-for-optional, auto-link, json-array, path aliases" },
|
|
178
|
-
{ label: "
|
|
177
|
+
{ label: "Daily token budget", path: "wishcraft.tokenBudget.daily", kind: "number", hint: "colours the cost segment; never blocks. 0 = off" },
|
|
179
178
|
],
|
|
180
179
|
},
|
|
181
180
|
{
|
|
182
|
-
title: "
|
|
181
|
+
title: "Shortcuts",
|
|
183
182
|
items: [
|
|
184
|
-
{ label: "Menu", path: "powerlineShortcuts.menu", kind: "text", hint: "
|
|
183
|
+
{ label: "Menu", path: "powerlineShortcuts.menu", kind: "text", hint: "e.g. alt+p" },
|
|
185
184
|
{ label: "Info", path: "powerlineShortcuts.info", kind: "text" },
|
|
186
185
|
{ label: "Stash", path: "powerlineShortcuts.stashHistory", kind: "text" },
|
|
187
|
-
{ label: "
|
|
186
|
+
{ label: "Idea", path: "powerlineShortcuts.ideaCapture", kind: "text" },
|
|
188
187
|
{ label: "Queue", path: "powerlineShortcuts.queueOpen", kind: "text" },
|
|
189
188
|
],
|
|
190
189
|
},
|
|
@@ -202,8 +201,8 @@ function isPrintable(data: string): boolean {
|
|
|
202
201
|
}
|
|
203
202
|
|
|
204
203
|
function displayValue(item: ConfigItem, value: ConfigValue): string {
|
|
205
|
-
if (value === null || value === undefined || value === "") return item.kind === "toggle" ? "
|
|
206
|
-
if (item.kind === "toggle") return value ? "
|
|
204
|
+
if (value === null || value === undefined || value === "") return item.kind === "toggle" ? "off" : "—";
|
|
205
|
+
if (item.kind === "toggle") return value ? "on" : "off";
|
|
207
206
|
return String(value);
|
|
208
207
|
}
|
|
209
208
|
|
|
@@ -220,7 +219,7 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
220
219
|
let settings = readSettings(cwd);
|
|
221
220
|
let groups = buildConfigGroups(settings);
|
|
222
221
|
|
|
223
|
-
//
|
|
222
|
+
// flat row list: group titles + items
|
|
224
223
|
type Row =
|
|
225
224
|
| { type: "group"; title: string }
|
|
226
225
|
| { type: "item"; group: number; item: ConfigItem };
|
|
@@ -239,7 +238,7 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
239
238
|
const wrapRow = (t: string, w: number) =>
|
|
240
239
|
`${border("│")}${truncateToWidth(t, w, "…", true)}${border("│")}`;
|
|
241
240
|
|
|
242
|
-
let selected = 1; //
|
|
241
|
+
let selected = 1; // first item (row 0 is a group title)
|
|
243
242
|
let editing = false;
|
|
244
243
|
let editBuffer = "";
|
|
245
244
|
|
|
@@ -254,12 +253,12 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
254
253
|
if (!cur) return;
|
|
255
254
|
const { item } = cur;
|
|
256
255
|
let value: ConfigValue;
|
|
257
|
-
if (item.kind === "toggle") value = next === "
|
|
256
|
+
if (item.kind === "toggle") value = next === "on";
|
|
258
257
|
else value = coerce(item, readConfigPath(settings, item.path), next);
|
|
259
258
|
const ok = writeConfigPath(cwd, item.path, value);
|
|
260
259
|
settings = readSettings(cwd);
|
|
261
260
|
groups = buildConfigGroups(settings);
|
|
262
|
-
// live
|
|
261
|
+
// live-reload powerline config + status bar
|
|
263
262
|
if (item.path.startsWith("powerline")) {
|
|
264
263
|
setConfig({
|
|
265
264
|
...stateConfig,
|
|
@@ -268,7 +267,7 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
268
267
|
rt.tuiRef?.requestRender?.();
|
|
269
268
|
}
|
|
270
269
|
ctx.ui.notify(
|
|
271
|
-
ok ? `${item.label}: ${displayValue(item, value)} (
|
|
270
|
+
ok ? `${item.label}: ${displayValue(item, value)} (saved)` : `${item.label} not saved (settings.json?)`,
|
|
272
271
|
ok ? "info" : "warning",
|
|
273
272
|
);
|
|
274
273
|
};
|
|
@@ -282,7 +281,7 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
282
281
|
settings = readSettings(cwd);
|
|
283
282
|
groups = buildConfigGroups(settings);
|
|
284
283
|
ctx.ui.notify(
|
|
285
|
-
ok ? `${item.label}: ${next} (
|
|
284
|
+
ok ? `${item.label}: ${next} (saved)` : `${item.label} not saved`,
|
|
286
285
|
ok ? "info" : "warning",
|
|
287
286
|
);
|
|
288
287
|
};
|
|
@@ -293,7 +292,7 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
293
292
|
settings = readSettings(cwd);
|
|
294
293
|
groups = buildConfigGroups(settings);
|
|
295
294
|
ctx.ui.notify(
|
|
296
|
-
ok ? `${item.label}: ${!(cur === true) ? "
|
|
295
|
+
ok ? `${item.label}: ${!(cur === true) ? "on" : "off"} (saved)` : `${item.label} not saved`,
|
|
297
296
|
ok ? "info" : "warning",
|
|
298
297
|
);
|
|
299
298
|
};
|
|
@@ -304,12 +303,12 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
304
303
|
const lines: string[] = [];
|
|
305
304
|
lines.push(border(`╭${"─".repeat(innerWidth)}╮`));
|
|
306
305
|
lines.push(
|
|
307
|
-
wrapRow(theme.fg("accent", theme.bold("Wishcraft ·
|
|
306
|
+
wrapRow(theme.fg("accent", theme.bold("Wishcraft · configuration")), innerWidth),
|
|
308
307
|
);
|
|
309
308
|
lines.push(border(`├${"─".repeat(innerWidth)}┤`));
|
|
310
309
|
|
|
311
310
|
const rows = buildRows();
|
|
312
|
-
// scroll
|
|
311
|
+
// scroll window around the selection
|
|
313
312
|
let start = Math.max(0, selected - Math.floor(LIST_ROWS / 2));
|
|
314
313
|
let end = Math.min(start + LIST_ROWS, rows.length);
|
|
315
314
|
if (end - start < Math.min(LIST_ROWS, rows.length)) start = Math.max(0, end - LIST_ROWS);
|
|
@@ -341,8 +340,8 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
341
340
|
theme.fg(
|
|
342
341
|
"dim",
|
|
343
342
|
editing
|
|
344
|
-
? "
|
|
345
|
-
: "↑↓ · enter=
|
|
343
|
+
? "type=value · enter=save · esc=cancel"
|
|
344
|
+
: "↑↓ · enter=select/edit (←→ cycles) · esc=close",
|
|
346
345
|
),
|
|
347
346
|
innerWidth,
|
|
348
347
|
),
|
|
@@ -388,7 +387,7 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
388
387
|
} while (rows[selected]!.type === "group");
|
|
389
388
|
} else if (matchesKey(data, "pageUp")) {
|
|
390
389
|
selected = Math.max(1, selected - LIST_ROWS);
|
|
391
|
-
//
|
|
390
|
+
// do not land on a group header: skip to the next item
|
|
392
391
|
while (selected < rows.length - 1 && rows[selected]!.type === "group")
|
|
393
392
|
selected++;
|
|
394
393
|
} else if (matchesKey(data, "pageDown")) {
|
|
@@ -424,10 +423,10 @@ export async function showWishcraftConfig(rt: RuntimeState, ctx: any): Promise<v
|
|
|
424
423
|
);
|
|
425
424
|
}
|
|
426
425
|
|
|
427
|
-
/**
|
|
426
|
+
/** Register /wishcraft. */
|
|
428
427
|
export function registerWishcraftConfigCommand(pi: ExtensionAPI, rt: RuntimeState): void {
|
|
429
428
|
pi.registerCommand("wishcraft", {
|
|
430
|
-
description: "
|
|
429
|
+
description: "Configure all wishcraft settings in one overlay (status bar, welcome, hooks, shortcuts)",
|
|
431
430
|
handler: async (_args: string, ctx: any) => {
|
|
432
431
|
if (!rt.enabled || !ctx.hasUI) {
|
|
433
432
|
ctx.ui.notify("Powerline UI is disabled", "info");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* inline-invocation.ts
|
|
3
3
|
* ------------------------------------------------------------------------
|
|
4
|
-
* Inline trigger
|
|
4
|
+
* Inline trigger expansion like Cursor (`/`) and Codex (`$`).
|
|
5
5
|
*
|
|
6
|
-
* /command ->
|
|
7
|
-
* $skill ->
|
|
6
|
+
* /command -> replaced with the command.md skill body
|
|
7
|
+
* $skill -> replaced with the skill.md skill body
|
|
8
8
|
*
|
|
9
|
-
* Discovery
|
|
10
|
-
*
|
|
9
|
+
* Discovery and cache live in skill-registry.ts (pi core loadSkills + TTL)
|
|
10
|
+
* so new skills work without a restart and usage is tracked.
|
|
11
11
|
* ------------------------------------------------------------------------
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -64,7 +64,7 @@ function isExcluded(index: number, ranges: Array<[number, number]>): boolean {
|
|
|
64
64
|
export function expandInlineTriggers(text: string): string {
|
|
65
65
|
const availableSkills = getAvailableSkills();
|
|
66
66
|
|
|
67
|
-
// Pattern
|
|
67
|
+
// Pattern for both /command and $skill
|
|
68
68
|
const TRIGGER_REGEX = /(^|[\s(])(\/|\$)([a-zA-Z0-9_-]+)/g;
|
|
69
69
|
const excluded = findExcludedRanges(text);
|
|
70
70
|
|
|
@@ -96,7 +96,7 @@ export function expandInlineTriggers(text: string): string {
|
|
|
96
96
|
// Geen matches -> originele tekst teruggeven
|
|
97
97
|
if (matches.length === 0) return text;
|
|
98
98
|
|
|
99
|
-
//
|
|
99
|
+
// Sort by position and drop overlaps
|
|
100
100
|
matches.sort((a, b) => a.start - b.start);
|
|
101
101
|
const deduped: typeof matches = [];
|
|
102
102
|
let lastEnd = -1;
|
|
@@ -107,7 +107,7 @@ export function expandInlineTriggers(text: string): string {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
//
|
|
110
|
+
// Rebuild the text with expansions
|
|
111
111
|
let result = "";
|
|
112
112
|
let cursor = 0;
|
|
113
113
|
|
|
@@ -160,7 +160,7 @@ export function setupInlineInvocation(
|
|
|
160
160
|
return { action: "continue" };
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
-
//
|
|
163
|
+
// Refresh the cache on restart/reload so new skills show up immediately
|
|
164
164
|
pi.on("session_start", () => {
|
|
165
165
|
invalidateSkillCache();
|
|
166
166
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* skill-manager.ts
|
|
3
3
|
* ---------------------------------------------------------------------------
|
|
4
|
-
* Skills Manager v2 —
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* - detail
|
|
9
|
-
* - e=
|
|
10
|
-
* n=
|
|
4
|
+
* Skills Manager v2 — list ⇄ detail overlay:
|
|
5
|
+
* - search that actually filters (type=filter, ctrl+u clears)
|
|
6
|
+
* - category headers (global/project/prompts/extra) + tab category filter
|
|
7
|
+
* - sort by name or usage (s), usage counts from the ledger
|
|
8
|
+
* - detail panel: metadata, frontmatter, body with scroll
|
|
9
|
+
* - e=edit (edit command in the editor via pi's ! flow),
|
|
10
|
+
* n=new skill, d=delete with confirm
|
|
11
11
|
* ---------------------------------------------------------------------------
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
getSkillUsage,
|
|
22
22
|
invalidateSkillCache,
|
|
23
23
|
loadSkillCatalog,
|
|
24
|
+
insertSkillBody,
|
|
24
25
|
readSkillBody,
|
|
25
|
-
recordSkillUsage,
|
|
26
26
|
type SkillCategory,
|
|
27
27
|
type SkillEntry,
|
|
28
28
|
} from "./skill-registry.ts";
|
|
@@ -30,7 +30,7 @@ import { runSkillDoctor } from "./skill-doctor.ts";
|
|
|
30
30
|
import { runSkillsNew } from "./skill-templates.ts";
|
|
31
31
|
|
|
32
32
|
const CATEGORY_LABELS: Record<SkillCategory | "all", string> = {
|
|
33
|
-
all: "
|
|
33
|
+
all: "all",
|
|
34
34
|
global: "global",
|
|
35
35
|
project: "project",
|
|
36
36
|
prompts: "prompts",
|
|
@@ -59,18 +59,18 @@ function formatBytes(n: number): string {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function formatLastUsed(ms: number): string {
|
|
62
|
-
if (!ms) return "
|
|
62
|
+
if (!ms) return "never";
|
|
63
63
|
const diff = Date.now() - ms;
|
|
64
64
|
const min = Math.floor(diff / 60_000);
|
|
65
|
-
if (min < 1) return "
|
|
66
|
-
if (min < 60) return `${min}m
|
|
65
|
+
if (min < 1) return "just now";
|
|
66
|
+
if (min < 60) return `${min}m ago`;
|
|
67
67
|
const h = Math.floor(min / 60);
|
|
68
|
-
if (h < 24) return `${h}
|
|
68
|
+
if (h < 24) return `${h}h ago`;
|
|
69
69
|
const d = Math.floor(h / 24);
|
|
70
|
-
return `${d}d
|
|
70
|
+
return `${d}d ago`;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
/**
|
|
73
|
+
/** Append text as a new editor line; the user presses enter to run it. */
|
|
74
74
|
function appendToEditor(ctx: any, text: string, notify: string): void {
|
|
75
75
|
const current = ctx.ui.getEditorText?.() ?? "";
|
|
76
76
|
const separator = current && !current.endsWith("\n") ? "\n" : "";
|
|
@@ -78,8 +78,8 @@ function appendToEditor(ctx: any, text: string, notify: string): void {
|
|
|
78
78
|
ctx.ui.notify(notify, "info");
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
/** POSIX single-quote
|
|
82
|
-
* (
|
|
81
|
+
/** POSIX single-quote a path so a skill name with shell metacharacters
|
|
82
|
+
* (e.g. `a; curl … | sh` from an untrusted cloned repo) cannot inject. */
|
|
83
83
|
function shellQuote(value: string): string {
|
|
84
84
|
return `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
85
85
|
}
|
|
@@ -144,10 +144,10 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
144
144
|
} else {
|
|
145
145
|
rmSync(entry.filePath, { force: true });
|
|
146
146
|
}
|
|
147
|
-
ctx.ui.notify(`Skill
|
|
147
|
+
ctx.ui.notify(`Skill deleted: ${entry.name}`, "info");
|
|
148
148
|
} catch (error) {
|
|
149
149
|
ctx.ui.notify(
|
|
150
|
-
`
|
|
150
|
+
`Delete failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
151
151
|
"error",
|
|
152
152
|
);
|
|
153
153
|
}
|
|
@@ -159,12 +159,8 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
const insertBody = (entry: SkillEntry) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const separator = current && !current.endsWith("\n") ? "\n\n" : "";
|
|
165
|
-
ctx.ui.setEditorText(`${current}${separator}${body}\n`);
|
|
166
|
-
recordSkillUsage(entry.name);
|
|
167
|
-
ctx.ui.notify("Skill ingevoegd in je prompt", "info");
|
|
162
|
+
insertSkillBody(ctx, entry.name, readSkillBody(entry.filePath));
|
|
163
|
+
ctx.ui.notify("Skill inserted into your prompt", "info");
|
|
168
164
|
};
|
|
169
165
|
|
|
170
166
|
return {
|
|
@@ -175,8 +171,8 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
175
171
|
|
|
176
172
|
if (mode === "list") {
|
|
177
173
|
const f = filtered();
|
|
178
|
-
//
|
|
179
|
-
const head = `Skills · ${f.length}/${entries.length} · ${sort === "name" ? "
|
|
174
|
+
// Header: total + sort + live filter
|
|
175
|
+
const head = `Skills · ${f.length}/${entries.length} · ${sort === "name" ? "name" : "usage"} · ${CATEGORY_LABELS[category]}${query ? ` · search "${query}"` : ""}`;
|
|
180
176
|
lines.push(wrapRow(theme.fg("accent", theme.bold(head)), innerWidth));
|
|
181
177
|
lines.push(border(`├${"─".repeat(innerWidth)}┤`));
|
|
182
178
|
|
|
@@ -184,12 +180,12 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
184
180
|
const emptyMsg =
|
|
185
181
|
entries.length === 0 && !query
|
|
186
182
|
? "No skills installed — ctrl+n to create one"
|
|
187
|
-
: `
|
|
183
|
+
: `No skills for "${query}"`;
|
|
188
184
|
lines.push(
|
|
189
185
|
wrapRow(theme.fg("warning", emptyMsg), innerWidth),
|
|
190
186
|
);
|
|
191
187
|
} else {
|
|
192
|
-
// scroll
|
|
188
|
+
// scroll window around the selection
|
|
193
189
|
const start = Math.max(
|
|
194
190
|
0,
|
|
195
191
|
Math.min(selected - Math.floor(LIST_ROWS / 2), f.length - LIST_ROWS),
|
|
@@ -242,7 +238,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
242
238
|
wrapRow(
|
|
243
239
|
theme.fg(
|
|
244
240
|
"warning",
|
|
245
|
-
`ctrl+d
|
|
241
|
+
`ctrl+d or enter = delete "${selectedEntry()?.name ?? ""}", any other key cancels`,
|
|
246
242
|
),
|
|
247
243
|
innerWidth,
|
|
248
244
|
),
|
|
@@ -252,7 +248,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
252
248
|
wrapRow(
|
|
253
249
|
theme.fg(
|
|
254
250
|
"dim",
|
|
255
|
-
"
|
|
251
|
+
"type=filter · ↑↓ · →/enter=detail · tab=category · ctrl+s=sort",
|
|
256
252
|
),
|
|
257
253
|
innerWidth,
|
|
258
254
|
),
|
|
@@ -261,7 +257,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
261
257
|
wrapRow(
|
|
262
258
|
theme.fg(
|
|
263
259
|
"dim",
|
|
264
|
-
"ctrl+e=
|
|
260
|
+
"ctrl+e=edit · ctrl+n=new · ctrl+d=delete · esc=close",
|
|
265
261
|
),
|
|
266
262
|
innerWidth,
|
|
267
263
|
),
|
|
@@ -287,15 +283,15 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
287
283
|
);
|
|
288
284
|
lines.push(
|
|
289
285
|
meta(
|
|
290
|
-
"
|
|
291
|
-
`${u?.count ?? 0}× ·
|
|
286
|
+
"used",
|
|
287
|
+
`${u?.count ?? 0}× · last ${formatLastUsed(u?.lastUsed ?? 0)}`,
|
|
292
288
|
),
|
|
293
289
|
);
|
|
294
|
-
lines.push(meta("
|
|
290
|
+
lines.push(meta("file", e.filePath));
|
|
295
291
|
lines.push(
|
|
296
292
|
meta(
|
|
297
|
-
"
|
|
298
|
-
`${formatBytes(e.sizeBytes)} · ${e.lineCount}
|
|
293
|
+
"size",
|
|
294
|
+
`${formatBytes(e.sizeBytes)} · ${e.lineCount} lines · changed ${formatLastUsed(e.mtimeMs)}`,
|
|
299
295
|
),
|
|
300
296
|
);
|
|
301
297
|
lines.push(
|
|
@@ -303,13 +299,13 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
303
299
|
"frontmatter",
|
|
304
300
|
e.frontmatterKeys.length
|
|
305
301
|
? e.frontmatterKeys.join(", ")
|
|
306
|
-
: "(
|
|
302
|
+
: "(none)",
|
|
307
303
|
),
|
|
308
304
|
);
|
|
309
305
|
if (e.disableModelInvocation) {
|
|
310
306
|
lines.push(
|
|
311
307
|
wrapRow(
|
|
312
|
-
theme.fg("warning", "model
|
|
308
|
+
theme.fg("warning", "model invocation off — insert only"),
|
|
313
309
|
innerWidth,
|
|
314
310
|
),
|
|
315
311
|
);
|
|
@@ -320,7 +316,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
320
316
|
lines.push(border(`├${"─".repeat(innerWidth)}┤`));
|
|
321
317
|
const shown = bodyLines.slice(scroll, scroll + DETAIL_ROWS);
|
|
322
318
|
if (shown.length === 0 || shown.join("").trim() === "") {
|
|
323
|
-
lines.push(wrapRow(theme.fg("dim", "(
|
|
319
|
+
lines.push(wrapRow(theme.fg("dim", "(empty body)"), innerWidth));
|
|
324
320
|
}
|
|
325
321
|
for (const line of shown) {
|
|
326
322
|
lines.push(wrapRow(theme.fg("text", line || " "), innerWidth));
|
|
@@ -329,7 +325,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
329
325
|
if (confirmDelete) {
|
|
330
326
|
lines.push(
|
|
331
327
|
wrapRow(
|
|
332
|
-
theme.fg("warning", `ctrl+d
|
|
328
|
+
theme.fg("warning", `ctrl+d or enter = delete "${e.name}", any other key cancels`),
|
|
333
329
|
innerWidth,
|
|
334
330
|
),
|
|
335
331
|
);
|
|
@@ -338,7 +334,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
338
334
|
wrapRow(
|
|
339
335
|
theme.fg(
|
|
340
336
|
"dim",
|
|
341
|
-
"↑↓ scroll · enter=
|
|
337
|
+
"↑↓ scroll · enter=insert · ctrl+e=edit · ctrl+d=delete · ←/esc=back",
|
|
342
338
|
),
|
|
343
339
|
innerWidth,
|
|
344
340
|
),
|
|
@@ -360,7 +356,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
360
356
|
if (mode === "list") {
|
|
361
357
|
const f = filtered();
|
|
362
358
|
if (confirmDelete) {
|
|
363
|
-
//
|
|
359
|
+
// Confirm delete: ctrl+d or enter; any other key cancels.
|
|
364
360
|
if (data === "\x04" || matchesKey(data, "enter")) {
|
|
365
361
|
const entry = selectedEntry();
|
|
366
362
|
if (entry) doDelete(entry);
|
|
@@ -379,17 +375,17 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
379
375
|
category = CATEGORY_ORDER[(idx + 1) % CATEGORY_ORDER.length]!;
|
|
380
376
|
selected = 0;
|
|
381
377
|
} else if (data === "\x13") {
|
|
382
|
-
// ctrl+s =
|
|
378
|
+
// ctrl+s = sort
|
|
383
379
|
sort = sort === "name" ? "usage" : "name";
|
|
384
380
|
selected = 0;
|
|
385
381
|
} else if (data === "\x05") {
|
|
386
|
-
// ctrl+e =
|
|
382
|
+
// ctrl+e = edit
|
|
387
383
|
const entry = selectedEntry();
|
|
388
384
|
if (entry) {
|
|
389
385
|
appendToEditor(
|
|
390
386
|
ctx,
|
|
391
387
|
editorCommand(entry.filePath),
|
|
392
|
-
"Edit
|
|
388
|
+
"Edit command in the editor — press enter to run it",
|
|
393
389
|
);
|
|
394
390
|
close();
|
|
395
391
|
return;
|
|
@@ -399,7 +395,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
399
395
|
done("new");
|
|
400
396
|
return;
|
|
401
397
|
} else if (data === "\x04") {
|
|
402
|
-
// ctrl+d =
|
|
398
|
+
// ctrl+d = delete (with confirm)
|
|
403
399
|
if (selectedEntry()) confirmDelete = true;
|
|
404
400
|
} else if (matchesKey(data, "enter") || matchesKey(data, "right")) {
|
|
405
401
|
const entry = selectedEntry();
|
|
@@ -409,7 +405,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
409
405
|
matchesKey(data, "backspace") ||
|
|
410
406
|
data === "\x15"
|
|
411
407
|
) {
|
|
412
|
-
//
|
|
408
|
+
// typing filters; ctrl+u clears the filter
|
|
413
409
|
if (data === "\x15") query = "";
|
|
414
410
|
else if (matchesKey(data, "backspace")) query = query.slice(0, -1);
|
|
415
411
|
else query += data;
|
|
@@ -433,16 +429,16 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
433
429
|
scroll + 1,
|
|
434
430
|
);
|
|
435
431
|
} else if (data === "\x05") {
|
|
436
|
-
// ctrl+e =
|
|
432
|
+
// ctrl+e = edit
|
|
437
433
|
appendToEditor(
|
|
438
434
|
ctx,
|
|
439
435
|
editorCommand(detail!.filePath),
|
|
440
|
-
"Edit
|
|
436
|
+
"Edit command in the editor — press enter to run it",
|
|
441
437
|
);
|
|
442
438
|
close();
|
|
443
439
|
return;
|
|
444
440
|
} else if (data === "\x04") {
|
|
445
|
-
// ctrl+d =
|
|
441
|
+
// ctrl+d = delete
|
|
446
442
|
confirmDelete = true;
|
|
447
443
|
} else if (matchesKey(data, "enter") || matchesKey(data, "tab")) {
|
|
448
444
|
insertBody(detail!);
|
|
@@ -464,7 +460,7 @@ export async function showSkillManager(ctx: any): Promise<"new" | null> {
|
|
|
464
460
|
);
|
|
465
461
|
}
|
|
466
462
|
|
|
467
|
-
/**
|
|
463
|
+
/** Register the `/skills` command. */
|
|
468
464
|
export type SkillManagerCommandDeps = {
|
|
469
465
|
runDoctor?: (ctx: any) => Promise<void>;
|
|
470
466
|
};
|
|
@@ -497,5 +493,5 @@ export function registerSkillManagerCommand(
|
|
|
497
493
|
});
|
|
498
494
|
}
|
|
499
495
|
|
|
500
|
-
// Re-export
|
|
496
|
+
// Re-export for existing importers/tests.
|
|
501
497
|
export { listSkills, readSkillBody } from "./skill-registry.ts";
|