@lumenflow/memory 1.3.4 → 1.3.6
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/dist/mem-checkpoint-core.js +4 -11
- package/dist/mem-cleanup-core.js +3 -6
- package/dist/mem-create-core.js +4 -11
- package/dist/mem-init-core.js +7 -4
- package/dist/mem-ready-core.js +3 -2
- package/dist/mem-signal-core.js +2 -5
- package/dist/mem-start-core.js +3 -6
- package/dist/mem-summarize-core.js +3 -6
- package/dist/mem-triage-core.js +4 -7
- package/dist/paths.js +28 -0
- package/package.json +2 -2
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mem-checkpoint-core.d.ts +0 -91
- package/dist/mem-checkpoint-core.d.ts.map +0 -1
- package/dist/mem-checkpoint-core.js.map +0 -1
- package/dist/mem-cleanup-core.d.ts +0 -202
- package/dist/mem-cleanup-core.d.ts.map +0 -1
- package/dist/mem-cleanup-core.js.map +0 -1
- package/dist/mem-create-core.d.ts +0 -93
- package/dist/mem-create-core.d.ts.map +0 -1
- package/dist/mem-create-core.js.map +0 -1
- package/dist/mem-id.d.ts +0 -91
- package/dist/mem-id.d.ts.map +0 -1
- package/dist/mem-id.js.map +0 -1
- package/dist/mem-init-core.d.ts +0 -91
- package/dist/mem-init-core.d.ts.map +0 -1
- package/dist/mem-init-core.js.map +0 -1
- package/dist/mem-ready-core.d.ts +0 -56
- package/dist/mem-ready-core.d.ts.map +0 -1
- package/dist/mem-ready-core.js.map +0 -1
- package/dist/mem-signal-core.d.ts +0 -132
- package/dist/mem-signal-core.d.ts.map +0 -1
- package/dist/mem-signal-core.js.map +0 -1
- package/dist/mem-start-core.d.ts +0 -76
- package/dist/mem-start-core.d.ts.map +0 -1
- package/dist/mem-start-core.js.map +0 -1
- package/dist/mem-summarize-core.d.ts +0 -105
- package/dist/mem-summarize-core.d.ts.map +0 -1
- package/dist/mem-summarize-core.js.map +0 -1
- package/dist/mem-triage-core.d.ts +0 -127
- package/dist/mem-triage-core.d.ts.map +0 -1
- package/dist/mem-triage-core.js.map +0 -1
- package/dist/memory-schema.d.ts +0 -150
- package/dist/memory-schema.d.ts.map +0 -1
- package/dist/memory-schema.js.map +0 -1
- package/dist/memory-store.d.ts +0 -108
- package/dist/memory-store.d.ts.map +0 -1
- package/dist/memory-store.js.map +0 -1
|
@@ -21,14 +21,7 @@ import { generateMemId } from './mem-id.js';
|
|
|
21
21
|
import { appendNode } from './memory-store.js';
|
|
22
22
|
import { MEMORY_PATTERNS } from './memory-schema.js';
|
|
23
23
|
import { WUStateStore } from '@lumenflow/core/wu-state-store';
|
|
24
|
-
|
|
25
|
-
* Memory directory path relative to base directory
|
|
26
|
-
*/
|
|
27
|
-
const MEMORY_DIR = '.beacon/memory';
|
|
28
|
-
/**
|
|
29
|
-
* WU state directory path relative to base directory (WU-1748)
|
|
30
|
-
*/
|
|
31
|
-
const STATE_DIR = '.beacon/state';
|
|
24
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
32
25
|
/**
|
|
33
26
|
* Error messages for validation
|
|
34
27
|
*/
|
|
@@ -63,7 +56,7 @@ function isValidWuId(wuId) {
|
|
|
63
56
|
* @returns Memory directory path
|
|
64
57
|
*/
|
|
65
58
|
async function ensureMemoryDir(baseDir) {
|
|
66
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
59
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
67
60
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Known directory path
|
|
68
61
|
await fs.mkdir(memoryDir, { recursive: true });
|
|
69
62
|
return memoryDir;
|
|
@@ -86,7 +79,7 @@ function generateCheckpointContent(note) {
|
|
|
86
79
|
* - Optional session and WU linking
|
|
87
80
|
* - Progress summary and next steps in metadata
|
|
88
81
|
*
|
|
89
|
-
* @param baseDir - Base directory containing .
|
|
82
|
+
* @param baseDir - Base directory containing .lumenflow/memory/
|
|
90
83
|
* @param options - Checkpoint options
|
|
91
84
|
* @returns Result with created checkpoint node
|
|
92
85
|
* @throws If note is missing or WU ID is invalid
|
|
@@ -155,7 +148,7 @@ export async function createCheckpoint(baseDir, options) {
|
|
|
155
148
|
// WU-1748: Also persist to wu-events.jsonl for cross-agent visibility
|
|
156
149
|
if (wuId) {
|
|
157
150
|
try {
|
|
158
|
-
const stateDir = path.join(baseDir, STATE_DIR);
|
|
151
|
+
const stateDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.STATE_DIR);
|
|
159
152
|
const store = new WUStateStore(stateDir);
|
|
160
153
|
await store.checkpoint(wuId, note, {
|
|
161
154
|
sessionId,
|
package/dist/mem-cleanup-core.js
CHANGED
|
@@ -33,10 +33,7 @@ import path from 'node:path';
|
|
|
33
33
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
34
34
|
const ms = require('ms');
|
|
35
35
|
import { loadMemory, MEMORY_FILE_NAME } from './memory-store.js';
|
|
36
|
-
|
|
37
|
-
* Memory directory path relative to base directory
|
|
38
|
-
*/
|
|
39
|
-
const MEMORY_DIR = '.beacon/memory';
|
|
36
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
40
37
|
/**
|
|
41
38
|
* Lifecycle policy definitions
|
|
42
39
|
*
|
|
@@ -281,7 +278,7 @@ async function writeRetainedNodes(memoryDir, retainedNodes) {
|
|
|
281
278
|
* In dry-run mode, no modifications are made but the result shows
|
|
282
279
|
* what would be removed.
|
|
283
280
|
*
|
|
284
|
-
* @param {string} baseDir - Base directory containing .
|
|
281
|
+
* @param {string} baseDir - Base directory containing .lumenflow/memory/
|
|
285
282
|
* @param {CleanupOptions} options - Cleanup options
|
|
286
283
|
* @returns {Promise<CleanupResult>} Result with removed nodes and metrics
|
|
287
284
|
*
|
|
@@ -305,7 +302,7 @@ async function writeRetainedNodes(memoryDir, retainedNodes) {
|
|
|
305
302
|
*/
|
|
306
303
|
export async function cleanupMemory(baseDir, options = {}) {
|
|
307
304
|
const { dryRun = false, sessionId, ttl, ttlMs: providedTtlMs, now = Date.now() } = options;
|
|
308
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
305
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
309
306
|
// WU-1554: Parse TTL if provided as string
|
|
310
307
|
let ttlMs = providedTtlMs;
|
|
311
308
|
if (ttl && !ttlMs) {
|
package/dist/mem-create-core.js
CHANGED
|
@@ -20,10 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
import { generateMemId } from './mem-id.js';
|
|
21
21
|
import { appendNode } from './memory-store.js';
|
|
22
22
|
import { MEMORY_NODE_TYPES, MEMORY_PATTERNS, validateMemoryNode, validateRelationship, } from './memory-schema.js';
|
|
23
|
-
|
|
24
|
-
* Memory directory path relative to base directory
|
|
25
|
-
*/
|
|
26
|
-
const MEMORY_DIR = '.beacon/memory';
|
|
23
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
27
24
|
/**
|
|
28
25
|
* Relationships file name
|
|
29
26
|
*/
|
|
@@ -32,10 +29,6 @@ const RELATIONSHIPS_FILE_NAME = 'relationships.jsonl';
|
|
|
32
29
|
* Default node type
|
|
33
30
|
*/
|
|
34
31
|
const DEFAULT_NODE_TYPE = 'discovery';
|
|
35
|
-
/**
|
|
36
|
-
* Session file path relative to main checkout
|
|
37
|
-
*/
|
|
38
|
-
const SESSION_FILE_PATH = '.beacon/sessions/current.json';
|
|
39
32
|
/**
|
|
40
33
|
* Type aliases for user-friendly CLI experience (WU-1762)
|
|
41
34
|
* Maps alias names to canonical types and additional tags
|
|
@@ -126,7 +119,7 @@ async function getMainCheckoutFromWorktree(dir) {
|
|
|
126
119
|
* @returns Session data or null
|
|
127
120
|
*/
|
|
128
121
|
async function readCurrentSession(baseDir) {
|
|
129
|
-
const sessionPath = path.join(baseDir,
|
|
122
|
+
const sessionPath = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.SESSION_CURRENT);
|
|
130
123
|
try {
|
|
131
124
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Known session path
|
|
132
125
|
const content = await fs.readFile(sessionPath, { encoding: 'utf-8' });
|
|
@@ -197,7 +190,7 @@ function isValidMemoryId(memId) {
|
|
|
197
190
|
* @returns Memory directory path
|
|
198
191
|
*/
|
|
199
192
|
async function ensureMemoryDir(baseDir) {
|
|
200
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
193
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
201
194
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Known directory path
|
|
202
195
|
await fs.mkdir(memoryDir, { recursive: true });
|
|
203
196
|
return memoryDir;
|
|
@@ -243,7 +236,7 @@ function getLifecycleForType(type) {
|
|
|
243
236
|
* - Type-appropriate lifecycle
|
|
244
237
|
* - Optional discovered-from relationship for provenance tracking
|
|
245
238
|
*
|
|
246
|
-
* @param {string} baseDir - Base directory containing .
|
|
239
|
+
* @param {string} baseDir - Base directory containing .lumenflow/memory/
|
|
247
240
|
* @param {CreateMemoryNodeOptions} options - Node creation options
|
|
248
241
|
* @returns {Promise<CreateMemoryNodeResult>} Result with created node and optional relationship
|
|
249
242
|
* @throws {Error} If title is missing, type is invalid, or IDs are malformed
|
package/dist/mem-init-core.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Memory Init Core (WU-1464)
|
|
3
3
|
*
|
|
4
4
|
* Core logic for initializing memory layer in a repository.
|
|
5
|
-
* Creates .
|
|
5
|
+
* Creates .lumenflow/memory/ directory with empty memory.jsonl and config.yaml.
|
|
6
6
|
*
|
|
7
7
|
* @see {@link tools/__tests__/mem-init.test.mjs} - Tests
|
|
8
8
|
* @see {@link tools/lib/memory-store.mjs} - Memory store operations
|
|
@@ -11,12 +11,15 @@
|
|
|
11
11
|
import fs from 'node:fs/promises';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import yaml from 'yaml';
|
|
14
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
14
15
|
/**
|
|
15
16
|
* Memory layer file/directory paths
|
|
17
|
+
*
|
|
18
|
+
* Uses LUMENFLOW_MEMORY_PATHS from local paths.ts to avoid circular dependency.
|
|
16
19
|
*/
|
|
17
20
|
export const MEMORY_PATHS = {
|
|
18
21
|
/** Memory directory relative to project root */
|
|
19
|
-
MEMORY_DIR:
|
|
22
|
+
MEMORY_DIR: LUMENFLOW_MEMORY_PATHS.MEMORY_DIR,
|
|
20
23
|
/** Memory JSONL file name */
|
|
21
24
|
MEMORY_FILE: 'memory.jsonl',
|
|
22
25
|
/** Config YAML file name */
|
|
@@ -74,7 +77,7 @@ function generateConfigYaml() {
|
|
|
74
77
|
* Initialize memory layer in a repository.
|
|
75
78
|
*
|
|
76
79
|
* Creates:
|
|
77
|
-
* - .
|
|
80
|
+
* - .lumenflow/memory/ directory
|
|
78
81
|
* - memory.jsonl (empty if not exists)
|
|
79
82
|
* - config.yaml (default settings if not exists)
|
|
80
83
|
*
|
|
@@ -116,7 +119,7 @@ export async function initMemory(baseDir) {
|
|
|
116
119
|
}
|
|
117
120
|
// Create directory if needed
|
|
118
121
|
if (!dirExists) {
|
|
119
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool creates .
|
|
122
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- CLI tool creates .lumenflow/memory/ directory
|
|
120
123
|
await fs.mkdir(memoryDir, { recursive: true });
|
|
121
124
|
result.created.directory = true;
|
|
122
125
|
}
|
package/dist/mem-ready-core.js
CHANGED
|
@@ -23,6 +23,7 @@ import fs from 'node:fs/promises';
|
|
|
23
23
|
import path from 'node:path';
|
|
24
24
|
import { loadMemory } from './memory-store.js';
|
|
25
25
|
import { MEMORY_PATTERNS } from './memory-schema.js';
|
|
26
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
26
27
|
/**
|
|
27
28
|
* Relationships file name
|
|
28
29
|
*/
|
|
@@ -183,7 +184,7 @@ function validateWuId(wuId) {
|
|
|
183
184
|
* 2. CreatedAt (oldest first for same priority)
|
|
184
185
|
* 3. ID (alphabetical for stable sort)
|
|
185
186
|
*
|
|
186
|
-
* @param baseDir - Base directory containing .
|
|
187
|
+
* @param baseDir - Base directory containing .lumenflow/memory
|
|
187
188
|
* @param options - Query options
|
|
188
189
|
* @returns Deterministically ordered ready nodes
|
|
189
190
|
* @throws If WU ID format is invalid or file contains malformed JSON
|
|
@@ -203,7 +204,7 @@ export async function queryReadyNodes(baseDir, options) {
|
|
|
203
204
|
const { wuId, type } = options;
|
|
204
205
|
// Validate WU ID
|
|
205
206
|
validateWuId(wuId);
|
|
206
|
-
const memoryDir = path.join(baseDir,
|
|
207
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
207
208
|
// Load memory and relationships
|
|
208
209
|
const memory = await loadMemory(memoryDir);
|
|
209
210
|
const relationships = await loadRelationships(memoryDir);
|
package/dist/mem-signal-core.js
CHANGED
|
@@ -16,14 +16,11 @@
|
|
|
16
16
|
import { randomBytes } from 'node:crypto';
|
|
17
17
|
import fs from 'node:fs/promises';
|
|
18
18
|
import path from 'node:path';
|
|
19
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
19
20
|
/**
|
|
20
21
|
* Signal file name constant
|
|
21
22
|
*/
|
|
22
23
|
export const SIGNAL_FILE_NAME = 'signals.jsonl';
|
|
23
|
-
/**
|
|
24
|
-
* Memory directory path within project
|
|
25
|
-
*/
|
|
26
|
-
const MEMORY_DIR = '.beacon/memory';
|
|
27
24
|
/**
|
|
28
25
|
* WU ID validation pattern (from memory-schema.mjs)
|
|
29
26
|
*/
|
|
@@ -63,7 +60,7 @@ function generateSignalId() {
|
|
|
63
60
|
* @returns Full path to memory directory
|
|
64
61
|
*/
|
|
65
62
|
function getMemoryDir(baseDir) {
|
|
66
|
-
return path.join(baseDir, MEMORY_DIR);
|
|
63
|
+
return path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
67
64
|
}
|
|
68
65
|
/**
|
|
69
66
|
* Gets the signals file path for a project.
|
package/dist/mem-start-core.js
CHANGED
|
@@ -20,10 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
import { generateMemId } from './mem-id.js';
|
|
21
21
|
import { appendNode } from './memory-store.js';
|
|
22
22
|
import { MEMORY_PATTERNS } from './memory-schema.js';
|
|
23
|
-
|
|
24
|
-
* Memory directory path relative to base directory
|
|
25
|
-
*/
|
|
26
|
-
const MEMORY_DIR = '.beacon/memory';
|
|
23
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
27
24
|
/**
|
|
28
25
|
* Default values for session metadata
|
|
29
26
|
*/
|
|
@@ -54,7 +51,7 @@ function isValidWuId(wuId) {
|
|
|
54
51
|
* @returns Memory directory path
|
|
55
52
|
*/
|
|
56
53
|
async function ensureMemoryDir(baseDir) {
|
|
57
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
54
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
58
55
|
// eslint-disable-next-line security/detect-non-literal-fs-filename -- Known directory path
|
|
59
56
|
await fs.mkdir(memoryDir, { recursive: true });
|
|
60
57
|
return memoryDir;
|
|
@@ -79,7 +76,7 @@ function generateSessionContent(wuId, agentType, contextTier) {
|
|
|
79
76
|
* - Agent type and context tier in metadata
|
|
80
77
|
* - UUID session_id for unique identification
|
|
81
78
|
*
|
|
82
|
-
* @param baseDir - Base directory containing .
|
|
79
|
+
* @param baseDir - Base directory containing .lumenflow/memory/
|
|
83
80
|
* @param options - Session options
|
|
84
81
|
* @returns Result with created session node
|
|
85
82
|
* @throws If wuId is missing or invalid
|
|
@@ -17,10 +17,7 @@ import { loadMemory, appendNode } from './memory-store.js';
|
|
|
17
17
|
import { generateMemId } from './mem-id.js';
|
|
18
18
|
import { validateMemoryNode } from './memory-schema.js';
|
|
19
19
|
import path from 'node:path';
|
|
20
|
-
|
|
21
|
-
* Memory directory path relative to base directory
|
|
22
|
-
*/
|
|
23
|
-
const MEMORY_DIR = '.beacon/memory';
|
|
20
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
24
21
|
/**
|
|
25
22
|
* Node types that can be summarized
|
|
26
23
|
*/
|
|
@@ -202,7 +199,7 @@ function createCleanupMarkers(nodes, summaryId) {
|
|
|
202
199
|
* summary node. Original nodes are marked for cleanup (unless
|
|
203
200
|
* they have project lifecycle).
|
|
204
201
|
*
|
|
205
|
-
* @param baseDir - Base directory containing .
|
|
202
|
+
* @param baseDir - Base directory containing .lumenflow/memory/
|
|
206
203
|
* @param options - Summarization options
|
|
207
204
|
* @returns Result with summary and cleanup info
|
|
208
205
|
* @throws If no summarizable nodes found for WU
|
|
@@ -222,7 +219,7 @@ function createCleanupMarkers(nodes, summaryId) {
|
|
|
222
219
|
*/
|
|
223
220
|
export async function summarizeWu(baseDir, options) {
|
|
224
221
|
const { wuId, dryRun = false } = options;
|
|
225
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
222
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
226
223
|
// Load existing memory
|
|
227
224
|
const memory = await loadMemory(memoryDir);
|
|
228
225
|
// Filter summarizable nodes
|
package/dist/mem-triage-core.js
CHANGED
|
@@ -15,10 +15,7 @@ import fs from 'node:fs/promises';
|
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
import { loadMemory, appendNode } from './memory-store.js';
|
|
17
17
|
import { validateLaneFormat } from '@lumenflow/core/lane-checker';
|
|
18
|
-
|
|
19
|
-
* Memory directory path relative to base
|
|
20
|
-
*/
|
|
21
|
-
const MEMORY_DIR = '.beacon/memory';
|
|
18
|
+
import { LUMENFLOW_MEMORY_PATHS } from './paths.js';
|
|
22
19
|
/**
|
|
23
20
|
* WU directory path relative to base
|
|
24
21
|
*/
|
|
@@ -170,7 +167,7 @@ function isClosed(node) {
|
|
|
170
167
|
* @returns Open discovery nodes
|
|
171
168
|
*/
|
|
172
169
|
export async function listOpenDiscoveries(baseDir, options = {}) {
|
|
173
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
170
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
174
171
|
const memory = await loadMemory(memoryDir);
|
|
175
172
|
const relationships = await loadRelationships(memoryDir);
|
|
176
173
|
const blockedByRelationships = buildBlockedSet(relationships);
|
|
@@ -209,7 +206,7 @@ export async function listOpenDiscoveries(baseDir, options = {}) {
|
|
|
209
206
|
*/
|
|
210
207
|
export async function archiveDiscovery(baseDir, options) {
|
|
211
208
|
const { nodeId, reason } = options;
|
|
212
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
209
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
213
210
|
const memory = await loadMemory(memoryDir);
|
|
214
211
|
const node = memory.byId.get(nodeId);
|
|
215
212
|
if (!node) {
|
|
@@ -294,7 +291,7 @@ function truncateToTitle(content) {
|
|
|
294
291
|
*/
|
|
295
292
|
export async function promoteDiscovery(baseDir, options) {
|
|
296
293
|
const { nodeId, lane, title, wuId, priority, dryRun: _dryRun = false } = options;
|
|
297
|
-
const memoryDir = path.join(baseDir, MEMORY_DIR);
|
|
294
|
+
const memoryDir = path.join(baseDir, LUMENFLOW_MEMORY_PATHS.MEMORY_DIR);
|
|
298
295
|
// Validate lane format
|
|
299
296
|
try {
|
|
300
297
|
validateLaneFormat(lane);
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Package Path Constants
|
|
3
|
+
*
|
|
4
|
+
* Defines paths used by the memory layer locally to avoid circular
|
|
5
|
+
* dependencies with @lumenflow/core (which imports from memory).
|
|
6
|
+
*
|
|
7
|
+
* These values MUST match LUMENFLOW_PATHS in @lumenflow/core/wu-constants.ts.
|
|
8
|
+
* When updating paths, update both locations.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link packages/@lumenflow/core/src/wu-constants.ts} - Source of truth
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Path constants for LumenFlow memory layer.
|
|
14
|
+
* Duplicated here to avoid circular dependency with @lumenflow/core.
|
|
15
|
+
*
|
|
16
|
+
* Note: Named LUMENFLOW_MEMORY_PATHS to avoid conflict with
|
|
17
|
+
* MEMORY_PATHS exported from mem-init-core.ts
|
|
18
|
+
*/
|
|
19
|
+
export const LUMENFLOW_MEMORY_PATHS = {
|
|
20
|
+
/** Base directory for all LumenFlow runtime data */
|
|
21
|
+
BASE: '.lumenflow',
|
|
22
|
+
/** WU state store directory */
|
|
23
|
+
STATE_DIR: '.lumenflow/state',
|
|
24
|
+
/** Memory layer directory */
|
|
25
|
+
MEMORY_DIR: '.lumenflow/memory',
|
|
26
|
+
/** Current session file */
|
|
27
|
+
SESSION_CURRENT: '.lumenflow/sessions/current.json',
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumenflow/memory",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Memory layer for LumenFlow workflow framework - session tracking, context recovery, and agent coordination",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lumenflow",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"ms": "^2.1.3",
|
|
48
48
|
"yaml": "^2.8.2",
|
|
49
49
|
"zod": "^4.3.5",
|
|
50
|
-
"@lumenflow/core": "1.3.
|
|
50
|
+
"@lumenflow/core": "1.3.6"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@vitest/coverage-v8": "^4.0.17",
|
package/dist/index.d.ts
DELETED
|
@@ -1,16 +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-id.js';
|
|
9
|
-
export * from './mem-init-core.js';
|
|
10
|
-
export * from './mem-ready-core.js';
|
|
11
|
-
export * from './mem-signal-core.js';
|
|
12
|
-
export * from './mem-start-core.js';
|
|
13
|
-
export { filterSummarizableNodes, summarizeWu, getCompactionRatio as getSummarizeCompactionRatio, } from './mem-summarize-core.js';
|
|
14
|
-
export * from './mem-triage-core.js';
|
|
15
|
-
export * from './memory-schema.js';
|
|
16
|
-
export * from './memory-store.js';
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
|
@@ -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 .beacon/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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mem-checkpoint-core.d.ts","sourceRoot":"","sources":["../src/mem-checkpoint-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAwEH;;;;;;;;;;GAUG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,KAAA,EAAE,OAAO,KAAA;;;;;;;;;GAmFtD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mem-checkpoint-core.js","sourceRoot":"","sources":["../src/mem-checkpoint-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE;;GAEG;AACH,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAEpC;;GAEG;AACH,MAAM,SAAS,GAAG,eAAe,CAAC;AAElC;;GAEG;AACH,MAAM,cAAc,GAAG;IACrB,aAAa,EAAE,kBAAkB;IACjC,UAAU,EAAE,sBAAsB;IAClC,aAAa,EAAE,+DAA+D;CAC/E,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE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