@@ -10,6 +10,11 @@ import {
1010import { COMMAND_OUTPUT_SCHEMAS } from './command-output-schemas.ts' ;
1111import { AppError } from '../kernel/errors.ts' ;
1212import { formatToolErrorText , normalizeToolError } from './tool-error.ts' ;
13+ import {
14+ commandAlias ,
15+ normalizeCrossSurfaceCommandAlias ,
16+ type CommandAlias ,
17+ } from '../command-aliases.ts' ;
1318
1419export type ToolResult = {
1520 isError : boolean ;
@@ -65,17 +70,28 @@ export function createCommandToolExecutor(deps: CommandToolExecutorDeps = {}): C
6570 const refPinsByScope = new Map < string , Map < string , number > > ( ) ;
6671 return {
6772 execute : async ( name , input ) => {
68- if ( ! isCommandName ( name ) ) {
73+ const canonicalName = normalizeCrossSurfaceCommandAlias ( name ) ;
74+ if ( ! isCommandName ( canonicalName ) ) {
6975 throw new AppError ( 'INVALID_ARGS' , `Unknown command tool: ${ name } ` ) ;
7076 }
77+ const alias = canonicalName === name ? undefined : commandAlias ( name ) ;
7178 const config = readMcpToolConfig ( input ) ;
7279 const commandInput = stripMcpConfigFields ( input ) ;
7380 const scopeKey = readPinScopeKey ( config , commandInput ) ;
74- const pinnedInput = pinPlainRefArguments ( name , commandInput , refPinsByScope . get ( scopeKey ) ) ;
81+ const pinnedInput = pinPlainRefArguments (
82+ canonicalName ,
83+ commandInput ,
84+ refPinsByScope . get ( scopeKey ) ,
85+ ) ;
7586 const client = await createClient ( deps , config . client ) ;
7687 try {
77- const result = await ( deps . runCommand ?? runCommand ) ( client , name , pinnedInput ) ;
78- mergeIssuedRefPins ( refPinsByScope , scopeKey , name , result ) ;
88+ const canonicalResult = await ( deps . runCommand ?? runCommand ) (
89+ client ,
90+ canonicalName ,
91+ pinnedInput ,
92+ ) ;
93+ const result = restoreLegacyAliasResult ( alias , canonicalResult ) ;
94+ mergeIssuedRefPins ( refPinsByScope , scopeKey , canonicalName , result ) ;
7995 return {
8096 isError : false ,
8197 structuredContent : result ,
@@ -85,7 +101,7 @@ export function createCommandToolExecutor(deps: CommandToolExecutorDeps = {}): C
85101 // Render from the UNPINNED input: the model typed plain refs and
86102 // must never see generation suffixes (zero token cost).
87103 text : renderToolText ( {
88- name,
104+ name : canonicalName ,
89105 input : commandInput ,
90106 result,
91107 outputFormat : config . outputFormat ,
@@ -101,6 +117,12 @@ export function createCommandToolExecutor(deps: CommandToolExecutorDeps = {}): C
101117 } ;
102118}
103119
120+ function restoreLegacyAliasResult ( alias : CommandAlias | undefined , result : unknown ) : unknown {
121+ if ( ! alias ?. legacyResultAction ) return result ;
122+ const record = asOptionalRecord ( result ) ;
123+ return record ? { ...record , action : alias . legacyResultAction } : result ;
124+ }
125+
104126/**
105127 * ADR 0012: a command error is a ref-issuing result — `isError: true`, the
106128 * normalized error as `structuredContent`, and an `available`
0 commit comments