Skip to content

Commit e53edfd

Browse files
committed
feat(remote): add route bridge status/repair commands and docs
1 parent dcb7656 commit e53edfd

18 files changed

Lines changed: 1333 additions & 0 deletions

.codex/skills/hack-cli/SKILL.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ Use `hack` as the primary interface for local development.
7777
- Start/stop/status: `hack global up`, `hack global down`, `hack global status`
7878
- Global logs: `hack global logs <service> --no-follow --tail 200`
7979

80+
## Remote Nodes + Dispatch
81+
82+
- Pair/register a node: `hack node pair ...`, then verify via `hack node list` and `hack node status --watch`.
83+
- Repair SSH access for remote Git/mutagen: `hack node ssh setup --node <id>`.
84+
- Inspect node workspace map on the node host: `ssh <user@host> 'hack node workspace list --json'`.
85+
- Inspect/repair controller route bridge: `hack node routes status`, `hack node routes repair`.
86+
- Dispatch command to remote workspace: `hack dispatch run --project <name|id> --node default --branch <branch> --runner generic -- "pwd"`.
87+
8088
## Lifecycle + Startup
8189

8290
- Put host setup in `.hack/hack.config.json` under `startup` / `lifecycle`.

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ Global infra:
287287
- Start/stop/status: `hack global up`, `hack global down`, `hack global status`
288288
- Use `hack global up` before Loki/Grafana queries if global logging is offline.
289289

290+
Remote nodes + dispatch:
291+
- Pair/register nodes: `hack node pair ...`, then verify with `hack node list` and `hack node status --watch`.
292+
- Repair SSH for remote Git/mutagen: `hack node ssh setup --node <id>`.
293+
- On node host, inspect workspace map via `hack node workspace list|resolve|attach|remove`.
294+
- Inspect/repair controller-side route bridge with `hack node routes status` and `hack node routes repair`.
295+
- Dispatch remote commands: `hack dispatch run --project <name|id> --node default --branch <branch> --runner generic -- "<command>"`.
296+
290297
When to use a branch instance:
291298
- You need two versions running at once (PR review, experiments, migrations).
292299
- You want to keep a stable environment while testing another branch.

CLAUDE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ Global infra:
182182
- Start/stop/status: `hack global up`, `hack global down`, `hack global status`
183183
- Use `hack global up` before Loki/Grafana queries if global logging is offline.
184184

185+
Remote nodes + dispatch:
186+
- Pair/register nodes: `hack node pair ...`, then verify with `hack node list` and `hack node status --watch`.
187+
- Repair SSH for remote Git/mutagen: `hack node ssh setup --node <id>`.
188+
- On node host, inspect workspace map via `hack node workspace list|resolve|attach|remove`.
189+
- Inspect/repair controller-side route bridge with `hack node routes status` and `hack node routes repair`.
190+
- Dispatch remote commands: `hack dispatch run --project <name|id> --node default --branch <branch> --runner generic -- "<command>"`.
191+
185192
When to use a branch instance:
186193
- You need two versions running at once (PR review, experiments, migrations).
187194
- You want to keep a stable environment while testing another branch.

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Monorepo note:
2222
Quick diagnostics:
2323
- `hack usage` (resource usage across running projects)
2424
- `hack usage --watch` (live resource trends)
25+
- `hack node routes status` (controller-side remote route bridge state)
26+
- `hack node routes repair` (re-apply persisted remote route bridge routes)
2527

2628
## Guides
2729

docs/cli.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ Subcommands:
757757
| `use` | Set default node |
758758
| `remove` | Remove node registration |
759759
| `workspace` | Inspect and repair node workspace map entries |
760+
| `routes` | Inspect and repair controller-side remote route bridge |
760761
| `provider` | Manage provider-specific node bootstrap workflows |
761762
| `devcontainer` | Manage remote node devcontainer lifecycle and attach hints |
762763

@@ -804,6 +805,11 @@ ssh <user@node-host> 'hack node workspace resolve --project <name|id> --json'
804805
ssh <user@node-host> 'hack node workspace attach --project <name|id> --path <absolute-path> --json'
805806
ssh <user@node-host> 'hack node workspace remove --project <name|id> --json'
806807

808+
# inspect/repair controller-side remote route bridge
809+
hack node routes status
810+
hack node routes status --json
811+
hack node routes repair
812+
807813
# Railway provider bootstrap (existing service + auto domain endpoint)
808814
hack node provider railway bootstrap \
809815
--railway-project "<project-id-or-name>" \
@@ -874,6 +880,25 @@ hack node workspace attach --project my-project --path "$HOME/.hack/projects/my-
874880
hack node workspace remove --project my-project --json
875881
```
876882

883+
### hack node routes
884+
885+
Usage: `hack node routes <subcommand>`
886+
887+
Subcommands:
888+
889+
| Subcommand | Summary |
890+
| --- | --- |
891+
| `status` | Show controller-side remote route bridge state |
892+
| `repair` | Re-render and re-apply persisted route bridge stack |
893+
894+
Examples:
895+
896+
```bash
897+
hack node routes status
898+
hack node routes status --json
899+
hack node routes repair
900+
```
901+
877902
### hack dispatch
878903

879904
Usage: `hack dispatch <subcommand>`

docs/guides/remote-node-laptop-e2e.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ ssh <user@node-host> 'hack node workspace list --json'
124124
Expected:
125125
1. Mapping entry exists for controller project id/name.
126126
2. Workspace root resolves under `~/.hack/projects/<project-slug>/` unless explicitly attached elsewhere.
127+
3. Controller writes/updates the local remote-route bridge so `https://<project>.hack` is proxied through local Caddy to the remote node host.
128+
4. Route bridge diagnostics/repair are available on controller via `hack node routes status` and `hack node routes repair`.
127129

