mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
* docs(coding-agent): improve getting started documentation * docs(coding-agent): correct getting started details * docs(coding-agent): clarify SDK entry point * docs(coding-agent): restructure guides and references * docs(coding-agent): improve getting started guides * docs(coding-agent): refresh integration guides * docs(coding-agent): improve terminal and CLI guides * docs(coding-agent): refresh customisation guides * docs(coding-agent): clarify project trust terminology * docs(coding-agent): simplify customisation guidance * docs(coding-agent): improve runtime and reference guidance * Fix settings reference * feat(coding-agent): add Crowdin documentation sync * docs(coding-agent): separate CLI and slash command references * docs(coding-agent): correct compaction reference * docs(coding-agent): streamline package documentation * docs(coding-agent): split RPC reference documentation * Update configuration docs * Shorten config docs * docs(coding-agent): refine configuration references * docs(coding-agent): streamline settings reference * docs(coding-agent): clarify configuration reference * docs(coding-agent): clarify project trust exception * docs(coding-agent): simplify keybindings reference * docs(coding-agent): remove Crowdin integration * docs(coding-agent): turn themes reference into guide * docs(coding-agent): consolidate model and authentication docs * docs(tui): require Component.invalidate() (fixes #9358) * docs(coding-agent): document offline catalog behavior (fixes #8684) * docs(coding-agent): preserve established documentation routes * docs(coding-agent): reorganize documentation navigation * docs(coding-agent): correct audited behavior Clarify provider, session, local-model, Termux, TUI, SDK, debug, and extension behavior. Simplify the documentation audit to report only clear user-visible contradictions. * docs(coding-agent): fix broken documentation links
35 lines
1 KiB
TypeScript
35 lines
1 KiB
TypeScript
/**
|
|
* Run one prompt through a Pi RPC child process.
|
|
*
|
|
* Build the coding-agent package first, then run:
|
|
* npx tsx examples/rpc-client.ts "Explain this repository"
|
|
*/
|
|
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { RpcClient } from "@earendil-works/pi-coding-agent";
|
|
|
|
const exampleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
const prompt = process.argv.slice(2).join(" ") || "Explain this repository in one paragraph.";
|
|
|
|
const client = new RpcClient({
|
|
cliPath: join(exampleDirectory, "../dist/cli.js"),
|
|
args: ["--no-session"],
|
|
});
|
|
|
|
const unsubscribe = client.onEvent((event) => {
|
|
if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
|
|
process.stdout.write(event.assistantMessageEvent.delta);
|
|
} else if (event.type === "tool_execution_start") {
|
|
process.stderr.write(`\n[tool: ${event.toolName}]\n`);
|
|
}
|
|
});
|
|
|
|
try {
|
|
await client.start();
|
|
await client.promptAndWait(prompt);
|
|
process.stdout.write("\n");
|
|
} finally {
|
|
unsubscribe();
|
|
await client.stop();
|
|
}
|