@@ -20,7 +20,7 @@ export async function sync(_ctx: CommandContext): Promise<void> {
2020 }
2121
2222 const source = new URL ( "node_modules/@bomb.sh/tools/skills/" , root ) ;
23- if ( ! ( await exists ( source ) ) ) {
23+ if ( ! ( await safeRead ( source ) ) ) {
2424 console . error ( "@bomb.sh/tools is not installed. Run `pnpm add -D @bomb.sh/tools` first." ) ;
2525 return ;
2626 }
@@ -61,8 +61,9 @@ async function copySkills(options: { source: URL; dest: URL }): Promise<SkillInf
6161 await symlink ( target , fileURLToPath ( destDir ) , linkType ) ;
6262
6363 const skillMd = new URL ( "SKILL.md" , srcDir ) ;
64- if ( await exists ( skillMd ) ) {
65- const content = await readFile ( skillMd , "utf8" ) ;
64+
65+ const content = await safeRead ( skillMd ) ;
66+ if ( content ) {
6667 const frontmatter = parseFrontmatter ( content ) ;
6768 if ( frontmatter ) {
6869 skills . push ( frontmatter ) ;
@@ -109,10 +110,7 @@ async function pruneStaleLinks(options: {
109110async function updateGitignore ( options : { root : URL ; skills : SkillInfo [ ] } ) : Promise < void > {
110111 const { root, skills } = options ;
111112 const gitignorePath = new URL ( ".gitignore" , root ) ;
112- let content = "" ;
113- if ( await exists ( gitignorePath ) ) {
114- content = await readFile ( gitignorePath , "utf8" ) ;
115- }
113+ let content = ( await safeRead ( gitignorePath ) ) ?? "" ;
116114
117115 const lines = skills . map ( ( s ) => `skills/${ s . name } /` ) ;
118116 const section = [ GITIGNORE_START , ...lines , GITIGNORE_END ] . join ( "\n" ) ;
@@ -133,14 +131,11 @@ async function updateGitignore(options: { root: URL; skills: SkillInfo[] }): Pro
133131async function updateAgentsMd ( options : { root : URL ; skills : SkillInfo [ ] } ) : Promise < void > {
134132 const { root, skills } = options ;
135133 const agentsPath = new URL ( "AGENTS.md" , root ) ;
136- let content = "" ;
137- if ( await exists ( agentsPath ) ) {
138- content = await readFile ( agentsPath , "utf8" ) ;
139- }
134+ let content = ( await safeRead ( agentsPath ) ) ?? "" ;
140135
141136 const lines = skills . map ( ( s ) => {
142- const desc = s . description . split ( "." ) [ 0 ] . trim ( ) ;
143- return `- **${ s . name } ** — [skills/${ s . name } /SKILL.md](skills/${ s . name } /SKILL.md) — ${ desc } ` ;
137+ const desc = s . description . split ( "." ) [ 0 ] ? .trim ( ) ;
138+ return `- **${ s . name } ** — [skills/${ s . name } /SKILL.md](skills/${ s . name } /SKILL.md)${ desc ? ` - ${ desc } ` : "" } ` ;
144139 } ) ;
145140
146141 const section = [
0 commit comments