mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-05 16:04:43 +00:00
Improve daemon RPC resiliency and diff handling
This commit is contained in:
@@ -1987,7 +1987,11 @@ export class Session {
|
||||
}
|
||||
|
||||
private async generateCommitMessage(cwd: string): Promise<string> {
|
||||
const diff = await getCheckoutDiff(cwd, { mode: "uncommitted" }, { paseoHome: this.paseoHome });
|
||||
const diff = await getCheckoutDiff(
|
||||
cwd,
|
||||
{ mode: "uncommitted", includeStructured: true },
|
||||
{ paseoHome: this.paseoHome }
|
||||
);
|
||||
const schema = z.object({
|
||||
message: z
|
||||
.string()
|
||||
@@ -1995,11 +1999,29 @@ export class Session {
|
||||
.max(72)
|
||||
.describe("Concise git commit message, imperative mood, no trailing period."),
|
||||
});
|
||||
const fileList =
|
||||
diff.structured && diff.structured.length > 0
|
||||
? [
|
||||
"Files changed:",
|
||||
...diff.structured.map((file) => {
|
||||
const changeType = file.isNew ? "A" : file.isDeleted ? "D" : "M";
|
||||
const status = file.status && file.status !== "ok" ? ` [${file.status}]` : "";
|
||||
return `${changeType}\t${file.path}\t(+${file.additions} -${file.deletions})${status}`;
|
||||
}),
|
||||
].join("\n")
|
||||
: "Files changed: (unknown)";
|
||||
const maxPatchChars = 120_000;
|
||||
const patch =
|
||||
diff.diff.length > maxPatchChars
|
||||
? `${diff.diff.slice(0, maxPatchChars)}\n\n... (diff truncated to ${maxPatchChars} chars)\n`
|
||||
: diff.diff;
|
||||
const prompt = [
|
||||
"Write a concise git commit message for the changes below.",
|
||||
"Return JSON only with a single field 'message'.",
|
||||
"",
|
||||
diff.diff.length > 0 ? diff.diff : "(No diff available)",
|
||||
fileList,
|
||||
"",
|
||||
patch.length > 0 ? patch : "(No diff available)",
|
||||
].join("\n");
|
||||
try {
|
||||
const result = await generateStructuredAgentResponse({
|
||||
@@ -2034,6 +2056,7 @@ export class Session {
|
||||
{
|
||||
mode: "base",
|
||||
baseRef,
|
||||
includeStructured: true,
|
||||
},
|
||||
{ paseoHome: this.paseoHome }
|
||||
);
|
||||
@@ -2041,11 +2064,29 @@ export class Session {
|
||||
title: z.string().min(1).max(72),
|
||||
body: z.string().min(1),
|
||||
});
|
||||
const fileList =
|
||||
diff.structured && diff.structured.length > 0
|
||||
? [
|
||||
"Files changed:",
|
||||
...diff.structured.map((file) => {
|
||||
const changeType = file.isNew ? "A" : file.isDeleted ? "D" : "M";
|
||||
const status = file.status && file.status !== "ok" ? ` [${file.status}]` : "";
|
||||
return `${changeType}\t${file.path}\t(+${file.additions} -${file.deletions})${status}`;
|
||||
}),
|
||||
].join("\n")
|
||||
: "Files changed: (unknown)";
|
||||
const maxPatchChars = 200_000;
|
||||
const patch =
|
||||
diff.diff.length > maxPatchChars
|
||||
? `${diff.diff.slice(0, maxPatchChars)}\n\n... (diff truncated to ${maxPatchChars} chars)\n`
|
||||
: diff.diff;
|
||||
const prompt = [
|
||||
"Write a pull request title and body for the changes below.",
|
||||
"Return JSON only with fields 'title' and 'body'.",
|
||||
"",
|
||||
diff.diff.length > 0 ? diff.diff : "(No diff available)",
|
||||
fileList,
|
||||
"",
|
||||
patch.length > 0 ? patch : "(No diff available)",
|
||||
].join("\n");
|
||||
try {
|
||||
return await generateStructuredAgentResponse({
|
||||
|
||||
Reference in New Issue
Block a user