@petroglyph/core
v0.2.1
Published
Core library for working with Personal Knowledge Management (PKM) systems. Fully compatible with Obsidian.
Maintainers
Readme
@petroglyph/core
Core library for working with Personal Knowledge Management (PKM) systems. Fully compatible with Obsidian.
Installation
bun add @petroglyph/core
# or
npm install @petroglyph/core
# or
pnpm add @petroglyph/coreUsage
import { createCave } from '@petroglyph/core';
import { LocalFileSystem } from '@petroglyph/fs';
import { RemarkRenderer } from '@petroglyph/renderer/remark';
// createCave is async - builds index for Obsidian-style resolution
const cave = await createCave({
fileSystem: new LocalFileSystem('path-to-your-folder'),
renderer: new RemarkRenderer(), // optional
autoRefresh: true // optional, auto-updates index on create/delete
});Features
Notes
// List all notes
const notes = await cave.notes.listAll();
// Get note by path, wikilink, or name
const note = await cave.notes.get('Notes/my-note.md');
const note = await cave.notes.get('[[my-note]]');
const note = await cave.notes.get('my-note', { nearest: 'current-note' });
// Typed notes with Zod schemas
import { z } from 'zod';
const bookSchema = z.object({
type: z.literal('book'),
title: z.string(),
author: z.string(),
});
const note = await cave.notes.typed(bookSchema).get('my-book');
// note.frontmatter is now typed according to the schema
// Search notes
const results = await cave.notes.search('search term');Files, Bases, and Canvases
// Files
const files = await cave.files.listAll();
const file = await cave.files.get('document.pdf');
// Bases
const bases = await cave.bases.listAll();
const base = await cave.bases.get('my-base.base');
const view = await cave.bases.render(base, 'view-name');
// Canvases
const canvases = await cave.canvases.listAll();
const canvas = await cave.canvases.get('my-canvas.canvas');API Reference
See the main Petroglyph documentation for complete API reference.
License
MIT
