diff --git a/CHANGELOG.md b/CHANGELOG.md index cfe0e31..6349440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,5 @@ # Changelog -## 1.0.2 — 2026-12-04 - -- Правила: перед исследованием репозитория, сервера или CI сначала искать процедуру в памяти. -- memory_search по умолчанию ищет по всей установке, включая заметки других проектов. - ## 1.0.1 — 2026-12-03 - Первая версия, обработанная npm после ревью; содержимое пакета без изменений. diff --git a/docs/SITE.md b/docs/SITE.md deleted file mode 100644 index 07ee9cf..0000000 --- a/docs/SITE.md +++ /dev/null @@ -1,93 +0,0 @@ -# Memory & Vault - -> **Память и сейф паролей для DeepSeek Harness** - -[![npm](https://img.shields.io/npm/v/%40itmarkovnpm%2Fdsh-memory-vault?color=41b883&label=npm)](https://www.npmjs.com/package/@itmarkovnpm/dsh-memory-vault) -[![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) -[![node](https://img.shields.io/badge/node-%E2%89%A522.13-brightgreen.svg)](https://nodejs.org) - -Агент больше не начинает каждый чат с чистого листа. Memory & Vault хранит то, что выяснилось в прошлых сессиях — конвенции, решения, ловушки, доступы — и отдаёт это модели в нужный момент. - -Заметки живут локально и зеркалятся на ваш сервер. Пароли и токены лежат отдельно, под замком, и попадают к агенту только тогда, когда действительно нужны. - ---- - -## Две вещи в одном плагине - -| | **Память** | **Сейф** | -|---|---|---| -| **Что хранит** | предпочтения, конвенции, решения, инфраструктуру, ловушки | пароли, токены, API-ключи, пары логин/пароль | -| **Как попадает к агенту** | автоматический recall + поиск по ключевым словам | только по явному `secret_get`, с предупреждением | -| **Где лежит** | `memory_entries`, обе базы | `memory_secrets`, обе базы | -| **Интерфейс** | команда `/memory`, карточка плагина | менеджер паролей в карточке и вкладка в боковой панели | - ---- - -## Возможности - -- **Память, которая не теряется.** Запись идёт в локальную SQLite всегда, а в PostgreSQL — когда сервер доступен. Сервер упал — работа продолжается локально и догоняется позже. -- **Чтение «сервер → локально → досыл».** Сначала спрашиваем сервер, при пустом ответе берём локальную базу и возвращаем найденное на сервер. -- **Разделы заметок.** `personal`, `home-server`, имя проекта или сайта, `dsh` — чтобы «всё про домашний сервер» лежало в одном месте. -- **Поиск с индексами.** FTS5 в SQLite; GIN по словоформам, триграммам и тегам в PostgreSQL. Работает и по чужим проектам: деплой-плейбук находится из любой сессии. -- **Обновление вместо дублей.** `memory_update` переписывает запись на месте, сохраняя id и историю. -- **Правила в системном промпте.** Когда сохранять, что не хранить, как обращаться с кредами — модель следует этому без напоминаний. -- **Сейф с менеджером.** Поиск, показ на 30 секунд, копирование в буфер, добавление, правка, удаление. Список отдаёт только метаданные. -- **Внешняя база по просьбе.** Скажите «разверни внешнюю базу» — агент спросит, где, поднимет PostgreSQL в Docker, применит схему, подключит плагин и проверит. - ---- - -## Как это выглядит в работе - -```text -Пользователь: выкати itmarkov.ru - -Агент: memory_search("деплой itmarkov forgejo") - → схема /opt/проект, releases/, current - → CI tests → build → deploy по ssh, DEPLOY_SSH_KEY - → ждать прогон через actions/tasks - - дальше — по записанной процедуре, а не с нуля -``` - ---- - -## Установка - -```bash -dsh plugin add @itmarkovnpm/dsh-memory-vault -``` - -Или в интерфейсе: **Plugins → Add plugin** → `@itmarkovnpm/dsh-memory-vault`. - -**Требования:** DeepSeek Harness 0.2.x, Node.js 22.13+. PostgreSQL не обязателен — без него всё работает локально. - ---- - -## Хранение - -```text - ┌──────────────────┐ запись всегда ┌──────────────────┐ - │ SQLite (локально) │ ───────────────────────────▶ │ PostgreSQL (сервер) │ - │ memory.sqlite │ ◀─────────────────────────── │ memory_entries │ - └──────────────────┘ чтение: сервер первым └──────────────────┘ - │ │ - └──── досыл найденного ──┘ -``` - -Секреты не попадают в заметки: для них отдельная таблица, отдельные инструменты и отдельный экран. - ---- - -## Безопасность - -> **Секреты хранятся в открытом виде** — в локальной SQLite и в PostgreSQL, как и любой файл с паролями. Доступ к файлу или базе означает доступ к кредам. Для автоматизации передавайте их через переменные окружения или `$DSH_HOME/.env`, а базу держите в LAN или за VPN. - ---- - -## Ссылки - -- npm: https://www.npmjs.com/package/@itmarkovnpm/dsh-memory-vault -- исходники: https://git.itmarkov.ru/dmarkov/dsh-memory-vault -- лицензия: [MIT](LICENSE) - -

