22import type { PackageUsage } from './agent/detect-imports.ts'
33import type { AgentType } from './agent/index.ts'
44import { existsSync , readFileSync , realpathSync } from 'node:fs'
5+ import { styleText } from 'node:util'
56import * as p from '@clack/prompts'
67import { defineCommand , runMain } from 'citty'
78import pLimit from 'p-limit'
@@ -49,7 +50,7 @@ function deprecatedForwarder(
4950 ...cmd ,
5051 meta : { ...cmd . meta , name : oldName } ,
5152 async run ( ctx : any ) {
52- console . warn ( `\x1B[33m ⚠ \`skilld ${ oldName } \` is deprecated. Use \`skilld ${ newName } \` instead.\x1B[0m` )
53+ console . warn ( styleText ( 'yellow' , ` ⚠ \`skilld ${ oldName } \` is deprecated. Use \`skilld ${ newName } \` instead.` ) )
5354 return original ( ctx )
5455 } ,
5556 } )
@@ -128,8 +129,8 @@ const main = defineCommand({
128129 }
129130 p . log . info (
130131 'No agent selected - skills export as portable PROMPT_*.md files.\n'
131- + ' Run \x1B[36mskilld add <pkg>\x1B[0m to generate prompts for any package.\n'
132- + ' Run \x1B[36mskilld config\x1B[0m to set a target agent later.' ,
132+ + ` Run ${ styleText ( 'cyan' , 'skilld add <pkg>' ) } to generate prompts for any package.\n`
133+ + ` Run ${ styleText ( 'cyan' , 'skilld config' ) } to set a target agent later.` ,
133134 )
134135 return
135136 }
@@ -181,14 +182,14 @@ const main = defineCommand({
181182
182183 // Show self-update notification
183184 if ( selfUpdate ) {
184- const released = selfUpdate . releasedAt ? `\x1B[90m · ${ relativeTime ( new Date ( selfUpdate . releasedAt ) ) } \x1B[0m` : ''
185+ const released = selfUpdate . releasedAt ? styleText ( 'gray' , ` · ${ relativeTime ( new Date ( selfUpdate . releasedAt ) ) } ` ) : ''
185186 const binPath = realpathSync ( process . argv [ 1 ] ! )
186187 const isLocal = binPath . startsWith ( resolve ( cwd , 'node_modules' ) )
187188 const flag = isLocal ? '' : ' -g'
188189 const cmd = `npx nypm add${ flag } skilld@${ selfUpdate . latest } `
189190 p . note (
190- `\x1B[90m ${ version } \x1B[0m → \x1B[1m\x1B[32m ${ selfUpdate . latest } \x1B[0m ${ released } \n\x1B[36m ${ cmd } \x1B[0m ` ,
191- '\x1B[33mUpdate available\x1B[0m' ,
191+ `${ styleText ( 'gray' , version ) } → ${ styleText ( [ 'bold' , 'green' ] , selfUpdate . latest ) } ${ released } \n${ styleText ( 'cyan' , cmd ) } ` ,
192+ styleText ( 'yellow' , 'Update available' ) ,
192193 )
193194 }
194195
@@ -208,7 +209,7 @@ const main = defineCommand({
208209 const hasPkgJson = !!projectPkg
209210 const projectName = projectPkg?.parsed.name as string | undefined
210211 const projectLabel = projectName
211- ? `Generating skills for \x1B[36m$ { projectName } \x1B[0m `
212+ ? `Generating skills for $ { styleText ( 'cyan' , projectName ) } `
212213 : 'Generating skills for current directory'
213214 p.log.step(projectLabel)
214215
@@ -219,7 +220,7 @@ const main = defineCommand({
219220 if (state.shipped.length > 0 ) {
220221 const totalShipped = state . shipped . reduce ( ( sum , s ) => sum + s . skills . length , 0 )
221222 const names = state . shipped . map ( s => s . packageName ) . join ( ', ' )
222- p . log . info ( `\x1B[36m ${ totalShipped } ready-to-use skill${ totalShipped > 1 ? 's' : '' } \x1B[0m shipped by your dependencies: ${ names } ` )
223+ p . log . info ( `${ styleText ( 'cyan' , ` ${ totalShipped } ready-to-use skill${ totalShipped > 1 ? 's' : '' } ` ) } shipped by your dependencies: ${ names } ` )
223224 }
224225
225226 p.log.info('Tip: Add skills for packages with complex APIs or frequent breaking changes - not every dependency needs one.')
@@ -228,7 +229,7 @@ const main = defineCommand({
228229 let setupComplete = false
229230 while (!setupComplete) {
230231 const shippedOption = state . shipped . length > 0
231- ? [ { label : 'Install shipped skills' , value : 'shipped' as const , hint : `\x1B[36m ${ state . shipped . reduce ( ( sum , s ) => sum + s . skills . length , 0 ) } ready to use\x1B[0m` } ]
232+ ? [ { label : 'Install shipped skills' , value : 'shipped' as const , hint : styleText ( 'cyan' , ` ${ state . shipped . reduce ( ( sum , s ) => sum + s . skills . length , 0 ) } ready to use` ) } ]
232233 : [ ]
233234
234235 const source = hasPkgJson
@@ -250,7 +251,7 @@ const main = defineCommand({
250251 }
251252
252253 if (source === 'skip') {
253- p . log . info ( ' Run \x1B[36mskilld add <pkg>\x1B[0m or \x1B[36mskilld\x1B[0m anytime to add skills.' )
254+ p . log . info ( ` Run ${ styleText ( 'cyan' , 'skilld add <pkg>' ) } or ${ styleText ( 'cyan' , 'skilld' ) } anytime to add skills.` )
254255 return
255256 }
256257
@@ -344,7 +345,7 @@ const main = defineCommand({
344345 const hint = sourceMap . get ( name ) === 'preset' ? 'nuxt module' : undefined
345346 const pad = ' ' . repeat ( maxLen - name . length + 2 )
346347 const meta = [ ver , hint , repo ] . filter ( Boolean ) . join ( ' ' )
347- return { label : meta ? `${ name } ${ pad } \x1B[90m ${ meta } \x1B[39m ` : name , value : name }
348+ return { label : meta ? `${ name } ${ pad } ${ styleText ( 'gray' , meta ) } ` : name , value : name }
348349 } ) ,
349350 initialValues : preselect ,
350351 } )
@@ -384,7 +385,7 @@ const main = defineCommand({
384385 const previewLines = previewContent . split ( '\n' ) . slice ( 0 , 20 ) . join ( '\n' ) . replace ( / \x1B \[ [ 0 - ? ] * [ - / ] * [ @ - ~ ] / g, '' ) . replace ( / \x1B \] .* ?(?: \x07 | \x1B \\ ) / g, '' )
385386 const fileSize = ( Buffer . byteLength ( previewContent ) / 1024 ) . toFixed ( 1 )
386387 p . note (
387- `\x1B[90m ${ previewLines } \n...\x1B[0m` ,
388+ styleText ( 'gray' , ` ${ previewLines } \n...` ) ,
388389 `${ agents [ agent ] . skillsDir } /${ previewSkill . name } /SKILL.md (${ fileSize } KB)` ,
389390 )
390391 }
@@ -408,18 +409,18 @@ const main = defineCommand({
408409 }
409410 const verifyLine = agentInstalled
410411 ? (verifyTips[agent] ?? '')
411- : `Skills are ready in ${ agents [ agent ] . skillsDir } /.\n\x1B[90m$ { agentName } was not detected on this machine.\nInstall it to use these skills, or run \`skilld config\` to change agents.\x1B[0m `
412+ : `Skills are ready in ${ agents [ agent ] . skillsDir } /.\n$ { styleText ( 'gray' , ` ${ agentName } was not detected on this machine.\nInstall it to use these skills, or run \`skilld config\` to change agents.` ) } `
412413
413414 // Build a "try it" suggestion that tests skill-specific knowledge
414415 const firstPkg = previewSkill?.info?.packageName || previewSkill?.name
415416 const trySuggestion = firstPkg
416- ? `\n\n\x1B[36mTry it:\x1B[0m ask your agent "What are the gotchas or breaking changes in ${ firstPkg } ?"`
417+ ? `\n\n$ { styleText ( 'cyan' , 'Try it:' ) } ask your agent "What are the gotchas or breaking changes in ${ firstPkg } ?"`
417418 : ''
418419
419420 p.note(
420421 `${ verifyLine } ${ trySuggestion } \n\n`
421- + `Run \x1B[36mskilld info\x1B[0m to see installed skills.\n`
422- + `Run \x1B[36mskilld\x1B[0m again to add more, update, or search.`,
422+ + `Run $ { styleText ( 'cyan' , 'skilld info' ) } to see installed skills.\n`
423+ + `Run $ { styleText ( 'cyan' , 'skilld' ) } again to add more, update, or search.`,
423424 `${ agentName } - next steps`,
424425 )
425426
@@ -439,13 +440,13 @@ const main = defineCommand({
439440
440441 let needsPrepareHook = ! hasPrepareHook ( cwd )
441442 if ( needsPrepareHook ) {
442- p . log . warn ( `\x1B[33mNo prepare hook.\x1B[0m Skills won't auto-restore on \x1B[36mnpm install\x1B[0m .` )
443+ p . log . warn ( `${ styleText ( 'yellow' , 'No prepare hook.' ) } Skills won't auto-restore on ${ styleText ( 'cyan' , 'npm install' ) } .` )
443444 }
444445
445446 if (state.shipped.length > 0 ) {
446447 const totalSkills = state . shipped . reduce ( ( sum , s ) => sum + s . skills . length , 0 )
447448 const names = state . shipped . map ( s => s . packageName ) . join ( ', ' )
448- p . log . info ( `\x1B[36m ${ totalSkills } ready-to-use skill${ totalSkills > 1 ? 's' : '' } \x1B[0m shipped by your dependencies: ${ names } ` )
449+ p . log . info ( `${ styleText ( 'cyan' , ` ${ totalSkills } ready-to-use skill${ totalSkills > 1 ? 's' : '' } ` ) } shipped by your dependencies: ${ names } ` )
449450 }
450451
451452 const refreshState = async () => {
@@ -459,14 +460,14 @@ const main = defineCommand({
459460 const opts : Array < { label : string , value : string , hint ?: string } > = [ ]
460461 if ( state . shipped . length > 0 ) {
461462 const total = state . shipped . reduce ( ( sum , s ) => sum + s . skills . length , 0 )
462- opts . push ( { label : 'Install shipped skills' , value : 'shipped' , hint : `\x1B[36m ${ total } available\x1B[0m` } )
463+ opts . push ( { label : 'Install shipped skills' , value : 'shipped' , hint : styleText ( 'cyan' , ` ${ total } available` ) } )
463464 }
464465 opts . push ( { label : 'Add new skills' , value : 'install' } )
465466 if ( state . outdated . length > 0 ) {
466- opts . push ( { label : 'Update skills' , value : 'update' , hint : `\x1B[33m ${ state . outdated . length } outdated\x1B[0m` } )
467+ opts . push ( { label : 'Update skills' , value : 'update' , hint : styleText ( 'yellow' , ` ${ state . outdated . length } outdated` ) } )
467468 }
468469 if ( needsPrepareHook ) {
469- opts . push ( { label : 'Setup prepare hook' , value : 'prepare-hook' , hint : '\x1B[33mrecommended\x1B[0m' } )
470+ opts . push ( { label : 'Setup prepare hook' , value : 'prepare-hook' , hint : styleText ( 'yellow' , 'recommended' ) } )
470471 }
471472 opts . push (
472473 { label : 'Remove skills' , value : 'remove' } ,
@@ -595,7 +596,7 @@ const main = defineCommand({
595596 : undefined
596597 const pad = ' ' . repeat ( maxLen - name . length + 2 )
597598 const meta = [ ver , hint , repo ] . filter ( Boolean ) . join ( ' ' )
598- return { label : meta ? `${ name } ${ pad } \x1B[90m ${ meta } \x1B[39m ` : name , value : name }
599+ return { label : meta ? `${ name } ${ pad } ${ styleText ( 'gray' , meta ) } ` : name , value : name }
599600 } ) ,
600601 initialValues : [ ] ,
601602 } ) )
0 commit comments