@postnesia/db 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/BOOTSTRAP.md CHANGED
@@ -8,7 +8,13 @@ You have a persistent memory system at `openmind/`. This is not optional — use
8
8
  - **L2 (Associative Memory):** Vector similarity search against the database. Use `memory_search` to pull relevant context you don't have in L1.
9
9
  - **L3 (Deep Storage):** Full-detail records. Access by memory ID when you need the complete picture.
10
10
 
11
- ## MCP Tools Available
11
+ ## Tool Access
12
+
13
+ Tools are available in two modes depending on how you are connected.
14
+
15
+ ### MCP (preferred)
16
+
17
+ If an MCP connection to `postnesia-mcp` is active, use MCP tools directly:
12
18
 
13
19
  | Tool | When to Use |
14
20
  |---|---|
@@ -25,11 +31,35 @@ You have a persistent memory system at `openmind/`. This is not optional — use
25
31
  | `task_update` | Update a task's status, title, or description. |
26
32
  | `task_list` | List tasks filtered by status and/or session_id. Use at session start to resume open work. |
27
33
 
34
+ ### CLI fallback (no MCP connection)
35
+
36
+ If no MCP connection is available, use the `postnesia` CLI via Bash. Every MCP tool has a direct equivalent:
37
+
38
+ | MCP Tool | CLI Command |
39
+ |---|---|
40
+ | `memory_search` | `postnesia memory search "<query>" [--limit N]` |
41
+ | `memory_add` | `postnesia memory add "<content>" --type <type> --importance <1-5> --tags "<t1,t2>" [--content-l1 "<summary>"] [--context "<ctx>"] [--core]` |
42
+ | `memory_update_core` | `postnesia memory update-core <id> --content "<content>" --content-l1 "<summary>"` |
43
+ | `memory_recent` | `postnesia memory recent [--hours N] [--limit N]` |
44
+ | `memory_stats` | `postnesia memory stats` |
45
+ | `memory_consolidate` | `postnesia memory consolidate` |
46
+ | `memory_relationships` | `postnesia memory relationships <id>` |
47
+ | `journal_add` | `postnesia journal add <YYYY-MM-DD> "<content>" [--learned "..."] [--key-moments "..."] [--mood "..."]` |
48
+ | `journal_recent` | `postnesia journal recent [--days N]` |
49
+ | `task_create` | `postnesia task create "<title>" [-d "<description>"] [-s <session-id>]` |
50
+ | `task_update` | `postnesia task update <id> [-s <status>] [-t "<title>"] [-d "<description>"]` |
51
+ | `task_list` | `postnesia task list [--status <status>] [--session-id <id>] [-l N]` |
52
+
53
+ All CLI commands output plain text or JSON to stdout, identical to MCP responses.
54
+
28
55
  ## Session Start Checklist
29
56
 
30
57
  1. Check open tasks: `task_list(status="pending")` or `task_list(session_id="<project>", status="pending")`
58
+ - CLI: `postnesia task list --status pending [--session-id <project>]`
31
59
  2. Search relevant lessons: `memory_search("lesson")` for the current project context
60
+ - CLI: `postnesia memory search "lesson"`
32
61
  3. Review recent memories if needed: `memory_recent(hours=24)`
62
+ - CLI: `postnesia memory recent --hours 24`
33
63
 
34
64
  ## Task Workflow
