dart-decimate 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/Cargo.lock +572 -0
  2. package/Cargo.toml +41 -0
  3. package/LICENSE +21 -0
  4. package/README.md +617 -0
  5. package/assets/dart-decimate-banner.png +0 -0
  6. package/npm/bin/dart-decimate-mcp.js +48 -0
  7. package/npm/bin/dart-decimate.js +48 -0
  8. package/npm/scripts/postinstall.js +46 -0
  9. package/npm/scripts/test-npx-local.js +54 -0
  10. package/npm/scripts/test-npx-mcp-local.js +56 -0
  11. package/package.json +45 -0
  12. package/src/baseline.rs +643 -0
  13. package/src/bin/dart-decimate-mcp.rs +11 -0
  14. package/src/boundaries/tests.rs +60 -0
  15. package/src/boundaries.rs +317 -0
  16. package/src/changed_scope.rs +117 -0
  17. package/src/ci_template.rs +399 -0
  18. package/src/cli/analyze.rs +462 -0
  19. package/src/cli/analyzer_options.rs +82 -0
  20. package/src/cli/audit_run.rs +327 -0
  21. package/src/cli/boundary_args.rs +44 -0
  22. package/src/cli/ci_template_run.rs +196 -0
  23. package/src/cli/command_name.rs +20 -0
  24. package/src/cli/common_args.rs +167 -0
  25. package/src/cli/config_run.rs +78 -0
  26. package/src/cli/coverage_run.rs +393 -0
  27. package/src/cli/decision_surface_run.rs +99 -0
  28. package/src/cli/default_command.rs +69 -0
  29. package/src/cli/dupes_args.rs +150 -0
  30. package/src/cli/entry_points.rs +121 -0
  31. package/src/cli/error.rs +149 -0
  32. package/src/cli/error_output.rs +68 -0
  33. package/src/cli/explain_run.rs +72 -0
  34. package/src/cli/fix_run.rs +162 -0
  35. package/src/cli/flags_args.rs +23 -0
  36. package/src/cli/health_args.rs +200 -0
  37. package/src/cli/hooks_run.rs +191 -0
  38. package/src/cli/impact_run.rs +95 -0
  39. package/src/cli/init_run.rs +49 -0
  40. package/src/cli/inspect_args.rs +20 -0
  41. package/src/cli/inspect_run.rs +66 -0
  42. package/src/cli/issue_filter_args.rs +240 -0
  43. package/src/cli/list_run.rs +311 -0
  44. package/src/cli/mode_args.rs +72 -0
  45. package/src/cli/output_format.rs +62 -0
  46. package/src/cli/regression_args.rs +156 -0
  47. package/src/cli/request_args.rs +175 -0
  48. package/src/cli/schema_commands.rs +72 -0
  49. package/src/cli/scope_args.rs +174 -0
  50. package/src/cli/security_args.rs +175 -0
  51. package/src/cli/security_gate_run.rs +66 -0
  52. package/src/cli/security_summary_run.rs +43 -0
  53. package/src/cli/summary_args.rs +12 -0
  54. package/src/cli/tests.rs +516 -0
  55. package/src/cli/trace_args.rs +67 -0
  56. package/src/cli/trace_run.rs +131 -0
  57. package/src/cli/trace_tests.rs +235 -0
  58. package/src/cli/unsupported_run.rs +116 -0
  59. package/src/cli/watch_run.rs +153 -0
  60. package/src/cli.rs +603 -0
  61. package/src/config/boundary_config.rs +235 -0
  62. package/src/config/cache.rs +25 -0
  63. package/src/config/dependencies.rs +114 -0
  64. package/src/config/health.rs +237 -0
  65. package/src/config/jsonc.rs +66 -0
  66. package/src/config/policy.rs +91 -0
  67. package/src/config/rule_aliases.rs +487 -0
  68. package/src/config/rules.rs +339 -0
  69. package/src/config.rs +635 -0
  70. package/src/coverage.rs +469 -0
  71. package/src/dart_parser.rs +673 -0
  72. package/src/decision_surface.rs +405 -0
  73. package/src/dependencies/analyze.rs +218 -0
  74. package/src/dependencies/codegen.rs +118 -0
  75. package/src/dependencies/discovery.rs +60 -0
  76. package/src/dependencies/overrides.rs +76 -0
  77. package/src/dependencies/private_src_imports.rs +32 -0
  78. package/src/dependencies/pubspec_document.rs +86 -0
  79. package/src/dependencies/pubspec_entry.rs +96 -0
  80. package/src/dependencies/tests.rs +544 -0
  81. package/src/dependencies/usage.rs +33 -0
  82. package/src/dependencies.rs +553 -0
  83. package/src/dependency_scripts.rs +91 -0
  84. package/src/dupes/lex.rs +236 -0
  85. package/src/dupes/tests.rs +119 -0
  86. package/src/dupes.rs +625 -0
  87. package/src/explain.rs +692 -0
  88. package/src/extract/directives.rs +252 -0
  89. package/src/extract/error_tests.rs +25 -0
  90. package/src/extract/members.rs +210 -0
  91. package/src/extract/primary_constructors.rs +421 -0
  92. package/src/extract/references.rs +151 -0
  93. package/src/extract/routes.rs +691 -0
  94. package/src/extract/signatures.rs +266 -0
  95. package/src/extract/string_tests.rs +18 -0
  96. package/src/extract/strings.rs +107 -0
  97. package/src/extract/tests.rs +697 -0
  98. package/src/extract.rs +680 -0
  99. package/src/feature_flags/tests.rs +76 -0
  100. package/src/feature_flags.rs +453 -0
  101. package/src/finding_identity.rs +60 -0
  102. package/src/fix.rs +551 -0
  103. package/src/generated.rs +53 -0
  104. package/src/graph/augment_tests.rs +212 -0
  105. package/src/graph/conditionals.rs +74 -0
  106. package/src/graph/package_config_tests.rs +100 -0
  107. package/src/graph/parts.rs +248 -0
  108. package/src/graph/pubspec_tests.rs +119 -0
  109. package/src/graph/tests.rs +837 -0
  110. package/src/graph/uri_tests.rs +102 -0
  111. package/src/graph.rs +644 -0
  112. package/src/health/coverage.rs +309 -0
  113. package/src/health/ownership.rs +175 -0
  114. package/src/health/runtime_coverage.rs +616 -0
  115. package/src/health/runtime_intelligence.rs +511 -0
  116. package/src/health/scores.rs +296 -0
  117. package/src/health/tests.rs +240 -0
  118. package/src/health/threshold_types.rs +163 -0
  119. package/src/health/thresholds.rs +229 -0
  120. package/src/health/types.rs +636 -0
  121. package/src/health.rs +597 -0
  122. package/src/hooks/agent_settings.rs +175 -0
  123. package/src/hooks/templates.rs +51 -0
  124. package/src/hooks.rs +569 -0
  125. package/src/impact.rs +287 -0
  126. package/src/init.rs +237 -0
  127. package/src/inspect.rs +142 -0
  128. package/src/intelligence/tests.rs +232 -0
  129. package/src/intelligence.rs +305 -0
  130. package/src/lib.rs +198 -0
  131. package/src/main.rs +5 -0
  132. package/src/manifest/mcp.rs +565 -0
  133. package/src/manifest.rs +552 -0
  134. package/src/mcp/cli_args/value_args.rs +175 -0
  135. package/src/mcp/cli_args.rs +658 -0
  136. package/src/mcp/cli_args_tests.rs +522 -0
  137. package/src/mcp/code_execute.rs +671 -0
  138. package/src/mcp/tools.rs +660 -0
  139. package/src/mcp.rs +325 -0
  140. package/src/output/audit_risk.rs +135 -0
  141. package/src/output/dependency_findings.rs +327 -0
  142. package/src/output/duplication_findings.rs +114 -0
  143. package/src/output/feature_flag_findings.rs +122 -0
  144. package/src/output/format.rs +31 -0
  145. package/src/output/graph_findings.rs +461 -0
  146. package/src/output/health_findings.rs +612 -0
  147. package/src/output/human.rs +27 -0
  148. package/src/output/next_steps.rs +92 -0
  149. package/src/output/route_findings.rs +76 -0
  150. package/src/output/runtime_coverage.rs +515 -0
  151. package/src/output/scope.rs +183 -0
  152. package/src/output/security_findings.rs +390 -0
  153. package/src/output/security_sarif.rs +150 -0
  154. package/src/output/suppressions.rs +323 -0
  155. package/src/output/symbol_findings.rs +257 -0
  156. package/src/output/tests.rs +114 -0
  157. package/src/output/types.rs +604 -0
  158. package/src/output/widget_findings.rs +213 -0
  159. package/src/output.rs +682 -0
  160. package/src/package_map.rs +495 -0
  161. package/src/policy/packs.rs +232 -0
  162. package/src/policy/tests.rs +134 -0
  163. package/src/policy.rs +640 -0
  164. package/src/project_list.rs +376 -0
  165. package/src/report_schema/inventory.rs +418 -0
  166. package/src/report_schema.rs +488 -0
  167. package/src/routes.rs +354 -0
  168. package/src/scan/tests.rs +250 -0
  169. package/src/scan.rs +275 -0
  170. package/src/security/detect.rs +639 -0
  171. package/src/security/tests.rs +178 -0
  172. package/src/security.rs +373 -0
  173. package/src/security_gate.rs +555 -0
  174. package/src/symbols/path_filters.rs +27 -0
  175. package/src/symbols/private_type_leaks.rs +125 -0
  176. package/src/symbols/riverpod.rs +113 -0
  177. package/src/symbols/tests.rs +692 -0
  178. package/src/symbols.rs +693 -0
  179. package/src/trace/tests.rs +225 -0
  180. package/src/trace.rs +690 -0
  181. package/src/unsupported.rs +47 -0
  182. package/src/widgets/lifecycle.rs +484 -0
  183. package/src/widgets/params.rs +236 -0
  184. package/src/widgets/tests.rs +430 -0
  185. package/src/widgets/top_level.rs +110 -0
  186. package/src/widgets/unrendered.rs +374 -0
  187. package/src/widgets.rs +590 -0
  188. package/src/workspace_scope.rs +358 -0
