tractatus/scripts/update-cache-version.js
TheFlow 1906c0be0b docs: update framework to 6 services with PluralisticDeliberationOrchestrator
- Updated all core documentation (introduction, core-concepts, implementation guides)
- Added comprehensive PluralisticDeliberationOrchestrator sections
- Fixed implementation-guide-v1.1.md (BlogCuration → PluralisticDeliberationOrchestrator)
- Updated UI pages (index, researcher, leader) to reflect 6 services
- Enhanced cache busting with unified version script
- FAQ already includes comprehensive value pluralism coverage (Q18-22)

Framework now correctly documents all 6 mandatory services:
1. InstructionPersistenceClassifier
2. CrossReferenceValidator
3. BoundaryEnforcer
4. ContextPressureMonitor
5. MetacognitiveVerifier
6. PluralisticDeliberationOrchestrator (added October 2025)

🤖 Generated with Claude Code
2025-10-12 19:55:44 +13:00

123 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* Update Cache Version - Unified Cache Busting
*
* Updates all HTML files with a consistent cache-busting version string.
* Format: v={package.version}.{timestamp}
* Example: v=0.1.0.1760201234
*
* This ensures all assets (CSS, JS) are loaded with the same version,
* solving the inconsistent cache busting problem.
*/
const fs = require('fs');
const path = require('path');
const packageJson = require('../package.json');
// Generate cache version: package version + timestamp
const CACHE_VERSION = `${packageJson.version}.${Date.now()}`;
// HTML files to update (relative to project root)
const HTML_FILES = [
'public/index.html',
'public/docs.html',
'public/faq.html',
'public/researcher.html',
'public/implementer.html',
'public/leader.html',
'public/about.html',
'public/privacy.html',
'public/blog.html',
'public/blog-post.html',
'public/docs-viewer.html',
'public/api-reference.html',
'public/media-inquiry.html',
'public/case-submission.html',
'public/koha.html',
'public/check-version.html'
];
/**
* Update cache version in a file
* Replaces all instances of ?v=X with ?v={CACHE_VERSION}
*/
function updateCacheVersion(filePath) {
try {
const fullPath = path.join(__dirname, '..', filePath);
if (!fs.existsSync(fullPath)) {
console.warn(`⚠️ File not found: ${filePath}`);
return false;
}
let content = fs.readFileSync(fullPath, 'utf8');
const originalContent = content;
// Pattern: ?v=ANYTHING → ?v={CACHE_VERSION}
// Matches: ?v=1.0.4, ?v=1759833751, ?v=1.0.5.1760123456
content = content.replace(/\?v=[0-9a-zA-Z._-]+/g, `?v=${CACHE_VERSION}`);
// Only write if changed
if (content !== originalContent) {
fs.writeFileSync(fullPath, content, 'utf8');
// Count replacements
const matches = originalContent.match(/\?v=[0-9a-zA-Z._-]+/g) || [];
console.log(`${filePath}: Updated ${matches.length} cache version(s)`);
return true;
} else {
console.log(` ${filePath}: No changes needed`);
return false;
}
} catch (error) {
console.error(`❌ Error updating ${filePath}:`, error.message);
return false;
}
}
/**
* Main execution
*/
function main() {
console.log('');
console.log('═'.repeat(70));
console.log(' Tractatus - Cache Version Update');
console.log('═'.repeat(70));
console.log('');
console.log(`📦 Package version: ${packageJson.version}`);
console.log(`🔄 New cache version: ${CACHE_VERSION}`);
console.log('');
let updatedCount = 0;
let totalFiles = 0;
HTML_FILES.forEach(file => {
totalFiles++;
if (updateCacheVersion(file)) {
updatedCount++;
}
});
console.log('');
console.log('═'.repeat(70));
console.log(` Summary: ${updatedCount}/${totalFiles} files updated`);
console.log('═'.repeat(70));
console.log('');
if (updatedCount > 0) {
console.log('✅ Cache version updated successfully!');
console.log(` All assets will now use: ?v=${CACHE_VERSION}`);
} else {
console.log(' No files needed updating');
}
console.log('');
}
// Run if called directly
if (require.main === module) {
main();
}
module.exports = { updateCacheVersion, CACHE_VERSION };