- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
107 lines
3.3 KiB
JavaScript
107 lines
3.3 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Parse Architectural Safeguards Document into Sections
|
|
* Updates database with section metadata for card-based rendering
|
|
*/
|
|
|
|
require('dotenv').config();
|
|
|
|
const fs = require('fs').promises;
|
|
const path = require('path');
|
|
const { connect, close } = require('../src/utils/db.util');
|
|
const Document = require('../src/models/Document.model');
|
|
const { parseDocumentSections } = require('../src/utils/document-section-parser');
|
|
const { markdownToHtml } = require('../src/utils/markdown.util');
|
|
|
|
async function parseAndUpdateDocument() {
|
|
try {
|
|
console.log('\n=== Parsing Architectural Safeguards Document ===\n');
|
|
|
|
const mdPath = path.resolve('docs/research/ARCHITECTURAL-SAFEGUARDS-Against-LLM-Hierarchical-Dominance-Prose.md');
|
|
const slug = 'architectural-safeguards-against-llm-hierarchical-dominance-prose';
|
|
|
|
// Read markdown file
|
|
console.log('📄 Reading markdown file...');
|
|
const rawContent = await fs.readFile(mdPath, 'utf-8');
|
|
|
|
// Parse into sections
|
|
console.log('🔍 Parsing document into sections...');
|
|
const sections = parseDocumentSections(rawContent);
|
|
|
|
console.log(`✓ Found ${sections.length} sections`);
|
|
|
|
// Convert each section's markdown to HTML
|
|
console.log('🔄 Converting sections to HTML...');
|
|
sections.forEach(section => {
|
|
section.content_html = markdownToHtml(section.content);
|
|
});
|
|
|
|
console.log('✓ Converted all sections to HTML');
|
|
|
|
// Connect to database
|
|
await connect();
|
|
|
|
// Find existing document
|
|
console.log('📊 Finding document in database...');
|
|
const doc = await Document.findBySlug(slug);
|
|
|
|
if (!doc) {
|
|
console.error('❌ Error: Document not found in database');
|
|
await close();
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('✓ Found document');
|
|
|
|
// Update document with sections and move to getting-started
|
|
console.log('💾 Updating document with sections...');
|
|
|
|
const updated = await Document.update(doc._id, {
|
|
sections: sections,
|
|
category: 'getting-started',
|
|
order: 2 // Prominently placed in getting-started
|
|
});
|
|
|
|
if (!updated) {
|
|
console.error('❌ Error: Document update failed');
|
|
await close();
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('✓ Document updated successfully!');
|
|
|
|
console.log('\n📊 Document Details:');
|
|
console.log(` Title: ${doc.title}`);
|
|
console.log(` Slug: ${doc.slug}`);
|
|
console.log(` Category: getting-started (moved from research-theory)`);
|
|
console.log(` Order: 2`);
|
|
console.log(` Sections: ${sections.length}`);
|
|
|
|
console.log('\n📋 Section Breakdown:');
|
|
const categoryCounts = {};
|
|
sections.forEach(section => {
|
|
categoryCounts[section.category] = (categoryCounts[section.category] || 0) + 1;
|
|
});
|
|
|
|
Object.entries(categoryCounts).forEach(([category, count]) => {
|
|
console.log(` ${category}: ${count} sections`);
|
|
});
|
|
|
|
console.log('\n✅ Document now has card-based rendering enabled!');
|
|
console.log(` View at: https://agenticgovernance.digital/docs.html?doc=${slug}`);
|
|
|
|
await close();
|
|
|
|
} catch (error) {
|
|
console.error('\n❌ Update failed:', error.message);
|
|
console.error(error.stack);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Run if called directly
|
|
if (require.main === module) {
|
|
parseAndUpdateDocument();
|
|
}
|
|
|
|
module.exports = parseAndUpdateDocument;
|