Skip to content

Instantly share code, notes, and snippets.

@meoyawn
Last active July 12, 2026 12:15
Show Gist options
  • Select an option

  • Save meoyawn/a536c1f498bbe4a8309fad597f9d0b70 to your computer and use it in GitHub Desktop.

Select an option

Save meoyawn/a536c1f498bbe4a8309fad597f9d0b70 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bun
import { $ } from "bun";
const prompt =
"Generate a concise Git commit message for the staged diff. Plain text only. Imperative subject; body only if useful.";
async function main(): Promise<0 | 1> {
await $`git add -A -- .`;
const diff = await $`git diff --cached --no-ext-diff --no-color`.text();
if (diff.length === 0) {
console.error("No changes to commit after git add -A.");
return 1;
}
console.log("Generating commit msg...");
const message =
await $`${import.meta.dir}/gpt.ts -m gpt-5.3-codex-spark -c model_reasoning_effort=low ${prompt} < ${new Response(diff)}`.text();
if (message.trim().length === 0) {
console.error("Codex produced an empty commit message.");
return 1;
}
console.log(`Commit message:\n${message.trimEnd()}\n`);
await $`git commit -F - < ${new Response(message)}`;
return 0;
}
if (import.meta.main) {
process.exit(await main());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment