136
137
private _buildCommitMessagePrompt(workingDirectory: URI, branchName: string | undefined, diffs: readonly ISessionFileDiff[]): { role: 'system' | 'user'; content: string }[] {
139
>
return [
140
>
{
141
>
role: 'system',
142
>
content: [
143
>
'You generate concise Git commit messages.',
144
>
'Return only the commit message text, with no markdown or code fences.',
145
>
'Use imperative mood. Keep the subject line under 72 characters.',
146
>
'Add a body only when it helps explain multiple related changes.',
147
>
].join(' '),
148
>
},
149
>
{
150
>
role: 'user',
151
>
content: [
152
>
`Repository: ${basename(workingDirectory)}`,
153
>
`Branch: ${branchName ?? 'unknown'}`,
154
>
'Changed files:',
155
>
changeSummary,
156
>
].join('\n'),
157
>
},
158
>
];
159
>
}
160
161
private _summarizeDiffsForPrompt(diffs: readonly ISessionFileDiff[]): string {
163
>
for (const diff of diffs) {
164
>
const before = diff.before?.uri;
165
>
const after = diff.after?.uri;
166
>
const path = after ?? before ?? '(unknown)';
167
>
let kind = 'Edit';
168
>
if (!before && after) {
169
>
kind = 'Create';
170
>
} else if (before && !after) {
171
kind = 'Delete';
172
} else if (before && after && before !== after) {
173
kind = 'Rename';
174
}
176
>
if (lines.join('\n').length > MAX_CHANGE_SUMMARY_PROMPT_CHARS) {
177
lines.push('[file list truncated]');
178
break;
179
}
181
>
return lines.join('\n');
182
>
}
183
184
private _displayUri(uri: string): string {
186
>
const parsed = URI.parse(uri);
187
>
return parsed.scheme === 'file' ? parsed.fsPath : parsed.path || uri;
188
>
} catch {
189
return uri;
190
}
192
193
private _cleanCommitMessage(raw: string): string {