scripts: b/job accepts args as instruction and stdin as content when both present
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e6d41e36da
commit
ea58313f94
23
doc/USAGE.md
23
doc/USAGE.md
|
|
@ -99,22 +99,13 @@ Valid spec keys: `name` (auto-generated if omitted), `cwd` (required), `agent`,
|
||||||
|
|
||||||
## AI pipelines
|
## AI pipelines
|
||||||
|
|
||||||
`b/q` reads its prompt from args or stdin — not both. When args are present, stdin is
|
`b/q` and `b/job` write to stdout and compose naturally with Unix pipes. When both args
|
||||||
ignored. This shapes how pipelines compose:
|
and stdin are present, args are treated as the instruction and stdin as the content:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# prompt from stdin: works
|
echo "write a haiku about filesystems" | $OLLIE/b/q | wc -w
|
||||||
echo "write a haiku about filesystems" | $OLLIE/b/q
|
cat error.log | $OLLIE/b/q "what is causing this?" | $OLLIE/b/q "suggest a fix"
|
||||||
|
$OLLIE/b/q "list 5 blog post ideas" | grep -v "^$" | head -3 | $OLLIE/b/q "expand the best one"
|
||||||
# pipe b/q output through shell tools, then into another b/q via stdin
|
|
||||||
$OLLIE/b/q "list 5 blog post ideas" | grep -v "^$" | head -3 | $OLLIE/b/q
|
|
||||||
|
|
||||||
# capture output, build next prompt explicitly
|
|
||||||
ideas=$($OLLIE/b/q "list 5 blog post ideas" | grep -v "^$" | head -3)
|
|
||||||
$OLLIE/b/q "expand the best of these ideas: $ideas"
|
|
||||||
|
|
||||||
# pipe file content as the prompt
|
|
||||||
cat error.log | $OLLIE/b/q
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`u/optimize` is a worked example — it generates N candidate prompts in parallel via
|
`u/optimize` is a worked example — it generates N candidate prompts in parallel via
|
||||||
|
|
@ -124,11 +115,11 @@ cat error.log | $OLLIE/b/q
|
||||||
$OLLIE/u/optimize -n 3 -cm qwen/qwen3-8b -jm anthropic/claude-opus-4-6 "explain recursion"
|
$OLLIE/u/optimize -n 3 -cm qwen/qwen3-8b -jm anthropic/claude-opus-4-6 "explain recursion"
|
||||||
```
|
```
|
||||||
|
|
||||||
Progress goes to stderr; capture the output to use in a subsequent call:
|
Progress goes to stderr; pipe the optimized prompt with content into a subsequent call:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
prompt=$($OLLIE/u/optimize "translate this to Spanish" 2>/dev/null)
|
prompt=$($OLLIE/u/optimize "translate this to Spanish" 2>/dev/null)
|
||||||
{ echo "$prompt"; cat document.txt; } | $OLLIE/b/q
|
cat document.txt | $OLLIE/b/q "$prompt"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Alternative front-ends
|
## Alternative front-ends
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,10 @@ while [ $# -gt 0 ]; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# Prompt from remaining args or stdin.
|
# Prompt from args, stdin, or both (args as instruction, stdin as content).
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ] && ! [ -t 0 ]; then
|
||||||
|
prompt="$*"$'\n'"$(cat)"
|
||||||
|
elif [ $# -gt 0 ]; then
|
||||||
prompt="$*"
|
prompt="$*"
|
||||||
elif ! [ -t 0 ]; then
|
elif ! [ -t 0 ]; then
|
||||||
prompt=$(cat)
|
prompt=$(cat)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue