feat: add pi CLI support and clis prompt terminal command#11
Open
ducphamhoang wants to merge 1 commit into
Open
feat: add pi CLI support and clis prompt terminal command#11ducphamhoang wants to merge 1 commit into
ducphamhoang wants to merge 1 commit into
Conversation
Adds two new capabilities: 1. pi (https://pi.dev) as a fourth supported agent tool 2. clis prompt command for terminal-based agent interaction --- Pi CLI integration --- Session lifecycle verified live against pi 0.75.5: 1. pi starts and auto-generates a session UUID 2. /session command outputs "ID: <uuid>" — captured via status-command mode 3. Resume uses pi --session <uuid> Schema & config: - newSessionCommand field added to runner template types and Zod schemas - pi registered as a valid agentCLITool with default template (create.mode=runner, capture via /session, resume via --session) Session routing: - pi uses status-command capture (same as codex/gemini), so it participates in standard live rotation — no special routing needed - retryFreshStartAfterStoredResumeFailure gate handles create.mode=runner so pi sessions survive crash recovery Transcript normalization: - looksLikePiSnapshot: detects pi output; excludes bare > to avoid false positives with shell prompts - shouldDropPiChromeLine: drops pi help-bar and working-status chrome while preserving Warning/Note content - dropPiPromptBlocks: strips prompt echo blocks pi re-emits before AI responses Also fixes: - buildRunnerFromToolTemplate: preserve per-element resume args for non-codex runners (was incorrectly flattening arrays) - Guard isPi detection against collision with Gemini output patterns Tests: 54 chrome normalization tests, session routing tests, startup blocker coverage, schema defaults tests. --- clis prompt command --- New command for sending a message to a running agent from the terminal and receiving the response on stdout without needing Slack or Telegram. clis prompt --agent <id> --message <text> [--stream] [--json] - control/prompt-cli.ts: runPromptCli using buildSteeringPromptText - cli.ts / main.ts: prompt command added to CLI routing - auth/resolve.ts: terminal:senderId principal resolved correctly - channels/rendering.ts: plain-text renderer for terminal platform - test/prompt-cli.test.ts: 12 tests covering auth, rendering, help output --- Standalone fixes --- - runner-exit-diagnostics.ts: use process.execPath instead of bare node so the exit-record writer works in nvm-managed environments where node may not be in PATH inside tmux sessions - runner-exit-diagnostics.ts: fix shellQuote single-quote escape sequence Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clis promptcommand for terminal-based agent interaction without Slack/Telegramprocess.execPathbug in runner launch that broke exit-record writing in nvm environmentsPi CLI integration
Session lifecycle (verified live against pi 0.75.5)
Pi's
/sessioncommand outputs the current session ID, so it uses the existingstatus-commandcapture mechanism — no new infrastructure required.Schema & config
newSessionCommandfield added to runner template types and Zod schemas, resolved through the standard template override chainpiregistered as a validagentCLIToolwith default template (create.mode=runner,capture.statusCommand=/session,resume via --session)Session routing (
runner-service.ts)/session(same pattern as codex/gemini), so it participates in standard live rotation — no special routing bypass neededretryFreshStartAfterStoredResumeFailuregate already handlescreate.mode=runner, so pi sessions survive crash recovery with no changesTranscript normalization
looksLikePiSnapshot: detects pi output; excludes bare>to avoid false positives with shell promptsshouldDropPiChromeLine: drops pi help-bar and working-status chrome while preserving Warning/Note contentdropPiPromptBlocks: strips prompt echo blocks that pi re-emits before AI responsesAlso fixes
buildRunnerFromToolTemplate: preserve per-element resume args for non-codex runners (was incorrectly flattening arrays)isPidetection against collision with Gemini output patternsTests: 54 chrome normalization tests, session routing tests, startup blocker coverage, schema defaults tests
clis prompt command
New
clis promptCLI command for sending a message to a running clisbot agent from the terminal and receiving the response on stdout — useful for scripting and local dev without a Slack or Telegram surface.src/control/prompt-cli.ts:runPromptCliusingbuildSteeringPromptTextcli.ts/main.ts:promptcommand added to CLI routingauth/resolve.ts:terminal:senderIdprincipal resolved correctlychannels/rendering.ts: plain-text renderer for terminal platform (no Slack/Telegram decorators)test/prompt-cli.test.ts: 12 tests covering auth principal, rendering, and help outputStandalone fixes
process.execPathin runner launch (runner-exit-diagnostics.ts): barenodeis not guaranteed to be in PATH inside tmux when using nvm. Usingprocess.execPathensures the exit-record writer uses the same Node binary running clisbot.shellQuoteescape fix: single-quote escape was'\"'\"'(incorrect), now'"'"'(correct POSIX).Test plan
bun test test/text/text-cleaning-chrome.suite.ts— 54 pi chrome normalization tests passbun test test/runner-service.integration.test.ts— pi session and routing tests passbun test test/prompt-cli.test.ts— 12 terminal prompt tests passbun run check— full typecheck + test suite passes🤖 Generated with Claude Code