claude-crap 0.1.2

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 (202) hide show
  1. package/CHANGELOG.md +308 -0
  2. package/LICENSE +21 -0
  3. package/README.md +550 -0
  4. package/bin/claude-crap.mjs +141 -0
  5. package/dist/adapters/bandit.d.ts +48 -0
  6. package/dist/adapters/bandit.d.ts.map +1 -0
  7. package/dist/adapters/bandit.js +145 -0
  8. package/dist/adapters/bandit.js.map +1 -0
  9. package/dist/adapters/common.d.ts +73 -0
  10. package/dist/adapters/common.d.ts.map +1 -0
  11. package/dist/adapters/common.js +78 -0
  12. package/dist/adapters/common.js.map +1 -0
  13. package/dist/adapters/eslint.d.ts +52 -0
  14. package/dist/adapters/eslint.d.ts.map +1 -0
  15. package/dist/adapters/eslint.js +142 -0
  16. package/dist/adapters/eslint.js.map +1 -0
  17. package/dist/adapters/index.d.ts +47 -0
  18. package/dist/adapters/index.d.ts.map +1 -0
  19. package/dist/adapters/index.js +64 -0
  20. package/dist/adapters/index.js.map +1 -0
  21. package/dist/adapters/semgrep.d.ts +30 -0
  22. package/dist/adapters/semgrep.d.ts.map +1 -0
  23. package/dist/adapters/semgrep.js +130 -0
  24. package/dist/adapters/semgrep.js.map +1 -0
  25. package/dist/adapters/stryker.d.ts +55 -0
  26. package/dist/adapters/stryker.d.ts.map +1 -0
  27. package/dist/adapters/stryker.js +165 -0
  28. package/dist/adapters/stryker.js.map +1 -0
  29. package/dist/ast/cyclomatic.d.ts +48 -0
  30. package/dist/ast/cyclomatic.d.ts.map +1 -0
  31. package/dist/ast/cyclomatic.js +106 -0
  32. package/dist/ast/cyclomatic.js.map +1 -0
  33. package/dist/ast/index.d.ts +26 -0
  34. package/dist/ast/index.d.ts.map +1 -0
  35. package/dist/ast/index.js +23 -0
  36. package/dist/ast/index.js.map +1 -0
  37. package/dist/ast/language-config.d.ts +70 -0
  38. package/dist/ast/language-config.d.ts.map +1 -0
  39. package/dist/ast/language-config.js +192 -0
  40. package/dist/ast/language-config.js.map +1 -0
  41. package/dist/ast/tree-sitter-engine.d.ts +133 -0
  42. package/dist/ast/tree-sitter-engine.d.ts.map +1 -0
  43. package/dist/ast/tree-sitter-engine.js +270 -0
  44. package/dist/ast/tree-sitter-engine.js.map +1 -0
  45. package/dist/config.d.ts +57 -0
  46. package/dist/config.d.ts.map +1 -0
  47. package/dist/config.js +78 -0
  48. package/dist/config.js.map +1 -0
  49. package/dist/crap-config.d.ts +97 -0
  50. package/dist/crap-config.d.ts.map +1 -0
  51. package/dist/crap-config.js +144 -0
  52. package/dist/crap-config.js.map +1 -0
  53. package/dist/dashboard/server.d.ts +65 -0
  54. package/dist/dashboard/server.d.ts.map +1 -0
  55. package/dist/dashboard/server.js +147 -0
  56. package/dist/dashboard/server.js.map +1 -0
  57. package/dist/index.d.ts +32 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +574 -0
  60. package/dist/index.js.map +1 -0
  61. package/dist/metrics/crap.d.ts +71 -0
  62. package/dist/metrics/crap.d.ts.map +1 -0
  63. package/dist/metrics/crap.js +67 -0
  64. package/dist/metrics/crap.js.map +1 -0
  65. package/dist/metrics/index.d.ts +31 -0
  66. package/dist/metrics/index.d.ts.map +1 -0
  67. package/dist/metrics/index.js +27 -0
  68. package/dist/metrics/index.js.map +1 -0
  69. package/dist/metrics/score.d.ts +143 -0
  70. package/dist/metrics/score.d.ts.map +1 -0
  71. package/dist/metrics/score.js +224 -0
  72. package/dist/metrics/score.js.map +1 -0
  73. package/dist/metrics/tdr.d.ts +106 -0
  74. package/dist/metrics/tdr.d.ts.map +1 -0
  75. package/dist/metrics/tdr.js +117 -0
  76. package/dist/metrics/tdr.js.map +1 -0
  77. package/dist/metrics/workspace-walker.d.ts +43 -0
  78. package/dist/metrics/workspace-walker.d.ts.map +1 -0
  79. package/dist/metrics/workspace-walker.js +137 -0
  80. package/dist/metrics/workspace-walker.js.map +1 -0
  81. package/dist/sarif/index.d.ts +21 -0
  82. package/dist/sarif/index.d.ts.map +1 -0
  83. package/dist/sarif/index.js +19 -0
  84. package/dist/sarif/index.js.map +1 -0
  85. package/dist/sarif/sarif-builder.d.ts +128 -0
  86. package/dist/sarif/sarif-builder.d.ts.map +1 -0
  87. package/dist/sarif/sarif-builder.js +79 -0
  88. package/dist/sarif/sarif-builder.js.map +1 -0
  89. package/dist/sarif/sarif-store.d.ts +205 -0
  90. package/dist/sarif/sarif-store.d.ts.map +1 -0
  91. package/dist/sarif/sarif-store.js +246 -0
  92. package/dist/sarif/sarif-store.js.map +1 -0
  93. package/dist/sarif/sarif-validator.d.ts +45 -0
  94. package/dist/sarif/sarif-validator.d.ts.map +1 -0
  95. package/dist/sarif/sarif-validator.js +138 -0
  96. package/dist/sarif/sarif-validator.js.map +1 -0
  97. package/dist/schemas/tool-schemas.d.ts +216 -0
  98. package/dist/schemas/tool-schemas.d.ts.map +1 -0
  99. package/dist/schemas/tool-schemas.js +208 -0
  100. package/dist/schemas/tool-schemas.js.map +1 -0
  101. package/dist/sdk.d.ts +45 -0
  102. package/dist/sdk.d.ts.map +1 -0
  103. package/dist/sdk.js +44 -0
  104. package/dist/sdk.js.map +1 -0
  105. package/dist/tools/index.d.ts +24 -0
  106. package/dist/tools/index.d.ts.map +1 -0
  107. package/dist/tools/index.js +23 -0
  108. package/dist/tools/index.js.map +1 -0
  109. package/dist/tools/test-harness.d.ts +75 -0
  110. package/dist/tools/test-harness.d.ts.map +1 -0
  111. package/dist/tools/test-harness.js +137 -0
  112. package/dist/tools/test-harness.js.map +1 -0
  113. package/dist/workspace-guard.d.ts +53 -0
  114. package/dist/workspace-guard.d.ts.map +1 -0
  115. package/dist/workspace-guard.js +61 -0
  116. package/dist/workspace-guard.js.map +1 -0
  117. package/package.json +133 -0
  118. package/plugin/.claude-plugin/plugin.json +29 -0
  119. package/plugin/.mcp.json +18 -0
  120. package/plugin/CLAUDE.md +143 -0
  121. package/plugin/bundle/dashboard/public/index.html +368 -0
  122. package/plugin/bundle/dashboard/public/vendor/vue.global.prod.js +9 -0
  123. package/plugin/bundle/mcp-server.mjs +8718 -0
  124. package/plugin/bundle/mcp-server.mjs.map +7 -0
  125. package/plugin/bundle/tdr-engine.mjs +50 -0
  126. package/plugin/bundle/tdr-engine.mjs.map +7 -0
  127. package/plugin/hooks/hooks.json +62 -0
  128. package/plugin/hooks/lib/crap-config.mjs +152 -0
  129. package/plugin/hooks/lib/gatekeeper-rules.mjs +257 -0
  130. package/plugin/hooks/lib/hook-io.mjs +151 -0
  131. package/plugin/hooks/lib/quality-gate.mjs +329 -0
  132. package/plugin/hooks/lib/test-harness.mjs +152 -0
  133. package/plugin/hooks/post-tool-use.mjs +245 -0
  134. package/plugin/hooks/pre-tool-use.mjs +290 -0
  135. package/plugin/hooks/session-start.mjs +109 -0
  136. package/plugin/hooks/stop-quality-gate.mjs +226 -0
  137. package/plugin/package.json +18 -0
  138. package/plugin/skills/adopt/SKILL.md +74 -0
  139. package/plugin/skills/analyze/SKILL.md +77 -0
  140. package/plugin/skills/check-test/SKILL.md +50 -0
  141. package/plugin/skills/score/SKILL.md +31 -0
  142. package/scripts/bug-report.mjs +328 -0
  143. package/scripts/build-fast.mjs +130 -0
  144. package/scripts/bundle-plugin.mjs +74 -0
  145. package/scripts/doctor.mjs +320 -0
  146. package/scripts/install.mjs +192 -0
  147. package/scripts/lib/cli-ui.mjs +122 -0
  148. package/scripts/postinstall.mjs +127 -0
  149. package/scripts/run-tests.mjs +95 -0
  150. package/scripts/status.mjs +110 -0
  151. package/scripts/uninstall.mjs +72 -0
  152. package/src/adapters/bandit.ts +191 -0
  153. package/src/adapters/common.ts +133 -0
  154. package/src/adapters/eslint.ts +187 -0
  155. package/src/adapters/index.ts +78 -0
  156. package/src/adapters/semgrep.ts +150 -0
  157. package/src/adapters/stryker.ts +218 -0
  158. package/src/ast/cyclomatic.ts +131 -0
  159. package/src/ast/index.ts +33 -0
  160. package/src/ast/language-config.ts +231 -0
  161. package/src/ast/tree-sitter-engine.ts +385 -0
  162. package/src/config.ts +109 -0
  163. package/src/crap-config.ts +196 -0
  164. package/src/dashboard/public/index.html +368 -0
  165. package/src/dashboard/public/vendor/vue.global.prod.js +9 -0
  166. package/src/dashboard/server.ts +205 -0
  167. package/src/index.ts +696 -0
  168. package/src/metrics/crap.ts +101 -0
  169. package/src/metrics/index.ts +51 -0
  170. package/src/metrics/score.ts +329 -0
  171. package/src/metrics/tdr.ts +155 -0
  172. package/src/metrics/workspace-walker.ts +146 -0
  173. package/src/sarif/index.ts +31 -0
  174. package/src/sarif/sarif-builder.ts +139 -0
  175. package/src/sarif/sarif-store.ts +347 -0
  176. package/src/sarif/sarif-validator.ts +145 -0
  177. package/src/schemas/tool-schemas.ts +225 -0
  178. package/src/sdk.ts +110 -0
  179. package/src/tests/adapters/bandit.test.ts +111 -0
  180. package/src/tests/adapters/dispatch.test.ts +100 -0
  181. package/src/tests/adapters/eslint.test.ts +138 -0
  182. package/src/tests/adapters/semgrep.test.ts +125 -0
  183. package/src/tests/adapters/stryker.test.ts +103 -0
  184. package/src/tests/crap-config.test.ts +228 -0
  185. package/src/tests/crap.test.ts +59 -0
  186. package/src/tests/cyclomatic.test.ts +87 -0
  187. package/src/tests/dashboard-http.test.ts +108 -0
  188. package/src/tests/dashboard-integrity.test.ts +128 -0
  189. package/src/tests/integration/mcp-server.integration.test.ts +352 -0
  190. package/src/tests/pre-tool-use-hook.test.ts +178 -0
  191. package/src/tests/sarif-store.test.ts +241 -0
  192. package/src/tests/sarif-validator.test.ts +164 -0
  193. package/src/tests/score.test.ts +260 -0
  194. package/src/tests/skills-frontmatter.test.ts +172 -0
  195. package/src/tests/stop-quality-gate-strictness.test.ts +243 -0
  196. package/src/tests/tdr.test.ts +86 -0
  197. package/src/tests/test-harness.test.ts +153 -0
  198. package/src/tests/workspace-guard.test.ts +111 -0
  199. package/src/tools/index.ts +24 -0
  200. package/src/tools/test-harness.ts +158 -0
  201. package/src/workspace-guard.ts +64 -0
  202. package/tsconfig.json +27 -0
