@lumenflow/memory 2.10.0 → 2.11.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/package.json +2 -2
- package/dist/index.d.ts +0 -17
- package/dist/mem-checkpoint-core.d.ts +0 -91
- package/dist/mem-cleanup-core.d.ts +0 -202
- package/dist/mem-create-core.d.ts +0 -93
- package/dist/mem-export-core.d.ts +0 -33
- package/dist/mem-id.d.ts +0 -91
- package/dist/mem-init-core.d.ts +0 -93
- package/dist/mem-ready-core.d.ts +0 -56
- package/dist/mem-signal-core.d.ts +0 -132
- package/dist/mem-start-core.d.ts +0 -76
- package/dist/mem-summarize-core.d.ts +0 -105
- package/dist/mem-triage-core.d.ts +0 -127
- package/dist/memory-schema.d.ts +0 -150
- package/dist/memory-store.d.ts +0 -108
- package/dist/paths.d.ts +0 -28
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumenflow/memory",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Memory layer for LumenFlow workflow framework - session tracking, context recovery, and agent coordination",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lumenflow",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"ms": "^2.1.3",
|
|
50
50
|
"yaml": "^2.8.2",
|
|
51
51
|
"zod": "^4.3.5",
|
|
52
|
-
"@lumenflow/core": "2.
|
|
52
|
+
"@lumenflow/core": "2.11.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@vitest/coverage-v8": "^4.0.17",
|
package/dist/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @lumenflow/memory - Session tracking and context recovery
|
|
3
|
-
* @module @lumenflow/memory
|
|
4
|
-
*/
|
|
5
|
-
export * from './mem-checkpoint-core.js';
|
|
6
|
-
export * from './mem-cleanup-core.js';
|
|
7
|
-
export * from './mem-create-core.js';
|
|
8
|
-
export * from './mem-export-core.js';
|
|
9
|
-
export * from './mem-id.js';
|
|
10
|
-
export * from './mem-init-core.js';
|
|
11
|
-
export * from './mem-ready-core.js';
|
|
12
|
-
export * from './mem-signal-core.js';
|
|
13
|
-
export * from './mem-start-core.js';
|
|
14
|
-
export { filterSummarizableNodes, summarizeWu, getCompactionRatio as getSummarizeCompactionRatio, } from './mem-summarize-core.js';
|
|
15
|
-
export * from './mem-triage-core.js';
|
|
16
|
-
export * from './memory-schema.js';
|
|
17
|
-
export * from './memory-store.js';
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Checkpoint Core (WU-1467, WU-1748)
|
|
3
|
-
*
|
|
4
|
-
* Core logic for creating checkpoint nodes for context snapshots.
|
|
5
|
-
* Used before /clear or session handoff to preserve progress state.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Creates checkpoint nodes with progress summary and next steps
|
|
9
|
-
* - Optional linking to sessions and WUs
|
|
10
|
-
* - Supports handoff trigger detection
|
|
11
|
-
* - Auto-initializes memory layer if not present
|
|
12
|
-
* - WU-1748: Persists to wu-events.jsonl for cross-agent visibility
|
|
13
|
-
*
|
|
14
|
-
* @see {@link tools/mem-checkpoint.mjs} - CLI wrapper
|
|
15
|
-
* @see {@link tools/__tests__/mem-checkpoint.test.mjs} - Tests
|
|
16
|
-
* @see {@link tools/lib/memory-schema.mjs} - Schema definitions
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* Checkpoint creation options
|
|
20
|
-
*/
|
|
21
|
-
export interface CreateCheckpointOptions {
|
|
22
|
-
/** Checkpoint note/description (required) */
|
|
23
|
-
note: string;
|
|
24
|
-
/** Session ID to link checkpoint to */
|
|
25
|
-
sessionId?: string;
|
|
26
|
-
/** Work Unit ID to link checkpoint to */
|
|
27
|
-
wuId?: string;
|
|
28
|
-
/** Progress summary */
|
|
29
|
-
progress?: string;
|
|
30
|
-
/** Next steps description */
|
|
31
|
-
nextSteps?: string;
|
|
32
|
-
/** Handoff trigger (e.g., 'clear', 'handoff') */
|
|
33
|
-
trigger?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Checkpoint metadata stored in the node
|
|
37
|
-
*/
|
|
38
|
-
interface CheckpointMetadata {
|
|
39
|
-
progress?: string;
|
|
40
|
-
nextSteps?: string;
|
|
41
|
-
trigger?: string;
|
|
42
|
-
[key: string]: unknown;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Memory node structure for checkpoints
|
|
46
|
-
*/
|
|
47
|
-
interface CheckpointNode {
|
|
48
|
-
id: string;
|
|
49
|
-
type: 'checkpoint';
|
|
50
|
-
lifecycle: 'session';
|
|
51
|
-
content: string;
|
|
52
|
-
created_at: string;
|
|
53
|
-
wu_id?: string;
|
|
54
|
-
session_id?: string;
|
|
55
|
-
metadata?: CheckpointMetadata;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Checkpoint creation result
|
|
59
|
-
*/
|
|
60
|
-
export interface CreateCheckpointResult {
|
|
61
|
-
/** Whether the operation succeeded */
|
|
62
|
-
success: boolean;
|
|
63
|
-
/** Created checkpoint node */
|
|
64
|
-
checkpoint: CheckpointNode;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Creates a new checkpoint node for context preservation.
|
|
68
|
-
*
|
|
69
|
-
* Creates a checkpoint-type memory node with:
|
|
70
|
-
* - Unique ID (mem-XXXX format)
|
|
71
|
-
* - User-provided note in content
|
|
72
|
-
* - Optional session and WU linking
|
|
73
|
-
* - Progress summary and next steps in metadata
|
|
74
|
-
*
|
|
75
|
-
* @param baseDir - Base directory containing .lumenflow/memory/
|
|
76
|
-
* @param options - Checkpoint options
|
|
77
|
-
* @returns Result with created checkpoint node
|
|
78
|
-
* @throws If note is missing or WU ID is invalid
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* const result = await createCheckpoint(baseDir, {
|
|
82
|
-
* note: 'Before /clear - completed TDD tests',
|
|
83
|
-
* sessionId: 'session-uuid',
|
|
84
|
-
* wuId: 'WU-1467',
|
|
85
|
-
* progress: 'TDD tests passing, core module implemented',
|
|
86
|
-
* nextSteps: 'Implement CLI wrapper, add package.json script',
|
|
87
|
-
* });
|
|
88
|
-
* console.log(result.checkpoint.id); // 'mem-a1b2'
|
|
89
|
-
*/
|
|
90
|
-
export declare function createCheckpoint(baseDir: string, options: CreateCheckpointOptions): Promise<CreateCheckpointResult>;
|
|
91
|
-
export {};
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Cleanup Core (WU-1472, WU-1554)
|
|
3
|
-
*
|
|
4
|
-
* Prune closed memory nodes based on lifecycle policy.
|
|
5
|
-
* Implements compaction to prevent memory bloat.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Remove ephemeral nodes (always discarded)
|
|
9
|
-
* - Remove session nodes when session is closed
|
|
10
|
-
* - Archive summarized nodes (marked with summarized_into)
|
|
11
|
-
* - Respect sensitive:true flag for stricter retention
|
|
12
|
-
* - Support dry-run mode for preview
|
|
13
|
-
* - Report compaction metrics (ratio, bytes freed)
|
|
14
|
-
* - WU-1554: TTL-based expiration for old nodes
|
|
15
|
-
* - WU-1554: Active session protection regardless of age
|
|
16
|
-
*
|
|
17
|
-
* Lifecycle Policy:
|
|
18
|
-
* - ephemeral: Always removed (scratch pad data)
|
|
19
|
-
* - session: Removed when session is closed
|
|
20
|
-
* - wu: Removed when marked with summarized_into (after WU completion)
|
|
21
|
-
* - project: Never removed (architectural knowledge)
|
|
22
|
-
*
|
|
23
|
-
* TTL Policy (WU-1554):
|
|
24
|
-
* - Nodes older than TTL are removed regardless of lifecycle
|
|
25
|
-
* - Active sessions (status: 'active') are never removed
|
|
26
|
-
* - Project and sensitive nodes are protected from TTL removal
|
|
27
|
-
*
|
|
28
|
-
* @see {@link tools/mem-cleanup.mjs} - CLI wrapper
|
|
29
|
-
* @see {@link tools/__tests__/mem-cleanup.test.mjs} - Tests
|
|
30
|
-
*/
|
|
31
|
-
import type { MemoryNode } from './memory-schema.js';
|
|
32
|
-
/**
|
|
33
|
-
* Lifecycle policy definition
|
|
34
|
-
*/
|
|
35
|
-
interface LifecyclePolicyEntry {
|
|
36
|
-
alwaysRemove: boolean;
|
|
37
|
-
requiresSummarized: boolean;
|
|
38
|
-
protected?: boolean;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Lifecycle policy type for indexed access
|
|
42
|
-
*/
|
|
43
|
-
type LifecycleType = 'ephemeral' | 'session' | 'wu' | 'project';
|
|
44
|
-
/**
|
|
45
|
-
* Lifecycle policy definitions
|
|
46
|
-
*
|
|
47
|
-
* Determines which nodes are eligible for cleanup based on lifecycle.
|
|
48
|
-
*/
|
|
49
|
-
export declare const LIFECYCLE_POLICY: Record<LifecycleType, LifecyclePolicyEntry>;
|
|
50
|
-
/**
|
|
51
|
-
* Metadata flag that indicates sensitive data requiring stricter retention
|
|
52
|
-
*/
|
|
53
|
-
export declare const SENSITIVE_FLAG = "sensitive";
|
|
54
|
-
/**
|
|
55
|
-
* Cleanup options for memory pruning
|
|
56
|
-
*/
|
|
57
|
-
export interface CleanupOptions {
|
|
58
|
-
/** If true, preview without modifications */
|
|
59
|
-
dryRun?: boolean;
|
|
60
|
-
/** Session ID to consider closed (removes session lifecycle nodes) */
|
|
61
|
-
sessionId?: string;
|
|
62
|
-
/** TTL duration string (e.g., '30d', '7d', '24h') for age-based cleanup */
|
|
63
|
-
ttl?: string;
|
|
64
|
-
/** TTL in milliseconds (alternative to ttl string) */
|
|
65
|
-
ttlMs?: number;
|
|
66
|
-
/** Current timestamp for testing (defaults to Date.now()) */
|
|
67
|
-
now?: number;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Breakdown of cleanup by lifecycle type
|
|
71
|
-
*/
|
|
72
|
-
interface CleanupBreakdown {
|
|
73
|
-
ephemeral: number;
|
|
74
|
-
session: number;
|
|
75
|
-
wu: number;
|
|
76
|
-
sensitive: number;
|
|
77
|
-
ttlExpired: number;
|
|
78
|
-
activeSessionProtected: number;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Result of cleanup operation
|
|
82
|
-
*/
|
|
83
|
-
export interface CleanupResult {
|
|
84
|
-
/** Whether cleanup succeeded */
|
|
85
|
-
success: boolean;
|
|
86
|
-
/** IDs of removed nodes */
|
|
87
|
-
removedIds: string[];
|
|
88
|
-
/** IDs of retained nodes */
|
|
89
|
-
retainedIds: string[];
|
|
90
|
-
/** Approximate bytes freed (0 if dry-run) */
|
|
91
|
-
bytesFreed: number;
|
|
92
|
-
/** Ratio of removed to total nodes */
|
|
93
|
-
compactionRatio: number;
|
|
94
|
-
/** True if in dry-run mode */
|
|
95
|
-
dryRun?: boolean;
|
|
96
|
-
/** TTL in milliseconds if TTL was provided */
|
|
97
|
-
ttlMs?: number;
|
|
98
|
-
/** Breakdown by lifecycle */
|
|
99
|
-
breakdown: CleanupBreakdown;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Parse a TTL duration string into milliseconds (WU-1554).
|
|
103
|
-
*
|
|
104
|
-
* Uses the `ms` package to parse human-readable duration strings.
|
|
105
|
-
*
|
|
106
|
-
* @param ttlString - TTL string (e.g., '30d', '7d', '24h', '60m')
|
|
107
|
-
* @returns TTL in milliseconds
|
|
108
|
-
* @throws If TTL format is invalid
|
|
109
|
-
*
|
|
110
|
-
* @example
|
|
111
|
-
* parseTtl('30d'); // 2592000000 (30 days in ms)
|
|
112
|
-
* parseTtl('7d'); // 604800000 (7 days in ms)
|
|
113
|
-
* parseTtl('24h'); // 86400000 (24 hours in ms)
|
|
114
|
-
*/
|
|
115
|
-
export declare function parseTtl(ttlString: string): number;
|
|
116
|
-
/**
|
|
117
|
-
* Check if a node has expired based on TTL (WU-1554).
|
|
118
|
-
*
|
|
119
|
-
* @param node - Memory node to check
|
|
120
|
-
* @param ttlMs - TTL in milliseconds
|
|
121
|
-
* @param now - Current timestamp (defaults to Date.now())
|
|
122
|
-
* @returns True if node is older than TTL
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* // Check if node is older than 30 days
|
|
126
|
-
* const expired = isNodeExpired(node, 30 * 24 * 60 * 60 * 1000);
|
|
127
|
-
*/
|
|
128
|
-
export declare function isNodeExpired(node: MemoryNode, ttlMs: number, now?: number): boolean;
|
|
129
|
-
/**
|
|
130
|
-
* Check if a node should be removed based on lifecycle policy and TTL.
|
|
131
|
-
*
|
|
132
|
-
* Policy rules (checked in order):
|
|
133
|
-
* 1. Active sessions are always retained (WU-1554)
|
|
134
|
-
* 2. Sensitive nodes are always retained
|
|
135
|
-
* 3. Protected lifecycle (project) nodes are never removed
|
|
136
|
-
* 4. TTL expiration removes old nodes (WU-1554)
|
|
137
|
-
* 5. Ephemeral nodes are always removed
|
|
138
|
-
* 6. Session nodes are removed when their session is closed
|
|
139
|
-
* 7. WU nodes are removed only when marked with summarized_into
|
|
140
|
-
*
|
|
141
|
-
* @param {MemoryNode} node - Memory node to check
|
|
142
|
-
* @param {CleanupOptions} options - Cleanup options
|
|
143
|
-
* @returns {{remove: boolean, reason: string}} Removal decision with reason
|
|
144
|
-
*/
|
|
145
|
-
export declare function shouldRemoveNode(node: MemoryNode, options?: CleanupOptions): {
|
|
146
|
-
remove: boolean;
|
|
147
|
-
reason: string;
|
|
148
|
-
};
|
|
149
|
-
/**
|
|
150
|
-
* Calculate approximate byte size of a node when serialized.
|
|
151
|
-
*
|
|
152
|
-
* @param node - Memory node
|
|
153
|
-
* @returns Approximate byte size
|
|
154
|
-
*/
|
|
155
|
-
export declare function estimateNodeBytes(node: MemoryNode): number;
|
|
156
|
-
/**
|
|
157
|
-
* Calculate compaction ratio (removed / total).
|
|
158
|
-
*
|
|
159
|
-
* @param removedCount - Number of removed nodes
|
|
160
|
-
* @param totalCount - Total number of nodes
|
|
161
|
-
* @returns Compaction ratio (0 to 1, or 0 if no nodes)
|
|
162
|
-
*/
|
|
163
|
-
export declare function getCompactionRatio(removedCount: number, totalCount: number): number;
|
|
164
|
-
/**
|
|
165
|
-
* Perform memory cleanup based on lifecycle policy and TTL.
|
|
166
|
-
*
|
|
167
|
-
* Removes nodes according to lifecycle policy:
|
|
168
|
-
* - Active sessions are never removed (WU-1554)
|
|
169
|
-
* - Sensitive nodes are always retained
|
|
170
|
-
* - Project nodes are never removed
|
|
171
|
-
* - TTL-expired nodes are removed (WU-1554)
|
|
172
|
-
* - Ephemeral nodes are always removed
|
|
173
|
-
* - Session nodes are removed when their session is closed
|
|
174
|
-
* - WU nodes are removed only when marked with summarized_into
|
|
175
|
-
*
|
|
176
|
-
* In dry-run mode, no modifications are made but the result shows
|
|
177
|
-
* what would be removed.
|
|
178
|
-
*
|
|
179
|
-
* @param {string} baseDir - Base directory containing .lumenflow/memory/
|
|
180
|
-
* @param {CleanupOptions} options - Cleanup options
|
|
181
|
-
* @returns {Promise<CleanupResult>} Result with removed nodes and metrics
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* // Cleanup with dry-run to preview
|
|
185
|
-
* const preview = await cleanupMemory(baseDir, { dryRun: true });
|
|
186
|
-
* console.log(`Would remove ${preview.removedIds.length} nodes`);
|
|
187
|
-
* console.log(`Would free ${preview.bytesFreed} bytes`);
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* // Cleanup session nodes when session closes
|
|
191
|
-
* const result = await cleanupMemory(baseDir, {
|
|
192
|
-
* sessionId: 'abc-123-def-456',
|
|
193
|
-
* });
|
|
194
|
-
* console.log(`Removed ${result.removedIds.length} nodes`);
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* // WU-1554: TTL-based cleanup
|
|
198
|
-
* const result = await cleanupMemory(baseDir, { ttl: '30d' });
|
|
199
|
-
* console.log(`Removed ${result.breakdown.ttlExpired} expired nodes`);
|
|
200
|
-
*/
|
|
201
|
-
export declare function cleanupMemory(baseDir: string, options?: CleanupOptions): Promise<CleanupResult>;
|
|
202
|
-
export {};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Create Core (WU-1469)
|
|
3
|
-
*
|
|
4
|
-
* Core logic for creating memory nodes with discovered-from provenance.
|
|
5
|
-
* KEY DIFFERENTIATOR: supports discovered-from relationship for scope-creep
|
|
6
|
-
* forensics. Creates audit trail of WHY work expanded, not just WHAT changed.
|
|
7
|
-
*
|
|
8
|
-
* Features:
|
|
9
|
-
* - Creates all 5 node types: session, discovery, checkpoint, note, summary
|
|
10
|
-
* - Auto-generates hash-based ID using mem-id
|
|
11
|
-
* - Validates node against memory-schema
|
|
12
|
-
* - Supports discovered-from relationship for provenance tracking
|
|
13
|
-
*
|
|
14
|
-
* @see {@link tools/mem-create.mjs} - CLI wrapper
|
|
15
|
-
* @see {@link tools/__tests__/mem-create.test.mjs} - Tests
|
|
16
|
-
* @see {@link tools/lib/memory-schema.mjs} - Schema definitions
|
|
17
|
-
*/
|
|
18
|
-
import { type MemoryNode } from './memory-schema.js';
|
|
19
|
-
/**
|
|
20
|
-
* Memory node creation options
|
|
21
|
-
*/
|
|
22
|
-
export interface CreateMemoryNodeOptions {
|
|
23
|
-
/** Node title/content (required) */
|
|
24
|
-
title: string;
|
|
25
|
-
/** Node type (session, discovery, checkpoint, note, summary) */
|
|
26
|
-
type?: string;
|
|
27
|
-
/** Work Unit ID to link node to */
|
|
28
|
-
wuId?: string;
|
|
29
|
-
/** Session ID to link node to */
|
|
30
|
-
sessionId?: string;
|
|
31
|
-
/** Parent node ID for provenance tracking */
|
|
32
|
-
discoveredFrom?: string;
|
|
33
|
-
/** Tags for categorization */
|
|
34
|
-
tags?: string[];
|
|
35
|
-
/** Priority level (P0, P1, P2, P3) */
|
|
36
|
-
priority?: string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Relationship between memory nodes
|
|
40
|
-
*/
|
|
41
|
-
interface Relationship {
|
|
42
|
-
from_id: string;
|
|
43
|
-
to_id: string;
|
|
44
|
-
type: string;
|
|
45
|
-
created_at: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Memory node creation result
|
|
49
|
-
*/
|
|
50
|
-
export interface CreateMemoryNodeResult {
|
|
51
|
-
/** Whether the operation succeeded */
|
|
52
|
-
success: boolean;
|
|
53
|
-
/** Created memory node */
|
|
54
|
-
node: MemoryNode;
|
|
55
|
-
/** Created relationship (if discoveredFrom provided) */
|
|
56
|
-
relationship?: Relationship;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new memory node with optional discovered-from provenance.
|
|
60
|
-
*
|
|
61
|
-
* Creates a memory node with:
|
|
62
|
-
* - Unique ID (mem-XXXX format) generated from content hash
|
|
63
|
-
* - User-provided title as content
|
|
64
|
-
* - Type-appropriate lifecycle
|
|
65
|
-
* - Optional discovered-from relationship for provenance tracking
|
|
66
|
-
*
|
|
67
|
-
* @param {string} baseDir - Base directory containing .lumenflow/memory/
|
|
68
|
-
* @param {CreateMemoryNodeOptions} options - Node creation options
|
|
69
|
-
* @returns {Promise<CreateMemoryNodeResult>} Result with created node and optional relationship
|
|
70
|
-
* @throws {Error} If title is missing, type is invalid, or IDs are malformed
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* // Create a simple discovery node
|
|
74
|
-
* const result = await createMemoryNode(baseDir, {
|
|
75
|
-
* title: 'Found relevant file at src/utils.mjs',
|
|
76
|
-
* type: 'discovery',
|
|
77
|
-
* wuId: 'WU-1469',
|
|
78
|
-
* });
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* // Create a node with provenance (scope-creep tracking)
|
|
82
|
-
* const parent = await createMemoryNode(baseDir, {
|
|
83
|
-
* title: 'Found src/components/',
|
|
84
|
-
* type: 'discovery',
|
|
85
|
-
* });
|
|
86
|
-
* const child = await createMemoryNode(baseDir, {
|
|
87
|
-
* title: 'Found src/components/Button.tsx',
|
|
88
|
-
* type: 'discovery',
|
|
89
|
-
* discoveredFrom: parent.node.id, // Track where this came from
|
|
90
|
-
* });
|
|
91
|
-
*/
|
|
92
|
-
export declare function createMemoryNode(baseDir: string, options: CreateMemoryNodeOptions): Promise<CreateMemoryNodeResult>;
|
|
93
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Export Core (WU-1137)
|
|
3
|
-
*
|
|
4
|
-
* Render memory.jsonl as markdown or JSON with basic filters.
|
|
5
|
-
* Designed for human-readable inspection without changing storage format.
|
|
6
|
-
*/
|
|
7
|
-
import type { MemoryNode } from './memory-schema.js';
|
|
8
|
-
/** Supported output formats for export */
|
|
9
|
-
export type ExportFormat = 'markdown' | 'json';
|
|
10
|
-
/** Export filters */
|
|
11
|
-
export interface ExportOptions {
|
|
12
|
-
/** WU ID filter (e.g., WU-1234) */
|
|
13
|
-
wuId?: string;
|
|
14
|
-
/** Node type filter (e.g., discovery, checkpoint) */
|
|
15
|
-
type?: string;
|
|
16
|
-
/** Lifecycle filter (ephemeral, session, wu, project) */
|
|
17
|
-
lifecycle?: string;
|
|
18
|
-
/** Output format (markdown or json) */
|
|
19
|
-
format?: ExportFormat;
|
|
20
|
-
}
|
|
21
|
-
/** Export result */
|
|
22
|
-
export interface ExportResult {
|
|
23
|
-
format: ExportFormat;
|
|
24
|
-
nodes: MemoryNode[];
|
|
25
|
-
output: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Export memory nodes in the requested format.
|
|
29
|
-
*
|
|
30
|
-
* @param baseDir - Project base directory
|
|
31
|
-
* @param options - Export options
|
|
32
|
-
*/
|
|
33
|
-
export declare function exportMemory(baseDir: string, options?: ExportOptions): Promise<ExportResult>;
|
package/dist/mem-id.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory ID Generator (WU-1465)
|
|
3
|
-
*
|
|
4
|
-
* Hash-based collision-free ID generation for memory nodes.
|
|
5
|
-
* Format: mem-[4 hex chars] derived from content hash.
|
|
6
|
-
* Supports hierarchical IDs (mem-a1b2.1.2) for sub-task decomposition.
|
|
7
|
-
*
|
|
8
|
-
* @see {@link tools/lib/__tests__/mem-id.test.mjs} - Tests
|
|
9
|
-
* @see {@link tools/lib/memory-schema.mjs} - Schema definitions
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Regex patterns for memory ID validation
|
|
13
|
-
*/
|
|
14
|
-
export declare const MEM_ID_PATTERNS: {
|
|
15
|
-
/**
|
|
16
|
-
* Base memory ID format: mem-[a-f0-9]{4}
|
|
17
|
-
* Only lowercase hex characters (0-9, a-f)
|
|
18
|
-
*/
|
|
19
|
-
BASE_ID: RegExp;
|
|
20
|
-
/**
|
|
21
|
-
* Hierarchical memory ID format: mem-[a-f0-9]{4}(.[1-9][0-9]*)*
|
|
22
|
-
* Base ID followed by optional dot-separated positive integers
|
|
23
|
-
* Examples: mem-a1b2, mem-a1b2.1, mem-a1b2.1.2
|
|
24
|
-
*/
|
|
25
|
-
HIERARCHICAL_ID: RegExp;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Generates a deterministic memory ID from content.
|
|
29
|
-
*
|
|
30
|
-
* Uses SHA-256 hash of the content, taking the first 4 hex characters.
|
|
31
|
-
* Same content always produces the same ID (deterministic).
|
|
32
|
-
*
|
|
33
|
-
* @param content - Content to hash for ID generation
|
|
34
|
-
* @returns Memory ID in format mem-[a-f0-9]{4}
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const id = generateMemId('discovered file at src/utils.mjs');
|
|
38
|
-
* // Returns something like 'mem-a3f2'
|
|
39
|
-
*/
|
|
40
|
-
export declare function generateMemId(content: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Generates a hierarchical memory ID by appending an index to a parent ID.
|
|
43
|
-
*
|
|
44
|
-
* Used for sub-task decomposition where a parent task (mem-a1b2) has
|
|
45
|
-
* child tasks (mem-a1b2.1, mem-a1b2.2) and grandchildren (mem-a1b2.1.1).
|
|
46
|
-
*
|
|
47
|
-
* @param parentId - Parent memory ID (base or hierarchical)
|
|
48
|
-
* @param index - Positive integer index (1-based)
|
|
49
|
-
* @returns Hierarchical memory ID
|
|
50
|
-
* @throws If parentId is invalid or index is not positive
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* generateHierarchicalId('mem-a1b2', 1); // 'mem-a1b2.1'
|
|
54
|
-
* generateHierarchicalId('mem-a1b2.1', 2); // 'mem-a1b2.1.2'
|
|
55
|
-
*/
|
|
56
|
-
export declare function generateHierarchicalId(parentId: string, index: number): string;
|
|
57
|
-
/**
|
|
58
|
-
* Validation result from validateMemId
|
|
59
|
-
*/
|
|
60
|
-
export interface MemIdValidationResult {
|
|
61
|
-
/** Whether the ID is valid */
|
|
62
|
-
valid: boolean;
|
|
63
|
-
/** Type of ID if valid */
|
|
64
|
-
type?: 'base' | 'hierarchical';
|
|
65
|
-
/** Base ID portion if hierarchical */
|
|
66
|
-
baseId?: string;
|
|
67
|
-
/** Hierarchical indices (empty for base IDs) */
|
|
68
|
-
indices: number[];
|
|
69
|
-
/** Error message if invalid */
|
|
70
|
-
error?: string;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Validates a memory ID and extracts its components.
|
|
74
|
-
*
|
|
75
|
-
* Returns validation result with type classification and parsed components.
|
|
76
|
-
* Compatible with MEMORY_PATTERNS.MEMORY_ID from memory-schema.mjs.
|
|
77
|
-
*
|
|
78
|
-
* @param id - Memory ID to validate
|
|
79
|
-
* @returns Validation result with parsed components
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* validateMemId('mem-a1b2');
|
|
83
|
-
* // { valid: true, type: 'base', baseId: 'mem-a1b2', indices: [] }
|
|
84
|
-
*
|
|
85
|
-
* validateMemId('mem-a1b2.1.2');
|
|
86
|
-
* // { valid: true, type: 'hierarchical', baseId: 'mem-a1b2', indices: [1, 2] }
|
|
87
|
-
*
|
|
88
|
-
* validateMemId('invalid');
|
|
89
|
-
* // { valid: false, error: 'Invalid memory ID format', indices: [] }
|
|
90
|
-
*/
|
|
91
|
-
export declare function validateMemId(id: string): MemIdValidationResult;
|
package/dist/mem-init-core.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Init Core (WU-1464)
|
|
3
|
-
*
|
|
4
|
-
* Core logic for initializing memory layer in a repository.
|
|
5
|
-
* Creates .lumenflow/memory/ directory with empty memory.jsonl and config.yaml.
|
|
6
|
-
*
|
|
7
|
-
* @see {@link tools/__tests__/mem-init.test.mjs} - Tests
|
|
8
|
-
* @see {@link tools/lib/memory-store.mjs} - Memory store operations
|
|
9
|
-
* @see {@link tools/lib/memory-schema.mjs} - Memory schema definitions
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Memory layer file/directory paths
|
|
13
|
-
*
|
|
14
|
-
* Uses LUMENFLOW_MEMORY_PATHS from local paths.ts to avoid circular dependency.
|
|
15
|
-
*/
|
|
16
|
-
export declare const MEMORY_PATHS: {
|
|
17
|
-
/** Memory directory relative to project root */
|
|
18
|
-
MEMORY_DIR: ".lumenflow/memory";
|
|
19
|
-
/** Memory JSONL file name */
|
|
20
|
-
MEMORY_FILE: string;
|
|
21
|
-
/** Config YAML file name */
|
|
22
|
-
CONFIG_FILE: string;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Default memory layer configuration
|
|
26
|
-
*
|
|
27
|
-
* Retention values are in seconds:
|
|
28
|
-
* - ephemeral: 0 (immediate discard)
|
|
29
|
-
* - session: 3600 (1 hour)
|
|
30
|
-
* - wu: 604800 (7 days)
|
|
31
|
-
* - project: -1 (never expire)
|
|
32
|
-
*/
|
|
33
|
-
export declare const DEFAULT_CONFIG: {
|
|
34
|
-
/** Config schema version */
|
|
35
|
-
version: number;
|
|
36
|
-
/** Retention policy for each lifecycle */
|
|
37
|
-
retention: {
|
|
38
|
-
/** Ephemeral nodes are discarded immediately after use */
|
|
39
|
-
ephemeral: number;
|
|
40
|
-
/** Session nodes expire after 1 hour */
|
|
41
|
-
session: number;
|
|
42
|
-
/** WU nodes expire after 7 days */
|
|
43
|
-
wu: number;
|
|
44
|
-
/** Project nodes never expire (-1 = infinite) */
|
|
45
|
-
project: number;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Memory initialization paths
|
|
50
|
-
*/
|
|
51
|
-
interface InitMemoryPaths {
|
|
52
|
-
memoryDir: string;
|
|
53
|
-
memoryJsonl: string;
|
|
54
|
-
configYaml: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Memory initialization created flags
|
|
58
|
-
*/
|
|
59
|
-
interface InitMemoryCreated {
|
|
60
|
-
directory: boolean;
|
|
61
|
-
memoryJsonl: boolean;
|
|
62
|
-
configYaml: boolean;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Memory initialization result
|
|
66
|
-
*/
|
|
67
|
-
export interface InitMemoryResult {
|
|
68
|
-
success: boolean;
|
|
69
|
-
alreadyInitialized: boolean;
|
|
70
|
-
paths: InitMemoryPaths;
|
|
71
|
-
created: InitMemoryCreated;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Initialize memory layer in a repository.
|
|
75
|
-
*
|
|
76
|
-
* Creates:
|
|
77
|
-
* - .lumenflow/memory/ directory
|
|
78
|
-
* - memory.jsonl (empty if not exists)
|
|
79
|
-
* - config.yaml (default settings if not exists)
|
|
80
|
-
*
|
|
81
|
-
* Idempotent: Running multiple times does not corrupt existing data.
|
|
82
|
-
*
|
|
83
|
-
* @param baseDir - Base directory of the repository
|
|
84
|
-
* @returns Result object with success, paths, and created flags
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* const result = await initMemory(process.cwd());
|
|
88
|
-
* if (result.success) {
|
|
89
|
-
* console.log('Memory initialized at:', result.paths.memoryDir);
|
|
90
|
-
* }
|
|
91
|
-
*/
|
|
92
|
-
export declare function initMemory(baseDir: string): Promise<InitMemoryResult>;
|
|
93
|
-
export {};
|
package/dist/mem-ready-core.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Ready Core (WU-1468)
|
|
3
|
-
*
|
|
4
|
-
* Deterministic ready-work query for "what next?" oracle.
|
|
5
|
-
* Returns open nodes with no blockers, ordered by priority then createdAt.
|
|
6
|
-
*
|
|
7
|
-
* Ordering algorithm:
|
|
8
|
-
* 1. Priority ASC (P0 first, then P1, P2, P3; nodes without priority last)
|
|
9
|
-
* 2. CreatedAt ASC (oldest first for same priority)
|
|
10
|
-
* 3. ID ASC (stable sort for identical priority and timestamp)
|
|
11
|
-
*
|
|
12
|
-
* A node is "ready" if:
|
|
13
|
-
* - Linked to the specified WU
|
|
14
|
-
* - Not blocked by another node (no `blocks` relationship pointing to it)
|
|
15
|
-
* - No `metadata.blocked_by` array set
|
|
16
|
-
* - Lifecycle is not `ephemeral`
|
|
17
|
-
* - Status is not `closed` (metadata.status !== 'closed')
|
|
18
|
-
*
|
|
19
|
-
* @see {@link tools/mem-ready.mjs} - CLI implementation
|
|
20
|
-
* @see {@link tools/__tests__/mem-ready.test.mjs} - Tests
|
|
21
|
-
*/
|
|
22
|
-
import { type MemoryNode } from './memory-schema.js';
|
|
23
|
-
/**
|
|
24
|
-
* Query options for ready nodes
|
|
25
|
-
*/
|
|
26
|
-
export interface QueryOptions {
|
|
27
|
-
/** WU ID to query (required) */
|
|
28
|
-
wuId: string;
|
|
29
|
-
/** Filter by node type (optional) */
|
|
30
|
-
type?: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Query ready nodes for a WU.
|
|
34
|
-
*
|
|
35
|
-
* Returns unblocked, open nodes linked to the WU in deterministic order:
|
|
36
|
-
* 1. Priority (P0 first, then P1, P2, P3; nodes without priority last)
|
|
37
|
-
* 2. CreatedAt (oldest first for same priority)
|
|
38
|
-
* 3. ID (alphabetical for stable sort)
|
|
39
|
-
*
|
|
40
|
-
* @param baseDir - Base directory containing .lumenflow/memory
|
|
41
|
-
* @param options - Query options
|
|
42
|
-
* @returns Deterministically ordered ready nodes
|
|
43
|
-
* @throws If WU ID format is invalid or file contains malformed JSON
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* const ready = await queryReadyNodes('/path/to/project', { wuId: 'WU-1234' });
|
|
47
|
-
* console.log(`${ready.length} nodes ready for processing`);
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* // Filter by type
|
|
51
|
-
* const discoveries = await queryReadyNodes('/path/to/project', {
|
|
52
|
-
* wuId: 'WU-1234',
|
|
53
|
-
* type: 'discovery',
|
|
54
|
-
* });
|
|
55
|
-
*/
|
|
56
|
-
export declare function queryReadyNodes(baseDir: string, options: QueryOptions): Promise<MemoryNode[]>;
|