# C:\Users\leonk\Documents\AI_Projects\ai_workspace\core\context_engine.py # Streamlined Organism Local Context & Semantic Tracker Baseline [LK] import os import json from datetime import datetime, timezone class LocalContextEngine: def __init__(self, workspace_root=r"C:\Users\leonk\Documents\AI_Projects\ai_workspace\\"): self.workspace_root = workspace_root self.registry_log = r"C:\Users\leonk\Documents\AI_Projects\ai_workspace\core\operations_wal.jsonl" def scan_local_assets(self): """Scans local project names and lengths safely to update the internal tracking context.""" discovered_files = [] print("[INFO] Initializing passive local file context inventory check...") try: # Traverses directories safely without touching legacy files or writing backup cache for root, dirs, files in os.walk(self.workspace_root): # Ignore system hidden or temporary build cache directories if "browser_backup" in root or "__pycache__" in root: continue for file in files: full_path = os.path.join(root, file) file_extension = os.path.splitext(file)[1] # Read basic file attributes using standard system APIs (Physics/Data tracking) try: file_size = os.path.getsize(full_path) discovered_files.append({ "name": file, "extension": file_extension, "size_bytes": file_size, "path": full_path }) except OSError: continue # Safely skip files locked by other OS system processes print(f"[SUCCESS] Scanned {len(discovered_files)} local assets across your project workspace.") return discovered_files except Exception as e: print(f"[ERROR] Scan halted: {str(e)}") return [] if __name__ == "__main__": print("=" * 60) print("TESTING LOCAL CONTEXT INTELLIGENCE LAYER [LK]") engine = LocalContextEngine() assets = engine.scan_local_assets() if assets: print(f"Sample asset discovered: '{assets[0]['name']}' ({assets[0]['size_bytes']} bytes)") print("=" * 60)