opencode-fractal-memory 0.6.7 → 0.6.8

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.
@@ -93,6 +93,32 @@ export function queryNodes(scope) {
93
93
  db.close();
94
94
  return rows.map((r) => rowToNode(r));
95
95
  }
96
+ export function queryPlaybooks(scope) {
97
+ const db = openDb(scope);
98
+ if (!db)
99
+ return [];
100
+ const rows = db.query(`
101
+ SELECT id, label, content, metadata, times_used, usefulness_score
102
+ FROM memory_nodes
103
+ WHERE type = 'playbook' AND scope = ?
104
+ ORDER BY label
105
+ `).all(scope);
106
+ db.close();
107
+ return rows.map((r) => {
108
+ const meta = r.metadata ? JSON.parse(r.metadata) : {};
109
+ return {
110
+ id: r.id,
111
+ name: r.label || "",
112
+ description: r.content || "",
113
+ steps: meta.steps || [],
114
+ triggers: meta.triggers || [],
115
+ tags: meta.tags || [],
116
+ executionCount: meta.executionCount ?? r.times_used ?? 0,
117
+ avgDurationMs: meta.avgDurationMs ?? null,
118
+ lastExecutedAt: meta.lastExecutedAt ?? null,
119
+ };
120
+ });
121
+ }
96
122
  export function cosineSimilarity(a, b) {
97
123
  let dot = 0, normA = 0, normB = 0;
98
124
  for (let i = 0; i < a.length && i < b.length; i++) {
@@ -1,6 +1,6 @@
1
1
  import { memLog } from "../logging";
2
2
  import { generateEmbedding } from "../embeddings";
3
- import { queryNodes, getAvailableScopes, extractLinks, computeStats, readProjectConfig, writeProjectConfig, rowToNode, withDb, jsonResponse, cosineSimilarity, } from "./helpers";
3
+ import { queryNodes, queryPlaybooks, getAvailableScopes, extractLinks, computeStats, readProjectConfig, writeProjectConfig, rowToNode, withDb, jsonResponse, cosineSimilarity, } from "./helpers";
4
4
  function handleScopes() {
5
5
  return jsonResponse(getAvailableScopes());
6
6
  }
@@ -15,6 +15,9 @@ function handleStats(ctx) {
15
15
  const nodes = queryNodes(ctx.scope);
16
16
  return jsonResponse(computeStats(nodes));
17
17
  }
18
+ function handlePlaybooks(ctx) {
19
+ return jsonResponse(queryPlaybooks(ctx.scope));
20
+ }
18
21
  function handleConfigGet() {
19
22
  return jsonResponse(readProjectConfig());
20
23
  }
@@ -186,6 +189,7 @@ export function registerRoutes(router) {
186
189
  router.get(/^\/api\/nodes$/, (_, ctx) => handleNodes(ctx));
187
190
  router.get(/^\/api\/links$/, (_, ctx) => handleLinks(ctx));
188
191
  router.get(/^\/api\/stats$/, (_, ctx) => handleStats(ctx));
192
+ router.get(/^\/api\/playbooks$/, (_, ctx) => handlePlaybooks(ctx));
189
193
  router.get(/^\/api\/config$/, () => handleConfigGet());
190
194
  router.put(/^\/api\/config$/, (req) => handleConfigSave(req));
191
195
  router.post(/^\/api\/config$/, (req) => handleConfigSave(req));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fractal-memory",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "Fractal memory system for OpenCode with semantic search and automatic compression.",
5
5
  "main": "dist/plugin.js",
6
6
  "exports": {