v1.0
This commit is contained in:
28
src/noteOrganizer.js
Normal file
28
src/noteOrganizer.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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 };
|
||||
Reference in New Issue
Block a user