|
| 1 | +import { publisher } from './constants' |
| 2 | + |
| 3 | +import type { |
| 4 | + AgentDefinition, |
| 5 | + AgentStepContext, |
| 6 | +} from './types/agent-definition' |
| 7 | + |
| 8 | +const definition: AgentDefinition = { |
| 9 | + id: 'git-committer', |
| 10 | + displayName: 'Mitt the Git Committer', |
| 11 | + model: 'openai/gpt-5-nano', |
| 12 | + |
| 13 | + publisher, |
| 14 | + toolNames: ['read_files', 'run_terminal_command', 'add_message', 'end_turn'], |
| 15 | + |
| 16 | + inputSchema: { |
| 17 | + prompt: { |
| 18 | + type: 'string', |
| 19 | + description: 'What changes to commit', |
| 20 | + }, |
| 21 | + }, |
| 22 | + |
| 23 | + spawnerPrompt: |
| 24 | + 'Spawn when you need to commit code changes to git with an appropriate commit message', |
| 25 | + |
| 26 | + systemPrompt: |
| 27 | + 'You are an expert software developer. Your job is to create a git commit with a really good commit message.', |
| 28 | + |
| 29 | + instructionsPrompt: |
| 30 | + 'Follow the steps to create a good commit: analyze changes with git diff and git log, read relevant files for context, stage appropriate files, analyze changes, and create a commit with proper formatting.', |
| 31 | + |
| 32 | + stepPrompt: |
| 33 | + 'Continue the commit workflow: if needed, read relevant files for context; decide which files to stage and stage only related changes; draft a concise, imperative commit message focusing on why, then create a single commit including the Codebuff footer. Do not push and use end_turn when the commit is created.', |
| 34 | + |
| 35 | + handleSteps: function* ({ agentState, prompt, params }: AgentStepContext) { |
| 36 | + // Step 1: Run git diff and git log to analyze changes. |
| 37 | + yield { |
| 38 | + toolName: 'run_terminal_command', |
| 39 | + input: { |
| 40 | + command: 'git diff', |
| 41 | + process_type: 'SYNC', |
| 42 | + timeout_seconds: 30, |
| 43 | + }, |
| 44 | + } |
| 45 | + |
| 46 | + yield { |
| 47 | + toolName: 'run_terminal_command', |
| 48 | + input: { |
| 49 | + command: 'git log --oneline -10', |
| 50 | + process_type: 'SYNC', |
| 51 | + timeout_seconds: 30, |
| 52 | + }, |
| 53 | + } |
| 54 | + |
| 55 | + // Step 2: Put words in AI's mouth so it will read files next. |
| 56 | + yield { |
| 57 | + toolName: 'add_message', |
| 58 | + input: { |
| 59 | + role: 'assistant', |
| 60 | + content: |
| 61 | + "I've analyzed the git diff and recent commit history. Now I'll read any relevant files to better understand the context of these changes.", |
| 62 | + }, |
| 63 | + } |
| 64 | + |
| 65 | + // Step 3: Let AI generate a step to decide which files to read. |
| 66 | + yield 'STEP' |
| 67 | + |
| 68 | + // Step 4: Put words in AI's mouth to analyze the changes and create a commit. |
| 69 | + yield { |
| 70 | + toolName: 'add_message', |
| 71 | + input: { |
| 72 | + role: 'assistant', |
| 73 | + content: |
| 74 | + "Now I'll analyze the changes and create a commit with a good commit message.", |
| 75 | + }, |
| 76 | + } |
| 77 | + |
| 78 | + yield 'STEP_ALL' |
| 79 | + }, |
| 80 | +} |
| 81 | + |
| 82 | +export default definition |
0 commit comments