summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx14
-rw-r--r--packages/opencode/src/session/prompt.ts7
2 files changed, 17 insertions, 4 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
index 730da20c2..e19c8b709 100644
--- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
+++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
@@ -546,16 +546,22 @@ export function Prompt(props: PromptProps) {
} else if (
inputText.startsWith("/") &&
iife(() => {
- const command = inputText.split(" ")[0].slice(1)
- console.log(command)
+ const firstLine = inputText.split("\n")[0]
+ const command = firstLine.split(" ")[0].slice(1)
return sync.data.command.some((x) => x.name === command)
})
) {
- let [command, ...args] = inputText.split(" ")
+ // Parse command from first line, preserve multi-line content in arguments
+ const firstLineEnd = inputText.indexOf("\n")
+ const firstLine = firstLineEnd === -1 ? inputText : inputText.slice(0, firstLineEnd)
+ const [command, ...firstLineArgs] = firstLine.split(" ")
+ const restOfInput = firstLineEnd === -1 ? "" : inputText.slice(firstLineEnd + 1)
+ const args = firstLineArgs.join(" ") + (restOfInput ? "\n" + restOfInput : "")
+
sdk.client.session.command({
sessionID,
command: command.slice(1),
- arguments: args.join(" "),
+ arguments: args,
agent: local.agent.current().name,
model: `${selectedModel.providerID}/${selectedModel.modelID}`,
messageID,
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index 9dbca30d8..9325583ac 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -1627,8 +1627,15 @@ NOTE: At any point in time through this workflow you should feel free to ask the
if (position === last) return args.slice(argIndex).join(" ")
return args[argIndex]
})
+ const usesArgumentsPlaceholder = templateCommand.includes("$ARGUMENTS")
let template = withArgs.replaceAll("$ARGUMENTS", input.arguments)
+ // If command doesn't explicitly handle arguments (no $N or $ARGUMENTS placeholders)
+ // but user provided arguments, append them to the template
+ if (placeholders.length === 0 && !usesArgumentsPlaceholder && input.arguments.trim()) {
+ template = template + "\n\n" + input.arguments
+ }
+
const shell = ConfigMarkdown.shell(template)
if (shell.length > 0) {
const results = await Promise.all(