Skip to content

Commit f51ba13

Browse files
committed
docs: updated docs for ctx generate command
1 parent 7d895fe commit f51ba13

File tree

3 files changed

+84
-56
lines changed

3 files changed

+84
-56
lines changed

docs/advanced/development-process.md

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -52,52 +52,38 @@ Use the following instruction to create a context file with detailed description
5252
> help it understand the document structure.
5353
5454
```
55-
Your goal is to create a `context.yaml` configuration that:
56-
57-
1. Organizes source code into logical, cohesive documents
58-
2. Provides detailed descriptions that explain each component's purpose and relationships
59-
3. Uses appropriate source types and filtering to capture relevant code
60-
4. Creates a structure that makes navigation and understanding intuitive
61-
62-
## Configuration Structure
63-
64-
Start by analyzing the codebase to identify major functional areas. For each area, create a document with:
65-
66-
1. A clear, descriptive title that indicates the document's focus
67-
2. A detailed description explaining what functionality this area provides
68-
3. Sources that target the relevant files with appropriate filtering
69-
4. For each source, a comprehensive description of what those specific files contribute
70-
71-
## Provide the following information:
72-
73-
Please create a configuration that:
74-
75-
1. Organizes the code by [functional areas/module types/etc.]
76-
2. Provides detailed descriptions explaining [what aspects you want explained]
77-
3. Uses [specific source types if relevant]
78-
4. Includes explanatory content using the text source type where helpful
79-
80-
## Best Practices
81-
82-
When creating configurations:
83-
84-
1. **Use meaningful groupings**: Group related files together based on functionality rather than just directory
85-
structure
86-
2. **Provide context in descriptions**: Explain not just what components do, but how they relate to the larger system
87-
3. **Use filtering effectively**: Apply path, pattern, and content filters to include only relevant files
88-
4. **Include architectural overviews**: Use text sources to provide high-level explanations where appropriate
89-
5. **Leverage tree visualizations**: For complex projects, include tree sources to visualize structure
90-
6. **Add directory context**: When using tree sources, add explanations via the dirContext property
91-
92-
## Using Advanced Features
93-
94-
Consider using these advanced features for more comprehensive configurations:
95-
96-
1. **Modifier configurations**: Use php-content-filter or sanitizer modifiers to focus on relevant code parts
97-
2. **Combined sources**: Mix different source types (file, text, tree) in a document for richer context
98-
3. **Nested documents**: Create hierarchical document structures with overview and detail documents
99-
4. **Tag-based organization**: Use tags to create cross-cutting views of the codebase
100-
5. **GitDiff sources**: For evolving codebases, capture recent changes for focused documentation
55+
Your goal is to create a `context.yaml` file, using provided JSON schema for context generator.
56+
Always use YAML syntax.
57+
58+
Provide multiple configs. Split documents into small logical config files. Small configs is better that one big config.
59+
60+
**Rules**
61+
1. **Organizes Code**
62+
- Split your source code into clear, logical documents based on its functions or modules.
63+
- Group related files together based on what they do, not just their folder structure.
64+
2. **Detailed Descriptions**
65+
- Write a title and a short, clear description for each document.
66+
- Explain the purpose of each component and how they connect to the rest of the project.
67+
3. **Relevant Sources and Filtering**
68+
- Use the right source types (file, text, tree, etc.) to capture the needed code.
69+
- Apply filters (by path, pattern, or content) to only include the important files.
70+
- Do not try to use `contains` filter. Only by file path.
71+
4. **Output Paths**
72+
- Make sure output paths start with the content/context type, like `project/` or `feature/`.
73+
5. **Content Limit**
74+
- Ensure that each document does not exceed 50,000 characters.
75+
76+
**Extra Tips:**
77+
- **Meaningful Groupings:** Focus on functionality. Group files that work together.
78+
- More small documents is better than one big document.
79+
- **Use Visuals:** For bigger projects, include tree views or mermaid diagrams with extra notes.
80+
- Do not provide default values for properties
81+
- Do not use quotes if it unnecessary
82+
- Do not use arrays in format `[...]`
83+
- Advanced Features:
84+
- Mix different source types for richer details.
85+
- Consider nested documents or tag-based views for more complex projects.
86+
- Use GitDiff sources if you need to show recent changes.
10187
```
10288
10389
### Step 3: Explore Configuration and Entry Points

