-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.json
More file actions
345 lines (345 loc) · 13 KB
/
schema.json
File metadata and controls
345 lines (345 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/bntvllnt/codebase-intelligence/main/schema.json",
"title": "Codebase Intelligence configuration",
"description": "Configuration for the codebase-intelligence CLI, MCP server, and CI gate. Place in a file named codebase-intelligence.json (or .codebase-intelligence.json / .codebase-intelligencerc.json) at the project root.",
"type": "object",
"additionalProperties": false,
"properties": {
"$schema": {
"type": "string",
"description": "Path or URL to this JSON Schema, for editor autocomplete and validation."
},
"root": {
"type": "string",
"description": "Project root to analyze, relative to the config file.",
"default": "."
},
"include": {
"type": "array",
"description": "Glob patterns of files to analyze. Defaults to all .ts/.tsx not ignored.",
"items": { "type": "string" },
"default": ["**/*.ts", "**/*.tsx"]
},
"exclude": {
"type": "array",
"description": "Glob patterns to exclude from analysis (in addition to .gitignore, node_modules, .d.ts).",
"items": { "type": "string" },
"default": ["**/*.test.ts", "**/*.spec.ts", "dist/**"]
},
"entry": {
"type": "array",
"description": "Entry-point files or globs. Exports reachable from entries are never reported as dead. Framework conventions (Next.js routes, Convex functions, test files) are auto-detected on top of this.",
"items": { "type": "string" }
},
"ignore": {
"type": "object",
"description": "Suppress whole categories of findings.",
"additionalProperties": false,
"properties": {
"dependencies": {
"type": "array",
"description": "Package names never reported as unused/unlisted.",
"items": { "type": "string" }
},
"unresolvedImports": {
"type": "array",
"description": "Import specifier patterns to treat as resolvable (e.g. virtual modules).",
"items": { "type": "string" }
},
"exportsUsedInFile": {
"type": "boolean",
"description": "If true, an export referenced anywhere in its own file is not reported as dead.",
"default": false
}
}
},
"rules": {
"type": "object",
"description": "Rule configuration, ESLint-style. Each key is a rule id; the value is a severity ('off' | 'warn' | 'error' or 0 | 1 | 2), or a tuple [severity, options]. Unknown rule ids are validated against the generic entry shape so custom rules are allowed.",
"additionalProperties": { "$ref": "#/$defs/ruleEntry" },
"properties": {
"no-circular-deps": {
"$ref": "#/$defs/severity",
"description": "Forbid circular dependencies between files/modules."
},
"no-dead-exports": {
"$ref": "#/$defs/severity",
"description": "Report exported symbols that are never imported (respecting entry points + framework awareness)."
},
"no-dead-files": {
"$ref": "#/$defs/severity",
"description": "Report files unreachable from any entry point."
},
"no-unused-deps": {
"$ref": "#/$defs/severity",
"description": "Report package.json dependencies that are never imported."
},
"no-duplication": {
"description": "Report duplicated code (clone families).",
"oneOf": [
{ "$ref": "#/$defs/severity" },
{
"type": "array",
"prefixItems": [
{ "$ref": "#/$defs/severity" },
{
"type": "object",
"additionalProperties": false,
"properties": {
"minTokens": { "type": "integer", "minimum": 10, "default": 50 },
"mode": { "enum": ["strict", "mild", "weak"], "default": "mild" },
"skipLocal": { "type": "boolean", "default": false, "description": "Only report clones that span different directories." }
}
}
],
"minItems": 1,
"maxItems": 2
}
]
},
"max-cyclomatic-complexity": {
"description": "Forbid functions above a cyclomatic-complexity threshold.",
"oneOf": [
{ "$ref": "#/$defs/severity" },
{
"type": "array",
"prefixItems": [
{ "$ref": "#/$defs/severity" },
{
"type": "object",
"additionalProperties": false,
"properties": { "max": { "type": "integer", "minimum": 1, "default": 15 } }
}
],
"minItems": 1,
"maxItems": 2
}
]
},
"max-cognitive-complexity": {
"description": "Forbid functions above a cognitive-complexity threshold.",
"oneOf": [
{ "$ref": "#/$defs/severity" },
{
"type": "array",
"prefixItems": [
{ "$ref": "#/$defs/severity" },
{
"type": "object",
"additionalProperties": false,
"properties": { "max": { "type": "integer", "minimum": 1, "default": 20 } }
}
],
"minItems": 1,
"maxItems": 2
}
]
},
"no-boundary-violations": {
"$ref": "#/$defs/severity",
"description": "Forbid imports that cross a forbidden architecture boundary (see top-level 'boundaries')."
},
"no-divergent-paths": {
"description": "Highways gate: forbid more than N divergent code paths for one logical data operation (low data-path reuse).",
"oneOf": [
{ "$ref": "#/$defs/severity" },
{
"type": "array",
"prefixItems": [
{ "$ref": "#/$defs/severity" },
{
"type": "object",
"additionalProperties": false,
"properties": {
"minRoutes": { "type": "integer", "minimum": 2, "default": 3, "description": "Flag an operation group with at least this many divergent routes." },
"maxConvergenceRatio": { "type": "number", "minimum": 0, "maximum": 1, "default": 0.34, "description": "Flag only when shared-intermediate ratio is below this." }
}
}
],
"minItems": 1,
"maxItems": 2
}
]
},
"no-comments": {
"description": "Forbid comments. By default forbids // line comments while allowing JSDoc, compiler/tool directives, and a license header. Set style:'all' to forbid every comment.",
"oneOf": [
{ "$ref": "#/$defs/severity" },
{
"type": "array",
"prefixItems": [
{ "$ref": "#/$defs/severity" },
{
"type": "object",
"additionalProperties": false,
"properties": {
"style": {
"enum": ["line", "block", "all"],
"default": "line",
"description": "Which comment kinds to forbid: 'line' (//), 'block' (/* */), or 'all'."
},
"allowJSDoc": {
"type": "boolean",
"default": true,
"description": "Allow /** ... */ JSDoc/TSDoc blocks."
},
"allowDirectives": {
"type": "boolean",
"default": true,
"description": "Allow directive comments such as @ts-expect-error, @ts-ignore, eslint-disable, and this tool's own ci-ignore comments."
},
"allowLicenseHeader": {
"type": "boolean",
"default": true,
"description": "Allow a comment at the very top of a file (license/banner)."
},
"allow": {
"type": "array",
"description": "Allow comments whose body (delimiters stripped) starts with one of these strings, e.g. 'TODO', 'FIXME', '@public'.",
"items": { "type": "string" }
}
}
}
],
"minItems": 1,
"maxItems": 2
}
]
}
}
},
"boundaries": {
"type": "object",
"description": "Architecture boundary rules. Used by the no-boundary-violations rule.",
"additionalProperties": false,
"properties": {
"preset": {
"enum": ["layered", "hexagonal", "feature-sliced"],
"description": "Start from a preset architecture, then override with zones/rules."
},
"zones": {
"type": "array",
"description": "Named logical areas of the codebase.",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["name", "patterns"],
"properties": {
"name": { "type": "string" },
"patterns": { "type": "array", "items": { "type": "string" } },
"autoDiscover": { "type": "boolean", "default": false }
}
}
},
"rules": {
"type": "array",
"description": "Directed allow/forbid edges between zones.",
"items": {
"type": "object",
"additionalProperties": false,
"required": ["from"],
"properties": {
"from": { "type": "string", "description": "Source zone name." },
"allow": { "type": "array", "items": { "type": "string" }, "description": "Zone names this zone may import." },
"forbid": { "type": "array", "items": { "type": "string" }, "description": "Zone names this zone may not import." }
}
}
}
}
},
"thresholds": {
"type": "object",
"description": "Composite-score gates.",
"additionalProperties": false,
"properties": {
"health": {
"type": "object",
"additionalProperties": false,
"properties": {
"minScore": {
"type": "integer",
"minimum": 0,
"maximum": 100,
"description": "Fail if the 0-100 health score is below this."
}
}
}
}
},
"output": {
"type": "object",
"description": "Default output options (CLI flags override these).",
"additionalProperties": false,
"properties": {
"format": {
"enum": ["text", "json", "sarif", "markdown", "annotations", "pr-comment-github", "pr-comment-gitlab", "badge"],
"default": "text"
},
"quiet": { "type": "boolean", "default": false },
"summary": { "type": "boolean", "default": false }
}
},
"baseline": {
"type": "string",
"description": "Path to a baseline file. When set, the CI gate fails only on findings not present in the baseline."
},
"ci": {
"type": "object",
"description": "Continuous-integration gate behavior.",
"additionalProperties": false,
"properties": {
"gate": {
"enum": ["all", "new-only"],
"default": "new-only",
"description": "Fail on all findings, or only on findings introduced since --base."
},
"failOn": {
"enum": ["error", "warn", "never"],
"default": "error",
"description": "Minimum severity that makes the process exit non-zero."
},
"maxWarnings": {
"type": "integer",
"minimum": -1,
"default": -1,
"description": "Fail if warnings exceed this count. -1 disables the warning gate."
},
"tolerance": {
"type": "number",
"minimum": 0,
"default": 0,
"description": "Allowed percent growth in findings vs baseline before failing."
},
"base": {
"type": "string",
"description": "Git ref to diff against for new-only gating (e.g. origin/main). Overridable with --base."
}
}
}
},
"$defs": {
"severity": {
"description": "Rule severity: 'off' | 'warn' | 'error', or numeric 0 | 1 | 2.",
"oneOf": [
{ "enum": ["off", "warn", "error"] },
{ "enum": [0, 1, 2] }
]
},
"ruleEntry": {
"description": "A rule severity, or a [severity, options] tuple.",
"oneOf": [
{ "$ref": "#/$defs/severity" },
{
"type": "array",
"prefixItems": [
{ "$ref": "#/$defs/severity" },
{ "type": "object" }
],
"minItems": 1,
"maxItems": 2
}
]
}
}
}