@cleocode/contracts 2026.4.0 → 2026.4.3
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/adapter.d.ts +60 -0
- package/dist/adapter.d.ts.map +1 -1
- package/dist/brain.d.ts +19 -0
- package/dist/brain.d.ts.map +1 -1
- package/dist/capabilities.d.ts +1 -0
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/conduit.d.ts +5 -0
- package/dist/conduit.d.ts.map +1 -1
- package/dist/config.d.ts +38 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/errors.d.ts +30 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +30 -0
- package/dist/errors.js.map +1 -1
- package/dist/install.d.ts +1 -1
- package/dist/install.d.ts.map +1 -1
- package/dist/lafs.d.ts +167 -11
- package/dist/lafs.d.ts.map +1 -1
- package/dist/lafs.js +57 -3
- package/dist/lafs.js.map +1 -1
- package/dist/memory.d.ts +77 -0
- package/dist/memory.d.ts.map +1 -1
- package/dist/operations/issues.d.ts +1 -1
- package/dist/operations/issues.d.ts.map +1 -1
- package/dist/operations/session.d.ts +1 -1
- package/dist/operations/session.js +1 -1
- package/dist/operations/tasks.d.ts +1 -1
- package/dist/operations/tasks.js +1 -1
- package/dist/results.d.ts +89 -0
- package/dist/results.d.ts.map +1 -1
- package/dist/session.d.ts +78 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +5 -0
- package/dist/session.js.map +1 -1
- package/dist/status-registry.d.ts +1 -1
- package/dist/status-registry.js +1 -1
- package/dist/task.d.ts +106 -33
- package/dist/task.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/adapter.ts +60 -0
- package/src/brain.ts +19 -0
- package/src/capabilities.ts +1 -0
- package/src/conduit.ts +3 -0
- package/src/config.ts +38 -3
- package/src/errors.ts +30 -0
- package/src/install.ts +1 -1
- package/src/lafs.ts +169 -13
- package/src/memory.ts +77 -0
- package/src/operations/issues.ts +1 -1
- package/src/operations/session.ts +1 -1
- package/src/operations/tasks.ts +1 -1
- package/src/results.ts +89 -0
- package/src/session.ts +78 -0
- package/src/status-registry.ts +1 -1
- package/src/task.ts +106 -33
package/src/errors.ts
CHANGED
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
* @param fallbackMessage - Message to use if error provides none
|
|
21
21
|
* @returns Normalized error with consistent shape
|
|
22
22
|
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* This function is safe to call on any value thrown by a `catch` clause.
|
|
25
|
+
* It guarantees the returned object is always an `Error` instance with a
|
|
26
|
+
* non-empty `message` property.
|
|
27
|
+
*
|
|
23
28
|
* @example
|
|
24
29
|
* ```typescript
|
|
25
30
|
* try {
|
|
@@ -63,6 +68,10 @@ export function normalizeError(
|
|
|
63
68
|
* @param fallback - Fallback message if extraction fails
|
|
64
69
|
* @returns The error message string
|
|
65
70
|
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Inspects the value for an `Error` instance, a plain string, or an object
|
|
73
|
+
* with a `message` property before falling back to the provided default.
|
|
74
|
+
*
|
|
66
75
|
* @example
|
|
67
76
|
* ```typescript
|
|
68
77
|
* const message = getErrorMessage(err, 'Unknown error');
|
|
@@ -99,6 +108,11 @@ export function getErrorMessage(error: unknown, fallback = 'Unknown error'): str
|
|
|
99
108
|
* @param includeStack - Whether to include stack traces (default: false)
|
|
100
109
|
* @returns Formatted error string
|
|
101
110
|
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* When `context` is provided it is prefixed in square brackets (e.g.
|
|
113
|
+
* `[Database] Connection refused`). Stack traces are appended on a new line
|
|
114
|
+
* only when `includeStack` is `true` and the value is an `Error` with a stack.
|
|
115
|
+
*
|
|
102
116
|
* @example
|
|
103
117
|
* ```typescript
|
|
104
118
|
* console.error(formatError(err, 'Database connection'));
|
|
@@ -126,6 +140,10 @@ export function formatError(error: unknown, context?: string, includeStack = fal
|
|
|
126
140
|
* @param codeOrName - The error code or name to match
|
|
127
141
|
* @returns True if the error matches
|
|
128
142
|
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* Checks both `Error.name` and a custom `code` property, supporting both
|
|
145
|
+
* standard and LAFS-style error codes (e.g. `"E_NOT_FOUND"`).
|
|
146
|
+
*
|
|
129
147
|
* @example
|
|
130
148
|
* ```typescript
|
|
131
149
|
* if (isErrorType(err, 'E_NOT_FOUND')) {
|
|
@@ -154,6 +172,10 @@ export function isErrorType(error: unknown, codeOrName: string): boolean {
|
|
|
154
172
|
* @param error - The error value
|
|
155
173
|
* @returns Error result object
|
|
156
174
|
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* Pairs with {@link createSuccessResult} and {@link isErrorResult} to provide
|
|
177
|
+
* a consistent result-or-error pattern without exceptions.
|
|
178
|
+
*
|
|
157
179
|
* @example
|
|
158
180
|
* ```typescript
|
|
159
181
|
* return createErrorResult(err);
|
|
@@ -172,6 +194,10 @@ export function createErrorResult(error: unknown): { success: false; error: stri
|
|
|
172
194
|
*
|
|
173
195
|
* @returns Success result object
|
|
174
196
|
*
|
|
197
|
+
* @remarks
|
|
198
|
+
* Pairs with {@link createErrorResult} and {@link isErrorResult} to provide
|
|
199
|
+
* a consistent result-or-error pattern without exceptions.
|
|
200
|
+
*
|
|
175
201
|
* @example
|
|
176
202
|
* ```typescript
|
|
177
203
|
* return createSuccessResult();
|
|
@@ -188,6 +214,10 @@ export function createSuccessResult(): { success: true } {
|
|
|
188
214
|
* @param result - The result to check
|
|
189
215
|
* @returns True if the result is an error result
|
|
190
216
|
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* Narrows the result type so that `result.error` is guaranteed to be a string
|
|
219
|
+
* after the guard returns `true`.
|
|
220
|
+
*
|
|
191
221
|
* @example
|
|
192
222
|
* ```typescript
|
|
193
223
|
* const result = await someOperation();
|
package/src/install.ts
CHANGED
|
@@ -16,13 +16,13 @@ export interface AdapterInstallProvider {
|
|
|
16
16
|
export interface InstallOptions {
|
|
17
17
|
projectDir: string;
|
|
18
18
|
global?: boolean;
|
|
19
|
-
mcpServerPath?: string;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
export interface InstallResult {
|
|
23
22
|
success: boolean;
|
|
24
23
|
installedAt: string;
|
|
25
24
|
instructionFileUpdated: boolean;
|
|
25
|
+
/** Always false. CLI dispatch only. */
|
|
26
26
|
mcpRegistered: boolean;
|
|
27
27
|
details?: Record<string, unknown>;
|
|
28
28
|
}
|
package/src/lafs.ts
CHANGED
|
@@ -26,36 +26,57 @@ export type LAFSErrorCategory =
|
|
|
26
26
|
|
|
27
27
|
/** LAFS error object. */
|
|
28
28
|
export interface LAFSError {
|
|
29
|
+
/** Stable error code (numeric HTTP status or string identifier). */
|
|
29
30
|
code: number | string;
|
|
31
|
+
/** High-level error classification category. */
|
|
30
32
|
category: LAFSErrorCategory;
|
|
33
|
+
/** Human-readable error description. */
|
|
31
34
|
message: string;
|
|
35
|
+
/**
|
|
36
|
+
* Suggested fix or recovery action for the caller.
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue undefined
|
|
39
|
+
*/
|
|
32
40
|
fix?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Arbitrary key-value pairs with additional error context.
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue undefined
|
|
45
|
+
*/
|
|
33
46
|
details?: Record<string, unknown>;
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
/** LAFS warning. */
|
|
37
50
|
export interface Warning {
|
|
51
|
+
/** Machine-readable warning code. */
|
|
38
52
|
code: string;
|
|
53
|
+
/** Human-readable warning description. */
|
|
39
54
|
message: string;
|
|
40
55
|
}
|
|
41
56
|
|
|
42
57
|
/** LAFS transport metadata. */
|
|
43
|
-
export type LAFSTransport = '
|
|
58
|
+
export type LAFSTransport = 'cli' | 'http' | 'sdk';
|
|
44
59
|
|
|
45
60
|
/** MVI (Minimal Viable Information) level. */
|
|
46
61
|
export type MVILevel = 'minimal' | 'standard' | 'full';
|
|
47
62
|
|
|
48
63
|
/** LAFS page — no pagination. */
|
|
49
64
|
export interface LAFSPageNone {
|
|
65
|
+
/** Discriminant indicating no pagination is applied. */
|
|
50
66
|
strategy: 'none';
|
|
51
67
|
}
|
|
52
68
|
|
|
53
69
|
/** LAFS page — offset-based pagination. */
|
|
54
70
|
export interface LAFSPageOffset {
|
|
71
|
+
/** Discriminant identifying offset-based pagination. */
|
|
55
72
|
strategy: 'offset';
|
|
73
|
+
/** Zero-based index of the first item in this page. */
|
|
56
74
|
offset: number;
|
|
75
|
+
/** Maximum number of items per page. */
|
|
57
76
|
limit: number;
|
|
77
|
+
/** Total number of items across all pages. */
|
|
58
78
|
total: number;
|
|
79
|
+
/** Whether additional pages exist beyond the current one. */
|
|
59
80
|
hasMore: boolean;
|
|
60
81
|
}
|
|
61
82
|
|
|
@@ -64,31 +85,69 @@ export type LAFSPage = LAFSPageNone | LAFSPageOffset;
|
|
|
64
85
|
|
|
65
86
|
/** LAFS metadata block. */
|
|
66
87
|
export interface LAFSMeta {
|
|
88
|
+
/** Transport protocol used for this envelope. */
|
|
67
89
|
transport: LAFSTransport;
|
|
90
|
+
/** Minimum Viable Information level controlling verbosity. */
|
|
68
91
|
mvi: MVILevel;
|
|
92
|
+
/**
|
|
93
|
+
* Pagination metadata when the result is a paginated collection.
|
|
94
|
+
*
|
|
95
|
+
* @defaultValue undefined
|
|
96
|
+
*/
|
|
69
97
|
page?: LAFSPage;
|
|
98
|
+
/**
|
|
99
|
+
* Non-fatal warnings to surface to the consuming agent.
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue undefined
|
|
102
|
+
*/
|
|
70
103
|
warnings?: Warning[];
|
|
104
|
+
/**
|
|
105
|
+
* Operation duration in milliseconds.
|
|
106
|
+
*
|
|
107
|
+
* @defaultValue undefined
|
|
108
|
+
*/
|
|
71
109
|
durationMs?: number;
|
|
72
110
|
}
|
|
73
111
|
|
|
74
112
|
/** LAFS envelope (canonical protocol type). */
|
|
75
113
|
export interface LAFSEnvelope<T = unknown> {
|
|
114
|
+
/** Whether the operation completed successfully. */
|
|
76
115
|
success: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Operation result payload on success.
|
|
118
|
+
*
|
|
119
|
+
* @defaultValue undefined
|
|
120
|
+
*/
|
|
77
121
|
data?: T;
|
|
122
|
+
/**
|
|
123
|
+
* Structured error payload on failure.
|
|
124
|
+
*
|
|
125
|
+
* @defaultValue undefined
|
|
126
|
+
*/
|
|
78
127
|
error?: LAFSError;
|
|
128
|
+
/**
|
|
129
|
+
* Protocol and transport metadata.
|
|
130
|
+
*
|
|
131
|
+
* @defaultValue undefined
|
|
132
|
+
*/
|
|
79
133
|
_meta?: LAFSMeta;
|
|
80
134
|
}
|
|
81
135
|
|
|
82
136
|
/** Flag input for conformance checks. */
|
|
83
137
|
export interface FlagInput {
|
|
138
|
+
/** Name of the flag being checked. */
|
|
84
139
|
flag: string;
|
|
140
|
+
/** Value of the flag to validate. */
|
|
85
141
|
value: unknown;
|
|
86
142
|
}
|
|
87
143
|
|
|
88
144
|
/** Conformance report. */
|
|
89
145
|
export interface ConformanceReport {
|
|
146
|
+
/** Whether all conformance checks passed. */
|
|
90
147
|
valid: boolean;
|
|
148
|
+
/** List of conformance violation descriptions. */
|
|
91
149
|
violations: string[];
|
|
150
|
+
/** List of non-fatal warning descriptions. */
|
|
92
151
|
warnings: string[];
|
|
93
152
|
}
|
|
94
153
|
|
|
@@ -98,17 +157,41 @@ export interface ConformanceReport {
|
|
|
98
157
|
|
|
99
158
|
/** Actionable alternative the caller can try. */
|
|
100
159
|
export interface LafsAlternative {
|
|
160
|
+
/** Description of the alternative action. */
|
|
101
161
|
action: string;
|
|
162
|
+
/** CLI command the caller can run instead. */
|
|
102
163
|
command: string;
|
|
103
164
|
}
|
|
104
165
|
|
|
105
|
-
/** LAFS error detail shared between CLI and
|
|
166
|
+
/** LAFS error detail shared between CLI and gateway. */
|
|
106
167
|
export interface LafsErrorDetail {
|
|
168
|
+
/** Stable error code (numeric HTTP status or string identifier). */
|
|
107
169
|
code: number | string;
|
|
170
|
+
/**
|
|
171
|
+
* Optional human-readable error name (e.g. `"NOT_FOUND"`).
|
|
172
|
+
*
|
|
173
|
+
* @defaultValue undefined
|
|
174
|
+
*/
|
|
108
175
|
name?: string;
|
|
176
|
+
/** Human-readable error description. */
|
|
109
177
|
message: string;
|
|
178
|
+
/**
|
|
179
|
+
* Suggested fix or recovery action for the caller.
|
|
180
|
+
*
|
|
181
|
+
* @defaultValue undefined
|
|
182
|
+
*/
|
|
110
183
|
fix?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Alternative commands the caller can try.
|
|
186
|
+
*
|
|
187
|
+
* @defaultValue undefined
|
|
188
|
+
*/
|
|
111
189
|
alternatives?: LafsAlternative[];
|
|
190
|
+
/**
|
|
191
|
+
* Arbitrary key-value pairs with additional error context.
|
|
192
|
+
*
|
|
193
|
+
* @defaultValue undefined
|
|
194
|
+
*/
|
|
112
195
|
details?: Record<string, unknown>;
|
|
113
196
|
}
|
|
114
197
|
|
|
@@ -118,15 +201,29 @@ export interface LafsErrorDetail {
|
|
|
118
201
|
|
|
119
202
|
/** LAFS success envelope (CLI). */
|
|
120
203
|
export interface LafsSuccess<T = unknown> {
|
|
204
|
+
/** Discriminant: always `true` for success envelopes. */
|
|
121
205
|
success: true;
|
|
206
|
+
/** Operation result payload. */
|
|
122
207
|
data: T;
|
|
208
|
+
/**
|
|
209
|
+
* Optional human-readable summary of the operation outcome.
|
|
210
|
+
*
|
|
211
|
+
* @defaultValue undefined
|
|
212
|
+
*/
|
|
123
213
|
message?: string;
|
|
214
|
+
/**
|
|
215
|
+
* When `true`, the operation was a no-op (data is unchanged).
|
|
216
|
+
*
|
|
217
|
+
* @defaultValue undefined
|
|
218
|
+
*/
|
|
124
219
|
noChange?: boolean;
|
|
125
220
|
}
|
|
126
221
|
|
|
127
222
|
/** LAFS error envelope (CLI). */
|
|
128
223
|
export interface LafsError {
|
|
224
|
+
/** Discriminant: always `false` for error envelopes. */
|
|
129
225
|
success: false;
|
|
226
|
+
/** Structured error detail with code, message, and fix guidance. */
|
|
130
227
|
error: LafsErrorDetail;
|
|
131
228
|
}
|
|
132
229
|
|
|
@@ -134,43 +231,48 @@ export interface LafsError {
|
|
|
134
231
|
export type LafsEnvelope<T = unknown> = LafsSuccess<T> | LafsError;
|
|
135
232
|
|
|
136
233
|
// ---------------------------------------------------------------------------
|
|
137
|
-
//
|
|
234
|
+
// Gateway envelope extension (extends LAFSMeta)
|
|
138
235
|
// ---------------------------------------------------------------------------
|
|
139
236
|
|
|
140
237
|
/**
|
|
141
|
-
* Metadata attached to every
|
|
238
|
+
* Metadata attached to every gateway response.
|
|
142
239
|
* Extends the canonical LAFSMeta with CLEO gateway-specific fields.
|
|
143
240
|
*
|
|
144
241
|
* @task T4655
|
|
145
242
|
*/
|
|
146
243
|
export interface GatewayMeta extends LAFSMeta {
|
|
244
|
+
/** Gateway identifier that processed this request. */
|
|
147
245
|
gateway: string;
|
|
246
|
+
/** CLEO domain that handled the operation (e.g. `"tasks"`, `"session"`). */
|
|
148
247
|
domain: string;
|
|
248
|
+
/** Operation duration in milliseconds. */
|
|
149
249
|
duration_ms: number;
|
|
150
250
|
}
|
|
151
251
|
|
|
152
|
-
/**
|
|
252
|
+
/** Gateway success envelope (extends CLI base with _meta). */
|
|
153
253
|
export interface GatewaySuccess<T = unknown> extends LafsSuccess<T> {
|
|
254
|
+
/** Gateway-specific metadata including domain and timing. */
|
|
154
255
|
_meta: GatewayMeta;
|
|
155
256
|
}
|
|
156
257
|
|
|
157
|
-
/**
|
|
258
|
+
/** Gateway error envelope (extends CLI base with _meta). */
|
|
158
259
|
export interface GatewayError extends LafsError {
|
|
260
|
+
/** Gateway-specific metadata including domain and timing. */
|
|
159
261
|
_meta: GatewayMeta;
|
|
160
262
|
}
|
|
161
263
|
|
|
162
|
-
/**
|
|
264
|
+
/** Gateway envelope union type. */
|
|
163
265
|
export type GatewayEnvelope<T = unknown> = GatewaySuccess<T> | GatewayError;
|
|
164
266
|
|
|
165
267
|
// ---------------------------------------------------------------------------
|
|
166
|
-
// Unified envelope (covers both CLI and
|
|
268
|
+
// Unified envelope (covers both CLI and Gateway)
|
|
167
269
|
// ---------------------------------------------------------------------------
|
|
168
270
|
|
|
169
271
|
/**
|
|
170
272
|
* Unified CLEO response envelope.
|
|
171
273
|
*
|
|
172
|
-
* Every CLEO response (CLI or
|
|
173
|
-
* the _meta field; CLI responses do not.
|
|
274
|
+
* Every CLEO response (CLI or Gateway) is a CleoResponse. Gateway responses
|
|
275
|
+
* include the _meta field; CLI responses do not.
|
|
174
276
|
*/
|
|
175
277
|
export type CleoResponse<T = unknown> = LafsEnvelope<T> | GatewayEnvelope<T>;
|
|
176
278
|
|
|
@@ -178,17 +280,71 @@ export type CleoResponse<T = unknown> = LafsEnvelope<T> | GatewayEnvelope<T>;
|
|
|
178
280
|
// Type guards
|
|
179
281
|
// ---------------------------------------------------------------------------
|
|
180
282
|
|
|
181
|
-
/**
|
|
283
|
+
/**
|
|
284
|
+
* Type guard for success responses.
|
|
285
|
+
*
|
|
286
|
+
* @typeParam T - The data payload type of the envelope.
|
|
287
|
+
* @param envelope - The envelope to check.
|
|
288
|
+
* @returns `true` if the envelope represents a successful operation.
|
|
289
|
+
*
|
|
290
|
+
* @remarks
|
|
291
|
+
* Narrows a {@link LafsEnvelope} to {@link LafsSuccess} so that `envelope.data`
|
|
292
|
+
* is accessible without additional type assertions.
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```ts
|
|
296
|
+
* const result: LafsEnvelope<Task[]> = await fetchTasks();
|
|
297
|
+
* if (isLafsSuccess(result)) {
|
|
298
|
+
* console.log(result.data); // Task[]
|
|
299
|
+
* }
|
|
300
|
+
* ```
|
|
301
|
+
*/
|
|
182
302
|
export function isLafsSuccess<T>(envelope: LafsEnvelope<T>): envelope is LafsSuccess<T> {
|
|
183
303
|
return envelope.success === true;
|
|
184
304
|
}
|
|
185
305
|
|
|
186
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* Type guard for error responses.
|
|
308
|
+
*
|
|
309
|
+
* @typeParam T - The data payload type of the envelope.
|
|
310
|
+
* @param envelope - The envelope to check.
|
|
311
|
+
* @returns `true` if the envelope represents a failed operation.
|
|
312
|
+
*
|
|
313
|
+
* @remarks
|
|
314
|
+
* Narrows a {@link LafsEnvelope} to {@link LafsError} so that `envelope.error`
|
|
315
|
+
* is accessible without additional type assertions.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* const result: LafsEnvelope<Task[]> = await fetchTasks();
|
|
320
|
+
* if (isLafsError(result)) {
|
|
321
|
+
* console.error(result.error.message);
|
|
322
|
+
* }
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
187
325
|
export function isLafsError<T>(envelope: LafsEnvelope<T>): envelope is LafsError {
|
|
188
326
|
return envelope.success === false;
|
|
189
327
|
}
|
|
190
328
|
|
|
191
|
-
/**
|
|
329
|
+
/**
|
|
330
|
+
* Type guard for gateway responses (has _meta).
|
|
331
|
+
*
|
|
332
|
+
* @typeParam T - The data payload type of the envelope.
|
|
333
|
+
* @param envelope - The response to check.
|
|
334
|
+
* @returns `true` if the response includes gateway metadata.
|
|
335
|
+
*
|
|
336
|
+
* @remarks
|
|
337
|
+
* Distinguishes gateway responses from plain CLI responses by checking for the
|
|
338
|
+
* presence of the `_meta` field, which carries gateway-specific routing and timing data.
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* const response: CleoResponse<Task> = await handleRequest();
|
|
343
|
+
* if (isGatewayEnvelope(response)) {
|
|
344
|
+
* console.log(response._meta.gateway);
|
|
345
|
+
* }
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
192
348
|
export function isGatewayEnvelope<T>(envelope: CleoResponse<T>): envelope is GatewayEnvelope<T> {
|
|
193
349
|
return '_meta' in envelope && envelope._meta !== undefined;
|
|
194
350
|
}
|
package/src/memory.ts
CHANGED
|
@@ -6,52 +6,129 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
export interface MemoryBridgeConfig {
|
|
9
|
+
/** Maximum number of recent observations to include in the bridge. */
|
|
9
10
|
maxObservations: number;
|
|
11
|
+
/** Maximum number of key learnings to include. */
|
|
10
12
|
maxLearnings: number;
|
|
13
|
+
/** Maximum number of patterns (follow/avoid) to include. */
|
|
11
14
|
maxPatterns: number;
|
|
15
|
+
/** Maximum number of recent decisions to include. */
|
|
12
16
|
maxDecisions: number;
|
|
17
|
+
/** Whether to include the last session handoff summary. */
|
|
13
18
|
includeHandoff: boolean;
|
|
19
|
+
/** Whether to include anti-patterns alongside follow-patterns. */
|
|
14
20
|
includeAntiPatterns: boolean;
|
|
15
21
|
}
|
|
16
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Structured content of the `.cleo/memory-bridge.md` file.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* The memory bridge is auto-generated from brain.db and provides cross-session
|
|
28
|
+
* memory context to agents. It is refreshed on session end, task completion,
|
|
29
|
+
* and explicit `cleo refresh-memory` invocations.
|
|
30
|
+
*/
|
|
17
31
|
export interface MemoryBridgeContent {
|
|
32
|
+
/** ISO 8601 timestamp of when this bridge content was generated. */
|
|
18
33
|
generatedAt: string;
|
|
34
|
+
/**
|
|
35
|
+
* Summary of the most recent session.
|
|
36
|
+
*
|
|
37
|
+
* @defaultValue undefined
|
|
38
|
+
*/
|
|
19
39
|
lastSession?: SessionSummary;
|
|
40
|
+
/** Key learnings extracted from brain.db observations. */
|
|
20
41
|
learnings: BridgeLearning[];
|
|
42
|
+
/** Patterns to follow, identified from recurring successful outcomes. */
|
|
21
43
|
patterns: BridgePattern[];
|
|
44
|
+
/** Anti-patterns to avoid, identified from recurring failures. */
|
|
22
45
|
antiPatterns: BridgePattern[];
|
|
46
|
+
/** Recent decisions made during sessions. */
|
|
23
47
|
decisions: BridgeDecision[];
|
|
48
|
+
/** Most recent observations from brain.db. */
|
|
24
49
|
recentObservations: BridgeObservation[];
|
|
25
50
|
}
|
|
26
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Summary of a completed session for the memory bridge.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Captures the essential outcomes of a session so subsequent sessions
|
|
57
|
+
* can pick up where the previous one left off.
|
|
58
|
+
*/
|
|
27
59
|
export interface SessionSummary {
|
|
60
|
+
/** Unique identifier of the summarized session. */
|
|
28
61
|
sessionId: string;
|
|
62
|
+
/** ISO 8601 date when the session occurred. */
|
|
29
63
|
date: string;
|
|
64
|
+
/** Task IDs that were completed during this session. */
|
|
30
65
|
tasksCompleted: string[];
|
|
66
|
+
/** Key decisions made during this session. */
|
|
31
67
|
decisions: string[];
|
|
68
|
+
/** Suggested next actions for the following session. */
|
|
32
69
|
nextSuggested: string[];
|
|
33
70
|
}
|
|
34
71
|
|
|
72
|
+
/**
|
|
73
|
+
* A key learning extracted from brain.db for the memory bridge.
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* Learnings are observations that have been validated or reinforced across
|
|
77
|
+
* multiple sessions, with a confidence score reflecting their reliability.
|
|
78
|
+
*/
|
|
35
79
|
export interface BridgeLearning {
|
|
80
|
+
/** Brain.db entry identifier (e.g. `"L-abc123"`). */
|
|
36
81
|
id: string;
|
|
82
|
+
/** Human-readable learning text. */
|
|
37
83
|
text: string;
|
|
84
|
+
/** Confidence score from 0.0 to 1.0. */
|
|
38
85
|
confidence: number;
|
|
39
86
|
}
|
|
40
87
|
|
|
88
|
+
/**
|
|
89
|
+
* A recurring pattern identified in brain.db entries.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* Patterns are classified as either `"follow"` (positive patterns to repeat)
|
|
93
|
+
* or `"avoid"` (anti-patterns to prevent).
|
|
94
|
+
*/
|
|
41
95
|
export interface BridgePattern {
|
|
96
|
+
/** Brain.db entry identifier (e.g. `"P-abc123"`). */
|
|
42
97
|
id: string;
|
|
98
|
+
/** Human-readable pattern description. */
|
|
43
99
|
text: string;
|
|
100
|
+
/** Whether this is a pattern to follow or avoid. */
|
|
44
101
|
type: 'follow' | 'avoid';
|
|
45
102
|
}
|
|
46
103
|
|
|
104
|
+
/**
|
|
105
|
+
* A decision recorded in brain.db for the memory bridge.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* Decisions are high-signal observations that capture architectural or
|
|
109
|
+
* process choices made during sessions.
|
|
110
|
+
*/
|
|
47
111
|
export interface BridgeDecision {
|
|
112
|
+
/** Brain.db entry identifier (e.g. `"D-abc123"`). */
|
|
48
113
|
id: string;
|
|
114
|
+
/** Short title summarizing the decision. */
|
|
49
115
|
title: string;
|
|
116
|
+
/** ISO 8601 date when the decision was made. */
|
|
50
117
|
date: string;
|
|
51
118
|
}
|
|
52
119
|
|
|
120
|
+
/**
|
|
121
|
+
* A recent observation from brain.db for the memory bridge.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* Observations are the raw input to the brain memory system. Only the most
|
|
125
|
+
* recent ones are included in the bridge to keep token cost low.
|
|
126
|
+
*/
|
|
53
127
|
export interface BridgeObservation {
|
|
128
|
+
/** Brain.db entry identifier (e.g. `"O-abc123"`). */
|
|
54
129
|
id: string;
|
|
130
|
+
/** ISO 8601 date when the observation was recorded. */
|
|
55
131
|
date: string;
|
|
132
|
+
/** Truncated summary of the observation content. */
|
|
56
133
|
summary: string;
|
|
57
134
|
}
|
package/src/operations/issues.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* Common issue types
|
|
12
12
|
*/
|
|
13
13
|
export type IssueSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
14
|
-
export type IssueArea = 'cli' | '
|
|
14
|
+
export type IssueArea = 'cli' | 'dispatch' | 'docs' | 'tests' | 'other';
|
|
15
15
|
export type IssueType = 'bug' | 'feature' | 'help';
|
|
16
16
|
|
|
17
17
|
export interface Diagnostics {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SYNC: Canonical type definitions live in the CLI package at:
|
|
8
8
|
* src/types/session.ts (Session, SessionScope, etc.)
|
|
9
|
-
* These
|
|
9
|
+
* These operation types are the API contract (wire format).
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
/**
|
package/src/operations/tasks.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SYNC: Canonical type definitions live in the CLI package at:
|
|
8
8
|
* src/types/task.ts (TaskStatus, TaskPriority, Task, etc.)
|
|
9
|
-
* These
|
|
9
|
+
* These operation types are the API contract (wire format).
|
|
10
10
|
* Internal domain types must stay aligned with CLI definitions.
|
|
11
11
|
*/
|
|
12
12
|
|