|
1 | | -import { normalizeSkillIndexName } from "../skills/discovery/skill-index.js"; |
2 | | -import type { SkillStatusEntry, SkillStatusReport } from "../skills/discovery/status.js"; |
| 1 | +import { |
| 2 | +resolveSkillStatusEntry, |
| 3 | +type SkillStatusEntry, |
| 4 | +type SkillStatusReport, |
| 5 | +} from "../skills/discovery/status.js"; |
3 | 6 | import { sanitizeForLog, stripAnsi } from "../terminal/ansi.js"; |
4 | 7 | import { decorativeEmoji, decorativePrefix } from "../terminal/decorative-emoji.js"; |
5 | 8 | import { getTerminalTableWidth, renderTable } from "../terminal/table.js"; |
@@ -104,53 +107,6 @@ function formatSkillMissingSummary(skill: SkillStatusEntry): string {
|
104 | 107 | return missing.join("; "); |
105 | 108 | } |
106 | 109 | |
107 | | -function normalizeSkillLookupToken(value: string): string { |
108 | | -return normalizeSkillIndexName(value); |
109 | | -} |
110 | | - |
111 | | -function resolveSkillByName( |
112 | | -report: SkillStatusReport, |
113 | | -requestedName: string, |
114 | | -): SkillStatusEntry | null { |
115 | | -const raw = requestedName.trim(); |
116 | | -if (!raw) { |
117 | | -return null; |
118 | | -} |
119 | | - |
120 | | -const direct = report.skills.find((s) => s.name === raw || s.skillKey === raw); |
121 | | -if (direct) { |
122 | | -return direct; |
123 | | -} |
124 | | - |
125 | | -const lower = raw.toLowerCase(); |
126 | | -const caseInsensitiveMatches = report.skills.filter( |
127 | | -(s) => s.name.toLowerCase() === lower || s.skillKey.toLowerCase() === lower, |
128 | | -); |
129 | | -if (caseInsensitiveMatches.length === 1) { |
130 | | -return caseInsensitiveMatches[0] ?? null; |
131 | | -} |
132 | | -if (caseInsensitiveMatches.length > 1) { |
133 | | -return null; |
134 | | -} |
135 | | - |
136 | | -const normalized = normalizeSkillLookupToken(raw); |
137 | | -if (!normalized) { |
138 | | -return null; |
139 | | -} |
140 | | - |
141 | | -const normalizedMatches = report.skills.filter( |
142 | | -(s) => |
143 | | -normalizeSkillLookupToken(s.name) === normalized || |
144 | | -normalizeSkillLookupToken(s.skillKey) === normalized, |
145 | | -); |
146 | | - |
147 | | -if (normalizedMatches.length !== 1) { |
148 | | -return null; |
149 | | -} |
150 | | - |
151 | | -return normalizedMatches[0] ?? null; |
152 | | -} |
153 | | - |
154 | 110 | export function formatSkillsList(report: SkillStatusReport, opts: SkillsListOptions): string { |
155 | 111 | const isReadyForAgent = (skill: SkillStatusEntry) => |
156 | 112 | skill.eligible && !skill.blockedByAgentFilter; |
@@ -233,7 +189,7 @@ export function formatSkillInfo(
|
233 | 189 | ): string { |
234 | 190 | const requestedName = skillName.trim(); |
235 | 191 | const safeRequestedName = sanitizeJsonString(sanitizeForLog(requestedName)); |
236 | | -const skill = resolveSkillByName(report, requestedName); |
| 192 | +const skill = resolveSkillStatusEntry(report.skills, requestedName); |
237 | 193 | |
238 | 194 | if (!skill) { |
239 | 195 | if (opts.json) { |
|