@soulbatical/tetra-dev-toolkit 1.1.0

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 (39) hide show
  1. package/README.md +312 -0
  2. package/bin/vca-audit.js +90 -0
  3. package/bin/vca-dev-token.js +39 -0
  4. package/bin/vca-setup.js +227 -0
  5. package/lib/checks/codeQuality/api-response-format.js +268 -0
  6. package/lib/checks/health/claude-md.js +114 -0
  7. package/lib/checks/health/doppler-compliance.js +174 -0
  8. package/lib/checks/health/git.js +61 -0
  9. package/lib/checks/health/gitignore.js +83 -0
  10. package/lib/checks/health/index.js +26 -0
  11. package/lib/checks/health/infrastructure-yml.js +87 -0
  12. package/lib/checks/health/mcps.js +57 -0
  13. package/lib/checks/health/naming-conventions.js +302 -0
  14. package/lib/checks/health/plugins.js +38 -0
  15. package/lib/checks/health/quality-toolkit.js +97 -0
  16. package/lib/checks/health/repo-visibility.js +70 -0
  17. package/lib/checks/health/rls-audit.js +130 -0
  18. package/lib/checks/health/scanner.js +68 -0
  19. package/lib/checks/health/secrets.js +80 -0
  20. package/lib/checks/health/stella-integration.js +124 -0
  21. package/lib/checks/health/tests.js +140 -0
  22. package/lib/checks/health/types.js +77 -0
  23. package/lib/checks/health/vincifox-widget.js +47 -0
  24. package/lib/checks/index.js +17 -0
  25. package/lib/checks/security/deprecated-supabase-admin.js +96 -0
  26. package/lib/checks/security/gitignore-validation.js +211 -0
  27. package/lib/checks/security/hardcoded-secrets.js +95 -0
  28. package/lib/checks/security/service-key-exposure.js +107 -0
  29. package/lib/checks/security/systemdb-whitelist.js +138 -0
  30. package/lib/checks/stability/ci-pipeline.js +143 -0
  31. package/lib/checks/stability/husky-hooks.js +117 -0
  32. package/lib/checks/stability/npm-audit.js +140 -0
  33. package/lib/checks/supabase/rls-policy-audit.js +261 -0
  34. package/lib/commands/dev-token.js +342 -0
  35. package/lib/config.js +213 -0
  36. package/lib/index.js +17 -0
  37. package/lib/reporters/terminal.js +134 -0
  38. package/lib/runner.js +179 -0
  39. package/package.json +72 -0
