Blame · Line-by-line history
CLAUDE.md
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| fc1817a | 1 | # gluecron |
| 2 | ||
| 90fa787 | 3 | AI-native code intelligence platform — git hosting, automated CI, and push-time gate enforcement. |
| fc1817a | 4 | |
| 3b99c5f | 5 | ## Source of truth: Gluecron (not GitHub) |
| 6 | ||
| 7 | This repository self-hosts on Gluecron itself. The canonical remote is | |
| 8 | `https://gluecron.com/ccantynz/Gluecron.com.git`. GitHub is a 7-day | |
| 9 | fallback mirror only. | |
| 10 | ||
| 11 | **For any AI session working in this repo:** | |
| 12 | ||
| 4cd9a67 | 13 | - Use the Gluecron MCP server. It is declared in `.mcp.json` at the |
| 14 | repo root (project scope — this is the file Claude Code actually | |
| 15 | loads MCP servers from, on both web/cloud sessions and the CLI; the | |
| 16 | old `mcpServers` block in `.claude/settings.json` was never read). | |
| 17 | Tools: `gluecron_create_pr`, `gluecron_merge_pr`, | |
| 3b99c5f | 18 | `gluecron_create_issue`, `gluecron_comment_pr`, etc. See |
| 19 | `src/lib/mcp-tools.ts` for the full 15-tool surface. | |
| 4cd9a67 | 20 | - **Cloud (web) sessions:** the clone comes from the GitHub mirror and |
| 21 | `git push` to origin goes through the GitHub proxy. To run a PR | |
| 22 | through Gluecron: (1) push the feature branch to origin as usual, | |
| 23 | (2) also push it to the canonical remote — | |
| 24 | `git push https://x:${GLUECRON_PAT}@gluecron.com/ccantynz/Gluecron.com.git HEAD:<branch>` | |
| 25 | (requires `gluecron.com` in the environment's network allowlist) — | |
| 26 | then (3) open the PR with `gluecron_create_pr`. If gluecron.com is | |
| 27 | unreachable, fall back to GitHub and say so in the session. | |
| 3b99c5f | 28 | - Do NOT call any `mcp__github__*` write tool. The settings file's |
| 29 | `permissions.deny` already blocks them; if you encounter a deny | |
| 30 | error, switch to the equivalent `gluecron_*` tool. | |
| 31 | - The `.claude/skills/gluecron-pr`, `gluecron-issue`, and | |
| 32 | `gluecron-review` skills are the highest-leverage entry points for | |
| 33 | routine work. Invoke them when the user mentions a PR, an issue, | |
| 34 | or wants a second AI review pass. | |
| 35 | - Auth: the `GLUECRON_PAT` env var holds the user's personal access | |
| 36 | token. If it's missing, prompt the user to generate one at | |
| 37 | `/settings/tokens` (admin scope required for the merge tools). | |
| 38 | ||
| ab45e6a | 39 | **Deploys are self-driven now.** Push to the canonical Gluecron remote |
| 40 | and `src/hooks/post-receive.ts` fires `scripts/self-deploy.sh` directly. | |
| 41 | The live site reflects the push in ~25 seconds. Watch `/admin/deploys` | |
| 42 | for the live step stream. | |
| 43 | ||
| 44 | **Server:** `gluecron.com` → `66.42.121.161` (VPS, not Fly.io or Hetzner — | |
| 45 | both are decommissioned). Working tree lives at `/opt/gluecron` on that box. | |
| 46 | ||
| 47 | **To deploy:** | |
| 48 | ```bash | |
| 49 | git push gluecron main | |
| 50 | # or first-time setup: | |
| 51 | git remote add gluecron https://x:${GLUECRON_PAT}@gluecron.com/ccantynz/Gluecron.com.git | |
| 52 | ``` | |
| 53 | ||
| 54 | **Do NOT use Vercel** — it has been disconnected. GitHub (`ccantynz-alt/Gluecron.com`) | |
| 55 | is a mirror only; pushing there does not deploy. | |
| 3b99c5f | 56 | |
| 9ab6971 | 57 | ## READ FIRST — every session |
| 58 | ||
| 59 | **`BUILD_BIBLE.md` is mandatory reading for every Claude agent before any code changes.** | |
| 60 | ||
| 61 | It contains: | |
| 62 | - Agent policy (do-not-undo rule, continuous-build rule) | |
| 63 | - GitHub parity scorecard (what's shipped vs missing) | |
| 64 | - Numbered build plan (Blocks A–H) | |
| 65 | - Locked components that cannot be altered without owner permission | |
| 66 | - Session workflow | |
| 67 | ||
| 68 | Do not skip it. Do not refactor locked files. Do not stop mid-block. | |
| 69 | ||
| fc1817a | 70 | ## Stack |
| 71 | ||
| 72 | - **Runtime:** Bun | |
| 73 | - **Framework:** Hono (with JSX for server-rendered views) | |
| 74 | - **Database:** Drizzle ORM + Neon (PostgreSQL) | |
| 75 | - **Git:** Smart HTTP protocol via git CLI subprocesses | |
| 76 | ||
| 77 | ## Development | |
| 78 | ||
| 79 | ```bash | |
| 80 | bun install # install dependencies | |
| 81 | bun dev # start dev server (hot reload) | |
| 82 | bun test # run tests | |
| 83 | bun run db:migrate # run database migrations | |
| 84 | ``` | |
| 85 | ||
| 86 | ## Architecture | |
| 87 | ||
| 74a8784 | 88 | > Note (2026-06-10): the tree below is illustrative, not exhaustive — the |
| 89 | > platform has grown to ~190 route files in `src/routes/` and 161 tables in | |
| 90 | > `src/db/schema.ts`. `BUILD_BIBLE.md` §2 is the authoritative feature map. | |
| 91 | ||
| fc1817a | 92 | ``` |
| 93 | src/ | |
| 43de941 | 94 | index.ts Entry point (Bun server) |
| 95 | app.tsx Hono app composition + error handlers | |
| 96 | lib/ | |
| 97 | config.ts Environment config (getters, reads env at access time) | |
| 98 | auth.ts Password hashing (bcrypt), session tokens | |
| 99 | highlight.ts Syntax highlighting (highlight.js, 40+ languages) | |
| 100 | markdown.ts Markdown rendering (GFM + syntax highlighting) | |
| fc1817a | 101 | db/ |
| 43de941 | 102 | schema.ts Drizzle schema (all tables) |
| 103 | index.ts Lazy DB connection (proxy pattern) | |
| 104 | migrate.ts Migration runner | |
| fc1817a | 105 | git/ |
| 43de941 | 106 | repository.ts Git operations (tree, blob, commits, diff, branches, blame, search, raw) |
| 107 | protocol.ts Smart HTTP protocol (pkt-line, service RPC) | |
| fc1817a | 108 | hooks/ |
| 90fa787 | 109 | post-receive.ts GateTest + optional deploy webhook on push |
| 43de941 | 110 | middleware/ |
| 111 | auth.ts softAuth + requireAuth middleware | |
| fc1817a | 112 | routes/ |
| 43de941 | 113 | git.ts Git HTTP endpoints (clone/push) |
| 114 | api.ts REST API (repo CRUD, setup) | |
| 115 | auth.tsx Register, login, logout (web + API) | |
| 116 | web.tsx Web UI (file browser, commits, diffs, search, blame, raw) | |
| 117 | issues.tsx Issue tracker (CRUD, comments, close/reopen) | |
| 118 | pulls.tsx Pull requests (create, review, merge, close) | |
| 119 | editor.tsx Web file editor (create/edit via git plumbing) | |
| 120 | compare.tsx Branch comparison (diff + commit list) | |
| 121 | settings.tsx User settings (profile, SSH keys) | |
| 122 | repo-settings.tsx Repository settings (description, visibility, delete) | |
| 123 | webhooks.tsx Webhook management + delivery engine | |
| 124 | fork.ts Repository forking | |
| 125 | explore.tsx Explore/discover public repos | |
| 126 | tokens.tsx Personal access tokens | |
| 127 | contributors.tsx Contributor list + commit activity graph | |
| fc1817a | 128 | views/ |
| 43de941 | 129 | layout.tsx HTML shell + CSS (dark theme) + auth-aware nav |
| 130 | components.tsx UI components (file table, commit list, diff viewer, etc.) | |
| fc1817a | 131 | ``` |
| 132 | ||
| 43de941 | 133 | ## Database Schema |
| 134 | ||
| 135 | - `users` — accounts with bcrypt password hashing | |
| 136 | - `sessions` — cookie-based auth sessions (30 day expiry) | |
| 137 | - `repositories` — repos with fork tracking, star/fork/issue counts | |
| 138 | - `stars` — user-repo star relationships | |
| 139 | - `issues` — issue tracker with open/closed state | |
| 140 | - `issue_comments` — threaded comments on issues | |
| 141 | - `labels` + `issue_labels` — issue categorization | |
| 142 | - `pull_requests` — PRs with base/head branches, open/closed/merged state | |
| 143 | - `pr_comments` — PR comments with AI review flag + file/line annotations | |
| 144 | - `activity_feed` — event log for repos | |
| 145 | - `webhooks` — registered webhook URLs with HMAC secret + event filtering | |
| 146 | - `api_tokens` — personal access tokens with SHA-256 hashing | |
| 147 | - `repo_topics` — repository tags for discoverability | |
| 148 | - `ssh_keys` — user SSH public keys | |
| 149 | ||
| fc1817a | 150 | ## Integrations |
| 151 | ||
| 90fa787 | 152 | - **GateTest (optional):** third-party security scanner. When `GATETEST_URL` is set, `git push` POSTs to it; inbound results accepted at `POST /api/hooks/gatetest`. |
| 9ecf5a4 | 153 | - **Outbound deploy webhook (optional):** when `VAPRON_DEPLOY_URL` is set (legacy `CRONTECH_DEPLOY_URL` honored), pushes to the default branch POST to Vapron (formerly Crontech). |
| 90fa787 | 154 | - **Webhooks:** POST to user-registered URLs on push/issue/PR/star events with HMAC signatures. |
| fc1817a | 155 | |
| 156 | ## Environment Variables | |
| 157 | ||
| 158 | See `.env.example` for required variables. Key ones: | |
| 159 | - `DATABASE_URL` — Neon PostgreSQL connection string | |
| 160 | - `GIT_REPOS_PATH` — directory for bare git repos (default: `./repos`) | |
| 161 | - `PORT` — HTTP port (default: 3000) | |
| fc0785e | 162 | |
| 163 | ## Deployment | |
| 164 | ||
| ab45e6a | 165 | - **Production server:** `66.42.121.161` (`gluecron.com`) — VPS running Bun directly via systemd. |
| 166 | - **Deploy trigger:** `git push gluecron main` → `post-receive.ts` → `scripts/self-deploy.sh` → systemd reload. | |
| 167 | - **Fly.io:** decommissioned (fly.toml kept for reference, not active). | |
| 168 | - **Vercel:** disconnected — do not reconnect. | |
| 90fa787 | 169 | - **Database:** Neon PostgreSQL (direct connection via `DATABASE_URL`). |
| ab45e6a | 170 | - **Logs:** `/var/log/gluecron-self-deploy.log` on the server; live stream at `/admin/deploys`. |
| 43095dc | 171 | |
| 172 | ## Skills available for this project | |
| 173 | ||
| 174 | Claude Code skill bundle for the Gluecron MCP write surface lives in | |
| 175 | `.claude/skills/`. The install script (`scripts/install.sh`) copies these | |
| 176 | into `~/.claude/skills/` so they are available across all projects: | |
| 177 | ||
| 178 | - **`gluecron-pr`** — open, list, fetch, comment on, merge, or close pull | |
| 179 | requests on a Gluecron-hosted repository. | |
| 180 | - **`gluecron-issue`** — create, list, comment on, close, or reopen issues | |
| 181 | on a Gluecron-hosted repository. | |
| 182 | - **`gluecron-review`** — act as a secondary AI code reviewer on a | |
| 183 | Gluecron PR; complements the built-in `src/lib/ai-review.ts` pass. | |
| 184 | ||
| 185 | All three skills drive the K1 MCP write tools defined in | |
| 186 | `src/lib/mcp-tools.ts` (`gluecron_create_issue`, `gluecron_create_pr`, | |
| 187 | `gluecron_merge_pr`, etc.). They auto-invoke when the active repo's | |
| 188 | origin URL contains `gluecron.com` or matches `$GLUECRON_HOST`. |