Skip to content

Commit 4511a33

Browse files
author
hack-cli-tests
committed
docs: reposition github setup around workflows
1 parent 1fc5757 commit 4511a33

8 files changed

Lines changed: 182 additions & 5 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ bun run build:node-runtime-image --tag hack-node-runtime:dev
123123

124124
Full operator guide: [`docs/guides/remote-node-container.md`](docs/guides/remote-node-container.md)
125125

126+
### GitHub workflows (optional)
127+
128+
Connect GitHub only when you want Hack to do GitHub work for you. Today that mainly means:
129+
130+
- creating or updating PRs from `hack dispatch run --pr` or `hack x github pr-upsert`
131+
- helping the controller bootstrap a private GitHub repo onto a remote node when the node cannot
132+
already clone it
133+
134+
You do not need GitHub for local `hack init/up/open`, logs, tickets, or remote runs against public
135+
repos.
136+
137+
Guide: [`docs/guides/github-workflows.md`](docs/guides/github-workflows.md)
138+
126139
### Tickets (optional, git-backed issue tracking)
127140

128141
`hack` includes a lightweight, git-backed ticket system for tracking work without leaving your repo. Tickets are stored in a hidden git ref (`refs/hack/tickets`) so they sync with your code but don't clutter your branch list.

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Quick diagnostics:
3434
- Remote setup (one command): `hack remote setup`
3535
- [Initialize a project](guides/init-project.md)
3636
- [Global settings](guides/global-settings.md)
37+
- [GitHub workflows](guides/github-workflows.md)
3738
- [Tickets (git-backed)](guides/tickets.md)
3839
- [Expose the gateway over SSH](guides/remote-ssh.md)
3940
- [Expose the gateway with Cloudflare](guides/remote-cloudflare.md)

docs/cli.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ GitHub profile precedence for `--pr`:
959959
2. Project `controlPlane.routing.overrides.github.profile`.
960960
3. Global `controlPlane.extensions["dance.hack.github"].config.defaultProfile`.
961961

962+
`--pr` requires GitHub auth to resolve for the selected profile. Set that up with
963+
`hack x github oauth-connect` or `hack x github connect` before using PR automation.
964+
962965
#### hack dispatch status
963966

964967
Usage: `hack dispatch status <run-id> [--json]`

docs/extensions.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,36 @@ Options:
198198
199199
### GitHub extension (`hack x github`)
200200
201+
Use GitHub when you want Hack to do GitHub work for you. GitHub is optional for core Hack setup
202+
and day-to-day local orchestration.
203+
204+
GitHub currently unlocks:
205+
206+
- PR automation from `hack dispatch run --pr` or `hack x github pr-upsert`
207+
- private GitHub repo bootstrap fallback for remote nodes when the node cannot clone on its own
208+
- explicit GitHub profile routing across Hack Desktop and the CLI
209+
210+
You do not need GitHub for `hack init`, `hack up`, `hack open`, logs, tickets, or remote workflows
211+
against public repos.
212+
213+
GitHub becomes required when:
214+
215+
- you want Hack to create or update a GitHub PR
216+
- you want the controller to supply private GitHub clone credentials during remote bootstrap
217+
218+
`Connect GitHub integration` is also separate from `Sign in to Hack with GitHub`. The first gives
219+
Hack a GitHub identity for GitHub-specific workflows. The second is only about Hack account auth.
220+
221+
For the workflow-first guide, see [GitHub workflows](guides/github-workflows.md).
222+
223+
Fastest setup paths:
224+
225+
Interactive browser auth + installation picker:
226+
227+
```bash
228+
hack x github oauth-connect --profile personal --set-default
229+
```
230+
201231
Connect or update a profile directly from token input:
202232
203233
```bash
@@ -225,11 +255,9 @@ printf "%s" "$GITHUB_APP_PRIVATE_KEY" | hack x github connect \
225255
--private-key-auth-ref github.app.private_key.default
226256
```
227257

228-
One-click browser OAuth bootstrap (via `gh`) + installation picker:
258+
Optional non-interactive installation bind with browser OAuth:
229259

230260
```bash
231-
hack x github oauth-connect --profile personal --set-default
232-
# optional non-interactive installation bind:
233261
hack x github oauth-connect --profile personal --installation-id 12345678
234262
```
235263