package/README.md ADDED
@@ -0,0 +1,312 @@
1
+ # @vca/quality-toolkit
2
+
3
+ Unified quality checks for all VCA projects. Consolidates security, stability, and code quality checks from sparkbuddy-live and vca-tools into a single npm package.
4
+
5
+ **Status:** Installed in 13 projects | Version 1.0.0
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # Local installation (recommended for VCA projects)
11
+ npm install --save-dev /Users/albertbarth/projecten/vca-quality-toolkit
12
+
13
+ # Or via file reference in package.json
14
+ "devDependencies": {
15
+ "@vca/quality-toolkit": "file:../vca-quality-toolkit"
16
+ }
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```bash
22
+ # Run all checks
23
+ npx vca-audit
24
+
25
+ # Run only security checks
26
+ npx vca-audit security
27
+
28
+ # Run only stability checks
29
+ npx vca-audit stability
30
+
31
+ # Quick check (critical issues only - fast, for pre-commit)
32
+ npx vca-audit quick
33
+
34
+ # Setup Husky hooks and CI
35
+ npx vca-setup
36
+ ```
37
+
38
+ ## Example Output
39
+
40
+ ```
41
+ ═══════════════════════════════════════════════════════════════
42
+ 🔍 VCA Quality Toolkit - Audit Results
43
+ ═══════════════════════════════════════════════════════════════
44
+
45
+ Project: /Users/albertbarth/projecten/ralph-manager
46
+ Time: 2026-02-03T15:04:03.478Z
47
+
48
+ ✅ Overall Status: PASSED
49
+
50
+ ✅ SECURITY
51
+ ──────────────────────────────────────────────────
52
+ ✅ Hardcoded Secrets Detection PASS
53
+ ✅ Service Role Key Exposure PASS
54
+ ✅ Deprecated supabaseAdmin Usage PASS
55
+ ✅ systemDB Context Whitelist PASS
56
+
57
+ ✅ STABILITY
58
+ ──────────────────────────────────────────────────
59
+ ✅ Pre-commit Hooks (Husky) PASS
60
+ ✅ CI/CD Pipeline PASS
61
+ ✅ NPM Vulnerability Audit PASS
62
+
63
+ ═══════════════════════════════════════════════════════════════
64
+ Checks: 7 passed, 0 failed, 0 skipped
65
+ ═══════════════════════════════════════════════════════════════
66
+ ```
67
+
68
+ ## What It Checks
69
+
70
+ ### Security (4 checks implemented)
71
+ | Check | Severity | Description |
72
+ |-------|----------|-------------|
73
+ | Hardcoded Secrets | Critical | API keys, tokens, JWTs in source code |
74
+ | Service Key Exposure | Critical | Supabase service role key in frontend |
75
+ | Deprecated supabaseAdmin | High | Direct supabaseAdmin usage (use systemDB/userDB) |
76
+ | systemDB Whitelist | High | Unwhitelisted systemDB contexts |
77
+
78
+ ### Stability (3 checks implemented)
79
+ | Check | Severity | Description |
80
+ |-------|----------|-------------|
81
+ | Husky Hooks | High | Pre-commit hooks configured with useful checks |
82
+ | CI Pipeline | High | GitHub Actions/GitLab CI with lint, test, build |
83
+ | npm audit | High | No critical/high vulnerabilities |
84
+
85
+ ### Health (15 ecosystem checks) — NEW
86
+
87
+ Project-level health scanner shared by ralph-manager and development-mcp.
88
+
89
+ | Check | Max Score | Description |
90
+ |-------|-----------|-------------|
91
+ | `plugins` | 2 | Claude Code plugins installed |
92
+ | `mcps` | 1 | MCP servers configured |
93
+ | `git` | 3 | Branch, uncommitted, unpushed |
94
+ | `tests` | 5 | Test pyramid (unit/integration/e2e) |
95
+ | `secrets` | 2 | Exposed secrets in MD files |
96
+ | `quality-toolkit` | 2 | @vca/dev-toolkit installed |
97
+ | `naming-conventions` | 3 | DB + code naming compliance |
98
+ | `rls-audit` | 3 | RLS policies in SQL migrations |
99
+ | `gitignore` | 2 | Critical .gitignore entries |
100
+ | `repo-visibility` | 2 | Public vs private repo |
101
+ | `vincifox-widget` | 2 | VinciFox feedback widget |
102
+ | `stella-integration` | 2 | @ralph/stella integration level |
103
+ | `claude-md` | 3 | CLAUDE.md protocol sections |
104
+ | `doppler-compliance` | 3 | Doppler secret management |
105
+ | `infrastructure-yml` | 3 | .ralph/INFRASTRUCTURE.yml |
106
+
107
+ **Total: 38 points.** Score thresholds: Healthy >= 70%, Warning 40-70%, Unhealthy < 40%.
108
+
109
+ ```javascript
110
+ import { scanProjectHealth } from '@vca/dev-toolkit'
111
+
112
+ const report = await scanProjectHealth('/path/to/project', 'my-project')
113
+ console.log(report.healthPercent + '%') // e.g. "58%"
114
+ console.log(report.status) // "healthy" | "warning" | "unhealthy"
115
+ ```
116
+
117
+ ### Planned Checks
118
+ - [ ] Dead code detection (Knip integration)
119
+ - [ ] Circular dependency detection
120
+ - [ ] TypeScript strict mode
121
+ - [ ] Test coverage thresholds
122
+
123
+ ## Integration with Ralph Manager
124
+
125
+ The toolkit integrates with ralph-manager's Health dashboard:
126
+
127
+ - **Health Scanner**: Shared 15-check scanner (ralph-manager imports from this package)
128
+ - **Toolkit Check**: Shows toolkit installation status per project
129
+ - **API Endpoint**: `/api/admin/health/quality-toolkit` returns status for all projects
130
+
131
+ ## Usage in package.json
132
+
133
+ ```json
134
+ {
135
+ "scripts": {
136
+ "audit": "vca-audit",
137
+ "audit:security": "vca-audit security",
138
+ "audit:quick": "vca-audit quick",
139
+ "prepare": "husky"
140
+ }
141
+ }
142
+ ```
143
+
144
+ ## Configuration
145
+
146
+ Create `.vca-quality.json` in your project root:
147
+
148
+ ```json
149
+ {
150
+ "suites": {
151
+ "security": true,
152
+ "stability": true,
153
+ "codeQuality": true,
154
+ "supabase": "auto"
155
+ },
156
+ "security": {
157
+ "checkHardcodedSecrets": true,
158
+ "checkServiceKeyExposure": true
159
+ },
160
+ "stability": {
161
+ "requireHusky": true,
162
+ "requireCiConfig": true,
163
+ "allowedVulnerabilities": {
164
+ "critical": 0,
165
+ "high": 0,
166
+ "moderate": 10
167
+ }
168
+ },
169
+ "supabase": {
170
+ "publicRpcFunctions": ["get_public_stats"],
171
+ "publicTables": ["lookup_countries"]
172
+ },
173
+ "ignore": [
174
+ "node_modules/**",
175
+ "dist/**"
176
+ ]
177
+ }
178
+ ```
179
+
180
+ ## CI Integration
181
+
182
+ ### GitHub Actions
183
+
184
+ ```yaml
185
+ name: Quality Checks
186
+
187
+ on: [push, pull_request]
188
+
189
+ jobs:
190
+ quality:
191
+ runs-on: ubuntu-latest
192
+ steps:
193
+ - uses: actions/checkout@v4
194
+ - uses: actions/setup-node@v4
195
+ with:
196
+ node-version: '20'
197
+ - run: npm ci
198
+ - run: npx vca-audit --ci
199
+ ```
200
+
201
+ The `--ci` flag outputs GitHub Actions annotations for inline PR feedback.
202
+
203
+ ### Pre-commit Hook
204
+
205
+ Run `npx vca-setup hooks` or manually create `.husky/pre-commit`:
206
+
207
+ ```bash
208
+ #!/bin/sh
209
+ npx vca-audit quick
210
+ if [ $? -ne 0 ]; then
211
+ echo "❌ Security issues found! Fix before committing."
212
+ exit 1
213
+ fi
214
+ ```
215
+
216
+ ## Programmatic Usage
217
+
218
+ ```javascript
219
+ import { runAllChecks, runSecurityChecks } from '@vca/quality-toolkit'
220
+
221
+ const results = await runAllChecks()
222
+
223
+ if (!results.passed) {
224
+ console.log('Quality checks failed!')
225
+ console.log(`Critical: ${results.summary.findings.critical}`)
226
+ console.log(`High: ${results.summary.findings.high}`)
227
+ }
228
+ ```
229
+
230
+ ## Projects Using This Toolkit
231
+
232
+ | Project | Status | Version |
233
+ |---------|--------|---------|
234
+ | ralph-manager | ✅ | 1.0.0 |
235
+ | sparkbuddy-live | ✅ | 1.0.0 |
236
+ | snelstart-mcp | ✅ | 1.0.0 |
237
+ | snelstart-portal | ✅ | 1.0.0 |
238
+ | vibecodingacademy | ✅ | 1.0.0 |
239
+ | Plokko | ✅ | 1.0.0 |
240
+ | ad-agent | ✅ | 1.0.0 |
241
+ | ai-finder | ✅ | 1.0.0 |
242
+ | airbnb | ✅ | 1.0.0 |
243
+ | github-ai-research | ✅ | 1.0.0 |
244
+ | groei-boom | ✅ | 1.0.0 |
245
+ | sparkgrowth | ✅ | 1.0.0 |
246
+ | vca-security | ✅ | 1.0.0 |
247
+
248
+ ## Relationship to vca-tools
249
+
250
+ This package complements [vca-tools](https://github.com/mralbertzwolle/vibe-coding-academy-tools) (Claude Code plugins):
251
+
252
+ | Tool | Purpose | Usage |
253
+ |------|---------|-------|
254
+ | **vca-tools** | Interactive Claude Code plugins | `/security-audit:run`, `/codebase-stability-audit:run` |
255
+ | **@vca/quality-toolkit** | Automated CI/pre-commit checks | `npx vca-audit`, GitHub Actions |
256
+
257
+ Both share the same check logic, but:
258
+ - **vca-tools** = human-in-the-loop, detailed reports, fix suggestions
259
+ - **@vca/quality-toolkit** = automated, CI-friendly, pass/fail
260
+
261
+ ## Architecture
262
+
263
+ ```
264
+ @vca/quality-toolkit/
265
+ ├── bin/
266
+ │ ├── vca-audit.js # Main CLI
267
+ │ └── vca-setup.js # Setup hooks/CI
268
+ ├── lib/
269
+ │ ├── index.js # Main exports
270
+ │ ├── config.js # Configuration loader
271
+ │ ├── runner.js # Check orchestrator
272
+ │ ├── checks/
273
+ │ │ ├── health/ # 15 ecosystem health checks (shared with ralph-manager)
274
+ │ │ │ ├── scanner.js # Orchestrator — scanProjectHealth()
275
+ │ │ │ ├── types.js # Shared types & helpers
276
+ │ │ │ ├── plugins.js # Claude Code plugins
277
+ │ │ │ ├── mcps.js # MCP server config
278
+ │ │ │ ├── git.js # Git status
279
+ │ │ │ ├── tests.js # Test pyramid
280
+ │ │ │ ├── secrets.js # Exposed secrets
281
+ │ │ │ └── ... # 10 more checks
282
+ │ │ ├── security/ # Security checks
283
+ │ │ ├── stability/ # Stability checks
284
+ │ │ ├── codeQuality/ # Code quality checks
285
+ │ │ └── supabase/ # Supabase checks
286
+ │ └── reporters/
287
+ │ └── terminal.js # Pretty output + GitHub Actions
288
+ └── package.json
289
+ ```
290
+
291
+ ## Consumers
292
+
293
+ | Package | Import | Usage |
294
+ |---------|--------|-------|
295
+ | **ralph-manager** | `scanProjectHealth` | Dashboard health scanner (background job, every 2 min) |
296
+ | **development-mcp** | `scanProjectHealth` | `health_check` MCP tool (on-demand via Claude Code) |
297
+ | **13 VCA projects** | `vca-audit` CLI | CI/pre-commit quality checks |
298
+
299
+ ## Contributing
300
+
301
+ 1. Add new check in `lib/checks/<category>/<name>.js`
302
+ 2. Register in `lib/runner.js`
303
+ 3. Update README
304
+ 4. Test with `npx vca-audit` in a project
305
+
306
+ ## License
307
+
308
+ MIT
309
+
310
+ ---
311
+
312
+ Built by [Vibe Coding Academy](https://vibecodingacademy.nl) • [Albert Barth](https://linkedin.com/in/albertbarth/)
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * VCA Quality Toolkit - Main CLI
5
+ *
6
+ * Usage:
7
+ * vca-audit # Run all checks
8
+ * vca-audit security # Run security checks only
9
+ * vca-audit stability # Run stability checks only
10
+ * vca-audit quick # Run quick critical checks
11
+ * vca-audit --ci # CI mode (GitHub Actions annotations)
12
+ * vca-audit --json # JSON output
13
+ */
14
+
15
+ import { program } from 'commander'
16
+ import { runAllChecks, runSecurityChecks, runStabilityChecks, runCodeQualityChecks, runQuickCheck } from '../lib/runner.js'
17
+ import { formatResults, formatGitHubActions } from '../lib/reporters/terminal.js'
18
+
19
+ program
20
+ .name('vca-audit')
21
+ .description('VCA Quality Toolkit - Unified quality checks for all projects')
22
+ .version('1.0.0')
23
+ .argument('[suite]', 'Check suite to run: security, stability, quick, or all (default)')
24
+ .option('--ci', 'CI mode - output GitHub Actions annotations')
25
+ .option('--json', 'Output results as JSON')
26
+ .option('-v, --verbose', 'Show detailed output including fix suggestions')
27
+ .option('--max-findings <n>', 'Maximum findings to show per check', parseInt, 5)
28
+ .action(async (suite, options) => {
29
+ try {
30
+ let results
31
+
32
+ switch (suite) {
33
+ case 'security':
34
+ results = await runSecurityChecks()
35
+ break
36
+ case 'stability':
37
+ results = await runStabilityChecks()
38
+ break
39
+ case 'codeQuality':
40
+ case 'code-quality':
41
+ results = await runCodeQualityChecks()
42
+ break
43
+ case 'quick':
44
+ results = await runQuickCheck()
45
+ break
46
+ default:
47
+ results = await runAllChecks()
48
+ }
49
+
50
+ // Output based on format
51
+ if (options.json) {
52
+ console.log(JSON.stringify(results, null, 2))
53
+ } else if (options.ci) {
54
+ // GitHub Actions format
55
+ console.log(formatGitHubActions(results))
56
+
57
+ // Also print summary
58
+ console.log('')
59
+ console.log('## VCA Quality Audit Results')
60
+ console.log('')
61
+ console.log(`- **Status**: ${results.passed ? '✅ PASSED' : '❌ FAILED'}`)
62
+ console.log(`- **Checks**: ${results.summary.passed} passed, ${results.summary.failed} failed`)
63
+
64
+ if (results.summary.findings.critical > 0) {
65
+ console.log(`- **Critical Issues**: ${results.summary.findings.critical}`)
66
+ }
67
+ if (results.summary.findings.high > 0) {
68
+ console.log(`- **High Issues**: ${results.summary.findings.high}`)
69
+ }
70
+ } else {
71
+ // Terminal format
72
+ console.log(formatResults(results, {
73
+ verbose: options.verbose,
74
+ maxFindings: options.maxFindings
75
+ }))
76
+ }
77
+
78
+ // Exit with appropriate code
79
+ process.exit(results.passed ? 0 : 1)
80
+
81
+ } catch (error) {
82
+ console.error('Error running audit:', error.message)
83
+ if (options.verbose) {
84
+ console.error(error.stack)
85
+ }
86
+ process.exit(2)
87
+ }
88
+ })
89
+
90
+ program.parse()
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * VCA Dev Toolkit - Dev Token CLI
5
+ *
6
+ * Manage Supabase dev tokens for API testing.
7
+ * Auto-detects project from package.json, finds Supabase config from .env files.
8
+ *
9
+ * Usage:
10
+ * vca-dev-token # Auto-refresh or show status
11
+ * vca-dev-token --login # Interactive login (prompts for password)
12
+ * vca-dev-token --status # Show current token status
13
+ * vca-dev-token --project myapp # Override project detection
14
+ */
15
+
16
+ import { program } from 'commander'
17
+ import { runDevToken } from '../lib/commands/dev-token.js'
18
+
19
+ program
20
+ .name('vca-dev-token')
21
+ .description('Manage Supabase dev tokens for API testing')
22
+ .version('1.1.0')
23
+ .option('--login', 'Interactive login (prompts for email/password)')
24
+ .option('--status', 'Show current token status')
25
+ .option('--project <name>', 'Override auto-detected project slug')
26
+ .action(async (options) => {
27
+ try {
28
+ await runDevToken({
29
+ forceLogin: options.login || false,
30
+ showStatus: options.status || false,
31
+ projectOverride: options.project || null,
32
+ })
33
+ } catch (error) {
34
+ console.error('Error:', error.message)
35
+ process.exit(2)
36
+ }
37
+ })
38
+
39
+ program.parse()
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * VCA Quality Toolkit - Setup CLI
5
+ *
6
+ * Sets up quality infrastructure in a project:
7
+ * - Husky pre-commit hooks
8
+ * - GitHub Actions workflow
9
+ * - Configuration file
10
+ *
11
+ * Usage:
12
+ * vca-setup # Interactive setup
13
+ * vca-setup hooks # Setup Husky hooks only
14
+ * vca-setup ci # Setup GitHub Actions only
15
+ * vca-setup config # Create .vca-quality.json
16
+ */
17
+
18
+ import { program } from 'commander'
19
+ import { execSync } from 'child_process'
20
+ import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs'
21
+ import { join } from 'path'
22
+
23
+ const projectRoot = process.cwd()
24
+
25
+ program
26
+ .name('vca-setup')
27
+ .description('Setup VCA Quality Toolkit in your project')
28
+ .version('1.0.0')
29
+ .argument('[component]', 'Component to setup: hooks, ci, config, or all (default)')
30
+ .option('-f, --force', 'Overwrite existing files')
31
+ .action(async (component, options) => {
32
+ console.log('')
33
+ console.log('🔧 VCA Quality Toolkit - Setup')
34
+ console.log('═'.repeat(50))
35
+ console.log('')
36
+
37
+ const components = component === 'all' || !component
38
+ ? ['hooks', 'ci', 'config']
39
+ : [component]
40
+
41
+ for (const comp of components) {
42
+ switch (comp) {
43
+ case 'hooks':
44
+ await setupHooks(options)
45
+ break
46
+ case 'ci':
47
+ await setupCi(options)
48
+ break
49
+ case 'config':
50
+ await setupConfig(options)
51
+ break
52
+ default:
53
+ console.log(`Unknown component: ${comp}`)
54
+ }
55
+ }
56
+
57
+ console.log('')
58
+ console.log('✅ Setup complete!')
59
+ console.log('')
60
+ console.log('Next steps:')
61
+ console.log(' 1. Run `vca-audit` to check your project')
62
+ console.log(' 2. Commit the generated files')
63
+ console.log(' 3. Push to trigger CI checks')
64
+ console.log('')
65
+ })
66
+
67
+ async function setupHooks(options) {
68
+ console.log('📦 Setting up Husky pre-commit hooks...')
69
+
70
+ // Check if husky is installed
71
+ const packagePath = join(projectRoot, 'package.json')
72
+ if (!existsSync(packagePath)) {
73
+ console.log(' ❌ No package.json found')
74
+ return
75
+ }
76
+
77
+ const pkg = JSON.parse(readFileSync(packagePath, 'utf-8'))
78
+ const hasHusky = pkg.devDependencies?.husky || pkg.dependencies?.husky
79
+
80
+ if (!hasHusky) {
81
+ console.log(' Installing husky...')
82
+ execSync('npm install --save-dev husky', { stdio: 'inherit' })
83
+ }
84
+
85
+ // Initialize husky
86
+ const huskyDir = join(projectRoot, '.husky')
87
+ if (!existsSync(huskyDir)) {
88
+ console.log(' Initializing husky...')
89
+ execSync('npx husky init', { stdio: 'inherit' })
90
+ }
91
+
92
+ // Create pre-commit hook
93
+ const preCommitPath = join(huskyDir, 'pre-commit')
94
+ if (!existsSync(preCommitPath) || options.force) {
95
+ const preCommitContent = `#!/bin/sh
96
+ . "$(dirname "$0")/_/husky.sh"
97
+
98
+ echo "🔍 Running VCA Quality checks..."
99
+
100
+ # Run quick security checks (fast, blocks commit on critical issues)
101
+ npx vca-audit quick
102
+ if [ $? -ne 0 ]; then
103
+ echo ""
104
+ echo "❌ Security issues found! Fix before committing."
105
+ echo " Run 'vca-audit' for detailed report."
106
+ exit 1
107
+ fi
108
+
109
+ # Run lint-staged if configured
110
+ if [ -f "package.json" ] && grep -q "lint-staged" package.json; then
111
+ npx lint-staged
112
+ fi
113
+
114
+ echo "✅ Pre-commit checks passed"
115
+ `
116
+ writeFileSync(preCommitPath, preCommitContent)
117
+ execSync(`chmod +x ${preCommitPath}`)
118
+ console.log(' ✅ Created .husky/pre-commit')
119
+ } else {
120
+ console.log(' ⏭️ .husky/pre-commit already exists (use --force to overwrite)')
121
+ }
122
+
123
+ // Add prepare script to package.json
124
+ if (!pkg.scripts?.prepare?.includes('husky')) {
125
+ pkg.scripts = pkg.scripts || {}
126
+ pkg.scripts.prepare = 'husky'
127
+ writeFileSync(packagePath, JSON.stringify(pkg, null, 2) + '\n')
128
+ console.log(' ✅ Added "prepare": "husky" to package.json')
129
+ }
130
+ }
131
+
132
+ async function setupCi(options) {
133
+ console.log('🔄 Setting up GitHub Actions workflow...')
134
+
135
+ const workflowDir = join(projectRoot, '.github/workflows')
136
+ if (!existsSync(workflowDir)) {
137
+ mkdirSync(workflowDir, { recursive: true })
138
+ }
139
+
140
+ const workflowPath = join(workflowDir, 'quality.yml')
141
+ if (!existsSync(workflowPath) || options.force) {
142
+ const workflowContent = `name: Quality Checks
143
+
144
+ on:
145
+ push:
146
+ branches: [main, master]
147
+ pull_request:
148
+ branches: [main, master]
149
+
150
+ jobs:
151
+ quality:
152
+ name: 🔍 VCA Quality Audit
153
+ runs-on: ubuntu-latest
154
+
155
+ steps:
156
+ - name: Checkout code
157
+ uses: actions/checkout@v4
158
+
159
+ - name: Setup Node.js
160
+ uses: actions/setup-node@v4
161
+ with:
162
+ node-version: '20'
163
+ cache: 'npm'
164
+
165
+ - name: Install dependencies
166
+ run: npm ci
167
+
168
+ - name: Run VCA Quality Audit
169
+ run: npx @vca/quality-toolkit --ci
170
+
171
+ - name: Upload results
172
+ if: always()
173
+ uses: actions/upload-artifact@v4
174
+ with:
175
+ name: quality-report
176
+ path: quality-report.json
177
+ retention-days: 7
178
+ `
179
+ writeFileSync(workflowPath, workflowContent)
180
+ console.log(' ✅ Created .github/workflows/quality.yml')
181
+ } else {
182
+ console.log(' ⏭️ Workflow already exists (use --force to overwrite)')
183
+ }
184
+ }
185
+
186
+ async function setupConfig(options) {
187
+ console.log('📝 Setting up configuration...')
188
+
189
+ const configPath = join(projectRoot, '.vca-quality.json')
190
+ if (!existsSync(configPath) || options.force) {
191
+ const config = {
192
+ "$schema": "https://vca-tools.dev/schemas/quality-toolkit.json",
193
+ "suites": {
194
+ "security": true,
195
+ "stability": true,
196
+ "codeQuality": true,
197
+ "supabase": "auto"
198
+ },
199
+ "security": {
200
+ "checkHardcodedSecrets": true,
201
+ "checkServiceKeyExposure": true
202
+ },
203
+ "stability": {
204
+ "requireHusky": true,
205
+ "requireCiConfig": true,
206
+ "allowedVulnerabilities": {
207
+ "critical": 0,
208
+ "high": 0,
209
+ "moderate": 10
210
+ }
211
+ },
212
+ "ignore": [
213
+ "node_modules/**",
214
+ "dist/**",
215
+ "build/**",
216
+ ".next/**"
217
+ ]
218
+ }
219
+
220
+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n')
221
+ console.log(' ✅ Created .vca-quality.json')
222
+ } else {
223
+ console.log(' ⏭️ Config already exists (use --force to overwrite)')
224
+ }
225
+ }
226
+
227
+ program.parse()