Skip to content

Commit a76b50a

Browse files
refactor(examples): code analysis engine
changes: - file: advanced_usage_examples.py area: core added: [example_4_batch_processing, example_5_custom_metrics, example_2_focus_area_strategies, example_1_custom_file_patterns, example_6_workflow_automation, main, +1 more] - file: cli_command_examples.py area: cli added: [run_command, main] - file: external_tools_examples.py area: util added: [example_2_run_individual_tools, example_5_custom_analysis, example_1_check_external_tools, example_3_run_all_tools, example_4_generate_strategy_with_tools, main] - file: integrated_functionality_examples.py area: core added: [example_2_template_generation, example_7_external_tools, example_3_strategy_comparison, example_5_strategy_stats, main, example_4_export_formats, +2 more] - file: quick_start_examples.py area: core added: [quick_start_4, quick_start_1, quick_start_2, quick_start_5, quick_start_3, main] - file: file_analyzer.py area: analyzer modified: [_extract_from_json_structure, _analyze_toon, _analyze_text, _analyze_json, _extract_from_yaml_structure, FileAnalyzer, +3 more] - file: generator.py area: analyzer modified: [_generate_goal, _generate_tasks, _make_serializable, PlanfileGenerator, _generate_target_metrics, _generate_quality_gates, +9 more] - file: metrics_extractor.py area: analyzer added: [_extract_critical_metrics, _extract_cc_metrics, _extract_duplication_metrics, extract_key_metrics, _extract_coverage_metrics, _extract_validation_metrics] - file: strategy_builder.py area: analyzer added: [generate_tasks, parse_effort, generate_quality_gates, generate_risks, generate_success_criteria, generate_target_metrics, +2 more] - file: json_parser.py area: analyzer added: [analyze_json] - file: text_parser.py area: analyzer added: [analyze_text] - file: toon_parser.py area: analyzer added: [_parse_toon_header, _parse_toon_sections, analyze_toon] - file: yaml_parser.py area: analyzer added: [extract_from_yaml_structure, analyze_yaml] - file: cmd_apply.py area: cli added: [_execute_apply_strategy, apply_strategy_cli, _display_apply_results, _save_results] - file: cmd_generate.py area: cli added: [generate_strategy_cli, generate_from_files_cmd] - file: cmd_review.py area: cli added: [review_strategy_cli] - file: cmd_utils.py area: cli added: [_select_backend, _load_backend_config, _load_and_validate_strategy, _parse_sprint_filter, get_backend] - file: cmd_validate.py area: cli added: [validate_strategy_cli] - file: commands.py area: cli removed: [validate_strategy_cli, _load_backend_config, _load_and_validate_strategy, _display_apply_results, _execute_apply_strategy, review_strategy_cli, +7 more] dependencies: flow: "external_tools_examples→generator→file_analyzer, advanced_usage_examples→generator→file_analyzer, toon_parser→text_parser, integrated_functionality_examples→generator→file_analyzer, json_parser→yaml_parser→text_parser, quick_start_examples→generator→file_analyzer" - advanced_usage_examples.py -> generator.py - external_tools_examples.py -> generator.py - integrated_functionality_examples.py -> generator.py - quick_start_examples.py -> generator.py - generator.py -> file_analyzer.py - json_parser.py -> yaml_parser.py - toon_parser.py -> text_parser.py - yaml_parser.py -> text_parser.py stats: lines: "+5027/-1184 (net +3843)" files: 27 complexity: "+127% complexity (monitor)"
1 parent 0dafe96 commit a76b50a

Some content is hidden

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

42 files changed

+5055
-1187
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.1.26] - 2026-03-26
11+
12+
### Docs
13+
- Update TODO.md
14+
- Update examples/EXAMPLES_REORGANIZATION.md
15+
- Update examples/README.md
16+
- Update examples/advanced-usage/README.md
17+
- Update examples/cli-commands/README.md
18+
- Update examples/external-tools/README.md
19+
- Update examples/integrated-functionality/README.md
20+
- Update examples/quick-start/README.md
21+
22+
### Other
23+
- Update examples/advanced-usage/advanced_usage_examples.py
24+
- Update examples/advanced-usage/run.sh
25+
- Update examples/cli-commands/cli_command_examples.py
26+
- Update examples/cli-commands/run.sh
27+
- Update examples/external-tools/external_tools_examples.py
28+
- Update examples/external-tools/run.sh
29+
- Update examples/integrated-functionality/integrated_functionality_examples.py
30+
- Update examples/integrated-functionality/run.sh
31+
- Update examples/quick-start.yaml
32+
- Update examples/quick-start/quick_start_examples.py
33+
- ... and 20 more files
34+
1035
## [0.1.25] - 2026-03-26
1136

