cd $WEFT_ROOT && source scripts/.env 2>/dev/null; python3 - << 'PYEOF'
import json, glob, os, sys
sys.path.insert(0, '.')
from agent.lib.kimi_client import generate_chronicle
from agent.lib.chronicle import write_chronicle, write_card, CardData
OUT_DIR = 'agent/.attestations/chronicle'
os.makedirs(OUT_DIR, exist_ok=True)
attestations = []
for path in sorted(glob.glob('agent/.attestations/*/attestation.json')):
with open(path) as f:
d = json.load(f)
attestations.append({
'milestoneHash': d.get('weft', {}).get('milestoneHash', d.get('milestoneHash', '')),
'projectId': d.get('weft', {}).get('projectId', d.get('projectId', 'weft-protocol')),
'verified': d.get('verdict', {}).get('verified', d.get('verified', False)),
'uniqueCallerCount': d.get('evidence', {}).get('usage', {}).get('uniqueCallerCount',
d.get('usage', {}).get('uniqueCallerCount', 0)),
'commitCount': len(d.get('evidence', {}).get('github', {}).get('commits', [])),
'narrative': d.get('narrative', {}).get('summary', ''),
'evidenceRoot': d.get('evidenceRoot', ''),
'peerSigners': d.get('peerSigners', 0),
})
if not attestations:
print('No attestation files found.')
print()
print('To generate a chronicle, you first need verified milestone attestations.')
print(' Run: /weft-verify (to verify a milestone and create an attestation)')
print(' Or: /weft-workflow (full multi-step verification pipeline)')
print()
print('Once attestations exist in agent/.attestations/*/attestation.json,')
print('run this skill again.')
sys.exit(1)
print(f'Found {len(attestations)} attestation(s). Generating chronicle...')
print()
chronicle = generate_chronicle(attestations)
print(f'Title: {chronicle.title}')
for ch in chronicle.chapters:
print(f' Chapter: {ch["heading"]}')
print(f' {ch["body"][:120]}...')
if chronicle.epilogue:
print(f' Epilogue: {chronicle.epilogue[:100]}...')
chronicle_path = f'{OUT_DIR}/chronicle.html'
write_chronicle(
title=chronicle.title,
chapters=chronicle.chapters,
epilogue=chronicle.epilogue,
attestations=attestations,
out_path=chronicle_path,
)
print(f'\nWritten: {chronicle_path}')
att = attestations[0]
ch0 = chronicle.chapters[0] if chronicle.chapters else {}
card = CardData(
milestone_hash=att['milestoneHash'],
project_id=att.get('projectId', 'weft-protocol'),
verified=att['verified'],
narrative_summary=att.get('narrative') or (ch0.get('body', '')[:300]),
unique_callers=att['uniqueCallerCount'],
commits=att['commitCount'],
peer_signers=att.get('peerSigners', 0),
evidence_root=att.get('evidenceRoot', ''),
chapter_heading=ch0.get('heading', ''),
chapter_body=ch0.get('body', ''),
)
card_path = f'{OUT_DIR}/milestone_card.html'
write_card(card, card_path)
print(f'Written: {card_path}')
print('\nDone. Opening in browser...')
PYEOF