@dzhi/ocpg 0.7.0 → 0.8.0

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.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/ocpg.ts +5 -15
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -19,6 +19,8 @@ In `opencode.json`:
19
19
 
20
20
  ## Connecting to the database
21
21
 
22
+ Need a Postgres instance? The [`deploy/`](./deploy) directory ships a hardened Docker Compose setup (localhost-only, `memories` schema auto-created on first boot) — see [`deploy/README.md`](./deploy/README.md).
23
+
22
24
  Configure the connection via environment variables, e.g. in `~/.zshenv`. Any Postgres user and database name will do — use whatever names fit your setup and mirror them here:
23
25
 
24
26
  ```bash
@@ -36,7 +38,7 @@ export OCPG_DB="ocpg"
36
38
  | `OCPG_USER` | `ocpguser` |
37
39
  | `OCPG_DB` | `ocpg` |
38
40
 
39
- **Password is env-only.** If `OCPG_PASSWORD` is unset, the plugin falls back to `pass show postgres-workstation-password` at startup.
41
+ **Password is env-only.** The plugin never reads config files, options, or external secret managers — set `OCPG_PASSWORD` in your shell environment (e.g. via direnv/.envrc, however you source your secrets).
40
42
 
41
43
  ## Tools
42
44
 
package/ocpg.ts CHANGED
@@ -12,18 +12,14 @@ type DbConfig = {
12
12
  type RecallArgs = { query?: string; global?: boolean; limit?: number };
13
13
  type RememberArgs = { content: string; tags?: string[] };
14
14
 
15
- // Defaults resolved ONCE at module init — the pass lookup here is the only permitted spawn in this file.
15
+ // Defaults resolved ONCE at module init — env-only, no process spawning.
16
16
  const defaultConfig: DbConfig = {
17
17
  host: process.env.OCPG_HOST || "localhost",
18
18
  port: Number(process.env.OCPG_PORT) || 5432,
19
19
  user: process.env.OCPG_USER || "ocpguser",
20
20
  database: process.env.OCPG_DB || "ocpg",
21
21
  };
22
- const password =
23
- process.env.OCPG_PASSWORD ||
24
- Bun.spawnSync(["pass", "show", "postgres-workstation-password"])
25
- .stdout.toString()
26
- .trim();
22
+ const password = process.env.OCPG_PASSWORD || "";
27
23
 
28
24
  // Options-object constructor, not a URL string: Bun's SQL parses string URLs via
29
25
  // url.parse(), which emits the DEP0169 DeprecationWarning at plugin load under opencode.
@@ -141,12 +137,6 @@ async function dispose(): Promise<void> {
141
137
 
142
138
  // --- Agent tools: recall + remember with dedup-on-write ---
143
139
 
144
- function normalizeTags(tags: string[] | undefined, projectDir: string): string[] {
145
- const input = tags ?? [];
146
- const base = projectDir.split('/').pop() ?? projectDir;
147
- return [...input, `project:${base}`];
148
- }
149
-
150
140
  async function recall(
151
141
  args: RecallArgs,
152
142
  ctx: { directory: string },
@@ -198,7 +188,8 @@ async function remember(
198
188
  return 'ERROR: content must be at least 10 characters.';
199
189
  }
200
190
 
201
- const normalizedTags = normalizeTags(args.tags, ctx.directory);
191
+ // Tags are stored verbatim — project scoping lives in the project column, not tags.
192
+ const tags = args.tags ?? [];
202
193
  const basename = ctx.directory.split('/').pop() ?? ctx.directory;
203
194
 
204
195
  // Dedup: project-scoped, common-opening-words AND-match via FTS
@@ -224,7 +215,7 @@ async function remember(
224
215
  // the element type hint is required for clean array storage.
225
216
  const inserted = await sql`
226
217
  INSERT INTO memories (content, tags, session_id, project)
227
- VALUES (${args.content}, ${sql.array(normalizedTags, "text")}, ${ctx.sessionID}, ${ctx.directory})
218
+ VALUES (${args.content}, ${sql.array(tags, "text")}, ${ctx.sessionID}, ${ctx.directory})
228
219
  RETURNING id
229
220
  ` as { id: number }[];
230
221
 
@@ -313,7 +304,6 @@ const __internals = {
313
304
  truncateMemory,
314
305
  formatBlock,
315
306
  handleTransform,
316
- normalizeTags,
317
307
  recall,
318
308
  remember,
319
309
  invalidateInjection,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dzhi/ocpg",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "type": "module",
5
5
  "description": "Postgres-backed persistent memory plugin for OpenCode",
6
6
  "main": "ocpg.ts",