@basicmemory/openclaw-basic-memory 0.24.1 → 1.1.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 (93) hide show
  1. package/README.md +28 -16
  2. package/bm-client.ts +461 -140
  3. package/commands/cli.ts +5 -6
  4. package/commands/slash.ts +4 -4
  5. package/config.ts +5 -0
  6. package/context-engine/basic-memory-context-engine.ts +74 -9
  7. package/context-engine/types.ts +21 -0
  8. package/dist/bm-client.d.ts +101 -32
  9. package/dist/bm-client.js +346 -108
  10. package/dist/commands/cli.d.ts +1 -1
  11. package/dist/commands/cli.js +5 -5
  12. package/dist/commands/slash.d.ts +1 -1
  13. package/dist/commands/slash.js +4 -3
  14. package/dist/config.d.ts +1 -0
  15. package/dist/config.js +1 -0
  16. package/dist/context-engine/basic-memory-context-engine.d.ts +20 -1
  17. package/dist/context-engine/basic-memory-context-engine.js +50 -2
  18. package/dist/context-engine/types.d.ts +9 -0
  19. package/dist/context-engine/types.js +1 -0
  20. package/dist/index.d.ts +10 -4
  21. package/dist/index.js +78 -69
  22. package/dist/memory/basic-memory-capability.d.ts +19 -0
  23. package/dist/memory/basic-memory-capability.js +196 -0
  24. package/dist/tools/build-context.d.ts +1 -1
  25. package/dist/tools/build-context.js +12 -4
  26. package/dist/tools/delete-note.d.ts +1 -1
  27. package/dist/tools/delete-note.js +2 -1
  28. package/dist/tools/edit-note.d.ts +1 -1
  29. package/dist/tools/edit-note.js +22 -12
  30. package/dist/tools/list-memory-projects.d.ts +1 -1
  31. package/dist/tools/list-memory-projects.js +2 -1
  32. package/dist/tools/list-workspaces.d.ts +1 -1
  33. package/dist/tools/list-workspaces.js +4 -4
  34. package/dist/tools/move-note.d.ts +1 -1
  35. package/dist/tools/move-note.js +2 -1
  36. package/dist/tools/read-note.d.ts +1 -1
  37. package/dist/tools/read-note.js +2 -1
  38. package/dist/tools/schema-diff.d.ts +1 -1
  39. package/dist/tools/schema-diff.js +7 -4
  40. package/dist/tools/schema-infer.d.ts +1 -1
  41. package/dist/tools/schema-infer.js +3 -2
  42. package/dist/tools/schema-validate.d.ts +1 -1
  43. package/dist/tools/schema-validate.js +7 -5
  44. package/dist/tools/search-notes.d.ts +1 -1
  45. package/dist/tools/search-notes.js +13 -6
  46. package/dist/tools/write-note.d.ts +1 -1
  47. package/dist/tools/write-note.js +11 -12
  48. package/index.ts +92 -84
  49. package/memory/basic-memory-capability.ts +259 -0
  50. package/openclaw.plugin.json +1 -3
  51. package/package.json +6 -5
  52. package/scripts/setup-bm.sh +1 -4
  53. package/skills/manifest.json +10 -5
  54. package/skills/memory-agents/SKILL.md +23 -10
  55. package/skills/memory-capture/SKILL.md +29 -18
  56. package/skills/memory-comark/SKILL.md +17 -6
  57. package/skills/memory-continue/SKILL.md +47 -27
  58. package/skills/memory-curate/SKILL.md +40 -24
  59. package/skills/memory-defrag/SKILL.md +18 -7
  60. package/skills/memory-doctor/SKILL.md +93 -0
  61. package/skills/memory-ingest/SKILL.md +35 -18
  62. package/skills/memory-lifecycle/SKILL.md +35 -22
  63. package/skills/memory-literary-analysis/SKILL.md +112 -75
  64. package/skills/memory-metadata-search/SKILL.md +39 -28
  65. package/skills/memory-notes/SKILL.md +75 -50
  66. package/skills/memory-okf/SKILL.md +27 -15
  67. package/skills/memory-quest/SKILL.md +24 -8
  68. package/skills/memory-reflect/SKILL.md +25 -13
  69. package/skills/memory-research/SKILL.md +28 -13
  70. package/skills/memory-schema/SKILL.md +36 -24
  71. package/skills/memory-start/SKILL.md +116 -0
  72. package/skills/memory-tasks/SKILL.md +34 -22
  73. package/tools/build-context.ts +14 -5
  74. package/tools/delete-note.ts +2 -2
  75. package/tools/edit-note.ts +27 -14
  76. package/tools/list-memory-projects.ts +6 -2
  77. package/tools/list-workspaces.ts +8 -5
  78. package/tools/move-note.ts +2 -2
  79. package/tools/read-note.ts +2 -2
  80. package/tools/schema-diff.ts +9 -5
  81. package/tools/schema-infer.ts +3 -3
  82. package/tools/schema-validate.ts +7 -6
  83. package/tools/search-notes.ts +18 -7
  84. package/tools/write-note.ts +12 -12
  85. package/dist/tools/memory-provider.d.ts +0 -15
  86. package/dist/tools/memory-provider.js +0 -275
  87. package/skills/memory-onboarding/SKILL.md +0 -142
  88. package/skills/memory-onboarding/evals/evals.json +0 -29
  89. package/skills/memory-onboarding/references/assistant-setup.md +0 -72
  90. package/skills/memory-onboarding/references/conventions.md +0 -118
  91. package/skills/memory-onboarding/references/domain-playbooks.md +0 -159
  92. package/skills/memory-onboarding/references/schema-guide.md +0 -136
  93. package/tools/memory-provider.ts +0 -336
