@spences10/pi-skills 0.0.14 → 0.0.16
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 +18 -4
- package/dist/commands.js +142 -6
- package/dist/commands.js.map +1 -1
- package/dist/gh-skill.d.ts +40 -0
- package/dist/gh-skill.js +181 -0
- package/dist/gh-skill.js.map +1 -0
- package/dist/skills-ui/github.d.ts +3 -0
- package/dist/skills-ui/github.js +282 -0
- package/dist/skills-ui/github.js.map +1 -0
- package/dist/skills-ui/home.d.ts +2 -0
- package/dist/skills-ui/home.js +41 -0
- package/dist/skills-ui/home.js.map +1 -0
- package/dist/skills-ui/importable.d.ts +3 -0
- package/dist/skills-ui/importable.js +91 -0
- package/dist/skills-ui/importable.js.map +1 -0
- package/dist/skills-ui/manage.d.ts +3 -0
- package/dist/skills-ui/manage.js +46 -0
- package/dist/skills-ui/manage.js.map +1 -0
- package/dist/skills-ui/profiles.d.ts +6 -0
- package/dist/skills-ui/profiles.js +165 -0
- package/dist/skills-ui/profiles.js.map +1 -0
- package/dist/skills-ui/progress.d.ts +13 -0
- package/dist/skills-ui/progress.js +120 -0
- package/dist/skills-ui/progress.js.map +1 -0
- package/dist/skills-ui/skill-list.d.ts +10 -0
- package/dist/skills-ui/skill-list.js +39 -0
- package/dist/skills-ui/skill-list.js.map +1 -0
- package/dist/skills-ui.d.ts +6 -17
- package/dist/skills-ui.js +6 -351
- package/dist/skills-ui.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { show_input_modal, show_picker_modal, show_text_modal, } from '@spences10/pi-tui-modal';
|
|
2
|
+
import { format_profile_detail, profile_description, } from '../skill-utils.js';
|
|
3
|
+
export async function show_refresh_summary(ctx, mgr) {
|
|
4
|
+
mgr.refresh();
|
|
5
|
+
ctx.ui.notify(`Skills refreshed: ${mgr.discover().length} managed, ${mgr.discover_importable().length} importable`, 'info');
|
|
6
|
+
}
|
|
7
|
+
export async function show_defaults_modal(ctx, mgr) {
|
|
8
|
+
const selected = await show_picker_modal(ctx, {
|
|
9
|
+
title: 'Default skill policy',
|
|
10
|
+
subtitle: `Active profile: ${mgr.get_active_profile()}`,
|
|
11
|
+
items: [
|
|
12
|
+
{
|
|
13
|
+
value: 'all-enabled',
|
|
14
|
+
label: 'Enable by default',
|
|
15
|
+
description: 'Start with matching skills enabled; exclude rules turn skills off',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
value: 'all-disabled',
|
|
19
|
+
label: 'Disable by default',
|
|
20
|
+
description: 'Start with skills disabled; include rules turn skills on',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
if (!selected)
|
|
25
|
+
return;
|
|
26
|
+
mgr.set_defaults(selected);
|
|
27
|
+
await show_text_modal(ctx, {
|
|
28
|
+
title: 'Default skill policy updated',
|
|
29
|
+
text: `Active profile now starts from: ${selected}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export async function pick_profile(ctx, mgr, title) {
|
|
33
|
+
return await show_picker_modal(ctx, {
|
|
34
|
+
title,
|
|
35
|
+
subtitle: `Active: ${mgr.get_active_profile()}`,
|
|
36
|
+
items: mgr.list_profiles().map((profile) => ({
|
|
37
|
+
value: profile.name,
|
|
38
|
+
label: `${profile.active ? '● ' : '○ '}${profile.name}`,
|
|
39
|
+
description: profile_description(profile),
|
|
40
|
+
})),
|
|
41
|
+
empty_message: 'No skill profiles found',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export async function show_profiles_modal(ctx, mgr) {
|
|
45
|
+
while (true) {
|
|
46
|
+
const selected = await show_picker_modal(ctx, {
|
|
47
|
+
title: 'Skill profiles',
|
|
48
|
+
subtitle: `Active: ${mgr.get_active_profile()}`,
|
|
49
|
+
items: [
|
|
50
|
+
{
|
|
51
|
+
value: 'use',
|
|
52
|
+
label: 'Use profile',
|
|
53
|
+
description: 'Switch the active skill profile and reload',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: 'create',
|
|
57
|
+
label: 'Create profile',
|
|
58
|
+
description: 'Create a named skill profile',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: 'include',
|
|
62
|
+
label: 'Add include rule',
|
|
63
|
+
description: 'Turn on skills that match a profile pattern',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: 'exclude',
|
|
67
|
+
label: 'Add exclude rule',
|
|
68
|
+
description: 'Turn off skills that match a profile pattern',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
value: 'defaults',
|
|
72
|
+
label: 'Default skill policy',
|
|
73
|
+
description: 'Choose the profile starting point before rules apply',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: 'show',
|
|
77
|
+
label: 'Show profile details',
|
|
78
|
+
description: 'Inspect include/exclude patterns',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
footer: 'patterns match skill names, keys, sources, or paths; * is supported',
|
|
82
|
+
});
|
|
83
|
+
if (!selected)
|
|
84
|
+
return false;
|
|
85
|
+
if (selected === 'use') {
|
|
86
|
+
const profile = await pick_profile(ctx, mgr, 'Use skill profile');
|
|
87
|
+
if (!profile)
|
|
88
|
+
continue;
|
|
89
|
+
try {
|
|
90
|
+
mgr.use_profile(profile);
|
|
91
|
+
ctx.ui.notify(`Using skill profile ${profile}. Reloading...`, 'info');
|
|
92
|
+
await ctx.reload();
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), 'warning');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (selected === 'create') {
|
|
100
|
+
const name = await show_input_modal(ctx, {
|
|
101
|
+
title: 'Create skill profile',
|
|
102
|
+
label: 'Profile name',
|
|
103
|
+
trim: true,
|
|
104
|
+
});
|
|
105
|
+
if (!name)
|
|
106
|
+
continue;
|
|
107
|
+
try {
|
|
108
|
+
mgr.create_profile(name);
|
|
109
|
+
await show_text_modal(ctx, {
|
|
110
|
+
title: 'Skill profile created',
|
|
111
|
+
text: `Created empty profile ${name}. Use /skills profile use ${name} to activate it, then /skills enable <skill> to add skills.`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), 'warning');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (selected === 'include' || selected === 'exclude') {
|
|
119
|
+
const profile = await pick_profile(ctx, mgr, selected === 'include'
|
|
120
|
+
? 'Choose profile for include rule'
|
|
121
|
+
: 'Choose profile for exclude rule');
|
|
122
|
+
if (!profile)
|
|
123
|
+
continue;
|
|
124
|
+
const pattern = await show_input_modal(ctx, {
|
|
125
|
+
title: selected === 'include'
|
|
126
|
+
? 'Add include rule'
|
|
127
|
+
: 'Add exclude rule',
|
|
128
|
+
subtitle: `Profile: ${profile}`,
|
|
129
|
+
label: 'Skill name, key, or pattern',
|
|
130
|
+
trim: true,
|
|
131
|
+
});
|
|
132
|
+
if (!pattern)
|
|
133
|
+
continue;
|
|
134
|
+
try {
|
|
135
|
+
if (selected === 'include')
|
|
136
|
+
mgr.include_in_profile(profile, pattern);
|
|
137
|
+
else
|
|
138
|
+
mgr.exclude_from_profile(profile, pattern);
|
|
139
|
+
ctx.ui.notify(`Updated ${profile}. Reloading...`, 'info');
|
|
140
|
+
await ctx.reload();
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
ctx.ui.notify(error instanceof Error ? error.message : String(error), 'warning');
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (selected === 'defaults') {
|
|
148
|
+
await show_defaults_modal(ctx, mgr);
|
|
149
|
+
}
|
|
150
|
+
else if (selected === 'show') {
|
|
151
|
+
const profile_name = await pick_profile(ctx, mgr, 'Show skill profile');
|
|
152
|
+
const profile = mgr
|
|
153
|
+
.list_profiles()
|
|
154
|
+
.find((p) => p.name === profile_name);
|
|
155
|
+
if (!profile)
|
|
156
|
+
continue;
|
|
157
|
+
await show_text_modal(ctx, {
|
|
158
|
+
title: profile.name,
|
|
159
|
+
subtitle: profile_description(profile),
|
|
160
|
+
text: format_profile_detail(profile),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/skills-ui/profiles.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,GACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,qBAAqB,EACrB,mBAAmB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACzC,GAA4B,EAC5B,GAAkB;IAElB,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,qBAAqB,GAAG,CAAC,QAAQ,EAAE,CAAC,MAAM,aAAa,GAAG,CAAC,mBAAmB,EAAE,CAAC,MAAM,aAAa,EACpG,MAAM,CACN,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,GAA4B,EAC5B,GAAkB;IAElB,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,GAAG,EAAE;QAC7C,KAAK,EAAE,sBAAsB;QAC7B,QAAQ,EAAE,mBAAmB,GAAG,CAAC,kBAAkB,EAAE,EAAE;QACvD,KAAK,EAAE;YACN;gBACC,KAAK,EAAE,aAAa;gBACpB,KAAK,EAAE,mBAAmB;gBAC1B,WAAW,EACV,mEAAmE;aACpE;YACD;gBACC,KAAK,EAAE,cAAc;gBACrB,KAAK,EAAE,oBAAoB;gBAC3B,WAAW,EACV,0DAA0D;aAC3D;SACD;KACD,CAAC,CAAC;IACH,IAA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AC;gBAChD,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,OAAO,gBAAgB,EAAE,MAAM,CAAC,CAAC;gBAC1D,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,IAAI,CAAC;YACb,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,GAAG,CAAC,EAAE,CAAC,MAAM,CACZ,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACtD,SAAS,CACT,CAAC;YACH,CAAC;QACF,CAAC;aAAM,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;YACpC,MAAM,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;YAChC,MAAM,YAAY,GAAG,MAAM,YAAY,CACtC,GAAG,EACH,GAAG,EACH,oBAAoB,CACpB,CAAC;YACF,MAAM,OAAO,GAAG,GAAG;iBACjB,aAAa,EAAE;iBACf,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;YACvC,IAAI,CAAC,OAAO;gBAAE,SAAS;YACvB,MAAM,eAAe,CAAC,GAAG,EAAE;gBAC1B,KAAK,EAAE,OAAO,CAAC,IAAI;gBACnB,QAAQ,EAAE,mBAAmB,CAAC,OAAO,CAAC;gBACtC,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC;aACpC,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
export interface SkillProgressUpdate {
|
|
3
|
+
message?: string;
|
|
4
|
+
current?: string;
|
|
5
|
+
completed?: number;
|
|
6
|
+
total?: number;
|
|
7
|
+
line?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SkillProgressController {
|
|
10
|
+
signal: AbortSignal;
|
|
11
|
+
update: (update: SkillProgressUpdate) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function run_with_skill_progress<T>(ctx: ExtensionCommandContext, title: string, message: string, task: (controller: SkillProgressController) => Promise<T>): Promise<T | undefined>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Key, matchesKey, truncateToWidth, } from '@earendil-works/pi-tui';
|
|
2
|
+
class SkillProgressOverlay {
|
|
3
|
+
tui;
|
|
4
|
+
theme;
|
|
5
|
+
state;
|
|
6
|
+
on_cancel;
|
|
7
|
+
frame = 0;
|
|
8
|
+
frames = [
|
|
9
|
+
'⠋',
|
|
10
|
+
'⠙',
|
|
11
|
+
'⠹',
|
|
12
|
+
'⠸',
|
|
13
|
+
'⠼',
|
|
14
|
+
'⠴',
|
|
15
|
+
'⠦',
|
|
16
|
+
'⠧',
|
|
17
|
+
'⠇',
|
|
18
|
+
'⠏',
|
|
19
|
+
];
|
|
20
|
+
interval;
|
|
21
|
+
constructor(tui, theme, state, on_cancel) {
|
|
22
|
+
this.tui = tui;
|
|
23
|
+
this.theme = theme;
|
|
24
|
+
this.state = state;
|
|
25
|
+
this.on_cancel = on_cancel;
|
|
26
|
+
this.interval = setInterval(() => {
|
|
27
|
+
this.frame = (this.frame + 1) % this.frames.length;
|
|
28
|
+
this.tui.requestRender();
|
|
29
|
+
}, 120);
|
|
30
|
+
}
|
|
31
|
+
render(width) {
|
|
32
|
+
const spinner = this.theme.fg('accent', this.frames[this.frame] ?? '•');
|
|
33
|
+
const count = this.state.total !== undefined &&
|
|
34
|
+
this.state.completed !== undefined
|
|
35
|
+
? this.theme.fg('dim', ` ${this.state.completed}/${this.state.total}`)
|
|
36
|
+
: '';
|
|
37
|
+
const lines = [
|
|
38
|
+
this.theme.fg('accent', this.theme.bold(this.state.title)),
|
|
39
|
+
`${spinner} ${this.state.message}${count}`,
|
|
40
|
+
];
|
|
41
|
+
if (this.state.current) {
|
|
42
|
+
lines.push(this.theme.fg('muted', `Current: ${this.state.current}`));
|
|
43
|
+
}
|
|
44
|
+
if (this.state.lines.length > 0) {
|
|
45
|
+
lines.push('', this.theme.fg('dim', 'Recent activity'));
|
|
46
|
+
lines.push(...this.state.lines.slice(-8));
|
|
47
|
+
}
|
|
48
|
+
lines.push('', this.theme.fg('dim', 'esc cancel'));
|
|
49
|
+
return lines.map((line) => truncateToWidth(line, width));
|
|
50
|
+
}
|
|
51
|
+
handleInput(data) {
|
|
52
|
+
if (matchesKey(data, Key.escape))
|
|
53
|
+
this.on_cancel();
|
|
54
|
+
}
|
|
55
|
+
invalidate() { }
|
|
56
|
+
dispose() {
|
|
57
|
+
clearInterval(this.interval);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export async function run_with_skill_progress(ctx, title, message, task) {
|
|
61
|
+
const result = await ctx.ui.custom((tui, theme, _kb, done) => {
|
|
62
|
+
const abort_controller = new AbortController();
|
|
63
|
+
const state = {
|
|
64
|
+
title,
|
|
65
|
+
message,
|
|
66
|
+
lines: [],
|
|
67
|
+
cancelled: false,
|
|
68
|
+
};
|
|
69
|
+
const update = (update) => {
|
|
70
|
+
if (update.message !== undefined)
|
|
71
|
+
state.message = update.message;
|
|
72
|
+
if (update.current !== undefined)
|
|
73
|
+
state.current = update.current;
|
|
74
|
+
if (update.completed !== undefined)
|
|
75
|
+
state.completed = update.completed;
|
|
76
|
+
if (update.total !== undefined)
|
|
77
|
+
state.total = update.total;
|
|
78
|
+
if (update.line)
|
|
79
|
+
state.lines.push(update.line);
|
|
80
|
+
tui.requestRender();
|
|
81
|
+
};
|
|
82
|
+
const component = new SkillProgressOverlay(tui, theme, state, () => {
|
|
83
|
+
if (state.cancelled)
|
|
84
|
+
return;
|
|
85
|
+
state.cancelled = true;
|
|
86
|
+
state.message = 'Cancelling...';
|
|
87
|
+
abort_controller.abort();
|
|
88
|
+
tui.requestRender();
|
|
89
|
+
});
|
|
90
|
+
void task({ signal: abort_controller.signal, update })
|
|
91
|
+
.then((value) => {
|
|
92
|
+
done(state.cancelled
|
|
93
|
+
? { status: 'cancelled' }
|
|
94
|
+
: { status: 'success', value });
|
|
95
|
+
})
|
|
96
|
+
.catch((error) => {
|
|
97
|
+
if (state.cancelled || abort_controller.signal.aborted) {
|
|
98
|
+
done({ status: 'cancelled' });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
done({ status: 'error', error });
|
|
102
|
+
});
|
|
103
|
+
return component;
|
|
104
|
+
}, {
|
|
105
|
+
overlay: true,
|
|
106
|
+
overlayOptions: {
|
|
107
|
+
width: '70%',
|
|
108
|
+
minWidth: 50,
|
|
109
|
+
maxHeight: '70%',
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
if (result.status === 'cancelled') {
|
|
113
|
+
ctx.ui.notify('Cancelled', 'info');
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
if (result.status === 'error')
|
|
117
|
+
throw result.error;
|
|
118
|
+
return result.value;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/skills-ui/progress.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,GAAG,EACH,UAAU,EACV,eAAe,GAGf,MAAM,wBAAwB,CAAC;AA8BhC,MAAM,oBAAoB;IAiBP;IACA;IACA;IACA;IAnBV,KAAK,GAAG,CAAC,CAAC;IACD,MAAM,GAAG;QACzB,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;KACH,CAAC;IACe,QAAQ,CAAiB;IAE1C,YACkB,GAAQ,EACR,KAAY,EACZ,KAAoB,EACpB,SAAqB;QAHrB,QAAG,GAAH,GAAG,CAAK;QACR,UAAK,GAAL,KAAK,CAAO;QACZ,UAAK,GA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,MAAM,CAAC,OAAO,EAAE,CAAC;gBACxD,IAAI,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;gBAC9B,OAAO;YACR,CAAC;YACD,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEJ,OAAO,SAAS,CAAC;IAClB,CAAC,EACD;QACC,OAAO,EAAE,IAAI;QACb,cAAc,EAAE;YACf,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,KAAK;SAChB;KACD,CACD,CAAC;IAEF,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACnC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QACnC,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO;QAAE,MAAM,MAAM,CAAC,KAAK,CAAC;IAClD,OAAO,MAAM,CAAC,KAAK,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ExtensionCommandContext } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import type { ManagedSkill, SkillsManager } from '../manager.js';
|
|
3
|
+
export declare function pick_skill(ctx: ExtensionCommandContext, options: {
|
|
4
|
+
title: string;
|
|
5
|
+
subtitle: string;
|
|
6
|
+
skills: ManagedSkill[];
|
|
7
|
+
empty_message: string;
|
|
8
|
+
}): Promise<string | undefined>;
|
|
9
|
+
export declare function show_skill_detail_modal(ctx: ExtensionCommandContext, skill: ManagedSkill): Promise<void>;
|
|
10
|
+
export declare function show_skill_list_modal(ctx: ExtensionCommandContext, mgr: SkillsManager): Promise<void>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { show_picker_modal, show_text_modal, } from '@spences10/pi-tui-modal';
|
|
2
|
+
import { find_skill, format_skill_detail, skill_status, sort_skills, } from '../skill-utils.js';
|
|
3
|
+
export async function pick_skill(ctx, options) {
|
|
4
|
+
return await show_picker_modal(ctx, {
|
|
5
|
+
title: options.title,
|
|
6
|
+
subtitle: options.subtitle,
|
|
7
|
+
items: options.skills.map((skill) => ({
|
|
8
|
+
value: skill.key,
|
|
9
|
+
label: skill.name,
|
|
10
|
+
description: `${skill_status(skill)} • ${skill.source} • ${skill.key}`,
|
|
11
|
+
})),
|
|
12
|
+
empty_message: options.empty_message,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export async function show_skill_detail_modal(ctx, skill) {
|
|
16
|
+
await show_text_modal(ctx, {
|
|
17
|
+
title: skill.name,
|
|
18
|
+
subtitle: `${skill_status(skill)} • ${skill.source}`,
|
|
19
|
+
text: format_skill_detail(skill),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export async function show_skill_list_modal(ctx, mgr) {
|
|
23
|
+
while (true) {
|
|
24
|
+
const skills = sort_skills([
|
|
25
|
+
...mgr.discover(),
|
|
26
|
+
...mgr.discover_importable(),
|
|
27
|
+
]);
|
|
28
|
+
const key = await pick_skill(ctx, {
|
|
29
|
+
title: 'Browse skills',
|
|
30
|
+
subtitle: `${mgr.discover().length} managed • ${mgr.discover_importable().length} importable`,
|
|
31
|
+
skills,
|
|
32
|
+
empty_message: 'No skills found',
|
|
33
|
+
});
|
|
34
|
+
if (!key)
|
|
35
|
+
return;
|
|
36
|
+
await show_skill_detail_modal(ctx, find_skill(skills, key));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=skill-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-list.js","sourceRoot":"","sources":["../../src/skills-ui/skill-list.ts"],"names":[],"mappings":"AACA,OAAO,EACN,iBAAiB,EACjB,eAAe,GACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACN,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,WAAW,GACX,MAAM,mBAA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AE,CAAC,MAAM,aAAa;YAC7F,MAAM;YACN,aAAa,EAAE,iBAAiB;SAChC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG;YAAE,OAAO;QACjB,MAAM,uBAAuB,CAAC,GAAG,EAAE,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAC7D,CAAC;AACF,CAAC"}
|
package/dist/skills-ui.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
title: string;
|
|
8
|
-
subtitle: string;
|
|
9
|
-
skills: ManagedSkill[];
|
|
10
|
-
empty_message: string;
|
|
11
|
-
}): Promise<string | undefined>;
|
|
12
|
-
export declare function show_skill_detail_modal(ctx: ExtensionCommandContext, skill: ManagedSkill): Promise<void>;
|
|
13
|
-
export declare function show_skill_list_modal(ctx: ExtensionCommandContext, mgr: SkillsManager): Promise<void>;
|
|
14
|
-
export declare function show_refresh_summary(ctx: ExtensionCommandContext, mgr: SkillsManager): Promise<void>;
|
|
15
|
-
export declare function show_defaults_modal(ctx: ExtensionCommandContext, mgr: SkillsManager): Promise<void>;
|
|
16
|
-
export declare function pick_profile(ctx: ExtensionCommandContext, mgr: SkillsManager, title: string): Promise<string | undefined>;
|
|
17
|
-
export declare function show_profiles_modal(ctx: ExtensionCommandContext, mgr: SkillsManager): Promise<boolean>;
|
|
1
|
+
export { show_add_github_skill_modal, show_update_github_skills_modal, } from './skills-ui/github.js';
|
|
2
|
+
export { show_skills_home_modal } from './skills-ui/home.js';
|
|
3
|
+
export { show_importable_skills_modal } from './skills-ui/importable.js';
|
|
4
|
+
export { show_skills_manager_modal } from './skills-ui/manage.js';
|
|
5
|
+
export { pick_profile, show_defaults_modal, show_profiles_modal, show_refresh_summary, } from './skills-ui/profiles.js';
|
|
6
|
+
export { pick_skill, show_skill_detail_modal, show_skill_list_modal, } from './skills-ui/skill-list.js';
|