docs/advanced/smart-context-requesting.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,35 @@ through executable commands. This creates a feedback loop that significantly enh
3737
Here's a complete workflow example showing how an LLM and the Context Generator can work together:
3838

3939
1. **User Question**:
40-
"I'm getting an error in our payment processing system when handling refunds. The error says 'Invalid transaction
41-
state'. How can I fix this?"
40+
41+
```
42+
I'm getting an error in our payment processing system when handling refunds.
43+
The error says 'Invalid transactionstate'. How can I fix this?
44+
45+
Here is my project structure:
46+
47+
├── services/
48+
│ └── payment/
49+
│ └── app/
50+
│ └── src/
51+
│ └── Application/
52+
│ ├── RefundService.php
53+
│ ├── TransactionState.php
54+
│ └── PaymentProcessor.php
55+
56+
I attached JSON schema of Context generator. Use it to ask for the context you need to fix the issue in the following format:
57+
58+
ctx --config='{
59+
"documents": [{
60+
"description": "Document description",
61+
"outputPath": "context.md",
62+
"sources": [{
63+
"type": "file",
64+
"sourcePaths": ["src"]
65+
}]
66+
}]
67+
}'
68+
```
4269

4370
2. **LLM Initial Response**:
4471
"I'll help troubleshoot this issue. To understand what's happening, I need to see the payment processing code,

docs/getting-started/command-reference.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ ctx build
1919

2020
### Options
2121

22-
| Option | Description |
23-
|------------------------|------------------------------------------------------------------------------------------------|
24-
| `--github-token`, `-t` | GitHub token for authentication (default: reads from `GITHUB_TOKEN` environment variable) |
25-
| `--env`, `-e` | Load environment variables from a file. If used without specifying a file, defaults to `.env`. |
22+
| Option | Description |
23+
|------------------------|----------------------------------------------------------------------------------------------------------------------------|
24+
| `--github-token`, `-t` | GitHub token for authentication (default: reads from `GITHUB_TOKEN` environment variable) |
25+
| `--env`, `-e` | Load environment variables from a file. If used without specifying a file, defaults to `.env`. |
26+
| `--inline`, `-i` | Inline JSON configuration string. If provided, file-based configuration will be ignored. |
27+
| `--config-file`, `-c` | Path to a specific configuration file or directory. If not provided, will look for standard config files in the root path. |
2628

27-
Examples of using the `--env` option:
29+
**Examples of using the `--env` option:**
2830

2931
```bash
3032
# Load variables from a specific file
@@ -34,6 +36,19 @@ ctx --env=.env.local
3436
ctx
3537
```
3638

39+
**Examples of specifying configuration:**
40+
41+
```bash
42+
# Use a specific configuration file
43+
ctx -c src/custom-config.yaml
44+
45+
# Look for standard config files (context.json, context.yaml, etc.) in a specific directory
46+
ctx -c src/configs
47+
48+
# Use inline JSON configuration
49+
ctx -i '{"documents":[{"description":"Quick Context","outputPath":"output.md","sources":[{"type":"text","content":"Sample content"}]}]}'
50+
```
51+
3752
## Initialize a Configuration File
3853

3954
Creates a new configuration file in the current directory. The default filename is `context.yaml` if not specified.
@@ -118,9 +133,9 @@ ctx schema -d -o custom-name.json
118133
You can provide a JSON configuration directly on the command line without needing a config file:
119134

120135
```bash
121-
ctx --config='{"documents":[{"description":"Quick Context","outputPath":"output.md","sources":[{"type":"text","content":"Sample content"}]}]}'
136+
ctx --inline='{"documents":[{"description":"Quick Context","outputPath":"output.md","sources":[{"type":"text","content":"Sample content"}]}]}'
122137
# or
123-
ctx -c '{"documents":[{"description":"Quick Context","outputPath":"output.md","sources":[{"type":"text","content":"Sample content"}]}]}'
138+
ctx -i '{"documents":[{"description":"Quick Context","outputPath":"output.md","sources":[{"type":"text","content":"Sample content"}]}]}'
124139
```
125140

126141
**This is useful for:**
@@ -134,7 +149,7 @@ The JSON configuration structure follows the same schema as config files. For co
134149
consider using a heredoc in your shell scripts:
135150

136151
```bash
137-
ctx --config='
152+
ctx --inline='
138153
{
139154
"documents": [
140155
{

0 commit comments

Comments
 (0)