@@ -323,7 +323,7 @@ function buildCliExecutionCommands(ctx) {
323323 } else if ( arg . startsWith ( '-' ) ) options . errors . push ( `unsupported option: ${ arg } ` )
324324 else options . candidateIds . push ( arg )
325325 }
326- if ( ! [ 'plan' , 'resolve' , 'match' ] . includes ( options . action ) ) {
326+ if ( ! [ 'plan' , 'resolve' , 'match' , 'intent' ] . includes ( options . action ) ) {
327327 options . errors . push ( `unknown skill subcommand: ${ options . action || '(none)' } ` )
328328 }
329329 if ( options . action === 'plan' && ! options . candidateIds . length ) {
@@ -332,16 +332,18 @@ function buildCliExecutionCommands(ctx) {
332332 if ( options . action === 'resolve' && ! options . candidateIds . length ) {
333333 options . errors . push ( 'at least one skill id is required for resolve' )
334334 }
335- if ( options . action === 'match' && ! options . candidateIds . length ) {
336- options . errors . push ( 'match requires a user prompt string (quote multi-word prompts)' )
335+ if ( ( options . action === 'match' || options . action === 'intent' ) && ! options . candidateIds . length ) {
336+ options . errors . push ( ` ${ options . action } requires a user prompt string (quote multi-word prompts)` )
337337 }
338338 return options
339339 }
340340
341341 function printSkillFailure ( options , errorCode , message , nextStep , details , exitCode ) {
342342 const operation = options . action === 'match'
343343 ? 'skill.match'
344- : ( options . action === 'resolve' ? 'skill.resolve' : 'skill.plan' )
344+ : ( options . action === 'intent'
345+ ? 'skill.intent'
346+ : ( options . action === 'resolve' ? 'skill.resolve' : 'skill.plan' ) )
345347 if ( options . json ) printCliJson ( console , createCliFailure ( operation , errorCode , message , nextStep , cliMetadata , details ) )
346348 else {
347349 console . log ( c . red ( ` [${ errorCode } ] ${ message } ` ) )
@@ -396,6 +398,64 @@ function buildCliExecutionCommands(ctx) {
396398 return publicResult
397399 }
398400
401+ function cmdSkillIntent ( options ) {
402+ let routeWorkspaceSkillIntent
403+ try {
404+ ; ( { routeWorkspaceSkillIntent } = require ( '../../hooks/_runtime/workspace-skill-intent.cjs' ) )
405+ } catch ( error ) {
406+ printSkillFailure ( options , 'SKILL_INTENT_UNAVAILABLE' , error . message , 'Reinstall DevCodex runtime hooks and retry.' , null , 1 )
407+ return null
408+ }
409+ const prompt = options . candidateIds . join ( ' ' )
410+ const result = routeWorkspaceSkillIntent ( prompt , {
411+ cwd : process . cwd ( ) ,
412+ consumerAuthority : 'cli'
413+ } )
414+ const publicResult = {
415+ mode : result . mode ,
416+ matched : result . matched ,
417+ skillId : result . skillId ,
418+ decision : result . decision ,
419+ mustReply : result . mustReply ,
420+ selectedLayer : result . selectedLayer ,
421+ selectedPath : result . selectedPath ,
422+ digest : result . digest ,
423+ alwaysOn : result . alwaysOn ,
424+ catalogDigest : result . catalog && result . catalog . digest ,
425+ entryExists : result . entry && result . entry . exists ,
426+ content : options . json ? result . content : undefined ,
427+ injectionText : options . json
428+ ? result . injectionText
429+ : ( result . injectionText ? '[present; use --json for full inject text]' : '' )
430+ }
431+ if ( options . json ) {
432+ printCliJson ( console , {
433+ schemaVersion : 'DevCodexCliEnvelopeV1' ,
434+ operation : 'skill.intent' ,
435+ ok : true ,
436+ result : options . json ? result : publicResult
437+ } )
438+ } else {
439+ console . log ( )
440+ console . log ( c . bold ( ' DevCodex WorkspaceSkillIntent' ) )
441+ console . log ( ` ${ c . cyan ( 'prompt' . padEnd ( 16 ) ) } ${ prompt } ` )
442+ console . log ( ` ${ c . cyan ( 'mode' . padEnd ( 16 ) ) } ${ result . mode } ` )
443+ console . log ( ` ${ c . cyan ( 'matched' . padEnd ( 16 ) ) } ${ result . matched } ` )
444+ console . log ( ` ${ c . cyan ( 'skillId' . padEnd ( 16 ) ) } ${ result . skillId || '(none)' } ` )
445+ console . log ( ` ${ c . cyan ( 'source' . padEnd ( 16 ) ) } ${ ( result . decision && result . decision . source ) || '(none)' } ` )
446+ console . log ( ` ${ c . cyan ( 'score' . padEnd ( 16 ) ) } ${ result . decision && result . decision . score != null ? result . decision . score : '(n/a)' } ` )
447+ console . log ( ` ${ c . cyan ( 'layer' . padEnd ( 16 ) ) } ${ result . selectedLayer || '(none)' } ` )
448+ console . log ( ` ${ c . cyan ( 'mustReply' . padEnd ( 16 ) ) } ${ result . mustReply || '(none)' } ` )
449+ console . log ( ` ${ c . cyan ( 'reasons' . padEnd ( 16 ) ) } ${ ( ( result . decision && result . decision . reasons ) || [ ] ) . join ( ', ' ) || '(none)' } ` )
450+ console . log ( ` ${ c . cyan ( 'entry' . padEnd ( 16 ) ) } ${ result . entry && result . entry . exists ? 'DEVCODEX.md ok' : 'missing' } ` )
451+ console . log ( c . dim ( ' default route: catalog + intent; legacy: DEVCODEX_SKILL_MATCH_MODE=legacy-token' ) )
452+ console . log ( c . dim ( ' closed-loop: UPS inject + Stop force when matched skill ignored' ) )
453+ console . log ( )
454+ }
455+ process . exitCode = 0
456+ return publicResult
457+ }
458+
399459 function cmdSkillResolve ( options ) {
400460 let resolveSkillReadPlan
401461 try {
@@ -458,14 +518,15 @@ function buildCliExecutionCommands(ctx) {
458518 options ,
459519 'CLI_INVALID_OPTION' ,
460520 options . errors . join ( '; ' ) ,
461- 'Use: devcodex skill plan <candidate...> | skill resolve <id...> | skill match <prompt...> [--json]' ,
521+ 'Use: devcodex skill plan <candidate...> | skill resolve <id...> | skill match <prompt...> | skill intent <prompt...> [--json]' ,
462522 { errors : options . errors } ,
463523 2
464524 )
465525 return null
466526 }
467527 if ( options . action === 'resolve' ) return cmdSkillResolve ( options )
468528 if ( options . action === 'match' ) return cmdSkillMatch ( options )
529+ if ( options . action === 'intent' ) return cmdSkillIntent ( options )
469530 let portfolio
470531 try {
471532 portfolio = readSkillPortfolio ( )
0 commit comments