chore(vendor): import pi 0.85.1
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
43
third_party/pi/packages/coding-agent/src/cli/initial-message.ts
vendored
Normal file
43
third_party/pi/packages/coding-agent/src/cli/initial-message.ts
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { ImageContent } from "@earendil-works/pi-ai";
|
||||
import type { Args } from "./args.ts";
|
||||
|
||||
export interface InitialMessageInput {
|
||||
parsed: Args;
|
||||
fileText?: string;
|
||||
fileImages?: ImageContent[];
|
||||
stdinContent?: string;
|
||||
}
|
||||
|
||||
export interface InitialMessageResult {
|
||||
initialMessage?: string;
|
||||
initialImages?: ImageContent[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine stdin content, @file text, and the first CLI message into a single
|
||||
* initial prompt for non-interactive mode.
|
||||
*/
|
||||
export function buildInitialMessage({
|
||||
parsed,
|
||||
fileText,
|
||||
fileImages,
|
||||
stdinContent,
|
||||
}: InitialMessageInput): InitialMessageResult {
|
||||
const parts: string[] = [];
|
||||
if (stdinContent !== undefined) {
|
||||
parts.push(stdinContent);
|
||||
}
|
||||
if (fileText) {
|
||||
parts.push(fileText);
|
||||
}
|
||||
|
||||
if (parsed.messages.length > 0) {
|
||||
parts.push(parsed.messages[0]);
|
||||
parsed.messages.shift();
|
||||
}
|
||||
|
||||
return {
|
||||
initialMessage: parts.length > 0 ? parts.join("") : undefined,
|
||||
initialImages: fileImages && fileImages.length > 0 ? fileImages : undefined,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user