devbrief 0.1.0__py3-none-any.whl
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.
- devbrief/__init__.py +0 -0
- devbrief/brief.py +48 -0
- devbrief/display.py +30 -0
- devbrief/github.py +48 -0
- devbrief/main.py +49 -0
- devbrief-0.1.0.dist-info/METADATA +169 -0
- devbrief-0.1.0.dist-info/RECORD +10 -0
- devbrief-0.1.0.dist-info/WHEEL +4 -0
- devbrief-0.1.0.dist-info/entry_points.txt +2 -0
- devbrief-0.1.0.dist-info/licenses/LICENSE +21 -0
devbrief/__init__.py
ADDED
|
File without changes
|
devbrief/brief.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import anthropic
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def build_prompt(repo: dict, readme: str, file_tree: list[str]) -> str:
|
|
6
|
+
readme_snippet = readme[:3000] if readme else "No README found."
|
|
7
|
+
tree_str = "\n".join(file_tree) if file_tree else "No file tree available."
|
|
8
|
+
topics_str = ", ".join(repo["topics"]) if repo["topics"] else "none"
|
|
9
|
+
|
|
10
|
+
return f"""You are a senior developer writing a concise project brief for a technical audience.
|
|
11
|
+
|
|
12
|
+
Repository: {repo['name']}
|
|
13
|
+
Description: {repo['description'] or 'No description provided.'}
|
|
14
|
+
Stars: {repo['stars']}
|
|
15
|
+
Primary language: {repo['language'] or 'unknown'}
|
|
16
|
+
Topics: {topics_str}
|
|
17
|
+
|
|
18
|
+
Top-level file tree:
|
|
19
|
+
{tree_str}
|
|
20
|
+
|
|
21
|
+
README (first 3000 chars):
|
|
22
|
+
{readme_snippet}
|
|
23
|
+
|
|
24
|
+
Write a structured project brief with exactly these sections:
|
|
25
|
+
1. **One-line description** – A single crisp sentence summarizing the project.
|
|
26
|
+
2. **Problem it solves** – 2-3 sentences on the core problem addressed.
|
|
27
|
+
3. **Tech stack** – Bullet list of detected technologies/frameworks.
|
|
28
|
+
4. **Getting started** – 3-5 steps extracted or inferred from the README.
|
|
29
|
+
5. **Who would find it useful** – 2-3 sentences on the target audience.
|
|
30
|
+
6. **Limitations / potential improvements** – 3-5 bullet points.
|
|
31
|
+
|
|
32
|
+
Be concise. Do not repeat the section headers verbatim — use them as guidance only."""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def generate_brief(repo: dict, readme: str, file_tree: list[str]) -> str:
|
|
36
|
+
api_key = os.environ.get("ANTHROPIC_API_KEY")
|
|
37
|
+
if not api_key:
|
|
38
|
+
raise EnvironmentError("ANTHROPIC_API_KEY environment variable is not set.")
|
|
39
|
+
|
|
40
|
+
client = anthropic.Anthropic(api_key=api_key)
|
|
41
|
+
prompt = build_prompt(repo, readme, file_tree)
|
|
42
|
+
|
|
43
|
+
message = client.messages.create(
|
|
44
|
+
model="claude-opus-4-6",
|
|
45
|
+
max_tokens=1024,
|
|
46
|
+
messages=[{"role": "user", "content": prompt}],
|
|
47
|
+
)
|
|
48
|
+
return message.content[0].text
|
devbrief/display.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from rich.console import Console
|
|
2
|
+
from rich.panel import Panel
|
|
3
|
+
from rich.markdown import Markdown
|
|
4
|
+
from rich.rule import Rule
|
|
5
|
+
from rich import print as rprint
|
|
6
|
+
|
|
7
|
+
console = Console()
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def show_fetching(url: str) -> None:
|
|
11
|
+
console.print(f"\n[bold cyan]Fetching data for:[/bold cyan] {url}")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def show_generating() -> None:
|
|
15
|
+
console.print("[bold yellow]Generating brief with Claude...[/bold yellow]\n")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def show_brief(repo_name: str, brief_text: str, elapsed: float) -> None:
|
|
19
|
+
console.print(Rule(f"[bold green] DevBrief: {repo_name} [/bold green]"))
|
|
20
|
+
console.print(Panel(Markdown(brief_text), border_style="green", padding=(1, 2)))
|
|
21
|
+
console.print(Rule(style="green"))
|
|
22
|
+
console.print(f"[dim]Brief generated in {elapsed:.1f}s[/dim]\n")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def show_saved(path: str) -> None:
|
|
26
|
+
console.print(f"[dim]Saved to[/dim] [bold]{path}[/bold]\n")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def show_error(message: str) -> None:
|
|
30
|
+
rprint(f"\n[bold red]Error:[/bold red] {message}\n")
|
devbrief/github.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def parse_repo_url(url: str) -> tuple[str, str]:
|
|
5
|
+
"""Extract owner and repo name from a GitHub URL."""
|
|
6
|
+
parts = url.rstrip("/").split("/")
|
|
7
|
+
if len(parts) < 2:
|
|
8
|
+
raise ValueError(f"Invalid GitHub URL: {url}")
|
|
9
|
+
return parts[-2], parts[-1]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def fetch_repo_data(owner: str, repo: str) -> dict:
|
|
13
|
+
"""Fetch repository metadata from GitHub API."""
|
|
14
|
+
url = f"https://api.github.com/repos/{owner}/{repo}"
|
|
15
|
+
response = requests.get(url, timeout=10)
|
|
16
|
+
response.raise_for_status()
|
|
17
|
+
data = response.json()
|
|
18
|
+
return {
|
|
19
|
+
"name": data.get("name", ""),
|
|
20
|
+
"description": data.get("description", ""),
|
|
21
|
+
"stars": data.get("stargazers_count", 0),
|
|
22
|
+
"language": data.get("language", ""),
|
|
23
|
+
"topics": data.get("topics", []),
|
|
24
|
+
"homepage": data.get("homepage", ""),
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def fetch_readme(owner: str, repo: str) -> str:
|
|
29
|
+
"""Fetch README content from GitHub API (decoded from base64)."""
|
|
30
|
+
url = f"https://api.github.com/repos/{owner}/{repo}/readme"
|
|
31
|
+
response = requests.get(url, timeout=10)
|
|
32
|
+
if response.status_code == 404:
|
|
33
|
+
return ""
|
|
34
|
+
response.raise_for_status()
|
|
35
|
+
import base64
|
|
36
|
+
content = response.json().get("content", "")
|
|
37
|
+
return base64.b64decode(content).decode("utf-8", errors="replace")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def fetch_file_tree(owner: str, repo: str) -> list[str]:
|
|
41
|
+
"""Fetch top-level file/directory names from GitHub API."""
|
|
42
|
+
url = f"https://api.github.com/repos/{owner}/{repo}/contents"
|
|
43
|
+
response = requests.get(url, timeout=10)
|
|
44
|
+
if response.status_code == 404:
|
|
45
|
+
return []
|
|
46
|
+
response.raise_for_status()
|
|
47
|
+
items = response.json()
|
|
48
|
+
return [item["name"] for item in items if isinstance(item, dict)]
|
devbrief/main.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import click
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
|
|
5
|
+
from devbrief.github import parse_repo_url, fetch_repo_data, fetch_readme, fetch_file_tree
|
|
6
|
+
from devbrief.brief import generate_brief
|
|
7
|
+
from devbrief.display import show_fetching, show_generating, show_brief, show_error, show_saved
|
|
8
|
+
|
|
9
|
+
load_dotenv()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@click.command()
|
|
13
|
+
@click.argument("github_url")
|
|
14
|
+
@click.option("--output", "-o", default=None, metavar="FILE", help="Save the brief to a markdown file.")
|
|
15
|
+
def cli(github_url: str, output: str | None) -> None:
|
|
16
|
+
"""Generate a human-readable brief for a GitHub repository."""
|
|
17
|
+
try:
|
|
18
|
+
show_fetching(github_url)
|
|
19
|
+
owner, repo_name = parse_repo_url(github_url)
|
|
20
|
+
|
|
21
|
+
repo = fetch_repo_data(owner, repo_name)
|
|
22
|
+
readme = fetch_readme(owner, repo_name)
|
|
23
|
+
file_tree = fetch_file_tree(owner, repo_name)
|
|
24
|
+
|
|
25
|
+
show_generating()
|
|
26
|
+
start = time.monotonic()
|
|
27
|
+
brief = generate_brief(repo, readme, file_tree)
|
|
28
|
+
elapsed = time.monotonic() - start
|
|
29
|
+
show_brief(repo["name"], brief, elapsed)
|
|
30
|
+
|
|
31
|
+
if output:
|
|
32
|
+
md = f"# {repo['name']}\n\n> {github_url}\n\n{brief}\n"
|
|
33
|
+
with open(output, "w", encoding="utf-8") as f:
|
|
34
|
+
f.write(md)
|
|
35
|
+
show_saved(output)
|
|
36
|
+
|
|
37
|
+
except ValueError as e:
|
|
38
|
+
show_error(str(e))
|
|
39
|
+
raise SystemExit(1)
|
|
40
|
+
except EnvironmentError as e:
|
|
41
|
+
show_error(str(e))
|
|
42
|
+
raise SystemExit(1)
|
|
43
|
+
except Exception as e:
|
|
44
|
+
show_error(f"Unexpected error: {e}")
|
|
45
|
+
raise SystemExit(1)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
cli()
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: devbrief
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate a human-readable brief for any GitHub repository using Claude AI
|
|
5
|
+
Project-URL: Homepage, https://github.com/s3bc40/devbrief
|
|
6
|
+
Project-URL: Repository, https://github.com/s3bc40/devbrief
|
|
7
|
+
Author-email: "Sebastien Claro (s3bc40)" <s3bc40@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ai,cli,developer-tools,github
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Requires-Dist: anthropic>=0.84.0
|
|
15
|
+
Requires-Dist: click>=8.3.1
|
|
16
|
+
Requires-Dist: python-dotenv>=1.2.2
|
|
17
|
+
Requires-Dist: requests>=2.32.5
|
|
18
|
+
Requires-Dist: rich>=14.3.3
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# devbrief
|
|
22
|
+
|
|
23
|
+
> Generate a human-readable project brief for any GitHub repository using Claude AI.
|
|
24
|
+
|
|
25
|
+
`devbrief` takes a GitHub URL, pulls the repository metadata, README, and file tree, then asks Claude to produce a structured brief — covering what the project does, its tech stack, how to get started, and its limitations — directly in your terminal.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
### pip
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install devbrief
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### uvx (run without installing)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uvx devbrief <github-url>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### uv (install globally)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
uv tool install devbrief
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Prerequisites
|
|
52
|
+
|
|
53
|
+
An [Anthropic API key](https://console.anthropic.com/) is required.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or place it in a `.env` file at your working directory:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
devbrief <github-url> [--output FILE]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Examples
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Print the brief to the terminal
|
|
77
|
+
devbrief https://github.com/anthropics/anthropic-sdk-python
|
|
78
|
+
|
|
79
|
+
# Save the brief as a markdown file
|
|
80
|
+
devbrief https://github.com/astral-sh/uv --output uv-brief.md
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Options
|
|
84
|
+
|
|
85
|
+
| Option | Short | Description |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `--output FILE` | `-o` | Save the brief as a markdown file |
|
|
88
|
+
| `--help` | | Show usage and exit |
|
|
89
|
+
|
|
90
|
+
### Output sections
|
|
91
|
+
|
|
92
|
+
Each generated brief contains:
|
|
93
|
+
|
|
94
|
+
- **One-line description** — a crisp summary of the project
|
|
95
|
+
- **Problem it solves** — the core need being addressed
|
|
96
|
+
- **Tech stack** — detected languages, frameworks, and tools
|
|
97
|
+
- **Getting started** — steps extracted from the README
|
|
98
|
+
- **Who would find it useful** — the target audience
|
|
99
|
+
- **Limitations / potential improvements** — honest trade-offs
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## How it works
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
GitHub URL
|
|
107
|
+
│
|
|
108
|
+
├── /repos/:owner/:repo → name, description, stars, language, topics
|
|
109
|
+
├── /repos/:owner/:repo/readme → decoded README content (first 3000 chars)
|
|
110
|
+
└── /repos/:owner/:repo/contents → top-level file tree
|
|
111
|
+
│
|
|
112
|
+
└── Structured prompt → Claude claude-opus-4-6 → Rich terminal output
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
Requires [uv](https://docs.astral.sh/uv/).
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
git clone https://github.com/s3bc40/devbrief
|
|
123
|
+
cd devbrief
|
|
124
|
+
uv sync
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Run locally
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
uv run devbrief https://github.com/s3bc40/devbrief
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Run tests
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
uv run pytest
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Tests cover URL parsing, GitHub API response mapping, edge cases (missing README, empty file tree), and Rich display output. No real API calls are made — all HTTP responses are mocked.
|
|
140
|
+
|
|
141
|
+
### Project structure
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
src/devbrief/
|
|
145
|
+
├── main.py # Click CLI entry point
|
|
146
|
+
├── github.py # GitHub REST API fetchers
|
|
147
|
+
├── brief.py # Prompt construction and Claude API call
|
|
148
|
+
└── display.py # Rich terminal rendering
|
|
149
|
+
tests/
|
|
150
|
+
├── test_github.py
|
|
151
|
+
└── test_display.py
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Contributing
|
|
157
|
+
|
|
158
|
+
1. Fork the repository and create a branch from `main`.
|
|
159
|
+
2. Make focused commits with explicit messages (one concern per commit).
|
|
160
|
+
3. Add or update tests for any changed behaviour.
|
|
161
|
+
4. Open a pull request — describe the problem and your solution.
|
|
162
|
+
|
|
163
|
+
Please do not open issues to ask for new AI providers or models; the project is intentionally scoped to the Anthropic API.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
devbrief/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
devbrief/brief.py,sha256=Uj05Q8sC3bsOFvMoJwyy68vQDhGCBc9wkbFsnYrv-mA,1812
|
|
3
|
+
devbrief/display.py,sha256=e7inuUA8v-EBgnUsyQ5GMWxlowMPGb7H9TDLwGcgb5I,947
|
|
4
|
+
devbrief/github.py,sha256=H-05q1K_XMlBbIvpNzFOCsqHnoQljEtmfJ7XPxxrCYg,1705
|
|
5
|
+
devbrief/main.py,sha256=Xbzu3k1QUkZn0itTXJ99dKUFqwNPSz-XeqPkkYMcReE,1551
|
|
6
|
+
devbrief-0.1.0.dist-info/METADATA,sha256=dcs-gEA6nKug-oS8I9hQFc-6tCVMGMgGME-IRid-AnY,3991
|
|
7
|
+
devbrief-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
8
|
+
devbrief-0.1.0.dist-info/entry_points.txt,sha256=kU7SIO5C2UJVzm_pxUgbqFZjf2sO5EsSigaaeyfiTdQ,47
|
|
9
|
+
devbrief-0.1.0.dist-info/licenses/LICENSE,sha256=M0Es4-j3Vq11f-N220IAcsGJrvRm3EMv3-e52DNg22c,1081
|
|
10
|
+
devbrief-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sebastien Claro (s3bc40)
|
|
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.
|