29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
// Module to organize notes by bridging other modules
|
|
const path = require('path');
|
|
const { getFileContents } = require('./fileReader');
|
|
const { organizeNotesWithAI } = require('./aiProcessor');
|
|
|
|
/**
|
|
* Orchestrates the process of reading, processing, and organizing notes.
|
|
* @param {string} dirPath - The path to the directory containing notes.
|
|
* @param {string} pattern - The file name pattern to match.
|
|
* @returns {Promise<string|null>} - The organized notes as a single markdown string, or null on error.
|
|
*/
|
|
async function processAndOrganizeNotes(dirPath, pattern) {
|
|
const fileData = getFileContents(dirPath, pattern);
|
|
if (fileData.length === 0) {
|
|
console.log('No matching files found to organize.');
|
|
return null;
|
|
}
|
|
|
|
const contextualizedNotes = fileData.map(data => {
|
|
const fileName = path.basename(data.filePath);
|
|
return `--- Note from ${fileName} ---\n\n${data.content}`;
|
|
});
|
|
|
|
const organizedNotes = await organizeNotesWithAI(contextualizedNotes);
|
|
return organizedNotes;
|
|
}
|
|
|
|
module.exports = { processAndOrganizeNotes };
|