tractatus/scripts/prepare-public-docs.js
TheFlow a04521713a feat(docs): documentation curation infrastructure (scripts + sidebar)
INFRASTRUCTURE COMPLETE (22 public documents from 129 total):

CATEGORY CONSOLIDATION (12 → 5):
- Eliminated chaotic category proliferation
- Defined 5 canonical categories with icons, descriptions
- Updated frontend sidebar (public/js/docs-app.js)
- Categories: getting-started, research-theory, technical-reference,
  advanced-topics, business-leadership

SCRIPTS CREATED:
- comprehensive-document-audit.js: Systematic audit of all 129 docs
- generate-public-pdfs.js: Puppeteer-based PDF generation (22 PDFs)
- migrate-documents-final.js: DB migration (22 updated, 104 archived)
- export-for-production.js: Export 22 docs for production
- import-from-export.js: Import documents to production DB
- analyze-categories.js: Category analysis tool
- prepare-public-docs.js: Document preparation validator

AUDIT RESULTS:
- docs/DOCUMENT_AUDIT_REPORT.json: Full analysis with recommendations
- 22 documents recommended for public visibility
- 104 documents to archive (internal/obsolete/poor quality)

REMAINING WORK:
- Fix inst_016/017/018 violations in 22 public documents (85 violations)
  • inst_016: Statistics need citations or [NEEDS VERIFICATION]
  • inst_017: Replace absolute assurance terms with evidence-based language
  • inst_018: Remove maturity claims or add documented evidence
- Regenerate PDFs after content fixes
- Regenerate production export file (compliant version)
- Deploy to production

Database migration already executed in dev (22 updated, 104 archived).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 21:36:54 +13:00

143 lines
5.7 KiB
JavaScript

/**
* Prepare Public Documents
* 1. Verify all public docs have sections (cards)
* 2. Generate missing PDFs
* 3. Report status
*/
const { MongoClient } = require('mongodb');
// Documents that should be public (from audit)
const PUBLIC_DOCS = [
// Getting Started (6)
'introduction-to-tractatus',
'core-concepts-tractatus',
'executive-summary-tractatus-inflection-point',
'implementation-guide-tractatus',
'implementation-guide',
'implementation-guide-python-examples',
// Research & Theory (7 including working paper)
'tractatus-framework-research', // Working Paper v0.1
'pluralistic-values-research-foundations',
'case-study-27027-pattern-recognition-bias',
'case-study-framework-failure-and-recovery',
'llm-integration-feasibility-research-scope',
'research-topic-concurrent-session-architecture',
'research-topic-rule-proliferation-transactional-overhead',
// Technical Reference (5)
'technical-architecture',
'api-reference-complete',
'api-javascript-examples',
'api-python-examples',
'openapi-specification',
// Advanced Topics (3)
'value-pluralism-faq',
'tractatus-framework-core-values',
'organizational-theory-foundations',
// Business Leadership (1)
'business-case-tractatus-framework'
];
async function run() {
const client = new MongoClient('mongodb://localhost:27017');
try {
await client.connect();
const db = client.db('tractatus_dev');
const collection = db.collection('documents');
console.log('═══════════════════════════════════════════════════════════');
console.log(' PUBLIC DOCUMENTS PREPARATION');
console.log('═══════════════════════════════════════════════════════════\n');
const needsSections = [];
const needsPDF = [];
const ready = [];
const notFound = [];
for (const slug of PUBLIC_DOCS) {
const doc = await collection.findOne({ slug });
if (!doc) {
notFound.push(slug);
continue;
}
const hasSections = doc.sections && doc.sections.length > 0;
const hasPDF = doc.download_formats && doc.download_formats.pdf;
if (hasSections && hasPDF) {
ready.push({ slug, title: doc.title, sections: doc.sections.length });
} else if (!hasSections && !hasPDF) {
needsSections.push({ slug, title: doc.title });
needsPDF.push({ slug, title: doc.title });
} else if (!hasSections) {
needsSections.push({ slug, title: doc.title });
} else if (!hasPDF) {
needsPDF.push({ slug, title: doc.title });
}
}
console.log('SUMMARY:');
console.log(` ✅ Ready (sections + PDF): ${ready.length}`);
console.log(` ⚠️ Needs sections: ${needsSections.length}`);
console.log(` ⚠️ Needs PDF: ${needsPDF.length}`);
console.log(` ❌ Not found: ${notFound.length}\n`);
if (ready.length > 0) {
console.log('═══════════════════════════════════════════════════════════');
console.log(' ✅ READY FOR PUBLIC');
console.log('═══════════════════════════════════════════════════════════\n');
ready.forEach(d => {
console.log(`${d.title}`);
console.log(` Slug: ${d.slug} | Sections: ${d.sections}`);
});
console.log('');
}
if (needsSections.length > 0) {
console.log('═══════════════════════════════════════════════════════════');
console.log(' ⚠️ NEEDS SECTIONS (CARDS)');
console.log('═══════════════════════════════════════════════════════════\n');
needsSections.forEach(d => {
console.log(` ⚠️ ${d.title}`);
console.log(` Slug: ${d.slug}`);
});
console.log('');
}
if (needsPDF.length > 0) {
console.log('═══════════════════════════════════════════════════════════');
console.log(' ⚠️ NEEDS PDF GENERATION');
console.log('═══════════════════════════════════════════════════════════\n');
needsPDF.forEach(d => {
console.log(` ⚠️ ${d.title}`);
console.log(` Slug: ${d.slug}`);
});
console.log('');
}
if (notFound.length > 0) {
console.log('═══════════════════════════════════════════════════════════');
console.log(' ❌ NOT FOUND IN DATABASE');
console.log('═══════════════════════════════════════════════════════════\n');
notFound.forEach(slug => {
console.log(`${slug}`);
});
console.log('');
}
await client.close();
process.exit(0);
} catch (error) {
console.error('Error:', error);
await client.close();
process.exit(1);
}
}
run();