summaryrefslogtreecommitdiff
path: root/packages/cli/src/services/FileCommandLoader.ts
diff options
context:
space:
mode:
authorAbhi <[email protected]>2025-08-17 00:02:54 -0400
committerGitHub <[email protected]>2025-08-17 04:02:54 +0000
commit33b9bdb11e9371dfa6891ba1be47a12b958f493d (patch)
tree46ac192df7dd2aeaf35cb5eef5c121bc5decada9 /packages/cli/src/services/FileCommandLoader.ts
parente7dbc607a598c5270507d0ce7d55a3c98dcb0c0c (diff)
feat(cli): Introduce arguments for shell execution in custom commands (#5966)
Diffstat (limited to 'packages/cli/src/services/FileCommandLoader.ts')
-rw-r--r--packages/cli/src/services/FileCommandLoader.ts22
1 files changed, 12 insertions, 10 deletions
diff --git a/packages/cli/src/services/FileCommandLoader.ts b/packages/cli/src/services/FileCommandLoader.ts
index 5b8d8c42..2942a8b9 100644
--- a/packages/cli/src/services/FileCommandLoader.ts
+++ b/packages/cli/src/services/FileCommandLoader.ts
@@ -21,10 +21,7 @@ import {
SlashCommand,
SlashCommandActionReturn,
} from '../ui/commands/types.js';
-import {
- DefaultArgumentProcessor,
- ShorthandArgumentProcessor,
-} from './prompt-processors/argumentProcessor.js';
+import { DefaultArgumentProcessor } from './prompt-processors/argumentProcessor.js';
import {
IPromptProcessor,
SHORTHAND_ARGS_PLACEHOLDER,
@@ -224,16 +221,21 @@ export class FileCommandLoader implements ICommandLoader {
}
const processors: IPromptProcessor[] = [];
+ const usesArgs = validDef.prompt.includes(SHORTHAND_ARGS_PLACEHOLDER);
+ const usesShellInjection = validDef.prompt.includes(
+ SHELL_INJECTION_TRIGGER,
+ );
- // Add the Shell Processor if needed.
- if (validDef.prompt.includes(SHELL_INJECTION_TRIGGER)) {
+ // Interpolation (Shell Execution and Argument Injection)
+ // If the prompt uses either shell injection OR argument placeholders,
+ // we must use the ShellProcessor.
+ if (usesShellInjection || usesArgs) {
processors.push(new ShellProcessor(baseCommandName));
}
- // The presence of '{{args}}' is the switch that determines the behavior.
- if (validDef.prompt.includes(SHORTHAND_ARGS_PLACEHOLDER)) {
- processors.push(new ShorthandArgumentProcessor());
- } else {
+ // Default Argument Handling
+ // If NO explicit argument injection ({{args}}) was used, we append the raw invocation.
+ if (!usesArgs) {
processors.push(new DefaultArgumentProcessor());
}