Collapse the CLI Access shell snippet's curl call onto one line

The multi-line backslash-continued curl command was fragile to
copy/paste: a trailing space after \ or a dropped backslash (both
common when pasting a multi-line snippet out of a chat UI or browser)
silently breaks the continuation, so each following line gets parsed
as its own bogus command instead of a curl flag - exactly what Rune
hit ("command not found: -H", "-d", "no such file or directory:
http://localhost/") after pasting the previous version. A long single
line has no continuation character left to mangle.
This commit is contained in:
2026-08-14 11:06:05 +02:00
parent 35b5b09c6d
commit 7527cc4091
+5 -4
View File
@@ -1242,12 +1242,13 @@ It's better to admit "I need more information" or "I cannot do that" than to fak
// function call. Quoting the prompt is still the fully robust habit for other shell metacharacters
// (`;`, `|`, backticks, `$()`), but this covers the specific class of crash users are most likely
// to hit by accident (an unquoted question ending in "?").
// Deliberately one line, no backslash continuations: a `\` line-continuation is silently
// broken by a trailing space or a dropped backslash from copy/pasting out of a chat UI or
// browser each following line then gets parsed as its own bogus command ("command not
// found: -H", etc.). A long single line has no continuation character to mangle.
private static let cliShellFunctionSnippet = """
_ai_impl() {
curl -s --unix-socket "$HOME/Library/Application Support/oAI/cli.sock" \\
-H "Content-Type: application/json" \\
-d "$(jq -n --arg p "$*" '{prompt: $p}')" \\
http://localhost/ | jq -r 'if .error then "Error: " + .error else .response end'
curl -s --unix-socket "$HOME/Library/Application Support/oAI/cli.sock" -H "Content-Type: application/json" -d "$(jq -n --arg p "$*" '{prompt: $p}')" http://localhost/ | jq -r 'if .error then "Error: " + .error else .response end'
}
alias ai='noglob _ai_impl'
"""