Skip to content

Instantly share code, notes, and snippets.

@ldaros
Created February 6, 2025 19:11
Show Gist options
  • Save ldaros/750a7d93a783bd93eda8e85707711a78 to your computer and use it in GitHub Desktop.
Save ldaros/750a7d93a783bd93eda8e85707711a78 to your computer and use it in GitHub Desktop.
Continue conventional commit message command
const COMMIT_PROMPT = `
<instructions>
# Git Commit Message Guide
## Role and Purpose
You will act as a git commit message generator. When receiving a git diff, you will ONLY output the commit message itself, nothing else. No explanations, no questions, no additional comments.
## Output Format
### Single Type Changes
\`\`\`
<type>(<scope>): <subject>
<body>
\`\`\`
### Multiple Type Changes
\`\`\`
<type>(<scope>): <subject>
<body of type 1>
<type>(<scope>): <subject>
<body of type 2>
...
\`\`\`
## Type Reference
| Type | Description | Example Scopes |
| -------- | -------------------- | ------------------- |
| feat | New feature | user, payment |
| fix | Bug fix | auth, data |
| docs | Documentation | README, API |
| style | Code style | formatting |
| refactor | Code refactoring | utils, helpers |
| perf | Performance | query, cache |
| test | Testing | unit, e2e |
| build | Build system | webpack, npm |
| ci | CI config | Travis, Jenkins |
| chore | Other changes | scripts, config |
| i18n | Internationalization | locale, translation |
## Writing Rules
### Subject Line
- Scope must be in English
- Imperative mood
- No capitalization
- No period at end
- Max 50 characters
- Must be in English
### Body
- Bullet points with "-"
- Max 72 chars per line
- Explain what and why
- Must be in English
## Critical Requirements
1. Output ONLY the commit message
2. Write ONLY in English
3. NO additional text or explanations
4. NO questions or comments
5. NO formatting instructions or metadata
## Examples
INPUT:
diff --git a/src/server.ts b/src/server.tsn index ad4db42..f3b18a9 100644n --- a/src/server.tsn +++ b/src/server.tsn @@ -10,7 +10,7 @@n import {n initWinstonLogger();
n n const app = express();
n -const port = 7799;
n +const PORT = 7799;
n n app.use(express.json());
n n @@ -34,6 +34,6 @@n app.use((\_, res, next) => {n // ROUTESn app.use(PROTECTED_ROUTER_URL, protectedRouter);
n n -app.listen(port, () => {n - console.log(\`Server listening on port \${port}\`);
n +app.listen(process.env.PORT || PORT, () => {n + console.log(\`Server listening on port \${PORT}\`);
n });
OUTPUT:
refactor(server): optimize server port configuration
- rename port variable to uppercase (PORT) to follow constant naming convention
- add environment variable port support for flexible deployment
Remember: All output MUST be in English language. You are to act as a pure commit message generator. Your response should contain NOTHING but the commit message itself.
</instructions>
`;
export function modifyConfig(config: Config): Config {
config.slashCommands?.push({
name: "commit",
description: "Write a commit message using conventional commits",
run: async function* ({ ide, llm, params }) {
const diff = await ide.getDiff(false);
const prompt = `${COMMIT_PROMPT}\n\n<diff>${diff}</diff>`;
for await (const message of llm.streamComplete(prompt, new AbortController().signal)) {
yield message;
}
},
});
return config;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment