Files
Phantom/scripts/validate-gns-agents.py
NW 863a67db8e config: full APAW agent infrastructure + Phantom project files
- Added all agent definitions (.kile/agents/*.md)
- Added commands, rules, skills, shared modules
- Added src/, scripts/, tests/, docker/, agent-evolution/
- Extracted 3 archives: website/, workspace/, release/
- Created .env with Gitea creds for UniqueSoft/Phantom
- Created docs/ with project-specific guides
- Added .gitignore for node_modules
2026-05-18 17:53:59 +01:00

75 lines
2.2 KiB
Python

#!/usr/bin/env python3
"""
GNS-2 Agent Protocol Validator
Validates that agents follow Gitea-Nervous-System v2.0 protocol.
"""
import re
import sys
import yaml
import glob
CHECKPOINT_PATTERN = re.compile(r'## GNS Checkpoint\s*```yaml\s*(.*?)```', re.DOTALL)
EVENT_PATTERN = re.compile(r'<!-- GNS_EVENT:\s*(.*?)\s*-->', re.DOTALL)
def validate_agent_file(path):
with open(path) as f:
content = f.read()
errors = []
agent_name = path.split('/')[-1].replace('.md', '')
# Check frontmatter
if not content.startswith('---'):
errors.append('Missing YAML frontmatter')
else:
parts = content.split('---')
if len(parts) >= 2:
try:
fm = yaml.safe_load(parts[1])
if not fm.get('description'):
errors.append('Missing description in frontmatter')
if 'mode' not in fm:
errors.append('Missing mode in frontmatter')
if 'task' not in str(fm.get('permission', {})):
errors.append('Missing task permission')
except Exception as e:
errors.append(f'Invalid YAML frontmatter: {e}')
# Check GNS protocol sections
if 'GNS Checkpoint' not in content:
errors.append('Missing GNS Checkpoint section')
if 'GNS_EVENT' not in content:
errors.append('Missing GNS_EVENT footer example')
if 'gns-agent-protocol' not in content.lower() and 'GNS' not in content:
errors.append('Agent not updated for GNS-2 protocol')
return errors
def main():
print("GNS-2 Agent Protocol Validator")
print()
all_valid = True
for path in glob.glob('.kilo/agents/*.md'):
errors = validate_agent_file(path)
agent_name = path.split('/')[-1].replace('.md', '')
if errors:
print(f"{agent_name}: {len(errors)} errors")
for err in errors:
print(f" - {err}")
all_valid = False
else:
print(f"{agent_name}")
print()
if all_valid:
print("All agents pass GNS-2 validation")
return 0
else:
print("Some agents need GNS-2 protocol update")
return 1
if __name__ == '__main__':
sys.exit(main())