feat(cli): wire active extension context into slash command routing

Extracts the extension context from slash commands based on their registered metadata and sets it as the active context in the Config before execution. This enables the backend to dynamically route plan directories based on the extension that owns the invoked command.
This commit is contained in:
Mahima Shanware
2026-04-06 16:20:05 +00:00
parent 985c5953c6
commit 39a7d59b27
6 changed files with 30 additions and 13 deletions
+5 -1
View File
@@ -10,6 +10,7 @@ export type ParsedSlashCommand = {
commandToExecute: SlashCommand | undefined;
args: string;
canonicalPath: string[];
extensionContext?: string;
};
/**
@@ -69,6 +70,8 @@ export const parseSlashCommand = (
const args = parts.slice(pathIndex).join(' ');
const extensionContext = commandToExecute?.extensionName;
// Backtrack if the matched (sub)command doesn't take arguments but some were provided,
// AND the parent command is capable of handling them.
if (
@@ -82,8 +85,9 @@ export const parseSlashCommand = (
commandToExecute: parentCommand,
args: parts.slice(pathIndex - 1).join(' '),
canonicalPath: canonicalPath.slice(0, -1),
extensionContext: parentCommand.extensionName,
};
}
return { commandToExecute, args, canonicalPath };
return { commandToExecute, args, canonicalPath, extensionContext };
};