128130
### Private repo bootstrap behavior (default, no manual copy)
129131

@@ -208,6 +210,10 @@ cat ~/.hack/registry/runs/<run-id>/summary.md
208210
9. `Mutagen binary was not found on this machine`
209211
- Cause: controller is missing mutagen and auto-install failed (permissions/network/tooling).
210212
- Fix: run `hack doctor --fix` (or `hack global install`) and retry.
213+
10. `hack up --target auto` succeeds remotely but local browser on `https://<project>.hack` fails TLS/connection
214+
- Cause: local global proxy stack is down, so remote bridge routes were saved but not applied.
215+
- Fix: run `hack global up`; remote routes are reconciled automatically on startup.
216+
- Optional: run `hack node routes status` and `hack node routes repair` to inspect/re-apply bridge routes explicitly.
211217

212218
## Evidence capture
213219

@@ -216,6 +222,7 @@ Record these outputs in your run notes:
216222
```bash
217223
hack node list
218224
hack node status --json
225+
hack node routes status --json
219226
hack config get "controlPlane.execution.mode"
220227
hack config get "controlPlane.execution.nodeId"
221228
hack dispatch status <run-id>

docs/guides/remote-node-quickstart.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Validate:
4646
```bash
4747
hack node list
4848
hack node status --node <node-id>
49+
hack node routes status
4950
```
5051

5152
## Step 3: route a project to the remote node
@@ -75,6 +76,12 @@ Optional remote check:
7576
ssh <user@remote-host> 'hack node workspace list --json'
7677
```
7778

79+
Controller route bridge check:
80+
81+
```bash
82+
hack node routes status --json
83+
```
84+
7885
## macOS app flow
7986

8087
You can do the same flow in Hack Desktop:
@@ -92,3 +99,6 @@ You can do the same flow in Hack Desktop:
9299
- install `hack` on remote or pass `--remote-hack` with the full path.
93100
3. `Connection closed by ... port 22`:
94101
- confirm username and shell access with `ssh <user@host> "echo ok"`.
102+
4. Local project URL fails after remote dispatch (`https://<project>.hack`):
103+
- run `hack node routes status` then `hack node routes repair`.
104+
- if global proxy is down, run `hack global up` and retry.

src/agents/codex-skill.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ export function renderCodexSkill(): string {
193193
"- Start/stop/status: `hack global up`, `hack global down`, `hack global status`",
194194
"- Global logs: `hack global logs <service> --no-follow --tail 200`",
195195
"",
196+
"## Remote Nodes + Dispatch",
197+
"",
198+
"- Pair/register a node: `hack node pair ...`, then verify via `hack node list` and `hack node status --watch`.",
199+
"- Repair SSH access for remote Git/mutagen: `hack node ssh setup --node <id>`.",
200+
"- Inspect node workspace map on the node host: `ssh <user@host> 'hack node workspace list --json'`.",
201+
"- Inspect/repair controller route bridge: `hack node routes status`, `hack node routes repair`.",
202+
'- Dispatch command to remote workspace: `hack dispatch run --project <name|id> --node default --branch <branch> --runner generic -- "pwd"`.',
203+
"",
196204
"## Lifecycle + Startup",
197205
"",
198206
"- Put host setup in `.hack/hack.config.json` under `startup` / `lifecycle`.",

src/agents/cursor.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ export function renderCursorRules(): string {
159159
"hack global status",
160160
"hack session",
161161
"hack tickets list",
162+
"hack node list",
163+
"hack node status --watch",
164+
"hack node ssh setup --node <id>",
165+
"hack node routes status",
166+
"hack node routes repair",
167+
'hack dispatch run --project <name|id> --node default --branch <branch> --runner generic -- "pwd"',
162168
"hack internal extra-hosts list",
163169
"hack internal extra-hosts set <hostname> <target>",
164170
"hack internal extra-hosts unset <hostname>",

src/agents/init-patterns.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export function renderAgentInitPatterns(): string {
5959
"- If host-side setup is required (auth proxy, tunnel, credential bootstrap), encode it in `.hack/hack.config.json` under `startup`/`lifecycle`.",
6060
"- For service-to-host proxy/tunnel routing, configure static `internal.extra_hosts` or dynamic mappings via `hack internal extra-hosts set`.",
6161
"- For externally reachable local HTTP routes, ensure services carry Caddy labels (`caddy`, `caddy.reverse_proxy`, `caddy.tls=internal`) and attach to `hack-dev`.",
62+
"- For remote-run projects, set `controlPlane.execution.mode=local_edit_remote_run` and pin `controlPlane.execution.nodeId` to a paired node.",
63+
"- When remote project URLs fail locally, inspect/re-apply controller route bridge with `hack node routes status` and `hack node routes repair`.",
64+
"- Keep remote node workspaces healthy with `hack node workspace list|resolve|attach|remove` (run on node host over SSH).",
6265
"- Use `.hack.gy` alias hosts for OAuth callback testing when provider rules reject `.hack`.",
6366
"- Treat `.hack/.internal/*` and `.hack/.branch/*` overrides as generated artifacts; keep edits in source config/compose files.",
6467
"- Use `hack run <service> <cmd...>` for one-off tasks.",

0 commit comments

Comments
 (0)