@mathew-cf/opencode-memory 0.2.0 → 0.2.1

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/dist/config.d.ts CHANGED
@@ -11,8 +11,14 @@
11
11
  * The snippet appended to subagent prompts. Captured in one place so
12
12
  * tests can snapshot it and users can `Edit` it locally if they want a
13
13
  * different emphasis.
14
+ *
15
+ * Sections beyond "Memory & Sessions" / "Discoveries worth saving" are
16
+ * generic agent-quality nudges that pair naturally with the memory
17
+ * protocol — they describe how to deliver an answer once you've done
18
+ * the search work. They're scoped tight enough not to crowd out the
19
+ * memory bits but useful enough to ship as opinionated defaults.
14
20
  */
15
- export declare const MEMORY_PROMPT_APPENDIX = "## Memory & Sessions\n\n1. **Before work:** call `memory_search` and `session_search` with your topic. Read results \u2014 don't just glance at summaries.\n2. **When something is unfamiliar mid-task** (tool, API, pattern, build system): search both `memory_search` and `session_search` BEFORE attempting. Use previous sessions to inform your approach \u2014 don't try first, search first.\n3. **When you discover something reusable:** write to ~/opencode-memory/{category}/{filename}.md and `memory_save` immediately. Never defer, never ask.\n\nIf you can't write to memory, end your response with:\n## Discoveries worth saving\n- [list findings that took >1 min to figure out]\n\n## Ground in code\n\nNEVER answer questions about a codebase from training data. Always open the actual files first.";
21
+ export declare const MEMORY_PROMPT_APPENDIX = "## Memory & Sessions\n\n1. **Before work:** call `memory_search` and `session_search` with your topic. Read results \u2014 don't just glance at summaries.\n2. **When something is unfamiliar mid-task** (tool, API, pattern, build system): search both `memory_search` and `session_search` BEFORE attempting. Use previous sessions to inform your approach \u2014 don't try first, search first.\n3. **When you discover something reusable:** write to ~/opencode-memory/{category}/{filename}.md and `memory_save` immediately. Never defer, never ask.\n\nIf you can't write to memory, end your response with:\n## Discoveries worth saving\n- [list findings that took >1 min to figure out]\n\n## Ground in code\n\nNEVER answer questions about a codebase from training data. Always open the actual files first.\n\n## Synthesis\n\nEnd with: a clear conclusion (recommendation, diagnosis, or finding), your confidence level, any conflicts or open questions, and concrete next steps where applicable.\n\n## Source age\n\nFlag anything > 1 year old as potentially stale.";
16
22
  /**
17
23
  * Subagents that should get the memory prompt appendix. These are the
18
24
  * built-in subagent names used by OpenCode — custom agents are left alone.
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,kyBAY6D,CAAC;AAEjG;;;GAGG;AACH,eAAO,MAAM,aAAa,uEAMhB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOtD,CAAC;AAEF,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC/C,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;QACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;KACvD,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD,IAAI,CA6DN"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,kiCAoBc,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,aAAa,uEAMhB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOtD,CAAC;AAEF,UAAU,UAAU;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC/C,UAAU,CAAC,EAAE;QACX,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;QACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;KACvD,CAAC;CACH;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD,IAAI,CA6DN"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from "node:module";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __returnValue = (v) => v;
3
4
  function __exportSetter(name, newValue) {
@@ -12,6 +13,7 @@ var __export = (target, all) => {
12
13
  set: __exportSetter.bind(all, name)
13
14
  });
14
15
  };
16
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
15
17
 
16
18
  // src/index.ts
17
19
  import { dirname, resolve } from "node:path";
@@ -76,7 +78,15 @@ If you can't write to memory, end your response with:
76
78
 
77
79
  ## Ground in code
78
80
 
79
- NEVER answer questions about a codebase from training data. Always open the actual files first.`;
81
+ NEVER answer questions about a codebase from training data. Always open the actual files first.
82
+
83
+ ## Synthesis
84
+
85
+ End with: a clear conclusion (recommendation, diagnosis, or finding), your confidence level, any conflicts or open questions, and concrete next steps where applicable.
86
+
87
+ ## Source age
88
+
89
+ Flag anything > 1 year old as potentially stale.`;
80
90
  var TARGET_AGENTS = [
81
91
  "general",
82
92
  "explore",
@@ -12632,8 +12642,8 @@ function todayISO() {
12632
12642
  }
12633
12643
 
12634
12644
  // src/lib/rag.ts
12635
- import { createRequire } from "node:module";
12636
- var require2 = createRequire(import.meta.url);
12645
+ import { createRequire as createRequire2 } from "node:module";
12646
+ var require2 = createRequire2(import.meta.url);
12637
12647
  function resolveRagBinary() {
12638
12648
  try {
12639
12649
  return require2.resolve("@mathew-cf/rag-cli/bin/rag.js");
@@ -12683,10 +12693,21 @@ function spawnRagIndex(args) {
12683
12693
  });
12684
12694
  return true;
12685
12695
  }
12696
+ async function downloadModel() {
12697
+ const shim = resolveRagBinary();
12698
+ if (!shim)
12699
+ return installGuidance();
12700
+ try {
12701
+ const out = await Bun.$`${shim} download`.text();
12702
+ return out.trim() || "Model downloaded.";
12703
+ } catch (err) {
12704
+ return `rag download failed: ${String(err)}`;
12705
+ }
12706
+ }
12686
12707
 
12687
12708
  // src/lib/ripgrep.ts
12688
- import { createRequire as createRequire2 } from "node:module";
12689
- var require3 = createRequire2(import.meta.url);
12709
+ import { createRequire as createRequire3 } from "node:module";
12710
+ var require3 = createRequire3(import.meta.url);
12690
12711
  function resolveRgBinary() {
12691
12712
  try {
12692
12713
  const mod = require3("@vscode/ripgrep");
@@ -13504,7 +13525,7 @@ ${r.text}`).join(`
13504
13525
  }
13505
13526
 
13506
13527
  // src/index.ts
13507
- var __dirname = "/Users/mat/repos/github.com/mathew-cf/opencode-memory/src";
13528
+ var __dirname = "/home/runner/work/opencode-memory/opencode-memory/src";
13508
13529
  function resolveSkillsDir() {
13509
13530
  try {
13510
13531
  const here = typeof import.meta !== "undefined" && import.meta.url ? dirname(fileURLToPath(import.meta.url)) : typeof __dirname !== "undefined" ? __dirname : undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mathew-cf/opencode-memory",
3
- "version": "0.2.0",
4
- "description": "Persistent cross-session memory for OpenCode \u2014 a hybrid keyword + semantic search layer over a local markdown knowledge base, plus session history tools and guardrails that nudge agents to use them.",
3
+ "version": "0.2.1",
4
+ "description": "Persistent cross-session memory for OpenCode a hybrid keyword + semantic search layer over a local markdown knowledge base, plus session history tools and guardrails that nudge agents to use them.",
5
5
  "author": "mat",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -11,12 +11,15 @@
11
11
  "type": "module",
12
12
  "main": "dist/index.js",
13
13
  "types": "dist/index.d.ts",
14
+ "bin": {
15
+ "opencode-memory": "dist/cli.js"
16
+ },
14
17
  "files": [
15
18
  "dist",
16
19
  "skills"
17
20
  ],
18
21
  "scripts": {
19
- "build": "bun build src/index.ts --outdir dist --target node && tsc --emitDeclarationOnly",
22
+ "build": "bun build src/index.ts src/cli.ts --outdir dist --target node && tsc --emitDeclarationOnly",
20
23
  "test": "bun test",
21
24
  "prepublishOnly": "bun run build",
22
25
  "typecheck": "tsc --noEmit",
@@ -285,11 +285,18 @@ Both search backends ship as npm dependencies with prebuilt binaries:
285
285
 
286
286
  No manual install is needed — `npm install` (or whatever installs this plugin) pulls in both and resolves them via `require.resolve` at runtime. Nothing depends on `$PATH`.
287
287
 
288
- After install, run once to pre-cache the embedding model (optional but makes the first semantic search instant):
288
+ ### One-shot bootstrap
289
+
290
+ The plugin ships a CLI that does everything in one step:
289
291
 
290
292
  ```bash
291
- memory_setup # reports which backends are resolvable
292
- rag download # downloads the MiniLM-L6 weights (~90MB)
293
+ bunx @mathew-cf/opencode-memory init
293
294
  ```
294
295
 
295
- If a backend fails to install (unsupported platform, etc.), the tools degrade gracefully `memory_search` still returns whatever the available backend can find. Call `memory_setup` any time to see install guidance for the missing piece.
296
+ This creates the memory dir if missing, runs `git init`, scaffolds the category subdirs, and downloads the embedding model. Idempotent safe to re-run.
297
+
298
+ Other CLI subcommands:
299
+ - `bunx @mathew-cf/opencode-memory status` — report backend resolution (same as `memory_setup` tool)
300
+ - `bunx @mathew-cf/opencode-memory init --skip-model` — bootstrap dirs only, defer the download
301
+
302
+ If a backend fails to install (unsupported platform, etc.), the tools degrade gracefully — `memory_search` still returns whatever the available backend can find.