87 lines
2.2 KiB
Python
87 lines
2.2 KiB
Python
"""Integration test: Project Indexer + Context Manager.
|
|
|
|
Tests against the variet-agent project itself.
|
|
"""
|
|
|
|
import sys
|
|
import io
|
|
if sys.stdout.encoding != "utf-8":
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
|
sys.path.insert(0, r"C:\Users\CafeVariet-GL552VW\Desktop\source_diff\variet-agent")
|
|
|
|
from core.project_indexer import ProjectIndex
|
|
from core.context_manager import ContextManager
|
|
|
|
PROJECT = r"C:\Users\CafeVariet-GL552VW\Desktop\source_diff\variet-agent"
|
|
|
|
|
|
def test_indexer():
|
|
print("=" * 60)
|
|
print("TEST 1: Project Indexer Scan")
|
|
print("=" * 60)
|
|
|
|
idx = ProjectIndex(PROJECT)
|
|
idx.scan()
|
|
|
|
print(f" Files found: {len(idx.files)}")
|
|
for fpath, info in sorted(idx.files.items()):
|
|
funcs = ", ".join(info.functions[:3]) if info.functions else ""
|
|
print(f" {fpath} ({info.line_count}L) [{info.language}] {funcs}")
|
|
|
|
print(f"\n Import graph entries: {len(idx.import_graph)}")
|
|
for fpath, deps in idx.import_graph.items():
|
|
if deps:
|
|
print(f" {fpath} → {deps}")
|
|
|
|
return idx
|
|
|
|
|
|
def test_find_relevant(idx):
|
|
print("\n" + "=" * 60)
|
|
print("TEST 2: Find Relevant Files")
|
|
print("=" * 60)
|
|
|
|
queries = [
|
|
"context_manager",
|
|
"gemini caller",
|
|
"project indexer scan",
|
|
"vikunja helper",
|
|
]
|
|
|
|
for q in queries:
|
|
results = idx.find_relevant(q)
|
|
print(f" Query: '{q}' → {results[:5]}")
|
|
|
|
|
|
def test_context_manager(idx):
|
|
print("\n" + "=" * 60)
|
|
print("TEST 3: Context Manager Gather")
|
|
print("=" * 60)
|
|
|
|
cm = ContextManager(idx, token_budget=10_000)
|
|
context = cm.gather("context_manager gather files")
|
|
|
|
print(f" Context length: {len(context)} chars")
|
|
print(f" First 500 chars:")
|
|
print(context[:500])
|
|
print("...")
|
|
print(f" Last 200 chars:")
|
|
print(context[-200:])
|
|
|
|
|
|
def test_structure_summary(idx):
|
|
print("\n" + "=" * 60)
|
|
print("TEST 4: Structure Summary")
|
|
print("=" * 60)
|
|
|
|
summary = idx.get_structure_summary()
|
|
print(summary)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
idx = test_indexer()
|
|
test_find_relevant(idx)
|
|
test_context_manager(idx)
|
|
test_structure_summary(idx)
|
|
print("\n✅ All tests passed!")
|