github-kb 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- github_kb-0.1.1/LICENSE +21 -0
- github_kb-0.1.1/PKG-INFO +229 -0
- github_kb-0.1.1/README.md +192 -0
- github_kb-0.1.1/pyproject.toml +47 -0
- github_kb-0.1.1/src/github_kb/__init__.py +3 -0
- github_kb-0.1.1/src/github_kb/__main__.py +5 -0
- github_kb-0.1.1/src/github_kb/cli.py +25 -0
- github_kb-0.1.1/src/github_kb/commands/__init__.py +1 -0
- github_kb-0.1.1/src/github_kb/commands/ask.py +32 -0
- github_kb-0.1.1/src/github_kb/commands/audit.py +33 -0
- github_kb-0.1.1/src/github_kb/commands/chat.py +60 -0
- github_kb-0.1.1/src/github_kb/commands/common.py +109 -0
- github_kb-0.1.1/src/github_kb/commands/doctor.py +39 -0
- github_kb-0.1.1/src/github_kb/commands/endpoints.py +31 -0
- github_kb-0.1.1/src/github_kb/commands/explain.py +33 -0
- github_kb-0.1.1/src/github_kb/env/local/.env.example +2 -0
- github_kb-0.1.1/src/github_kb/lib/__init__.py +1 -0
- github_kb-0.1.1/src/github_kb/lib/agent.py +61 -0
- github_kb-0.1.1/src/github_kb/lib/doctor.py +115 -0
- github_kb-0.1.1/src/github_kb/lib/github.py +111 -0
- github_kb-0.1.1/src/github_kb/lib/models.py +32 -0
- github_kb-0.1.1/src/github_kb/lib/prompts.py +57 -0
- github_kb-0.1.1/src/github_kb/lib/repository.py +204 -0
- github_kb-0.1.1/src/github_kb/lib/ui.py +24 -0
- github_kb-0.1.1/src/github_kb/settings.py +84 -0
github_kb-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gonzalo Ayuso
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
github_kb-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: github-kb
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Ask questions about a GitHub repository with Strands Agents and AWS Bedrock
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: github,ai,agents,bedrock,cli,developer-tools
|
|
8
|
+
Author: Gonzalo Ayuso
|
|
9
|
+
Author-email: gonzalo123@gmail.com
|
|
10
|
+
Requires-Python: >=3.11,<4.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
25
|
+
Requires-Dist: boto3 (>=1.42.78,<2.0.0)
|
|
26
|
+
Requires-Dist: click (>=8.3.1,<9.0.0)
|
|
27
|
+
Requires-Dist: pydantic (>=2.12.3,<3.0.0)
|
|
28
|
+
Requires-Dist: pydantic-settings (>=2.13.1,<3.0.0)
|
|
29
|
+
Requires-Dist: python-dotenv (>=1.2.2,<2.0.0)
|
|
30
|
+
Requires-Dist: rich (>=14.3.0,<15.0.0)
|
|
31
|
+
Requires-Dist: strands-agents (>=1.34.1,<2.0.0)
|
|
32
|
+
Project-URL: Documentation, https://github.com/gonzalo123/github.kb#readme
|
|
33
|
+
Project-URL: Homepage, https://github.com/gonzalo123/github.kb
|
|
34
|
+
Project-URL: Repository, https://github.com/gonzalo123/github.kb
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# What if you could ask questions to any GitHub repository? Building a repository-aware AI agent with Python, Strands Agents, and Bedrock
|
|
38
|
+
|
|
39
|
+
Sometimes we land on an unfamiliar GitHub repository and the first problem is not writing code. The real problem is understanding the project fast enough. Is this a REST API? Where are the entrypoints? How is the application wired? Are there obvious risks in the codebase? If the repository is big enough, answering those questions manually is slow and boring.
|
|
40
|
+
|
|
41
|
+
That's just my PoC. An interactive command-line application that can inspect any public GitHub repository and answer questions about it.
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
I have the feeling this workflow should exist natively on GitHub. Once repositories become large enough, being able to ask architecture, audit, or API questions feels like a natural evolution of code search and Copilot. Maybe the reason it does not exist yet is cost, scope, or product complexity. In the meantime, a CLI-first open source approach feels like a good place to start: simple, scriptable, hackable, and based on bring-your-own-model credentials so each user keeps control of their own usage and billing.
|
|
46
|
+
|
|
47
|
+
The idea is simple. We give a GitHub repository to a CLI application. The CLI creates a local checkout, exposes a small set of repository-aware tools to a Strands Agent, and lets the agent inspect the project with AWS Bedrock. Because the agent can list directories, search code and read files, we can ask practical questions such as:
|
|
48
|
+
|
|
49
|
+
- Explain how the project works
|
|
50
|
+
- Audit the codebase looking for risks
|
|
51
|
+
- List the API endpoints
|
|
52
|
+
- Describe the execution flow of a specific module
|
|
53
|
+
|
|
54
|
+
This is not a vector database project and it is not a RAG pipeline. It is a much simpler approach. We let the agent explore the repository directly, file by file, using tools.
|
|
55
|
+
|
|
56
|
+
## The architecture
|
|
57
|
+
|
|
58
|
+
The flow is straightforward:
|
|
59
|
+
|
|
60
|
+
1. The user calls the CLI with a GitHub repository.
|
|
61
|
+
2. The repository is cloned into a local cache.
|
|
62
|
+
3. A Strands Agent is created with a Bedrock model.
|
|
63
|
+
4. The agent receives a system prompt plus four tools:
|
|
64
|
+
`get_directory_tree`, `list_directory`, `search_code` and `read_file`.
|
|
65
|
+
5. The agent inspects the repository and returns the final answer in Markdown.
|
|
66
|
+
|
|
67
|
+
This is enough for a surprising number of use cases. If the system prompt is focused on architecture, the answer becomes an explanation. If the prompt is focused on risk, the answer becomes a code audit. If the prompt is focused on HTTP routes, the answer becomes an API inventory.
|
|
68
|
+
|
|
69
|
+
## Project structure
|
|
70
|
+
|
|
71
|
+
I like to keep configuration in `settings.py`. It is a pattern I borrowed years ago from Django and I still use it in small prototypes because it keeps things simple:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
src/
|
|
75
|
+
└── github_kb/
|
|
76
|
+
├── cli.py
|
|
77
|
+
├── settings.py
|
|
78
|
+
├── commands/
|
|
79
|
+
│ ├── ask.py
|
|
80
|
+
│ ├── audit.py
|
|
81
|
+
│ ├── chat.py
|
|
82
|
+
│ ├── endpoints.py
|
|
83
|
+
│ └── explain.py
|
|
84
|
+
├── lib/
|
|
85
|
+
│ ├── agent.py
|
|
86
|
+
│ ├── github.py
|
|
87
|
+
│ ├── models.py
|
|
88
|
+
│ ├── prompts.py
|
|
89
|
+
│ ├── repository.py
|
|
90
|
+
│ └── ui.py
|
|
91
|
+
└── env/
|
|
92
|
+
└── local/
|
|
93
|
+
└── .env.example
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The responsibilities are small and explicit:
|
|
97
|
+
|
|
98
|
+
- `github_kb/commands/` contains the Click commands.
|
|
99
|
+
- `github_kb/lib/github.py` resolves the GitHub repository and manages the local checkout.
|
|
100
|
+
- `github_kb/lib/repository.py` contains the repository exploration logic used by the agent tools.
|
|
101
|
+
- `github_kb/lib/agent.py` wires Strands Agents with AWS Bedrock.
|
|
102
|
+
- `github_kb/lib/prompts.py` keeps the system prompt and the task-specific prompts in one place.
|
|
103
|
+
|
|
104
|
+
## Why this works
|
|
105
|
+
|
|
106
|
+
Large repositories are difficult because we rarely need the whole repository at once. We normally need a guided exploration strategy. A tree view helps us identify the shape of the project. Search helps us jump to the interesting files. Reading files gives us the final confirmation.
|
|
107
|
+
|
|
108
|
+
That sequence maps very well to tool-based agents.
|
|
109
|
+
|
|
110
|
+
Instead of trying to send the whole repository in one prompt, the model can progressively inspect only the relevant parts. It is cheaper, easier to reason about, and much closer to how we inspect an unknown codebase ourselves.
|
|
111
|
+
|
|
112
|
+
## Install
|
|
113
|
+
|
|
114
|
+
The intended installation flow is:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pipx install github-kb
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Quick start
|
|
121
|
+
|
|
122
|
+
The happy path should look like this:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
aws sso login --profile sandbox
|
|
126
|
+
AWS_PROFILE=sandbox AWS_REGION=us-west-2 github-kb doctor
|
|
127
|
+
AWS_PROFILE=sandbox AWS_REGION=us-west-2 github-kb chat gonzalo123/autofix
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The CLI is designed to work out of the box with the standard AWS credential chain. That means it can use:
|
|
131
|
+
|
|
132
|
+
- `AWS_PROFILE`
|
|
133
|
+
- `AWS_REGION`
|
|
134
|
+
- `aws sso login`
|
|
135
|
+
- regular access keys if they are already configured in the environment
|
|
136
|
+
|
|
137
|
+
You can also override the runtime explicitly with CLI flags such as `--aws-profile`, `--region`, and `--model`.
|
|
138
|
+
|
|
139
|
+
## Usage
|
|
140
|
+
|
|
141
|
+
Now we can ask questions:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
github-kb ask gonzalo123/autofix "How does the automated fix flow work?"
|
|
145
|
+
github-kb chat gonzalo123/autofix
|
|
146
|
+
github-kb explain gonzalo123/autofix --topic architecture
|
|
147
|
+
github-kb audit gonzalo123/autofix --focus github
|
|
148
|
+
github-kb endpoints gonzalo123/autofix
|
|
149
|
+
github-kb doctor
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
If we want to keep the same conversation alive across multiple questions in one terminal session:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
github-kb chat gonzalo123/autofix
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
It also accepts full GitHub URLs:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
github-kb ask https://github.com/gonzalo123/autofix "Where is the application bootstrapped?"
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
If we want to refresh the local cache:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
github-kb audit gonzalo123/autofix --refresh
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
We can also pass the AWS runtime explicitly:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
github-kb chat gonzalo123/autofix --aws-profile sandbox --region us-west-2
|
|
174
|
+
github-kb ask gonzalo123/autofix "Explain the architecture" --model us.anthropic.claude-sonnet-4-20250514-v1:0
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Development
|
|
178
|
+
|
|
179
|
+
For local development:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
poetry install
|
|
183
|
+
cp src/github_kb/env/local/.env.example src/github_kb/env/local/.env
|
|
184
|
+
poetry run pytest -q
|
|
185
|
+
poetry run github-kb --help
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
For local packaging tests:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
poetry build
|
|
192
|
+
pipx install --force dist/github_kb-0.1.0-py3-none-any.whl
|
|
193
|
+
github-kb --help
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
For publishing, see [RELEASING.md](RELEASING.md).
|
|
197
|
+
|
|
198
|
+
## Demo screenshots
|
|
199
|
+
|
|
200
|
+
Here are a few real screenshots generated against one of my own repositories, [`gonzalo123/autofix`](https://github.com/gonzalo123/autofix).
|
|
201
|
+
|
|
202
|
+
The screenshots below are embedded as PNG files:
|
|
203
|
+
|
|
204
|
+
### `explain`
|
|
205
|
+
|
|
206
|
+

|
|
207
|
+
|
|
208
|
+
### `endpoints`
|
|
209
|
+
|
|
210
|
+

|
|
211
|
+
|
|
212
|
+
### `audit`
|
|
213
|
+
|
|
214
|
+

|
|
215
|
+
|
|
216
|
+
## A couple of notes
|
|
217
|
+
|
|
218
|
+
This is still a PoC. The goal is not to build a perfect repository analysis platform. The goal is to validate a simple idea: an agent with a tiny set of well-chosen tools can already be useful for code understanding.
|
|
219
|
+
|
|
220
|
+
There are several obvious next steps:
|
|
221
|
+
|
|
222
|
+
- add more repository-aware tools
|
|
223
|
+
- persist analysis sessions
|
|
224
|
+
- summarize previous findings before starting a new question
|
|
225
|
+
- support GitHub authentication for private repositories
|
|
226
|
+
- add specialized prompts for security reviews or framework-specific inspections
|
|
227
|
+
|
|
228
|
+
Even in its current state, it is already a nice example of how tool-based agents can help with a very real developer problem.
|
|
229
|
+
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# What if you could ask questions to any GitHub repository? Building a repository-aware AI agent with Python, Strands Agents, and Bedrock
|
|
2
|
+
|
|
3
|
+
Sometimes we land on an unfamiliar GitHub repository and the first problem is not writing code. The real problem is understanding the project fast enough. Is this a REST API? Where are the entrypoints? How is the application wired? Are there obvious risks in the codebase? If the repository is big enough, answering those questions manually is slow and boring.
|
|
4
|
+
|
|
5
|
+
That's just my PoC. An interactive command-line application that can inspect any public GitHub repository and answer questions about it.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
I have the feeling this workflow should exist natively on GitHub. Once repositories become large enough, being able to ask architecture, audit, or API questions feels like a natural evolution of code search and Copilot. Maybe the reason it does not exist yet is cost, scope, or product complexity. In the meantime, a CLI-first open source approach feels like a good place to start: simple, scriptable, hackable, and based on bring-your-own-model credentials so each user keeps control of their own usage and billing.
|
|
10
|
+
|
|
11
|
+
The idea is simple. We give a GitHub repository to a CLI application. The CLI creates a local checkout, exposes a small set of repository-aware tools to a Strands Agent, and lets the agent inspect the project with AWS Bedrock. Because the agent can list directories, search code and read files, we can ask practical questions such as:
|
|
12
|
+
|
|
13
|
+
- Explain how the project works
|
|
14
|
+
- Audit the codebase looking for risks
|
|
15
|
+
- List the API endpoints
|
|
16
|
+
- Describe the execution flow of a specific module
|
|
17
|
+
|
|
18
|
+
This is not a vector database project and it is not a RAG pipeline. It is a much simpler approach. We let the agent explore the repository directly, file by file, using tools.
|
|
19
|
+
|
|
20
|
+
## The architecture
|
|
21
|
+
|
|
22
|
+
The flow is straightforward:
|
|
23
|
+
|
|
24
|
+
1. The user calls the CLI with a GitHub repository.
|
|
25
|
+
2. The repository is cloned into a local cache.
|
|
26
|
+
3. A Strands Agent is created with a Bedrock model.
|
|
27
|
+
4. The agent receives a system prompt plus four tools:
|
|
28
|
+
`get_directory_tree`, `list_directory`, `search_code` and `read_file`.
|
|
29
|
+
5. The agent inspects the repository and returns the final answer in Markdown.
|
|
30
|
+
|
|
31
|
+
This is enough for a surprising number of use cases. If the system prompt is focused on architecture, the answer becomes an explanation. If the prompt is focused on risk, the answer becomes a code audit. If the prompt is focused on HTTP routes, the answer becomes an API inventory.
|
|
32
|
+
|
|
33
|
+
## Project structure
|
|
34
|
+
|
|
35
|
+
I like to keep configuration in `settings.py`. It is a pattern I borrowed years ago from Django and I still use it in small prototypes because it keeps things simple:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
src/
|
|
39
|
+
└── github_kb/
|
|
40
|
+
├── cli.py
|
|
41
|
+
├── settings.py
|
|
42
|
+
├── commands/
|
|
43
|
+
│ ├── ask.py
|
|
44
|
+
│ ├── audit.py
|
|
45
|
+
│ ├── chat.py
|
|
46
|
+
│ ├── endpoints.py
|
|
47
|
+
│ └── explain.py
|
|
48
|
+
├── lib/
|
|
49
|
+
│ ├── agent.py
|
|
50
|
+
│ ├── github.py
|
|
51
|
+
│ ├── models.py
|
|
52
|
+
│ ├── prompts.py
|
|
53
|
+
│ ├── repository.py
|
|
54
|
+
│ └── ui.py
|
|
55
|
+
└── env/
|
|
56
|
+
└── local/
|
|
57
|
+
└── .env.example
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The responsibilities are small and explicit:
|
|
61
|
+
|
|
62
|
+
- `github_kb/commands/` contains the Click commands.
|
|
63
|
+
- `github_kb/lib/github.py` resolves the GitHub repository and manages the local checkout.
|
|
64
|
+
- `github_kb/lib/repository.py` contains the repository exploration logic used by the agent tools.
|
|
65
|
+
- `github_kb/lib/agent.py` wires Strands Agents with AWS Bedrock.
|
|
66
|
+
- `github_kb/lib/prompts.py` keeps the system prompt and the task-specific prompts in one place.
|
|
67
|
+
|
|
68
|
+
## Why this works
|
|
69
|
+
|
|
70
|
+
Large repositories are difficult because we rarely need the whole repository at once. We normally need a guided exploration strategy. A tree view helps us identify the shape of the project. Search helps us jump to the interesting files. Reading files gives us the final confirmation.
|
|
71
|
+
|
|
72
|
+
That sequence maps very well to tool-based agents.
|
|
73
|
+
|
|
74
|
+
Instead of trying to send the whole repository in one prompt, the model can progressively inspect only the relevant parts. It is cheaper, easier to reason about, and much closer to how we inspect an unknown codebase ourselves.
|
|
75
|
+
|
|
76
|
+
## Install
|
|
77
|
+
|
|
78
|
+
The intended installation flow is:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pipx install github-kb
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Quick start
|
|
85
|
+
|
|
86
|
+
The happy path should look like this:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
aws sso login --profile sandbox
|
|
90
|
+
AWS_PROFILE=sandbox AWS_REGION=us-west-2 github-kb doctor
|
|
91
|
+
AWS_PROFILE=sandbox AWS_REGION=us-west-2 github-kb chat gonzalo123/autofix
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The CLI is designed to work out of the box with the standard AWS credential chain. That means it can use:
|
|
95
|
+
|
|
96
|
+
- `AWS_PROFILE`
|
|
97
|
+
- `AWS_REGION`
|
|
98
|
+
- `aws sso login`
|
|
99
|
+
- regular access keys if they are already configured in the environment
|
|
100
|
+
|
|
101
|
+
You can also override the runtime explicitly with CLI flags such as `--aws-profile`, `--region`, and `--model`.
|
|
102
|
+
|
|
103
|
+
## Usage
|
|
104
|
+
|
|
105
|
+
Now we can ask questions:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
github-kb ask gonzalo123/autofix "How does the automated fix flow work?"
|
|
109
|
+
github-kb chat gonzalo123/autofix
|
|
110
|
+
github-kb explain gonzalo123/autofix --topic architecture
|
|
111
|
+
github-kb audit gonzalo123/autofix --focus github
|
|
112
|
+
github-kb endpoints gonzalo123/autofix
|
|
113
|
+
github-kb doctor
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
If we want to keep the same conversation alive across multiple questions in one terminal session:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
github-kb chat gonzalo123/autofix
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
It also accepts full GitHub URLs:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
github-kb ask https://github.com/gonzalo123/autofix "Where is the application bootstrapped?"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
If we want to refresh the local cache:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
github-kb audit gonzalo123/autofix --refresh
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
We can also pass the AWS runtime explicitly:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
github-kb chat gonzalo123/autofix --aws-profile sandbox --region us-west-2
|
|
138
|
+
github-kb ask gonzalo123/autofix "Explain the architecture" --model us.anthropic.claude-sonnet-4-20250514-v1:0
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Development
|
|
142
|
+
|
|
143
|
+
For local development:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
poetry install
|
|
147
|
+
cp src/github_kb/env/local/.env.example src/github_kb/env/local/.env
|
|
148
|
+
poetry run pytest -q
|
|
149
|
+
poetry run github-kb --help
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
For local packaging tests:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
poetry build
|
|
156
|
+
pipx install --force dist/github_kb-0.1.0-py3-none-any.whl
|
|
157
|
+
github-kb --help
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
For publishing, see [RELEASING.md](RELEASING.md).
|
|
161
|
+
|
|
162
|
+
## Demo screenshots
|
|
163
|
+
|
|
164
|
+
Here are a few real screenshots generated against one of my own repositories, [`gonzalo123/autofix`](https://github.com/gonzalo123/autofix).
|
|
165
|
+
|
|
166
|
+
The screenshots below are embedded as PNG files:
|
|
167
|
+
|
|
168
|
+
### `explain`
|
|
169
|
+
|
|
170
|
+

|
|
171
|
+
|
|
172
|
+
### `endpoints`
|
|
173
|
+
|
|
174
|
+

|
|
175
|
+
|
|
176
|
+
### `audit`
|
|
177
|
+
|
|
178
|
+

|
|
179
|
+
|
|
180
|
+
## A couple of notes
|
|
181
|
+
|
|
182
|
+
This is still a PoC. The goal is not to build a perfect repository analysis platform. The goal is to validate a simple idea: an agent with a tiny set of well-chosen tools can already be useful for code understanding.
|
|
183
|
+
|
|
184
|
+
There are several obvious next steps:
|
|
185
|
+
|
|
186
|
+
- add more repository-aware tools
|
|
187
|
+
- persist analysis sessions
|
|
188
|
+
- summarize previous findings before starting a new question
|
|
189
|
+
- support GitHub authentication for private repositories
|
|
190
|
+
- add specialized prompts for security reviews or framework-specific inspections
|
|
191
|
+
|
|
192
|
+
Even in its current state, it is already a nice example of how tool-based agents can help with a very real developer problem.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "github-kb"
|
|
3
|
+
version = "0.1.1"
|
|
4
|
+
description = "Ask questions about a GitHub repository with Strands Agents and AWS Bedrock"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
authors = ["Gonzalo Ayuso <gonzalo123@gmail.com>"]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
homepage = "https://github.com/gonzalo123/github.kb"
|
|
9
|
+
repository = "https://github.com/gonzalo123/github.kb"
|
|
10
|
+
documentation = "https://github.com/gonzalo123/github.kb#readme"
|
|
11
|
+
keywords = ["github", "ai", "agents", "bedrock", "cli", "developer-tools"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Environment :: Console",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: MacOS",
|
|
18
|
+
"Operating System :: POSIX :: Linux",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Software Development :: Documentation",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
26
|
+
]
|
|
27
|
+
packages = [{include = "github_kb", from = "src"}]
|
|
28
|
+
|
|
29
|
+
[tool.poetry.dependencies]
|
|
30
|
+
python = ">=3.11,<4.0"
|
|
31
|
+
boto3 = "^1.42.78"
|
|
32
|
+
click = "^8.3.1"
|
|
33
|
+
pydantic = "^2.12.3"
|
|
34
|
+
pydantic-settings = "^2.13.1"
|
|
35
|
+
python-dotenv = "^1.2.2"
|
|
36
|
+
rich = "^14.3.0"
|
|
37
|
+
strands-agents = "^1.34.1"
|
|
38
|
+
|
|
39
|
+
[tool.poetry.group.dev.dependencies]
|
|
40
|
+
pytest = "^8.4.2"
|
|
41
|
+
|
|
42
|
+
[tool.poetry.scripts]
|
|
43
|
+
github-kb = "github_kb.cli:cli"
|
|
44
|
+
|
|
45
|
+
[build-system]
|
|
46
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
47
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from github_kb.commands.ask import ask_command
|
|
4
|
+
from github_kb.commands.audit import audit_command
|
|
5
|
+
from github_kb.commands.chat import chat_command
|
|
6
|
+
from github_kb.commands.doctor import doctor_command
|
|
7
|
+
from github_kb.commands.endpoints import endpoints_command
|
|
8
|
+
from github_kb.commands.explain import explain_command
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@click.group()
|
|
12
|
+
def cli() -> None:
|
|
13
|
+
"""Ask questions about a GitHub repository using Strands Agents and AWS Bedrock."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
cli.add_command(ask_command)
|
|
17
|
+
cli.add_command(audit_command)
|
|
18
|
+
cli.add_command(chat_command)
|
|
19
|
+
cli.add_command(doctor_command)
|
|
20
|
+
cli.add_command(endpoints_command)
|
|
21
|
+
cli.add_command(explain_command)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if __name__ == "__main__":
|
|
25
|
+
cli()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Commands package.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from github_kb.commands.common import join_parts, run_prompt, runtime_options
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@click.command(name="ask")
|
|
7
|
+
@click.argument("repository")
|
|
8
|
+
@click.argument("question", nargs=-1, required=True)
|
|
9
|
+
@click.option("--ref", default=None, help="Git branch, tag or commit to inspect.")
|
|
10
|
+
@click.option("--refresh", is_flag=True, help="Refresh the cached local checkout.")
|
|
11
|
+
@runtime_options
|
|
12
|
+
def ask_command(
|
|
13
|
+
repository: str,
|
|
14
|
+
question: tuple[str, ...],
|
|
15
|
+
ref: str | None,
|
|
16
|
+
refresh: bool,
|
|
17
|
+
aws_profile: str | None,
|
|
18
|
+
region: str | None,
|
|
19
|
+
model: str | None,
|
|
20
|
+
) -> None:
|
|
21
|
+
"""Ask an open question about a GitHub repository."""
|
|
22
|
+
|
|
23
|
+
run_prompt(
|
|
24
|
+
repository,
|
|
25
|
+
join_parts(question),
|
|
26
|
+
title="Answer",
|
|
27
|
+
ref=ref,
|
|
28
|
+
refresh=refresh,
|
|
29
|
+
aws_profile=aws_profile,
|
|
30
|
+
region=region,
|
|
31
|
+
model=model,
|
|
32
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from github_kb.commands.common import run_prompt, runtime_options
|
|
4
|
+
from github_kb.lib.prompts import build_audit_prompt
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@click.command(name="audit")
|
|
8
|
+
@click.argument("repository")
|
|
9
|
+
@click.option("--focus", default=None, help="Optional area to focus the audit on.")
|
|
10
|
+
@click.option("--ref", default=None, help="Git branch, tag or commit to inspect.")
|
|
11
|
+
@click.option("--refresh", is_flag=True, help="Refresh the cached local checkout.")
|
|
12
|
+
@runtime_options
|
|
13
|
+
def audit_command(
|
|
14
|
+
repository: str,
|
|
15
|
+
focus: str | None,
|
|
16
|
+
ref: str | None,
|
|
17
|
+
refresh: bool,
|
|
18
|
+
aws_profile: str | None,
|
|
19
|
+
region: str | None,
|
|
20
|
+
model: str | None,
|
|
21
|
+
) -> None:
|
|
22
|
+
"""Run a code audit against the repository."""
|
|
23
|
+
|
|
24
|
+
run_prompt(
|
|
25
|
+
repository,
|
|
26
|
+
build_audit_prompt(focus=focus),
|
|
27
|
+
title="Audit",
|
|
28
|
+
ref=ref,
|
|
29
|
+
refresh=refresh,
|
|
30
|
+
aws_profile=aws_profile,
|
|
31
|
+
region=region,
|
|
32
|
+
model=model,
|
|
33
|
+
)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
from github_kb.commands.common import prepare_agent, runtime_options
|
|
4
|
+
from github_kb.lib.ui import get_console, print_repository_panel, print_result
|
|
5
|
+
|
|
6
|
+
EXIT_COMMANDS = {"exit", "quit", "/exit", "/quit", ":q", "q"}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def is_exit_command(value: str) -> bool:
|
|
10
|
+
return value.strip().lower() in EXIT_COMMANDS
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@click.command(name="chat")
|
|
14
|
+
@click.argument("repository")
|
|
15
|
+
@click.option("--ref", default=None, help="Git branch, tag or commit to inspect.")
|
|
16
|
+
@click.option("--refresh", is_flag=True, help="Refresh the cached local checkout.")
|
|
17
|
+
@runtime_options
|
|
18
|
+
def chat_command(
|
|
19
|
+
repository: str,
|
|
20
|
+
ref: str | None,
|
|
21
|
+
refresh: bool,
|
|
22
|
+
aws_profile: str | None,
|
|
23
|
+
region: str | None,
|
|
24
|
+
model: str | None,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Start a conversational session about a GitHub repository."""
|
|
27
|
+
|
|
28
|
+
console = get_console()
|
|
29
|
+
repository_context, agent = prepare_agent(
|
|
30
|
+
repository,
|
|
31
|
+
ref=ref,
|
|
32
|
+
refresh=refresh,
|
|
33
|
+
aws_profile=aws_profile,
|
|
34
|
+
region=region,
|
|
35
|
+
model=model,
|
|
36
|
+
)
|
|
37
|
+
print_repository_panel(repository_context)
|
|
38
|
+
console.print("Interactive mode. Type your question or `/exit` to finish.\n")
|
|
39
|
+
|
|
40
|
+
while True:
|
|
41
|
+
try:
|
|
42
|
+
question = console.input("[bold cyan]> [/]").strip()
|
|
43
|
+
except (EOFError, KeyboardInterrupt):
|
|
44
|
+
console.print("\nSession closed.")
|
|
45
|
+
break
|
|
46
|
+
|
|
47
|
+
if not question:
|
|
48
|
+
continue
|
|
49
|
+
|
|
50
|
+
if is_exit_command(question):
|
|
51
|
+
console.print("Session closed.")
|
|
52
|
+
break
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
with console.status("Thinking with Bedrock...", spinner="dots"):
|
|
56
|
+
result = agent(question)
|
|
57
|
+
except Exception as error:
|
|
58
|
+
raise click.ClickException(str(error)) from error
|
|
59
|
+
|
|
60
|
+
print_result("Answer", str(result))
|