Skip to content

Commit eafa98e

Browse files
committed
resources and usage
1 parent 1677d42 commit eafa98e

23 files changed

Lines changed: 2688 additions & 160 deletions

README.md

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ If anything fails, use `hack logs --pretty` and summarize next steps.
104104

105105
If the agent cannot run shell commands, use MCP instead: `hack setup mcp` and `hack mcp serve`.
106106

107-
### Initialize a repo (manual)
108-
```bash
109-
cd /path/to/your-repo
110-
hack init
111-
hack up --detach
112-
hack open
113-
```
114-
115107
### Configuration (.hack/hack.config.json)
116108
- `name`: project slug (also used for Docker Compose project name)
117109
- `dev_host`: base hostname (`<dev_host>.hack`)
@@ -152,16 +144,16 @@ hack config set logs.snapshot_backend "compose"
152144

153145
## Commands (high level)
154146

155-
- **Global**: `hack global install|up|down|status|logs|logs-reset|ca|cert|trust`
156-
- **Project**: `hack init|up|down|restart|ps|run|logs|open|tui`
157-
- **Config**: `hack config get|set`
158-
- **Projects**: `hack projects|prune`
159-
- **Status**: `hack status` (shortcut for `hack projects --details`)
160-
- **Branch**: `hack branch add|list|remove|open`
161-
- **Agents**: `hack setup cursor|claude|codex|agents|mcp`, `hack agent prime|init|patterns`, `hack mcp serve|install|print`
162-
- **Diagnostics**: `hack doctor|daemon|log-pipe`
163-
- **Secrets**: `hack secrets get|set|delete`
164-
- **Crash override**: `hack the planet`
147+
Run `hack help` (or `hack help <command>`) for full usage.
148+
149+
Common:
150+
- `hack global install|up|down`
151+
- `hack init|up|down|logs|open|tui`
152+
- `hack status`
153+
- `hack remote setup`
154+
- `hack gateway enable`
155+
156+
Full command table + flags: `docs/cli.md`.
165157

166158
Run `hack help <command>` for detailed help.
167159

@@ -391,13 +383,16 @@ hack branch open feature-x
391383
```
392384

393385

394-
## Service-to-service connections (DB/Redis)
386+
## Service-to-service connections (HTTP vs DB/Redis)
395387

396388
If your app runs in Docker (the default in `hack`), don’t connect to `127.0.0.1` / `localhost` for Postgres/Redis.
397389
Inside a container, `localhost` is that container, not the other compose services.
398390

399-
With CoreDNS enabled (`internal.dns: true`), containers can use the same `https://*.hack` URLs as your host.
400-
If CoreDNS isn’t running (or you disable it), use the Compose service hostname on the default network:
391+
For HTTP services, use the same `https://*.hack` URLs you use on the host. `hack up` injects internal DNS,
392+
TLS trust, and `extra_hosts` mappings so `*.hack` resolves reliably inside containers. If you see `ENOTFOUND`
393+
inside containers, run `hack restart` to refresh the host mappings.
394+
395+
For non-HTTP services, use the Compose service hostname on the default network:
401396

402397
- `Postgres: db:5432`
403398
- `Redis: redis:6379`
@@ -489,7 +484,8 @@ hack up --project my-project
489484
OAuth providers (notably Google) require `localhost` or a host that ends with a real public suffix.
490485

491486
We keep `.hack` as the primary local dev domain, and optionally expose an alias domain for OAuth flows.
492-
Default: `*.hack.gy` → `127.0.0.1` (via dnsmasq + OS resolver).
487+
If the OAuth alias is enabled, `hack global install` configures `*.hack.gy` to resolve to `127.0.0.1`
488+
via dnsmasq + the OS resolver.
493489

494490
If you use Next.js (or another dev server that cares about dev origins), configure its dev allowlist to include the proxy domains.
495491
Next.js supports `allowedDevOrigins` (wildcards supported) in `next.config.js`:
@@ -532,21 +528,16 @@ Use `--out <dir>` if you want certs written somewhere else.
532528

533529
## Internal DNS (containers)
534530

535-
`hack global install` runs CoreDNS on the `hack-dev` network and pins Caddy + CoreDNS to stable IPs.
536-
CoreDNS answers `*.hack` and `*.hack.*` with Caddy’s IP so containers can use the same `https://*.hack`
537-
URLs as the host. All other DNS is forwarded to Docker’s resolver.
531+
`hack global install` runs CoreDNS on the `hack-dev` network. CoreDNS answers `*.hack` and `*.hack.*` with
532+
Caddy’s current IP so containers can use the same `https://*.hack` URLs as the host.
533+
534+
Some runtimes don’t honor custom DNS for `*.hack` reliably, so `hack up` also injects `extra_hosts` mappings
535+
to the Caddy IP. If the Caddy IP changes, `hack status`, `hack doctor`, and the TUI show a warning; fix it
536+
with `hack restart` to refresh the mapping.
538537

