-
Notifications
You must be signed in to change notification settings - Fork 8k
Expand file tree
/
Copy pathcv-sync-check.mjs
More file actions
101 lines (87 loc) · 3.5 KB
/
cv-sync-check.mjs
File metadata and controls
101 lines (87 loc) · 3.5 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
#!/usr/bin/env node
/**
* cv-sync-check.mjs — Validates that the career-ops setup is consistent.
*
* Checks:
* 1. cv.md exists
* 2. config/profile.yml exists and has required fields
* 3. No hardcoded metrics in _shared.md or batch/batch-prompt.md
* 4. article-digest.md freshness (if exists)
*/
import { readFileSync, existsSync, statSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const projectRoot = __dirname;
const warnings = [];
const errors = [];
// 1. Check cv.md exists
const cvPath = join(projectRoot, 'cv.md');
if (!existsSync(cvPath)) {
errors.push('cv.md not found in project root. Create it with your CV in markdown format.');
} else {
const cvContent = readFileSync(cvPath, 'utf-8');
if (cvContent.trim().length < 100) {
warnings.push('cv.md seems too short. Make sure it contains your full CV.');
}
}
// 2. Check profile.yml exists
const profilePath = join(projectRoot, 'config', 'profile.yml');
if (!existsSync(profilePath)) {
errors.push('config/profile.yml not found. Copy from config/profile.example.yml and fill in your details.');
} else {
const profileContent = readFileSync(profilePath, 'utf-8');
const requiredFields = ['full_name', 'email', 'location'];
for (const field of requiredFields) {
if (!profileContent.includes(field) || profileContent.includes(`"Jane Smith"`)) {
warnings.push(`config/profile.yml may still have example data. Check field: ${field}`);
break;
}
}
}
// 3. Check for hardcoded metrics in prompt files
const filesToCheck = [
{ path: join(projectRoot, 'modes', '_shared.md'), name: '_shared.md' },
{ path: join(projectRoot, 'batch', 'batch-prompt.md'), name: 'batch-prompt.md' },
];
// Pattern: numbers that look like hardcoded metrics (e.g., "170+ hours", "90% self-service")
const metricPattern = /\b\d{2,4}\+?\s*(hours?|%|evals?|layers?|tests?|fields?|bases?)\b/gi;
for (const { path, name } of filesToCheck) {
if (!existsSync(path)) continue;
const content = readFileSync(path, 'utf-8');
// Skip lines that are clearly instructions (contain "NEVER hardcode" etc.)
const lines = content.split('\n');
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('NEVER hardcode') || line.includes('NUNCA hardcode') || line.startsWith('#') || line.startsWith('<!--')) continue;
const matches = line.match(metricPattern);
if (matches) {
warnings.push(`${name}:${i + 1} — Possible hardcoded metric: "${matches[0]}". Should this be read from cv.md/article-digest.md?`);
}
}
}
// 4. Check article-digest.md freshness
const digestPath = join(projectRoot, 'article-digest.md');
if (existsSync(digestPath)) {
const stats = statSync(digestPath);
const daysSinceModified = (Date.now() - stats.mtimeMs) / (1000 * 60 * 60 * 24);
if (daysSinceModified > 30) {
warnings.push(`article-digest.md is ${Math.round(daysSinceModified)} days old. Consider updating if your projects have new metrics.`);
}
}
// Output results
console.log('\n=== career-ops sync check ===\n');
if (errors.length === 0 && warnings.length === 0) {
console.log('All checks passed.');
} else {
if (errors.length > 0) {
console.log(`ERRORS (${errors.length}):`);
errors.forEach(e => console.log(` ERROR: ${e}`));
}
if (warnings.length > 0) {
console.log(`\nWARNINGS (${warnings.length}):`);
warnings.forEach(w => console.log(` WARN: ${w}`));
}
}
console.log('');
process.exit(errors.length > 0 ? 1 : 0);