{
"name": "getNoteOverview",
"description": "Analyzes the current note and provides detailed statistics and information"
}
async function getNoteOverview() {
console.log("got here!");
const mermaid = new snippets.MermaidManager(app);
try {
const currentNote = await noteManager.getCurrentNote();
const metadata = await noteManager.getNoteMetadata(currentNote);
const content = await noteManager.getNoteContent(currentNote);
// Calculate additional statistics
const wordCount = content.split(/\s+/).length;
const charCount = content.length;
const lineCount = content.split('\n').length;
// Get unique links (excluding duplicates)
const uniqueLinks = [...new Set(metadata.links)];
// Count headings by level
const headingCounts = metadata.headings.reduce((acc, h) => {
acc[h.level] = (acc[h.level] || 0) + 1;
return acc;
}, {});
// Search for specific patterns (e.g., TODO, FIXME)
const todoCount = (content.match(/TODO/gi) || []).length;
const fixmeCount = (content.match(/FIXME/gi) || []).length;
return `
Note Overview for "${metadata.name}":
- Path: ${metadata.path}
- Size: ${metadata.size} bytes
- Created: ${new Date(metadata.created).toLocaleString()}
- Modified: ${new Date(metadata.modified).toLocaleString()}
Content Statistics:
- Word Count: ${wordCount}
- Character Count: ${charCount}
- Line Count: ${lineCount}
- TODO Count: ${todoCount}
- FIXME Count: ${fixmeCount}
Structure:
- Tags: ${metadata.tags.join(', ') || 'None'}
- Unique Links: ${uniqueLinks.join(', ') || 'None'}
- Total Links: ${metadata.links.length}
- Headings: ${Object.entries(headingCounts).map(([level, count]) => `H${level}: ${count}`).join(', ') || 'None'}
- Total Headings: ${metadata.headings.length}
- Backlinks: ${metadata.backlinks.length}
First 100 characters of content:
${content.substring(0, 100)}...
`;
} catch (error) {
return `Error getting note overview: ${error.message}`;
}
}