165 lines
6.0 KiB
Gherkin
165 lines
6.0 KiB
Gherkin
Feature: Context Service Analysis Integration
|
|
As a developer using CleverAgents
|
|
I want to analyze context files using LangGraph workflows
|
|
So that I can understand the codebase better before making changes
|
|
|
|
Background:
|
|
Given I have initialized a CleverAgents project
|
|
And I have a context service with LangGraph integration
|
|
|
|
Scenario: Analyze context when no files are loaded
|
|
Given the current plan has no context files
|
|
When I analyze the context
|
|
Then the analysis result should have empty documents
|
|
And the analysis summary should indicate no files to analyze
|
|
And there should be no error in the analysis
|
|
|
|
Scenario: Analyze context with a single Python file
|
|
Given I have a Python file "main.py" with content:
|
|
"""
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
def main():
|
|
print("Hello, World!")
|
|
"""
|
|
And I have added "main.py" to the LangGraph context
|
|
When I analyze the context
|
|
Then the analysis result should have 1 document
|
|
And the dependencies for "main.py" should include "os"
|
|
And the relevance score for "main.py" should be between 0.0 and 1.0
|
|
And the summary should not be empty
|
|
|
|
Scenario: Analyze context with multiple files
|
|
Given I have a Python file "utils.py" with content:
|
|
"""
|
|
def helper():
|
|
return 42
|
|
"""
|
|
And I have a Python file "app.py" with content:
|
|
"""
|
|
from utils import helper
|
|
print(helper())
|
|
"""
|
|
And I have added "utils.py" to the LangGraph context
|
|
And I have added "app.py" to the LangGraph context
|
|
When I analyze the context
|
|
Then the analysis result should have 2 documents
|
|
And the dependencies should include entries for both files
|
|
And the relevance scores should have entries for both files
|
|
|
|
Scenario: Get context summary
|
|
Given I have a Python file "sample.py" with content:
|
|
"""
|
|
# Sample module
|
|
class Sample:
|
|
pass
|
|
"""
|
|
And I have added "sample.py" to the LangGraph context
|
|
When I get the context summary
|
|
Then the summary should be a non-empty string
|
|
And the summary should not indicate an error
|
|
|
|
Scenario: Get context dependencies
|
|
Given I have a Python file "deps.py" with content:
|
|
"""
|
|
import json
|
|
import requests
|
|
from typing import Dict
|
|
"""
|
|
And I have added "deps.py" to the LangGraph context
|
|
When I get the context dependencies
|
|
Then the dependencies dict should have an entry for "deps.py"
|
|
And the dependencies should be a non-empty list
|
|
|
|
Scenario: Get relevant files with threshold
|
|
Given I have a Python file "important.py" with content:
|
|
"""
|
|
# Core business logic
|
|
def critical_function():
|
|
return "important"
|
|
"""
|
|
And I have a Python file "trivial.py" with content:
|
|
"""
|
|
# Just comments
|
|
pass
|
|
"""
|
|
And I have added "important.py" to the LangGraph context
|
|
And I have added "trivial.py" to the LangGraph context
|
|
When I get relevant files with threshold 0.0
|
|
Then the result should include both files with scores
|
|
And all LangGraph scores should be between 0.0 and 1.0
|
|
|
|
Scenario: Stream context analysis
|
|
Given I have a Python file "streaming.py" with content:
|
|
"""
|
|
print("test streaming")
|
|
"""
|
|
And I have added "streaming.py" to the LangGraph context
|
|
When I stream the context analysis
|
|
Then I should receive multiple events
|
|
And the events should include node execution results
|
|
|
|
Scenario: Stream context analysis when no files are loaded
|
|
Given the current plan has no context files
|
|
When I stream the context analysis
|
|
Then the streaming output should report no files to analyze
|
|
|
|
Scenario: Analyze context asynchronously
|
|
|
|
Given I have a Python file "async_test.py" with content:
|
|
"""
|
|
async def async_func():
|
|
return "async"
|
|
"""
|
|
And I have added "async_test.py" to the LangGraph context
|
|
When I analyze the context asynchronously
|
|
Then the async result should have documents
|
|
And the async result should have a summary
|
|
And there should be no error in the async result
|
|
|
|
Scenario: Analyze context asynchronously when no files are loaded
|
|
Given the current plan has no context files
|
|
When I analyze the context asynchronously
|
|
Then the async analysis result should have empty documents
|
|
And the async analysis summary should indicate no files to analyze
|
|
|
|
Scenario: Stream context analysis asynchronously with loaded files
|
|
Given I have a Python file "async_stream.py" with content:
|
|
"""
|
|
print("async stream")
|
|
"""
|
|
And I have added "async_stream.py" to the LangGraph context
|
|
When I stream the context analysis asynchronously
|
|
Then the async streaming events should include node execution results
|
|
|
|
Scenario: Stream context analysis asynchronously with no files
|
|
Given the current plan has no context files
|
|
When I stream the context analysis asynchronously
|
|
Then the async streaming output should report no files to analyze
|
|
|
|
Scenario: Handle non-existent files gracefully
|
|
Given I have added a non-existent file path to the analysis
|
|
|
|
|
|
When I analyze the context with the non-existent path
|
|
Then the analysis should complete without raising an exception
|
|
And the error field should contain file not found information
|
|
|
|
Scenario: Get context agent instance
|
|
When I request a context analysis agent
|
|
Then I should receive a ContextAnalysisAgent instance
|
|
And the agent should have the standard workflow nodes
|
|
|
|
Scenario: Prepare LangSmith metadata when tracing is enabled
|
|
Given LangSmith tracing is enabled for context analysis metadata
|
|
And I have a Python file "langsmith.py" with content:
|
|
"""
|
|
print("langsmith tracing")
|
|
"""
|
|
And I have added "langsmith.py" to the LangGraph context
|
|
When I prepare the LangGraph analysis config for run "LangSmithRun" in "stream" mode
|
|
Then the LangSmith config should include the current project metadata
|
|
And the LangSmith config should record 1 context file path
|