CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
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 | ||
| 39 | **Deploys are self-driven now.** Push to `main` and | |
| 40 | `src/hooks/post-receive.ts` fires `scripts/self-deploy.sh` directly — | |
| 41 | no GitHub Actions involvement. The live site reflects the push in | |
| 42 | ~25 seconds. Watch `/admin/deploys` for the live step stream. | |
| 43 | ||
| 9ab6971 | 44 | ## READ FIRST — every session |
| 45 | ||
| 46 | **`BUILD_BIBLE.md` is mandatory reading for every Claude agent before any code changes.** | |
| 47 | ||
| 48 | It contains: | |
| 49 | - Agent policy (do-not-undo rule, continuous-build rule) | |
| 50 | - GitHub parity scorecard (what's shipped vs missing) | |
| 51 | - Numbered build plan (Blocks A–H) | |
| 52 | - Locked components that cannot be altered without owner permission | |
| 53 | - Session workflow | |
| 54 | ||
| 55 | Do not skip it. Do not refactor locked files. Do not stop mid-block. | |
| 56 | ||
| fc1817a | 57 | ## Stack |
| 58 | ||
| 59 | - **Runtime:** Bun | |
| 60 | - **Framework:** Hono (with JSX for server-rendered views) | |
| 61 | - **Database:** Drizzle ORM + Neon (PostgreSQL) | |
| 62 | - **Git:** Smart HTTP protocol via git CLI subprocesses | |
| 63 | ||
| 64 | ## Development | |
| 65 | ||
| 66 | ```bash | |
| 67 | bun install # install dependencies | |
| 68 | bun dev # start dev server (hot reload) | |
| 69 | bun test # run tests | |
| 70 | bun run db:migrate # run database migrations | |
| 71 | ``` | |
| 72 | ||
| 73 | ## Architecture | |
| 74 | ||
| 74a8784 | 75 | > Note (2026-06-10): the tree below is illustrative, not exhaustive — the |
| 76 | > platform has grown to ~190 route files in `src/routes/` and 161 tables in | |
| 77 | > `src/db/schema.ts`. `BUILD_BIBLE.md` §2 is the authoritative feature map. | |
| 78 | ||
| fc1817a | 79 | ``` |
| 80 | src/ | |
| 43de941 | 81 | index.ts Entry point (Bun server) |
| 82 | app.tsx Hono app composition + error handlers | |
| 83 | lib/ | |
| 84 | config.ts Environment config (getters, reads env at access time) | |
| 85 | auth.ts Password hashing (bcrypt), session tokens | |
| 86 | highlight.ts Syntax highlighting (highlight.js, 40+ languages) | |
| 87 | markdown.ts Markdown rendering (GFM + syntax highlighting) | |
| fc1817a | 88 | db/ |
| 43de941 | 89 | schema.ts Drizzle schema (all tables) |
| 90 | index.ts Lazy DB connection (proxy pattern) | |
| 91 | migrate.ts Migration runner | |
| fc1817a | 92 | git/ |
| 43de941 | 93 | repository.ts Git operations (tree, blob, commits, diff, branches, blame, search, raw) |
| 94 | protocol.ts Smart HTTP protocol (pkt-line, service RPC) | |
| fc1817a | 95 | hooks/ |
| 90fa787 | 96 | post-receive.ts GateTest + optional deploy webhook on push |
| 43de941 | 97 | middleware/ |
| 98 | auth.ts softAuth + requireAuth middleware | |
| fc1817a | 99 | routes/ |
| 43de941 | 100 | git.ts Git HTTP endpoints (clone/push) |
| 101 | api.ts REST API (repo CRUD, setup) | |
| 102 | auth.tsx Register, login, logout (web + API) | |
| 103 | web.tsx Web UI (file browser, commits, diffs, search, blame, raw) | |
| 104 | issues.tsx Issue tracker (CRUD, comments, close/reopen) | |
| 105 | pulls.tsx Pull requests (create, review, merge, close) | |
| 106 | editor.tsx Web file editor (create/edit via git plumbing) | |
| 107 | compare.tsx Branch comparison (diff + commit list) | |
| 108 | settings.tsx User settings (profile, SSH keys) | |
| 109 | repo-settings.tsx Repository settings (description, visibility, delete) | |
| 110 | webhooks.tsx Webhook management + delivery engine | |
| 111 | fork.ts Repository forking | |
| 112 | explore.tsx Explore/discover public repos | |
| 113 | tokens.tsx Personal access tokens | |
| 114 | contributors.tsx Contributor list + commit activity graph | |
| fc1817a | 115 | views/ |
| 43de941 | 116 | layout.tsx HTML shell + CSS (dark theme) + auth-aware nav |
| 117 | components.tsx UI components (file table, commit list, diff viewer, etc.) | |
| fc1817a | 118 | ``` |
| 119 | ||
| 43de941 | 120 | ## Database Schema |
| 121 | ||
| 122 | - `users` — accounts with bcrypt password hashing | |
| 123 | - `sessions` — cookie-based auth sessions (30 day expiry) | |
| 124 | - `repositories` — repos with fork tracking, star/fork/issue counts | |
| 125 | - `stars` — user-repo star relationships | |
| 126 | - `issues` — issue tracker with open/closed state | |
| 127 | - `issue_comments` — threaded comments on issues | |
| 128 | - `labels` + `issue_labels` — issue categorization | |
| 129 | - `pull_requests` — PRs with base/head branches, open/closed/merged state | |
| 130 | - `pr_comments` — PR comments with AI review flag + file/line annotations | |
| 131 | - `activity_feed` — event log for repos | |
| 132 | - `webhooks` — registered webhook URLs with HMAC secret + event filtering | |
| 133 | - `api_tokens` — personal access tokens with SHA-256 hashing | |
| 134 | - `repo_topics` — repository tags for discoverability | |
| 135 | - `ssh_keys` — user SSH public keys | |
| 136 | ||
| fc1817a | 137 | ## Integrations |
| 138 | ||
| 90fa787 | 139 | - **GateTest (optional):** third-party security scanner. When `GATETEST_URL` is set, `git push` POSTs to it; inbound results accepted at `POST /api/hooks/gatetest`. |
| 140 | - **Outbound deploy webhook (optional):** when `CRONTECH_DEPLOY_URL` is set, pushes to the default branch POST there. | |
| 141 | - **Webhooks:** POST to user-registered URLs on push/issue/PR/star events with HMAC signatures. | |
| fc1817a | 142 | |
| 143 | ## Environment Variables | |
| 144 | ||
| 145 | See `.env.example` for required variables. Key ones: | |
| 146 | - `DATABASE_URL` — Neon PostgreSQL connection string | |
| 147 | - `GIT_REPOS_PATH` — directory for bare git repos (default: `./repos`) | |
| 148 | - `PORT` — HTTP port (default: 3000) | |
| fc0785e | 149 | |
| 150 | ## Deployment | |
| 151 | ||
| 90fa787 | 152 | - **Primary target:** Fly.io — the repo ships a ready `fly.toml` (release command runs `bun run db:migrate`, `gluecron_repos` volume mounted at `/app/repos`). |
| 153 | - **Other hosts:** a `Dockerfile` is in the repo, so any standard Docker host works. | |
| 154 | - **Database:** Neon PostgreSQL (direct connection via `DATABASE_URL`). | |
| 155 | - See DEPLOY.md for full deployment instructions. | |
| 43095dc | 156 | |
| 157 | ## Skills available for this project | |
| 158 | ||
| 159 | Claude Code skill bundle for the Gluecron MCP write surface lives in | |
| 160 | `.claude/skills/`. The install script (`scripts/install.sh`) copies these | |
| 161 | into `~/.claude/skills/` so they are available across all projects: | |
| 162 | ||
| 163 | - **`gluecron-pr`** — open, list, fetch, comment on, merge, or close pull | |
| 164 | requests on a Gluecron-hosted repository. | |
| 165 | - **`gluecron-issue`** — create, list, comment on, close, or reopen issues | |
| 166 | on a Gluecron-hosted repository. | |
| 167 | - **`gluecron-review`** — act as a secondary AI code reviewer on a | |
| 168 | Gluecron PR; complements the built-in `src/lib/ai-review.ts` pass. | |
| 169 | ||
| 170 | All three skills drive the K1 MCP write tools defined in | |
| 171 | `src/lib/mcp-tools.ts` (`gluecron_create_issue`, `gluecron_create_pr`, | |
| 172 | `gluecron_merge_pr`, etc.). They auto-invoke when the active repo's | |
| 173 | origin URL contains `gluecron.com` or matches `$GLUECRON_HOST`. |