1237
### Docs

TODO.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Planfile TODO List
2+
3+
## Completed Tasks
4+
- [x] Identify and remove unnecessary and generated files (`htmlcov/`, `.coverage`, etc.)
5+
- [x] Organize generated markdown summaries into `docs/summaries/` directory
6+
- [x] Run projects in `examples/*` to ensure base correctness
7+
- [x] Refactor `planfile/analysis/file_analyzer.py` (God module)
8+
- [x] Refactor `planfile/analysis/generator.py` (God module)
9+
- [x] Refactor `planfile/cli/commands.py` (God module)
10+
- [x] Split highest-CC functions (e.g., `_analyze_toon`, `_extract_key_metrics`)
11+
- [x] Preserve module boundaries and update imports/exports as per `map.toon.yaml`
12+
13+
## Pending Improvements
14+
- [ ] Implement `--version` flag for the CLI to display the current version.
15+
- [ ] Add an extensible Backend Registry to remove complex `if/elif` statements when creating integrations.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.25
1+
0.1.26
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Examples Reorganization Summary
2+
3+
## What Was Done
4+
5+
Reorganized all new examples into separate folders with consistent structure:
6+
7+
```
8+
examples/
9+
├── quick-start/ # Beginner friendly examples
10+
│ ├── README.md
11+
│ ├── run.sh
12+
│ └── quick_start_examples.py
13+
├── integrated-functionality/ # Complete feature demo
14+
│ ├── README.md
15+
│ ├── run.sh
16+
│ └── integrated_functionality_examples.py
17+
├── cli-commands/ # CLI command showcase
18+
│ ├── README.md
19+
│ ├── run.sh
20+
│ └── cli_command_examples.py
21+
├── external-tools/ # External tools integration
22+
│ ├── README.md
23+
│ ├── run.sh
24+
│ └── external_tools_examples.py
25+
└── advanced-usage/ # Advanced patterns
26+
├── README.md
27+
├── run.sh
28+
└── advanced_usage_examples.py
29+
```
30+
31+
## Benefits
32+
33+
1. **Better Organization** - Each example type has its own folder
34+
2. **Consistent Structure** - Every folder has README.md, run.sh, and Python script
35+
3. **Easy Navigation** - Clear progression from beginner to advanced
36+
4. **Independent Execution** - Each example can be run independently
37+
5. **Better Documentation** - Each README is specific to its examples
38+
39+
## How to Use
40+
41+
```bash
42+
# Quick start for beginners
43+
cd quick-start && ./run.sh
44+
45+
# Complete functionality overview
46+
cd integrated-functionality && ./run.sh
47+
48+
# CLI commands demonstration
49+
cd cli-commands && ./run.sh
50+
51+
# External tools (code2llm, vallm, redup)
52+
cd external-tools && ./run.sh
53+
54+
# Advanced patterns and workflows
55+
cd advanced-usage && ./run.sh
56+
```
57+
58+
## File Changes
59+
60+
### Moved Files
61+
- `quick_start_examples.py``quick-start/`
62+
- `integrated_functionality_examples.py``integrated-functionality/`
63+
- `cli_command_examples.py``cli-commands/`
64+
- `external_tools_examples.py``external-tools/`
65+
- `advanced_usage_examples.py``advanced-usage/`
66+
67+
### Created Files
68+
- 5 × `README.md` - One for each example folder
69+
- 5 × `run.sh` - Convenience scripts for each example
70+
- Updated main `examples/README.md` with new structure
71+
72+
### Updated Files
73+
- `examples/README.md` - Updated to reflect folder structure
74+
- Fixed import issue in `file_analyzer.py`
75+
76+
## Testing
77+
78+
All examples have been tested and work correctly:
79+
- Each `run.sh` script is executable
80+
- Examples run independently
81+
- Documentation is clear and accurate
82+
- Progression from simple to complex is logical
83+
84+
## Next Steps
85+
86+
1. Users can start with `quick-start` for basics
87+
2. Progress through examples based on needs
88+
3. Each folder is self-contained
89+
4. Generated files stay in their respective folders
90+
91+
The examples are now better organized and easier to navigate!