@@ -0,0 +1,138 @@
1
+ /**
2
+ * AJV-backed minimal SARIF 2.1.0 document validator.
3
+ *
4
+ * F-A05-01: the `ingest_sarif` MCP tool accepts a caller-supplied
5
+ * `sarifDocument` object and, before this module existed, only
6
+ * checked `version === "2.1.0"`. That was enough for tool-call
7
+ * dispatch but not for the payload itself — a SARIF with a missing
8
+ * `runs[]`, a `results` array of wrong-type entries, or a result
9
+ * without a `ruleId` would still be accepted by the MCP tool and
10
+ * flow through to the store, the dashboard, and any downstream
11
+ * consumer that uploads claude-crap's SARIF to GitHub code-scanning
12
+ * or an IDE viewer.
13
+ *
14
+ * This module uses the `ajv` dependency (already in package.json) to
15
+ * compile a minimal JSON Schema that covers exactly the fields
16
+ * claude-crap reads: `version`, `runs`, `runs[].tool.driver.name`,
17
+ * and the per-result shape. Everything else (tool metadata, rule
18
+ * definitions, snippets, etc.) is passthrough — we do not enforce
19
+ * the full SARIF 2.1.0 spec because claude-crap does not consume
20
+ * those fields.
21
+ *
22
+ * The compiled validator is cached so the ~5 ms AJV compile cost is
23
+ * paid once per MCP server process, not once per ingestion.
24
+ *
25
+ * @module sarif/sarif-validator
26
+ */
27
+ import { Ajv } from "ajv";
28
+ /**
29
+ * Minimal JSON Schema covering every field claude-crap reads from a
30
+ * SARIF 2.1.0 document. Passthrough fields are allowed because
31
+ * `additionalProperties` is left at the default (`true`).
32
+ *
33
+ * Keep this schema in sync with `hydrateFindingFromResult` in
34
+ * `src/sarif/sarif-store.ts` — anything the store reads MUST be
35
+ * covered here, and nothing else should be enforced.
36
+ */
37
+ const SARIF_MINIMAL_SCHEMA = {
38
+ type: "object",
39
+ properties: {
40
+ version: { type: "string", enum: ["2.1.0"] },
41
+ $schema: { type: "string" },
42
+ runs: {
43
+ type: "array",
44
+ items: {
45
+ type: "object",
46
+ properties: {
47
+ tool: {
48
+ type: "object",
49
+ properties: {
50
+ driver: {
51
+ type: "object",
52
+ properties: {
53
+ name: { type: "string", minLength: 1 },
54
+ version: { type: "string" },
55
+ },
56
+ required: ["name"],
57
+ },
58
+ },
59
+ required: ["driver"],
60
+ },
61
+ results: {
62
+ type: "array",
63
+ items: {
64
+ type: "object",
65
+ properties: {
66
+ ruleId: { type: "string", minLength: 1 },
67
+ level: { type: "string", enum: ["none", "note", "warning", "error"] },
68
+ message: {
69
+ type: "object",
70
+ properties: { text: { type: "string", minLength: 1 } },
71
+ required: ["text"],
72
+ },
73
+ locations: { type: "array" },
74
+ properties: { type: "object" },
75
+ },
76
+ required: ["ruleId", "message"],
77
+ },
78
+ },
79
+ },
80
+ required: ["tool", "results"],
81
+ },
82
+ },
83
+ },
84
+ required: ["version", "runs"],
85
+ };
86
+ /**
87
+ * Lazily-compiled validator instance. `null` until the first call to
88
+ * {@link validateSarifDocument}, then reused for the lifetime of the
89
+ * process.
90
+ */
91
+ let cachedValidator = null;
92
+ /**
93
+ * Returned by {@link validateSarifDocument} when the document fails
94
+ * schema validation. Includes the full AJV error array for callers
95
+ * that want to surface structured diagnostics.
96
+ */
97
+ export class SarifValidationError extends Error {
98
+ errors;
99
+ constructor(message, errors) {
100
+ super(message);
101
+ this.name = "SarifValidationError";
102
+ this.errors = errors;
103
+ }
104
+ }
105
+ /**
106
+ * Obtain the compiled AJV validator, compiling on first use.
107
+ *
108
+ * The schema above intentionally allows passthrough fields on every
109
+ * object (AJV's default `additionalProperties: true`). We disable
110
+ * `strict` so AJV does not warn about benign constructs like the
111
+ * `format`/`enum` combination.
112
+ */
113
+ function getValidator() {
114
+ if (cachedValidator)
115
+ return cachedValidator;
116
+ const ajv = new Ajv({ allErrors: false, strict: false });
117
+ const validator = ajv.compile(SARIF_MINIMAL_SCHEMA);
118
+ cachedValidator = validator;
119
+ return validator;
120
+ }
121
+ /**
122
+ * Validate a SARIF 2.1.0 document against the minimal schema. Throws
123
+ * {@link SarifValidationError} when the document does not match.
124
+ *
125
+ * @param doc Document to validate. May be any value — the validator
126
+ * treats non-object inputs as a schema violation.
127
+ * @throws {@link SarifValidationError} on any validation failure.
128
+ */
129
+ export function validateSarifDocument(doc) {
130
+ const validator = getValidator();
131
+ if (validator(doc))
132
+ return;
133
+ const first = validator.errors?.[0];
134
+ const path = first?.instancePath?.length ? first.instancePath : "<root>";
135
+ const message = first?.message ?? "unknown validation error";
136
+ throw new SarifValidationError(`[sarif-validator] SARIF document is not valid 2.1.0: ${path} ${message}`, validator.errors ?? null);
137
+ }
138
+ //# sourceMappingURL=sarif-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sarif-validator.js","sourceRoot":"","sources":["../../src/sarif/sarif-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,GAAG,EAAyB,MAAM,KAAK,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,oBAAoB,GAAG;IAC3B,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;QAC5C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC3B,IAAI,EAAE;YACJ,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,MAAM,EAAE;gCACN,IAAI,EAAE,QAAQ;gCACd,UAAU,EAAE;oCACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE;oCACtC,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iCAC5B;gCACD,QAAQ,EAAE,CAAC,MAAM,CAAC;6BACnB;yBACF;wBACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;qBACrB;oBACD,OAAO,EAAE;wBACP,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE;4BACL,IAAI,EAAE,Q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OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpD,eAAe,GAAG,SAAS,CAAC;IAC5B,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,IAAI,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO;IAC3B,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzE,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,0BAA0B,CAAC;IAC7D,MAAM,IAAI,oBAAoB,CAC5B,wDAAwD,IAAI,IAAI,OAAO,EAAE,EACzE,SAAS,CAAC,MAAM,IAAI,IAAI,CACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,216 @@
1
+ /**
2
+ * JSON Schema (Draft-07) definitions for every tool exposed by the MCP server.
3
+ *
4
+ * Each schema uses `enum`, `pattern`, `minimum`, `maximum`, `oneOf` and
5
+ * `additionalProperties: false` to eliminate schema hallucinations from the
6
+ * LLM. The MCP SDK automatically validates tool-call inputs against these
7
+ * schemas before invoking the handler — any drift produces a deterministic
8
+ * error that the agent can consume and correct.
9
+ *
10
+ * These `description` fields are read by the LLM at tool-listing time and
11
+ * become part of the agent's context, so they must be precise, imperative,
12
+ * and never speculative. Keep them short but actionable.
13
+ *
14
+ * @module schemas/tool-schemas
15
+ */
16
+ /**
17
+ * Schema for the `compute_crap` tool. Returns a CRAP score for a single
18
+ * function and a block decision against the configured threshold.
19
+ */
20
+ export declare const computeCrapSchema: {
21
+ readonly type: "object";
22
+ readonly description: "Compute the CRAP (Change Risk Anti-Patterns) index for a single function. Returns the score and whether it exceeds the configured threshold. A blocked result means the function must be decomposed or covered by more tests before the Stop quality gate will pass.";
23
+ readonly properties: {
24
+ readonly cyclomaticComplexity: {
25
+ readonly type: "integer";
26
+ readonly minimum: 1;
27
+ readonly maximum: 1000;
28
+ readonly description: "Cyclomatic complexity of the function (number of linearly independent paths).";
29
+ };
30
+ readonly coveragePercent: {
31
+ readonly type: "number";
32
+ readonly minimum: 0;
33
+ readonly maximum: 100;
34
+ readonly description: "Test coverage percentage for the function, in the range [0, 100].";
35
+ };
36
+ readonly functionName: {
37
+ readonly type: "string";
38
+ readonly pattern: "^[A-Za-z_$][A-Za-z0-9_$.:<>]*$";
39
+ readonly minLength: 1;
40
+ readonly maxLength: 256;
41
+ readonly description: "Fully qualified name of the function under analysis, used for SARIF traceability.";
42
+ };
43
+ readonly filePath: {
44
+ readonly type: "string";
45
+ readonly minLength: 1;
46
+ readonly maxLength: 4096;
47
+ readonly description: "Absolute or workspace-relative path to the source file that contains the function.";
48
+ };
49
+ };
50
+ readonly required: readonly ["cyclomaticComplexity", "coveragePercent", "functionName", "filePath"];
51
+ readonly additionalProperties: false;
52
+ };
53
+ /**
54
+ * Schema for the `compute_tdr` tool. Returns a Technical Debt Ratio and a
55
+ * maintainability letter rating for a scope (project, module, or file).
56
+ */
57
+ export declare const computeTdrSchema: {
58
+ readonly type: "object";
59
+ readonly description: "Compute the Technical Debt Ratio (TDR) for a scope and return the maintainability letter rating (A..E). Rating E always halts the workflow regardless of the configured tolerance. Use this after aggregating remediation estimates from SARIF findings.";
60
+ readonly properties: {
61
+ readonly remediationMinutes: {
62
+ readonly type: "number";
63
+ readonly minimum: 0;
64
+ readonly maximum: 10000000;
65
+ readonly description: "Total estimated remediation effort in minutes, summed across every finding in the scope.";
66
+ };
67
+ readonly totalLinesOfCode: {
68
+ readonly type: "integer";
69
+ readonly minimum: 1;
70
+ readonly maximum: 100000000;
71
+ readonly description: "Physical lines of code in the scope (project, module, or file).";
72
+ };
73
+ readonly scope: {
74
+ readonly type: "string";
75
+ readonly enum: readonly ["project", "module", "file"];
76
+ readonly description: "Aggregation scope for the TDR computation.";
77
+ };
78
+ };
79
+ readonly required: readonly ["remediationMinutes", "totalLinesOfCode", "scope"];
80
+ readonly additionalProperties: false;
81
+ };
82
+ /**
83
+ * Schema for the `analyze_file_ast` tool. Returns deterministic AST
84
+ * metrics (LOC, cyclomatic complexity, node counts) for a source file.
85
+ */
86
+ export declare const analyzeFileAstSchema: {
87
+ readonly type: "object";
88
+ readonly description: "Parse a source file with tree-sitter and return deterministic metrics (lines of code, cyclomatic complexity per function, top-level node counts). Prefer this tool over reading the file directly — it is faster and will not bloat the agent context.";
89
+ readonly properties: {
90
+ readonly filePath: {
91
+ readonly type: "string";
92
+ readonly minLength: 1;
93
+ readonly maxLength: 4096;
94
+ readonly pattern: "^(?!.*\\.\\./).*$";
95
+ readonly description: "Path to the file to analyze. Paths containing `../` are rejected to prevent workspace escape.";
96
+ };
97
+ readonly language: {
98
+ readonly type: "string";
99
+ readonly enum: readonly ["csharp", "javascript", "typescript", "python", "java"];
100
+ readonly description: "Source language of the file. Determines which tree-sitter grammar to load.";
101
+ };
102
+ };
103
+ readonly required: readonly ["filePath", "language"];
104
+ readonly additionalProperties: false;
105
+ };
106
+ /**
107
+ * Schema for the `score_project` tool. Aggregates the latest SARIF
108
+ * report and the workspace size into a single project score with
109
+ * Maintainability / Reliability / Security letter grades, an overall
110
+ * grade, the dashboard URL (when running), and the SARIF report path.
111
+ */
112
+ export declare const scoreProjectSchema: {
113
+ readonly type: "object";
114
+ readonly description: "Compute the aggregate project score (Maintainability / Reliability / Security / Overall A..E), and return both a chat-friendly Markdown summary and a structured JSON snapshot. Includes the local dashboard URL and the consolidated SARIF report path so the user can drill in without opening any extra tooling.";
115
+ readonly properties: {
116
+ readonly format: {
117
+ readonly type: "string";
118
+ readonly enum: readonly ["markdown", "json", "both"];
119
+ readonly description: "Output format. `markdown` returns only the chat summary, `json` returns only the structured snapshot, `both` (default) returns both as separate content blocks.";
120
+ };
121
+ };
122
+ readonly required: readonly [];
123
+ readonly additionalProperties: false;
124
+ };
125
+ /**
126
+ * Schema for the `require_test_harness` tool. Checks whether a production
127
+ * source file has an accompanying test file in any of the conventional
128
+ * locations the resolver supports (sibling `.test.`, `__tests__/`, mirror
129
+ * tree, Python `test_` prefix).
130
+ */
131
+ export declare const requireTestHarnessSchema: {
132
+ readonly type: "object";
133
+ readonly description: "Check whether a production source file has a matching test file. Returns the first existing test path, or the full list of paths the resolver probed when none exists. Use this BEFORE writing any functional code — the CLAUDE.md Golden Rule requires a test harness to exist first.";
134
+ readonly properties: {
135
+ readonly filePath: {
136
+ readonly type: "string";
137
+ readonly minLength: 1;
138
+ readonly maxLength: 4096;
139
+ readonly pattern: "^(?!.*\\.\\./).*$";
140
+ readonly description: "Path to the production file. Paths containing `../` are rejected to prevent workspace escape.";
141
+ };
142
+ };
143
+ readonly required: readonly ["filePath"];
144
+ readonly additionalProperties: false;
145
+ };
146
+ /**
147
+ * Schema for the `ingest_scanner_output` tool. Accepts a scanner
148
+ * identifier (Semgrep, ESLint, Bandit, Stryker) plus that scanner's
149
+ * native output (SARIF or JSON), routes the input through the
150
+ * matching adapter in `src/adapters/`, and persists the normalized
151
+ * SARIF 2.1.0 document in the store.
152
+ *
153
+ * This tool is the preferred path for ingesting scanner output that
154
+ * is not already SARIF — `ingest_sarif` remains the right choice
155
+ * when you already have a SARIF document and just need deduplication.
156
+ */
157
+ export declare const ingestScannerOutputSchema: {
158
+ readonly type: "object";
159
+ readonly description: "Ingest a scanner's native output (Semgrep SARIF, ESLint JSON, Bandit JSON, or Stryker JSON), route it through the matching adapter, enrich every finding with an effort estimate, and persist the normalized SARIF 2.1.0 document. Prefer this tool over `ingest_sarif` whenever the scanner does not emit SARIF natively.";
160
+ readonly properties: {
161
+ readonly scanner: {
162
+ readonly type: "string";
163
+ readonly enum: readonly ["semgrep", "eslint", "bandit", "stryker"];
164
+ readonly description: "Identifier of the producing scanner.";
165
+ };
166
+ readonly rawOutput: {
167
+ readonly description: "The scanner's native output. Accepts either a JSON string (as produced by the scanner's CLI) or a pre-parsed JSON object / array.";
168
+ readonly oneOf: readonly [{
169
+ readonly type: "string";
170
+ }, {
171
+ readonly type: "object";
172
+ }, {
173
+ readonly type: "array";
174
+ }];
175
+ };
176
+ };
177
+ readonly required: readonly ["scanner", "rawOutput"];
178
+ readonly additionalProperties: false;
179
+ };
180
+ /**
181
+ * Schema for the `ingest_sarif` tool. Accepts a raw SARIF 2.1.0 document
182
+ * from an external scanner, deduplicates against the internal store, and
183
+ * normalizes the output into claude-crap's canonical format.
184
+ */
185
+ export declare const ingestSarifSchema: {
186
+ readonly type: "object";
187
+ readonly description: "Ingest a raw SARIF 2.1.0 report produced by an external scanner (Semgrep, ESLint, Bandit, Stryker, etc.), deduplicate it against the internal store, and return the normalized document. The agent should call this once per scanner invocation, not once per finding.";
188
+ readonly properties: {
189
+ readonly sarifDocument: {
190
+ readonly type: "object";
191
+ readonly description: "A full SARIF 2.1.0 document with `version` and `runs` keys.";
192
+ readonly properties: {
193
+ readonly version: {
194
+ readonly type: "string";
195
+ readonly enum: readonly ["2.1.0"];
196
+ };
197
+ readonly $schema: {
198
+ readonly type: "string";
199
+ };
200
+ readonly runs: {
201
+ readonly type: "array";
202
+ readonly minItems: 1;
203
+ };
204
+ };
205
+ readonly required: readonly ["version", "runs"];
206
+ };
207
+ readonly sourceTool: {
208
+ readonly type: "string";
209
+ readonly pattern: "^[a-zA-Z0-9._-]{1,64}$";
210
+ readonly description: "Stable identifier of the tool that produced the report (`semgrep`, `eslint`, `bandit`, ...).";
211
+ };
212
+ };
213
+ readonly required: readonly ["sarifDocument", "sourceTool"];
214
+ readonly additionalProperties: false;
215
+ };
216
+ //# sourceMappingURL=tool-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/tool-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCpB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;CAyBnB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;CAuBvB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;CAcrB,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;CAgB3B,CAAC;AAEX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;CAkB5B,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuBpB,CAAC"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * JSON Schema (Draft-07) definitions for every tool exposed by the MCP server.
3
+ *
4
+ * Each schema uses `enum`, `pattern`, `minimum`, `maximum`, `oneOf` and
5
+ * `additionalProperties: false` to eliminate schema hallucinations from the
6
+ * LLM. The MCP SDK automatically validates tool-call inputs against these
7
+ * schemas before invoking the handler — any drift produces a deterministic
8
+ * error that the agent can consume and correct.
9
+ *
10
+ * These `description` fields are read by the LLM at tool-listing time and
11
+ * become part of the agent's context, so they must be precise, imperative,
12
+ * and never speculative. Keep them short but actionable.
13
+ *
14
+ * @module schemas/tool-schemas
15
+ */
16
+ // The MCP SDK consumes these as the `inputSchema` field of a Tool. We type
17
+ // them with `as const` so TypeScript infers literal types and the MCP SDK
18
+ // accepts them without runtime casting.
19
+ /**
20
+ * Schema for the `compute_crap` tool. Returns a CRAP score for a single
21
+ * function and a block decision against the configured threshold.
22
+ */
23
+ export const computeCrapSchema = {
24
+ type: "object",
25
+ description: "Compute the CRAP (Change Risk Anti-Patterns) index for a single function. Returns the score and whether it exceeds the configured threshold. A blocked result means the function must be decomposed or covered by more tests before the Stop quality gate will pass.",
26
+ properties: {
27
+ cyclomaticComplexity: {
28
+ type: "integer",
29
+ minimum: 1,
30
+ maximum: 1000,
31
+ description: "Cyclomatic complexity of the function (number of linearly independent paths).",
32
+ },
33
+ coveragePercent: {
34
+ type: "number",
35
+ minimum: 0,
36
+ maximum: 100,
37
+ description: "Test coverage percentage for the function, in the range [0, 100].",
38
+ },
39
+ functionName: {
40
+ type: "string",
41
+ pattern: "^[A-Za-z_$][A-Za-z0-9_$.:<>]*$",
42
+ minLength: 1,
43
+ maxLength: 256,
44
+ description: "Fully qualified name of the function under analysis, used for SARIF traceability.",
45
+ },
46
+ filePath: {
47
+ type: "string",
48
+ minLength: 1,
49
+ maxLength: 4096,
50
+ description: "Absolute or workspace-relative path to the source file that contains the function.",
51
+ },
52
+ },
53
+ required: ["cyclomaticComplexity", "coveragePercent", "functionName", "filePath"],
54
+ additionalProperties: false,
55
+ };
56
+ /**
57
+ * Schema for the `compute_tdr` tool. Returns a Technical Debt Ratio and a
58
+ * maintainability letter rating for a scope (project, module, or file).
59
+ */
60
+ export const computeTdrSchema = {
61
+ type: "object",
62
+ description: "Compute the Technical Debt Ratio (TDR) for a scope and return the maintainability letter rating (A..E). Rating E always halts the workflow regardless of the configured tolerance. Use this after aggregating remediation estimates from SARIF findings.",
63
+ properties: {
64
+ remediationMinutes: {
65
+ type: "number",
66
+ minimum: 0,
67
+ maximum: 10_000_000,
68
+ description: "Total estimated remediation effort in minutes, summed across every finding in the scope.",
69
+ },
70
+ totalLinesOfCode: {
71
+ type: "integer",
72
+ minimum: 1,
73
+ maximum: 100_000_000,
74
+ description: "Physical lines of code in the scope (project, module, or file).",
75
+ },
76
+ scope: {
77
+ type: "string",
78
+ enum: ["project", "module", "file"],
79
+ description: "Aggregation scope for the TDR computation.",
80
+ },
81
+ },
82
+ required: ["remediationMinutes", "totalLinesOfCode", "scope"],
83
+ additionalProperties: false,
84
+ };
85
+ /**
86
+ * Schema for the `analyze_file_ast` tool. Returns deterministic AST
87
+ * metrics (LOC, cyclomatic complexity, node counts) for a source file.
88
+ */
89
+ export const analyzeFileAstSchema = {
90
+ type: "object",
91
+ description: "Parse a source file with tree-sitter and return deterministic metrics (lines of code, cyclomatic complexity per function, top-level node counts). Prefer this tool over reading the file directly — it is faster and will not bloat the agent context.",
92
+ properties: {
93
+ filePath: {
94
+ type: "string",
95
+ minLength: 1,
96
+ maxLength: 4096,
97
+ // The lookahead pattern rejects any path traversal (`../`) to prevent
98
+ // the LLM from reading files outside the workspace. Any absolute path
99
+ // that does not contain `../` is still allowed.
100
+ pattern: "^(?!.*\\.\\./).*$",
101
+ description: "Path to the file to analyze. Paths containing `../` are rejected to prevent workspace escape.",
102
+ },
103
+ language: {
104
+ type: "string",
105
+ enum: ["csharp", "javascript", "typescript", "python", "java"],
106
+ description: "Source language of the file. Determines which tree-sitter grammar to load.",
107
+ },
108
+ },
109
+ required: ["filePath", "language"],
110
+ additionalProperties: false,
111
+ };
112
+ /**
113
+ * Schema for the `score_project` tool. Aggregates the latest SARIF
114
+ * report and the workspace size into a single project score with
115
+ * Maintainability / Reliability / Security letter grades, an overall
116
+ * grade, the dashboard URL (when running), and the SARIF report path.
117
+ */
118
+ export const scoreProjectSchema = {
119
+ type: "object",
120
+ description: "Compute the aggregate project score (Maintainability / Reliability / Security / Overall A..E), and return both a chat-friendly Markdown summary and a structured JSON snapshot. Includes the local dashboard URL and the consolidated SARIF report path so the user can drill in without opening any extra tooling.",
121
+ properties: {
122
+ format: {
123
+ type: "string",
124
+ enum: ["markdown", "json", "both"],
125
+ description: "Output format. `markdown` returns only the chat summary, `json` returns only the structured snapshot, `both` (default) returns both as separate content blocks.",
126
+ },
127
+ },
128
+ required: [],
129
+ additionalProperties: false,
130
+ };
131
+ /**
132
+ * Schema for the `require_test_harness` tool. Checks whether a production
133
+ * source file has an accompanying test file in any of the conventional
134
+ * locations the resolver supports (sibling `.test.`, `__tests__/`, mirror
135
+ * tree, Python `test_` prefix).
136
+ */
137
+ export const requireTestHarnessSchema = {
138
+ type: "object",
139
+ description: "Check whether a production source file has a matching test file. Returns the first existing test path, or the full list of paths the resolver probed when none exists. Use this BEFORE writing any functional code — the CLAUDE.md Golden Rule requires a test harness to exist first.",
140
+ properties: {
141
+ filePath: {
142
+ type: "string",
143
+ minLength: 1,
144
+ maxLength: 4096,
145
+ pattern: "^(?!.*\\.\\./).*$",
146
+ description: "Path to the production file. Paths containing `../` are rejected to prevent workspace escape.",
147
+ },
148
+ },
149
+ required: ["filePath"],
150
+ additionalProperties: false,
151
+ };
152
+ /**
153
+ * Schema for the `ingest_scanner_output` tool. Accepts a scanner
154
+ * identifier (Semgrep, ESLint, Bandit, Stryker) plus that scanner's
155
+ * native output (SARIF or JSON), routes the input through the
156
+ * matching adapter in `src/adapters/`, and persists the normalized
157
+ * SARIF 2.1.0 document in the store.
158
+ *
159
+ * This tool is the preferred path for ingesting scanner output that
160
+ * is not already SARIF — `ingest_sarif` remains the right choice
161
+ * when you already have a SARIF document and just need deduplication.
162
+ */
163
+ export const ingestScannerOutputSchema = {
164
+ type: "object",
165
+ description: "Ingest a scanner's native output (Semgrep SARIF, ESLint JSON, Bandit JSON, or Stryker JSON), route it through the matching adapter, enrich every finding with an effort estimate, and persist the normalized SARIF 2.1.0 document. Prefer this tool over `ingest_sarif` whenever the scanner does not emit SARIF natively.",
166
+ properties: {
167
+ scanner: {
168
+ type: "string",
169
+ enum: ["semgrep", "eslint", "bandit", "stryker"],
170
+ description: "Identifier of the producing scanner.",
171
+ },
172
+ rawOutput: {
173
+ description: "The scanner's native output. Accepts either a JSON string (as produced by the scanner's CLI) or a pre-parsed JSON object / array.",
174
+ oneOf: [{ type: "string" }, { type: "object" }, { type: "array" }],
175
+ },
176
+ },
177
+ required: ["scanner", "rawOutput"],
178
+ additionalProperties: false,
179
+ };
180
+ /**
181
+ * Schema for the `ingest_sarif` tool. Accepts a raw SARIF 2.1.0 document
182
+ * from an external scanner, deduplicates against the internal store, and
183
+ * normalizes the output into claude-crap's canonical format.
184
+ */
185
+ export const ingestSarifSchema = {
186
+ type: "object",
187
+ description: "Ingest a raw SARIF 2.1.0 report produced by an external scanner (Semgrep, ESLint, Bandit, Stryker, etc.), deduplicate it against the internal store, and return the normalized document. The agent should call this once per scanner invocation, not once per finding.",
188
+ properties: {
189
+ sarifDocument: {
190
+ type: "object",
191
+ description: "A full SARIF 2.1.0 document with `version` and `runs` keys.",
192
+ properties: {
193
+ version: { type: "string", enum: ["2.1.0"] },
194
+ $schema: { type: "string" },
195
+ runs: { type: "array", minItems: 1 },
196
+ },
197
+ required: ["version", "runs"],
198
+ },
199
+ sourceTool: {
200
+ type: "string",
201
+ pattern: "^[a-zA-Z0-9._-]{1,64}$",
202
+ description: "Stable identifier of the tool that produced the report (`semgrep`, `eslint`, `bandit`, ...).",
203
+ },
204
+ },
205
+ required: ["sarifDocument", "sourceTool"],
206
+ additionalProperties: false,
207
+ };
208
+ //# sourceMappingURL=tool-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-schemas.js","sourceRoot":"","sources":["../../src/schemas/tool-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2EAA2E;AAC3E,0EAA0E;AAC1E,wCAAwC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,sQAAsQ;IACxQ,UAAU,EAAE;QACV,oBAAoB,EAAE;YACpB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,+EAA+E;SAC7F;QACD,eAAe,EAAE;YACf,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,GAAG;YACZ,WAAW,EAAE,mEAAmE;SACjF;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,gCAAgC;YACzC,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,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,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;SACnE;KACF;IACD,QAAQ,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC;IAClC,oBAAoB,EAAE,KAAK;CACnB,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,QAAQ;IACd,WAAW,EACT,wQAAwQ;IAC1Q,UAAU,EAAE;QACV,aAAa,EAAE;YACb,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6DAA6D;YAC1E,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE;gBAC5C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE;aACrC;YACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;SAC9B;QACD,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,wBAAwB;YACjC,WAAW,EAAE,8FAA8F;SAC5G;KACF;IACD,QAAQ,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;IACzC,oBAAoB,EAAE,KAAK;CACnB,CAAC"}
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Root public SDK for `claude-crap`.
3
+ *
4
+ * This is the module you get when you do
5
+ * `import ... from "claude-crap"`. It is intentionally
6
+ * **side-effect-free**: importing this file does NOT start the MCP
7
+ * server, does NOT open the dashboard, does NOT touch the filesystem.
8
+ * Only the executable entrypoint in `dist/index.js` boots the
9
+ * server — that file is invoked by the `.mcp.json` command and the
10
+ * CLI bin, never as a library.
11
+ *
12
+ * Structure:
13
+ *
14
+ * - `./metrics` — CRAP, TDR, project score, workspace walker
15
+ * - `./sarif` — SARIF 2.1.0 builder and on-disk store
16
+ * - `./ast` — tree-sitter engine, cyclomatic complexity, language config
17
+ * - `./tools` — test-harness resolver used by `require_test_harness`
18
+ *
19
+ * Prefer deep imports
20
+ * (`import { computeCrap } from "claude-crap/metrics"`) over
21
+ * pulling everything through the root — they give TypeScript more
22
+ * precise type information and help tree-shakers drop unused modules.
23
+ *
24
+ * The symbols re-exported here are the ones most code paths need:
25
+ *
26
+ * - `computeCrap`, `computeTdr`, `computeProjectScore`
27
+ * - `renderProjectScoreMarkdown`
28
+ * - `classifyTdr`, `ratingIsWorseThan`
29
+ * - `SarifStore`, `buildSarifDocument`
30
+ * - `TreeSitterEngine`
31
+ *
32
+ * @module claude-crap
33
+ */
34
+ export { computeCrap, computeTdr, classifyTdr, ratingIsWorseThan, ratingToRank, computeProjectScore, renderProjectScoreMarkdown, estimateWorkspaceLoc, } from "./metrics/index.js";
35
+ export type { CrapInput, CrapResult, TdrInput, TdrResult, ComputeProjectScoreInput, DimensionScore, FindingsSummary, MaintainabilityScore, ProjectScore, ScoreLocation, SeverityRating, WorkspaceStats, WorkspaceWalkResult, } from "./metrics/index.js";
36
+ export { SarifStore, buildSarifDocument } from "./sarif/index.js";
37
+ export type { IngestedFinding, PersistedSarif, SarifFinding, SarifLevel, SarifLocation, SarifStoreOptions, SarifToolInfo, } from "./sarif/index.js";
38
+ export { TreeSitterEngine, computeCyclomaticComplexity, detectLanguageFromPath, LANGUAGE_TABLE, } from "./ast/index.js";
39
+ export type { AnalyzeFileRequest, AstNode, FileMetrics, FunctionMetrics, LanguageConfig, SupportedLanguage, TreeSitterEngineOptions, } from "./ast/index.js";
40
+ export { findTestFile, isTestFile, candidatePaths } from "./tools/index.js";
41
+ export type { TestFileResolution } from "./tools/index.js";
42
+ export { adaptScannerOutput, adaptSemgrep, adaptEslint, adaptBandit, adaptStryker, KNOWN_SCANNERS, } from "./adapters/index.js";
43
+ export type { AdapterResult, KnownScanner } from "./adapters/index.js";
44
+ export type { MaintainabilityRating, CrapConfig } from "./config.js";
45
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,SAAS,EACT,UAAU,EACV,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,cAAc,EACd,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EACV,eAAe,EACf,cAAc,EACd,YAAY,EACZ,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,sBAAsB,EACtB,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5E,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,M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