539538
When `internal.tls` is enabled, `hack up` mounts the Caddy Local CA into each container and sets common
540539
SSL env vars so HTTPS to `*.hack` is trusted inside containers.
541540

542-
If you created the `hack-dev` network before this feature, recreate it once so the static IPs can be
543-
assigned (better runtime compatibility):
544-
545-
```bash
546-
docker network rm hack-dev
547-
hack global install
548-
```
549-
550541
If you update `hack`, rerun `hack global install` once to refresh the CoreDNS config.
551542

552543

@@ -705,11 +696,12 @@ See examples:
705696

706697
- Logs missing in Grafana: ensure Alloy is running (`hack global status`) and try `{app="docker"}` in Explore.
707698

708-
- `ENOTFOUND` for `*.hack`/`*.hack.gy` inside containers: refresh CoreDNS config with `hack global install`,
709-
then restart CoreDNS: `docker compose -f ~/.hack/caddy/docker-compose.yml restart coredns`.
699+
- `ENOTFOUND` for `*.hack` inside containers: run `hack restart` to refresh `extra_hosts` mappings (check
700+
`hack status` or the TUI for Caddy IP mismatch warnings).
710701

711702
- `EAI_AGAIN` for external domains inside containers (e.g. `api.clerk.com`): CoreDNS isn’t forwarding.
712-
Run `hack global install` and restart CoreDNS as above.
703+
Run `hack global install` and restart CoreDNS:
704+
`docker compose -f ~/.hack/caddy/docker-compose.yml restart coredns`.
713705

714706
- `hack global up` warns about `hack-dev` network labels or missing subnet: remove the network and reinstall:
715707
`docker network rm hack-dev` then `hack global install`.

docs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ This directory contains the public documentation for hack. Specs remain in `SPEC
44

55
## Core docs
66

7+
- [CLI reference](cli.md)
78
- [Architecture](architecture.md)
89
- [Gateway overview](gateway.md)
910
- [Gateway API](gateway-api.md)
1011
- [Supervisor](supervisor.md)
1112
- [Extensions](extensions.md)
1213
- [Control-plane SDK](sdk.md)
1314

15+
Quick diagnostics:
16+
- `hack usage` (resource usage across running projects)
17+
- `hack usage --watch` (live resource trends)
18+
1419
## Guides
1520

1621
- Remote setup (one command): `hack remote setup`

docs/architecture.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Running multiple local projects at the same time is messy when everything wants
1616
proxy, DNS helpers, and logging stack under `~/.hack/`.
1717

1818
- **Caddy** (docker-proxy) routes `*.hack` based on container labels.
19-
- **CoreDNS** resolves `*.hack` inside containers to the Caddy IP.
19+
- **CoreDNS** resolves `*.hack` inside containers to the Caddy IP, with `extra_hosts` mappings for resolver compatibility.
2020
- **Alloy + Loki + Grafana** capture logs and provide history.
2121
- **Schemas** are served by Caddy at `https://schemas.hack`.
2222
- **hackd (optional daemon)** caches Docker state for fast `hack projects --json` / `hack ps --json`.
@@ -87,8 +87,10 @@ When `internal.dns` / `internal.tls` are enabled, `hack up` writes a Compose ove
8787
- sets each service’s DNS to the CoreDNS container
8888
- mounts Caddy’s local CA cert into each service
8989
- sets common SSL env vars (Node, curl, git, requests)
90+
- injects `extra_hosts` mappings for `*.hack` → current Caddy IP (for runtimes that ignore custom DNS)
9091

91-
This lets containers use the same `https://*.hack` hostnames as the host machine.
92+
This lets containers use the same `https://*.hack` hostnames as the host machine. If Caddy’s IP changes,
93+
`hack status`, `hack doctor`, and the TUI will warn; `hack restart` refreshes the mapping.
9294

9395
```mermaid
9496
graph LR
@@ -134,6 +136,10 @@ sequenceDiagram
134136

135137
NDJSON streaming (`hack logs --json`) emits `start`, `log`, and `end` events for MCP/TUI consumers.
136138

139+
Retention:
140+
- Loki retention is set in the global Loki config (`~/.hack/logging/loki.yaml`), default `168h` in the template.
141+
- Per-project overrides live in `hack.config.json` under `logs.retention_period` and apply when `hack down` prunes logs.
142+
137143
```mermaid
138144
graph LR
139145
Containers["Compose containers"] -->|"stdout/stderr"| Alloy

0 commit comments

Comments
 (0)