diff --git a/doc/USAGE.md b/doc/USAGE.md index f4fc913..cbc7641 100644 --- a/doc/USAGE.md +++ b/doc/USAGE.md @@ -99,22 +99,13 @@ Valid spec keys: `name` (auto-generated if omitted), `cwd` (required), `agent`, ## AI pipelines -`b/q` reads its prompt from args or stdin — not both. When args are present, stdin is -ignored. This shapes how pipelines compose: +`b/q` and `b/job` write to stdout and compose naturally with Unix pipes. When both args +and stdin are present, args are treated as the instruction and stdin as the content: ```sh -# prompt from stdin: works -echo "write a haiku about filesystems" | $OLLIE/b/q - -# 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 +echo "write a haiku about filesystems" | $OLLIE/b/q | wc -w +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" ``` `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" ``` -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 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 diff --git a/scripts/b/job b/scripts/b/job index 8d234dd..b3eb2b8 100755 --- a/scripts/b/job +++ b/scripts/b/job @@ -64,8 +64,10 @@ while [ $# -gt 0 ]; do shift done -# Prompt from remaining args or stdin. -if [ $# -gt 0 ]; then +# Prompt from args, stdin, or both (args as instruction, stdin as content). +if [ $# -gt 0 ] && ! [ -t 0 ]; then + prompt="$*"$'\n'"$(cat)" +elif [ $# -gt 0 ]; then prompt="$*" elif ! [ -t 0 ]; then prompt=$(cat)