Skip to content

Commit 4b44411

Browse files
Vapi Taskerclaude
andcommitted
feat(discovery): add convention file discovery and config types
Adds the foundation for dynamic project checks: - New ConventionsConfig and DiscoveryConfig interfaces in config.ts - Extended ChecksConfig with lint, format, build flags - Extended CommandsConfig with lint, format, build (nullable) commands - New conventions.ts module for discovering convention files - Discovers CLAUDE.md, .cursorrules, .cursor/rules, .claude/settings - Priority-based loading with size limits (100KB/file, 200KB combined) - Deduplication of similar content blocks - UTF-8 text validation and circular symlink detection Part 1 of 4 for VAP-11695. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 68409b2 commit 4b44411

2 files changed

Lines changed: 392 additions & 2 deletions

File tree

src/config.ts

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ export interface CoverageThresholds {
2323
export interface ChecksConfig {
2424
/** Run rules compliance check against project conventions */
2525
rules: boolean
26+
/** Run linting (discovered from package.json) */
27+
lint: boolean
28+
/** Run formatting check (discovered from package.json) */
29+
format: boolean
2630
/** Run TypeScript type checking */
2731
typecheck: boolean
32+
/** Run build (discovered from package.json) */
33+
build: boolean
2834
/** Run test suite */
2935
tests: boolean
3036
/** Run coverage analysis */
@@ -35,8 +41,14 @@ export interface ChecksConfig {
3541
* Commands configuration - npm scripts to run for each check
3642
*/
3743
export interface CommandsConfig {
44+
/** Command to run lint (auto-discovered or manual) */
45+
lint: string | null
46+
/** Command to run format check (auto-discovered or manual) */
47+
format: string | null
3848
/** Command to run typecheck (default: npm run typecheck) */
3949
typecheck: string
50+
/** Command to run build (auto-discovered or manual) */
51+
build: string | null
4052
/** Command to run tests (default: npm run test) */
4153
test: string
4254
/** Command to run tests with coverage (default: npm run test:coverage:ci) */
@@ -47,6 +59,28 @@ export interface CommandsConfig {
4759
testCoverageRelated: string
4860
}
4961

62+
/**
63+
* Convention discovery configuration
64+
*/
65+
export interface ConventionsConfig {
66+
/** Maximum size per convention file in bytes (default: 100KB) */
67+
maxFileSize: number
68+
/** Maximum combined size of all convention files in bytes (default: 200KB) */
69+
maxCombinedSize: number
70+
/** Whether to include source markers when combining files (default: true) */
71+
includeSourceMarkers: boolean
72+
}
73+
74+
/**
75+
* Discovery configuration
76+
*/
77+
export interface DiscoveryConfig {
78+
/** Convention file discovery settings */
79+
conventions: ConventionsConfig
80+
/** Whether to auto-discover scripts from package.json (default: true) */
81+
autoDiscoverScripts: boolean
82+
}
83+
5084
/**
5185
* Coverage scope configuration - patterns for files that require coverage
5286
*/
@@ -79,9 +113,15 @@ export interface BulletproofConfig {
79113
/** Commands to run for each check */
80114
commands: CommandsConfig
81115

82-
/** Path to rules file (default: .cursorrules) */
116+
/**
117+
* Path to rules file (default: .cursorrules)
118+
* @deprecated Use discovery.conventions instead - convention files are now auto-discovered
119+
*/
83120
rulesFile: string
84121

122+
/** Discovery configuration */
123+
discovery: DiscoveryConfig
124+
85125
/** System prompt customization */
86126
systemPrompt?: string
87127

@@ -118,18 +158,32 @@ export const DEFAULT_CONFIG: BulletproofConfig = {
118158
},
119159
checks: {
120160
rules: true,
161+
lint: true,
162+
format: true,
121163
typecheck: true,
164+
build: true,
122165
tests: true,
123166
coverage: true,
124167
},
125168
commands: {
169+
lint: null, // Auto-discovered from package.json
170+
format: null, // Auto-discovered from package.json
126171
typecheck: 'npm run typecheck',
172+
build: null, // Auto-discovered from package.json
127173
test: 'npm run test',
128174
testCoverage: 'npm run test:coverage:ci',
129175
testRelated: 'npm run test:related',
130176
testCoverageRelated: 'npm run test:coverage:related',
131177
},
132-
rulesFile: '.cursorrules',
178+
rulesFile: '.cursorrules', // Deprecated - use discovery.conventions
179+
discovery: {
180+
conventions: {
181+
maxFileSize: 100 * 1024, // 100KB
182+
maxCombinedSize: 200 * 1024, // 200KB
183+
includeSourceMarkers: true,
184+
},
185+
autoDiscoverScripts: true,
186+
},
133187
}
134188

135189
/**
@@ -205,6 +259,15 @@ export function mergeConfig(
205259
...partial.commands,
206260
},
207261
rulesFile: partial.rulesFile ?? defaults.rulesFile,
262+
discovery: {
263+
conventions: {
264+
...defaults.discovery.conventions,
265+
...partial.discovery?.conventions,
266+
},
267+
autoDiscoverScripts:
268+
partial.discovery?.autoDiscoverScripts ??
269+
defaults.discovery.autoDiscoverScripts,
270+
},
208271
systemPrompt: partial.systemPrompt,
209272
additionalInstructions: partial.additionalInstructions,
210273
}

0 commit comments

Comments
 (0)