Skip to content

Commit 52c6b45

Browse files
authored
Added login command (#43)
Co-authored-by: Tomas Vesely <448809+wham@users.noreply.github.com>
1 parent ff1377e commit 52c6b45

5 files changed

Lines changed: 778 additions & 33 deletions

File tree

README.md

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ GitHub Brain also includes a web-based UI for ultra-fast search:
2424

2525
And a Raycast extension:
2626

27-
28-
2927
![](./docs/raycast.png)
3028

3129
GitHub Brain is [programmed in Markdown](https://github.blog/ai-and-ml/generative-ai/spec-driven-development-using-markdown-as-a-programming-language-when-building-with-ai/).
@@ -46,8 +44,9 @@ github-brain <command> [<args>]
4644

4745
**Workflow:**
4846

49-
1. Use `pull` to populate the local database
50-
2. Use `mcp` to start the MCP server
47+
1. Use `login` to authenticate with GitHub (or set `GITHUB_TOKEN` manually)
48+
2. Use `pull` to populate the local database
49+
3. Use `mcp` to start the MCP server
5150

5251
Re-run `pull` anytime to update the database with new GitHub data.
5352

@@ -62,6 +61,21 @@ You can change the home directory with the `-m` argument available for all comma
6261

6362
</details>
6463

64+
### `login`
65+
66+
Opens your browser to authorize _GitHub Brain_ app and stores resulting `GITHUB_TOKEN` in the `.env` file.
67+
Optionally, you can also specify `ORGANIZATION` to store in the same file.
68+
69+
Example:
70+
71+
```sh
72+
github-brain login
73+
```
74+
75+
| Argument | Description |
76+
| :------- | :----------------------------------------- |
77+
| `-m` | Home directory. Default: `~/.github-brain` |
78+
6579
### `pull`
6680

6781
Populate the local database with GitHub data.
@@ -74,14 +88,14 @@ github-brain pull -o my-org
7488

7589
The first run may take a while. Subsequent runs are faster, fetching only new data.
7690

77-
| Argument | Variable | Description |
78-
| :------- | :---------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
79-
| `-t` | `GITHUB_TOKEN` | Your GitHub [personal token](https://github.com/settings/personal-access-tokens) to access the API. **Required.** |
80-
| `-o` | `ORGANIZATION` | The GitHub organization to pull data from. **Required.** |
81-
| `-m` | | Home directory. Default: `~/.github-brain` (or checkout directory if run via `scripts/run`). |
82-
| `-i` | | Pull only selected entities: `repositories`, `discussions`, `issues`, `pull-requests` (comma-separated). |
83-
| `-f` | | Remove all data before pulling. With `-i`, removes only specified items. |
84-
| `-e` | `EXCLUDED_REPOSITORIES` | Repositories to exclude (comma-separated). Useful for large repos not relevant to your analysis. |
91+
| Argument | Variable | Description |
92+
| :------- | :---------------------- | :------------------------------------------------------------------------------------------------------------------------------------- |
93+
| | `GITHUB_TOKEN` | Your GitHub token. Use `login` command or create a [personal token](https://github.com/settings/personal-access-tokens). **Required.** |
94+
| `-o` | `ORGANIZATION` | The GitHub organization to pull data from. **Required.** |
95+
| `-m` | | Home directory. Default: `~/.github-brain` |
96+
| `-i` | | Pull only selected entities: `repositories`, `discussions`, `issues`, `pull-requests` (comma-separated). |
97+
| `-f` | | Remove all data before pulling. With `-i`, removes only specified items. |
98+
| `-e` | `EXCLUDED_REPOSITORIES` | Repositories to exclude (comma-separated). Useful for large repos not relevant to your analysis. |
8599

86100
<details>
87101
<summary>Personal access token scopes</summary>
@@ -104,10 +118,10 @@ Example:
104118
github-brain mcp -o my-org
105119
```
106120

107-
| Argument | Variable | Description |
108-
| :------- | :------------- | :-------------------------------------------------------------------------------------------------------------------- |
109-
| `-o` | `ORGANIZATION` | GitHub organization. **Required.** |
110-
| `-m` | | Home directory. Default: `~/.github-brain` (or checkout directory if run via `scripts/run`). |
121+
| Argument | Variable | Description |
122+
| :------- | :------------- | :------------------------------------------ |
123+
| `-o` | `ORGANIZATION` | GitHub organization. **Required.** |
124+
| `-m` | | Home directory. Default: `~/.github-brain` |
111125

112126
### `ui`
113127

@@ -117,11 +131,11 @@ Start the web UI for quick searches (alternative to MCP).
117131
github-brain ui -o my-org
118132
```
119133

120-
| Argument | Variable | Description |
121-
| :------- | :------------- | :-------------------------------------------------------------------------------------------------------------------- |
122-
| `-o` | `ORGANIZATION` | GitHub organization. **Required.** |
123-
| `-m` | | Home directory. Default: `~/.github-brain` (or checkout directory if run via `scripts/run`). |
124-
| `-p` | `UI_PORT` | Port. Default: `8080`. |
134+
| Argument | Variable | Description |
135+
| :------- | :------------- | :------------------------------------------|
136+
| `-o` | `ORGANIZATION` | GitHub organization. **Required.** |
137+
| `-m` | | Home directory. Default: `~/.github-brain` |
138+
| `-p` | `UI_PORT` | Port. Default: `8080`. |
125139

126140
### Additional Arguments
127141

@@ -183,4 +197,4 @@ The extension uses the MCP server to search GitHub data.
183197

184198
## Development
185199

186-
`scripts/run` builds and runs `github-brain` with the checkout directory as home (database in `db/`, config in `.env`).
200+
`scripts/run` builds and runs `github-brain` with the checkout directory as home `-m` (database in `db/`, config in `.env`).

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ require (
1111
github.com/joho/godotenv v1.5.1
1212
github.com/mattn/go-sqlite3 v1.14.28
1313
github.com/modelcontextprotocol/go-sdk v1.1.0
14+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
1415
github.com/shurcooL/githubv4 v0.0.0-20230704064427-599ae7bbf278
1516
golang.org/x/oauth2 v0.30.0
1617
)
1718

1819
require (
20+
github.com/atotto/clipboard v0.1.4 // indirect
1921
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
2022
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
2123
github.com/charmbracelet/x/ansi v0.10.1 // indirect

go.sum

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
2+
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
13
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
24
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
35
github.com/charmbracelet/bubbles v0.21.0 h1:9TdC97SdRVg/1aaXNVWfFH3nnLAwOXr8Fn6u6mfQdFs=
@@ -40,6 +42,8 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU
4042
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
4143
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
4244
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
45+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
46+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
4347
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
4448
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
4549
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
@@ -56,6 +60,7 @@ golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p
5660
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
5761
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
5862
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
63+
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5964
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6065
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
6166
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=

0 commit comments

Comments
 (0)