Deploy

Compile TypeScript, sync caches, push to GitHub Pages, and sync Supabase.

kittechsix-blip updated 22d ago
Claude CodeGeneric
View source ↗
# Deploy myMedKitt

Compile TypeScript, sync caches, push to GitHub Pages, and sync Supabase.

**RULE: Users must NEVER need to manually clear cache.** The deploy process must handle all three data layers (Supabase, IndexedDB, SW cache) so content updates are automatic.

## Steps

00. **EDEADLK Preflight (informational — DO NOT abort the deploy):**
    ```bash
    # Diagnostic only. EDEADLK is not a build blocker anymore.
    ls ~/Desktop/myMedKitt >/dev/null 2>&1 && echo "project dir OK"        || echo "project dir blocked (will use /tmp at commit)"
    cd ~/Desktop/myMedKitt && git status >/dev/null 2>&1 && echo "git OK"  || echo "git blocked (will use /tmp at commit)"
    ```

    Build steps 1-7 (TypeScript compile, CSS copy, cache sync, Supabase push, file verification) run on Desktop as usual — none of them go through git's mmap path, so they work even when git is locked. The commit/push step (step 8) routes through `~/Desktop/claude-brain/bin/git-via-tmp.sh`, which transparently falls back to a `/tmp` shadow when Desktop git can't open its pack files. Andy does NOT need to reboot, and does NOT need to be at the Mac.

    Reboot is the last resort, not the first response. Verified 2-for-2 on real deploys (2026-05-20 culture-positive-results-ed, 2026-05-21 status-epilepticus BAO mimicker). Full reference: `~/Desktop/claude-brain/operations/edeadlk-playbook.md`.

0. **MANDATORY — Lint CRITICAL_ACTIONS linkage:**
   ```bash
   node scripts/lint-critical-actions.mjs --strict

This asserts every nodeId referenced in *_CRITICAL_ACTIONS arrays resolves to an actual node in the same tree's *_NODES array. Broken linkage = dead clinical guidance link = FDA Prong-4 risk (clinician cannot review the basis for the recommendation).

If this step fails, the deploy ABORTS. Fix the broken nodeIds before continuing. Either:

  • Rename the CRITICAL_ACTIONS nodeId to match an existing node id (most common — usually a node was renamed without updating the reference), OR
  • Add the missing node to the NODES array if the critical action references content that should exist, OR
  • Remove the dead reference from CRITICAL_ACTIONS if it's no longer clinically relevant

Carried recommendation across 6 Louis Litt audits. Closed 2026-05-12 — initial enforcement caught 266 broken nodeIds across 54 files.

  1. Compile TypeScript:

    bunx tsc --skipLibCheck --noUnusedLocals false
    

    Verify zero errors (ignore bun-types lib conflicts).

  2. Copy CSS to docs:

    cp src/views/style.css docs/style.css
    
  3. Run cache sync automation:

    node scripts/deploy-cache-sync.mjs
    

    What it does automatically:

    • Detects which tree/drug/info-page data files changed (via git diff against HEAD)
    • Generates supabase-hotfix-update.sql with UPDATE statements for changed nodes
    • Bumps DATA_VERSION in both src/services/cache-db.ts and docs/services/cache-db.js → forces IndexedDB wipe
    • Bumps CACHE_NAME version in docs/sw.js → triggers service worker update

    Optional flags:

    • --dry-run — preview changes without writing anything
    • --skip-data-version — don't bump DATA_VERSION (e.g., CSS-only deploys)
    • --skip-sw — don't bump SW cache (unusual, almost never skip this)

    After running, recompile to pick up the DATA_VERSION change:

    bunx tsc --skipLibCheck --noUnusedLocals false
    
  4. MANDATORY — Supabase sync for changed tree/node data: The app loads from Supabase FIRST. If Supabase has stale data, users see stale content regardless of hardcoded fixes or cache bumps. This step is NOT optional when any tree node content changes.

    4a. Check if deploy-cache-sync generated UPDATE SQL:

    • If supabase-hotfix-update.sql was generated → use it (step 9)
    • If it shows ⚠ Unknown tree warnings or "No node-level changes detected" but you changed tree nodes → the script failed. Proceed to 4b.

    4b. Push directly via REST API (preferred — no copy-paste):

    node scripts/supabase-push.mjs <tree-id> --update
    

    This reads compiled JS from docs/ and pushes nodes + citations + metadata directly to Supabase via REST API. No SQL editor needed.

    For new consults, omit --update:

    node scripts/supabase-push.mjs <tree-id>
    

    4c. Fallback — manual SQL paste (only if REST push fails):

    open -a TextEdit supabase-hotfix-update.sql
    

    User: Cmd+A, Cmd+C, Supabase → New Query, Cmd+V, Run. If "destructive operation" warning appears: click "Run this query" — it's safe.

    Skip step 4 ONLY if the deploy touches zero tree/node data (e.g., CSS-only, calculator-only, new skill file).

  5. Generate Supabase INSERT SQL (for NEW consults only): Only for NEW consults. Step 4 handles updates to existing consults. Wait until all testing and iteration is complete.

    node scripts/generate-supabase-sql.mjs <tree-id> \
      --drugs <comma-separated new drug IDs> \
      --info-pages <comma-separated new info page IDs>
    
    • The script reads compiled JS from docs/ and outputs supabase-<tree-id>-insert.sql
    • Include --drugs for any NEW drugs added in this consult
    • Include --info-pages for any NEW info pages added

    Then push directly via REST API (preferred):

    node scripts/supabase-push.mjs <tree-id>
    

    Add --drugs id1,id2 and --info-pages id1,id2 flags for any new drugs/info pages.

    Skip this step if no new consult was added.

  6. Verify docs/sw.js has content:

    wc -l docs/sw.js
    

    If it's 0 lines, restore from git: git show HEAD:docs/sw.js > docs/sw.js and re-run step 3.

  7. Verify ALL compiled files are staged: Run git status docs/ and check for ANY unstaged changes. Every modified file in docs/ MUST be committed.

  8. Stage, commit, and push — via the EDEADLK-safe helper:


Maintain Deploy?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Deploy on getagentictools](https://getagentictools.com/loops/kittechsix-blip-deploy-mymedkitt?ref=badge)