35
65
 
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Wrapper around `prisma migrate dev`.
4
+ *
5
+ * Prisma migrate dev generates new migration SQL files from schema changes.
6
+ * Pass --name <migration-name> to label the migration.
7
+ *
8
+ * Usage:
9
+ * tsx src/migrate-dev.ts
10
+ * tsx src/migrate-dev.ts --name add-users-table
11
+ */
12
+ export {};
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Wrapper around `prisma migrate dev`.
4
+ *
5
+ * Prisma migrate dev generates new migration SQL files from schema changes.
6
+ * Pass --name <migration-name> to label the migration.
7
+ *
8
+ * Usage:
9
+ * tsx src/migrate-dev.ts
10
+ * tsx src/migrate-dev.ts --name add-users-table
11
+ */
12
+ import { spawnSync } from 'node:child_process';
13
+ const args = process.argv.slice(2);
14
+ const result = spawnSync('npx', ['prisma', 'migrate', 'dev', '--name', 'init'], {
15
+ stdio: 'inherit',
16
+ shell: true,
17
+ });
18
+ process.exit(result.status ?? 1);
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copies prisma/schema.prisma from the @postnesia/db package into the
4
+ * consuming project's prisma/ directory, then runs `prisma migrate dev`.
5
+ *
6
+ * Run this from the root of the project that has @postnesia/db installed.
7
+ *
8
+ * Usage:
9
+ * postnesia-migrate-init
10
+ * postnesia-migrate-init --name add-users-table
11
+ */
12
+ export {};
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copies prisma/schema.prisma from the @postnesia/db package into the
4
+ * consuming project's prisma/ directory, then runs `prisma migrate dev`.
5
+ *
6
+ * Run this from the root of the project that has @postnesia/db installed.
7
+ *
8
+ * Usage:
9
+ * postnesia-migrate-init
10
+ * postnesia-migrate-init --name add-users-table
11
+ */
12
+ import { cpSync, mkdirSync } from 'node:fs';
13
+ import { join, dirname } from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+ import { spawnSync } from 'node:child_process';
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+ // Location of schema.prisma inside the @postnesia/db package
18
+ const schemaSource = join(__dirname, '../prisma/schema.prisma');
19
+ // Destination: prisma/ at the root of the consuming project
20
+ const targetDir = join(process.cwd(), 'prisma');
21
+ const schemaDest = join(targetDir, 'schema.prisma');
22
+ mkdirSync(targetDir, { recursive: true });
23
+ cpSync(schemaSource, schemaDest);
24
+ console.log(`Copied schema.prisma → ${schemaDest}`);
25
+ const args = process.argv.slice(2);
26
+ const result = spawnSync('npx', ['prisma', 'migrate', 'dev', '--name', 'init'], {
27
+ stdio: 'inherit',
28
+ shell: true,
29
+ cwd: process.cwd(),
30
+ });
31
+ process.exit(result.status ?? 1);
package/dist/seed.js CHANGED
@@ -47,6 +47,7 @@ try {
47
47
  'CORE: Memory system operational guide.',
48
48
  'L1=auto-loaded working memory, L2=vector search, L3=deep storage.',
49
49
  'Tools: memory_search, memory_add, memory_update_core, memory_recent, memory_stats, memory_consolidate, journal_add, journal_recent, task_create, task_update, task_list.',
50
+ 'NO MCP: use postnesia CLI — postnesia memory search|add|update-core|recent|stats|consolidate|relationships, postnesia journal add|recent, postnesia task create|update|list.',
50
51
  'SESSION START: task_list(status=pending) to resume work + memory_search("lesson").',
51
52
  'TASKS: task_create(title,session_id)→in_progress→completed. Tasks persist across sessions.',
52
53
  'Core memories: update with memory_update_core, never supersede.',
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@postnesia/db",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "AI Agent memory context database",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "main": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
9
  "bin": {
10
- "postnesia-seed": "./dist/seed.js"
10
+ "postnesia-seed": "./dist/seed.js",
11
+ "postnesia-migrate-dev": "./dist/migrate-dev.js",
12
+ "postnesia-migrate-init": "./dist/migrate-init.js"
11
13
  },
12
14
  "files": [
13
15
  "dist",
14
16
  "core",
17
+ "prisma.config.ts",
15
18
  "prisma/schema.prisma"
16
19
  ],
17
20
  "exports": {
@@ -43,6 +46,8 @@
43
46
  "db:generate": "prisma generate",
44
47
  "db:migrate": "tsx src/migrate.ts",
45
48
  "db:migrate:status": "tsx src/migrate.ts --status",
49
+ "db:migrate:dev": "tsx src/migrate-dev.ts",
50
+ "db:migrate:init": "tsx src/migrate-init.ts",
46
51
  "db:migrate:diff": "tsx src/migrate-diff.ts",
47
52
  "backup": "tsx src/backup.ts",
48
53
  "seed": "tsx src/seed.ts"
@@ -0,0 +1,12 @@
1
+ import 'dotenv/config';
2
+ import { defineConfig, env } from "prisma/config";
3
+
4
+ export default defineConfig({
5
+ schema: "prisma/schema.prisma",
6
+ migrations: {
7
+ path: "prisma/migrations",
8
+ },
9
+ datasource: {
10
+ url: env('DATABASE_URL'),
11
+ },
12
+ });