Skip to content

@W-21102094 - Add PMD XPath custom rule creation tool with AST prompt generation#381

Merged
iowillhoit merged 36 commits intomainfrom
arun.tyagi/feature/pmd_apex_rule_creation_tool
Mar 18, 2026
Merged

@W-21102094 - Add PMD XPath custom rule creation tool with AST prompt generation#381
iowillhoit merged 36 commits intomainfrom
arun.tyagi/feature/pmd_apex_rule_creation_tool

Conversation

@aruntyagiTutu
Copy link
Copy Markdown
Contributor

@aruntyagiTutu aruntyagiTutu commented Feb 11, 2026

What does this PR do?

@W-21102094@

What issues does this PR fix or reference?

This PR introduces an end‑to‑end flow for creating PMD XPath custom rules. It generates PMD AST XML from sample Apex code, extracts AST nodes and cached metadata, builds a high‑signal prompt for XPath generation, and then writes a PMD ruleset XML plus updates code-analyzer.yml (with relative custom ruleset paths). It also adds engine strategies/pipeline/adapters to keep the workflow extensible for future engines, along with tests and tool registration updates.

Notes / Future Work
The Apex AST reference JSON is cached locally in the provider to enable prompt enrichment in phase 1. This is a temporary placement and will move into the PMD engine implementation in core once the engine plugin owns AST metadata.
PMD CLI integration is used to generate AST XML in phase 1. This will be replaced by a PMD engine API in core (Java SDK or internal API) so we can avoid external process execution and share logic across tools.

@aruntyagiTutu aruntyagiTutu requested review from a team as code owners February 11, 2026 02:56
@aruntyagiTutu aruntyagiTutu changed the title @W-21102094 - Custom rule creation for PMD based on xpath @W-21102094 - [WIP] [Do not review] Custom rule creation for PMD based on xpath Feb 11, 2026
* add validation that this implementation supports pmd only for now

* update prompt - optimize for output  size

* refactor create tool

* file name santization

* updated action name

* update prompt

* update prompt optimize for simple xpath

* fix tests

* fix test with mock
…y methods (#386)

* langugae in ruleset template

* update telemetry on success

* xpath is optional

* clean chuncky methods
@stephen-carter-at-sf stephen-carter-at-sf marked this pull request as draft February 16, 2026 13:25
@aruntyagiTutu aruntyagiTutu changed the title @W-21102094 - [WIP] [Do not review] Custom rule creation for PMD based on xpath @W-21102094 - Add PMD XPath custom rule creation workflow with AST prompt generation Feb 17, 2026
@aruntyagiTutu aruntyagiTutu changed the title @W-21102094 - Add PMD XPath custom rule creation workflow with AST prompt generation @W-21102094 - Add PMD XPath custom rule creation tool with AST prompt generation Feb 17, 2026
@aruntyagiTutu aruntyagiTutu marked this pull request as ready for review February 18, 2026 11:32
Comment thread packages/mcp-provider-code-analyzer/src/tools/create_custom_rule.ts Outdated
Comment thread packages/mcp-provider-code-analyzer/Untitled Outdated
Comment thread packages/mcp-provider-code-analyzer/src/ast/extract-ast-nodes.ts
Comment thread packages/mcp-provider-code-analyzer/src/tools/create_custom_rule.ts Outdated
Comment thread packages/mcp-provider-code-analyzer/src/tools/create_custom_rule.ts
Comment thread packages/mcp-provider-code-analyzer/src/engines/engine-strategies.ts Outdated
Comment thread packages/mcp-provider-code-analyzer/src/tools/generate_xpath_prompt.ts Outdated
@iowillhoit iowillhoit merged commit d3bb83f into main Mar 18, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants