Skip to content

Commit 80f85f8

Browse files
committed
add agent instruction docs
1 parent 9733218 commit 80f85f8

6 files changed

Lines changed: 38 additions & 22 deletions

File tree

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ codewiki generate --create-branch --github-pages --verbose
139139
CodeWiki supports customization for language-specific projects and documentation styles:
140140

141141
```bash
142-
# C# project: only analyze .cs files, exclude tests
143-
codewiki generate --include "*.cs" --exclude "*Tests*,*Specs*"
142+
# C# project: only analyze .cs files, exclude test directories
143+
codewiki generate --include "*.cs" --exclude "Tests,Specs,*.test.cs"
144144

145145
# Focus on specific modules with architecture-style docs
146146
codewiki generate --focus "src/core,src/api" --doc-type architecture
@@ -149,6 +149,21 @@ codewiki generate --focus "src/core,src/api" --doc-type architecture
149149
codewiki generate --instructions "Focus on public APIs and include usage examples"
150150
```
151151

152+
#### Pattern Behavior (Important!)
153+
154+
- **`--include`**: When specified, **ONLY** these patterns are used (replaces defaults completely)
155+
- Example: `--include "*.cs"` will analyze ONLY `.cs` files
156+
- If omitted, all supported file types are analyzed
157+
- Supports glob patterns: `*.py`, `src/**/*.ts`, `*.{js,jsx}`
158+
159+
- **`--exclude`**: When specified, patterns are **MERGED** with default ignore patterns
160+
- Example: `--exclude "Tests,Specs"` will exclude these directories AND still exclude `.git`, `__pycache__`, `node_modules`, etc.
161+
- Default patterns include: `.git`, `node_modules`, `__pycache__`, `*.pyc`, `bin/`, `dist/`, and many more
162+
- Supports multiple formats:
163+
- Exact names: `Tests`, `.env`, `config.local`
164+
- Glob patterns: `*.test.js`, `*_test.py`, `*.min.*`
165+
- Directory patterns: `build/`, `dist/`, `coverage/`
166+
152167
#### Setting Persistent Defaults
153168

154169
Save your preferred settings as defaults:
@@ -157,8 +172,8 @@ Save your preferred settings as defaults:
157172
# Set include patterns for C# projects
158173
codewiki config agent --include "*.cs"
159174

160-
# Exclude test projects by default
161-
codewiki config agent --exclude "*Tests*,*Specs*,test_*"
175+
# Exclude test projects by default (merged with default excludes)
176+
codewiki config agent --exclude "Tests,Specs,*.test.cs"
162177

