2026-10-19 13:30:59 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
"""Render a current State Hub orientation brief without Git operations or hub writes."""
|
|
|
|
|
import argparse
|
|
|
|
|
import json
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
from consistency_check import _write_custodian_brief
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
|
|
|
parser.add_argument('--repo-path', type=Path, required=True)
|
|
|
|
|
parser.add_argument('--repo-slug', required=True)
|
|
|
|
|
parser.add_argument('--api-base', default='http://127.0.0.1:8000')
|
|
|
|
|
parser.add_argument('--check', action='store_true')
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
try:
|
|
|
|
|
if not re.fullmatch(r'[a-z0-9]+(?:-[a-z0-9]+)*', args.repo_slug):
|
|
|
|
|
raise ValueError('canonical repository slug required')
|
|
|
|
|
if not args.repo_path.is_dir():
|
|
|
|
|
raise ValueError('repository path must exist')
|
|
|
|
|
if (args.repo_path / '.custodian-brief.md').is_symlink():
|
|
|
|
|
raise ValueError('refuse redirected brief')
|
|
|
|
|
changed = _write_custodian_brief(args.api_base, args.repo_slug, str(args.repo_path),
|
2026-10-19 13:46:45 +02:00
|
|
|
strict=True, check=args.check)
|
2026-10-19 13:30:59 +02:00
|
|
|
except (OSError, ValueError, KeyError, TypeError) as exc:
|
|
|
|
|
parser.exit(1, f'Brief generation refused: {exc}\n')
|
|
|
|
|
print(json.dumps({'repo': args.repo_slug, 'status': 'updated' if changed else 'current',
|
|
|
|
|
'source': 'state-hub-read-model', 'git_operations': False}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
main()
|