Skip to content

Commit 8e50fd7

Browse files
montfortclaude
andcommitted
feat: implement analyze command with arborist-metrics integration
Add `devtrail analyze [path]` for code complexity analysis using the arborist-metrics crate. Supports cognitive + cyclomatic metrics with --threshold, --output (text/json/markdown), and --top flags. Includes 10 integration tests and config.yml extension for threshold settings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b7cbf0f commit 8e50fd7

16 files changed

Lines changed: 1117 additions & 6 deletions

File tree

CLAUDE.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ devtrail/
1212
├── cli/ # Rust CLI source code
1313
│ ├── src/
1414
│ │ ├── main.rs # Entry point, command routing
15-
│ │ ├── commands/ # Subcommands: init, update, remove, status, repair, validate, compliance, metrics, audit, explore, about
15+
│ │ ├── commands/ # Subcommands: init, update, remove, status, repair, validate, compliance, metrics, analyze, audit, explore, about
1616
│ │ ├── tui/ # Terminal UI for `explore` (ratatui + crossterm)
17-
│ │ ├── config.rs # DevTrailConfig, Checksums
17+
│ │ ├── analysis_engine.rs # Code complexity analysis (arborist-metrics)
18+
│ │ ├── config.rs # DevTrailConfig, Checksums, ComplexityConfig
1819
│ │ ├── download.rs # GitHub API, ZIP downloads
1920
│ │ ├── inject.rs # Directive injection system
2021
│ │ ├── manifest.rs # dist-manifest.yml parser
@@ -178,6 +179,7 @@ Users can now run `devtrail update-framework` to get the new version.
178179
| `devtrail validate [path]` | Validate documents for compliance and correctness |
179180
| `devtrail compliance [path]` | Check regulatory compliance (EU AI Act, ISO 42001, NIST) |
180181
| `devtrail metrics [path]` | Show governance metrics and documentation statistics |
182+
| `devtrail analyze [path]` | Analyze code complexity (cognitive + cyclomatic metrics) |
181183
| `devtrail audit [path]` | Generate audit trail reports with timeline and traceability |
182184
| `devtrail explore [path]` | Interactive TUI documentation browser |
183185
| `devtrail about` | Show version and license info |
@@ -196,7 +198,7 @@ cargo build --no-default-features # Without TUI
196198
### Test
197199

198200
```bash
199-
cargo test # All 95 tests
201+
cargo test # All 111 tests
200202
```
201203

202204
### Feature Flags

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Built-in CLI tools for governance:
103103
- **`devtrail validate`** — 13 validation rules for document correctness
104104
- **`devtrail compliance`** — Regulatory compliance scoring (EU AI Act, ISO 42001, NIST AI RMF)
105105
- **`devtrail metrics`** — Governance KPIs, review rates, risk distribution, trends
106+
- **`devtrail analyze`** — Code complexity analysis (cognitive + cyclomatic) via arborist-metrics
106107
- **`devtrail audit`** — Audit trail reports with timeline, traceability maps, and HTML export
107108
- **Pre-commit hooks** + **GitHub Actions** for CI/CD validation
108109

@@ -164,6 +165,7 @@ Check installed versions with `devtrail status` or `devtrail about`.
164165
| `devtrail validate [path]` | Validate documents for compliance and correctness |
165166
| `devtrail compliance [path]` | Check regulatory compliance (EU AI Act, ISO 42001, NIST) |
166167
| `devtrail metrics [path]` | Show governance metrics and documentation statistics |
168+
| `devtrail analyze [path]` | Analyze code complexity (cognitive + cyclomatic metrics) |
167169
| `devtrail audit [path]` | Generate audit trail reports with timeline and traceability |
168170
| `devtrail explore [path]` | Browse documentation interactively in a TUI |
169171
| `devtrail about` | Show version and license info |

cli/Cargo.lock

Lines changed: 104 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ tar = "0.4"
3535
ratatui = { version = "0.29", optional = true, default-features = false, features = ["crossterm"] }
3636
crossterm = { version = "0.28", optional = true }
3737
pulldown-cmark = { version = "0.12", optional = true }
38+
arborist-metrics = { version = "0.1", optional = true }
3839

3940
[features]
40-
default = ["tui"]
41+
default = ["tui", "analyze"]
4142
tui = ["ratatui", "crossterm", "pulldown-cmark"]
43+
analyze = ["arborist-metrics"]
4244

4345
[dev-dependencies]
4446
assert_cmd = "2"

0 commit comments

Comments
 (0)