* Extract client SDK package * Polish SDK client identity defaults * Build client before dependent CI jobs * Restore daemon client server export * Extract protocol and client SDK packages * Fix provider override schema validation * Fix app test daemon client imports * Simplify workspace build targets * Fix CLI test server build bootstrap * Run SDK package tests in CI * Fix rebase package split drift * Restore lockfile registry metadata * Update SDK config test for prompt default * Move terminal stream router test to client package * Fix rebase drift for protocol imports * Fix SDK agent capability fixture * Restore legacy server client exports * Fix server export compatibility test * Advertise custom mode icon client capability * Remove server daemon-client exports * Format rebased mode control import * Fix rebase drift for protocol imports Files added by upstream PRs (#893, #1147, #1154) referenced the pre-split shared/ paths that this branch moves into @getpaseo/protocol. Redirect those imports to the protocol package so typecheck stays green after the rebase.
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { readPaseoConfigJson } from "./paseo-config-file.js";
|
|
import { PaseoConfigSchema } from "@getpaseo/protocol/paseo-config-schema";
|
|
import { wrapWithUserInstructions } from "./wrap-user-instructions.js";
|
|
|
|
export type MetadataConfigKey = "agentTitle" | "branchName" | "commitMessage" | "pullRequest";
|
|
|
|
export interface RepoRootResolver {
|
|
resolveRepoRoot: (cwd: string) => Promise<string>;
|
|
}
|
|
|
|
export interface BuildMetadataPromptOptions {
|
|
cwd: string;
|
|
configKey: MetadataConfigKey;
|
|
before: string;
|
|
after: string;
|
|
trailing?: string;
|
|
workspaceGitService?: RepoRootResolver;
|
|
}
|
|
|
|
export async function buildMetadataPrompt(options: BuildMetadataPromptOptions): Promise<string> {
|
|
const instructions = await readProjectMetadataInstructions(options);
|
|
const head = isNonEmptyString(instructions)
|
|
? wrapWithUserInstructions(options.before, instructions, options.after)
|
|
: `${options.before}\n${options.after}`;
|
|
return options.trailing ? `${head}\n\n${options.trailing}` : head;
|
|
}
|
|
|
|
async function readProjectMetadataInstructions(
|
|
options: Pick<BuildMetadataPromptOptions, "cwd" | "configKey" | "workspaceGitService">,
|
|
): Promise<string | undefined> {
|
|
if (!options.workspaceGitService) {
|
|
return undefined;
|
|
}
|
|
try {
|
|
const repoRoot = await options.workspaceGitService.resolveRepoRoot(options.cwd);
|
|
const json = readPaseoConfigJson(repoRoot);
|
|
const config = PaseoConfigSchema.parse(json);
|
|
return config.metadataGeneration?.[options.configKey]?.instructions;
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|
|
|
|
function isNonEmptyString(value: unknown): value is string {
|
|
return typeof value === "string" && value.trim() !== "";
|
|
}
|