Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve patterns list/test output #62

Merged
merged 1 commit into from
Apr 3, 2024
Merged

feat: improve patterns list/test output #62

merged 1 commit into from
Apr 3, 2024

Conversation

morgante
Copy link
Contributor

@morgante morgante commented Mar 23, 2024

Implements experimental support for AI query generation and improves some of the plumbing utils for evals.

Summary by CodeRabbit

  • New Features
    • Added support for natural language processing in CLI commands.
    • Introduced new testing and reporting functionalities for pattern applications.
  • Enhancements
    • Updated language serialization and error handling mechanisms.
    • Enhanced configuration options for better customization and testing.
  • Bug Fixes
    • Fixed an issue with test result state enumeration for clearer result interpretation.

Copy link
Contributor

coderabbitai bot commented Mar 23, 2024

Walkthrough

This update integrates natural language processing capabilities into a CLI tool, enhancing its pattern application and testing functionalities. It introduces new dependencies, updates command structures with AI-related flags, and improves error handling and output formatting. Additionally, the update refines configuration for text transformations and adjusts serialization to accommodate changes in the language module, ensuring a smoother integration and usage of AI features within the tool's ecosystem.

Changes

Files Change Summary
crates/cli/Cargo.toml Added ai_querygen dependency; updated ai_builtins dependency.
crates/cli/src/commands/apply_pattern.rs Added ai flag for NLP.
crates/cli/src/commands/mod.rs
crates/cli/src/commands/patterns_test.rs
Updated function call with new argument; added parameters, structs, error handling improvements.
crates/cli/src/commands/plumbing.rs Added cwd parameter; updated function calls.
crates/cli_bin/fixtures/plumbing/... Introduced configuration objects and test patterns for text transformation.
crates/gritmodule/src/config.rs
crates/language/src/target_language.rs
Updated serialization/deserialization logic.
crates/gritmodule/src/testing.rs
crates/lsp/src/testing.rs
Updated enums and logic for test result states.

