system-prompts-and-models-o.../scripts/search.py
Claude cb8bb88b4f
refactor: Major repository enhancement v2.0
This commit represents a comprehensive refactor and enhancement of the
entire repository, transforming it from a simple collection to a
searchable, analyzable, and well-documented resource.

## Fixed Issues
- Fixed broken link for Amp directory (./AMp/ → ./Amp/)
- Added missing Emergent and Traycer AI entries to README
- Fixed file extension for Traycer AI/plan_mode_prompts.txt
- Updated line count statistics for accuracy (30,000+ → 25,000+)

## New Infrastructure
- Created scripts/ directory with automation tools
- Added .gitignore for generated files and common artifacts
- Implemented comprehensive metadata system

## New Scripts
- generate_metadata.py: Generate searchable index with tool metadata
- validate.py: Automated repository validation and quality checks
- search.py: Search and filter tools by multiple criteria
- analyze.py: Generate statistics, charts, and comparisons

## Enhanced Documentation
- CONTRIBUTING.md: Comprehensive contribution guidelines
- CHANGELOG.md: Version history and release notes
- README.md: Complete reorganization with categories and search guide
- scripts/README.md: Documentation for all automation tools

## Individual Tool READMEs
- Anthropic/README.md: Claude models documentation
- Cursor Prompts/README.md: Cursor AI system documentation
- Open Source prompts/README.md: Open source tools overview

## Improved Organization
- Reorganized tools by category (IDE, AI Agent, Code Assistant, etc.)
- Added Quick Start section with usage examples
- Added Search & Discovery section
- Better categorization and navigation

## Features
- Searchable metadata index (32 tools, 96 files, 20K+ lines)
- Category-based browsing (11 categories)
- Company and model filtering
- Automated validation checks
- Statistics and analysis tools
- Comparison table generation

## Statistics
- 32 AI tools documented
- 96 total files (76 txt, 15 json, 5 md)
- 20,045 lines of prompts and configuration
- 11 distinct categories
- 4 new Python scripts for automation

Version: 2.0.0
2025-11-15 02:08:32 +00:00

154 lines
4.9 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Search and filter AI tools in the repository.
Usage:
python scripts/search.py --category "Code Assistant"
python scripts/search.py --company "Anthropic"
python scripts/search.py --text "agent"
python scripts/search.py --model "gpt-5"
"""
import json
import argparse
import os
from pathlib import Path
class Colors:
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RESET = '\033[0m'
BOLD = '\033[1m'
def load_index():
"""Load the metadata index."""
index_path = "scripts/index.json"
if not os.path.exists(index_path):
print(f"Error: {index_path} not found. Run 'python scripts/generate_metadata.py' first.")
exit(1)
with open(index_path, 'r', encoding='utf-8') as f:
return json.load(f)
def search_tools(index, category=None, company=None, text=None, model=None, tool_type=None):
"""Search tools based on criteria."""
results = []
for tool in index['tools']:
# Filter by category
if category and tool.get('category', '').lower() != category.lower():
continue
# Filter by company
if company and company.lower() not in tool.get('company', '').lower():
continue
# Filter by type
if tool_type and tool.get('type', '').lower() != tool_type.lower():
continue
# Filter by model
if model:
models = tool.get('models', [])
if not any(model.lower() in m.lower() for m in models):
continue
# Filter by text in name or description
if text:
searchable = f"{tool.get('name', '')} {tool.get('description', '')}".lower()
if text.lower() not in searchable:
continue
results.append(tool)
return results
def display_results(results, verbose=False):
"""Display search results."""
if not results:
print(f"{Colors.YELLOW}No results found.{Colors.RESET}")
return
print(f"\n{Colors.BOLD}Found {len(results)} tool(s):{Colors.RESET}\n")
for tool in results:
print(f"{Colors.BLUE}{Colors.BOLD}{tool['name']}{Colors.RESET}")
print(f" Company: {tool.get('company', 'Unknown')}")
print(f" Category: {tool.get('category', 'Unknown')}")
print(f" Type: {tool.get('type', 'unknown')}")
if tool.get('website'):
print(f" Website: {tool['website']}")
if tool.get('models'):
print(f" Models: {', '.join(tool['models'])}")
print(f" Files: {tool['file_count']} ({tool.get('total_lines', 0):,} lines)")
if verbose:
print(f" Description: {tool.get('description', 'N/A')}")
print(f" Directory: {tool['directory']}")
if tool.get('files'):
print(" File list:")
for file in tool['files']:
size_kb = file['size'] / 1024
print(f" - {file['name']} ({size_kb:.1f} KB)")
print()
def list_categories(index):
"""List all categories."""
categories = set(tool.get('category', 'Unknown') for tool in index['tools'])
print(f"\n{Colors.BOLD}Available Categories:{Colors.RESET}")
for cat in sorted(categories):
count = sum(1 for t in index['tools'] if t.get('category') == cat)
print(f" {cat} ({count})")
def list_companies(index):
"""List all companies."""
companies = set(tool.get('company', 'Unknown') for tool in index['tools'])
print(f"\n{Colors.BOLD}Available Companies:{Colors.RESET}")
for company in sorted(companies):
count = sum(1 for t in index['tools'] if t.get('company') == company)
print(f" {company} ({count})")
def main():
parser = argparse.ArgumentParser(description='Search AI tools in the repository')
parser.add_argument('--category', help='Filter by category')
parser.add_argument('--company', help='Filter by company')
parser.add_argument('--text', help='Search in name and description')
parser.add_argument('--model', help='Filter by AI model')
parser.add_argument('--type', help='Filter by type (proprietary/open-source)')
parser.add_argument('--verbose', '-v', action='store_true', help='Show detailed information')
parser.add_argument('--list-categories', action='store_true', help='List all categories')
parser.add_argument('--list-companies', action='store_true', help='List all companies')
args = parser.parse_args()
# Load index
index = load_index()
# Handle list commands
if args.list_categories:
list_categories(index)
return
if args.list_companies:
list_companies(index)
return
# Perform search
results = search_tools(
index,
category=args.category,
company=args.company,
text=args.text,
model=args.model,
tool_type=args.type
)
display_results(results, verbose=args.verbose)
if __name__ == "__main__":
main()