docs/guides/github-workflows.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# GitHub Workflows
2+
3+
Use GitHub when you want Hack to do GitHub work for you.
4+
5+
GitHub is not part of the base Hack setup. You do not need it for `hack init`, `hack up`,
6+
`hack open`, logs, local sessions, tickets, or public-repo remote workflows.
7+
8+
GitHub currently unlocks three things:
9+
10+
1. PR automation from Hack.
11+
2. Private GitHub repo bootstrap on remote nodes when the node cannot already clone the repo.
12+
3. A named GitHub profile that Hack Desktop and the CLI can route explicitly.
13+
14+
This is also separate from signing in to Hack with GitHub. `Sign in to Hack` controls your Hack
15+
account. `Connect GitHub integration` gives Hack a GitHub identity it can use for GitHub-specific
16+
workflows.
17+
18+
## When GitHub Is Optional
19+
20+
Leave GitHub disconnected if you are only using Hack for:
21+
22+
- local orchestration
23+
- project routing and HTTPS
24+
- logs and diagnostics
25+
- tickets or Linear workflows
26+
- remote execution against public repos
27+
- remote execution where the node already has working Git credentials
28+
29+
## When GitHub Is Required
30+
31+
Connect GitHub when you want either of these workflows:
32+
33+
- `hack dispatch run --pr` or `hack x github pr-upsert`
34+
- controller-assisted clone fallback for a private GitHub repo on a remote node
35+
36+
If the remote node can already clone the repo on its own, GitHub stays optional even for remote
37+
execution.
38+
39+
## Fastest Setup By Goal
40+
41+
### 1. Interactive setup for a person using Hack
42+
43+
Use browser auth and pick an installation:
44+
45+
```bash
46+
hack x github oauth-connect --profile personal --set-default
47+
```
48+
49+
Use this when you want the simplest path to PR automation or private-repo fallback.
50+
51+
### 2. Bring an existing token
52+
53+
Use this when you already manage a token outside Hack:
54+
55+
```bash
56+
hack x github connect --profile default --token-env HACK_GITHUB_APP_TOKEN
57+
58+
# or:
59+
printf "%s" "$HACK_GITHUB_APP_TOKEN" | hack x github connect --profile default --stdin
60+
```
61+
62+
### 3. Use GitHub App credentials for least privilege
63+
64+
Use this when you want installation-scoped auth that can refresh automatically:
65+
66+
```bash
67+
hack x github connect \
68+
--profile work \
69+
--set-default \
70+
--app-id 12345 \
71+
--installation-id 67890 \
72+
--private-key-env HACK_GITHUB_APP_PRIVATE_KEY
73+
```
74+
75+
## Common Commands
76+
77+
```bash
78+
hack x github profiles
79+
hack x github use --profile work
80+
hack x github status --profile work
81+
hack x github disconnect --profile work
82+
```
83+
84+
PR creation/update:
85+
86+
```bash
87+
hack x github pr-upsert \
88+
--profile work \
89+
--repo owner/repo \
90+
--head my-branch \
91+
--base main \
92+
--title "My PR" \
93+
--body "Details"
94+
```
95+
96+
## Profile Selection
97+
98+
Hack resolves the GitHub profile in this order:
99+
100+
1. `--profile`
101+
2. `controlPlane.routing.overrides.github.profile`
102+
3. `controlPlane.extensions["dance.hack.github"].config.defaultProfile`
103+
104+
Use separate profiles when you need different GitHub identities for different repos or automations.
105+
106+
## Browser Auth Requirements
107+
108+
`hack x github oauth-connect` needs the GitHub OAuth app config in global Hack config:
109+
110+
- `controlPlane.extensions["dance.hack.github"].config.oauthClientId`
111+
- `controlPlane.extensions["dance.hack.github"].config.oauthClientSecretAuthRef`
112+
113+
The referenced secret is stored in the OS keychain under service `hack-github-auth`.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ Expected:
129129

130130
### Private repo bootstrap behavior (default, no manual copy)
131131

132+
GitHub is optional for public repos or for private repos when the remote machine already has working
133+
Git credentials. It becomes required only when Hack needs to supply controller-side credentials for
134+
private GitHub clone fallback.
135+
132136
Workspace bootstrap now uses this order automatically:
133137
1. Attempt clone with the remote machine's existing Git credentials.
134138
2. If clone fails and origin is GitHub, retry with controller GitHub token auth (from `hack x github connect` or `HACK_GITHUB_APP_TOKEN`).

docs/guides/remote-node-quickstart.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Use this guide to connect one remote machine as a `hack` execution node and run
99
3. SSH access from host to remote (`user@host`).
1010
4. A reachable gateway endpoint on the remote (`http://<host>:7788` or tailnet URL).
1111

12+
GitHub is optional here. You only need it if the repo is private on GitHub and the remote machine
13+
cannot already clone it with its own credentials.
14+
1215
## Step 1: prepare the remote machine
1316

1417
Run on the remote machine:
@@ -70,6 +73,15 @@ hack dispatch run \
7073
-- "pwd"
7174
```
7275

76+
If this project is a private GitHub repo and the remote node cannot clone it directly, connect
77+
GitHub on the controller first:
78+
79+
```bash
80+
hack x github oauth-connect --profile work --set-default
81+
```
82+
83+
See [GitHub workflows](github-workflows.md) for the full optional-vs-required breakdown.
84+
7385
Optional remote check:
7486

7587
```bash
@@ -102,3 +114,6 @@ You can do the same flow in Hack Desktop:
102114
4. Local project URL fails after remote dispatch (`https://<project>.hack`):
103115
- run `hack node routes status` then `hack node routes repair`.
104116
- if global proxy is down, run `hack global up` and retry.
117+
5. Remote bootstrap fails on a private GitHub repo:
118+
- connect GitHub on the controller so Hack can retry clone with controller credentials.
119+
- run `hack x github oauth-connect --profile work --set-default` and retry.

src/control-plane/extensions/github/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const GITHUB_COMMANDS: readonly ExtensionCommand[] = [
102102
{
103103
name: "connect",
104104
summary:
105-
"Store a GitHub token in keychain and persist profile config (direct or App exchange)",
105+
"Connect GitHub for PR automation or remote repo bootstrap (token or App)",
106106
scope: "global",
107107
handler: async ({ ctx, args }) => {
108108
const parsed = parseConnectArgs({ args });
@@ -181,7 +181,7 @@ export const GITHUB_COMMANDS: readonly ExtensionCommand[] = [
181181
{
182182
name: "oauth-connect",
183183
summary:
184-
"Open browser GitHub auth via gh CLI, import token, and bind selected profile",
184+
"Connect GitHub in a browser and import a profile for Hack workflows",
185185
scope: "global",
186186
handler: async ({ ctx, args }) =>
187187
await handleGitHubOAuthConnectCommand({

0 commit comments

Comments
 (0)