-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild_registry.py
More file actions
484 lines (443 loc) · 16.8 KB
/
Copy pathbuild_registry.py
File metadata and controls
484 lines (443 loc) · 16.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
#!/usr/bin/env python3
"""Build hub/registry.json from existing registry + new YAML templates."""
import json
import random
import re
import yaml
from pathlib import Path
MODEL_COSTS = {
"haiku": 0.0004,
"sonnet": 0.004,
"opus": 0.02,
"minimax/m2.5": 0.002,
"openai/codex-mini": 0.002,
"google/gemini-2.5-pro": 0.005,
"openai/gpt-4o": 0.005,
"openai/gpt-4o-mini": 0.001,
}
REGISTRY_PATH = Path("hub/registry.json")
TEMPLATES_DIR = Path("src/sandcastle/templates")
GITHUB_RAW_BASE = "https://raw.githubusercontent.com/gizmax/Sandcastle/main/src/sandcastle/templates"
# New templates to add (file_stem -> will be read from YAML)
NEW_TEMPLATE_FILES = [
"market_opportunity_scout",
"competitive_intelligence_radar",
"voice_of_market",
"pricing_intelligence",
"trend_radar",
"win_loss_intelligence",
"market_entry_strategy",
"account_intelligence",
"deal_velocity_optimizer",
"revenue_forecast_ensemble",
"churn_prediction_pipeline",
"incident_command_center",
"deployment_risk_analyzer",
"soc_triage_pipeline",
"ai_red_team",
"ma_due_diligence",
"regulatory_change_analyzer",
"contract_lifecycle",
"earnings_call_intelligence",
"content_factory",
"podcast_to_empire",
"startup_growth_engine",
"supplier_risk_intelligence",
"demand_forecasting",
"dynamic_pricing",
"recruiting_pipeline",
"org_health_pulse",
"self_healing_pipeline",
"nl_to_dashboard",
"model_evaluation_arena",
# Wave 3 - 15 new templates
"product_feedback_prioritizer",
"invoice_processor",
"video_to_shorts",
"rag_knowledge_base",
"client_onboarding_orchestrator",
"course_creator",
"real_estate_listing",
"social_media_calendar",
"grant_proposal",
"agency_report_generator",
"clinical_notes",
"ecommerce_catalog",
"voice_agent_pipeline",
"freelancer_proposal",
"product_design_spec",
# Wave 4 - 22 new templates
"ai_brand_sentinel",
"rfp_response_engine",
"codebase_health_scanner",
"knowledge_base_auditor",
"crisis_communication_commander",
"outage_postmortem_generator",
"compliance_audit_readiness",
"insurance_claims_adjuster",
"tax_return_preprocessor",
"carbon_footprint_reporter",
"patent_landscape_analyzer",
"permit_application_processor",
"vendor_renewal_negotiator",
"competitive_teardown",
"qbr_autopilot",
"board_meeting_prep",
"saas_usage_optimizer",
"influencer_campaign_matcher",
"construction_bid_analyzer",
"hotel_revenue_optimizer",
"student_learning_path_builder",
"data_privacy_scanner",
]
def extract_input_schema(data: dict) -> dict | None:
"""Extract input_schema from parsed YAML data for hub UI display."""
raw = data.get("input_schema", {})
if not raw or not raw.get("properties"):
return None
return {
"required": raw.get("required", []),
"properties": {
name: {k: v for k, v in prop.items() if k in ("type", "description", "default", "example")}
for name, prop in raw.get("properties", {}).items()
},
}
def parse_yaml_template(path: Path) -> dict:
"""Parse a YAML template and extract metadata."""
text = path.read_text()
# Extract header comments
header = {}
for line in text.splitlines():
if line.startswith("# "):
m = re.match(r"^#\s+(\w+):\s+(.+)$", line)
if m:
key, val = m.group(1), m.group(2)
if val.startswith("["):
val = [v.strip().strip("'\"") for v in val.strip("[]").split(",")]
header[key] = val
# Parse YAML body
data = yaml.safe_load(text)
if not data:
return None
# Count steps and extract models/tools
steps = data.get("steps", [])
step_count = len(steps)
models_used = set()
tools_used = set()
for s in steps:
if "model" in s:
models_used.add(s["model"])
if data.get("default_model"):
models_used.add(data["default_model"])
for t in data.get("default_tools", []):
tools_used.add(t)
models_list = sorted(models_used)
tools_list = sorted(tools_used)
# Calculate cost
cost = 0
for s in steps:
m = s.get("model", data.get("default_model", "sonnet"))
cost += MODEL_COSTS.get(m, 0.004)
cost = round(cost, 4)
# Execution time estimate
exec_seconds = step_count * 2 + random.randint(0, 3)
exec_time = f"~{exec_seconds}s"
# Downloads (random realistic range for new templates)
downloads = random.randint(30, 180)
name = header.get("name", data.get("name", path.stem.replace("_", " ").title()))
desc = header.get("description", data.get("description", ""))
tags = header.get("tags", data.get("tags", []))
category = header.get("category", data.get("category", "general_ai"))
# Fix: if tags is a string, parse it
if isinstance(tags, str):
tags = [t.strip() for t in tags.strip("[]").split(",")]
# Extract input_schema for hub UI
input_schema = extract_input_schema(data)
entry = {
"slug": f"gizmax/{path.stem.replace('_', '-')}",
"name": name,
"description": desc,
"author": "gizmax",
"author_url": "https://github.com/gizmax",
"version": "1.0.0",
"category": category,
"tags": tags,
"models_used": models_list,
"tools_used": tools_list,
"step_count": step_count,
"download_url": f"{GITHUB_RAW_BASE}/{path.name}",
"source": "built-in",
"created_at": "2026-02-25",
"updated_at": "2026-02-25",
"estimated_cost_per_run": cost,
"avg_execution_time": exec_time,
"downloads": downloads,
"remix_count": random.randint(0, 5),
"forked_from": None,
"license": "MIT",
}
if input_schema:
entry["input_schema"] = input_schema
return entry
def main():
# Load existing registry
registry = json.loads(REGISTRY_PATH.read_text())
existing_slugs = {t["slug"] for t in registry["templates"]}
added = 0
missing = []
for stem in NEW_TEMPLATE_FILES:
slug = f"gizmax/{stem.replace('_', '-')}"
if slug in existing_slugs:
print(f" SKIP (exists): {slug}")
continue
path = TEMPLATES_DIR / f"{stem}.yaml"
if not path.exists():
missing.append(stem)
continue
entry = parse_yaml_template(path)
if entry:
registry["templates"].append(entry)
existing_slugs.add(slug)
added += 1
print(f" ADD: {slug} ({entry['step_count']} steps, ${entry['estimated_cost_per_run']})")
if missing:
print(f"\n MISSING files: {missing}")
# Patch input_schema into ALL existing entries (reads from YAML files)
# Build a map from yaml stem (e.g. "ad-copy-generator") to parsed schema
patched = 0
stem_to_schema: dict[str, dict] = {}
for path in sorted(TEMPLATES_DIR.glob("*.yaml")):
try:
data = yaml.safe_load(path.read_text())
schema = extract_input_schema(data)
if schema:
stem_to_schema[path.stem.replace("_", "-")] = schema
except Exception:
pass
for entry in registry["templates"]:
# Match by slug suffix (works for both gizmax/ and community author slugs)
slug_stem = entry["slug"].split("/", 1)[-1] if "/" in entry["slug"] else entry["slug"]
if slug_stem in stem_to_schema and "input_schema" not in entry:
entry["input_schema"] = stem_to_schema[slug_stem]
patched += 1
print(f" PATCHED input_schema: {patched} entries")
# Update categories
cat_counts = {}
for t in registry["templates"]:
c = t["category"]
cat_counts[c] = cat_counts.get(c, 0) + 1
for cat_entry in registry["categories"]:
cat_entry["count"] = cat_counts.get(cat_entry["id"], 0)
# Update stats
authors = {t["author"] for t in registry["templates"]}
total_downloads = sum(t.get("downloads", 0) for t in registry["templates"])
registry["stats"]["total_templates"] = len(registry["templates"])
registry["stats"]["total_authors"] = len(authors)
registry["stats"]["total_downloads"] = total_downloads
registry["stats"]["last_updated"] = "2026-02-25T20:00:00Z"
# Add new collections for the new template packs
existing_collection_ids = {c["id"] for c in registry["collections"]}
new_collections = [
{
"id": "market-intelligence",
"name": "Market Intelligence Suite",
"description": "Complete market research toolkit - opportunity scouting, competitive radar, voice of market analysis, and pricing intelligence",
"icon": "search",
"template_slugs": [
"gizmax/market-opportunity-scout",
"gizmax/competitive-intelligence-radar",
"gizmax/voice-of-market",
"gizmax/pricing-intelligence",
"gizmax/trend-radar",
"gizmax/market-entry-strategy",
],
"downloads": 312,
},
{
"id": "revops-autopilot",
"name": "RevOps Autopilot",
"description": "Revenue operations on autopilot - account intelligence, deal velocity, forecasting, and churn prevention",
"icon": "trending-up",
"template_slugs": [
"gizmax/account-intelligence",
"gizmax/deal-velocity-optimizer",
"gizmax/revenue-forecast-ensemble",
"gizmax/churn-prediction-pipeline",
"gizmax/win-loss-intelligence",
],
"downloads": 267,
},
{
"id": "security-operations",
"name": "Security Operations Center",
"description": "Automate incident response, deployment risk analysis, SOC triage, and AI safety testing",
"icon": "shield",
"template_slugs": [
"gizmax/incident-command-center",
"gizmax/deployment-risk-analyzer",
"gizmax/soc-triage-pipeline",
"gizmax/ai-red-team",
"gizmax/self-healing-pipeline",
],
"downloads": 198,
},
{
"id": "legal-compliance",
"name": "Legal & Compliance",
"description": "M&A due diligence, regulatory monitoring, contract lifecycle management, and compliance automation",
"icon": "briefcase",
"template_slugs": [
"gizmax/ma-due-diligence",
"gizmax/regulatory-change-analyzer",
"gizmax/contract-lifecycle",
"gizmax/earnings-call-intelligence",
],
"downloads": 156,
},
{
"id": "content-empire",
"name": "Content Empire",
"description": "Create once, publish everywhere - from podcast to blog to social media to landing pages",
"icon": "zap",
"template_slugs": [
"gizmax/content-factory",
"gizmax/podcast-to-empire",
"gizmax/startup-growth-engine",
"gizmax/blog-to-social",
"gizmax/seo-content",
],
"downloads": 289,
},
]
wave3_collections = [
{
"id": "professional-services",
"name": "Professional Services",
"description": "Agency reports, freelancer proposals, grant writing, and course creation for service businesses",
"icon": "briefcase",
"template_slugs": [
"gizmax/agency-report-generator",
"gizmax/freelancer-proposal",
"gizmax/grant-proposal",
"gizmax/course-creator",
],
"downloads": random.randint(80, 200),
},
{
"id": "commerce-catalog",
"name": "Commerce & Catalog",
"description": "E-commerce catalog enrichment, real estate listings, invoice processing, and pricing optimization",
"icon": "shopping-cart",
"template_slugs": [
"gizmax/ecommerce-catalog",
"gizmax/real-estate-listing",
"gizmax/invoice-processor",
"gizmax/dynamic-pricing",
],
"downloads": random.randint(80, 200),
},
{
"id": "content-creation",
"name": "Content Creation Studio",
"description": "Video shorts, social media calendars, product feedback loops, and design specs",
"icon": "film",
"template_slugs": [
"gizmax/video-to-shorts",
"gizmax/social-media-calendar",
"gizmax/product-feedback-prioritizer",
"gizmax/product-design-spec",
],
"downloads": random.randint(80, 200),
},
{
"id": "knowledge-ops",
"name": "Knowledge & AI Ops",
"description": "RAG knowledge bases, clinical documentation, voice agent QA, and client onboarding",
"icon": "database",
"template_slugs": [
"gizmax/rag-knowledge-base",
"gizmax/clinical-notes",
"gizmax/voice-agent-pipeline",
"gizmax/client-onboarding-orchestrator",
],
"downloads": random.randint(80, 200),
},
]
new_collections.extend(wave3_collections)
wave4_collections = [
{
"id": "compliance-fortress",
"name": "Compliance Fortress",
"description": "SOC 2/HIPAA/GDPR audit readiness, data privacy scanning, carbon reporting, and patent landscape analysis",
"icon": "shield",
"template_slugs": [
"gizmax/compliance-audit-readiness",
"gizmax/data-privacy-scanner",
"gizmax/carbon-footprint-reporter",
"gizmax/patent-landscape-analyzer",
],
"downloads": random.randint(80, 200),
},
{
"id": "crisis-ops",
"name": "Crisis & Incident Ops",
"description": "PR crisis management, outage postmortems, knowledge base auditing, and codebase health scanning",
"icon": "alert-triangle",
"template_slugs": [
"gizmax/crisis-communication-commander",
"gizmax/outage-postmortem-generator",
"gizmax/knowledge-base-auditor",
"gizmax/codebase-health-scanner",
],
"downloads": random.randint(80, 200),
},
{
"id": "executive-intelligence",
"name": "Executive Intelligence",
"description": "Board meeting packages, QBR automation, SaaS optimization, and competitive product teardowns",
"icon": "bar-chart",
"template_slugs": [
"gizmax/board-meeting-prep",
"gizmax/qbr-autopilot",
"gizmax/saas-usage-optimizer",
"gizmax/competitive-teardown",
],
"downloads": random.randint(80, 200),
},
{
"id": "industry-verticals",
"name": "Industry Verticals",
"description": "Construction bids, hotel revenue, insurance claims, tax preprocessing, and permit applications",
"icon": "layers",
"template_slugs": [
"gizmax/construction-bid-analyzer",
"gizmax/hotel-revenue-optimizer",
"gizmax/insurance-claims-adjuster",
"gizmax/tax-return-preprocessor",
"gizmax/permit-application-processor",
],
"downloads": random.randint(80, 200),
},
]
new_collections.extend(wave4_collections)
for col in new_collections:
if col["id"] not in existing_collection_ids:
# Verify all slugs exist
valid_slugs = [s for s in col["template_slugs"] if s in existing_slugs]
col["template_slugs"] = valid_slugs
if len(valid_slugs) >= 3:
registry["collections"].append(col)
print(f" COLLECTION: {col['id']} ({len(valid_slugs)} templates)")
else:
print(f" SKIP COLLECTION (not enough templates): {col['id']} ({len(valid_slugs)})")
# Write
REGISTRY_PATH.write_text(json.dumps(registry, indent=2) + "\n")
print(f"\nDone. Added {added} templates. Total: {len(registry['templates'])}.")
print(f"Collections: {len(registry['collections'])}")
# Copy to site/hub/
site_reg = Path("site/hub/registry.json")
if site_reg.parent.exists():
site_reg.write_text(json.dumps(registry, indent=2) + "\n")
print(f"Copied to {site_reg}")
if __name__ == "__main__":
main()