(p: StyleProfile | null)
| 180 | |
| 181 | /** Build the compact system-prompt block. Empty when confidence is too low to bother. */ |
| 182 | export function buildStyleBlock(p: StyleProfile | null): string { |
| 183 | if (!p || p.confidence < 0.2) return ''; |
| 184 | const indent = p.indent.type === 'tab' ? 'tabs' : `${p.indent.width}-space`; |
| 185 | const lines = [ |
| 186 | '# Code style (match the project)', |
| 187 | '', |
| 188 | `Write new code in this project's existing style — inferred from its source${p.fromEditorConfig ? ' + .editorconfig' : ''}:`, |
| 189 | `- Indentation: ${indent}`, |
| 190 | `- Strings: ${p.quotes === 'mixed' ? 'mixed (match the file you edit)' : p.quotes + ' quotes'}`, |
| 191 | `- Semicolons: ${p.semicolons ? 'yes' : 'no (omit them)'}`, |
| 192 | `- Identifiers: ${p.naming === 'mixed' ? 'match the surrounding file' : p.naming}`, |
| 193 | 'Follow the project\'s linter/formatter config if one exists; when in doubt, match the file you are editing.', |
| 194 | ]; |
| 195 | return lines.join('\n'); |
| 196 | } |
no outgoing calls
no test coverage detected