🐇✨
In the realm of code, where patterns intertwine,
A rabbit hopped in, making AI shine.
"With flags and tests, we'll see," it said,
"How words and code, can be seamlessly wed."
🌟📜🔍
Through changes and tweaks, the mission was clear,
To make understanding as close as it's near.
So cheers to the update, let's hop with delight,
For AI and code, have never been so bright.
🎉🐰💻

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@morgante morgante marked this pull request as ready for review April 3, 2024 07:09
@morgante morgante requested a review from a team April 3, 2024 07:09
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between ea47471 and 7212f3e.
Files ignored due to path filters (10)
  • crates/cli_bin/tests/snapshots/patterns__gets_json_output.snap is excluded by !**/*.snap
  • crates/cli_bin/tests/snapshots/private__run_pattern_with_private.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__recognizes_different_language_direct_imports_with_same_local_name.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__recognizes_different_language_namespace_imports_with_same_local_name.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__recognizes_mixed_language_imports_with_same_local_name.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__resolve_enforcement_level.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__resolve_from_root.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__resolve_multiple_layers.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__resolve_single_module.snap is excluded by !**/*.snap
  • crates/gritmodule/src/snapshots/marzano_gritmodule__resolver__tests__without_grit_yml.snap is excluded by !**/*.snap
Files selected for processing (12)
  • crates/cli/Cargo.toml (1 hunks)
  • crates/cli/src/commands/apply_pattern.rs (5 hunks)
  • crates/cli/src/commands/mod.rs (1 hunks)
  • crates/cli/src/commands/patterns_test.rs (8 hunks)
  • crates/cli/src/commands/plumbing.rs (2 hunks)
  • crates/cli_bin/fixtures/plumbing/test_comp.json (1 hunks)
  • crates/cli_bin/fixtures/plumbing/test_no_match.json (1 hunks)
  • crates/cli_bin/fixtures/plumbing/test_pattern_failure.json (1 hunks)
  • crates/gritmodule/src/config.rs (1 hunks)
  • crates/gritmodule/src/testing.rs (8 hunks)
  • crates/language/src/target_language.rs (2 hunks)
  • crates/lsp/src/testing.rs (1 hunks)
Additional comments not posted (18)
crates/cli_bin/fixtures/plumbing/test_comp.json (1)

1-7: LGTM! This JSON fixture appears correctly structured for testing purposes.

crates/cli_bin/fixtures/plumbing/test_pattern_failure.json (1)

1-12: LGTM! This JSON fixture is well-structured for testing failure scenarios.

crates/cli_bin/fixtures/plumbing/test_no_match.json (1)

1-12: LGTM! This JSON fixture is correctly structured for testing no match or incorrect output scenarios.

crates/cli/Cargo.toml (2)

102-102: Ensure compatibility of the newly added ai_querygen dependency with the rest of the project.


102-102: Ensure the updated ai_builtins dependency does not introduce breaking changes or conflicts.

crates/lsp/src/testing.rs (1)

152-152: Ensure that the new FailedMatch enum variant is correctly integrated and replaces all necessary instances of the previously used Fail variant throughout the codebase.

crates/cli/src/commands/plumbing.rs (1)

256-263: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [259-270]

Ensure that the cwd and parent parameters are correctly handled in get_grit_files_from and get_marzano_pattern_test_results functions, respectively.

Verification successful

The handling of cwd in get_grit_files_from and the indirect handling of parent through OutputFormat in get_marzano_pattern_test_results are consistent with the intended usage as per the function definitions and usages found in the codebase. The review comment regarding these aspects is accurate.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the handling of `cwd` in `get_grit_files_from`.
rg --type rust 'get_grit_files_from' -C 5
# Verify the handling of `parent` in `get_marzano_pattern_test_results`.
rg --type rust 'get_marzano_pattern_test_results' -C 5

Length of output: 20779

crates/gritmodule/src/config.rs (1)

172-177: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [109-118]

Ensure that including the language field in serialization/deserialization processes of ResolvedGritDefinition does not introduce unintended side effects.

Verification successful

The inclusion of the language field in the ResolvedGritDefinition struct's serialization/deserialization processes is widely reflected across the codebase, particularly in pattern resolution, testing, and CLI operations. This change appears to enhance the utility of the struct by providing more detailed information about patterns, which could improve pattern matching, testing, and user interactions with the CLI. It's important to ensure that all interactions with this struct across the codebase properly handle the language field to avoid unintended side effects. Given the information provided, there are no immediate issues detected with this change.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that no issues arise from the inclusion of the `language` field in serialization/deserialization processes.
rg --type rust 'ResolvedGritDefinition' -C 10

Length of output: 47920

crates/gritmodule/src/testing.rs (2)

109-118: Ensure that the new GritTestResultState enum variants are correctly integrated and handled throughout the codebase.


157-163: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [121-295]

Verify that the updated logic in SampleTestResult and test_pattern_sample functions correctly reflects the intended testing behavior with the new GritTestResultState enum variants.

Verification successful

The analysis of the provided context and the new context from shell scripts indicates that the logic surrounding the new enum variants in SampleTestResult and the test_pattern_sample function is correctly implemented and consistently used across the codebase. The handling of different test result states and the generation of SampleTestResult based on test outcomes align with the intended testing behavior. Therefore, the review comment is verified as accurate.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the logic surrounding the new enum variants in `SampleTestResult` and `test_pattern_sample` functions.
rg --type rust '(SampleTestResult|test_pattern_sample)' -C 20

Length of output: 35568

crates/cli/src/commands/mod.rs (1)

342-342: Ensure the run_patterns_test function correctly handles the newly added app.format_flags argument to utilize the global formatting flags effectively.

crates/cli/src/commands/apply_pattern.rs (2)

121-123: Ensure the ai flag is correctly handled throughout the codebase, especially with feature toggles like #[cfg(feature = "ai_querygen")], to prevent runtime errors in builds without AI query generation capabilities.


187-198: Ensure the error message for attempting to use AI-driven features without the ai_querygen feature enabled is user-friendly and informative, guiding users on how to enable the feature if necessary.

crates/cli/src/commands/patterns_test.rs (3)

35-35: Verify that the output: OutputFormat parameter is effectively utilized throughout the get_marzano_pattern_test_results function to handle different output formats as intended.


283-296: Ensure the TestOutcome and TestReport structs are effectively integrated with the output handling logic in get_marzano_pattern_test_results to generate structured and comprehensive JSON test reports.


105-112: Review the clarity and consistency of error messages and reports in get_marzano_pattern_test_results, ensuring they provide detailed and format-specific feedback on test failures.

crates/language/src/target_language.rs (2)

48-48: The addition of Deserialize to the derive list of PatternLanguage is a good practice for enabling deserialization from formats like JSON.


58-58: The use of serde(rename = "js") for the Tsx variant aligns with external data formats or API design choices, ensuring consistency in serialization/deserialization processes.

crates/language/src/target_language.rs Show resolved Hide resolved
@morgante morgante merged commit e7b243b into main Apr 3, 2024
8 checks passed
@morgante morgante deleted the list-output branch April 3, 2024 07:28
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.

2 participants