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.
- package/Cargo.lock +572 -0
- package/Cargo.toml +41 -0
- package/LICENSE +21 -0
- package/README.md +617 -0
- package/assets/dart-decimate-banner.png +0 -0
- package/npm/bin/dart-decimate-mcp.js +48 -0
- package/npm/bin/dart-decimate.js +48 -0
- package/npm/scripts/postinstall.js +46 -0
- package/npm/scripts/test-npx-local.js +54 -0
- package/npm/scripts/test-npx-mcp-local.js +56 -0
- package/package.json +45 -0
- package/src/baseline.rs +643 -0
- package/src/bin/dart-decimate-mcp.rs +11 -0
- package/src/boundaries/tests.rs +60 -0
- package/src/boundaries.rs +317 -0
- package/src/changed_scope.rs +117 -0
- package/src/ci_template.rs +399 -0
- package/src/cli/analyze.rs +462 -0
- package/src/cli/analyzer_options.rs +82 -0
- package/src/cli/audit_run.rs +327 -0
- package/src/cli/boundary_args.rs +44 -0
- package/src/cli/ci_template_run.rs +196 -0
- package/src/cli/command_name.rs +20 -0
- package/src/cli/common_args.rs +167 -0
- package/src/cli/config_run.rs +78 -0
- package/src/cli/coverage_run.rs +393 -0
- package/src/cli/decision_surface_run.rs +99 -0
- package/src/cli/default_command.rs +69 -0
- package/src/cli/dupes_args.rs +150 -0
- package/src/cli/entry_points.rs +121 -0
- package/src/cli/error.rs +149 -0
- package/src/cli/error_output.rs +68 -0
- package/src/cli/explain_run.rs +72 -0
- package/src/cli/fix_run.rs +162 -0
- package/src/cli/flags_args.rs +23 -0
- package/src/cli/health_args.rs +200 -0
- package/src/cli/hooks_run.rs +191 -0
- package/src/cli/impact_run.rs +95 -0
- package/src/cli/init_run.rs +49 -0
- package/src/cli/inspect_args.rs +20 -0
- package/src/cli/inspect_run.rs +66 -0
- package/src/cli/issue_filter_args.rs +240 -0
- package/src/cli/list_run.rs +311 -0
- package/src/cli/mode_args.rs +72 -0
- package/src/cli/output_format.rs +62 -0
- package/src/cli/regression_args.rs +156 -0
- package/src/cli/request_args.rs +175 -0
- package/src/cli/schema_commands.rs +72 -0
- package/src/cli/scope_args.rs +174 -0
- package/src/cli/security_args.rs +175 -0
- package/src/cli/security_gate_run.rs +66 -0
- package/src/cli/security_summary_run.rs +43 -0
- package/src/cli/summary_args.rs +12 -0
- package/src/cli/tests.rs +516 -0
- package/src/cli/trace_args.rs +67 -0
- package/src/cli/trace_run.rs +131 -0
- package/src/cli/trace_tests.rs +235 -0
- package/src/cli/unsupported_run.rs +116 -0
- package/src/cli/watch_run.rs +153 -0
- package/src/cli.rs +603 -0
- package/src/config/boundary_config.rs +235 -0
- package/src/config/cache.rs +25 -0
- package/src/config/dependencies.rs +114 -0
- package/src/config/health.rs +237 -0
- package/src/config/jsonc.rs +66 -0
- package/src/config/policy.rs +91 -0
- package/src/config/rule_aliases.rs +487 -0
- package/src/config/rules.rs +339 -0
- package/src/config.rs +635 -0
- package/src/coverage.rs +469 -0
- package/src/dart_parser.rs +673 -0
- package/src/decision_surface.rs +405 -0
- package/src/dependencies/analyze.rs +218 -0
- package/src/dependencies/codegen.rs +118 -0
- package/src/dependencies/discovery.rs +60 -0
- package/src/dependencies/overrides.rs +76 -0
- package/src/dependencies/private_src_imports.rs +32 -0
- package/src/dependencies/pubspec_document.rs +86 -0
- package/src/dependencies/pubspec_entry.rs +96 -0
- package/src/dependencies/tests.rs +544 -0
- package/src/dependencies/usage.rs +33 -0
- package/src/dependencies.rs +553 -0
- package/src/dependency_scripts.rs +91 -0
- package/src/dupes/lex.rs +236 -0
- package/src/dupes/tests.rs +119 -0
- package/src/dupes.rs +625 -0
- package/src/explain.rs +692 -0
- package/src/extract/directives.rs +252 -0
- package/src/extract/error_tests.rs +25 -0
- package/src/extract/members.rs +210 -0
- package/src/extract/primary_constructors.rs +421 -0
- package/src/extract/references.rs +151 -0
- package/src/extract/routes.rs +691 -0
- package/src/extract/signatures.rs +266 -0
- package/src/extract/string_tests.rs +18 -0
- package/src/extract/strings.rs +107 -0
- package/src/extract/tests.rs +697 -0
- package/src/extract.rs +680 -0
- package/src/feature_flags/tests.rs +76 -0
- package/src/feature_flags.rs +453 -0
- package/src/finding_identity.rs +60 -0
- package/src/fix.rs +551 -0
- package/src/generated.rs +53 -0
- package/src/graph/augment_tests.rs +212 -0
- package/src/graph/conditionals.rs +74 -0
- package/src/graph/package_config_tests.rs +100 -0
- package/src/graph/parts.rs +248 -0
- package/src/graph/pubspec_tests.rs +119 -0
- package/src/graph/tests.rs +837 -0
- package/src/graph/uri_tests.rs +102 -0
- package/src/graph.rs +644 -0
- package/src/health/coverage.rs +309 -0
- package/src/health/ownership.rs +175 -0
- package/src/health/runtime_coverage.rs +616 -0
- package/src/health/runtime_intelligence.rs +511 -0
- package/src/health/scores.rs +296 -0
- package/src/health/tests.rs +240 -0
- package/src/health/threshold_types.rs +163 -0
- package/src/health/thresholds.rs +229 -0
- package/src/health/types.rs +636 -0
- package/src/health.rs +597 -0
- package/src/hooks/agent_settings.rs +175 -0
- package/src/hooks/templates.rs +51 -0
- package/src/hooks.rs +569 -0
- package/src/impact.rs +287 -0
- package/src/init.rs +237 -0
- package/src/inspect.rs +142 -0
- package/src/intelligence/tests.rs +232 -0
- package/src/intelligence.rs +305 -0
- package/src/lib.rs +198 -0
- package/src/main.rs +5 -0
- package/src/manifest/mcp.rs +565 -0
- package/src/manifest.rs +552 -0
- package/src/mcp/cli_args/value_args.rs +175 -0
- package/src/mcp/cli_args.rs +658 -0
- package/src/mcp/cli_args_tests.rs +522 -0
- package/src/mcp/code_execute.rs +671 -0
- package/src/mcp/tools.rs +660 -0
- package/src/mcp.rs +325 -0
- package/src/output/audit_risk.rs +135 -0
- package/src/output/dependency_findings.rs +327 -0
- package/src/output/duplication_findings.rs +114 -0
- package/src/output/feature_flag_findings.rs +122 -0
- package/src/output/format.rs +31 -0
- package/src/output/graph_findings.rs +461 -0
- package/src/output/health_findings.rs +612 -0
- package/src/output/human.rs +27 -0
- package/src/output/next_steps.rs +92 -0
- package/src/output/route_findings.rs +76 -0
- package/src/output/runtime_coverage.rs +515 -0
- package/src/output/scope.rs +183 -0
- package/src/output/security_findings.rs +390 -0
- package/src/output/security_sarif.rs +150 -0
- package/src/output/suppressions.rs +323 -0
- package/src/output/symbol_findings.rs +257 -0
- package/src/output/tests.rs +114 -0
- package/src/output/types.rs +604 -0
- package/src/output/widget_findings.rs +213 -0
- package/src/output.rs +682 -0
- package/src/package_map.rs +495 -0
- package/src/policy/packs.rs +232 -0
- package/src/policy/tests.rs +134 -0
- package/src/policy.rs +640 -0
- package/src/project_list.rs +376 -0
- package/src/report_schema/inventory.rs +418 -0
- package/src/report_schema.rs +488 -0
- package/src/routes.rs +354 -0
- package/src/scan/tests.rs +250 -0
- package/src/scan.rs +275 -0
- package/src/security/detect.rs +639 -0
- package/src/security/tests.rs +178 -0
- package/src/security.rs +373 -0
- package/src/security_gate.rs +555 -0
- package/src/symbols/path_filters.rs +27 -0
- package/src/symbols/private_type_leaks.rs +125 -0
- package/src/symbols/riverpod.rs +113 -0
- package/src/symbols/tests.rs +692 -0
- package/src/symbols.rs +693 -0
- package/src/trace/tests.rs +225 -0
- package/src/trace.rs +690 -0
- package/src/unsupported.rs +47 -0
- package/src/widgets/lifecycle.rs +484 -0
- package/src/widgets/params.rs +236 -0
- package/src/widgets/tests.rs +430 -0
- package/src/widgets/top_level.rs +110 -0
- package/src/widgets/unrendered.rs +374 -0
- package/src/widgets.rs +590 -0
- package/src/workspace_scope.rs +358 -0
package/src/mcp/tools.rs
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
1
|
+
use serde_json::{Map, Value, json};
|
|
2
|
+
|
|
3
|
+
pub(super) fn tools() -> Value {
|
|
4
|
+
let mut values = Vec::new();
|
|
5
|
+
values.extend(overview_tools());
|
|
6
|
+
values.extend(trace_tools());
|
|
7
|
+
values.extend(analysis_tools());
|
|
8
|
+
values.extend(change_tools());
|
|
9
|
+
Value::Array(values)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
fn overview_tools() -> Vec<Value> {
|
|
13
|
+
vec![
|
|
14
|
+
code_execute_tool(),
|
|
15
|
+
analyze_tool(),
|
|
16
|
+
check_changed_tool(),
|
|
17
|
+
project_info_tool(),
|
|
18
|
+
list_boundaries_tool(),
|
|
19
|
+
inspect_target_tool(),
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fn code_execute_tool() -> Value {
|
|
24
|
+
tool(
|
|
25
|
+
"code_execute",
|
|
26
|
+
"Compose bounded read-only Dart Decimate MCP calls with a JSON program.",
|
|
27
|
+
schema(
|
|
28
|
+
&[
|
|
29
|
+
("code", "object"),
|
|
30
|
+
("program", "object"),
|
|
31
|
+
("max_steps", "integer"),
|
|
32
|
+
("max_tool_calls", "integer"),
|
|
33
|
+
("max_result_bytes", "integer"),
|
|
34
|
+
],
|
|
35
|
+
&[],
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fn analyze_tool() -> Value {
|
|
41
|
+
tool(
|
|
42
|
+
"analyze",
|
|
43
|
+
"Run Dart Decimate check and return the JSON report.",
|
|
44
|
+
schema(
|
|
45
|
+
&[
|
|
46
|
+
("root", "string"),
|
|
47
|
+
("config", "string"),
|
|
48
|
+
("issue_types", "array"),
|
|
49
|
+
("entry", "array"),
|
|
50
|
+
("dart_platform", "string"),
|
|
51
|
+
("file", "array"),
|
|
52
|
+
("workspace", "array"),
|
|
53
|
+
("changed_workspaces", "string"),
|
|
54
|
+
("changed_since", "string"),
|
|
55
|
+
("baseline", "string"),
|
|
56
|
+
("regression_baseline", "string"),
|
|
57
|
+
("fail_on_regression", "boolean"),
|
|
58
|
+
("tolerance", "string"),
|
|
59
|
+
("include_entry_exports", "boolean"),
|
|
60
|
+
("private_type_leaks", "boolean"),
|
|
61
|
+
("boundary", "array"),
|
|
62
|
+
("boundary_coverage", "boolean"),
|
|
63
|
+
("boundary_call", "array"),
|
|
64
|
+
("policy_pack", "array"),
|
|
65
|
+
("policy_violations", "boolean"),
|
|
66
|
+
("mode", "string"),
|
|
67
|
+
("min_tokens", "integer"),
|
|
68
|
+
("min_lines", "integer"),
|
|
69
|
+
("min_occurrences", "integer"),
|
|
70
|
+
("top", "integer"),
|
|
71
|
+
("threshold", "number"),
|
|
72
|
+
("cross_language", "boolean"),
|
|
73
|
+
("skip_local", "boolean"),
|
|
74
|
+
("ignore_imports", "boolean"),
|
|
75
|
+
("no_ignore_imports", "boolean"),
|
|
76
|
+
("max_cyclomatic", "integer"),
|
|
77
|
+
("max_cognitive", "integer"),
|
|
78
|
+
("max_crap", "integer"),
|
|
79
|
+
("coverage", "string"),
|
|
80
|
+
("runtime_coverage", "string"),
|
|
81
|
+
("min_invocations_hot", "integer"),
|
|
82
|
+
("min_observation_volume", "integer"),
|
|
83
|
+
("low_traffic_threshold", "number"),
|
|
84
|
+
("coverage_gaps", "boolean"),
|
|
85
|
+
("file_scores", "boolean"),
|
|
86
|
+
("hotspots", "boolean"),
|
|
87
|
+
("targets", "boolean"),
|
|
88
|
+
("ownership", "boolean"),
|
|
89
|
+
("complexity_breakdown", "boolean"),
|
|
90
|
+
("min_score", "integer"),
|
|
91
|
+
("production", "boolean"),
|
|
92
|
+
],
|
|
93
|
+
&[],
|
|
94
|
+
),
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
fn check_changed_tool() -> Value {
|
|
99
|
+
tool(
|
|
100
|
+
"check_changed",
|
|
101
|
+
"Run Dart Decimate check scoped to files changed since a Git ref.",
|
|
102
|
+
schema(
|
|
103
|
+
&[
|
|
104
|
+
("root", "string"),
|
|
105
|
+
("config", "string"),
|
|
106
|
+
("since", "string"),
|
|
107
|
+
("changed_since", "string"),
|
|
108
|
+
("baseline", "string"),
|
|
109
|
+
("regression_baseline", "string"),
|
|
110
|
+
("fail_on_regression", "boolean"),
|
|
111
|
+
("tolerance", "string"),
|
|
112
|
+
("production", "boolean"),
|
|
113
|
+
],
|
|
114
|
+
&[],
|
|
115
|
+
),
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
fn project_info_tool() -> Value {
|
|
120
|
+
tool(
|
|
121
|
+
"project_info",
|
|
122
|
+
"List Dart Decimate project metadata.",
|
|
123
|
+
schema(
|
|
124
|
+
&[
|
|
125
|
+
("root", "string"),
|
|
126
|
+
("config", "string"),
|
|
127
|
+
("files", "boolean"),
|
|
128
|
+
("entry_points", "boolean"),
|
|
129
|
+
("plugins", "boolean"),
|
|
130
|
+
("boundaries", "boolean"),
|
|
131
|
+
("workspaces", "boolean"),
|
|
132
|
+
("entry", "array"),
|
|
133
|
+
("dart_platform", "string"),
|
|
134
|
+
("file", "array"),
|
|
135
|
+
("workspace", "array"),
|
|
136
|
+
("changed_workspaces", "string"),
|
|
137
|
+
("production", "boolean"),
|
|
138
|
+
],
|
|
139
|
+
&[],
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
fn list_boundaries_tool() -> Value {
|
|
145
|
+
tool(
|
|
146
|
+
"list_boundaries",
|
|
147
|
+
"List configured architecture boundaries.",
|
|
148
|
+
schema(
|
|
149
|
+
&[
|
|
150
|
+
("root", "string"),
|
|
151
|
+
("config", "string"),
|
|
152
|
+
("entry", "array"),
|
|
153
|
+
("dart_platform", "string"),
|
|
154
|
+
("file", "array"),
|
|
155
|
+
("workspace", "array"),
|
|
156
|
+
("changed_workspaces", "string"),
|
|
157
|
+
("production", "boolean"),
|
|
158
|
+
],
|
|
159
|
+
&[],
|
|
160
|
+
),
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
fn inspect_target_tool() -> Value {
|
|
165
|
+
tool(
|
|
166
|
+
"inspect_target",
|
|
167
|
+
"Inspect one Dart file or symbol.",
|
|
168
|
+
schema(
|
|
169
|
+
&[
|
|
170
|
+
("root", "string"),
|
|
171
|
+
("config", "string"),
|
|
172
|
+
("target", "target"),
|
|
173
|
+
("file", "string"),
|
|
174
|
+
("symbol", "string"),
|
|
175
|
+
("production", "boolean"),
|
|
176
|
+
],
|
|
177
|
+
&[],
|
|
178
|
+
),
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fn trace_tools() -> Vec<Value> {
|
|
183
|
+
vec![
|
|
184
|
+
tool(
|
|
185
|
+
"trace_file",
|
|
186
|
+
"Trace a Dart file.",
|
|
187
|
+
schema(
|
|
188
|
+
&[("root", "string"), ("config", "string"), ("file", "string")],
|
|
189
|
+
&["file"],
|
|
190
|
+
),
|
|
191
|
+
),
|
|
192
|
+
tool(
|
|
193
|
+
"trace_export",
|
|
194
|
+
"Trace a top-level Dart symbol.",
|
|
195
|
+
schema(
|
|
196
|
+
&[
|
|
197
|
+
("root", "string"),
|
|
198
|
+
("config", "string"),
|
|
199
|
+
("file", "string"),
|
|
200
|
+
("symbol", "string"),
|
|
201
|
+
("export_name", "string"),
|
|
202
|
+
],
|
|
203
|
+
&["file"],
|
|
204
|
+
),
|
|
205
|
+
),
|
|
206
|
+
tool(
|
|
207
|
+
"trace_dependency",
|
|
208
|
+
"Trace pub dependency usage.",
|
|
209
|
+
schema(
|
|
210
|
+
&[
|
|
211
|
+
("root", "string"),
|
|
212
|
+
("config", "string"),
|
|
213
|
+
("dependency", "string"),
|
|
214
|
+
("package_name", "string"),
|
|
215
|
+
],
|
|
216
|
+
&[],
|
|
217
|
+
),
|
|
218
|
+
),
|
|
219
|
+
tool(
|
|
220
|
+
"trace_clone",
|
|
221
|
+
"Trace a duplicate-code clone group.",
|
|
222
|
+
schema(
|
|
223
|
+
&[
|
|
224
|
+
("root", "string"),
|
|
225
|
+
("config", "string"),
|
|
226
|
+
("fingerprint", "string"),
|
|
227
|
+
("file", "string"),
|
|
228
|
+
("line", "integer"),
|
|
229
|
+
("mode", "string"),
|
|
230
|
+
("min_tokens", "integer"),
|
|
231
|
+
("min_lines", "integer"),
|
|
232
|
+
("min_occurrences", "integer"),
|
|
233
|
+
("top", "integer"),
|
|
234
|
+
("threshold", "number"),
|
|
235
|
+
("cross_language", "boolean"),
|
|
236
|
+
("skip_local", "boolean"),
|
|
237
|
+
("ignore_imports", "boolean"),
|
|
238
|
+
("no_ignore_imports", "boolean"),
|
|
239
|
+
],
|
|
240
|
+
&[],
|
|
241
|
+
),
|
|
242
|
+
),
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
fn analysis_tools() -> Vec<Value> {
|
|
247
|
+
vec![
|
|
248
|
+
dupes_tool(),
|
|
249
|
+
health_tool(),
|
|
250
|
+
runtime_tool(
|
|
251
|
+
"check_runtime_coverage",
|
|
252
|
+
"Merge local V8 or Istanbul runtime coverage into Dart Decimate runtime intelligence.",
|
|
253
|
+
"coverage",
|
|
254
|
+
),
|
|
255
|
+
runtime_tool(
|
|
256
|
+
"get_hot_paths",
|
|
257
|
+
"Return runtime coverage context for hot-path review.",
|
|
258
|
+
"coverage",
|
|
259
|
+
),
|
|
260
|
+
runtime_tool(
|
|
261
|
+
"get_blast_radius",
|
|
262
|
+
"Return runtime coverage context for blast-radius review.",
|
|
263
|
+
"coverage",
|
|
264
|
+
),
|
|
265
|
+
runtime_tool(
|
|
266
|
+
"get_importance",
|
|
267
|
+
"Return runtime coverage context for production-importance review.",
|
|
268
|
+
"coverage",
|
|
269
|
+
),
|
|
270
|
+
runtime_tool(
|
|
271
|
+
"get_cleanup_candidates",
|
|
272
|
+
"Return runtime coverage context for low-traffic and unavailable-code cleanup review.",
|
|
273
|
+
"coverage",
|
|
274
|
+
),
|
|
275
|
+
security_tool(),
|
|
276
|
+
feature_flags_tool(),
|
|
277
|
+
impact_tool(),
|
|
278
|
+
impact_all_tool(),
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
fn dupes_tool() -> Value {
|
|
283
|
+
tool(
|
|
284
|
+
"find_dupes",
|
|
285
|
+
"Find duplicated Dart code blocks.",
|
|
286
|
+
schema(
|
|
287
|
+
&[
|
|
288
|
+
("root", "string"),
|
|
289
|
+
("config", "string"),
|
|
290
|
+
("mode", "string"),
|
|
291
|
+
("entry", "array"),
|
|
292
|
+
("dart_platform", "string"),
|
|
293
|
+
("file", "array"),
|
|
294
|
+
("workspace", "array"),
|
|
295
|
+
("changed_workspaces", "string"),
|
|
296
|
+
("changed_since", "string"),
|
|
297
|
+
("baseline", "string"),
|
|
298
|
+
("regression_baseline", "string"),
|
|
299
|
+
("fail_on_regression", "boolean"),
|
|
300
|
+
("tolerance", "string"),
|
|
301
|
+
("production", "boolean"),
|
|
302
|
+
("min_tokens", "integer"),
|
|
303
|
+
("min_lines", "integer"),
|
|
304
|
+
("min_occurrences", "integer"),
|
|
305
|
+
("top", "integer"),
|
|
306
|
+
("threshold", "number"),
|
|
307
|
+
("cross_language", "boolean"),
|
|
308
|
+
("skip_local", "boolean"),
|
|
309
|
+
("ignore_imports", "boolean"),
|
|
310
|
+
("no_ignore_imports", "boolean"),
|
|
311
|
+
],
|
|
312
|
+
&[],
|
|
313
|
+
),
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
fn health_tool() -> Value {
|
|
318
|
+
tool(
|
|
319
|
+
"check_health",
|
|
320
|
+
"Run Dart Decimate health checks.",
|
|
321
|
+
schema(
|
|
322
|
+
&[
|
|
323
|
+
("root", "string"),
|
|
324
|
+
("config", "string"),
|
|
325
|
+
("max_cyclomatic", "integer"),
|
|
326
|
+
("max_cognitive", "integer"),
|
|
327
|
+
("max_crap", "integer"),
|
|
328
|
+
("coverage", "string"),
|
|
329
|
+
("entry", "array"),
|
|
330
|
+
("dart_platform", "string"),
|
|
331
|
+
("file", "array"),
|
|
332
|
+
("workspace", "array"),
|
|
333
|
+
("changed_workspaces", "string"),
|
|
334
|
+
("changed_since", "string"),
|
|
335
|
+
("baseline", "string"),
|
|
336
|
+
("regression_baseline", "string"),
|
|
337
|
+
("fail_on_regression", "boolean"),
|
|
338
|
+
("tolerance", "string"),
|
|
339
|
+
("runtime_coverage", "string"),
|
|
340
|
+
("min_invocations_hot", "integer"),
|
|
341
|
+
("min_observation_volume", "integer"),
|
|
342
|
+
("low_traffic_threshold", "number"),
|
|
343
|
+
("coverage_gaps", "boolean"),
|
|
344
|
+
("file_scores", "boolean"),
|
|
345
|
+
("hotspots", "boolean"),
|
|
346
|
+
("targets", "boolean"),
|
|
347
|
+
("ownership", "boolean"),
|
|
348
|
+
("complexity_breakdown", "boolean"),
|
|
349
|
+
("min_score", "integer"),
|
|
350
|
+
("top", "integer"),
|
|
351
|
+
("production", "boolean"),
|
|
352
|
+
],
|
|
353
|
+
&[],
|
|
354
|
+
),
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
fn runtime_tool(name: &str, description: &str, required: &str) -> Value {
|
|
359
|
+
tool(
|
|
360
|
+
name,
|
|
361
|
+
description,
|
|
362
|
+
schema(
|
|
363
|
+
&[
|
|
364
|
+
("root", "string"),
|
|
365
|
+
("config", "string"),
|
|
366
|
+
("coverage", "string"),
|
|
367
|
+
("min_invocations_hot", "integer"),
|
|
368
|
+
("min_observation_volume", "integer"),
|
|
369
|
+
("low_traffic_threshold", "number"),
|
|
370
|
+
("top", "integer"),
|
|
371
|
+
("repo", "string"),
|
|
372
|
+
],
|
|
373
|
+
&[required],
|
|
374
|
+
),
|
|
375
|
+
)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
fn security_tool() -> Value {
|
|
379
|
+
tool(
|
|
380
|
+
"security_candidates",
|
|
381
|
+
"Surface security review candidates.",
|
|
382
|
+
schema(
|
|
383
|
+
&[
|
|
384
|
+
("root", "string"),
|
|
385
|
+
("config", "string"),
|
|
386
|
+
("top", "integer"),
|
|
387
|
+
("entry", "array"),
|
|
388
|
+
("dart_platform", "string"),
|
|
389
|
+
("file", "array"),
|
|
390
|
+
("workspace", "array"),
|
|
391
|
+
("changed_workspaces", "string"),
|
|
392
|
+
("changed_since", "string"),
|
|
393
|
+
("baseline", "string"),
|
|
394
|
+
("regression_baseline", "string"),
|
|
395
|
+
("fail_on_regression", "boolean"),
|
|
396
|
+
("tolerance", "string"),
|
|
397
|
+
("surface", "boolean"),
|
|
398
|
+
("production", "boolean"),
|
|
399
|
+
("gate", "string"),
|
|
400
|
+
("paths", "array"),
|
|
401
|
+
("diff_file", "string"),
|
|
402
|
+
("ci", "boolean"),
|
|
403
|
+
("fail_on_issues", "boolean"),
|
|
404
|
+
("summary", "boolean"),
|
|
405
|
+
],
|
|
406
|
+
&[],
|
|
407
|
+
),
|
|
408
|
+
)
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
fn impact_tool() -> Value {
|
|
412
|
+
tool(
|
|
413
|
+
"impact",
|
|
414
|
+
"Read the local Dart Decimate value report without running analysis.",
|
|
415
|
+
schema(&[("root", "string")], &[]),
|
|
416
|
+
)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
fn impact_all_tool() -> Value {
|
|
420
|
+
tool(
|
|
421
|
+
"impact_all",
|
|
422
|
+
"Roll up every tracked Dart Decimate project on this machine.",
|
|
423
|
+
schema(&[("sort", "string"), ("limit", "integer")], &[]),
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
fn feature_flags_tool() -> Value {
|
|
428
|
+
tool(
|
|
429
|
+
"feature_flags",
|
|
430
|
+
"Inventory Dart and Flutter feature flags.",
|
|
431
|
+
schema(
|
|
432
|
+
&[
|
|
433
|
+
("root", "string"),
|
|
434
|
+
("config", "string"),
|
|
435
|
+
("entry", "array"),
|
|
436
|
+
("dart_platform", "string"),
|
|
437
|
+
("file", "array"),
|
|
438
|
+
("workspace", "array"),
|
|
439
|
+
("changed_workspaces", "string"),
|
|
440
|
+
("top", "integer"),
|
|
441
|
+
("changed_since", "string"),
|
|
442
|
+
("baseline", "string"),
|
|
443
|
+
("regression_baseline", "string"),
|
|
444
|
+
("fail_on_regression", "boolean"),
|
|
445
|
+
("tolerance", "string"),
|
|
446
|
+
("production", "boolean"),
|
|
447
|
+
],
|
|
448
|
+
&[],
|
|
449
|
+
),
|
|
450
|
+
)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
fn change_tools() -> Vec<Value> {
|
|
454
|
+
vec![
|
|
455
|
+
fix_preview_tool(),
|
|
456
|
+
fix_apply_tool(),
|
|
457
|
+
audit_tool(),
|
|
458
|
+
decision_surface_tool(),
|
|
459
|
+
explain_tool("dart_decimate_explain"),
|
|
460
|
+
explain_tool("fallow_explain"),
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
fn fix_preview_tool() -> Value {
|
|
465
|
+
tool(
|
|
466
|
+
"fix_preview",
|
|
467
|
+
"Preview safe auto-fixes without modifying files.",
|
|
468
|
+
schema(
|
|
469
|
+
&[
|
|
470
|
+
("root", "string"),
|
|
471
|
+
("config", "string"),
|
|
472
|
+
("entry", "array"),
|
|
473
|
+
("dart_platform", "string"),
|
|
474
|
+
("file", "array"),
|
|
475
|
+
("workspace", "array"),
|
|
476
|
+
("changed_workspaces", "string"),
|
|
477
|
+
("changed_since", "string"),
|
|
478
|
+
("production", "boolean"),
|
|
479
|
+
("action", "array"),
|
|
480
|
+
("no_create_config", "boolean"),
|
|
481
|
+
],
|
|
482
|
+
&[],
|
|
483
|
+
),
|
|
484
|
+
)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
fn fix_apply_tool() -> Value {
|
|
488
|
+
tool_with_annotations(
|
|
489
|
+
"fix_apply",
|
|
490
|
+
"Apply safe auto-fixes. Requires yes: true.",
|
|
491
|
+
schema(
|
|
492
|
+
&[
|
|
493
|
+
("root", "string"),
|
|
494
|
+
("config", "string"),
|
|
495
|
+
("entry", "array"),
|
|
496
|
+
("dart_platform", "string"),
|
|
497
|
+
("file", "array"),
|
|
498
|
+
("workspace", "array"),
|
|
499
|
+
("changed_workspaces", "string"),
|
|
500
|
+
("changed_since", "string"),
|
|
501
|
+
("production", "boolean"),
|
|
502
|
+
("action", "array"),
|
|
503
|
+
("no_create_config", "boolean"),
|
|
504
|
+
("yes", "boolean"),
|
|
505
|
+
],
|
|
506
|
+
&["yes"],
|
|
507
|
+
),
|
|
508
|
+
false,
|
|
509
|
+
true,
|
|
510
|
+
)
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
fn audit_tool() -> Value {
|
|
514
|
+
tool(
|
|
515
|
+
"audit",
|
|
516
|
+
"Run changed-code audit.",
|
|
517
|
+
schema(
|
|
518
|
+
&[
|
|
519
|
+
("root", "string"),
|
|
520
|
+
("config", "string"),
|
|
521
|
+
("base", "string"),
|
|
522
|
+
("gate", "string"),
|
|
523
|
+
("entry", "array"),
|
|
524
|
+
("dart_platform", "string"),
|
|
525
|
+
("file", "array"),
|
|
526
|
+
("workspace", "array"),
|
|
527
|
+
("changed_workspaces", "string"),
|
|
528
|
+
("changed_since", "string"),
|
|
529
|
+
("include_entry_exports", "boolean"),
|
|
530
|
+
("private_type_leaks", "boolean"),
|
|
531
|
+
("boundary", "array"),
|
|
532
|
+
("boundary_coverage", "boolean"),
|
|
533
|
+
("boundary_call", "array"),
|
|
534
|
+
("policy_pack", "array"),
|
|
535
|
+
("policy_violations", "boolean"),
|
|
536
|
+
("mode", "string"),
|
|
537
|
+
("min_tokens", "integer"),
|
|
538
|
+
("min_lines", "integer"),
|
|
539
|
+
("min_occurrences", "integer"),
|
|
540
|
+
("top", "integer"),
|
|
541
|
+
("threshold", "number"),
|
|
542
|
+
("cross_language", "boolean"),
|
|
543
|
+
("skip_local", "boolean"),
|
|
544
|
+
("ignore_imports", "boolean"),
|
|
545
|
+
("no_ignore_imports", "boolean"),
|
|
546
|
+
("max_cyclomatic", "integer"),
|
|
547
|
+
("max_cognitive", "integer"),
|
|
548
|
+
("max_crap", "integer"),
|
|
549
|
+
("coverage", "string"),
|
|
550
|
+
("runtime_coverage", "string"),
|
|
551
|
+
("min_invocations_hot", "integer"),
|
|
552
|
+
("min_observation_volume", "integer"),
|
|
553
|
+
("low_traffic_threshold", "number"),
|
|
554
|
+
("coverage_gaps", "boolean"),
|
|
555
|
+
("file_scores", "boolean"),
|
|
556
|
+
("hotspots", "boolean"),
|
|
557
|
+
("targets", "boolean"),
|
|
558
|
+
("ownership", "boolean"),
|
|
559
|
+
("complexity_breakdown", "boolean"),
|
|
560
|
+
("min_score", "integer"),
|
|
561
|
+
("dead_code_baseline", "string"),
|
|
562
|
+
("health_baseline", "string"),
|
|
563
|
+
("dupes_baseline", "string"),
|
|
564
|
+
("production", "boolean"),
|
|
565
|
+
("brief", "boolean"),
|
|
566
|
+
("max_decisions", "integer"),
|
|
567
|
+
],
|
|
568
|
+
&["base"],
|
|
569
|
+
),
|
|
570
|
+
)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
fn decision_surface_tool() -> Value {
|
|
574
|
+
tool(
|
|
575
|
+
"decision_surface",
|
|
576
|
+
"Surface changed-code architecture decisions.",
|
|
577
|
+
schema(
|
|
578
|
+
&[
|
|
579
|
+
("root", "string"),
|
|
580
|
+
("config", "string"),
|
|
581
|
+
("base", "string"),
|
|
582
|
+
("max_decisions", "integer"),
|
|
583
|
+
],
|
|
584
|
+
&["base"],
|
|
585
|
+
),
|
|
586
|
+
)
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
fn explain_tool(name: &str) -> Value {
|
|
590
|
+
tool(
|
|
591
|
+
name,
|
|
592
|
+
"Explain a Dart Decimate issue type.",
|
|
593
|
+
schema(&[("issue_type", "string"), ("rule_id", "string")], &[]),
|
|
594
|
+
)
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
fn tool(name: &str, description: &str, input_schema: Value) -> Value {
|
|
598
|
+
tool_with_annotations(name, description, input_schema, true, false)
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
fn tool_with_annotations(
|
|
602
|
+
name: &str,
|
|
603
|
+
description: &str,
|
|
604
|
+
input_schema: Value,
|
|
605
|
+
read_only: bool,
|
|
606
|
+
destructive: bool,
|
|
607
|
+
) -> Value {
|
|
608
|
+
let mut tool = Map::new();
|
|
609
|
+
tool.insert("name".to_owned(), Value::String(name.to_owned()));
|
|
610
|
+
tool.insert(
|
|
611
|
+
"description".to_owned(),
|
|
612
|
+
Value::String(description.to_owned()),
|
|
613
|
+
);
|
|
614
|
+
tool.insert("inputSchema".to_owned(), input_schema);
|
|
615
|
+
tool.insert(
|
|
616
|
+
"annotations".to_owned(),
|
|
617
|
+
json!({
|
|
618
|
+
"readOnlyHint": read_only,
|
|
619
|
+
"destructiveHint": destructive,
|
|
620
|
+
"openWorldHint": false
|
|
621
|
+
}),
|
|
622
|
+
);
|
|
623
|
+
Value::Object(tool)
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
fn schema(properties: &[(&str, &str)], required: &[&str]) -> Value {
|
|
627
|
+
let properties = properties
|
|
628
|
+
.iter()
|
|
629
|
+
.map(|(name, kind)| ((*name).to_owned(), property_schema(kind)))
|
|
630
|
+
.collect::<Map<_, _>>();
|
|
631
|
+
json!({
|
|
632
|
+
"type": "object",
|
|
633
|
+
"properties": properties,
|
|
634
|
+
"required": required,
|
|
635
|
+
"additionalProperties": false
|
|
636
|
+
})
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
fn property_schema(kind: &str) -> Value {
|
|
640
|
+
match kind {
|
|
641
|
+
"array" => json!({ "type": "array", "items": { "type": "string" } }),
|
|
642
|
+
"object" => json!({ "type": "object" }),
|
|
643
|
+
"target" => target_schema(),
|
|
644
|
+
_ => json!({ "type": kind }),
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
fn target_schema() -> Value {
|
|
649
|
+
json!({
|
|
650
|
+
"type": "object",
|
|
651
|
+
"properties": {
|
|
652
|
+
"type": { "type": "string", "enum": ["file", "symbol"] },
|
|
653
|
+
"file": { "type": "string" },
|
|
654
|
+
"symbol": { "type": "string" },
|
|
655
|
+
"export_name": { "type": "string" }
|
|
656
|
+
},
|
|
657
|
+
"required": ["type"],
|
|
658
|
+
"additionalProperties": false
|
|
659
|
+
})
|
|
660
|
+
}
|