added
This commit is contained in:
commit
4af224804a
39 files changed
+5534
No files matched your search
@@ -0,0 +1,69 @@
|
||||
"""Deterministic, template-compatible file catalog; no source body duplication."""
|
||||
from pathlib import Path
|
||||
import argparse, json, re
|
||||
|
||||
FIXED = [
|
||||
('seo-geo-research-skill','skills/seo-geo-research/SKILL.md','SEO / GEO research service','skill','Weekly dual-engine research contract and verification gates.',['seo','geo','aeo','agent-discovery']),
|
||||
('seo-geo-research-framework','skills/seo-geo-research/references/research-framework.md','Original GEO / AI Search framework','reference','Original analytical scope for iNDX, NetworkSIG and AI discovery.',['iNDX','NetworkSIG','retrieval','provenance']),
|
||||
('seo-geo-report-template','templates/report-template.md','Weekly research report template','template','Report sections, source ledger, query ledger and architectural implications.',['research-report','web-search','exa']),
|
||||
('seo-geo-research-rollup','reports/seo-geo-research-rollup.md','Cumulative SEO / GEO research rollup','derived-rollup','Derived chronological collection, not independent evidence; preserves source report status.',['seo','geo','derived','historical-context'])]
|
||||
|
||||
def read_json(path): return json.loads(Path(path).read_text(encoding='utf-8-sig'))
|
||||
|
||||
def validate_index(root,index):
|
||||
root=Path(root).resolve(); ids=set(); paths=set()
|
||||
for item in index['items']:
|
||||
cid=item['content_id']; path=item['path']; target=(root/path).resolve()
|
||||
if cid in ids or path in paths: raise ValueError('Duplicate content ID or path')
|
||||
if not re.fullmatch(r'[a-z0-9]+(?:-[a-z0-9]+)*',cid): raise ValueError('Unsafe content ID')
|
||||
if not target.is_relative_to(root) or not target.is_file(): raise ValueError('Missing or unsafe indexed target: '+path)
|
||||
if item['status'] not in ['draft','published','archived','deprecated','superseded']: raise ValueError('Invalid lifecycle status')
|
||||
ids.add(cid); paths.add(path)
|
||||
for item in index['items']:
|
||||
if not set(item.get('related_content_ids',[])).issubset(ids): raise ValueError('Unresolved related content')
|
||||
|
||||
def make_index(root):
|
||||
root=Path(root); manifest=read_json(root/'repository.json'); old=read_json(root/'content-index.json') if (root/'content-index.json').exists() else {}
|
||||
old_items={i['path']:i for i in old.get('items',[])}; items=[]
|
||||
def add(cid,path,title,kind,desc,topics,date=None,status='draft'):
|
||||
previous=old_items.get(path,{})
|
||||
items.append({'content_id':previous.get('content_id',cid),'title':title,'description':desc,'content_type':kind,'path':path,'canonical_url':previous.get('canonical_url'), 'published_at':previous.get('published_at'), 'updated_at':previous.get('updated_at',date),'status':previous.get('status',status),'author':'Eddie Soehnel','topics':topics,'related_content_ids':[]})
|
||||
for cid,path,title,kind,desc,topics in FIXED: add(cid,path,title,kind,desc,topics,manifest['updated_at'])
|
||||
for p in sorted((root/'reports').rglob('*.md')):
|
||||
if 'receipts' in p.relative_to(root).parts: continue
|
||||
path=p.relative_to(root).as_posix()
|
||||
if p.name.startswith('GEO-AI-Search-Weekly-Research-Archive-'):
|
||||
match=re.search(r'(\d{4}-\d{2}-\d{2})_to_(\d{4}-\d{2}-\d{2})',p.name)
|
||||
coverage=f'{match[1]} through {match[2]}' if match else 'imported historical coverage'
|
||||
cid='seo-geo-history-'+re.sub(r'[^a-z0-9]+','-',p.stem.lower()).strip('-')
|
||||
add(cid,path,'Historical GEO / AI search archive','historical-archive','Imported '+coverage+'; original portable citations unavailable. Unverified historical context.', ['geo','ai-search','historical','unverified'],manifest['updated_at'],'archived')
|
||||
elif re.fullmatch(r'\d{4}-\d{2}-\d{2}-geo-ai-search-intelligence(?:-[a-zA-Z0-9-]+)?\.md',p.name):
|
||||
text=p.read_text(encoding='utf-8-sig'); title=next((line.lstrip('# ').strip() for line in text.splitlines() if line.startswith('# ')),p.stem)
|
||||
cid='seo-geo-report-'+p.stem
|
||||
add(cid,path,title,'research-report','Dated research report; consult body and local receipt for completion and coverage. Lifecycle publication status is recorded separately.', ['seo','geo','ai-search','weekly-report','web-search','exa'],p.name[:10])
|
||||
sources=[i['content_id'] for i in items if i['content_type'] in ['historical-archive','research-report']]
|
||||
for item in items:
|
||||
if item['content_id']=='seo-geo-research-rollup': item['related_content_ids']=sources
|
||||
elif item['content_type']=='research-report': item['related_content_ids']=['seo-geo-research-skill','seo-geo-report-template']
|
||||
index={'$schema':'./schemas/content-index.schema.json','schema_version':'1.0','collection_id':'seo-geo-research-documents','title':'SEO / GEO research documents','description':'File-level research catalog. Historical sources are unverified; cumulative rollup is derived. Completion and publication are distinct.','updated_at':old.get('updated_at',manifest['updated_at']),'items':items}
|
||||
if old and old.get('items')!=items:
|
||||
from datetime import datetime
|
||||
try:
|
||||
from zoneinfo import ZoneInfo
|
||||
today=datetime.now(ZoneInfo('America/Denver')).date().isoformat()
|
||||
except Exception:
|
||||
today=max([manifest['updated_at']]+[i.get('updated_at') or manifest['updated_at'] for i in items])
|
||||
index['updated_at']=today
|
||||
validate_index(root,index)
|
||||
return index
|
||||
|
||||
def build(root):
|
||||
root=Path(root); index=make_index(root); data=json.dumps(index,indent=2,ensure_ascii=False)+'\n'
|
||||
out=root/'content-index.json'; temp=out.with_suffix('.json.tmp')
|
||||
temp.write_text(data,encoding='utf-8'); temp.replace(out)
|
||||
if out.read_text(encoding='utf-8')!=data: raise IOError('Index readback failed')
|
||||
return index
|
||||
|
||||
if __name__=='__main__':
|
||||
parser=argparse.ArgumentParser(); parser.add_argument('--root',default=str(Path(__file__).resolve().parents[1])); args=parser.parse_args()
|
||||
print(f"Indexed {len(build(args.root)['items'])} documents")
|
||||
Reference in new issue
Block a user