Сделано для DeepSeek Harness · память, которая остаётся

diff --git a/docs/SITE.short.md b/docs/SITE.short.md deleted file mode 100644 index ae5b8c1..0000000 --- a/docs/SITE.short.md +++ /dev/null @@ -1,23 +0,0 @@ -# Memory & Vault - -**Память и сейф паролей для DeepSeek Harness.** - -Агент запоминает конвенции, решения и ловушки между сессиями, а пароли и токены хранит отдельно — в сейфе с менеджером прямо в интерфейсе. - -- заметки в локальной SQLite с зеркалом в PostgreSQL на вашем сервере; -- разделы `personal`, `home-server`, проект или сайт; -- поиск с индексами (FTS5 / GIN), обновление записей без дублей; -- пароли, токены и ключи — отдельная таблица, доступ только по запросу; -- правила памяти и секретов в системном промпте. - -**Установка** - -```bash -dsh plugin add @itmarkovnpm/dsh-memory-vault -``` - -Или: **Plugins → Add plugin** → `@itmarkovnpm/dsh-memory-vault`. Нужен Node.js 22.13+, PostgreSQL не обязателен. - -Секреты хранятся в открытом виде в обеих базах — держите сервер в LAN или за VPN. - -[npm](https://www.npmjs.com/package/@itmarkovnpm/dsh-memory-vault) · [исходники](https://git.itmarkov.ru/dmarkov/dsh-memory-vault) · MIT diff --git a/docs/hero.png b/docs/hero.png deleted file mode 100644 index 3121ece..0000000 Binary files a/docs/hero.png and /dev/null differ diff --git a/docs/hero.svg b/docs/hero.svg deleted file mode 100644 index f89e64e..0000000 --- a/docs/hero.svg +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/index.js b/index.js index 9109f38..e33b603 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,6 @@ You have durable memory shared by every session in this installation (plugin \`m The recall block in context is a cached digest and may lag behind the store. - **One signal is enough.** Save immediately, without asking and without waiting for confirmation, when any of these appear: a user preference, correction, or feedback; a project convention; an architectural decision together with its reason; an environment fact; a non-obvious gotcha that will outlive this session. Never ask the user whether to save. -- **Start from memory.** Before exploring a repository, server, or CI system, call \`memory_search\` with the task's keywords (deploy, release, pipeline, forgejo, service or host name). Earlier sessions likely recorded the procedure, the exact commands, and its gotchas: read that note and follow it instead of re-deriving the setup from scratch. Re-research only when memory has nothing or the note proves stale. - **Check before writing.** Call \`memory_search\` first. If a note already covers the topic but the fact changed, rewrite it in place with \`memory_update\` (same id, same history); use \`memory_forget\` + \`memory_save\` only when the old note is about something else. Do not keep two contradicting notes. - **One topic per note, one collection per note.** Write for a future session that knows nothing about this conversation: name the paths, commands, services, and reasons. Give the note a collection: \`personal\` for user facts and preferences, \`home-server\` for infrastructure, the project or site name (e.g. \`autoan\`, \`itmarkov.ru\`) for project knowledge, \`dsh\` for the harness itself. Scope \`global\` for user-wide facts, \`workspace\` for this project's conventions and decisions. Pin only rules that must always apply. When searching, pass \`collection\` to narrow the store. - **Do not save:** transient task state, secrets or credentials, anything already in the repository or AGENTS.md, unverified claims, point-in-time values (line numbers, counts, commit hashes), or facts that are cheaper to re-derive from the code than to recall. @@ -448,8 +447,6 @@ function createLocalStore(logger) { const cwdParam = cwd ?? null if (scope === 'global') return { sql: `scope = 'global'`, params: [] } if (scope === 'workspace') return { sql: `scope = 'workspace' AND workspace IS ?`, params: [cwdParam] } - // all без каталога = вся память установки, включая заметки других проектов. - if (scope === 'all' && cwdParam === null) return { sql: '1 = 1', params: [] } return { sql: `(scope = 'global' OR (scope = 'workspace' AND workspace IS ?))`, params: [cwdParam] } } @@ -642,10 +639,8 @@ function createPgStore(pool, logger) { ? `scope = 'global'` : scope === 'workspace' ? `scope = 'workspace' AND workspace = $1` - : scope === 'all' && cwd === undefined - ? `true` - : `(scope = 'global' OR (scope = 'workspace' AND workspace = $1))` - const params = (scope === 'global' || (scope === 'all' && cwd === undefined)) ? [] : [cwd ?? null] + : `(scope = 'global' OR (scope = 'workspace' AND workspace = $1))` + const params = scope === 'global' ? [] : [cwd ?? null] const filters = [where] if (collection) { filters.push(`collection = $${params.length + 1}`); params.push(collection) } params.push(limit) @@ -662,10 +657,8 @@ function createPgStore(pool, logger) { ? `scope = 'global'` : scope === 'workspace' ? `scope = 'workspace' AND workspace = $2` - : scope === 'all' && cwd === undefined - ? `true` - : `(scope = 'global' OR (scope = 'workspace' AND workspace = $2))` - const params = (scope === 'global' || (scope === 'all' && cwd === undefined)) ? [needle] : [needle, cwd ?? null] + : `(scope = 'global' OR (scope = 'workspace' AND workspace = $2))` + const params = scope === 'global' ? [needle] : [needle, cwd ?? null] let filters = [where] if (collection) { filters.push(`collection = $${params.length + 1}`); params.push(collection) } const likeIndex = params.length + 1 @@ -1089,13 +1082,13 @@ function createTools(ctx, engine, settings, recall) { { name: 'memory_search', description: - 'Search saved memory notes by keyword (substring of the note or an exact tag). Searches every collection and every project by default, so a deployment or CI note saved in another workspace is found here. ' - + 'Call it before exploring a repository, server, or CI system: earlier sessions likely recorded the procedure and its gotchas.', + 'Search saved memory notes by keyword (substring of the note or an exact tag). ' + + 'Call it when the user refers to something from an earlier session, an earlier decision, or a preference you do not see in the current conversation.', parameters: { type: 'object', properties: { query: { type: 'string', description: 'Keyword or phrase to look for.' }, - scope: { type: 'string', enum: ['all', 'global', 'workspace'], description: 'all (default) searches everything; global only user-wide notes; workspace only notes of the current working directory.' }, + scope: { type: 'string', enum: ['global', 'workspace', 'all'], description: 'Limit to global notes, workspace notes, or both (default).' }, collection: { type: 'string', description: 'Only notes from this collection (personal, home-server, project/site name). Optional.' }, limit: { type: 'number', description: 'Maximum results, 1-20 (default 8).' }, }, @@ -1108,8 +1101,7 @@ function createTools(ctx, engine, settings, recall) { if (text.length === 0) throw new Error('memory: `query` must be a non-empty string') const limit = clampInt(args.limit, 1, 20, 8) const scope = args.scope === 'global' || args.scope === 'workspace' ? args.scope : 'all' - const cwd = scope === 'workspace' ? sessionCwd(ctx, exec) : undefined - const rows = await engine.search(text.toLowerCase(), scope, cwd, limit, normalizeCollection(args.collection)) + const rows = await engine.search(text.toLowerCase(), scope, sessionCwd(ctx, exec), limit, normalizeCollection(args.collection)) if (rows.length === 0) return `No memories match ${JSON.stringify(text)}.` return `Found ${rows.length} memor${rows.length === 1 ? 'y' : 'ies'}:\n${rows.map(row => formatRow(row, { showDate: true })).join('\n')}` }, diff --git a/package.json b/package.json index 0e76f8c..1058519 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@itmarkovnpm/dsh-memory-vault", - "version": "1.0.2", + "version": "1.0.1", "description": "Memory \u0026 Vault: durable agent notes and a password/secret vault for DeepSeek Harness. Local SQLite plus an optional PostgreSQL mirror, indexed search, agent tools, /memory commands, global rules, a bundled setup skill, and an in-app password manager.", "type": "module", "license": "MIT",