papyr-core
v0.1.1
Published
Core package for Papyr - a markdown knowledge management system
Maintainers
Readme
Papyr Core
A powerful core package for building markdown-based knowledge management systems. Papyr Core provides essential functionality for parsing, analyzing, and managing interconnected markdown documents.
Features
- Markdown Processing: Parse markdown with frontmatter support
- Graph Analysis: Build and analyze document relationships
- Wiki Links: Support for
[[wiki-style]]links between documents - Search: Full-text search with FlexSearch
- Analytics: Document statistics and insights
- Export: JSON export capabilities
- TypeScript: Full TypeScript support with type definitions
Installation
npm install papyr-coreQuick Start
import { PapyrBuilder, PapyrGraph, PapyrAnalytics } from 'papyr-core';
// Build a knowledge base from markdown files
const builder = new PapyrBuilder();
const data = await builder.buildFromDirectory('./notes');
// Analyze the graph
const graph = new PapyrGraph(data.graph);
const analytics = new PapyrAnalytics(data);
// Get insights
console.log('Total notes:', analytics.getTotalNotes());
console.log('Orphaned notes:', analytics.getOrphanedNotes());
console.log('Most linked notes:', analytics.getMostLinkedNotes());API Reference
Core Classes
- PapyrBuilder: Build knowledge bases from markdown files
- PapyrGraph: Analyze document relationships and graph structure
- PapyrAnalytics: Generate insights and statistics
- PapyrSearch: Full-text search across documents
- PapyrFileProcessor: Process individual markdown files
Key Methods
PapyrBuilder
buildFromDirectory(path: string): Build from a directory of markdown filesbuildFromFiles(files: string[]): Build from specific file pathsbuildFromContent(content: string, filename?: string): Build from markdown content
PapyrGraph
getNeighbors(nodeId: string): Get connected documentsgetPath(from: string, to: string): Find path between documentsgetComponents(): Get disconnected graph components
PapyrAnalytics
getTotalNotes(): Count total documentsgetOrphanedNotes(): Find documents with no connectionsgetMostLinkedNotes(limit?: number): Get most referenced documents
Configuration
The package supports various configuration options through the builder:
const builder = new PapyrBuilder({
includeFrontmatter: true,
parseWikiLinks: true,
generateGraph: true,
generateSearchIndex: true
});Development
Prerequisites
- Node.js 18+
- pnpm (recommended) or npm
Setup
# Install dependencies
pnpm install
# Build the package
pnpm build
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Development mode (watch for changes)
pnpm devProject Structure
papyr-core/
├── src/ # Source code
├── tests/ # Test files
├── dist/ # Built output (generated)
├── package.json # Package configuration
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Build configuration
└── vitest.config.ts # Test configurationContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: GitHub Wiki
Related Packages
- papyr-react: React components for building Papyr UIs
- papyr-cli: Command-line interface for Papyr
