Skip to content

Commit 297259d

Browse files
authored
Merge pull request #2 from lizy-coding/develop
CLI project done
2 parents 79b5798 + 2b4ae76 commit 297259d

68 files changed

Lines changed: 1598 additions & 955 deletions

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ build/
1010

1111
# CLI
1212
.flutterguard/
13+
flutterguard
1314

1415
# IDE
1516
.idea/*/

.idea/modules.xml

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

.idea/runConfigurations/melos_flutter_test_flutterguard_flutter.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.idea/runConfigurations/melos_run_test_core.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.idea/runConfigurations/melos_run_test_dio.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

AGENTS.md

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,44 @@
44
IoT/smart home Flutter project static analysis CLI plugin. NOT an observability SDK or APM tool.
55

66
## Architecture
7-
- **Monorepo**: melos, 4 packages + 2 examples
7+
- **Monorepo**: melos, 1 package + 1 example
88
- **Path A (ACTIVE)**: `flutterguard_cli` — all new features
9-
- **Path B (FROZEN)**: `flutterguard_core`, `flutterguard_dio`, `flutterguard_flutter`bug fixes only
9+
- **Path B (ARCHIVED)**: `flutterguard_core`, `flutterguard_dio`, `flutterguard_flutter`in `archive/` for future reference
1010

1111
## Package Hierarchy
1212
| Package | Status | Depends On | Depended By |
1313
|---------|--------|------------|-------------|
14-
| flutterguard_cli | ACTIVE | core, args, analyzer, glob, path, yaml ||
15-
| flutterguard_core | FROZEN | meta | cli, dio, flutter |
16-
| flutterguard_dio | FROZEN | core, dio ^5.7.0 ||
17-
| flutterguard_flutter | FROZEN | core, flutter SDK ||
14+
| flutterguard_cli | ACTIVE | args, analyzer, glob, path, yaml ||
1815
| scan_demo || (none, scan target) ||
19-
| usage_demo || core ||
20-
21-
## Override Chain
22-
1. **pubspec_overrides.yaml** — melos auto-managed; 4 packages override `flutterguard_core` to local path
23-
2. **analysis_options.yaml** — root strict-casts/strict-inference → per-package overrides (cli: +lints/recommended + fixture exclude)
24-
3. **flutterguard.yaml** — root default config → user project overrides on scan
2516

2617
## Key Commands
2718
| Command | Purpose |
2819
|---------|---------|
29-
| `melos bootstrap` | Install + generate pubspec_overrides |
30-
| `melos run analyze` | dart analyze on all packages |
31-
| `melos run format` | dart format on all packages |
32-
| `melos run test` | Test all flutterguard_* packages |
33-
| `melos run test:cli` | CLI tests only |
20+
| `dart run melos bootstrap` | Install workspace dependencies |
21+
| `dart run melos run analyze` | dart analyze on all packages |
22+
| `dart run melos run test:cli` | CLI tests only |
3423
| `dart run flutterguard scan -p <path>` | Run scan on a project |
3524

3625
## CLI Entry Point
3726
`packages/flutterguard_cli/bin/flutterguard.dart`
3827

39-
Wired rules (3): LargeUnitsRule, LifecycleResourceRule, BoundaryImportRule
28+
Wired rules (5): LargeUnitsRule, LifecycleResourceRule, LayerViolationRule, ModuleViolationRule, CircularDependencyRule
4029

4130
## Source Layout
4231
```
4332
packages/flutterguard_cli/lib/src/
44-
config_loader.dart # YAML → ScanConfig
33+
config_loader.dart # YAML → ScanConfig (incl architecture.layers/modules)
4534
file_collector.dart # Glob file discovery
46-
static_issue.dart # StaticIssue + RiskLevel
47-
report_generator.dart # JSON/MD output + score
35+
static_issue.dart # StaticIssue + RiskLevel + IssueDomain + Priority
36+
report_generator.dart # Table + JSON output + score
37+
domain.dart # IssueDomain enum (architecture/performance/standards)
38+
priority.dart # Priority enum (p0/p1/p2)
4839
rules/
4940
large_units.dart # large_file, large_class, large_build_method
5041
lifecycle_resource.dart # lifecycle_resource_not_disposed
51-
boundary_import.dart # boundary_import_violation
42+
layer_violation.dart # layer_violation (architecture layer breaches)
43+
module_violation.dart # module_violation (cross-module breaches)
44+
circular_dependency.dart # circular_dependency (file-level cycles)
5245
```
5346

5447
## Spec
@@ -57,5 +50,7 @@ Single source of truth: `docs/FLUTTERGUARD_SPEC.md` — read before implementing
5750
## Maintenance Rules
5851
1. New rule: spec entry → config typedef → rule class → fixture → test → wire into bin/flutterguard.dart
5952
2. Always run `melos run analyze` + `melos run test:cli` before committing
60-
3. Do NOT modify frozen packages (core/dio/flutter) except for critical bug fixes
53+
3. Do NOT modify archived packages (core/dio/flutter) — they are frozen references
6154
4. Do NOT add Flutter widgets, web/cloud infra, or SaaS SDKs
55+
5. Output format defaults to `table`. JSON available via `--format=json`
56+
6. Architecture rules require explicit `architecture.layers` / `architecture.modules` in flutterguard.yaml

CHANGELOG.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@
22

33
## 0.1.0 (2026-05-17)
44

5-
### Initial Release
5+
### Initial Release — CLI Static Analysis
66

7-
- **cli:** Initial CLI scan command with 3 rules (large_units, lifecycle_resource, boundary_import)
8-
- **cli:** YAML-driven config with include/exclude patterns and rule thresholds
9-
- **cli:** JSON and Markdown report generation with score calculation
10-
- **cli:** CI gate integration with fail-on threshold and min-score support
11-
- **core:** Flow-level aspect tracing engine with Zone-based context propagation
12-
- **core:** Ring buffer trace store (100 trace default)
13-
- **core:** JSON and Markdown export for flow traces
14-
- **dio:** Dio 5.x interceptor for HTTP request tracing within flows
15-
- **flutter:** Flutter runtime integration with error hooks, route observer, and frame metrics
16-
- **flutter:** GuardBoundary widget for rebuild count tracking
17-
- **docs:** Comprehensive FLUTTERGUARD_SPEC.md with full contract, test matrices, and IoT rules
18-
- **docs:** Dual-language README (en/zh) with installation, API reference, and CI integration guide
19-
- **docs:** Agent-readable project rules (CONTEXT.md, PROJECT_RULES.md, AGENTS.md)
20-
- **docs:** ARCHITECTURE.md with dependency graph and override chain documentation
7+
- **cli:** 6 static analysis rules: large_file, large_class, large_build_method, lifecycle_resource_not_disposed (IoT-aware), layer_violation, module_violation, circular_dependency, missing_const_constructor
8+
- **cli:** YAML-driven config with include/exclude patterns, rule thresholds, and architecture layers/modules
9+
- **cli:** Table (terminal) and JSON output formats with domain-grouped reporting
10+
- **cli:** CI gate integration with --fail-on threshold and --min-score support
11+
- **cli:** Architecture layer/module enforcement with configurable enabled/disabled
12+
- **cli:** Config key validation (warns on unknown YAML keys)
13+
- **cli:** --version and comprehensive --help output
14+
- **cli:** Native binary compilation (dart compile exe)
15+
- **docs:** FLUTTERGUARD_SPEC.md with full rule contracts, config schema, and output spec
16+
- **docs:** ARCHITECTURE.md, AGENTS.md, PROJECT_RULES.md with dependency graph and override chains
2117
- **meta:** melos monorepo setup with 4 packages + 2 examples
2218
- **meta:** MIT license
2319

PROJECT_RULES.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
- NOT a general observability SDK, APM tool, or crash reporter.
66
- Output: compiled CLI binary (`dart compile exe`) that scans Dart source code.
77

8-
## 2. Active vs Frozen
8+
## 2. Active vs Archived
99

1010
| Path | Status | Package | Notes |
1111
|------|--------|---------|-------|
1212
| **Path A** — CLI static analysis | **ACTIVE** | `flutterguard_cli` | All new features |
13-
| **Path B** — Runtime tracing | **FROZEN** | `core`, `dio`, `flutter` | Bug fixes only |
13+
| **Path B** — Runtime tracing | **ARCHIVED** | `core`, `dio`, `flutter` | In `archive/` for future reference |
1414

15-
Do NOT modify frozen packages except for critical bug fixes. Do NOT add new features to them.
15+
Do NOT modify archived packages. They are preserved as-is for reference.
1616

1717
## 3. Architecture Constraints
1818
- Monorepo managed by **melos**. New packages must register in `melos.yaml`.
@@ -44,7 +44,7 @@ Do NOT modify frozen packages except for critical bug fixes. Do NOT add new feat
4444
- Do NOT add web/cloud infrastructure or dashboard UI.
4545
- Do NOT use third-party SaaS SDKs.
4646
- Do NOT commit secrets, API keys, or credentials.
47-
- Do NOT add runtime instrumentation outside frozen packages.
47+
- Do NOT add runtime instrumentation outside archived packages.
4848
- Do NOT introduce `package:build` / code generation dependencies.
4949

5050
## 8. Git Workflow
@@ -56,22 +56,14 @@ Do NOT modify frozen packages except for critical bug fixes. Do NOT add new feat
5656
## 9. Override Hierarchy
5757

5858
### 9.1 pubspec_overrides.yaml
59-
Managed by `melos bootstrap`. 4 packages override `flutterguard_core` to local path:
60-
61-
| Package | Override | Managed By |
62-
|---------|----------|------------|
63-
| `flutterguard_cli/pubspec_overrides.yaml` | `flutterguard_core``../flutterguard_core` | melos |
64-
| `flutterguard_dio/pubspec_overrides.yaml` | `flutterguard_core``../flutterguard_core` | melos |
65-
| `flutterguard_flutter/pubspec_overrides.yaml` | `flutterguard_core``../flutterguard_core` | melos |
66-
| `usage_demo/pubspec_overrides.yaml` | `flutterguard_core``../../packages/flutterguard_core` | melos |
59+
Managed by `melos bootstrap`. No path dependencies currently exist for `flutterguard_cli`.
6760

6861
**Rule**: Do NOT edit manually. Re-run `melos bootstrap` after any pubspec.yaml change.
6962

7063
### 9.2 analysis_options.yaml Inheritance Chain
7164
```
7265
root/analysis_options.yaml # strict-casts + strict-inference + 6 lint rules
73-
├── packages/flutterguard_cli/... # inherits root + package:lints/recommended + excludes test/fixtures/**
74-
├── examples/usage_demo/... # inherits root + excludes avoid_print
66+
└── packages/flutterguard_cli/... # inherits root + package:lints/recommended + excludes test/fixtures/**
7567
```
7668

7769
**Rule**: Keep corporate-wide strictness at root. Per-package loosening only for legitimate reasons (fixture code, print-based demos).

0 commit comments

Comments
 (0)