@specifica/store
v0.1.0
Published
Storage adapter interface for Specifica - implementation-agnostic types and contracts
Maintainers
Readme
@specifica/store
Storage adapter interface for Specifica - implementation-agnostic types and contracts.
Installation
npm install @specifica/storeOverview
This package defines the StorageAdapter interface that any Specifica-compatible storage backend must implement. It includes all TypeScript types and method signatures, with no infrastructure dependencies.
This is an interface package - it contains types only, not implementations.
Possible Implementations
- Cloudflare Durable Objects + SQLite (Cognium's proprietary implementation)
- Local filesystem (CLI tools)
- PostgreSQL (self-hosted)
- In-memory (testing)
- better-sqlite3 (Electron/desktop apps)
Usage
import type { StorageAdapter, StoredItem, MemoryItem } from '@specifica/store'
// Implement the interface
class MyStorageAdapter implements StorageAdapter {
async createItem(title: string, type = 'task') {
// Your implementation here
}
async getItem(id: string) {
// Your implementation here
}
// ... implement all methods
}Interface
The StorageAdapter interface provides:
Items
createItem(title, type?)- Create new itemupdateItem(id, updates)- Update existing itemgetItem(id)- Get single itemlistItems(filter?)- List items with filteringarchiveItem(id)- Archive item (soft delete)
Content
getContent(itemId)- Get spec/design/tasks filesupdateContent(itemId, file, content)- Update specific file
Tasks
getTasks(itemId)- Get parsed tasks from tasks.mdupdateTaskStatus(itemId, taskOrder, done)- Toggle task checkbox
Memory
addMemory(category, key, value, sourceItemId?)- Add memorygetMemory()- Get all memory itemsdeleteMemory(id)- Delete memorygetMemoryAsMarkdown()- Serialize to principles.md format
Chat
addMessage(itemId, role, content)- Add chat messagegetMessages(itemId, limit?)- Get chat history
Settings
getSettings()- Get user settingsupdateSettings(updates)- Update settings
Board State
getBoardState()- Get board state with columns
Git Sync
configureGit(config)- Configure Git settingssyncToGit(itemId)- Sync single itemsyncAllToGit()- Sync all items
Types
interface StoredItem {
id: string
title: string
slug: string
type: 'task' | 'routine' | 'feature'
status: 'new' | 'decomposing' | 'in_progress' |
'waiting_approval' | 'done' | 'archived'
parentId?: string
createdAt: number
updatedAt: number
}
interface MemoryItem {
id: string
category: 'people' | 'preferences' | 'location' | 'work' | 'general'
key: string
value: string
sourceItemId?: string
createdAt: number
}
interface Message {
id: string
itemId: string
role: 'user' | 'assistant'
content: string
createdAt: number
}
interface GitConfig {
token: string
repo: string
rootDir: string
branch?: string
}See the full type definitions for all exported types.
Design Principles
- No infrastructure leakage - No Cloudflare, SQLite, or HTTP transport types
- All methods async - Works with any backend (network, filesystem, database)
- Generic items - Single interface for features, tasks, and routines
- Chat is ephemeral - Stored but never synced to Git
- Memory has provenance - Track which item a memory came from
Related Packages
@specifica/format- Parser and serializer for Specifica markdown format
License
MIT
