memduck
v0.1.2
Published
A self-hosted personal memory engine for digesting external content into reusable memory.
Maintainers
Readme
memduck
A self-hosted personal memory engine
memduck digests links, copied text, and screenshots into reusable memory cards you can ask, revisit, and deepen over time. It is designed for single-user, self-hosted workflows and keeps the first version intentionally simple: one Next.js app, SQLite storage, local file assets, a thin browser extension, and a Telegram bot that all speak the same API.
Why it exists
Most tools help you save more. memduck is meant to help you understand first.
- Keep the raw source so you can always go back.
- Compress long external content into a card worth reopening.
- Group repeated material into topics instead of a flat inbox.
- Let Q&A and review reuse only what you have actually saved.
- Keep provider profiles, channel settings, and onboarding visible in the web UI.
- Use provider-backed embeddings plus reranking so Ask feels like real memory retrieval instead of keyword search.
- Keep topic summaries and review buckets compiled in the background, not rebuilt only from heuristics at render time.
- Let users explicitly star, highlight, and queue cards for review so memory weighting is visible instead of implicit only.
- Show runtime diagnostics in the channel center so self-hosters can debug readiness in the browser, not only in the terminal.
MVP stack
Next.jsfor the web UI and APISQLitefor local development storagebetter-sqlite3for a zero-setup embedded databasegrammYfor the Telegram botManifest V3browser extension for low-friction capture
Quick start
npm install path
Install the published CLI package:
npm install -g memduck@latest
memduckTo run Telegram together with the web runtime:
memduck --with-telegramThe npm-style runtime stores config and SQLite state under ~/.memduck by default.
Source checkout path
Use this path when developing memduck itself from the GitHub repository.
- Install dependencies
pnpm install- Start the local stack
pnpm memduck devTo run the web app, worker, and Telegram bot together:
pnpm memduck dev --with-telegramThe setup flow now walks you through:
- building a provider library with OpenAI, Anthropic, Gemini, Ollama, or OpenAI-compatible profiles
- activating one provider profile for the current runtime
- selecting embedding and rerank models so Ask uses semantic retrieval
- creating the first real memory card
- opening the channel center for Telegram and extension defaults
If you want a quick health check before opening the browser:
pnpm memduck doctorRuntime data is stored under ~/.memduck/runtime by default. Set MEMDUCK_HOME if you want a different home directory.
Optional entry points
Browser extension
Build the unpacked extension:
pnpm extension:buildThen load extension/dist as an unpacked Chrome extension. The popup lets you point at your local app URL and send either the current page or the selected text into /api/ingest.
The popup also:
- pings memduck on open
- syncs the extension base URL from the channel center when possible
- reports extension heartbeat status back to
/channels
Telegram bot
Either save the Telegram bot token in the web UI under /channels, or set TELEGRAM_BOT_TOKEN, then run:
memduck --with-telegramThe bot forwards links, text, and screenshots to the same local memduck API. Use /ask <question> for grounded Q&A and /review for the current review queue.
When the bot is running, it also sends heartbeats so the channel center can show whether Telegram has checked in recently.
Product shape
/setup: visual onboarding, provider library, first-memory flow/channels: channel center for Telegram, extension, and web runtime defaults/memory/:id: memory detail view with explicit signal actions and traceability/topics: topic overview with compiled summaries, repeated points, conflict points, and next questions/ask: persisted multi-turn threads grounded in semantic retrieval over your saved memory/review: compiled review buckets for today, high-value material, and theme momentum
Retrieval, grounding, and compilation
- Ready cards are embedded and stored locally in SQLite when the active provider profile includes an embedding model.
- Source text is chunked and embedded so Ask citations can point to original source spans, not only memory-card summaries.
- Ask embeds the incoming query, performs semantic retrieval over stored cards, then reranks the top candidates before answering.
- Topic links are model-resolved and persisted with confidence and reasoning, so topic pages can explain why cards belong together.
- The worker compiles topic summaries and review buckets in the background so the web UI is reading a persisted memory view rather than rebuilding everything ad hoc.
API surface
POST /api/channels/heartbeatPOST /api/ingestGET /api/setup-stateGET /api/conversationsGET /api/conversations/:idGET /api/memory-cardsGET /api/memory-cards/:idPOST /api/memory-cards/:id/analyzePOST /api/askPOST /api/searchPOST /api/topics/:id/askPATCH /api/topics/:idPOST /api/topics/:id/mergeDELETE /api/topics/:id/linksGET /api/reviewGET /api/settings/channelsPOST /api/settings/channelsGET /api/settings/providersPOST /api/settings/providersDELETE /api/settings/providersPOST /api/settings/providers/activatePOST /api/settings/provider/testPOST /api/settings/uiPOST /api/signals
CLI
memduck: create local runtime state if needed, start the packaged web server and worker, then open the dashboardmemduck --with-telegram: start web, worker, and Telegram together; Telegram is never started implicitlymemduck doctor: verify local runtime, provider, and Telegram readiness without mutating statepnpm memduck dev: start Next.js plus the background compiler worker from a source checkoutpnpm memduck dev --with-telegram: start the source web app, worker, and Telegram bot togetherpnpm worker:dev: run only the knowledge compiler workerpnpm check: run lint, typecheck, tests, extension build, and production build
If you type an unknown command or flag, memduck prints CLI usage and exits non-zero instead of guessing what you meant.
Publishing
Before publishing a new npm version:
pnpm check
npm publishThe package prepack script builds the CLI entrypoints and Next.js production app so the published memduck binary points at dist/cli.mjs instead of TypeScript source.
Quality gate
Before publishing, tagging, or opening a substantial change, run:
pnpm checkThis is the same gate used by CI. It verifies lint, TypeScript, Vitest, the browser extension build, and the Next.js production build.
Docs
- Chinese PRD: docs/prd.zh-CN.md
- Simplified MVP architecture: docs/architecture.zh-CN.md
- Open source release checklist: docs/open-source-release-checklist.md
- Contributing: CONTRIBUTING.md
- Security policy: SECURITY.md
- Code of conduct: CODE_OF_CONDUCT.md
- License: LICENSE
