Skip to main content

scripts-test-framework-knowledge

#!/usr/bin/env python3 """โ€‹

title: "Add parent directory to path" component_type: script version: "1.0.0" audience: contributor status: stable summary: "Test Framework Knowledge System" keywords: ['framework', 'knowledge', 'review', 'test', 'testing'] tokens: ~500 created: 2025-12-22 updated: 2025-12-22 script_name: "test-framework-knowledge.py" language: python executable: true usage: "python3 scripts/test-framework-knowledge.py [options]" python_version: "3.10+" dependencies: [] modifies_files: false network_access: false requires_auth: falseโ€‹

Test Framework Knowledge System

Quick test to verify FrameworkKnowledgeLoader and SystemPromptBuilder work correctly.

Author: AZ1.AI INC. """

import argparse import sys from pathlib import Path

def parse_args(): """Parse command line arguments""" parser = argparse.ArgumentParser( description='Test Framework Knowledge System - verify FrameworkKnowledgeLoader and SystemPromptBuilder.', formatter_class=argparse.RawDescriptionHelpFormatter, epilog=''' Examples: %(prog)s # Run all knowledge system tests %(prog)s --verbose # Show detailed test output %(prog)s --quick # Run quick validation only

Tests performed:

  1. Loading framework knowledge registry
  2. Getting agent metadata
  3. Getting component summary
  4. Recommending agents for tasks
  5. Building system prompts
  6. Building agent invocation prompts ''' ) parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output') parser.add_argument('--quick', action='store_true', help='Run quick validation only (tests 1-3)') return parser.parse_args()

Add parent directory to path

sys.path.insert(0, str(Path(file).parent.parent))

from llm_abstractions import ( get_framework_knowledge, SystemPromptBuilder )

def test_framework_knowledge(): """Test framework knowledge loader.""" print("๐Ÿงช Testing Framework Knowledge System") print("=" * 60)

# Test 1: Get knowledge instance
print("\n๐Ÿ“– Test 1: Loading framework knowledge...")
knowledge = get_framework_knowledge()

if knowledge.registry:
print(f" โœ… Registry loaded successfully")
print(f" ๐Ÿ“Š Agents: {len(knowledge.registry.agents)}")
print(f" ๐Ÿ“Š Skills: {len(knowledge.registry.skills)}")
print(f" ๐Ÿ“Š Commands: {len(knowledge.registry.commands)}")
print(f" ๐Ÿ“Š Scripts: {len(knowledge.registry.scripts)}")
else:
print(" โŒ Failed to load registry")
return False

# Test 2: Get specific agent metadata
print("\n๐Ÿ“– Test 2: Getting agent metadata...")
agent = knowledge.get_agent_metadata("ai-specialist")
if agent:
print(f" โœ… Found agent: {agent.name}")
print(f" ๐Ÿ“ Description: {agent.description[:80]}...")
else:
# Try another agent
all_agents = knowledge.get_all_agents()
if all_agents:
agent = all_agents[0]
print(f" โœ… Found agent: {agent.name}")
print(f" ๐Ÿ“ Description: {agent.description[:80]}...")
else:
print(" โŒ No agents found")

# Test 3: Get component summary
print("\n๐Ÿ“– Test 3: Getting component summary...")
summary = knowledge.get_component_summary("all")
print(f" โœ… Summary: {summary}")

# Test 4: Recommend agents
print("\n๐Ÿ“– Test 4: Recommending agents for task...")
recommendations = knowledge.recommend_agent("analyze code architecture and design patterns")
if recommendations:
print(f" โœ… Recommended {len(recommendations)} agents:")
for agent_id in recommendations[:3]:
agent = knowledge.get_agent_metadata(agent_id)
if agent:
print(f" - {agent.name} ({agent_id})")
else:
print(" โš ๏ธ No recommendations found")

# Test 5: System prompt builder
print("\n๐Ÿ“– Test 5: Building system prompts...")
builder = SystemPromptBuilder(knowledge)

prompt = builder.build_prompt(
task_type="general",
include_agents=True,
include_skills=True,
custom_context="Testing framework awareness"
)

print(f" โœ… Built system prompt ({len(prompt)} characters)")
print(f" ๐Ÿ“ Preview:\n")
print(" " + "\n ".join(prompt[:500].split("\n")))
print(" ...")

# Test 6: Agent invocation prompt
print("\n๐Ÿ“– Test 6: Building agent invocation prompt...")
if agent:
agent_prompt = builder.build_agent_invocation_prompt(agent.id)
print(f" โœ… Built agent prompt ({len(agent_prompt)} characters)")
print(f" ๐Ÿ“ Preview:\n")
print(" " + "\n ".join(agent_prompt[:300].split("\n")))
print(" ...")

print("\n" + "=" * 60)
print("โœ… All tests passed!")
print("=" * 60)

return True

if name == "main": args = parse_args() success = test_framework_knowledge() sys.exit(0 if success else 1)