@basicmemory/openclaw-basic-memory 1.0.0 → 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.
- package/README.md +4 -4
- package/bm-client.ts +180 -49
- package/config.ts +5 -0
- package/dist/bm-client.d.ts +40 -20
- package/dist/bm-client.js +118 -29
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -0
- package/dist/index.js +2 -3
- package/dist/memory/basic-memory-capability.js +7 -1
- package/dist/tools/schema-diff.js +5 -3
- package/dist/tools/schema-infer.js +1 -1
- package/dist/tools/schema-validate.js +5 -4
- package/index.ts +2 -3
- package/memory/basic-memory-capability.ts +7 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/setup-bm.sh +1 -4
- package/skills/manifest.json +5 -5
- package/skills/memory-agents/SKILL.md +12 -12
- package/skills/memory-capture/SKILL.md +1 -1
- package/skills/memory-comark/SKILL.md +1 -1
- package/skills/memory-continue/SKILL.md +8 -8
- package/skills/memory-curate/SKILL.md +2 -2
- package/skills/memory-defrag/SKILL.md +2 -2
- package/skills/memory-ingest/SKILL.md +4 -3
- package/skills/memory-lifecycle/SKILL.md +1 -1
- package/skills/memory-literary-analysis/SKILL.md +10 -10
- package/skills/memory-metadata-search/SKILL.md +1 -1
- package/skills/memory-notes/SKILL.md +1 -1
- package/skills/memory-okf/SKILL.md +1 -1
- package/skills/memory-quest/SKILL.md +9 -4
- package/skills/memory-reflect/SKILL.md +3 -3
- package/skills/memory-research/SKILL.md +1 -1
- package/skills/memory-schema/SKILL.md +14 -14
- package/skills/memory-start/SKILL.md +116 -0
- package/skills/memory-tasks/SKILL.md +5 -5
- package/tools/schema-diff.ts +7 -3
- package/tools/schema-infer.ts +1 -1
- package/tools/schema-validate.ts +5 -4
- package/skills/memory-onboarding/SKILL.md +0 -153
- package/skills/memory-onboarding/evals/evals.json +0 -29
- package/skills/memory-onboarding/references/assistant-setup.md +0 -72
- package/skills/memory-onboarding/references/conventions.md +0 -118
- package/skills/memory-onboarding/references/domain-playbooks.md +0 -159
- package/skills/memory-onboarding/references/schema-guide.md +0 -137
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ This uses sensible defaults: auto-generated project name, maps to your workspace
|
|
|
107
107
|
enabled: true,
|
|
108
108
|
config: {
|
|
109
109
|
project: "my-agent", // BM project name (default: "openclaw-{hostname}")
|
|
110
|
-
projectPath: ".", // Project directory (default: workspace root)
|
|
110
|
+
projectPath: ".", // Project directory (default: workspace root, or an existing project's folder)
|
|
111
111
|
memoryDir: "memory/", // Where task notes live
|
|
112
112
|
memoryFile: "MEMORY.md", // Working memory file
|
|
113
113
|
autoCapture: true, // Record conversations as daily notes
|
|
@@ -128,7 +128,7 @@ This uses sensible defaults: auto-generated project name, maps to your workspace
|
|
|
128
128
|
|--------|---------|-------------|
|
|
129
129
|
| `project` | `"openclaw-{hostname}"` | Basic Memory project name |
|
|
130
130
|
| `bmPath` | `"bm"` | Path to BM CLI binary |
|
|
131
|
-
| `projectPath` | `"."` | Project data directory |
|
|
131
|
+
| `projectPath` | `"."` | Project data directory, relative to the workspace or absolute. When unset and a project named `project` already exists, the plugin uses that project's stored folder. When set, it must match the stored folder; otherwise Basic Memory refuses the project and the plugin logs where it is stored |
|
|
132
132
|
| `memoryDir` | `"memory/"` | Relative path for task scanning |
|
|
133
133
|
| `memoryFile` | `"MEMORY.md"` | Working memory file for text search |
|
|
134
134
|
| `autoCapture` | `true` | Auto-index agent conversations |
|
|
@@ -234,10 +234,10 @@ These skills ship with the plugin — no installation needed:
|
|
|
234
234
|
- **memory-metadata-search** — query notes by frontmatter fields
|
|
235
235
|
- **memory-notes** — guidance for writing well-structured notes
|
|
236
236
|
- **memory-okf** — make a project ready for OKF export
|
|
237
|
-
- **memory-onboarding** — guided setup of a new knowledge system
|
|
238
237
|
- **memory-reflect** — periodic consolidation of recent notes into durable memory
|
|
239
238
|
- **memory-research** — research synthesis into durable notes
|
|
240
239
|
- **memory-schema** — schema lifecycle (infer, create, validate, diff)
|
|
240
|
+
- **memory-start** — a new user's first session: save one note, see it, get it back
|
|
241
241
|
- **memory-tasks** — structured task tracking that survives context compaction
|
|
242
242
|
|
|
243
243
|
### Updating skills
|
|
@@ -284,7 +284,7 @@ Cloud extends local-first — still plain Markdown, still yours. [Start a free t
|
|
|
284
284
|
|
|
285
285
|
## Troubleshooting
|
|
286
286
|
|
|
287
|
-
**`bm` not found** — Install uv, then restart the gateway. Or install manually: `uv tool install basic-memory
|
|
287
|
+
**`bm` not found** — Install uv, then restart the gateway. Or install manually: `uv tool install basic-memory`
|
|
288
288
|
|
|
289
289
|
**Search returns nothing** — Check that Basic Memory connected (look for `connected to BM` in logs). Verify files exist in the project directory.
|
|
290
290
|
|
package/bm-client.ts
CHANGED
|
@@ -6,6 +6,21 @@ import { log } from "./logger.ts"
|
|
|
6
6
|
|
|
7
7
|
const DEFAULT_RETRY_DELAYS_MS = [500, 1000, 2000]
|
|
8
8
|
|
|
9
|
+
// Thrown for calls to the plugin's project after BM refused to create it.
|
|
10
|
+
// Deliberately not a BmToolError: note methods read a BmToolError's refusal
|
|
11
|
+
// payload as their own, and would report this ALREADY_EXISTS as an existing
|
|
12
|
+
// note.
|
|
13
|
+
export class ProjectUnavailableError extends Error {
|
|
14
|
+
readonly project: string
|
|
15
|
+
readonly reason: string
|
|
16
|
+
constructor(project: string, reason: string) {
|
|
17
|
+
super(`Basic Memory project "${project}" is unavailable: ${reason}`)
|
|
18
|
+
this.name = "ProjectUnavailableError"
|
|
19
|
+
this.project = project
|
|
20
|
+
this.reason = reason
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
export class NoteAlreadyExistsError extends Error {
|
|
10
25
|
readonly permalink: string
|
|
11
26
|
constructor(title: string, permalink: string, message?: string) {
|
|
@@ -59,10 +74,14 @@ const REQUIRED_TOOLS = [
|
|
|
59
74
|
"bm_write",
|
|
60
75
|
"bm_edit",
|
|
61
76
|
"bm_context",
|
|
62
|
-
"
|
|
77
|
+
"bm_project_list",
|
|
78
|
+
"bm_project_create",
|
|
79
|
+
"bm_recent",
|
|
63
80
|
"bm_delete",
|
|
64
81
|
"bm_move",
|
|
65
|
-
"
|
|
82
|
+
"bm_schema_validate",
|
|
83
|
+
"bm_schema_infer",
|
|
84
|
+
"bm_schema_diff",
|
|
66
85
|
]
|
|
67
86
|
|
|
68
87
|
export interface SearchResult {
|
|
@@ -166,6 +185,8 @@ export interface RecentResult {
|
|
|
166
185
|
export interface ProjectListResult {
|
|
167
186
|
name: string
|
|
168
187
|
path: string
|
|
188
|
+
// Set only on the row attached to a local project; null on cloud-only rows.
|
|
189
|
+
local_path?: string | null
|
|
169
190
|
external_id?: string | null
|
|
170
191
|
source?: string | null
|
|
171
192
|
qualified_name?: string | null
|
|
@@ -185,23 +206,39 @@ export interface WorkspaceResult {
|
|
|
185
206
|
workspace_type: string | null
|
|
186
207
|
}
|
|
187
208
|
|
|
209
|
+
// The schema tool response shapes. They mirror the backend models in
|
|
210
|
+
// src/basic_memory/schemas/schema.py (ValidationReport, InferenceReport,
|
|
211
|
+
// DriftReport); the client casts the payload without translating fields, so
|
|
212
|
+
// a name that drifts from the backend renders as undefined (#1997).
|
|
213
|
+
// JSON responses drop null fields, so nullable backend fields are optional.
|
|
214
|
+
export interface SchemaNoteValidation {
|
|
215
|
+
note_identifier: string
|
|
216
|
+
schema_entity: string
|
|
217
|
+
passed: boolean
|
|
218
|
+
warnings: string[]
|
|
219
|
+
errors: string[]
|
|
220
|
+
}
|
|
221
|
+
|
|
188
222
|
export interface SchemaValidationResult {
|
|
189
|
-
|
|
223
|
+
note_type?: string | null
|
|
190
224
|
total_notes: number
|
|
191
225
|
total_entities: number
|
|
192
226
|
valid_count: number
|
|
193
227
|
warning_count: number
|
|
194
228
|
error_count: number
|
|
195
|
-
results:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
229
|
+
results: SchemaNoteValidation[]
|
|
230
|
+
type_summaries?: Array<{
|
|
231
|
+
note_type: string
|
|
232
|
+
total_notes: number
|
|
233
|
+
total_entities: number
|
|
234
|
+
valid_count: number
|
|
235
|
+
warning_count: number
|
|
236
|
+
error_count: number
|
|
200
237
|
}>
|
|
201
238
|
}
|
|
202
239
|
|
|
203
240
|
export interface SchemaInferResult {
|
|
204
|
-
|
|
241
|
+
note_type: string
|
|
205
242
|
notes_analyzed: number
|
|
206
243
|
field_frequencies: Array<{
|
|
207
244
|
name: string
|
|
@@ -219,18 +256,21 @@ export interface SchemaInferResult {
|
|
|
219
256
|
excluded: string[]
|
|
220
257
|
}
|
|
221
258
|
|
|
259
|
+
export interface SchemaDriftField {
|
|
260
|
+
name: string
|
|
261
|
+
source: string
|
|
262
|
+
count: number
|
|
263
|
+
total: number
|
|
264
|
+
percentage: number
|
|
265
|
+
}
|
|
266
|
+
|
|
222
267
|
export interface SchemaDiffResult {
|
|
223
|
-
|
|
268
|
+
note_type: string
|
|
224
269
|
schema_found: boolean
|
|
225
|
-
new_fields:
|
|
226
|
-
|
|
227
|
-
source: string
|
|
228
|
-
count: number
|
|
229
|
-
total: number
|
|
230
|
-
percentage: number
|
|
231
|
-
}>
|
|
232
|
-
dropped_fields: Array<{ name: string; source: string; declared_in?: string }>
|
|
270
|
+
new_fields: SchemaDriftField[]
|
|
271
|
+
dropped_fields: SchemaDriftField[]
|
|
233
272
|
cardinality_changes: string[]
|
|
273
|
+
notes_compared?: number | null
|
|
234
274
|
}
|
|
235
275
|
|
|
236
276
|
function getErrorMessage(err: unknown): string {
|
|
@@ -341,6 +381,13 @@ function projectMatchesWorkspace(
|
|
|
341
381
|
)
|
|
342
382
|
}
|
|
343
383
|
|
|
384
|
+
function parseProjectList(payload: unknown): ProjectListResult[] {
|
|
385
|
+
if (isRecord(payload) && Array.isArray(payload.projects)) {
|
|
386
|
+
return payload.projects as ProjectListResult[]
|
|
387
|
+
}
|
|
388
|
+
throw new Error("invalid bm_project_list response")
|
|
389
|
+
}
|
|
390
|
+
|
|
344
391
|
export class BmClient {
|
|
345
392
|
private bmPath: string
|
|
346
393
|
private project: string
|
|
@@ -357,6 +404,10 @@ export class BmClient {
|
|
|
357
404
|
private startup: Promise<void> | null = null
|
|
358
405
|
private startupRetry: Promise<void> | null = null
|
|
359
406
|
private projectPath?: string
|
|
407
|
+
private adoptExistingProject = false
|
|
408
|
+
// BM's refusal to create the plugin's project, kept so calls to that
|
|
409
|
+
// project report it while listing and other projects still work.
|
|
410
|
+
private projectSetupError: ProjectUnavailableError | null = null
|
|
360
411
|
private prepare?: () => Promise<void>
|
|
361
412
|
|
|
362
413
|
private client: Client | null = null
|
|
@@ -384,6 +435,9 @@ export class BmClient {
|
|
|
384
435
|
cwd?: string
|
|
385
436
|
env?: Record<string, string>
|
|
386
437
|
projectPath?: string
|
|
438
|
+
// True when projectPath is only the default: an existing project of the
|
|
439
|
+
// plugin's name is then used at its stored folder.
|
|
440
|
+
adoptExistingProject?: boolean
|
|
387
441
|
// Runs before each connect attempt, e.g. installing the bm CLI.
|
|
388
442
|
prepare?: () => Promise<void>
|
|
389
443
|
}): Promise<void> {
|
|
@@ -398,6 +452,9 @@ export class BmClient {
|
|
|
398
452
|
if (options?.projectPath) {
|
|
399
453
|
this.projectPath = options.projectPath
|
|
400
454
|
}
|
|
455
|
+
if (options?.adoptExistingProject !== undefined) {
|
|
456
|
+
this.adoptExistingProject = options.adoptExistingProject
|
|
457
|
+
}
|
|
401
458
|
if (options?.prepare) {
|
|
402
459
|
this.prepare = options.prepare
|
|
403
460
|
}
|
|
@@ -409,7 +466,72 @@ export class BmClient {
|
|
|
409
466
|
private async runStartup(): Promise<void> {
|
|
410
467
|
await this.prepare?.()
|
|
411
468
|
await this.connectWithRetries()
|
|
412
|
-
if (this.projectPath)
|
|
469
|
+
if (!this.projectPath) return
|
|
470
|
+
|
|
471
|
+
this.projectSetupError = null
|
|
472
|
+
const projectPath = await this.startupProjectPath(this.projectPath)
|
|
473
|
+
try {
|
|
474
|
+
await this.createProject(projectPath)
|
|
475
|
+
} catch (err) {
|
|
476
|
+
// Trigger: BM refused the project, e.g. a configured projectPath that
|
|
477
|
+
// differs from where a project of this name is stored (#1846).
|
|
478
|
+
// Why: a refusal is deterministic, so retrying startup cannot fix it,
|
|
479
|
+
// and failing startup would also fail project listing, the call a
|
|
480
|
+
// user needs to see the stored path. Other failures still fail
|
|
481
|
+
// startup so the next tool call retries them.
|
|
482
|
+
// Outcome: calls to the plugin's project throw this refusal; listing
|
|
483
|
+
// and calls naming another project still work.
|
|
484
|
+
if (
|
|
485
|
+
!(err instanceof BmToolError) ||
|
|
486
|
+
parseRefusalPayload(err.toolMessage) === null
|
|
487
|
+
) {
|
|
488
|
+
throw err
|
|
489
|
+
}
|
|
490
|
+
this.projectSetupError = new ProjectUnavailableError(
|
|
491
|
+
this.project,
|
|
492
|
+
describeToolError(err),
|
|
493
|
+
)
|
|
494
|
+
log.error(this.projectSetupError.message)
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// The folder startup creates the project at. Since #1846, BM refuses a
|
|
499
|
+
// create whose path differs from the stored one instead of reusing the
|
|
500
|
+
// project by name.
|
|
501
|
+
private async startupProjectPath(configured: string): Promise<string> {
|
|
502
|
+
// Trigger: projectPath was not configured.
|
|
503
|
+
// Why: its default has changed between plugin releases ("." and
|
|
504
|
+
// ~/.basic-memory/openclaw/), and users create projects by hand, so an
|
|
505
|
+
// existing project may sit somewhere other than the default.
|
|
506
|
+
// Outcome: create at the stored folder, which BM treats as idempotent.
|
|
507
|
+
if (!this.adoptExistingProject) return configured
|
|
508
|
+
|
|
509
|
+
// With cloud credentials the listing holds one row per workspace for a
|
|
510
|
+
// name, and only the row attached to the local project carries
|
|
511
|
+
// local_path; a cloud-only row's path is tenant-relative. BM compares a
|
|
512
|
+
// local create against the local project, so only local_path qualifies.
|
|
513
|
+
const name = this.project.toLowerCase()
|
|
514
|
+
const localPath = parseProjectList(
|
|
515
|
+
await this.callStructured("bm_project_list", {
|
|
516
|
+
output_format: "json",
|
|
517
|
+
}),
|
|
518
|
+
).find(
|
|
519
|
+
(project) => project.name.toLowerCase() === name && project.local_path,
|
|
520
|
+
)?.local_path
|
|
521
|
+
if (!localPath) return configured
|
|
522
|
+
|
|
523
|
+
if (localPath !== configured) {
|
|
524
|
+
log.info(
|
|
525
|
+
`using existing project "${this.project}" at ${localPath}; set projectPath to use another folder`,
|
|
526
|
+
)
|
|
527
|
+
}
|
|
528
|
+
return localPath
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// The refusal from the last project setup, or null when the project is
|
|
532
|
+
// usable. Status checks report it, since listing projects still succeeds.
|
|
533
|
+
projectUnavailableReason(): string | null {
|
|
534
|
+
return this.projectSetupError?.reason ?? null
|
|
413
535
|
}
|
|
414
536
|
|
|
415
537
|
private async waitForStartup(): Promise<void> {
|
|
@@ -646,6 +768,13 @@ export class BmClient {
|
|
|
646
768
|
args: Record<string, unknown>,
|
|
647
769
|
): Promise<unknown> {
|
|
648
770
|
await this.waitForStartup()
|
|
771
|
+
// Trigger: BM refused the plugin's project at startup.
|
|
772
|
+
// Why: the refusal concerns that project only; a call that names another
|
|
773
|
+
// project by name or id must still reach BM.
|
|
774
|
+
// Outcome: only calls routed to the plugin's project report the refusal.
|
|
775
|
+
if (this.projectSetupError && this.targetsPluginProject(args)) {
|
|
776
|
+
throw this.projectSetupError
|
|
777
|
+
}
|
|
649
778
|
return this.callStructured(name, args)
|
|
650
779
|
}
|
|
651
780
|
|
|
@@ -668,6 +797,15 @@ export class BmClient {
|
|
|
668
797
|
return structuredPayload
|
|
669
798
|
}
|
|
670
799
|
|
|
800
|
+
// Project names match case-insensitively in BM, so "Test-Project" routes
|
|
801
|
+
// to the plugin's "test-project" too.
|
|
802
|
+
private targetsPluginProject(args: Record<string, unknown>): boolean {
|
|
803
|
+
return (
|
|
804
|
+
typeof args.project === "string" &&
|
|
805
|
+
args.project.toLowerCase() === this.project.toLowerCase()
|
|
806
|
+
)
|
|
807
|
+
}
|
|
808
|
+
|
|
671
809
|
private routedProject(project?: string): string {
|
|
672
810
|
return project ?? this.project
|
|
673
811
|
}
|
|
@@ -684,8 +822,7 @@ export class BmClient {
|
|
|
684
822
|
}
|
|
685
823
|
|
|
686
824
|
private async createProject(projectPath: string): Promise<void> {
|
|
687
|
-
const payload = await this.callStructured("
|
|
688
|
-
command: "create",
|
|
825
|
+
const payload = await this.callStructured("bm_project_create", {
|
|
689
826
|
name: this.project,
|
|
690
827
|
path: projectPath,
|
|
691
828
|
set_default: true,
|
|
@@ -693,7 +830,7 @@ export class BmClient {
|
|
|
693
830
|
})
|
|
694
831
|
|
|
695
832
|
if (!isRecord(payload)) {
|
|
696
|
-
throw new Error("invalid
|
|
833
|
+
throw new Error("invalid bm_project_create response")
|
|
697
834
|
}
|
|
698
835
|
}
|
|
699
836
|
|
|
@@ -713,22 +850,20 @@ export class BmClient {
|
|
|
713
850
|
}
|
|
714
851
|
|
|
715
852
|
async listProjects(workspace?: string): Promise<ProjectListResult[]> {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
)
|
|
727
|
-
|
|
728
|
-
return projects
|
|
853
|
+
// Waits for startup but not for the plugin's project: when BM refused
|
|
854
|
+
// it, the listing is how the user finds where it is actually stored.
|
|
855
|
+
await this.waitForStartup()
|
|
856
|
+
const projects = parseProjectList(
|
|
857
|
+
await this.callStructured("bm_project_list", {
|
|
858
|
+
output_format: "json",
|
|
859
|
+
}),
|
|
860
|
+
)
|
|
861
|
+
if (workspace) {
|
|
862
|
+
return projects.filter((project) =>
|
|
863
|
+
projectMatchesWorkspace(project, workspace),
|
|
864
|
+
)
|
|
729
865
|
}
|
|
730
|
-
|
|
731
|
-
throw new Error("invalid bm_project response")
|
|
866
|
+
return projects
|
|
732
867
|
}
|
|
733
868
|
|
|
734
869
|
async search(
|
|
@@ -906,19 +1041,18 @@ export class BmClient {
|
|
|
906
1041
|
project?: string,
|
|
907
1042
|
): Promise<RecentResult[]> {
|
|
908
1043
|
const args: Record<string, unknown> = {
|
|
909
|
-
command: "recent",
|
|
910
1044
|
since: timeframe,
|
|
911
1045
|
output_format: "json",
|
|
912
1046
|
project: this.routedProject(project),
|
|
913
1047
|
}
|
|
914
1048
|
|
|
915
|
-
const payload = await this.callTool("
|
|
1049
|
+
const payload = await this.callTool("bm_recent", args)
|
|
916
1050
|
|
|
917
1051
|
if (isRecord(payload) && Array.isArray(payload.results)) {
|
|
918
1052
|
return payload.results as RecentResult[]
|
|
919
1053
|
}
|
|
920
1054
|
|
|
921
|
-
throw new Error("invalid
|
|
1055
|
+
throw new Error("invalid bm_recent response")
|
|
922
1056
|
}
|
|
923
1057
|
|
|
924
1058
|
async editNote(
|
|
@@ -1030,17 +1164,16 @@ export class BmClient {
|
|
|
1030
1164
|
project?: string,
|
|
1031
1165
|
): Promise<SchemaValidationResult> {
|
|
1032
1166
|
const args: Record<string, unknown> = {
|
|
1033
|
-
command: "validate",
|
|
1034
1167
|
output_format: "json",
|
|
1035
1168
|
project: this.routedProject(project),
|
|
1036
1169
|
}
|
|
1037
1170
|
if (noteType) args.note_type = noteType
|
|
1038
1171
|
if (identifier) args.identifier = identifier
|
|
1039
1172
|
|
|
1040
|
-
const payload = await this.callTool("
|
|
1173
|
+
const payload = await this.callTool("bm_schema_validate", args)
|
|
1041
1174
|
|
|
1042
1175
|
if (!isRecord(payload)) {
|
|
1043
|
-
throw new Error("invalid
|
|
1176
|
+
throw new Error("invalid bm_schema_validate response")
|
|
1044
1177
|
}
|
|
1045
1178
|
|
|
1046
1179
|
return payload as unknown as SchemaValidationResult
|
|
@@ -1052,17 +1185,16 @@ export class BmClient {
|
|
|
1052
1185
|
project?: string,
|
|
1053
1186
|
): Promise<SchemaInferResult> {
|
|
1054
1187
|
const args: Record<string, unknown> = {
|
|
1055
|
-
command: "infer",
|
|
1056
1188
|
note_type: noteType,
|
|
1057
1189
|
threshold,
|
|
1058
1190
|
output_format: "json",
|
|
1059
1191
|
project: this.routedProject(project),
|
|
1060
1192
|
}
|
|
1061
1193
|
|
|
1062
|
-
const payload = await this.callTool("
|
|
1194
|
+
const payload = await this.callTool("bm_schema_infer", args)
|
|
1063
1195
|
|
|
1064
1196
|
if (!isRecord(payload)) {
|
|
1065
|
-
throw new Error("invalid
|
|
1197
|
+
throw new Error("invalid bm_schema_infer response")
|
|
1066
1198
|
}
|
|
1067
1199
|
|
|
1068
1200
|
return payload as unknown as SchemaInferResult
|
|
@@ -1073,16 +1205,15 @@ export class BmClient {
|
|
|
1073
1205
|
project?: string,
|
|
1074
1206
|
): Promise<SchemaDiffResult> {
|
|
1075
1207
|
const args: Record<string, unknown> = {
|
|
1076
|
-
command: "diff",
|
|
1077
1208
|
note_type: noteType,
|
|
1078
1209
|
output_format: "json",
|
|
1079
1210
|
project: this.routedProject(project),
|
|
1080
1211
|
}
|
|
1081
1212
|
|
|
1082
|
-
const payload = await this.callTool("
|
|
1213
|
+
const payload = await this.callTool("bm_schema_diff", args)
|
|
1083
1214
|
|
|
1084
1215
|
if (!isRecord(payload)) {
|
|
1085
|
-
throw new Error("invalid
|
|
1216
|
+
throw new Error("invalid bm_schema_diff response")
|
|
1086
1217
|
}
|
|
1087
1218
|
|
|
1088
1219
|
return payload as unknown as SchemaDiffResult
|
package/config.ts
CHANGED
|
@@ -7,6 +7,9 @@ export type BasicMemoryConfig = {
|
|
|
7
7
|
memoryDir: string
|
|
8
8
|
memoryFile: string
|
|
9
9
|
projectPath: string
|
|
10
|
+
// False when projectPath fell back to the workspace-root default, so
|
|
11
|
+
// startup may adopt an existing project of the same name where it lives.
|
|
12
|
+
projectPathConfigured: boolean
|
|
10
13
|
autoCapture: boolean
|
|
11
14
|
captureMinChars: number
|
|
12
15
|
autoRecall: boolean
|
|
@@ -100,6 +103,8 @@ export function parseConfig(raw: unknown): BasicMemoryConfig {
|
|
|
100
103
|
typeof cfg.projectPath === "string" && cfg.projectPath.length > 0
|
|
101
104
|
? cfg.projectPath
|
|
102
105
|
: ".",
|
|
106
|
+
projectPathConfigured:
|
|
107
|
+
typeof cfg.projectPath === "string" && cfg.projectPath.length > 0,
|
|
103
108
|
bmPath:
|
|
104
109
|
typeof cfg.bmPath === "string" && cfg.bmPath.length > 0
|
|
105
110
|
? cfg.bmPath
|
package/dist/bm-client.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare class ProjectUnavailableError extends Error {
|
|
2
|
+
readonly project: string;
|
|
3
|
+
readonly reason: string;
|
|
4
|
+
constructor(project: string, reason: string);
|
|
5
|
+
}
|
|
1
6
|
export declare class NoteAlreadyExistsError extends Error {
|
|
2
7
|
readonly permalink: string;
|
|
3
8
|
constructor(title: string, permalink: string, message?: string);
|
|
@@ -97,6 +102,7 @@ export interface RecentResult {
|
|
|
97
102
|
export interface ProjectListResult {
|
|
98
103
|
name: string;
|
|
99
104
|
path: string;
|
|
105
|
+
local_path?: string | null;
|
|
100
106
|
external_id?: string | null;
|
|
101
107
|
source?: string | null;
|
|
102
108
|
qualified_name?: string | null;
|
|
@@ -114,22 +120,32 @@ export interface WorkspaceResult {
|
|
|
114
120
|
name: string;
|
|
115
121
|
workspace_type: string | null;
|
|
116
122
|
}
|
|
123
|
+
export interface SchemaNoteValidation {
|
|
124
|
+
note_identifier: string;
|
|
125
|
+
schema_entity: string;
|
|
126
|
+
passed: boolean;
|
|
127
|
+
warnings: string[];
|
|
128
|
+
errors: string[];
|
|
129
|
+
}
|
|
117
130
|
export interface SchemaValidationResult {
|
|
118
|
-
|
|
131
|
+
note_type?: string | null;
|
|
119
132
|
total_notes: number;
|
|
120
133
|
total_entities: number;
|
|
121
134
|
valid_count: number;
|
|
122
135
|
warning_count: number;
|
|
123
136
|
error_count: number;
|
|
124
|
-
results:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
results: SchemaNoteValidation[];
|
|
138
|
+
type_summaries?: Array<{
|
|
139
|
+
note_type: string;
|
|
140
|
+
total_notes: number;
|
|
141
|
+
total_entities: number;
|
|
142
|
+
valid_count: number;
|
|
143
|
+
warning_count: number;
|
|
144
|
+
error_count: number;
|
|
129
145
|
}>;
|
|
130
146
|
}
|
|
131
147
|
export interface SchemaInferResult {
|
|
132
|
-
|
|
148
|
+
note_type: string;
|
|
133
149
|
notes_analyzed: number;
|
|
134
150
|
field_frequencies: Array<{
|
|
135
151
|
name: string;
|
|
@@ -146,22 +162,20 @@ export interface SchemaInferResult {
|
|
|
146
162
|
suggested_optional: string[];
|
|
147
163
|
excluded: string[];
|
|
148
164
|
}
|
|
165
|
+
export interface SchemaDriftField {
|
|
166
|
+
name: string;
|
|
167
|
+
source: string;
|
|
168
|
+
count: number;
|
|
169
|
+
total: number;
|
|
170
|
+
percentage: number;
|
|
171
|
+
}
|
|
149
172
|
export interface SchemaDiffResult {
|
|
150
|
-
|
|
173
|
+
note_type: string;
|
|
151
174
|
schema_found: boolean;
|
|
152
|
-
new_fields:
|
|
153
|
-
|
|
154
|
-
source: string;
|
|
155
|
-
count: number;
|
|
156
|
-
total: number;
|
|
157
|
-
percentage: number;
|
|
158
|
-
}>;
|
|
159
|
-
dropped_fields: Array<{
|
|
160
|
-
name: string;
|
|
161
|
-
source: string;
|
|
162
|
-
declared_in?: string;
|
|
163
|
-
}>;
|
|
175
|
+
new_fields: SchemaDriftField[];
|
|
176
|
+
dropped_fields: SchemaDriftField[];
|
|
164
177
|
cardinality_changes: string[];
|
|
178
|
+
notes_compared?: number | null;
|
|
165
179
|
}
|
|
166
180
|
export declare function isNoteNotFoundError(err: unknown): boolean;
|
|
167
181
|
export type ConversationCaptureStatus = "committed" | "duplicate";
|
|
@@ -182,6 +196,8 @@ export declare class BmClient {
|
|
|
182
196
|
private startup;
|
|
183
197
|
private startupRetry;
|
|
184
198
|
private projectPath?;
|
|
199
|
+
private adoptExistingProject;
|
|
200
|
+
private projectSetupError;
|
|
185
201
|
private prepare?;
|
|
186
202
|
private client;
|
|
187
203
|
private transport;
|
|
@@ -201,9 +217,12 @@ export declare class BmClient {
|
|
|
201
217
|
cwd?: string;
|
|
202
218
|
env?: Record<string, string>;
|
|
203
219
|
projectPath?: string;
|
|
220
|
+
adoptExistingProject?: boolean;
|
|
204
221
|
prepare?: () => Promise<void>;
|
|
205
222
|
}): Promise<void>;
|
|
206
223
|
private runStartup;
|
|
224
|
+
private startupProjectPath;
|
|
225
|
+
projectUnavailableReason(): string | null;
|
|
207
226
|
private waitForStartup;
|
|
208
227
|
isServiceRunning(): boolean;
|
|
209
228
|
stop(): Promise<void>;
|
|
@@ -215,6 +234,7 @@ export declare class BmClient {
|
|
|
215
234
|
private callToolRaw;
|
|
216
235
|
private callTool;
|
|
217
236
|
private callStructured;
|
|
237
|
+
private targetsPluginProject;
|
|
218
238
|
private routedProject;
|
|
219
239
|
private routing;
|
|
220
240
|
ensureProject(projectPath: string): Promise<void>;
|