@brianluby/agent-brain 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/.claude-plugin/marketplace.json +16 -0
- package/.claude-plugin/plugin.json +12 -0
- package/LICENSE +21 -0
- package/README.md +249 -0
- package/commands/ask.md +27 -0
- package/commands/recent.md +27 -0
- package/commands/search.md +27 -0
- package/commands/stats.md +21 -0
- package/dist/hooks/hooks.json +44 -0
- package/dist/hooks/post-tool-use.js +1643 -0
- package/dist/hooks/post-tool-use.js.map +1 -0
- package/dist/hooks/session-start.js +554 -0
- package/dist/hooks/session-start.js.map +1 -0
- package/dist/hooks/smart-install.js +109 -0
- package/dist/hooks/smart-install.js.map +1 -0
- package/dist/hooks/stop.js +1386 -0
- package/dist/hooks/stop.js.map +1 -0
- package/dist/index.d.ts +397 -0
- package/dist/index.js +1236 -0
- package/dist/index.js.map +1 -0
- package/dist/opencode/plugin.d.ts +5 -0
- package/dist/opencode/plugin.js +1820 -0
- package/dist/opencode/plugin.js.map +1 -0
- package/dist/scripts/ask.js +213 -0
- package/dist/scripts/ask.js.map +1 -0
- package/dist/scripts/find.js +213 -0
- package/dist/scripts/find.js.map +1 -0
- package/dist/scripts/stats.js +225 -0
- package/dist/scripts/stats.js.map +1 -0
- package/dist/scripts/timeline.js +210 -0
- package/dist/scripts/timeline.js.map +1 -0
- package/package.json +91 -0
- package/skills/memory/SKILL.md +71 -0
- package/skills/mind/SKILL.md +71 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memvid Mind - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types for multi-platform agent memory persistence.
|
|
5
|
+
*/
|
|
6
|
+
/** Observation captured from tool use */
|
|
7
|
+
interface Observation {
|
|
8
|
+
id: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
type: ObservationType;
|
|
11
|
+
tool?: string;
|
|
12
|
+
summary: string;
|
|
13
|
+
content: string;
|
|
14
|
+
metadata?: ObservationMetadata;
|
|
15
|
+
}
|
|
16
|
+
/** Types of observations */
|
|
17
|
+
type ObservationType = "discovery" | "decision" | "problem" | "solution" | "pattern" | "warning" | "success" | "refactor" | "bugfix" | "feature";
|
|
18
|
+
/** Metadata attached to observations */
|
|
19
|
+
interface ObservationMetadata {
|
|
20
|
+
files?: string[];
|
|
21
|
+
functions?: string[];
|
|
22
|
+
error?: string;
|
|
23
|
+
confidence?: number;
|
|
24
|
+
tags?: string[];
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** Session summary stored at end of session */
|
|
29
|
+
interface SessionSummary {
|
|
30
|
+
id: string;
|
|
31
|
+
startTime: number;
|
|
32
|
+
endTime: number;
|
|
33
|
+
observationCount: number;
|
|
34
|
+
keyDecisions: string[];
|
|
35
|
+
filesModified: string[];
|
|
36
|
+
summary: string;
|
|
37
|
+
}
|
|
38
|
+
/** Context injected at session start */
|
|
39
|
+
interface InjectedContext {
|
|
40
|
+
recentObservations: Observation[];
|
|
41
|
+
relevantMemories: Observation[];
|
|
42
|
+
sessionSummaries: SessionSummary[];
|
|
43
|
+
tokenCount: number;
|
|
44
|
+
}
|
|
45
|
+
/** Configuration for Memvid Mind */
|
|
46
|
+
interface MindConfig {
|
|
47
|
+
/** Path to the memory file (default: .agent-brain/mind.mv2 in project root) */
|
|
48
|
+
memoryPath: string;
|
|
49
|
+
/** Maximum observations to inject at session start */
|
|
50
|
+
maxContextObservations: number;
|
|
51
|
+
/** Maximum tokens for context injection */
|
|
52
|
+
maxContextTokens: number;
|
|
53
|
+
/** Whether to auto-compress observations */
|
|
54
|
+
autoCompress: boolean;
|
|
55
|
+
/** Minimum confidence for storing observations */
|
|
56
|
+
minConfidence: number;
|
|
57
|
+
/** Enable debug logging */
|
|
58
|
+
debug: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** Default configuration */
|
|
61
|
+
declare const DEFAULT_CONFIG: MindConfig;
|
|
62
|
+
/** Hook input from the host coding assistant (Claude Code, OpenCode, etc.) */
|
|
63
|
+
interface HookInput {
|
|
64
|
+
session_id: string;
|
|
65
|
+
platform?: string;
|
|
66
|
+
contract_version?: string;
|
|
67
|
+
project_id?: string;
|
|
68
|
+
transcript_path?: string;
|
|
69
|
+
cwd?: string;
|
|
70
|
+
hook_event_name?: string;
|
|
71
|
+
permission_mode?: string;
|
|
72
|
+
tool_name?: string;
|
|
73
|
+
tool_input?: Record<string, unknown>;
|
|
74
|
+
tool_response?: unknown;
|
|
75
|
+
tool_use_id?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Hook output to Claude Code */
|
|
78
|
+
interface HookOutput {
|
|
79
|
+
continue?: boolean;
|
|
80
|
+
result?: string;
|
|
81
|
+
decision?: "block" | "approve" | "modify";
|
|
82
|
+
reason?: string;
|
|
83
|
+
modified_input?: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
/** Search result from memory */
|
|
86
|
+
interface MemorySearchResult {
|
|
87
|
+
observation: Observation;
|
|
88
|
+
score: number;
|
|
89
|
+
snippet: string;
|
|
90
|
+
}
|
|
91
|
+
/** Statistics about the mind file */
|
|
92
|
+
interface MindStats {
|
|
93
|
+
totalObservations: number;
|
|
94
|
+
totalSessions: number;
|
|
95
|
+
oldestMemory: number;
|
|
96
|
+
newestMemory: number;
|
|
97
|
+
fileSize: number;
|
|
98
|
+
topTypes: Record<ObservationType, number>;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Memvid Mind - Core Engine
|
|
103
|
+
*
|
|
104
|
+
* The brain behind Claude's persistent memory.
|
|
105
|
+
* Stores everything in ONE portable .memvid file.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Mind - Claude's portable memory engine
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const mind = await Mind.open();
|
|
114
|
+
* await mind.remember({
|
|
115
|
+
* type: "decision",
|
|
116
|
+
* summary: "Chose React over Vue for frontend",
|
|
117
|
+
* content: "Decision rationale: team familiarity, ecosystem..."
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* const context = await mind.getContext("authentication");
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
declare class Mind {
|
|
124
|
+
private memvid;
|
|
125
|
+
private config;
|
|
126
|
+
private memoryPath;
|
|
127
|
+
private sessionId;
|
|
128
|
+
private sessionStartTime;
|
|
129
|
+
private sessionObservationCount;
|
|
130
|
+
private cachedStats;
|
|
131
|
+
private cachedStatsFrameCount;
|
|
132
|
+
private initialized;
|
|
133
|
+
private constructor();
|
|
134
|
+
/**
|
|
135
|
+
* Open or create a Mind instance
|
|
136
|
+
*/
|
|
137
|
+
static open(configOverrides?: Partial<MindConfig>): Promise<Mind>;
|
|
138
|
+
private withLock;
|
|
139
|
+
/**
|
|
140
|
+
* Remember an observation
|
|
141
|
+
*/
|
|
142
|
+
remember(input: {
|
|
143
|
+
type: ObservationType;
|
|
144
|
+
summary: string;
|
|
145
|
+
content: string;
|
|
146
|
+
tool?: string;
|
|
147
|
+
metadata?: Record<string, unknown>;
|
|
148
|
+
}): Promise<string>;
|
|
149
|
+
/**
|
|
150
|
+
* Search memories by query (uses fast lexical search)
|
|
151
|
+
*/
|
|
152
|
+
search(query: string, limit?: number): Promise<MemorySearchResult[]>;
|
|
153
|
+
private searchUnlocked;
|
|
154
|
+
private toTimelineFrames;
|
|
155
|
+
private toSearchFrames;
|
|
156
|
+
private normalizeTimestampMs;
|
|
157
|
+
private parseSessionSummary;
|
|
158
|
+
private extractSessionSummary;
|
|
159
|
+
private extractSessionId;
|
|
160
|
+
private extractObservationType;
|
|
161
|
+
private extractPreviewFieldValues;
|
|
162
|
+
private extractObservationTypeFromPreview;
|
|
163
|
+
private parseLeadingJsonObject;
|
|
164
|
+
private extractSessionSummaryFromSearchHit;
|
|
165
|
+
/**
|
|
166
|
+
* Ask the memory a question (uses fast lexical search)
|
|
167
|
+
*/
|
|
168
|
+
ask(question: string): Promise<string>;
|
|
169
|
+
/**
|
|
170
|
+
* Get context for session start
|
|
171
|
+
*/
|
|
172
|
+
getContext(query?: string): Promise<InjectedContext>;
|
|
173
|
+
/**
|
|
174
|
+
* Save a session summary
|
|
175
|
+
*/
|
|
176
|
+
saveSessionSummary(summary: {
|
|
177
|
+
keyDecisions: string[];
|
|
178
|
+
filesModified: string[];
|
|
179
|
+
summary: string;
|
|
180
|
+
}): Promise<string>;
|
|
181
|
+
/**
|
|
182
|
+
* Get memory statistics
|
|
183
|
+
*/
|
|
184
|
+
stats(): Promise<MindStats>;
|
|
185
|
+
/**
|
|
186
|
+
* Get the session ID
|
|
187
|
+
*/
|
|
188
|
+
getSessionId(): string;
|
|
189
|
+
/**
|
|
190
|
+
* Get the memory file path
|
|
191
|
+
*/
|
|
192
|
+
getMemoryPath(): string;
|
|
193
|
+
/**
|
|
194
|
+
* Check if initialized
|
|
195
|
+
*/
|
|
196
|
+
isInitialized(): boolean;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get or create the Mind singleton
|
|
200
|
+
*/
|
|
201
|
+
declare function getMind(config?: Partial<MindConfig>): Promise<Mind>;
|
|
202
|
+
/**
|
|
203
|
+
* Reset the Mind singleton (for testing)
|
|
204
|
+
*/
|
|
205
|
+
declare function resetMind(): void;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Memvid Mind - Utility Helpers
|
|
209
|
+
*/
|
|
210
|
+
/**
|
|
211
|
+
* Generate a unique ID
|
|
212
|
+
*/
|
|
213
|
+
declare function generateId(): string;
|
|
214
|
+
/**
|
|
215
|
+
* Estimate token count for text (rough approximation)
|
|
216
|
+
* ~4 characters per token for English text
|
|
217
|
+
*/
|
|
218
|
+
declare function estimateTokens(text: string): number;
|
|
219
|
+
/**
|
|
220
|
+
* Truncate text to fit within token limit
|
|
221
|
+
*/
|
|
222
|
+
declare function truncateToTokens(text: string, maxTokens: number): string;
|
|
223
|
+
/**
|
|
224
|
+
* Format timestamp to human-readable string
|
|
225
|
+
*/
|
|
226
|
+
declare function formatTimestamp(ts: number): string;
|
|
227
|
+
/**
|
|
228
|
+
* Parse JSON safely
|
|
229
|
+
*/
|
|
230
|
+
declare function safeJsonParse<T>(text: string, fallback: T): T;
|
|
231
|
+
/**
|
|
232
|
+
* Read all stdin as string
|
|
233
|
+
*/
|
|
234
|
+
declare function readStdin(): Promise<string>;
|
|
235
|
+
/**
|
|
236
|
+
* Write JSON to stdout and exit immediately
|
|
237
|
+
* (Prevents SDK background tasks from blocking process exit)
|
|
238
|
+
*/
|
|
239
|
+
declare function writeOutput(output: unknown): never;
|
|
240
|
+
/**
|
|
241
|
+
* Log debug message to stderr
|
|
242
|
+
*/
|
|
243
|
+
declare function debug(message: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* Extract key information from tool output
|
|
246
|
+
*/
|
|
247
|
+
declare function extractKeyInfo(toolName: string, output: string): string;
|
|
248
|
+
/**
|
|
249
|
+
* Classify observation type from tool and output
|
|
250
|
+
*/
|
|
251
|
+
declare function classifyObservationType(toolName: string, output: string): "discovery" | "decision" | "problem" | "solution" | "pattern" | "warning" | "success" | "refactor" | "bugfix" | "feature";
|
|
252
|
+
|
|
253
|
+
type PlatformEventType = "session_start" | "tool_observation" | "session_stop";
|
|
254
|
+
interface PlatformProjectContext {
|
|
255
|
+
platformProjectId?: string;
|
|
256
|
+
canonicalPath?: string;
|
|
257
|
+
cwd?: string;
|
|
258
|
+
}
|
|
259
|
+
interface PlatformEventBase {
|
|
260
|
+
eventId: string;
|
|
261
|
+
eventType: PlatformEventType;
|
|
262
|
+
platform: string;
|
|
263
|
+
contractVersion: string;
|
|
264
|
+
sessionId: string;
|
|
265
|
+
timestamp: number;
|
|
266
|
+
projectContext: PlatformProjectContext;
|
|
267
|
+
}
|
|
268
|
+
interface SessionStartPayload {
|
|
269
|
+
hookEventName?: string;
|
|
270
|
+
permissionMode?: string;
|
|
271
|
+
transcriptPath?: string;
|
|
272
|
+
}
|
|
273
|
+
interface ToolObservationPayload {
|
|
274
|
+
toolName?: string;
|
|
275
|
+
toolInput?: Record<string, unknown>;
|
|
276
|
+
toolResponse?: unknown;
|
|
277
|
+
}
|
|
278
|
+
interface SessionStopPayload {
|
|
279
|
+
transcriptPath?: string;
|
|
280
|
+
}
|
|
281
|
+
interface SessionStartEvent extends PlatformEventBase {
|
|
282
|
+
eventType: "session_start";
|
|
283
|
+
payload: SessionStartPayload;
|
|
284
|
+
}
|
|
285
|
+
interface ToolObservationEvent extends PlatformEventBase {
|
|
286
|
+
eventType: "tool_observation";
|
|
287
|
+
payload: ToolObservationPayload;
|
|
288
|
+
}
|
|
289
|
+
interface SessionStopEvent extends PlatformEventBase {
|
|
290
|
+
eventType: "session_stop";
|
|
291
|
+
payload: SessionStopPayload;
|
|
292
|
+
}
|
|
293
|
+
type PlatformEvent = SessionStartEvent | ToolObservationEvent | SessionStopEvent;
|
|
294
|
+
|
|
295
|
+
declare const SUPPORTED_ADAPTER_CONTRACT_MAJOR = 1;
|
|
296
|
+
interface ContractValidationResult {
|
|
297
|
+
compatible: boolean;
|
|
298
|
+
supportedMajor: number;
|
|
299
|
+
adapterMajor: number | null;
|
|
300
|
+
reason?: string;
|
|
301
|
+
}
|
|
302
|
+
declare function validateAdapterContractVersion(version: string, supportedMajor?: number): ContractValidationResult;
|
|
303
|
+
interface PlatformAdapter {
|
|
304
|
+
platform: string;
|
|
305
|
+
contractVersion: string;
|
|
306
|
+
normalizeSessionStart(input: HookInput): SessionStartEvent;
|
|
307
|
+
normalizeToolObservation(input: HookInput): ToolObservationEvent | null;
|
|
308
|
+
normalizeSessionStop(input: HookInput): SessionStopEvent;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
interface ReadonlyAdapterRegistry {
|
|
312
|
+
resolve(platform: string): PlatformAdapter | null;
|
|
313
|
+
listPlatforms(): string[];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
type DiagnosticSeverity = "warning" | "error";
|
|
317
|
+
interface AdapterDiagnostic {
|
|
318
|
+
diagnosticId: string;
|
|
319
|
+
timestamp: number;
|
|
320
|
+
platform: string;
|
|
321
|
+
errorType: string;
|
|
322
|
+
fieldNames?: string[];
|
|
323
|
+
severity: DiagnosticSeverity;
|
|
324
|
+
redacted: true;
|
|
325
|
+
retentionDays: number;
|
|
326
|
+
expiresAt: number;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
interface CreateDiagnosticInput {
|
|
330
|
+
platform: string;
|
|
331
|
+
errorType: string;
|
|
332
|
+
fieldNames?: string[];
|
|
333
|
+
severity?: DiagnosticSeverity;
|
|
334
|
+
now?: number;
|
|
335
|
+
}
|
|
336
|
+
declare function createRedactedDiagnostic(input: CreateDiagnosticInput): AdapterDiagnostic;
|
|
337
|
+
|
|
338
|
+
type ProjectIdentitySource = "platform_project_id" | "canonical_path" | "unresolved";
|
|
339
|
+
interface ProjectIdentityResolution {
|
|
340
|
+
key: string | null;
|
|
341
|
+
source: ProjectIdentitySource;
|
|
342
|
+
canonicalPath?: string;
|
|
343
|
+
}
|
|
344
|
+
declare function resolveProjectIdentityKey(context: PlatformProjectContext): ProjectIdentityResolution;
|
|
345
|
+
|
|
346
|
+
type MemoryPathMode = "legacy_first" | "platform_opt_in";
|
|
347
|
+
interface MemoryPathPolicyInput {
|
|
348
|
+
projectDir: string;
|
|
349
|
+
platform: string;
|
|
350
|
+
defaultRelativePath: string;
|
|
351
|
+
platformRelativePath?: string;
|
|
352
|
+
platformOptIn?: boolean;
|
|
353
|
+
legacyRelativePaths?: string[];
|
|
354
|
+
}
|
|
355
|
+
interface MemoryMigrationSuggestion {
|
|
356
|
+
fromPath: string;
|
|
357
|
+
toPath: string;
|
|
358
|
+
}
|
|
359
|
+
interface MemoryPathPolicyResult {
|
|
360
|
+
mode: MemoryPathMode;
|
|
361
|
+
memoryPath: string;
|
|
362
|
+
canonicalPath: string;
|
|
363
|
+
migrationSuggestion?: MemoryMigrationSuggestion;
|
|
364
|
+
}
|
|
365
|
+
declare function resolveMemoryPathPolicy(input: MemoryPathPolicyInput): MemoryPathPolicyResult;
|
|
366
|
+
|
|
367
|
+
interface ProcessPlatformEventResult {
|
|
368
|
+
skipped: boolean;
|
|
369
|
+
reason?: string;
|
|
370
|
+
projectIdentityKey?: string;
|
|
371
|
+
diagnostic?: AdapterDiagnostic;
|
|
372
|
+
}
|
|
373
|
+
declare function processPlatformEvent(event: PlatformEvent): ProcessPlatformEventResult;
|
|
374
|
+
|
|
375
|
+
declare function detectPlatformFromEnv(): string;
|
|
376
|
+
declare function detectPlatform(input: HookInput): string;
|
|
377
|
+
|
|
378
|
+
declare const claudeAdapter: PlatformAdapter;
|
|
379
|
+
|
|
380
|
+
declare const opencodeAdapter: PlatformAdapter;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Example minimal adapter scaffold for future platform onboarding.
|
|
384
|
+
* This adapter is intentionally not registered by default.
|
|
385
|
+
*
|
|
386
|
+
* To create a new adapter for your platform, use:
|
|
387
|
+
* export const myAdapter = createAdapter("my-platform");
|
|
388
|
+
* Then register it via AdapterRegistry.register(myAdapter).
|
|
389
|
+
*/
|
|
390
|
+
declare const exampleAdapter: PlatformAdapter;
|
|
391
|
+
|
|
392
|
+
declare function createAdapter(platform: string): PlatformAdapter;
|
|
393
|
+
|
|
394
|
+
declare function getDefaultAdapterRegistry(): ReadonlyAdapterRegistry;
|
|
395
|
+
declare function resetDefaultAdapterRegistry(): void;
|
|
396
|
+
|
|
397
|
+
export { DEFAULT_CONFIG, type HookInput, type HookOutput, type InjectedContext, type MemorySearchResult, Mind, type MindConfig, type MindStats, type Observation, type ObservationMetadata, type ObservationType, type ReadonlyAdapterRegistry, SUPPORTED_ADAPTER_CONTRACT_MAJOR, type SessionSummary, classifyObservationType, claudeAdapter, createAdapter, createRedactedDiagnostic, debug, detectPlatform, detectPlatformFromEnv, estimateTokens, exampleAdapter, extractKeyInfo, formatTimestamp, generateId, getDefaultAdapterRegistry, getMind, opencodeAdapter, processPlatformEvent, readStdin, resetDefaultAdapterRegistry, resetMind, resolveMemoryPathPolicy, resolveProjectIdentityKey, safeJsonParse, truncateToTokens, validateAdapterContractVersion, writeOutput };
|