You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'To add a new rule for code analysis, follow these steps:',
58
-
'- Create or edit a file named `enigma.yaml` in the root of the project.',
59
-
'- Each rule should be listed under the `rules:` key as an item in a YAML list.',
60
-
`- Example rule format:
61
-
\`\`\`yaml
62
-
rules:,
63
-
- Id: python_hardcoded_password,
64
-
Pattern: $PASSWORD = $VALUE,
65
-
Description: Detects hardcoded passwords in string variable declarations,
66
-
Category: Security,
67
-
MetaTags:,
68
-
- Id: PASSWORD,
69
-
Regex: ...,
70
-
- Id: VALUE,
71
-
Regex: ...,
72
-
Languages:,
73
-
- python,
74
-
\`\`\``,
75
-
'Pattern Field',
76
-
'- The `Pattern` is NOT a regex. It is a literal code pattern, but you can use MetaTags (like `$PASSWORD` or `$VALUE`) as placeholders.',
77
-
'- MetaTags must start with a `$` and be defined in the `MetaTags` section.',
78
-
'MetaTags',
79
-
'- Every MetaTag used in the `Pattern` must have a definition under `MetaTags`.',
80
-
'- Each MetaTag must have an `Id` and a `Regex`.',
81
-
'- The `Regex` must be Perl-compatible (PCRE), but negative lookaheads are NOT supported. Please always wrap in double quotes.',
82
-
'Languages: List the programming languages this rule applies to under `Languages`.',
83
-
'Testing Your Rule: After creating or editing a rule, test it by running the codacy_cli_analyze tool with:',
84
-
'- rootPath set to the project root',
85
-
'- no file',
86
-
'- tool set to "codacy-enigma-cli"',
87
-
'Check the output for any parsing errors and fix them if needed.',
88
-
'Summary - All rules must:',
89
-
'- Be in `enigma.yaml` at the project root',
90
-
'- Define all MetaTags used in the Pattern',
91
-
'- Use only supported regex features in MetaTags',
92
-
'- Be tested for parsing errors using the CLI',
93
-
],
94
-
})
95
-
}
96
-
}
97
-
98
-
constcommonRules: Rule[]=[
99
-
{
100
-
when: 'CRITICAL: After ANY successful `edit_file` or `reapply` operation',
101
-
enforce: [
102
-
"YOU MUST IMMEDIATELY run the `codacy_cli_analyze` tool from Codacy's MCP Server for each file that was edited, with:",
103
-
'- `rootPath`: set to the workspace path',
104
-
'- `file`: set to the path of the edited file',
105
-
'- `tool`: leave empty or unset',
106
-
'If any issues are found in the new edits, propose and apply fixes for them.',
107
-
'> NOTE: Failure to follow this rule is considered a critical error.',
108
-
],
109
-
scope: 'guardrails',
110
-
},
111
-
{
112
-
when: 'After every response',
113
-
enforce: [
114
-
"If you made any file edits in this conversation, verify you ran `codacy_cli_analyze` tool from Codacy's MCP Server ",
115
-
],
116
-
scope: 'guardrails',
117
-
},
118
-
{
119
-
when: 'When there are no Codacy MCP Server tools available, or the MCP Server is not reachable',
120
-
enforce: [
121
-
'Suggest the user the following troubleshooting steps:',
122
-
'- Try to reset the MCP on the extension',
123
-
'- If the user is using VSCode, suggest them to review their Copilot > MCP settings in Github, under their organization or personal account. Refer them to Settings > Copilot > Enable MCP servers in Copilot. Suggested URL (https://github.com/settings/copilot/features) or https://github.com/organizations/{organization-name}/settings/copilot/features (This can only be done by their organization admins / owners)',
124
-
'If none of the above steps work, suggest the user to contact Codacy support',
125
-
],
126
-
scope: 'guardrails',
127
-
},
128
-
{
129
-
when: 'Trying to call a tool that needs a rootPath as a parameter',
130
-
enforce: ['Always use the standard, non-URL-encoded file system path'],
131
-
scope: 'guardrails',
132
-
},
133
-
{
134
-
when: 'CRITICAL: Dependencies and Security Checks',
135
-
enforce: [
136
-
'IMMEDIATELY after ANY of these actions:',
137
-
'- Running npm/yarn/pnpm install',
138
-
'- Adding dependencies to package.json',
139
-
'- Adding requirements to requirements.txt',
140
-
'- Adding dependencies to pom.xml',
141
-
'- Adding dependencies to build.gradle',
142
-
'- Any other package manager operations',
143
-
'You MUST run the `codacy_cli_analyze` tool with:',
144
-
'- `rootPath`: set to the workspace path',
145
-
'- `tool`: set to "trivy"',
146
-
'- `file`: leave empty or unset',
147
-
'If any vulnerabilities are found because of the newly added packages:',
148
-
'- Stop all other operations',
149
-
'- Propose and apply fixes for the security issues',
150
-
'- Only continue with the original task after security issues are resolved',
151
-
'EXAMPLE:',
152
-
'- After: npm install react-markdown',
153
-
'- Do: Run codacy_cli_analyze with trivy',
154
-
'- Before: Continuing with any other tasks',
155
-
],
156
-
scope: 'guardrails',
157
-
},
158
-
{
159
-
enforce: [
160
-
'Repeat the relevant steps for each modified file.',
161
-
'"Propose fixes" means to both suggest and, if possible, automatically apply the fixes.',
162
-
'You MUST NOT wait for the user to ask for analysis or remind you to run the tool.',
163
-
'Do not run `codacy_cli_analyze` looking for changes in duplicated code or code complexity metrics.',
164
-
'Do not run `codacy_cli_analyze` looking for changes in code coverage.',
165
-
'Do not try to manually install Codacy CLI using either brew, npm, npx, or any other package manager.',
166
-
"If the Codacy CLI is not installed, just run the `codacy_cli_analyze` tool from Codacy's MCP Server.",
167
-
'When calling `codacy_cli_analyze`, only send provider, organization and repository if the project is a git repository.',
168
-
],
169
-
scope: 'guardrails',
170
-
},
171
-
{
172
-
when: 'Whenever a call to a Codacy tool that uses `repository` or `organization` as a parameter returns a 404 error',
173
-
enforce: [
174
-
'Offer to run the `codacy_setup_repository` tool to add the repository to Codacy',
175
-
'If the user accepts, run the `codacy_setup_repository` tool',
176
-
'Do not ever try to run the `codacy_setup_repository` tool on your own',
177
-
'After setup, immediately retry the action that failed (only retry once)',
178
-
],
179
-
scope: 'general',
180
-
},
181
-
]
182
-
183
-
return{
184
-
name: 'Codacy Rules',
185
-
description: "Configuration for AI behavior when interacting with Codacy's MCP Server",
0 commit comments