( item: ToolItem, descriptor: AgentActivityDescriptor, )
| 23 | }; |
| 24 | |
| 25 | export function buildSkillReadContent( |
| 26 | item: ToolItem, |
| 27 | descriptor: AgentActivityDescriptor, |
| 28 | ): FileReadContent | null { |
| 29 | if (descriptor.renderClass !== "skill-read") { |
| 30 | return null; |
| 31 | } |
| 32 | |
| 33 | const skillRef = |
| 34 | getToolString(item.args, ["name"]) ?? |
| 35 | descriptor.preview ?? |
| 36 | descriptor.object; |
| 37 | if (!skillRef) { |
| 38 | return null; |
| 39 | } |
| 40 | |
| 41 | const resultText = getResultText(item.result); |
| 42 | if (!resultText.trim()) { |
| 43 | return null; |
| 44 | } |
| 45 | |
| 46 | const rawLines = trimTrailingEmptyLines(resultText.split(/\r?\n/)); |
| 47 | const lines = |
| 48 | rawLines.length > 0 |
| 49 | ? rawLines.map((line) => ({ |
| 50 | kind: "context" as const, |
| 51 | text: line, |
| 52 | })) |
| 53 | : [{ kind: "meta" as const, text: "No skill content returned." }]; |
| 54 | |
| 55 | const footerText = skillRef.includes("/") ? skillRef : `${skillRef}/SKILL.md`; |
| 56 | |
| 57 | return { |
| 58 | footerText, |
| 59 | footerTitle: skillRef, |
| 60 | lines, |
| 61 | path: skillRef, |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | export function buildFileReadContent( |
| 66 | item: ToolItem, |
no test coverage detected