163178
# Set focus modules
164179
codewiki config agent --focus "src/core,src/api"
@@ -173,13 +188,13 @@ codewiki config agent
173188
codewiki config agent --clear
174189
```
175190

176-
| Option | Description | Example |
177-
|--------|-------------|---------|
178-
| `--include` | File patterns to include | `*.cs`, `*.py,*.pyi` |
179-
| `--exclude` | Patterns to exclude | `*Tests*`, `*test*,*mock*` |
180-
| `--focus` | Modules to document in detail | `src/core,src/api` |
181-
| `--doc-type` | Documentation style | `api`, `architecture`, `user-guide`, `developer` |
182-
| `--instructions` | Custom agent instructions | Free-form text |
191+
| Option | Description | Behavior | Example |
192+
|--------|-------------|----------|---------|
193+
| `--include` | File patterns to include | **Replaces** defaults | `*.cs`, `*.py`, `src/**/*.ts` |
194+
| `--exclude` | Patterns to exclude | **Merges** with defaults | `Tests,Specs`, `*.test.js`, `build/` |
195+
| `--focus` | Modules to document in detail | Standalone option | `src/core,src/api` |
196+
| `--doc-type` | Documentation style | Standalone option | `api`, `architecture`, `user-guide`, `developer` |
197+
| `--instructions` | Custom agent instructions | Standalone option | Free-form text |
183198

184199
### Configuration Storage
185200

codewiki/src/be/agent_orchestrator.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
from codewiki.src.be.agent_tools.generate_sub_module_documentations import generate_sub_module_documentation_tool
4343
from codewiki.src.be.llm_services import create_fallback_models
4444
from codewiki.src.be.prompt_template import (
45-
SYSTEM_PROMPT,
46-
LEAF_SYSTEM_PROMPT,
4745
format_user_prompt,
4846
format_system_prompt,
4947
format_leaf_system_prompt,
@@ -64,12 +62,11 @@ class AgentOrchestrator:
6462
def __init__(self, config: Config):
6563
self.config = config
6664
self.fallback_models = create_fallback_models(config)
65+
self.custom_instructions = config.get_prompt_addition() if config else None
6766

6867
def create_agent(self, module_name: str, components: Dict[str, Any],
6968
core_component_ids: List[str]) -> Agent:
7069
"""Create an appropriate agent based on module complexity."""
71-
# Get custom instructions from config
72-
custom_instructions = self.config.get_prompt_addition() if self.config else None
7370

7471
if is_complex_module(components, core_component_ids):
7572
return Agent(
@@ -81,15 +78,15 @@ def create_agent(self, module_name: str, components: Dict[str, Any],
8178
str_replace_editor_tool,
8279
generate_sub_module_documentation_tool
8380
],
84-
system_prompt=format_system_prompt(module_name, custom_instructions),
81+
system_prompt=format_system_prompt(module_name, self.custom_instructions),
8582
)
8683
else:
8784
return Agent(
8885
self.fallback_models,
8986
name=module_name,
9087
deps_type=CodeWikiDeps,
9188
tools=[read_code_components_tool, str_replace_editor_tool],
92-
system_prompt=format_leaf_system_prompt(module_name, custom_instructions),
89+
system_prompt=format_leaf_system_prompt(module_name, self.custom_instructions),
9390
)
9491

9592
async def process_module(self, module_name: str, components: Dict[str, Node],
@@ -115,7 +112,8 @@ async def process_module(self, module_name: str, components: Dict[str, Node],
115112
module_tree=module_tree,
116113
max_depth=self.config.max_depth,
117114
current_depth=1,
118-
config=self.config
115+
config=self.config,
116+
custom_instructions=self.custom_instructions
119117
)
120118

121119
# check if overview docs already exists

codewiki/src/be/agent_tools/deps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ class CodeWikiDeps:
1313
module_tree: dict[str, any]
1414
max_depth: int
1515
current_depth: int
16-
config: Config # LLM configuration
16+
config: Config # LLM configuration
17+
custom_instructions: str = None

codewiki/src/be/agent_tools/generate_sub_module_documentations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ async def generate_sub_module_documentation(
5252
model=fallback_models,
5353
name=sub_module_name,
5454
deps_type=CodeWikiDeps,
55-
system_prompt=SYSTEM_PROMPT.format(module_name=sub_module_name),
55+
system_prompt=SYSTEM_PROMPT.format(module_name=sub_module_name, custom_instructions=ctx.deps.custom_instructions),
5656
tools=[read_code_components_tool, str_replace_editor_tool, generate_sub_module_documentation_tool],
5757
)
5858
else:
5959
sub_agent = Agent(
6060
model=fallback_models,
6161
name=sub_module_name,
6262
deps_type=CodeWikiDeps,
63-
system_prompt=LEAF_SYSTEM_PROMPT.format(module_name=sub_module_name),
63+
system_prompt=LEAF_SYSTEM_PROMPT.format(module_name=sub_module_name, custom_instructions=ctx.deps.custom_instructions),
6464
tools=[read_code_components_tool, str_replace_editor_tool],
6565
)
6666

codewiki/src/be/dependency_analyzer/analysis/repo_analyzer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ def __init__(
1919
include_patterns: Optional[List[str]] = None,
2020
exclude_patterns: Optional[List[str]] = None,
2121
) -> None:
22+
# Include patterns: if specified, use ONLY those patterns (replaces defaults)
2223
self.include_patterns = (
2324
include_patterns if include_patterns is not None else DEFAULT_INCLUDE_PATTERNS
2425
)
26+
# Exclude patterns: if specified, MERGE with default ignore patterns
2527
self.exclude_patterns = (
2628
list(DEFAULT_IGNORE_PATTERNS) + exclude_patterns
2729
if exclude_patterns is not None

codewiki/src/fe/background_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from dataclasses import asdict
1717

1818
from codewiki.src.be.documentation_generator import DocumentationGenerator
19-
from codewiki.src.config import Config
19+
from codewiki.src.config import Config, MAIN_MODEL
2020
from .models import JobStatus
2121
from .cache_manager import CacheManager
2222
from .github_processor import GitHubRepoProcessor

0 commit comments

Comments
 (0)