gut-cli 0.1.23 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -28
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +9 -20
- package/dist/lib/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -479,6 +479,10 @@ async function generateCommitMessage(diff, options, template) {
|
|
|
479
479
|
});
|
|
480
480
|
return result.text.trim();
|
|
481
481
|
}
|
|
482
|
+
var PRDescriptionSchema = z.object({
|
|
483
|
+
title: z.string().describe("Concise PR title (50-72 chars)"),
|
|
484
|
+
body: z.string().describe("PR description in markdown format")
|
|
485
|
+
});
|
|
482
486
|
async function generatePRDescription(context, options, template) {
|
|
483
487
|
const model = await getModel(options);
|
|
484
488
|
const prompt = buildPrompt(
|
|
@@ -490,29 +494,14 @@ async function generatePRDescription(context, options, template) {
|
|
|
490
494
|
commits: context.commits.map((c) => `- ${c}`).join("\n"),
|
|
491
495
|
diff: context.diff.slice(0, 6e3)
|
|
492
496
|
},
|
|
493
|
-
options.language
|
|
494
|
-
`Respond in JSON format:
|
|
495
|
-
\`\`\`json
|
|
496
|
-
{
|
|
497
|
-
"title": "...",
|
|
498
|
-
"body": "..."
|
|
499
|
-
}
|
|
500
|
-
\`\`\``
|
|
497
|
+
options.language
|
|
501
498
|
);
|
|
502
|
-
const result = await
|
|
499
|
+
const result = await generateObject({
|
|
503
500
|
model,
|
|
504
|
-
|
|
505
|
-
|
|
501
|
+
schema: PRDescriptionSchema,
|
|
502
|
+
prompt
|
|
506
503
|
});
|
|
507
|
-
|
|
508
|
-
const cleaned = result.text.replace(/```json\n?|\n?```/g, "").trim();
|
|
509
|
-
return JSON.parse(cleaned);
|
|
510
|
-
} catch {
|
|
511
|
-
return {
|
|
512
|
-
title: context.currentBranch.replace(/[-_]/g, " "),
|
|
513
|
-
body: result.text
|
|
514
|
-
};
|
|
515
|
-
}
|
|
504
|
+
return result.object;
|
|
516
505
|
}
|
|
517
506
|
var CodeReviewSchema = z.object({
|
|
518
507
|
summary: z.string().describe("Brief overall assessment"),
|
|
@@ -2418,16 +2407,22 @@ ${body}`;
|
|
|
2418
2407
|
if (answer.toLowerCase() === "y") {
|
|
2419
2408
|
const createSpinner = ora11("Creating PR...").start();
|
|
2420
2409
|
try {
|
|
2421
|
-
const escapedTitle = title.replace(/"/g, '\\"');
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
);
|
|
2410
|
+
const escapedTitle = title.replace(/"/g, '\\"').replace(/`/g, "\\`").replace(/\$/g, "\\$");
|
|
2411
|
+
execSync7(`gh pr create --title "${escapedTitle}" --body-file - --base ${baseBranch}`, {
|
|
2412
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
2413
|
+
input: body
|
|
2414
|
+
});
|
|
2427
2415
|
createSpinner.succeed("PR created successfully!");
|
|
2428
|
-
} catch {
|
|
2416
|
+
} catch (err) {
|
|
2429
2417
|
createSpinner.fail("Failed to create PR");
|
|
2430
|
-
|
|
2418
|
+
if (err instanceof Error && "stderr" in err) {
|
|
2419
|
+
const stderr = err.stderr?.toString?.() || "";
|
|
2420
|
+
if (stderr.includes("auth")) {
|
|
2421
|
+
console.error(chalk15.gray("Make sure gh CLI is authenticated: gh auth login"));
|
|
2422
|
+
} else if (stderr) {
|
|
2423
|
+
console.error(chalk15.red(stderr.trim()));
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2431
2426
|
}
|
|
2432
2427
|
} else if (!options.copy) {
|
|
2433
2428
|
console.log(chalk15.gray("\nTip: Use --copy to copy to clipboard"));
|