11import { existsSync , lstatSync , readdirSync , statSync } from "node:fs" ;
22import { basename , dirname , join } from "node:path" ;
3+ import { computeSkillFootprint } from "../shared/skill-footprint" ;
4+ import type { ParsedSkillMd } from "./parser" ;
35import type { AgentConfig } from "./types" ;
46import { parseSkillMdFile } from "./parser" ;
57import { readProvenanceRaw } from "./provenance" ;
@@ -96,6 +98,25 @@ function collectionFromRealPath(realOrLink: string, skillsRoot: string): string
9698 return undefined ;
9799}
98100
101+ function listingFootprintFromParsed ( parsed : ParsedSkillMd , rawName : string , dirName : string ) {
102+ const fp = computeSkillFootprint ( {
103+ description : parsed . description ,
104+ when_to_use : parsed . when_to_use ,
105+ disable_model_invocation : parsed . disable_model_invocation ,
106+ skill_md_char_count : parsed . skill_md_char_count ,
107+ display_name : rawName ,
108+ skill_id : dirName ,
109+ } ) ;
110+ return {
111+ when_to_use : parsed . when_to_use ?? null ,
112+ footprint_listing_source_chars : fp . footprint_listing_source_chars ,
113+ footprint_listing_slice_chars : fp . footprint_listing_slice_chars ,
114+ footprint_name_chars : fp . footprint_name_chars ,
115+ footprint_skill_md_chars : fp . footprint_skill_md_chars ,
116+ listing_excluded : fp . listing_excluded ,
117+ } ;
118+ }
119+
99120function resolveSource (
100121 skillId : string ,
101122 canonical : string ,
@@ -173,6 +194,7 @@ function scanInheritedRoot(
173194 const dirName = basename ( skillDir ) ;
174195 const collection = detectCollection ( skillDir , root ) ;
175196 const skillName = parsed . name ?? dirName ;
197+ const fp = listingFootprintFromParsed ( parsed , skillName , dirName ) ;
176198
177199 const installation : SkillInstallation = {
178200 agent_slug : agent . slug ,
@@ -186,6 +208,7 @@ function scanInheritedRoot(
186208 id : dirName ,
187209 name : skillName ,
188210 description : parsed . description ,
211+ ...fp ,
189212 canonical_path : canonical ,
190213 source : resolveSource ( dirName , canonical , provenance ) ,
191214 metadata : parsed . metadata ,
@@ -234,6 +257,7 @@ function scanSkillMdRoot(
234257 const symlink = isSymlink ( skillDir ) ;
235258 const collection = detectCollection ( skillDir , root ) ;
236259 const skillId = dirName ;
260+ const fp = listingFootprintFromParsed ( parsed , rawName , dirName ) ;
237261
238262 const installation : SkillInstallation = {
239263 agent_slug : agent . slug ,
@@ -249,6 +273,7 @@ function scanSkillMdRoot(
249273 id : skillId ,
250274 name : rawName ,
251275 description : parsed . description ,
276+ ...fp ,
252277 canonical_path : canonical ,
253278 source : resolveSource ( skillId , canonical , provenance ) ,
254279 metadata : parsed . metadata ,
0 commit comments