## Enhanced Mode v2 - Smart Section-Based Editing (routes/ai.js) ### Server-Side Section Replacement Architecture - Add cleanMarkdownFromTitle() to normalize section titles for matching - Add extractHeaders() to list all document sections for debugging - Add replaceSection() to surgically replace only modified sections - AI now returns ONLY the modified section, not entire document - Server automatically replaces section in original document - Automatic header level correction if AI changes ## to ### or vice versa - Section boundary detection based on header hierarchy ### Enhanced Prompt and Response Format - Modified prompt to explicitly request ONLY modified section - New closing format: document (mandatory) - Added fallback regex for old format with warnings - Explicit rules: keep exact header level (## stays ##) - Clear section boundary definition in prompt - Examples with proper formatting guidelines ### Comprehensive Logging System - Log all API requests with method, endpoint, payload size - Log AI responses with length and preview - Log section matching and replacement operations - Log header level corrections - Log section not found errors with available sections list - Track modified sections across iterations ## AI Button Mutex and Preview Mode Controls (assets/js/app.js) ### AI Button Mutex (Prevent API Overload) - Add disableAIButtons() to disable all AI buttons during operations - Add enableAIButtons() to re-enable after completion or error - Disable all AI buttons at start of any AI operation - Re-enable in finally blocks to ensure cleanup even on errors - Re-enable on validation failures (e.g., no text selected for rephrase) - Re-enable when user clicks Apply/Cancel in rephrase mode ### Preview Mode Button Restrictions - Disable Preview button during Enhanced Mode operation - Disable all AI buttons in preview mode (rephrase, inconsistencies, duplications, advice, liberty) - Disable Save and Load buttons in preview mode - Re-enable all buttons when returning to edit mode - Proper cleanup with finally blocks ## Mermaid Auto-Fix System - Complete Removal ### Removed from assets/js/app.js - Remove mermaidFixAttempts Set from constructor - Remove setupMessageListener() and postMessage handler - Remove fixMermaidDiagramBackground() function - Simplify Mermaid error display to inline messages only - Remove hash-based tracking mechanism ### Removed from routes/index.js (Present Mode) - Remove entire auto-fix fetch and retry logic - Remove status div updates and fix notifications - Remove postMessage to parent window - Simplify to display styled error message only ### Current Behavior - Preview mode: Shows inline error with simple message - Present mode: Shows styled error box with instructions - No automatic fix attempts - manual correction only ## Additional Improvements - Clean markdown formatting (##, **, etc.) from section titles in UI badges - Proper section title matching ignoring markdown syntax - Enhanced error handling with detailed logging - Better user feedback during Enhanced Mode iterations This release improves Enhanced Mode reliability, prevents API overload through button mutex, simplifies Mermaid error handling, and adds comprehensive logging for debugging.
Design Journal
A collaborative design documentation tool with AI-powered assistance for technical project management.
Features
Document Management
- Rich text editor for design journals
- Automatic table of contents generation from headings
- Real-time Markdown preview with GitHub-style rendering
- Auto-save functionality with timestamp tracking
- Version history with undo/redo (Ctrl+Z/Y)
AI-Powered Assistant (Mistral AI)
- Rephrase: Improve clarity and style of selected text
- Analyze: Detect inconsistencies and duplicates in documents
- Advice: Get constructive improvement suggestions
- Enhanced Mode (Smart Adaptive): AI-driven iterative document enrichment
- AI automatically selects which section to improve in each iteration
- Smart section selection based on quality assessment, importance, and coverage
- Up to 10 iterations of progressive enhancement
- Real-time streaming feedback with section tracking
- Precision control for creative vs. conservative improvements (30-90%)
- Automatically avoids re-modifying recently enhanced sections
User Interface
- Dark/Light theme with preference persistence
- Split-panel layout with collapsible sidebars
- Responsive design for various screen sizes
- Keyboard shortcuts for common actions
Export & Import
- Export to Markdown (.md), PDF, or HTML
- Import existing Markdown files
- Default template for quick starts
Installation
Prerequisites
- Node.js 16+
- npm or yarn
- Mistral API key (optional, for AI features)
Setup
# Clone the repository
git clone <repository-url>
cd conception-assistant
# Install dependencies
npm install
# Create configuration file (optional)
cp .env.example config/.env
# Edit config/.env and add your Mistral API key
Configuration
Create a config/.env file with the following (all optional):
# Server Configuration
PORT=3000
# Mistral AI Configuration (required for AI features)
MISTRAL_API_KEY=your_mistral_api_key_here
MISTRAL_MODEL=mistral-large-latest
MISTRAL_BASE_URL=https://api.mistral.ai/v1
# AI Advanced Configuration
AI_ENABLED=true
AI_MAX_TOKENS=35000
AI_TEMPERATURE=0.3
AI_TOP_P=0.85
Note
: The application works perfectly for journal management without an API key. AI features will be disabled if no key is provided.
Running
# Start the application
npm start
# Access the application
# Open http://localhost:3000 in your browser
Usage
Creating a New Journal
- Use the main editor to write your content
- The table of contents updates automatically
- Save with Ctrl+S or the Save button
Using AI Features
- Rephrase: Select text → click "Rephrase" button
- Analysis: Click "Inconsistencies", "Duplicates", or "Advice" buttons
- Enhanced Mode (Smart Adaptive):
- Choose number of iterations (1-10)
- Select precision level (30-90%)
- Click "Enhanced Mode"
- AI automatically analyzes the entire document
- At each iteration, AI selects ONE section to improve based on:
- Quality assessment (incomplete sections, lacking details)
- Strategic importance (introduction, architecture, APIs)
- Coverage (avoids recently modified sections)
- Watch real-time streaming with section badges showing which part is being enhanced
- Document updates automatically after each iteration
Keyboard Shortcuts
Ctrl+S- Save journalCtrl+Z- UndoCtrl+YorCtrl+Shift+Z- RedoTab- IndentEsc- Close panels
Project Structure
conception-assistant/
├── app.js # Express server
├── package.json # Dependencies and scripts
├── routes/ # API routes
│ ├── index.js # Main routes
│ ├── api.js # Journal CRUD operations
│ ├── ai.js # AI integration (Mistral)
│ ├── templates.js # Template management
│ └── export.js # PDF/HTML export
├── views/ # HTML components
│ ├── page.js # Main HTML structure
│ ├── header.js # Header component
│ ├── main.js # Main content area
│ └── footer.js # Footer component
├── assets/ # Static resources
│ ├── css/ # Stylesheets
│ └── js/ # Client-side JavaScript
├── templates/ # Document templates
│ └── default.md # Default template
└── data/ # Journal storage
└── journals_*.json # Saved journals
AI Configuration
Temperature Settings by Feature
- Rephrase: 0.2 (very precise)
- Analysis: 0.1 (factual)
- Advice: 0.4 (balanced)
- Enhanced Mode: 0.1-0.9 (dynamic based on precision setting)
Enhanced Mode Precision Levels
| Level | Description | Behavior | Use Case |
|---|---|---|---|
| 30% | Very Creative | Can create 70% new logical content | Initial brainstorming |
| 50% | Balanced | 50/50 deduction/creation | Standard development |
| 70% | Conservative | Primarily based on existing content | Document refinement |
| 90% | Very Precise | Only obvious deductions | Technical finalization |
Smart Adaptive Section Selection
The Enhanced Mode uses an intelligent strategy to automatically choose which section to improve:
Selection Criteria (in priority order):
-
Quality Assessment: Identifies sections that need improvement
- Incomplete content (too short, missing details)
- Vague or unclear explanations
- Lack of technical specifications
- Poor structure or organization
-
Strategic Importance: Prioritizes critical document sections
- Introduction and overview sections
- Architecture and design decisions
- Core APIs and implementation details
- Critical workflows and processes
-
Coverage Tracking: Ensures balanced enhancement
- Avoids sections recently modified
- Tracks modification history across iterations
- Ensures all sections receive attention
-
Progressive Enhancement: Builds incrementally
- Each iteration improves ONE section only
- Maintains document coherence
- Preserves all other sections unchanged
Output Format Per Iteration:
- Analyzed Sections: List of all major sections found in the document
- Selected Section: The specific section chosen for enhancement (with exact header name)
- Selection Reason: Explanation of why this section was prioritized
- Improvements Made: Detailed list of enhancements applied
- Next Recommendations: Suggestions for future iterations
Technology Stack
Backend
- Node.js - JavaScript runtime
- Express.js - Web framework
- Mistral AI - Language model API
- Puppeteer - PDF generation
Frontend
- Vanilla JavaScript - No framework dependencies
- Marked.js - Markdown parsing
- Mermaid.js - Diagram rendering
- CSS Variables - Dynamic theming
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
Open Source
This project is open source and available under the MIT License. No attribution required.