forked from agenticoding/agenticoding.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudit-presentations.js
More file actions
220 lines (194 loc) Β· 7.66 KB
/
audit-presentations.js
File metadata and controls
220 lines (194 loc) Β· 7.66 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
#!/usr/bin/env node
/**
* Audit all presentations for content array violations (3-5 items rule)
*/
import { readFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const MIN_ITEMS = 3;
const MAX_ITEMS = 5;
const MAX_WORDS = 5;
function auditPresentation(filePath) {
const content = readFileSync(filePath, 'utf-8');
const presentation = JSON.parse(content);
const violations = [];
const wordCountViolations = [];
// Check slides with content arrays
const slidesWithContent = presentation.slides.filter(slide => {
if (slide.type === 'title') return false;
return slide.content && Array.isArray(slide.content);
});
for (const slide of slidesWithContent) {
const contentLength = slide.content.length;
if (contentLength < MIN_ITEMS || contentLength > MAX_ITEMS) {
violations.push({
slide: slide.title || slide.type,
type: slide.type,
count: contentLength,
items: slide.content
});
}
}
// Check comparison slides (left/right content)
const comparisonSlides = presentation.slides.filter(s =>
s.type === 'comparison' || s.type === 'marketingReality'
);
for (const slide of comparisonSlides) {
const leftContent = slide.left?.content || slide.metaphor?.content;
const rightContent = slide.right?.content || slide.reality?.content;
if (leftContent && Array.isArray(leftContent)) {
const leftLength = leftContent.length;
if (leftLength < MIN_ITEMS || leftLength > MAX_ITEMS) {
violations.push({
slide: `${slide.title} (LEFT)`,
type: slide.type,
count: leftLength,
items: leftContent
});
}
}
if (rightContent && Array.isArray(rightContent)) {
const rightLength = rightContent.length;
if (rightLength < MIN_ITEMS || rightLength > MAX_ITEMS) {
violations.push({
slide: `${slide.title} (RIGHT)`,
type: slide.type,
count: rightLength,
items: rightContent
});
}
}
}
// Check takeaway word counts
const takeawaySlides = presentation.slides.filter(s => s.type === 'takeaway');
for (const slide of takeawaySlides) {
if (slide.content && Array.isArray(slide.content)) {
slide.content.forEach((item, index) => {
const wordCount = item.trim().split(/\s+/).length;
if (wordCount > MAX_WORDS) {
wordCountViolations.push({
type: 'takeaway',
slide: slide.title,
index: index + 1,
wordCount,
content: item,
excess: wordCount - MAX_WORDS
});
}
});
}
}
// Check learning objectives word counts
const objectives = presentation.metadata?.learningObjectives || [];
objectives.forEach((objective, index) => {
const wordCount = objective.trim().split(/\s+/).length;
if (wordCount > MAX_WORDS) {
wordCountViolations.push({
type: 'objective',
index: index + 1,
wordCount,
content: objective,
excess: wordCount - MAX_WORDS
});
}
});
return {
title: presentation.metadata?.title || 'Unknown',
violations,
wordCountViolations,
totalSlides: presentation.slides.length
};
}
function main() {
const presentationsDir = join(__dirname, '../website/static/presentations');
const files = [
'intro.json',
'methodology/lesson-3-high-level-methodology.json',
'methodology/lesson-4-prompting-101.json',
'methodology/lesson-5-grounding.json',
'practical-techniques/lesson-6-project-onboarding.json',
'practical-techniques/lesson-7-planning-execution.json',
'practical-techniques/lesson-8-tests-as-guardrails.json',
'practical-techniques/lesson-9-reviewing-code.json',
'practical-techniques/lesson-10-debugging.json',
'understanding-the-tools/lesson-1-intro.json',
'understanding-the-tools/lesson-2-understanding-agents.json'
];
console.log('π Auditing presentations for violations\n');
console.log('Checking:');
console.log(' β’ Content arrays (3-5 items rule)');
console.log(' β’ Takeaway word counts (5 words max)');
console.log(' β’ Learning objectives word counts (5 words max)\n');
const results = [];
let totalViolations = 0;
let totalWordCountViolations = 0;
for (const file of files) {
const filePath = join(presentationsDir, file);
try {
const result = auditPresentation(filePath);
results.push({ file, ...result });
const hasViolations = result.violations.length > 0;
const hasWordViolations = result.wordCountViolations.length > 0;
if (hasViolations || hasWordViolations) {
console.log(`β ${file}`);
console.log(` Title: ${result.title}`);
if (hasViolations) {
totalViolations += result.violations.length;
console.log(` Content array violations (${result.violations.length}):`);
result.violations.forEach(v => {
console.log(` - "${v.slide}" (${v.type}): ${v.count} items`);
if (v.count <= 8) {
v.items.forEach(item => {
const truncated = item.length > 60 ? item.substring(0, 57) + '...' : item;
console.log(` β’ ${truncated}`);
});
}
});
}
if (hasWordViolations) {
totalWordCountViolations += result.wordCountViolations.length;
console.log(` Word count violations (${result.wordCountViolations.length}):`);
result.wordCountViolations.forEach(v => {
if (v.type === 'takeaway') {
console.log(` - Takeaway "${v.slide}" item ${v.index}: ${v.wordCount} words (+${v.excess})`);
} else {
console.log(` - Learning objective ${v.index}: ${v.wordCount} words (+${v.excess})`);
}
const truncated = v.content.length > 60 ? v.content.substring(0, 57) + '...' : v.content;
console.log(` "${truncated}"`);
});
}
console.log('');
}
} catch (error) {
console.log(`β οΈ ${file}: Error reading file - ${error.message}\n`);
}
}
// Summary
console.log('βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ');
const violatingFiles = results.filter(r => r.violations.length > 0 || r.wordCountViolations.length > 0);
if (violatingFiles.length === 0) {
console.log('β
All presentations pass validation!');
} else {
console.log(`\nπ SUMMARY:\n`);
console.log(`Total files audited: ${results.length}`);
console.log(`Files with violations: ${violatingFiles.length}`);
console.log(` β’ Content array violations: ${totalViolations}`);
console.log(` β’ Word count violations: ${totalWordCountViolations}`);
console.log(` β’ Total: ${totalViolations + totalWordCountViolations}\n`);
console.log('Files needing regeneration:');
violatingFiles.forEach(r => {
const arrayViolations = r.violations.length;
const wordViolations = r.wordCountViolations.length;
const total = arrayViolations + wordViolations;
const details = [];
if (arrayViolations > 0) details.push(`${arrayViolations} array`);
if (wordViolations > 0) details.push(`${wordViolations} word`);
console.log(` - ${r.file} (${total} total: ${details.join(', ')})`);
});
}
console.log('βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ');
}
main();