"""Build the sghadimi.com copy of Clutch Coach from the Claude preview page. The preview is one index.html with its CSS and JS inline. The site's security policy allows no inline scripts, so this splits them into coach.css and coach.js, and makes the changes the public site needs: - a title, description, icon and a "Free tools" link back to the site; -
becomes
so the site does not add its own footer inside the app; - saving uses a plain browser download (the preview saves through claude.ai); - the Claude-only buttons (form feedback, improvement plan, tracking check, captions, message) are hidden, because they only work inside claude.ai; the on-device coaching moments stay; - the internal hand-off notes on the Status tab (next steps for the owner, the QC prompt with private links) are left out; - a line naming the vision model's license. Usage: python3 kit/site.py The other files (fonts/, audio/, media/, vendor/, model/) are copied unchanged from the preview.""" import sys, os, re src, out = sys.argv[1], sys.argv[2] s = open(src, encoding='utf8').read() def sub1(pat, rep, text, flags=0): new, n = re.subn(pat, rep, text, count=1, flags=flags) assert n == 1, 'not found: ' + pat[:60] return new def rep1(old, new, text): assert text.count(old) == 1, 'expected once: ' + old[:60] return text.replace(old, new) # The preview may already carry the tour (tour.js beside it) and the phone fixes; take them out here so they are added once. s = s.replace('\n', '') s = s.replace('\n ', '') head_end = s.index('') css = re.search(r'', s[:head_end], re.S).group(1) s = s[:head_end].replace('', '') + s[head_end:] js_start = s.index('') js = s[js_start + len('' + s[js_end + len(''):] # --- head --- s = rep1('Clutch Coach', 'Clutch Coach: free basketball shooting and form stats from a phone video\n' '\n' '', s) # --- layout: no site footer inside the app --- s = rep1('
', '
', s) s = rep1('
', '
', s) css = sub1(r'(^|\n)main\{', r'\1.main{', css) css = sub1(r'\n(\s+)main\{', r'\n\1.main{', css) # --- back to the site --- s = rep1('CLUTCHCoach\n ', 'CLUTCHCoach\n \n Free tools ›', s) css += ('\n/* sghadimi.com */\n' '.home{font:600 13px var(--body,inherit);color:#8C96AA;text-decoration:none;white-space:nowrap;margin-left:4px}\n' '.home:hover{color:#FF5A1F}\n' '@media (max-width:360px){.home{font-size:12px}}\n' '#formBtn,#planBtn,#verifyBtn,#claudeBtn,#recapBtn{display:none!important}\n' '.railfoot .row:empty{display:none}\n') # --- Claude-only features: say so once, where the pipeline is explained --- s = rep1('Claude is only asked when you press Form feedback, Improvement plan or the tracking check, and then it gets still frames of your player.', 'On this site nothing leaves your device. The version that runs inside Claude also writes form feedback from still frames and a week-long improvement plan; the master prompt on the project page rebuilds it.', s) s = rep1('The jersey number lets Claude double-check the tracking and who took each shot.', 'The jersey number and name label the report.', s) s = rep1('', '', s) js = rep1('$("#mReel").onclick = () => $("#planBtn").click();', '$("#mReel").onclick = () => $("#reelBtn").click();', js) # --- Status tab: public part only --- i = s.index('

Next steps, in order

') j = s.index('Copy QC prompt') + len('Copy QC prompt') s = s[:i] + s[j:] s = sub1(r'

Status, QC and next steps

\s*

.*?

', '

Status and checks

\n

Where Clutch Coach stands: what has been checked and how, what is still unchecked, and the known bugs.

', s, re.S) js = sub1(r'\$\("#qcCopy"\)\.onclick = .*?\n', '', js) # --- Compare tab: what this copy does, and the Superstat price as its linked store page shows it --- s = rep1("for one player; Claude form review and a week's practice plan", "for one player; time-tagged form fixes with drills (the Claude version adds a form review and a week's practice plan)", s) s = rep1('€10/game · €179.99/season', 'A$15–20/game · A$229.99/season (AU App Store)', s) # --- layout fixes for the site's four test sizes --- css += ('.nav a{white-space:nowrap}\n' '@media (max-width:900px){.top .pill{display:none}}\n' '@media (max-width:700px){.mobilebar{display:flex}.pipeline{grid-template-columns:1fr!important}}\n' '@media (max-width:700px), (max-height:500px){\n' ' .stage.picking .pickbar{position:fixed;left:10px;right:10px;bottom:calc(10px + env(safe-area-inset-bottom));transform:none;width:auto;z-index:40}\n' ' body:has(.stage.picking) .mobilebar{display:none}}\n') # On a phone the tap-to-mark controls covered most of the picture; they now sit at the bottom of the screen and the # picture scrolls up under the header so the whole frame stays tappable. js += ('\n// sghadimi.com: on phones, bring the picture up under the header while marking the hoop, court or player\n' 'new MutationObserver(() => { const st = document.getElementById("stage"); if (!st.classList.contains("picking") || !matchMedia("(max-width:700px), (max-height:500px)").matches) return;\n' ' const top = document.querySelector(".top"); scrollTo({top: st.getBoundingClientRect().top + scrollY - (top ? top.offsetHeight : 0) - 8, behavior: "smooth"});\n' '}).observe(document.getElementById("stage"), {attributes: true, attributeFilter: ["class"]});\n') # --- "Show me how": a 30-second guided tour of the sample report (tour.js, kept beside this script) --- s = rep1('', '\n ', s) s = rep1('', '\n', s) css += ('.tour-card{position:fixed;left:50%;bottom:calc(16px + env(safe-area-inset-bottom));transform:translateX(-50%);width:min(420px,calc(100% - 20px));z-index:60;' 'background:#141a26;border:1px solid rgba(255,90,31,.55);border-radius:16px;padding:14px 16px;box-shadow:0 18px 50px rgba(0,0,0,.55)}\n' '.tour-card[hidden]{display:none}\n' '.tour-top{display:flex;justify-content:space-between;align-items:center;font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:#8C96AA}\n' '.tour-x{background:none;border:0;color:#8C96AA;font-size:22px;line-height:1;cursor:pointer;padding:2px 6px}\n' '.tour-t{display:block;font-family:var(--display);text-transform:uppercase;letter-spacing:.04em;font-size:20px;margin:4px 0 2px}\n' '.tour-p{margin:0 0 12px;font-size:14px;color:#c9d0dc;line-height:1.45}\n' '.tour-acts{display:flex;gap:8px;justify-content:flex-end}\n' '.tour-lit{outline:3px solid #FF5A1F;outline-offset:4px;border-radius:var(--r)}\n' 'body.touring .mobilebar{display:none}\n' 'body.touring .main{padding-bottom:220px}\n' '@media (max-height:500px) and (min-width:600px){.tour-card{left:auto;right:10px;top:70px;bottom:auto;transform:none;width:300px}body.touring .main{padding-right:320px;padding-bottom:40px}}\n') # --- license line --- s = rep1('

Known limits

', '

Known limits

\n

Vision model: YOLOv8n by Ultralytics, AGPL-3.0, run in the browser with onnxruntime-web (MIT). The page\'s full code is on its project page.

', s) # --- saving: a plain download on the site; Claude is not available here --- js = sub1(r'function cap\(name\)\{.*?\n\}\n', 'function cap(name){\n' ' // sghadimi.com: no claude.ai capabilities. Saving is a plain browser download; Claude features are hidden.\n' ' if (name !== "downloads") return Promise.resolve(null);\n' ' return Promise.resolve({ save: async ({filename, data}) => {\n' ' const blob = data instanceof Blob ? data : new Blob([data], {type: /\\.csv$/.test(filename) ? "text/csv" : /\\.html$/.test(filename) ? "text/html" : "application/octet-stream"});\n' ' const a = document.createElement("a"); a.href = URL.createObjectURL(blob); a.download = filename; document.body.appendChild(a); a.click();\n' ' setTimeout(() => { URL.revokeObjectURL(a.href); a.remove(); }, 4000);\n' ' return {status: "saved"};\n' ' } });\n' '}\n', js, re.S) assert '