@@ -0,0 +1,552 @@
1
+ use serde_json::{Value, json};
2
+
3
+ use crate::ci_template::{CI_RECONCILE_REVIEW_SCHEMA_VERSION, CI_TEMPLATE_SCHEMA_VERSION};
4
+ use crate::config::CONFIG_SCHEMA_VERSION;
5
+ use crate::coverage::COVERAGE_ANALYSIS_SCHEMA_VERSION;
6
+ use crate::decision_surface::DECISION_SURFACE_SCHEMA_VERSION;
7
+ use crate::explain::EXPLAIN_SCHEMA_VERSION;
8
+ use crate::fix::FIX_SCHEMA_VERSION;
9
+ use crate::hooks::HOOKS_SCHEMA_VERSION;
10
+ use crate::impact::IMPACT_SCHEMA_VERSION;
11
+ use crate::init::INIT_SCHEMA_VERSION;
12
+ use crate::inspect::INSPECT_SCHEMA_VERSION;
13
+ use crate::output::{SCHEMA_VERSION, TRACE_SCHEMA_VERSION};
14
+ use crate::policy::RULE_PACK_SCHEMA_VERSION;
15
+ use crate::project_list::PROJECT_LIST_SCHEMA_VERSION;
16
+ use crate::unsupported::UNSUPPORTED_SCHEMA_VERSION;
17
+
18
+ mod mcp;
19
+ use mcp::mcp_tools;
20
+
21
+ /// Stable schema version for the agent capability manifest.
22
+ pub const MANIFEST_SCHEMA_VERSION: &str = "dart-decimate.schema.v1";
23
+
24
+ /// Return Dart Decimate's machine-readable CLI and issue manifest.
25
+ #[must_use]
26
+ pub fn dart_decimate_schema() -> Value {
27
+ json!({
28
+ "schema_version": MANIFEST_SCHEMA_VERSION,
29
+ "kind": "schema",
30
+ "tool": "dart-decimate",
31
+ "name": "Dart Decimate",
32
+ "description": "Rust-native Dart and Flutter module-graph intelligence.",
33
+ "manifest_version": MANIFEST_SCHEMA_VERSION,
34
+ "version": env!("CARGO_PKG_VERSION"),
35
+ "default_command": "check",
36
+ "default_behavior": "Bare dart-decimate invocations default to dart-decimate check against the provided root.",
37
+ "global_flags": ["--root", "--format", "--config", "--quiet"],
38
+ "output_formats": ["human", "json", "sarif"],
39
+ "plugins": plugins(),
40
+ "environment_variables": environment_variables(),
41
+ "mcp_tools": mcp_tools(),
42
+ "exit_codes": [
43
+ { "code": 0, "meaning": "success or no error-severity findings" },
44
+ { "code": 1, "meaning": "error-severity findings or skipped apply fixes" },
45
+ { "code": 2, "meaning": "runtime or configuration error" },
46
+ { "code": 3, "meaning": "config discovery miss for config --path" }
47
+ ],
48
+ "severity_levels": ["error", "warning"],
49
+ "suppression_comments": {
50
+ "next_line": "// dart-decimate-ignore-next-line <issue-type>",
51
+ "file": "// dart-decimate-ignore-file <issue-type>"
52
+ },
53
+ "schemas": {
54
+ "report": SCHEMA_VERSION,
55
+ "trace": TRACE_SCHEMA_VERSION,
56
+ "inspect": INSPECT_SCHEMA_VERSION,
57
+ "list": PROJECT_LIST_SCHEMA_VERSION,
58
+ "fix": FIX_SCHEMA_VERSION,
59
+ "explain": EXPLAIN_SCHEMA_VERSION,
60
+ "impact": IMPACT_SCHEMA_VERSION,
61
+ "init": INIT_SCHEMA_VERSION,
62
+ "hooks": HOOKS_SCHEMA_VERSION,
63
+ "ci_reconcile_review": CI_RECONCILE_REVIEW_SCHEMA_VERSION,
64
+ "ci_template": CI_TEMPLATE_SCHEMA_VERSION,
65
+ "config": CONFIG_SCHEMA_VERSION,
66
+ "coverage": COVERAGE_ANALYSIS_SCHEMA_VERSION,
67
+ "decision_surface": DECISION_SURFACE_SCHEMA_VERSION,
68
+ "unsupported": UNSUPPORTED_SCHEMA_VERSION,
69
+ "rule_pack": RULE_PACK_SCHEMA_VERSION
70
+ },
71
+ "commands": commands(),
72
+ "issue_types": issue_types(),
73
+ "task_matrix": task_matrix()
74
+ })
75
+ }
76
+
77
+ fn plugins() -> Value {
78
+ json!([
79
+ {
80
+ "name": "dart",
81
+ "kind": "language",
82
+ "description": "Parses Dart imports, exports, parts, augmentations, declarations, and references."
83
+ },
84
+ {
85
+ "name": "flutter",
86
+ "kind": "framework",
87
+ "description": "Adds Flutter widget, lifecycle, route, and security candidate checks."
88
+ },
89
+ {
90
+ "name": "pub-workspace",
91
+ "kind": "workspace",
92
+ "description": "Resolves pubspec packages, path dependencies, package_config.json, and Dart workspaces."
93
+ }
94
+ ])
95
+ }
96
+
97
+ fn environment_variables() -> Value {
98
+ json!([
99
+ {
100
+ "name": "DART_DECIMATE_BASE",
101
+ "scope": "generated-git-hook",
102
+ "description": "Overrides the base ref used by Dart Decimate-managed Git pre-commit hooks."
103
+ }
104
+ ])
105
+ }
106
+
107
+ fn commands() -> Value {
108
+ let mut commands = Vec::new();
109
+ append_commands(&mut commands, analysis_commands());
110
+ append_commands(&mut commands, coverage_commands());
111
+ append_commands(&mut commands, evidence_commands());
112
+ append_commands(&mut commands, support_commands());
113
+ Value::Array(commands)
114
+ }
115
+
116
+ fn append_commands(commands: &mut Vec<Value>, values: Value) {
117
+ if let Value::Array(values) = values {
118
+ commands.extend(values);
119
+ }
120
+ }
121
+
122
+ fn analysis_commands() -> Value {
123
+ json!([
124
+ {
125
+ "name": "check",
126
+ "kind": "combined",
127
+ "description": "Run all enabled graph, symbol, dependency, duplicate, health, flag, and security checks.",
128
+ "schema": SCHEMA_VERSION,
129
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--circular-deps", "--re-export-cycles", "--boundary-violations", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
130
+ },
131
+ {
132
+ "name": "audit",
133
+ "kind": "audit",
134
+ "description": "Run changed-code graph checks scoped from a Git base ref.",
135
+ "schema": SCHEMA_VERSION,
136
+ "flags": ["--root", "--brief", "--base", "--gate", "--dead-code-baseline", "--health-baseline", "--dupes-baseline", "--max-decisions", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--boundary", "--boundary-coverage", "--boundary-call", "--policy-pack", "--policy-violations", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--include-entry-exports", "--private-type-leaks"]
137
+ },
138
+ {
139
+ "name": "review",
140
+ "kind": "decision-surface",
141
+ "description": "Review changed-code structural decisions without failing CI.",
142
+ "schema": DECISION_SURFACE_SCHEMA_VERSION,
143
+ "flags": ["--root", "--base", "--format", "--config", "--max-decisions"]
144
+ },
145
+ {
146
+ "name": "decision-surface",
147
+ "kind": "decision-surface",
148
+ "description": "Surface changed-code structural decisions for reviewer judgment.",
149
+ "schema": DECISION_SURFACE_SCHEMA_VERSION,
150
+ "flags": ["--root", "--base", "--format", "--config", "--max-decisions"]
151
+ },
152
+ {
153
+ "name": "dead-code",
154
+ "kind": "dead-code",
155
+ "description": "Find unreachable Dart files and conservative symbol-level dead code.",
156
+ "schema": SCHEMA_VERSION,
157
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--include-entry-exports", "--private-type-leaks", "--unused-files", "--unused-exports", "--unused-types", "--unused-deps", "--unlisted-deps", "--private-src-imports", "--duplicate-exports", "--unused-enum-members", "--unused-class-members", "--unresolved-imports", "--stale-suppressions", "--unused-dependency-overrides", "--misconfigured-dependency-overrides"]
158
+ },
159
+ {
160
+ "name": "cycles",
161
+ "kind": "cycles",
162
+ "description": "Find import/export/part/augment dependency cycles.",
163
+ "schema": SCHEMA_VERSION,
164
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline"]
165
+ },
166
+ {
167
+ "name": "dupes",
168
+ "kind": "dupes",
169
+ "description": "Find duplicated Dart code blocks.",
170
+ "schema": SCHEMA_VERSION,
171
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports"]
172
+ },
173
+ {
174
+ "name": "health",
175
+ "kind": "health",
176
+ "description": "Find complex functions, coverage gaps, hotspots, and refactoring targets.",
177
+ "schema": SCHEMA_VERSION,
178
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--max-cyclomatic", "--max-cognitive", "--complexity-breakdown", "--coverage", "--coverage-gaps", "--max-crap", "--runtime-coverage", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--file-scores", "--hotspots", "--targets", "--ownership", "--min-score", "--top"]
179
+ },
180
+ {
181
+ "name": "flags",
182
+ "kind": "flags",
183
+ "description": "Inventory Dart and Flutter feature flag patterns.",
184
+ "schema": SCHEMA_VERSION,
185
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top"]
186
+ },
187
+ {
188
+ "name": "security",
189
+ "kind": "security",
190
+ "description": "Surface local deterministic security review candidates.",
191
+ "schema": SCHEMA_VERSION,
192
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--regression-baseline", "--save-regression-baseline", "--fail-on-regression", "--tolerance", "--baseline", "--save-baseline", "--top", "--surface", "--sarif-file", "--ci", "--fail-on-issues", "--summary", "--gate", "--diff-file", "--diff-stdin", "--changed-since"]
193
+ },
194
+ {
195
+ "name": "impact",
196
+ "kind": "impact",
197
+ "description": "Read the local Dart Decimate value report without running analysis.",
198
+ "schema": IMPACT_SCHEMA_VERSION,
199
+ "flags": ["--root", "--format", "--quiet", "--all", "--sort", "--limit"]
200
+ }
201
+ ])
202
+ }
203
+
204
+ fn coverage_commands() -> Value {
205
+ json!([
206
+ {
207
+ "name": "coverage setup",
208
+ "kind": "coverage-setup",
209
+ "description": "Plan or write local Dart/Flutter runtime coverage defaults.",
210
+ "schema": COVERAGE_ANALYSIS_SCHEMA_VERSION,
211
+ "flags": ["--root", "--format", "--config", "--yes", "--non-interactive"]
212
+ },
213
+ {
214
+ "name": "coverage analyze",
215
+ "kind": "runtime-coverage",
216
+ "description": "Analyze local V8 or Istanbul runtime coverage.",
217
+ "schema": COVERAGE_ANALYSIS_SCHEMA_VERSION,
218
+ "flags": ["--root", "--format", "--config", "--runtime-coverage", "--cloud", "--repo", "--min-invocations-hot", "--min-observation-volume", "--low-traffic-threshold", "--top"]
219
+ },
220
+ {
221
+ "name": "coverage upload-inventory",
222
+ "kind": "coverage-upload-inventory",
223
+ "description": "Build a local Dart source inventory upload dry-run packet.",
224
+ "schema": COVERAGE_ANALYSIS_SCHEMA_VERSION,
225
+ "flags": ["--root", "--format", "--config", "--repo", "--dry-run"]
226
+ },
227
+ {
228
+ "name": "coverage upload-source-maps",
229
+ "kind": "coverage-upload-source-maps",
230
+ "description": "Build a source-map upload dry-run packet.",
231
+ "schema": COVERAGE_ANALYSIS_SCHEMA_VERSION,
232
+ "flags": ["--root", "--format", "--config", "--dir", "--git-sha", "--repo", "--strip-path", "--dry-run"]
233
+ }
234
+ ])
235
+ }
236
+
237
+ fn evidence_commands() -> Value {
238
+ json!([
239
+ {
240
+ "name": "inspect",
241
+ "kind": "inspect",
242
+ "description": "Compose one evidence bundle for a Dart file or top-level symbol.",
243
+ "schema": INSPECT_SCHEMA_VERSION,
244
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--symbol"]
245
+ },
246
+ {
247
+ "name": "trace-file",
248
+ "kind": "trace-file",
249
+ "description": "Trace one Dart file's graph evidence.",
250
+ "schema": TRACE_SCHEMA_VERSION,
251
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file"]
252
+ },
253
+ {
254
+ "name": "trace",
255
+ "kind": "trace-symbol",
256
+ "description": "Trace one top-level symbol's declaration, references, and re-export chains.",
257
+ "schema": TRACE_SCHEMA_VERSION,
258
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production"]
259
+ },
260
+ {
261
+ "name": "trace-symbol",
262
+ "kind": "trace-symbol",
263
+ "description": "Trace one top-level symbol's declaration, references, and re-export chains.",
264
+ "schema": TRACE_SCHEMA_VERSION,
265
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--symbol"]
266
+ },
267
+ {
268
+ "name": "trace-dependency",
269
+ "kind": "trace-dependency",
270
+ "description": "Trace one pub dependency declaration and Dart import/export usage.",
271
+ "schema": TRACE_SCHEMA_VERSION,
272
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--dependency"]
273
+ },
274
+ {
275
+ "name": "trace-clone",
276
+ "kind": "trace-clone",
277
+ "description": "Trace one duplicate-code group by fingerprint or file line.",
278
+ "schema": TRACE_SCHEMA_VERSION,
279
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--mode", "--min-tokens", "--min-lines", "--min-occurrences", "--top", "--threshold", "--cross-language", "--skip-local", "--ignore-imports", "--no-ignore-imports", "--fingerprint"]
280
+ }
281
+ ])
282
+ }
283
+
284
+ fn support_commands() -> Value {
285
+ let mut commands = Vec::new();
286
+ commands.extend(project_support_commands());
287
+ commands.extend(local_support_commands());
288
+ commands.extend(integration_support_commands());
289
+ Value::Array(commands)
290
+ }
291
+
292
+ fn project_support_commands() -> Vec<Value> {
293
+ vec![
294
+ json!({
295
+ "name": "list",
296
+ "kind": "list",
297
+ "description": "List Dart Decimate project structure and active Dart/Flutter adapters.",
298
+ "schema": PROJECT_LIST_SCHEMA_VERSION,
299
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--files", "--entry-points", "--workspaces", "--plugins", "--boundaries", "--file", "--workspace", "--changed-workspaces"]
300
+ }),
301
+ json!({
302
+ "name": "workspaces",
303
+ "kind": "list",
304
+ "description": "List discovered local pub packages.",
305
+ "schema": PROJECT_LIST_SCHEMA_VERSION,
306
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces"]
307
+ }),
308
+ json!({
309
+ "name": "explain",
310
+ "kind": "explain",
311
+ "description": "Explain one Dart Decimate issue type without running analysis.",
312
+ "schema": EXPLAIN_SCHEMA_VERSION,
313
+ "flags": ["--format"]
314
+ }),
315
+ json!({
316
+ "name": "fix",
317
+ "kind": "fix",
318
+ "description": "Plan or apply safe auto-fixes.",
319
+ "schema": FIX_SCHEMA_VERSION,
320
+ "flags": ["--root", "--format", "--config", "--entry", "--dart-platform", "--production", "--no-production", "--file", "--workspace", "--changed-workspaces", "--changed-since", "--action", "--dry-run", "--apply", "--yes", "--confirm"]
321
+ }),
322
+ ]
323
+ }
324
+
325
+ fn local_support_commands() -> Vec<Value> {
326
+ vec![
327
+ json!({
328
+ "name": "migrate",
329
+ "kind": "unsupported",
330
+ "description": "Report Dart support status for Fallow migration helpers.",
331
+ "schema": UNSUPPORTED_SCHEMA_VERSION,
332
+ "flags": ["--format", "--dry-run"]
333
+ }),
334
+ json!({
335
+ "name": "telemetry",
336
+ "kind": "unsupported",
337
+ "description": "Report Dart Decimate telemetry support status.",
338
+ "schema": UNSUPPORTED_SCHEMA_VERSION,
339
+ "flags": ["status", "enable", "disable", "--format"]
340
+ }),
341
+ json!({
342
+ "name": "license",
343
+ "kind": "unsupported",
344
+ "description": "Report Dart Decimate license support status.",
345
+ "schema": UNSUPPORTED_SCHEMA_VERSION,
346
+ "flags": ["status", "activate", "--format"]
347
+ }),
348
+ json!({
349
+ "name": "init",
350
+ "kind": "init",
351
+ "description": "Create Dart Decimate config and optional AGENTS.md guidance.",
352
+ "schema": INIT_SCHEMA_VERSION,
353
+ "flags": ["--root", "--format", "--agents", "--force"]
354
+ }),
355
+ json!({
356
+ "name": "hooks",
357
+ "kind": "hooks",
358
+ "description": "Inspect, install, or remove Dart Decimate-managed Git and agent hooks.",
359
+ "schema": HOOKS_SCHEMA_VERSION,
360
+ "flags": ["status", "install", "uninstall", "--root", "--format", "--target", "--branch", "--force"]
361
+ }),
362
+ json!({
363
+ "name": "setup-hooks",
364
+ "kind": "hooks",
365
+ "description": "Install or remove Dart Decimate-managed repo-local agent hooks.",
366
+ "schema": HOOKS_SCHEMA_VERSION,
367
+ "flags": ["--root", "--format", "--agent", "--branch", "--dry-run", "--force", "--uninstall"]
368
+ }),
369
+ json!({
370
+ "name": "watch",
371
+ "kind": "watch",
372
+ "description": "Watch Dart project files and rerun Dart Decimate check.",
373
+ "schema": SCHEMA_VERSION,
374
+ "flags": ["--root", "--format", "--no-clear", "--once", "--interval-ms"]
375
+ }),
376
+ json!({
377
+ "name": "ci",
378
+ "kind": "ci",
379
+ "description": "Run CI integration utilities.",
380
+ "schema": CI_RECONCILE_REVIEW_SCHEMA_VERSION,
381
+ "flags": ["reconcile-review", "--provider", "--repo", "--project-id", "--pr", "--mr", "--api-url", "--envelope", "--dry-run", "--format"]
382
+ }),
383
+ ]
384
+ }
385
+
386
+ fn integration_support_commands() -> Vec<Value> {
387
+ vec![
388
+ json!({
389
+ "name": "ci-template",
390
+ "kind": "ci-template",
391
+ "description": "Print or vendor GitHub Actions and GitLab CI templates.",
392
+ "schema": CI_TEMPLATE_SCHEMA_VERSION,
393
+ "flags": ["--format", "--vendor", "--root", "--force"]
394
+ }),
395
+ json!({
396
+ "name": "config",
397
+ "kind": "config",
398
+ "description": "Print the resolved Dart Decimate configuration.",
399
+ "schema": CONFIG_SCHEMA_VERSION,
400
+ "flags": ["--root", "--format", "--config", "--path"]
401
+ }),
402
+ json!({
403
+ "name": "schema",
404
+ "kind": "schema",
405
+ "description": "Print this machine-readable CLI and issue manifest.",
406
+ "schema": MANIFEST_SCHEMA_VERSION,
407
+ "flags": ["--format"]
408
+ }),
409
+ json!({
410
+ "name": "config-schema",
411
+ "kind": "config-schema",
412
+ "description": "Print the configuration JSON schema.",
413
+ "schema": CONFIG_SCHEMA_VERSION,
414
+ "flags": ["--format"]
415
+ }),
416
+ json!({
417
+ "name": "report-schema",
418
+ "kind": "report-schema",
419
+ "description": "Print the analysis report JSON schema.",
420
+ "schema": SCHEMA_VERSION,
421
+ "flags": ["--format"]
422
+ }),
423
+ json!({
424
+ "name": "rule-pack-schema",
425
+ "kind": "rule-pack-schema",
426
+ "description": "Print the policy rule-pack JSON schema.",
427
+ "schema": RULE_PACK_SCHEMA_VERSION,
428
+ "flags": ["--format"]
429
+ }),
430
+ ]
431
+ }
432
+
433
+ fn issue_types() -> Value {
434
+ json!([
435
+ "dead-file",
436
+ "unused-export",
437
+ "unused-type",
438
+ "private-type-leak",
439
+ "unused-enum-member",
440
+ "unused-class-member",
441
+ "duplicate-export",
442
+ "route-collision",
443
+ "private-widget-class",
444
+ "widget-top-level-function-boundary",
445
+ "unused-widget-param",
446
+ "unrendered-widget",
447
+ "missing-context-mounted-after-await",
448
+ "missing-entry-point",
449
+ "circular-dependency",
450
+ "re-export-cycle",
451
+ "boundary-violation",
452
+ "boundary-coverage",
453
+ "boundary-call-violation",
454
+ "policy-violation",
455
+ "unresolved-dependency",
456
+ "part-of-violation",
457
+ "unused-dependency",
458
+ "unused-dev-dependency",
459
+ "test-only-dependency",
460
+ "unused-dependency-override",
461
+ "misconfigured-dependency-override",
462
+ "unlisted-dependency",
463
+ "private-src-import",
464
+ "code-duplication",
465
+ "high-cyclomatic-complexity",
466
+ "high-cognitive-complexity",
467
+ "high-complexity",
468
+ "coverage-gap",
469
+ "high-crap-score",
470
+ "health-hotspot",
471
+ "refactoring-target",
472
+ "feature-flag",
473
+ "security-candidate",
474
+ "stale-suppression",
475
+ "missing-suppression-reason"
476
+ ])
477
+ }
478
+
479
+ fn task_matrix() -> Value {
480
+ json!([
481
+ {
482
+ "intent": "find cleanup opportunities",
483
+ "command": "dart-decimate check --format json",
484
+ "reason": "Combined graph, symbol, dependency, duplication, health, flag, and security report."
485
+ },
486
+ {
487
+ "intent": "review changed code",
488
+ "command": "dart-decimate audit --format json --base <ref>",
489
+ "reason": "Changed-file gate with related graph findings."
490
+ },
491
+ {
492
+ "intent": "review structural decisions",
493
+ "command": "dart-decimate decision-surface --format json --base <ref>",
494
+ "reason": "Ranked changed-code questions for architecture, API, and dependency reviewers."
495
+ },
496
+ {
497
+ "intent": "delete an unused file or export",
498
+ "command": "dart-decimate inspect --format json --file <path>",
499
+ "reason": "Evidence bundle before any deletion or suppression."
500
+ },
501
+ {
502
+ "intent": "trace a top-level symbol",
503
+ "command": "dart-decimate inspect --format json --symbol <file>:<symbol>",
504
+ "reason": "Declaration, references, re-export chains, and file-scoped findings."
505
+ },
506
+ {
507
+ "intent": "verify an unused dependency",
508
+ "command": "dart-decimate trace-dependency --format json --dependency <package>",
509
+ "reason": "Pubspec declarations and Dart import/export usage."
510
+ },
511
+ {
512
+ "intent": "consolidate duplicated code",
513
+ "command": "dart-decimate trace-clone --format json --fingerprint <fingerprint>",
514
+ "reason": "Duplicate group instances and extraction suggestion."
515
+ },
516
+ {
517
+ "intent": "scope a monorepo",
518
+ "command": "dart-decimate check --format json --workspace <pattern>",
519
+ "reason": "Restrict findings to matching local pub packages."
520
+ },
521
+ {
522
+ "intent": "explain an issue",
523
+ "command": "dart-decimate explain --format json <issue-type>",
524
+ "reason": "Rule rationale, aliases, suppressions, and follow-up commands."
525
+ },
526
+ {
527
+ "intent": "show local value report",
528
+ "command": "dart-decimate impact --format json --quiet",
529
+ "reason": "Read-only local impact report; disabled projects return a populated zero-count report."
530
+ },
531
+ {
532
+ "intent": "initialize a Dart or Flutter project",
533
+ "command": "dart-decimate init --agents",
534
+ "reason": "Write agent-first Dart Decimate defaults and optional coding-agent guidance."
535
+ },
536
+ {
537
+ "intent": "guard commits",
538
+ "command": "dart-decimate hooks install --target git --branch origin/main",
539
+ "reason": "Install a Dart Decimate-managed pre-commit hook that runs changed-code audit."
540
+ },
541
+ {
542
+ "intent": "set up runtime coverage",
543
+ "command": "dart-decimate coverage setup --non-interactive --format json",
544
+ "reason": "Read-only setup plan; add --yes to create local coverage defaults."
545
+ },
546
+ {
547
+ "intent": "set up CI",
548
+ "command": "dart-decimate ci-template github --format yaml",
549
+ "reason": "Read-only CI template output for changed-code audit gating."
550
+ }
551
+ ])
552
+ }