Skip to content

Commit 6d0de7e

Browse files
clanker-loverclaude
andcommitted
v0.5.0: cloud AI support (OpenAI, OpenRouter, Groq, custom endpoints) + security hardening
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1f5e355 commit 6d0de7e

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ dist/
2626
.aider*
2727
benchmark.py
2828
benchmark_results.txt
29+
REVIEW.txt

README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ A docent is a guide who explains things to people who aren't experts. Codedocent
1010

1111
You're staring at a codebase you didn't write — maybe thousands of files across dozens of directories — and you need to understand what it does. Reading every file isn't realistic. You need a way to visualize the code structure, get a high-level map of what's where, and drill into the parts that matter without losing context.
1212

13-
Codedocent parses the codebase into a navigable, visual block structure and explains each piece in plain English. It's an AI code analysis tool that runs entirely on your machine — no API keys, no cloud, no data leaving your laptop. Point it at any codebase and get a structural overview you can explore interactively, understand quickly, and share as a static HTML file.
13+
Codedocent parses the codebase into a navigable, visual block structure and explains each piece in plain English. It's an AI code analysis tool — use a cloud provider for speed or run locally through Ollama for full privacy. Point it at any codebase and get a structural overview you can explore interactively, understand quickly, and share as a static HTML file.
1414

1515
## Who this is for
1616

@@ -23,15 +23,15 @@ Codedocent parses the codebase into a navigable, visual block structure and expl
2323

2424
## What you see
2525

26-
Nested, color-coded blocks representing directories, files, classes, and functions — the entire structure of a codebase laid out visually. Each block shows a plain English summary, a pseudocode translation, and quality warnings (green/yellow/red). Click any block to drill down; breadcrumbs navigate you back up. You can export code from any block or paste replacement code back into the source file. All AI runs locally through Ollama — nothing leaves your machine.
26+
Nested, color-coded blocks representing directories, files, classes, and functions — the entire structure of a codebase laid out visually. Each block shows a plain English summary, a pseudocode translation, and quality warnings (green/yellow/red). Click any block to drill down; breadcrumbs navigate you back up. You can export code from any block or paste replacement code back into the source file. AI explanations come from your choice of cloud provider or local Ollama.
2727

2828
## Install
2929

3030
```bash
3131
pip install codedocent
3232
```
3333

34-
Requires Python 3.10+ and [Ollama](https://ollama.com) running locally for AI features. Works without AI too (`--no-ai`).
34+
Requires Python 3.10+. Cloud AI needs an API key set in an env var (e.g. `OPENAI_API_KEY`). Local AI needs [Ollama](https://ollama.com) running. `--no-ai` skips AI entirely.
3535

3636
## Quick start
3737

@@ -40,15 +40,22 @@ codedocent # setup wizard — walks you through everythi
4040
codedocent /path/to/code # interactive mode (recommended)
4141
codedocent /path/to/code --full # full analysis, static HTML output
4242
codedocent --gui # graphical launcher
43+
codedocent /path/to/code --cloud openai # use OpenAI
44+
codedocent /path/to/code --cloud groq # use Groq
45+
codedocent /path/to/code --cloud custom --endpoint https://my-llm/v1/chat/completions
4346
```
4447

4548
## How it works
4649

47-
Parses code structure with tree-sitter, scores quality with static analysis, and sends individual blocks to a local Ollama model for plain English summaries and pseudocode. Interactive mode analyzes on click — typically 1-2 seconds per block. Full mode analyzes everything upfront into a self-contained HTML file you can share.
50+
Parses code structure with tree-sitter, scores quality with static analysis, and sends individual blocks to a cloud AI provider or local Ollama model for plain English summaries and pseudocode. Interactive mode analyzes on click — typically 1-2 seconds per block. Full mode analyzes everything upfront into a self-contained HTML file you can share.
4851

49-
## Why local
52+
## AI options
5053

51-
All AI processing runs through Ollama on your machine. Your code is never uploaded, transmitted, or stored anywhere external. No API keys, no accounts, no cloud services. This matters when you're working with proprietary code, client projects, or anything you can't share — codedocent works fully air-gapped. The `--no-ai` mode removes the AI dependency entirely while keeping the structural visualization and quality scoring.
54+
- **Cloud AI** — send code to OpenAI, OpenRouter, Groq, or any OpenAI-compatible endpoint. Fast, no local setup. Your code is sent to that service. API keys are read from env vars (`OPENAI_API_KEY`, `OPENROUTER_API_KEY`, `GROQ_API_KEY`, `CODEDOCENT_API_KEY` for custom endpoints).
55+
- **Local AI**[Ollama](https://ollama.com) on your machine. Code never leaves your laptop. No API keys, no accounts.
56+
- **No AI** (`--no-ai`) — structure and quality scores only.
57+
58+
The setup wizard (`codedocent` with no args) walks you through choosing.
5259

5360
## Supported languages
5461

codedocent/cloud_ai.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(self, value: str) -> None:
6464
self._value = value
6565

6666
def reveal(self) -> str:
67+
"""Return the unwrapped secret value."""
6768
return self._value
6869

6970
def __repr__(self) -> str:
@@ -128,11 +129,9 @@ def cloud_chat(
128129
"max_tokens": 1024,
129130
}).encode("utf-8")
130131

132+
key = api_key.reveal() if isinstance(api_key, _MaskedSecret) else api_key
131133
headers = {
132-
"Authorization": "Bearer {}".format(
133-
api_key.reveal()
134-
if isinstance(api_key, _MaskedSecret) else api_key
135-
),
134+
"Authorization": f"Bearer {key}",
136135
"Content-Type": "application/json",
137136
"User-Agent": _USER_AGENT,
138137
}

0 commit comments

Comments
 (0)