examples/README.md

Lines changed: 207 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,27 @@ examples/
2727
│ └── simple.yaml
2828
├── tasks/ # Example task patterns
2929
│ └── common.yaml
30-
└── run_all_tests.sh # Master test runner
30+
├── run_all_tests.sh # Master test runner
31+
├── quick-start/ # ⚡ Quick start guide (NEW!)
32+
│ ├── README.md
33+
│ ├── run.sh
34+
│ └── quick_start_examples.py
35+
├── integrated-functionality/ # 🚀 Integrated features demo
36+
│ ├── README.md
37+
│ ├── run.sh
38+
│ └── integrated_functionality_examples.py
39+
├── cli-commands/ # 💻 CLI commands showcase
40+
│ ├── README.md
41+
│ ├── run.sh
42+
│ └── cli_command_examples.py
43+
├── external-tools/ # 🔧 External tools integration
44+
│ ├── README.md
45+
│ ├── run.sh
46+
│ └── external_tools_examples.py
47+
└── advanced-usage/ # 🎯 Advanced patterns and workflows
48+
├── README.md
49+
├── run.sh
50+
└── advanced_usage_examples.py
3151
```
3252

3353
## Quick Start
@@ -48,14 +68,35 @@ pip install litellm llx PyGithub python-gitlab jira
4868
### 2. Set Up API Keys
4969

5070
```bash
71+
# For OpenAI (if using)
72+
export OPENAI_API_KEY=sk-...
73+
74+
# For GitHub backend (if using)
75+
export GITHUB_TOKEN=ghp_...
76+
5177
# For OpenRouter (free LLM validation)
52-
export OPENROUTER_API_KEY=your_key_here
78+
export OPENROUTER_API_KEY=sk-or-v1-...
79+
```
80+
81+
### 3. Run Examples
82+
83+
Each example has its own folder with README and run.sh script:
84+
85+
```bash
86+
# Quick start (beginners)
87+
cd quick-start && ./run.sh
88+
89+
# Integrated functionality (complete overview)
90+
cd integrated-functionality && ./run.sh
91+
92+
# CLI commands (command-line interface)
93+
cd cli-commands && ./run.sh
94+
95+
# External tools (code2llm, vallm, redup)
96+
cd external-tools && ./run.sh
5397

54-
# For various backends (optional)
55-
export GITHUB_TOKEN=your_github_token
56-
export JIRA_URL=your_jira_url
57-
export JIRA_EMAIL=your_email
58-
export JIRA_TOKEN=your_jira_token
98+
# Advanced usage (power users)
99+
cd advanced-usage && ./run.sh
59100
```
60101

61102
### 3. Run All Examples with Validation
@@ -117,6 +158,77 @@ Shows metric-driven planning using LLX:
117158
python ecosystem/04_llx_integration.py
118159
```
119160

161+
## New Examples (Integrated Functionality)
162+
163+
### ⚡ Quick Start (quick-start/)
164+
165+
Get started with planfile in minutes! This example shows the basics:
166+
- Generate strategy from files
167+
- Create templates
168+
- Load and analyze strategies
169+
- Export to different formats
170+
- Compare strategies
171+
172+
```bash
173+
cd quick-start && ./run.sh
174+
```
175+
176+
### 🚀 Integrated Functionality (integrated-functionality/)
177+
178+
Comprehensive demo of all new integrated features:
179+
- File analysis without external scripts
180+
- Template generation for different project types
181+
- Strategy comparison and merging
182+
- Multiple export formats
183+
- Statistics and health checking
184+
185+
```bash
186+
cd integrated-functionality && ./run.sh
187+
```
188+
189+
### 💻 CLI Commands (cli-commands/)
190+
191+
Shows how to use all new CLI commands:
192+
- `planfile template` - Generate templates
193+
- `planfile stats` - View statistics
194+
- `planfile export` - Export to various formats
195+
- `planfile compare` - Compare strategies
196+
- `planfile health` - Check project health
197+
- `planfile generate-from-files` - Analyze and generate
198+
199+
```bash
200+
cd cli-commands && ./run.sh
201+
```
202+
203+
### 🔧 External Tools (external-tools/)
204+
205+
Integration with external analysis tools:
206+
- code2llm - Code complexity analysis
207+
- vallm - Validation and linting
208+
- redup - Code duplication detection
209+
- Combined analysis with all tools
210+
211+
```bash
212+
# Install tools first
213+
pip install code2llm vallm redup
214+
215+
cd external-tools && ./run.sh
216+
```
217+
218+
### 🎯 Advanced Usage (advanced-usage/)
219+
220+
Advanced patterns and workflows:
221+
- Custom file patterns
222+
- Focus-specific strategies
223+
- Iterative strategy refinement
224+
- Batch processing multiple directories
225+
- Custom metrics integration
226+
- CI/CD workflow automation
227+
228+
```bash
229+
cd advanced-usage && ./run.sh
230+
```
231+
120232
## Validation with LLX
121233

