@rbbtsn0w/adg 0.8.0-beta.3 → 0.8.0-beta.5
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/dist/src/commands/multiselect-skills.js +3 -2
- package/dist/vendor/skills/src/add.js +92 -15
- package/dist/vendor/skills/src/agents.js +60 -0
- package/dist/vendor/skills/src/archive.js +311 -0
- package/dist/vendor/skills/src/blob.js +58 -22
- package/dist/vendor/skills/src/cli.js +21 -1
- package/dist/vendor/skills/src/constants.js +2 -0
- package/dist/vendor/skills/src/detect-agent.js +24 -1
- package/dist/vendor/skills/src/download-source.js +221 -0
- package/dist/vendor/skills/src/find.js +6 -5
- package/dist/vendor/skills/src/git.js +39 -13
- package/dist/vendor/skills/src/github-host.js +34 -0
- package/dist/vendor/skills/src/install.js +6 -1
- package/dist/vendor/skills/src/installer.js +8 -4
- package/dist/vendor/skills/src/list.js +28 -12
- package/dist/vendor/skills/src/local-lock.js +29 -4
- package/dist/vendor/skills/src/prompts/search-multiselect.js +274 -62
- package/dist/vendor/skills/src/providers/index.js +1 -1
- package/dist/vendor/skills/src/providers/wellknown.js +88 -90
- package/dist/vendor/skills/src/remove.js +98 -11
- package/dist/vendor/skills/src/skills.js +23 -19
- package/dist/vendor/skills/src/source-parser.js +73 -10
- package/dist/vendor/skills/src/sync.js +3 -3
- package/dist/vendor/skills/src/test-utils.js +74 -5
- package/dist/vendor/skills/src/update-source.js +56 -8
- package/dist/vendor/skills/src/update.js +355 -155
- package/dist/vendor/skills/src/use.js +41 -4
- package/package.json +14 -4
- package/vendor/skills/PROVENANCE.md +18 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdir, cp, access, readdir, symlink, lstat, rm, readlink, readFile, writeFile, stat, realpath, } from 'fs/promises';
|
|
1
|
+
import { mkdir, cp, access, readdir, symlink, lstat, rm, readlink, readFile, writeFile, stat, chmod, realpath, } from 'fs/promises';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import { join, basename, normalize, resolve, sep, relative, dirname, extname } from 'path';
|
|
4
4
|
import { homedir, platform } from 'os';
|
|
@@ -299,7 +299,7 @@ export async function installSkillForAgent(skill, agentType, options = {}) {
|
|
|
299
299
|
// actually used in this project. The skill is already available in .agents/skills/.
|
|
300
300
|
if (!isGlobal && !isUniversalAgent(agentType)) {
|
|
301
301
|
const agentRootDir = join(cwd, agents[agentType].skillsDir.split('/')[0]);
|
|
302
|
-
if (!existsSync(agentRootDir)) {
|
|
302
|
+
if (!existsSync(agentRootDir) && agentType !== 'claude-code') {
|
|
303
303
|
return {
|
|
304
304
|
success: true,
|
|
305
305
|
path: canonicalDir,
|
|
@@ -395,6 +395,8 @@ async function copyDirectory(src, dest, agentType) {
|
|
|
395
395
|
dereference: true,
|
|
396
396
|
recursive: true,
|
|
397
397
|
});
|
|
398
|
+
const sourceStats = await stat(srcPath);
|
|
399
|
+
await chmod(destPath, sourceStats.mode & 0o777);
|
|
398
400
|
}
|
|
399
401
|
catch (err) {
|
|
400
402
|
// Skip broken symlinks (e.g., pointing to absolute paths on another machine)
|
|
@@ -802,10 +804,12 @@ export async function installBlobSkillForAgent(skill, agentType, options = {}) {
|
|
|
802
804
|
};
|
|
803
805
|
}
|
|
804
806
|
// For project-level installs, skip creating symlinks for non-universal agents
|
|
805
|
-
// whose config directory doesn't already exist in the project.
|
|
807
|
+
// whose config directory doesn't already exist in the project. Claude Code is
|
|
808
|
+
// exempted since it can be explicitly selected as the install target even when
|
|
809
|
+
// .claude/ doesn't exist yet (see installSkillForAgent for the same exemption).
|
|
806
810
|
if (!isGlobal && !isUniversalAgent(agentType)) {
|
|
807
811
|
const agentRootDir = join(cwd, agents[agentType].skillsDir.split('/')[0]);
|
|
808
|
-
if (!existsSync(agentRootDir)) {
|
|
812
|
+
if (!existsSync(agentRootDir) && agentType !== 'claude-code') {
|
|
809
813
|
return {
|
|
810
814
|
success: true,
|
|
811
815
|
path: canonicalDir,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { homedir } from 'os';
|
|
2
2
|
import { agents } from "./agents.js";
|
|
3
|
-
import { listInstalledSkills } from "./installer.js";
|
|
3
|
+
import { listInstalledSkills, sanitizeName } from "./installer.js";
|
|
4
4
|
import { sanitizeMetadata } from "./sanitize.js";
|
|
5
5
|
import { getAllLockedSkills } from "./skill-lock.js";
|
|
6
|
+
import { readLocalLock } from "./local-lock.js";
|
|
6
7
|
const RESET = '\x1b[0m';
|
|
7
8
|
const BOLD = '\x1b[1m';
|
|
8
9
|
const DIM = '\x1b[38;5;102m';
|
|
@@ -73,20 +74,30 @@ export async function runList(args) {
|
|
|
73
74
|
global: scope,
|
|
74
75
|
agentFilter,
|
|
75
76
|
});
|
|
77
|
+
const cwd = process.cwd();
|
|
78
|
+
// Fetch lock entries to get source and plugin grouping info for the selected scope.
|
|
79
|
+
const lockedSkills = scope
|
|
80
|
+
? await getAllLockedSkills()
|
|
81
|
+
: (await readLocalLock(cwd)).skills;
|
|
82
|
+
const lockEntriesBySanitizedName = new Map(Object.entries(lockedSkills).map(([name, entry]) => [sanitizeName(name), entry]));
|
|
83
|
+
const getLockEntry = (skillName) => lockedSkills[skillName] ?? lockEntriesBySanitizedName.get(sanitizeName(skillName));
|
|
76
84
|
// JSON output mode: structured, no ANSI, untruncated agent lists
|
|
77
85
|
if (options.json) {
|
|
78
|
-
const jsonOutput = installedSkills.map((skill) =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
const jsonOutput = installedSkills.map((skill) => {
|
|
87
|
+
const lockEntry = getLockEntry(skill.name);
|
|
88
|
+
return {
|
|
89
|
+
name: skill.name,
|
|
90
|
+
path: skill.canonicalPath,
|
|
91
|
+
scope: skill.scope,
|
|
92
|
+
agents: skill.agents.map((a) => agents[a].displayName),
|
|
93
|
+
source: lockEntry?.source ?? null,
|
|
94
|
+
sourceUrl: lockEntry?.sourceUrl ?? null,
|
|
95
|
+
sourceType: lockEntry?.sourceType ?? null,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
84
98
|
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
85
99
|
return;
|
|
86
100
|
}
|
|
87
|
-
// Fetch lock entries to get plugin grouping info
|
|
88
|
-
const lockedSkills = await getAllLockedSkills();
|
|
89
|
-
const cwd = process.cwd();
|
|
90
101
|
const scopeLabel = scope ? 'Global' : 'Project';
|
|
91
102
|
if (installedSkills.length === 0) {
|
|
92
103
|
if (options.json) {
|
|
@@ -110,7 +121,12 @@ export async function runList(args) {
|
|
|
110
121
|
// Pad skill name and path for alignment
|
|
111
122
|
const paddedName = sanitizeMetadata(skill.name).padEnd(maxNameLength);
|
|
112
123
|
const paddedPath = shortPath.padEnd(maxPathLength);
|
|
113
|
-
|
|
124
|
+
// Determine source from lock file
|
|
125
|
+
const lockEntry = getLockEntry(skill.name);
|
|
126
|
+
const source = lockEntry?.source ?? null;
|
|
127
|
+
const sourceLabel = source ? sanitizeMetadata(source) : 'local';
|
|
128
|
+
console.log(`${prefix}${CYAN}${paddedName}${RESET} ${DIM}${paddedPath}${RESET}`);
|
|
129
|
+
console.log(`${prefix} ${DIM}Agents:${RESET} ${agentInfo} ${DIM}Source:${RESET} ${sourceLabel}`);
|
|
114
130
|
}
|
|
115
131
|
console.log(`${BOLD}${scopeLabel} Skills${RESET}`);
|
|
116
132
|
console.log();
|
|
@@ -118,7 +134,7 @@ export async function runList(args) {
|
|
|
118
134
|
const groupedSkills = {};
|
|
119
135
|
const ungroupedSkills = [];
|
|
120
136
|
for (const skill of installedSkills) {
|
|
121
|
-
const lockEntry =
|
|
137
|
+
const lockEntry = getLockEntry(skill.name);
|
|
122
138
|
if (lockEntry?.pluginName) {
|
|
123
139
|
const group = lockEntry.pluginName;
|
|
124
140
|
if (!groupedSkills[group]) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile, readdir, stat } from 'fs/promises';
|
|
2
|
-
import { join, relative } from 'path';
|
|
2
|
+
import { isAbsolute, join, relative, resolve, sep } from 'path';
|
|
3
3
|
import { createHash } from 'crypto';
|
|
4
4
|
const LOCAL_LOCK_FILE = 'skills-lock.json';
|
|
5
5
|
const CURRENT_VERSION = 1;
|
|
@@ -15,7 +15,8 @@ export function getLocalLockPath(cwd) {
|
|
|
15
15
|
* or is corrupted (e.g., merge conflict markers).
|
|
16
16
|
*/
|
|
17
17
|
export async function readLocalLock(cwd) {
|
|
18
|
-
const
|
|
18
|
+
const lockDir = cwd || process.cwd();
|
|
19
|
+
const lockPath = getLocalLockPath(lockDir);
|
|
19
20
|
try {
|
|
20
21
|
const content = await readFile(lockPath, 'utf-8');
|
|
21
22
|
const parsed = JSON.parse(content);
|
|
@@ -25,6 +26,11 @@ export async function readLocalLock(cwd) {
|
|
|
25
26
|
if (parsed.version < CURRENT_VERSION) {
|
|
26
27
|
return createEmptyLocalLock();
|
|
27
28
|
}
|
|
29
|
+
for (const entry of Object.values(parsed.skills)) {
|
|
30
|
+
if (entry.sourceType === 'local' && !isAbsolute(entry.source)) {
|
|
31
|
+
entry.source = resolve(lockDir, entry.source);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
28
34
|
return parsed;
|
|
29
35
|
}
|
|
30
36
|
catch {
|
|
@@ -36,16 +42,35 @@ export async function readLocalLock(cwd) {
|
|
|
36
42
|
* Skills are sorted alphabetically by name for deterministic output.
|
|
37
43
|
*/
|
|
38
44
|
export async function writeLocalLock(lock, cwd) {
|
|
39
|
-
const
|
|
45
|
+
const lockDir = cwd || process.cwd();
|
|
46
|
+
const lockPath = getLocalLockPath(lockDir);
|
|
40
47
|
// Sort skills alphabetically for deterministic output / clean diffs
|
|
41
48
|
const sortedSkills = {};
|
|
42
49
|
for (const key of Object.keys(lock.skills).sort()) {
|
|
43
|
-
|
|
50
|
+
const entry = lock.skills[key];
|
|
51
|
+
sortedSkills[key] =
|
|
52
|
+
entry.sourceType === 'local'
|
|
53
|
+
? { ...entry, source: getPortableLocalSource(entry.source, lockDir) }
|
|
54
|
+
: entry;
|
|
44
55
|
}
|
|
45
56
|
const sorted = { version: lock.version, skills: sortedSkills };
|
|
46
57
|
const content = JSON.stringify(sorted, null, 2) + '\n';
|
|
47
58
|
await writeFile(lockPath, content, 'utf-8');
|
|
48
59
|
}
|
|
60
|
+
function getPortableLocalSource(source, lockDir) {
|
|
61
|
+
const absoluteSource = isAbsolute(source) ? source : resolve(lockDir, source);
|
|
62
|
+
const relativeSource = relative(lockDir, absoluteSource);
|
|
63
|
+
// Different Windows drives cannot be represented by a relative path.
|
|
64
|
+
if (isAbsolute(relativeSource)) {
|
|
65
|
+
return absoluteSource.split(sep).join('/');
|
|
66
|
+
}
|
|
67
|
+
const portableSource = relativeSource.split(sep).join('/');
|
|
68
|
+
if (!portableSource)
|
|
69
|
+
return '.';
|
|
70
|
+
if (portableSource === '..' || portableSource.startsWith('../'))
|
|
71
|
+
return portableSource;
|
|
72
|
+
return `./${portableSource}`;
|
|
73
|
+
}
|
|
49
74
|
/**
|
|
50
75
|
* Compute a SHA-256 hash from all files in a skill directory.
|
|
51
76
|
* Reads all files recursively, sorts them by relative path for determinism,
|
|
@@ -96,13 +96,126 @@ export function countVisualRowsForLines(lines, columns) {
|
|
|
96
96
|
: 80;
|
|
97
97
|
return lines.reduce((sum, line) => sum + visualRowsForLine(line, cols), 0);
|
|
98
98
|
}
|
|
99
|
+
function truncateToWidth(text, width) {
|
|
100
|
+
let truncated = '';
|
|
101
|
+
for (const char of text) {
|
|
102
|
+
if (approxStringWidth(truncated + char) > width)
|
|
103
|
+
break;
|
|
104
|
+
truncated += char;
|
|
105
|
+
}
|
|
106
|
+
return truncated;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Wrap description text into a fixed number of terminal-width-safe lines.
|
|
110
|
+
* Empty lines are appended so changing the highlighted item never changes the
|
|
111
|
+
* prompt's logical height.
|
|
112
|
+
*/
|
|
113
|
+
export function formatDetailLines(detail, width, maxLines) {
|
|
114
|
+
const safeWidth = Math.max(1, width);
|
|
115
|
+
const normalized = detail?.replace(/\s+/g, ' ').trim() ?? '';
|
|
116
|
+
const lines = [];
|
|
117
|
+
let remaining = normalized;
|
|
118
|
+
while (remaining && lines.length < maxLines) {
|
|
119
|
+
if (approxStringWidth(remaining) <= safeWidth) {
|
|
120
|
+
lines.push(remaining);
|
|
121
|
+
remaining = '';
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
const candidate = truncateToWidth(remaining, safeWidth);
|
|
125
|
+
const breakAt = candidate.lastIndexOf(' ');
|
|
126
|
+
if (breakAt > 0) {
|
|
127
|
+
lines.push(candidate.slice(0, breakAt).trimEnd());
|
|
128
|
+
remaining = remaining.slice(breakAt).trimStart();
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
lines.push(candidate);
|
|
132
|
+
remaining = remaining.slice(candidate.length).trimStart();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (remaining && lines.length > 0) {
|
|
136
|
+
const last = lines.length - 1;
|
|
137
|
+
lines[last] = `${truncateToWidth(lines[last], Math.max(0, safeWidth - 1)).trimEnd()}…`;
|
|
138
|
+
}
|
|
139
|
+
while (lines.length < maxLines)
|
|
140
|
+
lines.push('');
|
|
141
|
+
return lines;
|
|
142
|
+
}
|
|
143
|
+
/** Build the navigable rows for a prompt, including selectable group headings. */
|
|
144
|
+
export function buildSearchEntries(items, selectGroups, collapsedGroups = new Set()) {
|
|
145
|
+
if (!selectGroups)
|
|
146
|
+
return items.map((item) => ({ type: 'item', item }));
|
|
147
|
+
const entries = [];
|
|
148
|
+
let index = 0;
|
|
149
|
+
while (index < items.length) {
|
|
150
|
+
const item = items[index];
|
|
151
|
+
if (!item.group) {
|
|
152
|
+
entries.push({ type: 'item', item });
|
|
153
|
+
index += 1;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const groupItems = [];
|
|
157
|
+
while (index < items.length && items[index].group === item.group) {
|
|
158
|
+
groupItems.push(items[index]);
|
|
159
|
+
index += 1;
|
|
160
|
+
}
|
|
161
|
+
const collapsed = collapsedGroups.has(item.group);
|
|
162
|
+
entries.push({ type: 'group', group: item.group, items: groupItems, collapsed });
|
|
163
|
+
if (!collapsed) {
|
|
164
|
+
entries.push(...groupItems.map((groupItem) => ({ type: 'item', item: groupItem })));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return entries;
|
|
168
|
+
}
|
|
169
|
+
/** Toggle one item, or every item represented by a selectable group heading. */
|
|
170
|
+
export function toggleSearchEntry(selected, entry) {
|
|
171
|
+
if (entry?.type === 'group') {
|
|
172
|
+
const allSelected = entry.items.every((item) => selected.has(item.value));
|
|
173
|
+
for (const item of entry.items) {
|
|
174
|
+
if (allSelected) {
|
|
175
|
+
selected.delete(item.value);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
selected.add(item.value);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (entry?.type === 'item') {
|
|
183
|
+
if (selected.has(entry.item.value)) {
|
|
184
|
+
selected.delete(entry.item.value);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
selected.add(entry.item.value);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/** Return the aggregate selection state represented by a Select All row. */
|
|
192
|
+
export function getSelectAllState(selected, items) {
|
|
193
|
+
const selectedCount = items.filter((item) => selected.has(item.value)).length;
|
|
194
|
+
if (selectedCount === 0)
|
|
195
|
+
return 'none';
|
|
196
|
+
if (selectedCount === items.length)
|
|
197
|
+
return 'all';
|
|
198
|
+
return 'partial';
|
|
199
|
+
}
|
|
200
|
+
/** Select every item unless they are all selected, in which case clear them all. */
|
|
201
|
+
export function toggleAllItems(selected, items) {
|
|
202
|
+
const shouldClear = getSelectAllState(selected, items) === 'all';
|
|
203
|
+
for (const item of items) {
|
|
204
|
+
if (shouldClear) {
|
|
205
|
+
selected.delete(item.value);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
selected.add(item.value);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
99
212
|
/**
|
|
100
213
|
* Interactive search multiselect prompt.
|
|
101
214
|
* Allows users to filter a long list by typing and select multiple items.
|
|
102
215
|
* Optionally supports a "locked" section that displays always-selected items.
|
|
103
216
|
*/
|
|
104
217
|
export async function searchMultiselect(options) {
|
|
105
|
-
const { message, items, maxVisible = 8, initialSelected = [], required = false, lockedSection, } = options;
|
|
218
|
+
const { message, items, maxVisible = 8, initialSelected = [], required = false, lockedSection, searchable = true, showDetail = false, detailLines = 2, showSelectedSummary = true, selectGroups = false, selectAll = false, } = options;
|
|
106
219
|
return new Promise((resolve) => {
|
|
107
220
|
const rl = readline.createInterface({
|
|
108
221
|
input: process.stdin,
|
|
@@ -117,6 +230,7 @@ export async function searchMultiselect(options) {
|
|
|
117
230
|
let query = '';
|
|
118
231
|
let cursor = 0;
|
|
119
232
|
const selected = new Set(initialSelected);
|
|
233
|
+
const collapsedGroups = new Set();
|
|
120
234
|
let lastRenderHeight = 0;
|
|
121
235
|
// Locked items are always included in the result
|
|
122
236
|
const lockedValues = lockedSection ? lockedSection.items.map((i) => i.value) : [];
|
|
@@ -130,20 +244,12 @@ export async function searchMultiselect(options) {
|
|
|
130
244
|
const getFiltered = () => {
|
|
131
245
|
return items.filter((item) => filter(item, query));
|
|
132
246
|
};
|
|
133
|
-
const clearRender = () => {
|
|
134
|
-
if (lastRenderHeight > 0) {
|
|
135
|
-
// Move up and clear each line
|
|
136
|
-
process.stdout.write(`\x1b[${lastRenderHeight}A`);
|
|
137
|
-
for (let i = 0; i < lastRenderHeight; i++) {
|
|
138
|
-
process.stdout.write('\x1b[2K\x1b[1B');
|
|
139
|
-
}
|
|
140
|
-
process.stdout.write(`\x1b[${lastRenderHeight}A`);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
247
|
const render = (state = 'active') => {
|
|
144
|
-
clearRender();
|
|
145
248
|
const lines = [];
|
|
146
249
|
const filtered = getFiltered();
|
|
250
|
+
const entries = buildSearchEntries(filtered, selectGroups, collapsedGroups);
|
|
251
|
+
const hasSelectAll = selectAll && items.length > 0;
|
|
252
|
+
const entryCursor = cursor - (hasSelectAll ? 1 : 0);
|
|
147
253
|
// Header
|
|
148
254
|
const icon = state === 'active' ? S_STEP_ACTIVE : state === 'cancel' ? S_STEP_CANCEL : S_STEP_SUBMIT;
|
|
149
255
|
lines.push(`${icon} ${pc.bold(message)}`);
|
|
@@ -157,64 +263,149 @@ export async function searchMultiselect(options) {
|
|
|
157
263
|
lines.push(`${S_BAR} ${S_BULLET} ${pc.bold(item.label)}`);
|
|
158
264
|
}
|
|
159
265
|
if (lockedSection.hiddenCount && lockedSection.hiddenCount > 0) {
|
|
160
|
-
lines.push(`${S_BAR} ${pc.dim(
|
|
266
|
+
lines.push(`${S_BAR} ${pc.dim(`…and ${lockedSection.hiddenCount} more`)}`);
|
|
161
267
|
}
|
|
162
268
|
lines.push(`${S_BAR}`);
|
|
163
269
|
lines.push(`${S_BAR} ${S_BAR_H}${S_BAR_H} ${pc.bold('Additional agents')} ${S_BAR_H.repeat(29)}`);
|
|
164
270
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
lines.push(`${S_BAR}`);
|
|
171
|
-
// Items
|
|
172
|
-
const visibleStart = Math.max(0, Math.min(cursor - Math.floor(maxVisible / 2), filtered.length - maxVisible));
|
|
173
|
-
const visibleEnd = Math.min(filtered.length, visibleStart + maxVisible);
|
|
174
|
-
const visibleItems = filtered.slice(visibleStart, visibleEnd);
|
|
175
|
-
if (filtered.length === 0) {
|
|
176
|
-
lines.push(`${S_BAR} ${pc.dim('No matches found')}`);
|
|
271
|
+
if (searchable) {
|
|
272
|
+
const searchLine = `${S_BAR} ${pc.dim('Search:')} ${query}${pc.inverse(' ')}`;
|
|
273
|
+
lines.push(searchLine);
|
|
274
|
+
lines.push(`${S_BAR} ${pc.dim('↑↓ move, space select, enter confirm')}`);
|
|
275
|
+
lines.push(`${S_BAR}`);
|
|
177
276
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
277
|
+
if (hasSelectAll) {
|
|
278
|
+
const selectedCount = items.filter((item) => selected.has(item.value)).length;
|
|
279
|
+
const selectAllState = getSelectAllState(selected, items);
|
|
280
|
+
const radio = selectAllState === 'all'
|
|
281
|
+
? S_RADIO_ACTIVE
|
|
282
|
+
: selectAllState === 'partial'
|
|
283
|
+
? pc.yellow('◐')
|
|
284
|
+
: S_RADIO_INACTIVE;
|
|
285
|
+
const isCursor = cursor === 0;
|
|
286
|
+
const prefix = isCursor ? pc.cyan('❯') : ' ';
|
|
287
|
+
const label = isCursor ? pc.underline(pc.bold('Select All')) : pc.bold('Select All');
|
|
288
|
+
lines.push(`${S_BAR} ${prefix} ${radio} ${label} ${pc.dim(`(${selectedCount}/${items.length})`)}`);
|
|
289
|
+
lines.push(`${S_BAR} ${S_BAR_H.repeat(36)}`);
|
|
290
|
+
}
|
|
291
|
+
const columns = process.stdout.columns && process.stdout.columns > 0 ? process.stdout.columns : 80;
|
|
292
|
+
const buildFooterLines = (includeDetail, includeSelectedSummary) => {
|
|
293
|
+
const footerLines = [];
|
|
294
|
+
if (includeDetail) {
|
|
295
|
+
const entry = entries[entryCursor];
|
|
296
|
+
const detail = hasSelectAll && cursor === 0
|
|
297
|
+
? `Select or clear all ${items.length} skills.`
|
|
298
|
+
: entry?.type === 'group'
|
|
299
|
+
? `Select all ${entry.items.length} skills in ${entry.group}.`
|
|
300
|
+
: entry?.item.detail;
|
|
301
|
+
// Keep a small margin for the left rail and terminal wrapping behavior.
|
|
302
|
+
const detailWidth = Math.max(1, columns - 5);
|
|
303
|
+
footerLines.push(`${S_BAR}`);
|
|
304
|
+
footerLines.push(`${S_BAR} ${pc.dim('Description')}`);
|
|
305
|
+
for (const line of formatDetailLines(detail, detailWidth, detailLines)) {
|
|
306
|
+
footerLines.push(`${S_BAR} ${pc.dim(line)}`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (includeSelectedSummary) {
|
|
310
|
+
// Selected summary (include locked items)
|
|
311
|
+
footerLines.push(`${S_BAR}`);
|
|
312
|
+
const allSelectedLabels = [
|
|
313
|
+
...(lockedSection ? lockedSection.items.map((i) => i.label) : []),
|
|
314
|
+
...items.filter((item) => selected.has(item.value)).map((item) => item.label),
|
|
315
|
+
];
|
|
316
|
+
if (allSelectedLabels.length === 0) {
|
|
317
|
+
footerLines.push(`${S_BAR} ${pc.dim('Selected: (none)')}`);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
const summary = allSelectedLabels.length <= 3
|
|
321
|
+
? allSelectedLabels.join(', ')
|
|
322
|
+
: `${allSelectedLabels.slice(0, 3).join(', ')} +${allSelectedLabels.length - 3} more`;
|
|
323
|
+
footerLines.push(`${S_BAR} ${pc.green('Selected:')} ${summary}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (!searchable) {
|
|
327
|
+
footerLines.push(`${S_BAR}`);
|
|
328
|
+
footerLines.push(`${S_BAR} ${pc.dim('↑↓ move, ←→ collapse/expand, space select, enter confirm')}`);
|
|
329
|
+
}
|
|
330
|
+
footerLines.push(`${pc.dim('└')}`);
|
|
331
|
+
return footerLines;
|
|
332
|
+
};
|
|
333
|
+
const buildItemLines = (visibleLimit) => {
|
|
334
|
+
if (filtered.length === 0) {
|
|
335
|
+
return [`${S_BAR} ${pc.dim('No matches found')}`];
|
|
336
|
+
}
|
|
337
|
+
const itemLines = [];
|
|
338
|
+
const visibleStart = Math.max(0, Math.min(entryCursor - Math.floor(visibleLimit / 2), entries.length - visibleLimit));
|
|
339
|
+
const visibleEnd = Math.min(entries.length, visibleStart + visibleLimit);
|
|
340
|
+
const visibleEntries = entries.slice(visibleStart, visibleEnd);
|
|
341
|
+
for (let i = 0; i < visibleEntries.length; i++) {
|
|
342
|
+
const entry = visibleEntries[i];
|
|
181
343
|
const actualIndex = visibleStart + i;
|
|
344
|
+
const isCursor = actualIndex === entryCursor;
|
|
345
|
+
if (entry.type === 'group') {
|
|
346
|
+
const selectedCount = entry.items.filter((item) => selected.has(item.value)).length;
|
|
347
|
+
const radio = selectedCount === entry.items.length
|
|
348
|
+
? S_RADIO_ACTIVE
|
|
349
|
+
: selectedCount > 0
|
|
350
|
+
? pc.yellow('◐')
|
|
351
|
+
: S_RADIO_INACTIVE;
|
|
352
|
+
const label = isCursor ? pc.underline(pc.bold(entry.group)) : pc.bold(entry.group);
|
|
353
|
+
const prefix = isCursor ? pc.cyan('❯') : ' ';
|
|
354
|
+
const disclosure = pc.dim(entry.collapsed ? '▸' : '▾');
|
|
355
|
+
itemLines.push(`${S_BAR} ${prefix} ${disclosure} ${radio} ${label}`);
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
const item = entry.item;
|
|
182
359
|
const isSelected = selected.has(item.value);
|
|
183
|
-
const isCursor = actualIndex === cursor;
|
|
184
360
|
const radio = isSelected ? S_RADIO_ACTIVE : S_RADIO_INACTIVE;
|
|
185
361
|
const label = isCursor ? pc.underline(item.label) : item.label;
|
|
186
362
|
const hint = item.hint ? pc.dim(` (${item.hint})`) : '';
|
|
187
363
|
const prefix = isCursor ? pc.cyan('❯') : ' ';
|
|
188
|
-
|
|
364
|
+
const groupItems = selectGroups && item.group ? filtered.filter((i) => i.group === item.group) : [];
|
|
365
|
+
const isLastInGroup = groupItems.at(-1) === item;
|
|
366
|
+
const tree = groupItems.length > 0 ? `${pc.dim(isLastInGroup ? '└─' : '├─')} ` : '';
|
|
367
|
+
itemLines.push(`${S_BAR} ${prefix} ${tree}${radio} ${label}${hint}`);
|
|
189
368
|
}
|
|
190
|
-
// Show count if more items
|
|
191
369
|
const hiddenBefore = visibleStart;
|
|
192
|
-
const hiddenAfter =
|
|
370
|
+
const hiddenAfter = entries.length - visibleEnd;
|
|
193
371
|
if (hiddenBefore > 0 || hiddenAfter > 0) {
|
|
194
372
|
const parts = [];
|
|
195
373
|
if (hiddenBefore > 0)
|
|
196
374
|
parts.push(`↑ ${hiddenBefore} more`);
|
|
197
375
|
if (hiddenAfter > 0)
|
|
198
376
|
parts.push(`↓ ${hiddenAfter} more`);
|
|
199
|
-
|
|
377
|
+
itemLines.push(`${S_BAR} ${pc.dim(parts.join(' '))}`);
|
|
200
378
|
}
|
|
379
|
+
return itemLines;
|
|
380
|
+
};
|
|
381
|
+
const terminalRows = process.stdout.rows && process.stdout.rows > 0 ? process.stdout.rows : undefined;
|
|
382
|
+
const maxFrameRows = terminalRows ? Math.max(1, terminalRows - 1) : undefined;
|
|
383
|
+
const fitFrame = (includeDetail, includeSelectedSummary) => {
|
|
384
|
+
const footerLines = buildFooterLines(includeDetail, includeSelectedSummary);
|
|
385
|
+
let visibleLimit = Math.max(1, maxVisible);
|
|
386
|
+
let itemLines = buildItemLines(visibleLimit);
|
|
387
|
+
let frameRows = countVisualRowsForLines([...lines, ...itemLines, ...footerLines], columns);
|
|
388
|
+
while (maxFrameRows && frameRows > maxFrameRows && visibleLimit > 1) {
|
|
389
|
+
visibleLimit -= 1;
|
|
390
|
+
itemLines = buildItemLines(visibleLimit);
|
|
391
|
+
frameRows = countVisualRowsForLines([...lines, ...itemLines, ...footerLines], columns);
|
|
392
|
+
}
|
|
393
|
+
return { itemLines, footerLines, frameRows };
|
|
394
|
+
};
|
|
395
|
+
let includeDetail = showDetail;
|
|
396
|
+
let includeSelectedSummary = showSelectedSummary;
|
|
397
|
+
let fitted = fitFrame(includeDetail, includeSelectedSummary);
|
|
398
|
+
// On very short terminals, preserve controls and selectable rows before
|
|
399
|
+
// optional context panes. The detail returns automatically when space grows.
|
|
400
|
+
if (maxFrameRows && fitted.frameRows > maxFrameRows && includeDetail) {
|
|
401
|
+
includeDetail = false;
|
|
402
|
+
fitted = fitFrame(includeDetail, includeSelectedSummary);
|
|
201
403
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
...(lockedSection ? lockedSection.items.map((i) => i.label) : []),
|
|
206
|
-
...items.filter((item) => selected.has(item.value)).map((item) => item.label),
|
|
207
|
-
];
|
|
208
|
-
if (allSelectedLabels.length === 0) {
|
|
209
|
-
lines.push(`${S_BAR} ${pc.dim('Selected: (none)')}`);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
const summary = allSelectedLabels.length <= 3
|
|
213
|
-
? allSelectedLabels.join(', ')
|
|
214
|
-
: `${allSelectedLabels.slice(0, 3).join(', ')} +${allSelectedLabels.length - 3} more`;
|
|
215
|
-
lines.push(`${S_BAR} ${pc.green('Selected:')} ${summary}`);
|
|
404
|
+
if (maxFrameRows && fitted.frameRows > maxFrameRows && includeSelectedSummary) {
|
|
405
|
+
includeSelectedSummary = false;
|
|
406
|
+
fitted = fitFrame(includeDetail, includeSelectedSummary);
|
|
216
407
|
}
|
|
217
|
-
lines.push(
|
|
408
|
+
lines.push(...fitted.itemLines, ...fitted.footerLines);
|
|
218
409
|
}
|
|
219
410
|
else if (state === 'submit') {
|
|
220
411
|
// Final state - show what was selected (including locked)
|
|
@@ -227,10 +418,13 @@ export async function searchMultiselect(options) {
|
|
|
227
418
|
else if (state === 'cancel') {
|
|
228
419
|
lines.push(`${S_BAR} ${pc.strikethrough(pc.dim('Cancelled'))}`);
|
|
229
420
|
}
|
|
230
|
-
|
|
421
|
+
// Write the clear sequence and next frame together. Clearing individual rows first
|
|
422
|
+
// makes larger prompts visibly flash between redraws in some terminals.
|
|
423
|
+
const clearPreviousFrame = lastRenderHeight > 0 ? `\x1b[${lastRenderHeight}A\x1b[J` : '';
|
|
424
|
+
process.stdout.write(clearPreviousFrame + lines.join('\n') + '\n');
|
|
231
425
|
// Use wrapped row count: logical lines can span multiple terminal rows when hints
|
|
232
|
-
// or labels exceed column width. Using lines.length alone under-counts and
|
|
233
|
-
//
|
|
426
|
+
// or labels exceed column width. Using lines.length alone under-counts and fails to
|
|
427
|
+
// clear the full previous frame, causing the prompt to re-print stale rows on redraw.
|
|
234
428
|
lastRenderHeight = countVisualRowsForLines(lines, process.stdout.columns);
|
|
235
429
|
};
|
|
236
430
|
const cleanup = () => {
|
|
@@ -259,7 +453,10 @@ export async function searchMultiselect(options) {
|
|
|
259
453
|
const keypressHandler = (_str, key) => {
|
|
260
454
|
if (!key)
|
|
261
455
|
return;
|
|
262
|
-
const
|
|
456
|
+
const entries = buildSearchEntries(getFiltered(), selectGroups, collapsedGroups);
|
|
457
|
+
const hasSelectAll = selectAll && items.length > 0;
|
|
458
|
+
const cursorOffset = hasSelectAll ? 1 : 0;
|
|
459
|
+
const entry = entries[cursor - cursorOffset];
|
|
263
460
|
if (key.name === 'return') {
|
|
264
461
|
submit();
|
|
265
462
|
return;
|
|
@@ -274,19 +471,34 @@ export async function searchMultiselect(options) {
|
|
|
274
471
|
return;
|
|
275
472
|
}
|
|
276
473
|
if (key.name === 'down') {
|
|
277
|
-
cursor = Math.min(
|
|
474
|
+
cursor = Math.min(entries.length + cursorOffset - 1, cursor + 1);
|
|
278
475
|
render();
|
|
279
476
|
return;
|
|
280
477
|
}
|
|
478
|
+
if (selectGroups && key.name === 'right') {
|
|
479
|
+
if (entry?.type === 'group' && entry.collapsed) {
|
|
480
|
+
collapsedGroups.delete(entry.group);
|
|
481
|
+
render();
|
|
482
|
+
}
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (selectGroups && key.name === 'left') {
|
|
486
|
+
const group = entry?.type === 'group' ? entry.group : entry?.item.group;
|
|
487
|
+
if (group) {
|
|
488
|
+
collapsedGroups.add(group);
|
|
489
|
+
const collapsedEntries = buildSearchEntries(getFiltered(), selectGroups, collapsedGroups);
|
|
490
|
+
cursor =
|
|
491
|
+
collapsedEntries.findIndex((collapsedEntry) => collapsedEntry.type === 'group' && collapsedEntry.group === group) + cursorOffset;
|
|
492
|
+
render();
|
|
493
|
+
}
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
281
496
|
if (key.name === 'space') {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
else {
|
|
288
|
-
selected.add(item.value);
|
|
289
|
-
}
|
|
497
|
+
if (hasSelectAll && cursor === 0) {
|
|
498
|
+
toggleAllItems(selected, items);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
toggleSearchEntry(selected, entry);
|
|
290
502
|
}
|
|
291
503
|
render();
|
|
292
504
|
return;
|
|
@@ -298,7 +510,7 @@ export async function searchMultiselect(options) {
|
|
|
298
510
|
return;
|
|
299
511
|
}
|
|
300
512
|
// Regular character input
|
|
301
|
-
if (key.sequence && !key.ctrl && !key.meta && key.sequence.length === 1) {
|
|
513
|
+
if (searchable && key.sequence && !key.ctrl && !key.meta && key.sequence.length === 1) {
|
|
302
514
|
query += key.sequence;
|
|
303
515
|
cursor = 0;
|
|
304
516
|
render();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Export registry functions
|
|
2
2
|
export { registry, registerProvider, findProvider, getProviders } from "./registry.js";
|
|
3
3
|
// Export individual providers
|
|
4
|
-
export { WellKnownProvider, wellKnownProvider, } from "./wellknown.js";
|
|
4
|
+
export { WellKnownProvider, WellKnownScopeNotFoundError, wellKnownProvider, computeWellKnownSkillDigest, } from "./wellknown.js";
|