@@ -1,5 +1,5 @@
1
1
  import { Type } from "@sinclair/typebox";
2
- import { NoteAlreadyExistsError, NoteRevisionConflictError, } from "../bm-client.js";
2
+ import { describeToolError, NoteAlreadyExistsError, NoteRevisionConflictError, } from "../bm-client.js";
3
3
  import { log } from "../logger.js";
4
4
  export function registerWriteTool(api, client) {
5
5
  api.registerTool({
@@ -41,7 +41,7 @@ export function registerWriteTool(api, client) {
41
41
  description: 'Note type stored in frontmatter. Defaults to "note".',
42
42
  })),
43
43
  expected_checksum: Type.Optional(Type.String({
44
- description: "Requires overwrite=true. The checksum of the note as you read it; " +
44
+ description: "Implies overwrite=true. The checksum of the note as you read it; " +
45
45
  "the note is replaced only while it is still that revision.",
46
46
  })),
47
47
  }),
@@ -65,7 +65,9 @@ export function registerWriteTool(api, client) {
65
65
  const checksumSuffix = note.checksum
66
66
  ? `\nChecksum: ${note.checksum}`
67
67
  : "";
68
- const msg = `Note saved: ${note.title} (${note.permalink})${checksumSuffix}`;
68
+ // The description tells agents to cite permalink and file_path, so both
69
+ // must appear in the text the agent reads, not only in details.
70
+ const msg = `Note saved: ${note.title} (${note.permalink})\nFile: ${note.file_path}${checksumSuffix}`;
69
71
  return {
70
72
  content: [
71
73
  {
@@ -84,13 +86,10 @@ export function registerWriteTool(api, client) {
84
86
  catch (err) {
85
87
  if (err instanceof NoteAlreadyExistsError) {
86
88
  const hint = [
87
- `Note already exists: "${params.title}" (${err.permalink})`,
89
+ err.message,
88
90
  "",
89
- "To update this note, use one of:",
90
- ` - edit_note("${err.permalink}", operation="append", content="...")`,
91
- ` - edit_note("${err.permalink}", operation="replace_section", section="...", content="...")`,
92
- ` - write_note("${params.title}", ..., overwrite=true) to fully replace`,
93
- ` - read_note("${err.permalink}", include_frontmatter=true) to inspect it first; pass its checksum as expected_checksum with overwrite=true to replace only that revision`,
91
+ "Use search_notes to locate the note, then read_note to inspect its current content and checksum.",
92
+ "Use edit_note for incremental changes, or write_note with overwrite=true and expected_checksum to replace the revision you read.",
94
93
  ].join("\n");
95
94
  return {
96
95
  content: [{ type: "text", text: hint }],
@@ -104,9 +103,9 @@ export function registerWriteTool(api, client) {
104
103
  if (err instanceof NoteRevisionConflictError) {
105
104
  const current = err.currentChecksum
106
105
  ? `Its current checksum is ${err.currentChecksum}.`
107
- : "No note exists at that path any more.";
106
+ : "Read the note to obtain its current checksum.";
108
107
  const text = [
109
- `Note revision conflict: "${params.title}" changed since it was read, so nothing was replaced. ${current}`,
108
+ `Note revision conflict: ${err.message} ${current}`,
110
109
  "",
111
110
  "Read the note again, confirm it should still be replaced, then retry with the new checksum as expected_checksum.",
112
111
  ].join("\n");
@@ -125,7 +124,7 @@ export function registerWriteTool(api, client) {
125
124
  content: [
126
125
  {
127
126
  type: "text",
128
- text: "Failed to write note. Is Basic Memory running? Check logs for details.",
127
+ text: `Failed to write note: ${describeToolError(err)}`,
129
128
  },
130
129
  ],
131
130
  details: {
package/index.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { execFileSync } from "node:child_process"
1
+ import { execFile } from "node:child_process"
2
+ import { mkdir } from "node:fs/promises"
3
+ import { promisify } from "node:util"
2
4
 
3
5
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry"
4
6
  import { BmClient } from "./bm-client.ts"
@@ -12,6 +14,7 @@ import {
12
14
  } from "./config.ts"
13
15
  import { BasicMemoryContextEngine } from "./context-engine/basic-memory-context-engine.ts"
14
16
  import { initLogger, log } from "./logger.ts"
17
+ import { buildBasicMemoryCapability } from "./memory/basic-memory-capability.ts"
15
18
  import { CONVERSATION_SCHEMA_CONTENT } from "./schema/conversation-schema.ts"
16
19
  import { TASK_SCHEMA_CONTENT } from "./schema/task-schema.ts"
17
20
  import { registerContextTool } from "./tools/build-context.ts"
@@ -19,10 +22,6 @@ import { registerDeleteTool } from "./tools/delete-note.ts"
19
22
  import { registerEditTool } from "./tools/edit-note.ts"
20
23
  import { registerProjectListTool } from "./tools/list-memory-projects.ts"
21
24
  import { registerWorkspaceListTool } from "./tools/list-workspaces.ts"
22
- import {
23
- registerMemoryProvider,
24
- setWorkspaceDir,
25
- } from "./tools/memory-provider.ts"
26
25
  import { registerMoveTool } from "./tools/move-note.ts"
27
26
  import { registerReadTool } from "./tools/read-note.ts"
28
27
  import { registerSchemaDiffTool } from "./tools/schema-diff.ts"
@@ -31,20 +30,69 @@ import { registerSchemaValidateTool } from "./tools/schema-validate.ts"
31
30
  import { registerSearchTool } from "./tools/search-notes.ts"
32
31
  import { registerWriteTool } from "./tools/write-note.ts"
33
32
 
34
- export function isCommandAvailable(command: string): boolean {
33
+ const execFileAsync = promisify(execFile)
34
+
35
+ // Async so a probe or an install never blocks OpenClaw's event loop during
36
+ // plugin startup.
37
+ export async function isCommandAvailable(command: string): Promise<boolean> {
35
38
  try {
36
- execFileSync(command, ["--version"], { stdio: "ignore" })
39
+ await execFileAsync(command, ["--version"])
37
40
  return true
38
41
  } catch {
39
42
  return false
40
43
  }
41
44
  }
42
45
 
46
+ async function installBasicMemoryIfMissing(bmBin: string): Promise<void> {
47
+ if (await isCommandAvailable(bmBin)) return
48
+
49
+ log.info("bm CLI not found on PATH — attempting auto-install...")
50
+ if (!(await isCommandAvailable("uv"))) {
51
+ throw new Error(
52
+ "Cannot auto-install basic-memory: uv not found. " +
53
+ "Install uv first (brew install uv, or curl -LsSf https://astral.sh/uv/install.sh | sh), " +
54
+ "then restart the gateway.",
55
+ )
56
+ }
57
+
58
+ log.info("installing basic-memory via uv (this may take a minute)...")
59
+ const { stdout } = await execFileAsync(
60
+ "uv",
61
+ ["tool", "install", "basic-memory", "--force"],
62
+ { encoding: "utf-8", timeout: 120_000 },
63
+ )
64
+ log.info(`basic-memory installed: ${stdout.trim().split("\n").pop()}`)
65
+ if (!(await isCommandAvailable(bmBin))) {
66
+ throw new Error(
67
+ "bm installed but not found on PATH. You may need to add uv's bin directory to your PATH (typically ~/.local/bin).",
68
+ )
69
+ }
70
+ }
71
+
72
+ async function seedSchemas(client: BmClient): Promise<void> {
73
+ for (const [name, content] of [
74
+ ["Task", TASK_SCHEMA_CONTENT],
75
+ ["Conversation", CONVERSATION_SCHEMA_CONTENT],
76
+ ] as const) {
77
+ try {
78
+ await client.readNote(`schema/${name}`)
79
+ log.debug(`${name} schema already exists, skipping seed`)
80
+ } catch {
81
+ try {
82
+ await client.writeNote(name, content, "schema")
83
+ log.debug(`seeded ${name} schema note`)
84
+ } catch (err) {
85
+ log.debug(`${name} schema seed failed (non-fatal)`, err)
86
+ }
87
+ }
88
+ }
89
+ }
90
+
43
91
  export default definePluginEntry({
44
92
  id: "openclaw-basic-memory",
45
93
  name: "Basic Memory",
46
94
  description:
47
- "Local-first knowledge graph for OpenClaw — persistent memory with graph search and composited memory_search",
95
+ "Local-first knowledge graph for OpenClaw — persistent memory with graph search, recall and conversation capture",
48
96
  configSchema: basicMemoryConfigSchema,
49
97
 
50
98
  register(api) {
@@ -72,9 +120,14 @@ export default definePluginEntry({
72
120
  registerSchemaInferTool(api, client)
73
121
  registerSchemaDiffTool(api, client)
74
122
 
75
- // --- Composited memory_search + memory_get (always registered) ---
76
- registerMemoryProvider(api, client, cfg)
77
- log.info("registered composited memory_search + memory_get")
123
+ // --- Memory capability ---
124
+ // OpenClaw 2026.10 owns the memory_search and memory_get tool names
125
+ // (memory-core registers them even when another plugin holds the memory
126
+ // slot), so the plugin serves the host through registerMemoryCapability:
127
+ // gateway memory search, status and doctor, Active Memory recall, and the
128
+ // pre-compaction flush.
129
+ api.registerMemoryCapability(buildBasicMemoryCapability(client))
130
+ log.info("registered Basic Memory memory capability")
78
131
  api.registerContextEngine(
79
132
  "openclaw-basic-memory",
80
133
  () => new BasicMemoryContextEngine(client, cfg),
@@ -92,83 +145,38 @@ export default definePluginEntry({
92
145
  start: async (ctx: { config?: unknown; workspaceDir?: string }) => {
93
146
  log.info("starting...")
94
147
 
95
- // Auto-install bm CLI if not found
96
- const bmBin = cfg.bmPath || "bm"
97
- if (!isCommandAvailable(bmBin)) {
98
- log.info("bm CLI not found on PATH — attempting auto-install...")
99
- try {
100
- if (!isCommandAvailable("uv")) {
101
- throw new Error("uv not found")
102
- }
103
- log.info(
104
- "installing basic-memory via uv (this may take a minute)...",
105
- )
106
- // basic-memory pins a FastMCP pre-release; without this flag uv
107
- // silently installs the last release that had none (#1338).
108
- const result = execFileSync(
109
- "uv",
110
- [
111
- "tool",
112
- "install",
113
- "basic-memory",
114
- "--prerelease=allow",
115
- "--force",
116
- ],
117
- {
118
- encoding: "utf-8",
119
- timeout: 120_000,
120
- stdio: ["ignore", "pipe", "pipe"],
121
- },
122
- )
123
- log.info(
124
- `basic-memory installed: ${result.trim().split("\n").pop()}`,
125
- )
126
- // Verify it worked
127
- if (isCommandAvailable(bmBin)) {
128
- log.info("bm CLI now available on PATH")
129
- } else {
130
- log.error(
131
- "bm installed but not found on PATH. You may need to add uv's bin directory to your PATH (typically ~/.local/bin).",
132
- )
133
- }
134
- } catch (_uvErr) {
135
- log.error(
136
- "Cannot auto-install basic-memory: uv not found. " +
137
- "Install uv first (brew install uv, or curl -LsSf https://astral.sh/uv/install.sh | sh), " +
138
- "then restart the gateway.",
139
- )
140
- }
141
- }
142
-
143
148
  const workspace = ctx.workspaceDir ?? process.cwd()
144
149
  const projectPath = resolveProjectPath(cfg.projectPath, workspace)
145
150
  cfg.projectPath = projectPath
146
151
 
147
- await client.start({ cwd: workspace })
148
- await client.ensureProject(projectPath)
149
- log.debug(`project "${cfg.project}" at ${projectPath}`)
150
-
151
- // Seed schemas if not already present
152
- for (const [name, content] of [
153
- ["Task", TASK_SCHEMA_CONTENT],
154
- ["Conversation", CONVERSATION_SCHEMA_CONTENT],
155
- ] as const) {
156
- try {
157
- await client.readNote(`schema/${name}`)
158
- log.debug(`${name} schema already exists, skipping seed`)
159
- } catch {
160
- try {
161
- await client.writeNote(name, content, "schema")
162
- log.debug(`seeded ${name} schema note`)
163
- } catch (err) {
164
- log.debug(`${name} schema seed failed (non-fatal)`, err)
165
- }
166
- }
167
- }
168
-
169
- setWorkspaceDir(workspace)
170
-
171
- log.info("connected — BM MCP stdio session running")
152
+ // bm runs with the workspace as its working directory. OpenClaw
153
+ // creates its default workspace only on the first agent run, and
154
+ // spawning into a missing directory fails with an ENOENT that names
155
+ // the bm binary instead of the directory.
156
+ await mkdir(workspace, { recursive: true })
157
+
158
+ // OpenClaw gives a service about 5 s to start. A first start (bm
159
+ // install, cold imports, first indexing) takes far longer, and a
160
+ // timed-out start fails the plugin. So startup runs in the
161
+ // background; tool calls wait for it inside BmClient, and a failed
162
+ // startup is retried by the next tool call instead of failing here.
163
+ client
164
+ .start({
165
+ cwd: workspace,
166
+ projectPath,
167
+ adoptExistingProject: !cfg.projectPathConfigured,
168
+ prepare: () => installBasicMemoryIfMissing(cfg.bmPath || "bm"),
169
+ })
170
+ .then(async () => {
171
+ log.info("connected — BM MCP stdio session running")
172
+ await seedSchemas(client)
173
+ })
174
+ .catch((err) => {
175
+ log.error(
176
+ "Basic Memory startup failed; the next tool call will retry",
177
+ err,
178
+ )
179
+ })
172
180
  },
173
181
  stop: async () => {
174
182
  log.info("stopping BM MCP session...")
@@ -0,0 +1,259 @@
1
+ import type { MemoryPluginCapability } from "openclaw/plugin-sdk/memory-host-core"
2
+ import {
3
+ type BmClient,
4
+ isNoteNotFoundError,
5
+ searchResultText,
6
+ } from "../bm-client.ts"
7
+ import { log } from "../logger.ts"
8
+
9
+ // OpenClaw documents deriving the provider types from the public capability
10
+ // type rather than importing its private memory-host-search facade.
11
+ type MemoryProviderRuntime = NonNullable<
12
+ MemoryPluginCapability["providerRuntime"]
13
+ >
14
+ type MemoryProviderHandle = NonNullable<
15
+ Awaited<ReturnType<MemoryProviderRuntime["open"]>>["provider"]
16
+ >
17
+ type MemorySearchRequest = Parameters<MemoryProviderHandle["search"]>[0]
18
+ type MemorySearchPage = Awaited<ReturnType<MemoryProviderHandle["search"]>>
19
+ type MemoryGetRequest = Parameters<MemoryProviderHandle["get"]>[0]
20
+ type MemoryGetResult = Awaited<ReturnType<MemoryProviderHandle["get"]>>
21
+ type MemoryHealth = Awaited<ReturnType<MemoryProviderHandle["health"]>>
22
+ type MemoryCallerContext = Parameters<
23
+ MemoryProviderRuntime["open"]
24
+ >[0]["context"]
25
+ type MemoryProviderFlushPlanResolver = NonNullable<
26
+ MemoryPluginCapability["providerFlushPlanResolver"]
27
+ >
28
+
29
+ export const MEMORY_PROVIDER_ID = "openclaw-basic-memory"
30
+
31
+ // Agent tools this plugin registers that Active Memory may use for deep
32
+ // recall, and that the pre-compaction flush may use to look before writing.
33
+ export const RECALL_TOOL_NAMES = [
34
+ "search_notes",
35
+ "read_note",
36
+ "build_context",
37
+ ] as const
38
+ const FLUSH_PERSISTENCE_TOOL_NAMES = ["write_note", "edit_note"] as const
39
+ const FLUSH_LOOKUP_TOOL_NAMES = ["search_notes", "read_note"] as const
40
+
41
+ const DEFAULT_MAX_RESULTS = 10
42
+ const MAX_EXCERPT_CHARS = 700
43
+ // memory-core's flush prompts use the same token for "nothing to save".
44
+ const SILENT_REPLY_TOKEN = "NO_REPLY"
45
+
46
+ // --- Search and retrieval ---
47
+
48
+ /**
49
+ * Basic Memory fuses keyword and vector scores into [0, 1.3] (see
50
+ * search_reader.py FUSION_BONUS). OpenClaw compares provider scores against a
51
+ * caller's minScore on a 0–1 scale, so a fused score above 1 is capped at 1.
52
+ */
53
+ function hostScore(score: number | undefined): number | undefined {
54
+ return score === undefined ? undefined : Math.min(score, 1)
55
+ }
56
+
57
+ function excerptOf(content: string): string {
58
+ return content.length > MAX_EXCERPT_CHARS
59
+ ? `${content.slice(0, MAX_EXCERPT_CHARS)}…`
60
+ : content
61
+ }
62
+
63
+ /**
64
+ * Apply the host's optional line window to a note body. `from` is 1-based,
65
+ * matching the host's memory_get contract.
66
+ */
67
+ function sliceLines(
68
+ text: string,
69
+ from: number | undefined,
70
+ lines: number | undefined,
71
+ ): Pick<
72
+ Extract<MemoryGetResult, { status: "ok" }>,
73
+ "text" | "truncated" | "from" | "lines" | "nextFrom"
74
+ > {
75
+ if (from === undefined && lines === undefined) return { text }
76
+
77
+ const all = text.split("\n")
78
+ const start = Math.max(1, from ?? 1)
79
+ const count = lines ?? all.length - start + 1
80
+ const window = all.slice(start - 1, start - 1 + count)
81
+ const end = start - 1 + window.length
82
+ const truncated = end < all.length
83
+ return {
84
+ text: window.join("\n"),
85
+ from: start,
86
+ lines: window.length,
87
+ truncated,
88
+ ...(truncated ? { nextFrom: end + 1 } : {}),
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Open a caller-bound reader over the plugin's shared BM MCP session.
94
+ *
95
+ * The host rechecks the caller's authority around every provider call;
96
+ * context.assertCurrent() is also called before and after each BM request so
97
+ * a revoked caller is refused rather than served. Every note in the project
98
+ * is visible to every caller, which matches what the plugin's own
99
+ * search_notes and read_note tools already expose.
100
+ */
101
+ export function openBasicMemoryReader(
102
+ client: BmClient,
103
+ context: MemoryCallerContext,
104
+ ): MemoryProviderHandle {
105
+ const guarded = async <T>(run: () => Promise<T>): Promise<T> => {
106
+ context.assertCurrent()
107
+ const result = await run()
108
+ context.assertCurrent()
109
+ return result
110
+ }
111
+
112
+ // Trigger: the reader opens while the plugin service is not running, as in
113
+ // one-shot CLI commands like `openclaw memory status`.
114
+ // Why: the first BM call then spawns a `bm mcp` child that nothing else
115
+ // will stop, and its open pipes keep the CLI process from exiting.
116
+ // Outcome: this reader owns that connection and stops it on close().
117
+ const ownsConnection = !client.isServiceRunning()
118
+
119
+ return {
120
+ capabilities: {
121
+ sources: ["memory"],
122
+ pagination: false,
123
+ candidates: [],
124
+ projectFilter: false,
125
+ },
126
+
127
+ async search(request: MemorySearchRequest): Promise<MemorySearchPage> {
128
+ const results = await guarded(() =>
129
+ client.search(request.query, request.maxResults ?? DEFAULT_MAX_RESULTS),
130
+ )
131
+
132
+ const hits = results
133
+ .map((result) => ({ result, score: hostScore(result.score) }))
134
+ // Trigger: the caller set a score floor.
135
+ // Why: the host contract requires every provider to enforce minScore.
136
+ // Outcome: unscored or lower-scored hits are dropped.
137
+ .filter(
138
+ ({ score }) =>
139
+ request.minScore === undefined ||
140
+ (score !== undefined && score >= request.minScore),
141
+ )
142
+ .map(({ result, score }) => ({
143
+ reference: { providerId: MEMORY_PROVIDER_ID, id: result.permalink },
144
+ excerpt: excerptOf(searchResultText(result)),
145
+ source: result.file_path,
146
+ ...(score === undefined ? {} : { score }),
147
+ }))
148
+
149
+ return { hits }
150
+ },
151
+
152
+ async get(request: MemoryGetRequest): Promise<MemoryGetResult> {
153
+ try {
154
+ const note = await guarded(() => client.readNote(request.reference.id))
155
+ return {
156
+ status: "ok",
157
+ reference: { providerId: MEMORY_PROVIDER_ID, id: note.permalink },
158
+ ...sliceLines(note.content, request.from, request.lines),
159
+ }
160
+ } catch (err) {
161
+ // A missing note is an answer; any other failure must surface so the
162
+ // host does not report it as an empty success.
163
+ if (isNoteNotFoundError(err)) return { status: "not_found" }
164
+ throw err
165
+ }
166
+ },
167
+
168
+ async health(): Promise<MemoryHealth> {
169
+ // Listing projects proves the BM MCP session answers without reading
170
+ // any note content, so it is safe for status-only callers.
171
+ try {
172
+ await guarded(() => client.listProjects())
173
+ } catch (err) {
174
+ log.warn(
175
+ `memory health check failed: ${err instanceof Error ? err.message : String(err)}`,
176
+ )
177
+ return {
178
+ status: "unavailable",
179
+ message: "Basic Memory is not reachable",
180
+ }
181
+ }
182
+ // Listing works even when BM refused the plugin's project, so the
183
+ // refusal is checked separately; every search and read would fail.
184
+ const projectProblem = client.projectUnavailableReason()
185
+ if (projectProblem) {
186
+ return { status: "unavailable", message: projectProblem }
187
+ }
188
+ return { status: "ready" }
189
+ },
190
+
191
+ // In the gateway the BM MCP session is shared by the whole plugin and
192
+ // owned by its service, so closing one caller's reader releases nothing.
193
+ async close(): Promise<void> {
194
+ if (ownsConnection) await client.stop()
195
+ },
196
+ }
197
+ }
198
+
199
+ // --- Pre-compaction flush ---
200
+
201
+ const FLUSH_PROMPT = [
202
+ "Pre-compaction memory flush.",
203
+ "Save durable facts, decisions and open tasks from this session to Basic Memory.",
204
+ "Use search_notes or read_note first to find an existing note, then edit_note to update it;",
205
+ "use write_note only for a new topic.",
206
+ `If nothing is worth saving, reply with ${SILENT_REPLY_TOKEN}.`,
207
+ ].join(" ")
208
+
209
+ const FLUSH_SYSTEM_PROMPT = [
210
+ "Pre-compaction memory flush turn.",
211
+ "The session is near auto-compaction; capture durable memories in Basic Memory with write_note or edit_note.",
212
+ `You may reply, but usually ${SILENT_REPLY_TOKEN} is correct.`,
213
+ ].join(" ")
214
+
215
+ // Returning a tools-arm plan makes the host persist through this plugin's own
216
+ // tools instead of appending to a workspace memory file. The host has already
217
+ // honored agents.defaults.compaction.memoryFlush.enabled before calling this.
218
+ const resolveFlushPlan: MemoryProviderFlushPlanResolver = () => ({
219
+ prompt: FLUSH_PROMPT,
220
+ systemPrompt: FLUSH_SYSTEM_PROMPT,
221
+ persistenceToolNames: FLUSH_PERSISTENCE_TOOL_NAMES,
222
+ lookupToolNames: FLUSH_LOOKUP_TOOL_NAMES,
223
+ })
224
+
225
+ // --- Prompt guidance ---
226
+
227
+ /**
228
+ * OpenClaw fills any capability field the slot owner leaves empty from other
229
+ * memory registrations, including memory-core's prompt section, which points
230
+ * agents at its file-only memory_search. Supplying our own section keeps the
231
+ * agent's guidance on the Basic Memory tools.
232
+ */
233
+ function buildPromptSection(params: { availableTools: Set<string> }): string[] {
234
+ if (!params.availableTools.has("search_notes")) return []
235
+ return [
236
+ "## Basic Memory",
237
+ "Long-term memory lives in Basic Memory, a knowledge graph of Markdown notes.",
238
+ "Before answering questions about prior work, decisions, people or preferences, search it with search_notes and read the best match with read_note.",
239
+ "Earlier conversations are saved automatically in daily conversation notes.",
240
+ "memory_search and memory_get cover only the workspace MEMORY.md and memory/ files, not Basic Memory.",
241
+ ]
242
+ }
243
+
244
+ // --- Capability ---
245
+
246
+ export function buildBasicMemoryCapability(
247
+ client: BmClient,
248
+ ): MemoryPluginCapability {
249
+ return {
250
+ providerRuntime: {
251
+ async open({ context }) {
252
+ return { provider: openBasicMemoryReader(client, context) }
253
+ },
254
+ },
255
+ recallToolNames: RECALL_TOOL_NAMES,
256
+ providerFlushPlanResolver: resolveFlushPlan,
257
+ promptBuilder: buildPromptSection,
258
+ }
259
+ }
@@ -8,8 +8,6 @@
8
8
  "edit_note",
9
9
  "list_memory_projects",
10
10
  "list_workspaces",
11
- "memory_get",
12
- "memory_search",
13
11
  "move_note",
14
12
  "read_note",
15
13
  "schema_diff",
@@ -28,10 +26,10 @@
28
26
  "skills/memory-metadata-search",
29
27
  "skills/memory-notes",
30
28
  "skills/memory-okf",
31
- "skills/memory-onboarding",
32
29
  "skills/memory-reflect",
33
30
  "skills/memory-research",
34
31
  "skills/memory-schema",
32
+ "skills/memory-start",
35
33
  "skills/memory-tasks"
36
34
  ],
37
35
  "uiHints": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basicmemory/openclaw-basic-memory",
3
- "version": "0.24.1",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -15,6 +15,8 @@
15
15
  "index.ts",
16
16
  "bm-client.ts",
17
17
  "context-engine/basic-memory-context-engine.ts",
18
+ "context-engine/types.ts",
19
+ "memory/basic-memory-capability.ts",
18
20
  "config.ts",
19
21
  "logger.ts",
20
22
  "commands/cli.ts",
@@ -27,7 +29,6 @@
27
29
  "tools/edit-note.ts",
28
30
  "tools/list-memory-projects.ts",
29
31
  "tools/list-workspaces.ts",
30
- "tools/memory-provider.ts",
31
32
  "tools/move-note.ts",
32
33
  "tools/read-note.ts",
33
34
  "tools/schema-diff.ts",
@@ -80,8 +81,8 @@
80
81
  "minGatewayVersion": "2026.5.2"
81
82
  },
82
83
  "build": {
83
- "openclawVersion": "2026.5.4",
84
- "pluginSdkVersion": "2026.5.4"
84
+ "openclawVersion": "2026.10.9",
85
+ "pluginSdkVersion": "2026.10.9"
85
86
  },
86
87
  "install": {
87
88
  "minHostVersion": ">=2026.5.2"
@@ -90,7 +91,7 @@
90
91
  "devDependencies": {
91
92
  "@biomejs/biome": "^2.4.6",
92
93
  "@types/node": "^20.0.0",
93
- "openclaw": "^2026.5.4",
94
+ "openclaw": "^2026.10.6",
94
95
  "typescript": "^5.9.3"
95
96
  }
96
97
  }
@@ -16,17 +16,14 @@ if ! command -v uv >/dev/null 2>&1; then
16
16
  fi
17
17
 
18
18
  # ── install basic-memory ────────────────────────────────
19
- # basic-memory pins a FastMCP pre-release; without --prerelease=allow uv
20
- # silently installs the last release that had none (#1338).
21
19
  if [[ -n "${BM_REF}" ]]; then
22
20
  echo "Installing basic-memory from ${BM_REPO}@${BM_REF} ..."
23
21
  uv tool install \
24
22
  "basic-memory @ git+${BM_REPO}@${BM_REF}" \
25
- --prerelease=allow \
26
23
  --force
27
24
  else
28
25
  echo "Installing latest basic-memory from PyPI ..."
29
- uv tool install basic-memory --prerelease=allow --force
26
+ uv tool install basic-memory --force
30
27
  fi
31
28
 
32
29
  # ── verify ────────────────────────────────────────────────────────
@@ -29,6 +29,11 @@
29
29
  "name": "memory-defrag",
30
30
  "description": "Defragment a Basic Memory project: split bloated notes, consolidate scattered facts, resolve contradictions, retire stale content. Plans first; deletes only when told. Run weekly or on demand."
31
31
  },
32
+ {
33
+ "dir": "memory-doctor",
34
+ "name": "memory-doctor",
35
+ "description": "Check local Basic Memory projects with bm doctor, explain the findings, and run the suggested fixes once the user agrees. Use when search misses or repeats notes, or a save looks lost."
36
+ },
32
37
  {
33
38
  "dir": "memory-ingest",
34
39
  "name": "memory-ingest",
@@ -59,11 +64,6 @@
59
64
  "name": "memory-okf",
60
65
  "description": "Make a Basic Memory project ready for OKF v0.2 export by finding and fixing what blocks it. Use when preparing a project for OKF export, publishing, or handoff, or checking an OKF bundle."
61
66
  },
62
- {
63
- "dir": "memory-onboarding",
64
- "name": "memory-onboarding",
65
- "description": "Help a new user design a Basic Memory knowledge system and set up their assistant to load it. Use when someone is getting started, has an empty or messy project, or wants context kept across sessions."
66
- },
67
67
  {
68
68
  "dir": "memory-quest",
69
69
  "name": "memory-quest",
@@ -84,6 +84,11 @@
84
84
  "name": "memory-schema",
85
85
  "description": "Manage Basic Memory schemas: find unschemaed notes, infer and edit schemas, validate notes, detect drift. Use when structured note types (Task, Person, Meeting) need consistency across the graph."
86
86
  },
87
+ {
88
+ "dir": "memory-start",
89
+ "name": "memory-start",
90
+ "description": "Help a new user's first Basic Memory session: save one short note, show it, and explain how to get it back. Use when getting started, or when a project is new, empty, or holds only starter notes."
91
+ },
87
92
  {
88
93
  "dir": "memory-tasks",
89
94
  "name": "memory-tasks",