122234
### Automated Validation
@@ -241,6 +353,94 @@ Each test generates:
241353

242354
## Example Generated Strategy
243355

356+
## Quick Reference
357+
358+
### New CLI Commands
359+
```bash
360+
# Generate template
361+
planfile template web ecommerce
362+
363+
# Generate from files
364+
planfile generate-from-files . --focus quality
365+
366+
# View statistics
367+
planfile stats strategy.yaml
368+
369+
# Export formats
370+
planfile export strategy.yaml --format html
371+
planfile export strategy.yaml --format csv
372+
373+
# Compare strategies
374+
planfile compare old.yaml new.yaml
375+
376+
# Health check
377+
planfile health .
378+
```
379+
380+
### Python API
381+
```python
382+
from planfile import Strategy
383+
from planfile.analysis.generator import generator
384+
385+
# Generate from analysis
386+
strategy = generator.generate_from_current_project(".")
387+
388+
# Create template
389+
from planfile.cli.extra_commands import generate_template
390+
template = generate_template("web", "ecommerce")
391+
392+
# Load and analyze
393+
s = Strategy.load("strategy.yaml")
394+
stats = s.get_stats()
395+
396+
# Compare
397+
comparison = s1.compare(s2)
398+
399+
# Export
400+
yaml_data = s.export("yaml")
401+
json_data = s.export("json")
402+
```
403+
404+
### Example Files Generated
405+
406+
Each example folder generates its own set of files:
407+
408+
**quick-start/**
409+
- `quick-start.yaml` - Basic generated strategy
410+
- `web-template.yaml` - Web project template
411+
- `web-template.json` - Template in JSON format
412+
413+
**integrated-functionality/**
414+
- `generated-from-examples.yaml` - Strategy from file analysis
415+
- `template-*.yaml` - Project templates (web, mobile, ml)
416+
- `strategy-export.*` - Various export formats
417+
- `merged-strategy.yaml` - Combined strategy
418+
419+
**cli-commands/**
420+
- `cli-example-*.yaml` - Generated strategies
421+
- `cli-example-*.json` - JSON exports
422+
- `cli-example.html` - HTML report
423+
424+
**external-tools/**
425+
- `*.toon.yaml` - External tool outputs (if tools installed)
426+
- `external-tools-generated.yaml` - Strategy from external analysis
427+
- `quality-focused.yaml` - Quality-focused strategy
428+
429+
**advanced-usage/**
430+
- `custom-patterns-strategy.yaml` - Custom analysis strategy
431+
- `focus-*-strategy.yaml` - Focus-specific strategies
432+
- `iterative-*.yaml` - Strategy versions
433+
- `batch-*-strategy.yaml` - Batch processing results
434+
- `ci-workflow.sh` - Generated CI/CD script
435+
436+
## Tips
437+
1. Start with `cd quick-start && ./run.sh` for basics
438+
2. Use `cd integrated-functionality && ./run.sh` for complete overview
439+
3. Install external tools for deeper analysis: `pip install code2llm vallm redup`
440+
4. Each example has its own README with detailed information
441+
5. Check generated YAML files to understand structure
442+
6. Use `./run.sh` in each folder for easy execution
443+
244444
```yaml
245445
project:
246446
name: "my-project"

0 commit comments

Comments
 (0)