Skip to content

Commit 63e68eb

Browse files
authored
Merge pull request #60 from FSoft-AI4Code/feat/run-on-claude-codex-sub
Support running on Claude and Codex subscriptions
2 parents 5a843b9 + 386806a commit 63e68eb

54 files changed

Lines changed: 28828 additions & 350 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DEVELOPMENT.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ codewiki/
1414
│ │ └── adapters/ # External integrations
1515
│ ├── src/ # Web application
1616
│ │ ├── be/ # Backend (dependency analysis, agents)
17-
│ │ │ ├── agent_orchestrator.py
17+
│ │ │ ├── backend.py # LLMBackend abstraction + factory
18+
│ │ │ ├── pydantic_ai_backend.py # API-key backend (OpenAI/Anthropic/Bedrock/Azure)
19+
│ │ │ ├── caw_backend.py # Subscription backend (claude / codex CLI via caw)
20+
│ │ │ ├── caw_toolkit.py # CodeWiki tools exposed to caw via MCP
1821
│ │ │ ├── agent_tools/
1922
│ │ │ ├── cluster_modules.py
2023
│ │ │ ├── dependency_analyzer/
@@ -83,11 +86,15 @@ pip install -r requirements.txt
8386
- Feature-oriented module partitioning
8487
- Topological sorting for dependency ordering
8588

86-
#### 3. Agent System (`src/be/agent_orchestrator.py`)
89+
#### 3. Agent System (`src/be/backend.py`, `pydantic_ai_backend.py`, `caw_backend.py`)
8790

88-
- Recursive agent-based documentation generation
89-
- Dynamic delegation for complex modules
90-
- Cross-module reference management
91+
- ``LLMBackend`` abstracts the API-key and CLI-subscription paths.
92+
- ``PydanticAIBackend`` runs the per-module agent via pydantic-ai (used by
93+
``openai-compatible`` / ``anthropic`` / ``bedrock`` / ``azure-openai``).
94+
- ``CawBackend`` routes the per-module agent through the ``claude`` /
95+
``codex`` CLI via the ``caw`` library (used by the ``claude-code`` /
96+
``codex`` providers). CodeWiki's tools are exposed to the CLI via an MCP
97+
server defined in ``caw_toolkit.py``.
9198

9299
#### 4. Agent Tools (`src/be/agent_tools/`)
93100

@@ -168,7 +175,7 @@ class AgentInstructions:
168175
5. **Use in relevant components**:
169176
- File filtering → `dependency_analyzer/ast_parser.py`
170177
- Prompts → `be/prompt_template.py`
171-
- Agent creation → `be/agent_orchestrator.py`
178+
- Agent creation → `be/pydantic_ai_backend.py` (API path) or `be/caw_backend.py` (subscription path)
172179

173180
---
174181

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@
1919
<a href="#quick-start"><strong>Quick Start</strong></a> •
2020
<a href="#cli-commands"><strong>CLI Commands</strong></a> •
2121
<a href="#documentation-output"><strong>Output Structure</strong></a> •
22+
<a href="./docs/index.html"><strong>Repo Docs</strong></a> •
2223
<a href="https://arxiv.org/abs/2510.24428"><strong>Paper</strong></a>
2324
</p>
2425

26+
<p align="center">
27+
📚 <strong>CodeWiki documents itself</strong> — browse the generated documentation for this repository at <a href="./docs/index.html"><code>docs/index.html</code></a> (open in a browser, or visit the hosted GitHub Pages site).
28+
</p>
29+
2530
<p align="center">
2631
<img src="./img/framework-overview.png" alt="CodeWiki Framework" width="600" style="border: 2px solid #e1e4e8; border-radius: 12px; padding: 20px;"/>
2732
</p>
@@ -42,11 +47,21 @@ codewiki --version
4247

4348
### 2. Configure Your Environment
4449

45-
CodeWiki supports multiple LLM providers: **OpenAI-compatible**, **Anthropic**, **AWS Bedrock**, and **Azure OpenAI**.
50+
CodeWiki supports multiple LLM providers: **OpenAI-compatible**, **Anthropic**, **AWS Bedrock**, **Azure OpenAI**, plus subscription mode via **Claude Code** and **Codex** CLIs (no API key required).
4651

