Skip to content

Conversation

@lightninglu10
Copy link
Contributor

@lightninglu10 lightninglu10 commented Aug 6, 2025

Add Contextual Review Tools and ContextGatherer

This PR extends the review agent by adding three new tools (find_patterns, find_utilities, analyze_architecture), updates the system prompt and index.ts to integrate these tools into the review workflow, and introduces a ContextGatherer class for aggregating review context programmatically.

Key Changes:

  • Defined new zod-based tools in src/agent/tools.ts for pattern search, utility discovery, and architecture analysis
  • Enhanced agent-system-prompt.ts and index.ts to include tool calls and richer instructions for contextual reviews
  • Added src/context-gatherer.ts with a ContextGatherer class to orchestrate context extraction from PRs

Review Notes:

  • Verify import and definition of helper functions (getAllSourceFiles, extractDependencies, findImporters)
  • Assess performance implications of synchronous file reads and stub implementations in ContextGatherer

@lightninglu10 lightninglu10 self-assigned this Aug 6, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❇️ CodePress Review Summary

👋 Hey team,

Overall the changes look solid, but I spotted 1 must-fix issue and left 1 helpful note inline.

Here's the quick rundown:

❌ Decision: REQUEST CHANGES
Undefined references and stub implementations must be addressed, and performance/test coverage improvements are required before merging.

🚧 Needs a bit of love

The required finding highlights a critical issue where unescaped XML tags in instruction strings can corrupt the reviewRequest payload. Embedding raw <resolvedComments> tags without proper escaping breaks the expected XML format, potentially causing downstream processing failures. Ensuring that XML special characters are escaped or avoiding direct inclusion of tag syntax in instruction text will maintain payload integrity and prevent parsing errors.

ℹ️ Other thoughts

The nit-level observation points to readability improvements in the illustrative JSON examples, noting that escaped quotes detract from clarity. Since these blocks serve as documentation rather than executable code, presenting them as raw, well-formatted JSON would be more user-friendly. Adopting this change enhances the maintainability and comprehension of the guidelines without impacting functionality.

Group similar issues into comprehensive feedback.
</step5>
**Tool Usage Guidelines**:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 NIT: The example JSON in the Tool Usage Guidelines still escapes quotes (e.g., \"domain\"). Consider using raw JSON formatting (without backslashes) for readability, since this block is illustrative rather than code that’s parsed literally.

5. **Prioritize Impact**: Focus on issues that would genuinely help the developer improve the codebase.
${existingComments.length > 0 ? "Special attention to existing comments:\n - Avoid creating duplicate or similar comments unless you have significantly different insights\n - Analyze whether any existing comments have been addressed by the changes\n - If existing comments are resolved by the code changes, include them in the <resolvedComments> section" : ""}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 REQUIRED: The literal <resolvedComments> in this instruction string will be injected unescaped into the XML payload, breaking the reviewRequest format. Escape the tag (e.g. &lt;resolvedComments&gt;) or otherwise avoid embedding raw XML tags in instruction text.

Suggested change
${existingComments.length > 0 ? "Special attention to existing comments:\n - Avoid creating duplicate or similar comments unless you have significantly different insights\n - Analyze whether any existing comments have been addressed by the changes\n - If existing comments are resolved by the code changes, include them in the <resolvedComments> section" : ""}
Replace the `<resolvedComments>` snippet with an escaped version, for example:

${existingComments.length > 0 ? "Special attention to existing comments:\n - Avoid creating duplicate or similar comments unless you have significantly different insights\n - Analyze whether any existing comments have been addressed by the changes\n - If existing comments are resolved by the code changes, include them in the <resolvedComments> section" : ""}

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.

1 participant