|
| 1 | +import * as vscode from 'vscode' |
| 2 | +import * as fs from 'fs' |
| 3 | +import * as path from 'path' |
| 4 | +import Logger from '../common/logger' |
| 5 | + |
| 6 | +type Workflow = { |
| 7 | + name: string |
| 8 | + description: string |
| 9 | + content: string |
| 10 | +} |
| 11 | + |
| 12 | +const workflows: Workflow[] = [ |
| 13 | + { |
| 14 | + name: 'codacy-fix-issues', |
| 15 | + description: 'Find and fix issues in your project using Codacy local analysis', |
| 16 | + content: ` |
| 17 | +If the user gave you files as context: |
| 18 | +
|
| 19 | +1. Run the 'codacy_cli_analyze' tool for each of the files given as context, with the following params: |
| 20 | + - rootPath: set to the workspace path |
| 21 | + - file: set to the path of the file |
| 22 | + - tool: leave empty or unset |
| 23 | +2. If any issues are found in the files, propose and apply fixes for them. |
| 24 | +3. If you encounter that Codacy is applying a tool to the project that it shouldn't, don't try to find the configuration of Codacy, just let the user know it's a false positive issue. |
| 25 | +
|
| 26 | +If the user didn't provide any files as context: |
| 27 | +
|
| 28 | +1. Ask the user which files they want to analyse. |
| 29 | +2. Analyse the files they answer with by running 'codacy_cli_analyze' tool for each file, with the following params: |
| 30 | + - rootPath: set to the workspace path |
| 31 | + - file: set to the path of the file |
| 32 | + - tool: leave empty or unset |
| 33 | +3. If any issues are found in the files, propose and apply fixes for them. |
| 34 | +4. If you encounter that Codacy is applying a tool to the project that it shouldn't, don't try to find the configuration of Codacy, just let the user know it's a false positive issue.`, |
| 35 | + }, |
| 36 | + { |
| 37 | + name: 'codacy-check-coverage', |
| 38 | + description: 'Check code coverage of your project using Codacy', |
| 39 | + content: ` |
| 40 | +1. Call 'codacy_get_file_coverage' tool for each of the files given as context |
| 41 | +2. If any files are missing coverage, propose and apply fixes for them |
| 42 | + `, |
| 43 | + }, |
| 44 | +] |
| 45 | + |
| 46 | +export const createWindsurfWorkflows = () => { |
| 47 | + const workspacePath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath |
| 48 | + if (!workspacePath) { |
| 49 | + throw new Error('No workspace folder found') |
| 50 | + } |
| 51 | + const fileFolder = path.join(workspacePath, '.windsurf', 'workflows') |
| 52 | + if (!fs.existsSync(fileFolder)) { |
| 53 | + fs.mkdirSync(fileFolder, { recursive: true }) |
| 54 | + } |
| 55 | + workflows.forEach((workflow) => { |
| 56 | + const filePath = path.join(fileFolder, `${workflow.name}.md`) |
| 57 | + fs.writeFileSync( |
| 58 | + filePath, |
| 59 | + `--- |
| 60 | +description: ${workflow.description} |
| 61 | +--- |
| 62 | +${workflow.content}` |
| 63 | + ) |
| 64 | + }) |
| 65 | + Logger.appendLine(`Generated workflow files`) |
| 66 | +} |
0 commit comments