4752
```bash
53+
# OpenAI-compatible
54+
codewiki config set \
55+
--provider openai-compatible \
56+
--api-key YOUR_API_KEY \
57+
--base-url https://api.anthropic.com \
58+
--main-model claude-sonnet-4 \
59+
--cluster-model claude-sonnet-4 \
60+
--fallback-model glm-4p5
61+
4862
# Anthropic
4963
codewiki config set \
64+
--provider anthropic \
5065
--api-key YOUR_API_KEY \
5166
--base-url https://api.anthropic.com \
5267
--main-model claude-sonnet-4 \
@@ -68,8 +83,26 @@ codewiki config set \
6883
--aws-region us-east-1 \
6984
--main-model anthropic.claude-sonnet-4-v2:0 \
7085
--cluster-model anthropic.claude-sonnet-4-v2:0
86+
87+
# Subscription mode (Claude Code) — uses your existing Claude OAuth login.
88+
# Install the Claude Code CLI and run `claude login` first.
89+
codewiki config set \
90+
--provider claude-code \
91+
--main-model claude-sonnet-4-6 \
92+
--cluster-model claude-sonnet-4-6
93+
94+
# Subscription mode (Codex) — uses your existing Codex CLI login.
95+
# Install the Codex CLI and run `codex login` first.
96+
codewiki config set \
97+
--provider codex \
98+
--main-model gpt-5.4 \
99+
--cluster-model gpt-5.5
71100
```
72101

102+
**Subscription mode** routes every LLM call through the local `claude` / `codex` CLI binary (via the [`caw`](https://github.com/zzjas/caw) library), so you can run CodeWiki on a Claude Pro/Max or Codex subscription instead of paying per-token API usage. Claude Code's built-in `Write`/`Edit`/`Bash` tools are disabled inside CodeWiki's agent loop so documentation writes still go through CodeWiki's Mermaid-validating editor.
103+
104+
> **Note on model names.** In subscription mode the model string is forwarded directly to `claude --model` / `codex --model`, so use the bare CLI model name (e.g. `gpt-5.4`, `claude-sonnet-4-6`) — **not** the litellm-style `openai/…` or `anthropic/…` prefix used by `openai-compatible`. If you previously ran with `openai-compatible`, re-run `config set` for **both** `--main-model` and `--cluster-model` to clear any stale prefixes; `config set` only updates the keys you pass.
105+
73106
### 3. Generate Documentation
74107

75108
```bash
@@ -289,6 +322,8 @@ Generated documentation includes both **textual descriptions** and **visual arti
289322
└── index.html # Interactive viewer (with --github-pages)
290323
```
291324

325+
> **See it in action:** This repository's own docs are checked in under [`./docs/`](./docs/) — open [`./docs/index.html`](./docs/index.html) in a browser for the interactive viewer, or start from [`./docs/overview.md`](./docs/overview.md).
326+
292327
---
293328

294329
## Experimental Results
@@ -359,6 +394,7 @@ CodeWiki employs a three-stage process for comprehensive documentation generatio
359394
## Additional Resources
360395

361396
### Documentation & Guides
397+
- **[This Repo's Generated Docs](./docs/index.html)** - Interactive documentation for CodeWiki itself, produced by CodeWiki (start at [`docs/overview.md`](./docs/overview.md))
362398
- **[MCP Server](codewiki/mcp/)** - Model Context Protocol server for IDE integrations
363399
- **[Docker Deployment](docker/DOCKER_README.md)** - Containerized deployment instructions
364400
- **[Development Guide](DEVELOPMENT.md)** - Project structure, architecture, and contributing guidelines

codewiki/cli/adapters/doc_generator.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ async def _run_backend_generation(self, backend_config: BackendConfig):
210210
from codewiki.src.be.cluster_modules import cluster_modules
211211
from codewiki.src.utils import file_manager
212212
from codewiki.src.config import FIRST_MODULE_TREE_FILENAME, MODULE_TREE_FILENAME
213-
213+
214214
working_dir = str(self.output_dir.absolute())
215215
file_manager.ensure_directory(working_dir)
216216
first_module_tree_path = os.path.join(working_dir, FIRST_MODULE_TREE_FILENAME)
217217
module_tree_path = os.path.join(working_dir, MODULE_TREE_FILENAME)
218-
218+
219219
try:
220220
if os.path.exists(first_module_tree_path):
221221
module_tree = file_manager.load_json(first_module_tree_path)
@@ -224,7 +224,13 @@ async def _run_backend_generation(self, backend_config: BackendConfig):
224224
else:
225225
if self.verbose:
226226
self.progress_tracker.update_stage(0.3, f"Clustering {len(leaf_nodes)} leaf nodes with LLM...")
227-
module_tree = cluster_modules(leaf_nodes, components, backend_config)
227+
cluster_model = backend_config.cluster_model or None
228+
module_tree = cluster_modules(
229+
leaf_nodes,
230+
components,
231+
backend_config,
232+
completer=lambda p: doc_generator.backend.complete(p, model=cluster_model),
233+
)
228234
file_manager.save_json(module_tree, first_module_tree_path)
229235

230236
file_manager.save_json(module_tree, module_tree_path)

0 commit comments

Comments
 (0)