Skip to content

Feat : Intent inference and integration - #17

Merged
haddybhaiya merged 5 commits into
test-branch-phase4from
prop-based-intent
Apr 8, 2026
Merged

Feat : Intent inference and integration#17
haddybhaiya merged 5 commits into
test-branch-phase4from
prop-based-intent

Conversation

@haddybhaiya

Copy link
Copy Markdown
Member

This pull request introduces a new intent inference capability for code diffs and integrates it into the test generation workflow. It also refines the prompts used for both intent extraction and test generation, and adds comprehensive tests for the new functionality.

Intent inference and integration:

  • Added an infer_intent function to groq_client.py that analyzes a code diff and extracts its purpose, key properties, and edge cases, outputting a structured JSON object.
  • Introduced a new INTENT_PROMPT in prompts.py to guide the LLM in extracting intent information from code diffs.
  • Updated generate_tests in test_generator.py to accept and incorporate intent information (purpose, properties, edge cases) into the test case generation prompt, improving the relevance and coverage of generated tests.

Prompt and output improvements:

  • Refined the test generation prompt to explicitly include intent, enforce stricter output formatting (Python code only, no markdown), and focus on edge cases and properties. Improved markdown/code block cleaning logic in the output.

Testing enhancements:

  • Added new tests in test_generated.py for both infer_intent and generate_tests, covering empty, short, and long diffs, as well as scenarios with and without context/intent.

actions-user and others added 5 commits April 1, 2026 16:25
Co-authored-by: deoxyforge dipudeeva@gmail.com
Co-authored-by: deoxygfx dipudeeva@gmail.com
 Co-authored-by: Dipesh Kumar dipudeeva@gmail.com
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

Automated Code Review Comment:

Bugs

  • The infer_intent function does not check if the diff parameter is None before trying to format the INTENT_PROMPT string. This could lead to a TypeError if diff is None.
  • The generate_tests function does not check if the intent parameter is None before trying to access its keys. This could lead to a TypeError if intent is None.
  • The generate_tests function does not check if the context parameter is None before trying to join its elements. This could lead to a TypeError if context is None.

Improvements

  • The code could benefit from more descriptive variable names. For example, diff could be renamed to code_diff to make it clearer what it represents.
  • The infer_intent function could be improved by adding a check to ensure that the diff parameter is not too long before trying to format the INTENT_PROMPT string.
  • The generate_tests function could be improved by adding a check to ensure that the context parameter is not too long before trying to join its elements.

Suggestions

  • Consider adding type hints for the function parameters to make it clearer what types of data are expected.
  • Consider adding docstrings to the functions to provide a description of what each function does and what it returns.
  • Consider using a more robust way to handle errors, such as logging the error message instead of just returning it as a string.
  • The code looks good overall, but it could benefit from some minor improvements to make it more robust and maintainable. Code looks good ✅

Suggested Tests

def test_infer_intent_empty_diff():
assert infer_intent("") == {"purpose": "", "properties": [], "edge_cases": [], "error": ""}

def test_infer_intent_short_diff():
diff = "diff --git a/file.py b/file.py"
intent = infer_intent(diff)
assert "purpose" in intent
assert "properties" in intent
assert "edge_cases" in intent

def test_infer_intent_long_diff():
diff = "diff --git a/file.py b/file.py" * 10000
intent = infer_intent(diff)
assert "purpose" in intent
assert "properties" in intent
assert "edge_cases" in intent

def test_generate_tests_no_context_no_intent():
diff = "diff --git a/file.py b/file.py"
tests = generate_tests(diff)
assert tests.strip() != ""

def test_generate_tests_with_context_and_intent():
diff = "diff --git a/file.py b/file.py"
context = ["context1", "context2"]
intent = {"purpose": "test", "properties": ["prop1", "prop2"], "edge_cases": ["case1", "case2"]}
tests = generate_tests(diff, context, intent)
assert tests.strip() != ""

@haddybhaiya

Copy link
Copy Markdown
Member Author

@copilot check bugs given by github-actions

@haddybhaiya haddybhaiya left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will check with the bugs in final merge !!Hopefully!

@haddybhaiya
haddybhaiya merged commit 9203601 into test-branch-phase4 Apr 8, 2026
1 of 2 checks passed
@haddybhaiya
haddybhaiya deleted the prop-based-intent branch April 8, 2026 12:30
@deoxyforge

Copy link
Copy Markdown
Collaborator

@haddybhaiya Bhaiyyaji meri pr kyu merge krdi

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