@vreko/cli 3.0.1
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/LICENSE +201 -0
- package/README.md +45 -0
- package/dist/CeremonyView-LQS7FTMK.js +134 -0
- package/dist/CeremonyView-LQS7FTMK.js.map +1 -0
- package/dist/InitApp-7K5DTYSW.js +1479 -0
- package/dist/InitApp-7K5DTYSW.js.map +1 -0
- package/dist/SkippedTestDetector-PJSKSOZR.js +7 -0
- package/dist/SkippedTestDetector-PJSKSOZR.js.map +1 -0
- package/dist/TuiApp-FX23XQBK.js +8 -0
- package/dist/TuiApp-FX23XQBK.js.map +1 -0
- package/dist/analysis-ABEO6RTN.js +8 -0
- package/dist/analysis-ABEO6RTN.js.map +1 -0
- package/dist/auth-XNBEBNPY.js +7669 -0
- package/dist/auth-XNBEBNPY.js.map +1 -0
- package/dist/ceremony-M7CXVBVA.js +45 -0
- package/dist/ceremony-M7CXVBVA.js.map +1 -0
- package/dist/chunk-A3QSZJPD.js +3147 -0
- package/dist/chunk-A3QSZJPD.js.map +1 -0
- package/dist/chunk-ASGZ5B6C.js +3969 -0
- package/dist/chunk-ASGZ5B6C.js.map +1 -0
- package/dist/chunk-DMXC2JTC.js +58 -0
- package/dist/chunk-DMXC2JTC.js.map +1 -0
- package/dist/chunk-EEBSK2IH.js +161 -0
- package/dist/chunk-EEBSK2IH.js.map +1 -0
- package/dist/chunk-EWOJGXRX.js +22 -0
- package/dist/chunk-EWOJGXRX.js.map +1 -0
- package/dist/chunk-F7GEJLP7.js +2389 -0
- package/dist/chunk-F7GEJLP7.js.map +1 -0
- package/dist/chunk-GOYL3F4T.js +605 -0
- package/dist/chunk-GOYL3F4T.js.map +1 -0
- package/dist/chunk-GRMRYWYS.js +17 -0
- package/dist/chunk-GRMRYWYS.js.map +1 -0
- package/dist/chunk-GSUGROXB.js +1951 -0
- package/dist/chunk-GSUGROXB.js.map +1 -0
- package/dist/chunk-H7773ONB.js +50 -0
- package/dist/chunk-H7773ONB.js.map +1 -0
- package/dist/chunk-HFQHU5LC.js +445 -0
- package/dist/chunk-HFQHU5LC.js.map +1 -0
- package/dist/chunk-IVHUBLJD.js +318 -0
- package/dist/chunk-IVHUBLJD.js.map +1 -0
- package/dist/chunk-KJWKY4L4.js +14 -0
- package/dist/chunk-KJWKY4L4.js.map +1 -0
- package/dist/chunk-MJVY2XUN.js +1793 -0
- package/dist/chunk-MJVY2XUN.js.map +1 -0
- package/dist/chunk-QWZVCJII.js +1797 -0
- package/dist/chunk-QWZVCJII.js.map +1 -0
- package/dist/chunk-VTSNRV3V.js +3237 -0
- package/dist/chunk-VTSNRV3V.js.map +1 -0
- package/dist/chunk-W5B4GTXR.js +1466 -0
- package/dist/chunk-W5B4GTXR.js.map +1 -0
- package/dist/chunk-WZEZLVOW.js +4995 -0
- package/dist/chunk-WZEZLVOW.js.map +1 -0
- package/dist/chunk-YPTTIXKC.js +199 -0
- package/dist/chunk-YPTTIXKC.js.map +1 -0
- package/dist/chunk-Z55UGM6X.js +6360 -0
- package/dist/chunk-Z55UGM6X.js.map +1 -0
- package/dist/chunk-ZIIRQODJ.js +110 -0
- package/dist/chunk-ZIIRQODJ.js.map +1 -0
- package/dist/chunk-ZSUQ4FMB.js +77 -0
- package/dist/chunk-ZSUQ4FMB.js.map +1 -0
- package/dist/client-JMTSZS3V.js +10 -0
- package/dist/client-JMTSZS3V.js.map +1 -0
- package/dist/deprecated-snap.js +19 -0
- package/dist/deprecated-snap.js.map +1 -0
- package/dist/dist-2KWBZFLA.js +14 -0
- package/dist/dist-2KWBZFLA.js.map +1 -0
- package/dist/dist-5ZYKNNU3.js +7 -0
- package/dist/dist-5ZYKNNU3.js.map +1 -0
- package/dist/dist-CP3RFHPI.js +11 -0
- package/dist/dist-CP3RFHPI.js.map +1 -0
- package/dist/gecko-53ITAGG6.js +56 -0
- package/dist/gecko-53ITAGG6.js.map +1 -0
- package/dist/guards-QAFC64NO.js +7 -0
- package/dist/guards-QAFC64NO.js.map +1 -0
- package/dist/index.js +57785 -0
- package/dist/index.js.map +1 -0
- package/dist/init-command-246JIVXM.js +7 -0
- package/dist/init-command-246JIVXM.js.map +1 -0
- package/dist/init-core-KAI7LCXZ.js +12 -0
- package/dist/init-core-KAI7LCXZ.js.map +1 -0
- package/dist/init-scan-RZNYDTUV.js +1919 -0
- package/dist/init-scan-RZNYDTUV.js.map +1 -0
- package/dist/local-service-adapter-6KNN6WQL.js +8 -0
- package/dist/local-service-adapter-6KNN6WQL.js.map +1 -0
- package/dist/secure-credentials-JXWAQLS2.js +306 -0
- package/dist/secure-credentials-JXWAQLS2.js.map +1 -0
- package/dist/tui-TPJPUS2R.js +111 -0
- package/dist/tui-TPJPUS2R.js.map +1 -0
- package/dist/vreko-dir-O3RLG7PI.js +8 -0
- package/dist/vreko-dir-O3RLG7PI.js.map +1 -0
- package/package.json +132 -0
- package/scripts/check-banned-words.ts +152 -0
- package/scripts/hooks/posttooluse-file-notify.sh +108 -0
- package/scripts/hooks/pretooluse-fragile-guard.sh +82 -0
- package/scripts/post-install-notice.js +24 -0
- package/scripts/postinstall.mjs +84 -0
- package/scripts/preuninstall.mjs +34 -0
- package/scripts/verify-jsx-transform.mjs +55 -0
|
@@ -0,0 +1,3237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { __name } from './chunk-EWOJGXRX.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
process.env.VREKO_CLI='true';process.env.NODE_NO_WARNINGS='1';
|
|
6
|
+
var JsonRpcRequestSchema = z.object({
|
|
7
|
+
jsonrpc: z.literal("2.0"),
|
|
8
|
+
id: z.union([
|
|
9
|
+
z.string(),
|
|
10
|
+
z.number()
|
|
11
|
+
]),
|
|
12
|
+
method: z.string(),
|
|
13
|
+
params: z.unknown().optional()
|
|
14
|
+
});
|
|
15
|
+
var JsonRpcErrorSchema = z.object({
|
|
16
|
+
code: z.number(),
|
|
17
|
+
message: z.string(),
|
|
18
|
+
data: z.unknown().optional()
|
|
19
|
+
});
|
|
20
|
+
var JsonRpcSuccessResponseSchema = z.object({
|
|
21
|
+
jsonrpc: z.literal("2.0"),
|
|
22
|
+
id: z.union([
|
|
23
|
+
z.string(),
|
|
24
|
+
z.number()
|
|
25
|
+
]).optional(),
|
|
26
|
+
result: z.unknown()
|
|
27
|
+
});
|
|
28
|
+
var JsonRpcErrorResponseSchema = z.object({
|
|
29
|
+
jsonrpc: z.literal("2.0"),
|
|
30
|
+
id: z.union([
|
|
31
|
+
z.string(),
|
|
32
|
+
z.number()
|
|
33
|
+
]).optional(),
|
|
34
|
+
error: JsonRpcErrorSchema
|
|
35
|
+
});
|
|
36
|
+
var JsonRpcResponseSchema = z.union([
|
|
37
|
+
JsonRpcSuccessResponseSchema,
|
|
38
|
+
JsonRpcErrorResponseSchema
|
|
39
|
+
]);
|
|
40
|
+
var JsonRpcNotificationSchema = z.object({
|
|
41
|
+
jsonrpc: z.literal("2.0"),
|
|
42
|
+
method: z.string(),
|
|
43
|
+
params: z.unknown().optional()
|
|
44
|
+
});
|
|
45
|
+
var JsonRpcMessageSchema = z.union([
|
|
46
|
+
JsonRpcRequestSchema,
|
|
47
|
+
JsonRpcResponseSchema,
|
|
48
|
+
JsonRpcNotificationSchema
|
|
49
|
+
]);
|
|
50
|
+
var ProtocolErrorCode;
|
|
51
|
+
(function(ProtocolErrorCode2) {
|
|
52
|
+
ProtocolErrorCode2[ProtocolErrorCode2["ParseError"] = -32700] = "ParseError";
|
|
53
|
+
ProtocolErrorCode2[ProtocolErrorCode2["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
54
|
+
ProtocolErrorCode2[ProtocolErrorCode2["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
55
|
+
ProtocolErrorCode2[ProtocolErrorCode2["InvalidParams"] = -32602] = "InvalidParams";
|
|
56
|
+
ProtocolErrorCode2[ProtocolErrorCode2["InternalError"] = -32603] = "InternalError";
|
|
57
|
+
ProtocolErrorCode2[ProtocolErrorCode2["ServerError"] = -32e3] = "ServerError";
|
|
58
|
+
ProtocolErrorCode2[ProtocolErrorCode2["NotInitialized"] = -32001] = "NotInitialized";
|
|
59
|
+
ProtocolErrorCode2[ProtocolErrorCode2["AlreadyInitialized"] = -32002] = "AlreadyInitialized";
|
|
60
|
+
ProtocolErrorCode2[ProtocolErrorCode2["ShuttingDown"] = -32003] = "ShuttingDown";
|
|
61
|
+
ProtocolErrorCode2[ProtocolErrorCode2["NotAuthenticated"] = 1e3] = "NotAuthenticated";
|
|
62
|
+
ProtocolErrorCode2[ProtocolErrorCode2["TierRequired"] = 1001] = "TierRequired";
|
|
63
|
+
ProtocolErrorCode2[ProtocolErrorCode2["ApiUnavailable"] = 1002] = "ApiUnavailable";
|
|
64
|
+
ProtocolErrorCode2[ProtocolErrorCode2["QuotaExceeded"] = 1003] = "QuotaExceeded";
|
|
65
|
+
ProtocolErrorCode2[ProtocolErrorCode2["WorkspaceNotFound"] = 1500] = "WorkspaceNotFound";
|
|
66
|
+
ProtocolErrorCode2[ProtocolErrorCode2["WorkspaceAlreadyExists"] = 1501] = "WorkspaceAlreadyExists";
|
|
67
|
+
ProtocolErrorCode2[ProtocolErrorCode2["SessionNotFound"] = 2e3] = "SessionNotFound";
|
|
68
|
+
ProtocolErrorCode2[ProtocolErrorCode2["SessionEnded"] = 2001] = "SessionEnded";
|
|
69
|
+
ProtocolErrorCode2[ProtocolErrorCode2["SnapshotNotFound"] = 3e3] = "SnapshotNotFound";
|
|
70
|
+
ProtocolErrorCode2[ProtocolErrorCode2["ContentHashMismatch"] = 3001] = "ContentHashMismatch";
|
|
71
|
+
ProtocolErrorCode2[ProtocolErrorCode2["RestoreFailed"] = 3002] = "RestoreFailed";
|
|
72
|
+
ProtocolErrorCode2[ProtocolErrorCode2["FileNotFound"] = 4e3] = "FileNotFound";
|
|
73
|
+
ProtocolErrorCode2[ProtocolErrorCode2["FileAccessDenied"] = 4001] = "FileAccessDenied";
|
|
74
|
+
ProtocolErrorCode2[ProtocolErrorCode2["InvalidPath"] = 4002] = "InvalidPath";
|
|
75
|
+
ProtocolErrorCode2[ProtocolErrorCode2["LearningNotFound"] = 5e3] = "LearningNotFound";
|
|
76
|
+
ProtocolErrorCode2[ProtocolErrorCode2["LearningEvaluationFailed"] = 5001] = "LearningEvaluationFailed";
|
|
77
|
+
ProtocolErrorCode2[ProtocolErrorCode2["SyncUnavailable"] = 6e3] = "SyncUnavailable";
|
|
78
|
+
ProtocolErrorCode2[ProtocolErrorCode2["SyncAuthRequired"] = 6001] = "SyncAuthRequired";
|
|
79
|
+
ProtocolErrorCode2[ProtocolErrorCode2["ValidationTimeout"] = 7e3] = "ValidationTimeout";
|
|
80
|
+
ProtocolErrorCode2[ProtocolErrorCode2["IntelligenceUnavailable"] = 8e3] = "IntelligenceUnavailable";
|
|
81
|
+
ProtocolErrorCode2[ProtocolErrorCode2["PatternNotFound"] = 8001] = "PatternNotFound";
|
|
82
|
+
})(ProtocolErrorCode || (ProtocolErrorCode = {}));
|
|
83
|
+
({
|
|
84
|
+
[ProtocolErrorCode.ParseError]: "Invalid JSON",
|
|
85
|
+
[ProtocolErrorCode.InvalidRequest]: "Invalid JSON-RPC request",
|
|
86
|
+
[ProtocolErrorCode.MethodNotFound]: "Method does not exist",
|
|
87
|
+
[ProtocolErrorCode.InvalidParams]: "Invalid method parameters",
|
|
88
|
+
[ProtocolErrorCode.InternalError]: "Internal service error",
|
|
89
|
+
[ProtocolErrorCode.ServerError]: "Server error",
|
|
90
|
+
[ProtocolErrorCode.NotInitialized]: "Client must call initialize before other methods",
|
|
91
|
+
[ProtocolErrorCode.AlreadyInitialized]: "Client has already called initialize",
|
|
92
|
+
[ProtocolErrorCode.ShuttingDown]: "Service is shutting down",
|
|
93
|
+
[ProtocolErrorCode.NotAuthenticated]: "Authentication required for this method",
|
|
94
|
+
[ProtocolErrorCode.TierRequired]: "PRO tier required for this method",
|
|
95
|
+
[ProtocolErrorCode.ApiUnavailable]: "Cannot reach api.vreko.dev",
|
|
96
|
+
[ProtocolErrorCode.QuotaExceeded]: "Storage or API quota exceeded",
|
|
97
|
+
[ProtocolErrorCode.SessionNotFound]: "Session does not exist",
|
|
98
|
+
[ProtocolErrorCode.SessionEnded]: "Session has already ended",
|
|
99
|
+
[ProtocolErrorCode.SnapshotNotFound]: "Snapshot does not exist",
|
|
100
|
+
[ProtocolErrorCode.ContentHashMismatch]: "Content integrity check failed",
|
|
101
|
+
[ProtocolErrorCode.RestoreFailed]: "Could not write restored file",
|
|
102
|
+
[ProtocolErrorCode.FileNotFound]: "File does not exist",
|
|
103
|
+
[ProtocolErrorCode.FileAccessDenied]: "Cannot read/write file",
|
|
104
|
+
[ProtocolErrorCode.InvalidPath]: "Path is outside allowed directories",
|
|
105
|
+
[ProtocolErrorCode.WorkspaceNotFound]: "Workspace not found or not initialized",
|
|
106
|
+
[ProtocolErrorCode.WorkspaceAlreadyExists]: "Workspace already exists",
|
|
107
|
+
[ProtocolErrorCode.LearningNotFound]: "Learning not found",
|
|
108
|
+
[ProtocolErrorCode.LearningEvaluationFailed]: "Learning evaluation failed",
|
|
109
|
+
[ProtocolErrorCode.SyncUnavailable]: "Sync worker not available",
|
|
110
|
+
[ProtocolErrorCode.SyncAuthRequired]: "Sync authentication required",
|
|
111
|
+
[ProtocolErrorCode.ValidationTimeout]: "Validation timed out",
|
|
112
|
+
[ProtocolErrorCode.IntelligenceUnavailable]: "Intelligence service not available",
|
|
113
|
+
[ProtocolErrorCode.PatternNotFound]: "Pattern not found"
|
|
114
|
+
});
|
|
115
|
+
var LearningTypeSchema = z.enum([
|
|
116
|
+
"pattern",
|
|
117
|
+
"pitfall",
|
|
118
|
+
"efficiency",
|
|
119
|
+
"workflow",
|
|
120
|
+
"discovery",
|
|
121
|
+
"architecture",
|
|
122
|
+
"performance"
|
|
123
|
+
]);
|
|
124
|
+
var LearningIntentSchema = z.enum([
|
|
125
|
+
"implement",
|
|
126
|
+
"debug",
|
|
127
|
+
"refactor",
|
|
128
|
+
"review"
|
|
129
|
+
]);
|
|
130
|
+
z.enum([
|
|
131
|
+
"add-flag",
|
|
132
|
+
"set-env",
|
|
133
|
+
"inject-validation",
|
|
134
|
+
"warn",
|
|
135
|
+
"suggest-file"
|
|
136
|
+
]);
|
|
137
|
+
var WarnSeveritySchema = z.enum([
|
|
138
|
+
"info",
|
|
139
|
+
"warning",
|
|
140
|
+
"error"
|
|
141
|
+
]);
|
|
142
|
+
var AddFlagPayloadSchema = z.object({
|
|
143
|
+
flag: z.string().min(1).describe("CLI flag to add, e.g. '--validate-expiry'"),
|
|
144
|
+
value: z.union([
|
|
145
|
+
z.string(),
|
|
146
|
+
z.boolean()
|
|
147
|
+
]).optional().describe("Flag value if applicable"),
|
|
148
|
+
reason: z.string().min(1).describe("Human-readable reason shown in verbose mode")
|
|
149
|
+
});
|
|
150
|
+
var SetEnvPayloadSchema = z.object({
|
|
151
|
+
key: z.string().min(1).regex(/^[A-Z_][A-Z0-9_]*$/, "Must be valid env var name"),
|
|
152
|
+
value: z.string().describe("Environment variable value"),
|
|
153
|
+
reason: z.string().min(1).describe("Human-readable reason shown in verbose mode")
|
|
154
|
+
});
|
|
155
|
+
var InjectValidationPayloadSchema = z.object({
|
|
156
|
+
validationType: z.string().min(1).describe("Validation type identifier, e.g. 'jwt-expiry', 'silent-catch'"),
|
|
157
|
+
targetFile: z.string().optional().describe("Optional file to target for validation"),
|
|
158
|
+
reason: z.string().min(1).describe("Human-readable reason shown in verbose mode")
|
|
159
|
+
});
|
|
160
|
+
var WarnPayloadSchema = z.object({
|
|
161
|
+
message: z.string().min(1).describe("Warning message to display"),
|
|
162
|
+
severity: WarnSeveritySchema.describe("Severity level affects display styling")
|
|
163
|
+
});
|
|
164
|
+
var SuggestFilePayloadSchema = z.object({
|
|
165
|
+
filePath: z.string().min(1).describe("Suggested file path, may contain {feature} placeholder"),
|
|
166
|
+
reason: z.string().min(1).describe("Human-readable reason for suggestion")
|
|
167
|
+
});
|
|
168
|
+
var LearningTriggerSchema = z.object({
|
|
169
|
+
commands: z.array(z.string()).optional().describe("Command names that trigger this learning, e.g. ['auth', 'deploy']"),
|
|
170
|
+
intent: z.array(LearningIntentSchema).optional().describe("Intent types that trigger this learning"),
|
|
171
|
+
filePatterns: z.array(z.string()).optional().describe("Glob patterns for file matching, e.g. ['**/*auth*.ts']"),
|
|
172
|
+
flags: z.array(z.string()).optional().describe("CLI flags that trigger this learning, e.g. ['--provider']"),
|
|
173
|
+
description: z.string().min(1).describe("Human-readable description for fuzzy matching")
|
|
174
|
+
});
|
|
175
|
+
var LearningActionSchema = z.discriminatedUnion("type", [
|
|
176
|
+
z.object({
|
|
177
|
+
type: z.literal("add-flag"),
|
|
178
|
+
payload: AddFlagPayloadSchema
|
|
179
|
+
}),
|
|
180
|
+
z.object({
|
|
181
|
+
type: z.literal("set-env"),
|
|
182
|
+
payload: SetEnvPayloadSchema
|
|
183
|
+
}),
|
|
184
|
+
z.object({
|
|
185
|
+
type: z.literal("inject-validation"),
|
|
186
|
+
payload: InjectValidationPayloadSchema
|
|
187
|
+
}),
|
|
188
|
+
z.object({
|
|
189
|
+
type: z.literal("warn"),
|
|
190
|
+
payload: WarnPayloadSchema
|
|
191
|
+
}),
|
|
192
|
+
z.object({
|
|
193
|
+
type: z.literal("suggest-file"),
|
|
194
|
+
payload: SuggestFilePayloadSchema
|
|
195
|
+
})
|
|
196
|
+
]);
|
|
197
|
+
var LearningSchema = z.object({
|
|
198
|
+
id: z.string().min(1).describe("Unique identifier for this learning"),
|
|
199
|
+
type: LearningTypeSchema.describe("Categorical classification"),
|
|
200
|
+
trigger: LearningTriggerSchema.describe("Conditions that activate this learning"),
|
|
201
|
+
action: LearningActionSchema.describe("Concrete action to execute"),
|
|
202
|
+
confidence: z.number().min(0).max(1).describe("Confidence score (0.0-1.0), static at creation"),
|
|
203
|
+
created: z.number().int().positive().describe("Creation timestamp (ms since epoch)"),
|
|
204
|
+
lastUsed: z.number().int().positive().optional().describe("Last usage timestamp (ms since epoch)"),
|
|
205
|
+
usageCount: z.number().int().nonnegative().default(0).describe("Number of times this learning was applied"),
|
|
206
|
+
tags: z.array(z.string()).default([]).describe("Searchable tags for categorization"),
|
|
207
|
+
archived: z.boolean().default(false).describe("Whether this learning is archived (excluded from matching)")
|
|
208
|
+
});
|
|
209
|
+
LearningSchema.omit({
|
|
210
|
+
id: true,
|
|
211
|
+
created: true,
|
|
212
|
+
lastUsed: true,
|
|
213
|
+
usageCount: true,
|
|
214
|
+
archived: true
|
|
215
|
+
}).extend({
|
|
216
|
+
tags: z.array(z.string()).optional().default([]),
|
|
217
|
+
archived: z.boolean().optional()
|
|
218
|
+
});
|
|
219
|
+
z.enum([
|
|
220
|
+
"observe",
|
|
221
|
+
"warn",
|
|
222
|
+
"apply-safe",
|
|
223
|
+
"apply-all",
|
|
224
|
+
"off"
|
|
225
|
+
]);
|
|
226
|
+
z.object({
|
|
227
|
+
workspaceId: z.string().min(1),
|
|
228
|
+
startedAt: z.number().int().positive(),
|
|
229
|
+
lastCommandAt: z.number().int().positive(),
|
|
230
|
+
appliedLearnings: z.array(z.string()).describe("Learning IDs applied in this session")
|
|
231
|
+
});
|
|
232
|
+
z.object({
|
|
233
|
+
workspaceId: z.string().min(1),
|
|
234
|
+
commandName: z.string().min(1),
|
|
235
|
+
args: z.record(z.unknown()).optional().describe("Parsed command arguments/flags"),
|
|
236
|
+
filesOrPaths: z.array(z.string()).optional().describe("Files involved in command"),
|
|
237
|
+
intent: LearningIntentSchema.optional().describe("User intent if known")
|
|
238
|
+
});
|
|
239
|
+
var SelectedLearningSchema = z.object({
|
|
240
|
+
id: z.string(),
|
|
241
|
+
title: z.string().describe("Human-readable title derived from trigger.description"),
|
|
242
|
+
type: LearningTypeSchema,
|
|
243
|
+
score: z.number().min(0).max(1),
|
|
244
|
+
action: LearningActionSchema,
|
|
245
|
+
tags: z.array(z.string())
|
|
246
|
+
});
|
|
247
|
+
z.object({
|
|
248
|
+
selectedLearnings: z.array(SelectedLearningSchema),
|
|
249
|
+
debug: z.object({
|
|
250
|
+
evaluatedCount: z.number().int().nonnegative(),
|
|
251
|
+
durationMs: z.number().nonnegative(),
|
|
252
|
+
skippedReason: z.string().optional()
|
|
253
|
+
}).optional()
|
|
254
|
+
});
|
|
255
|
+
var LearningTierSchema = z.enum([
|
|
256
|
+
"hot",
|
|
257
|
+
"warm",
|
|
258
|
+
"cold"
|
|
259
|
+
]);
|
|
260
|
+
var LearningPrioritySchema = z.enum([
|
|
261
|
+
"critical",
|
|
262
|
+
"high",
|
|
263
|
+
"medium",
|
|
264
|
+
"low"
|
|
265
|
+
]);
|
|
266
|
+
var LearningStorageTypeSchema = z.enum([
|
|
267
|
+
"pattern",
|
|
268
|
+
"pitfall",
|
|
269
|
+
"pit",
|
|
270
|
+
"architecture",
|
|
271
|
+
"performance",
|
|
272
|
+
"efficiency",
|
|
273
|
+
"discovery",
|
|
274
|
+
"workflow",
|
|
275
|
+
"best-practice"
|
|
276
|
+
]);
|
|
277
|
+
var LearningStorageSchema = z.object({
|
|
278
|
+
id: z.string().min(1).optional(),
|
|
279
|
+
type: LearningStorageTypeSchema,
|
|
280
|
+
trigger: z.union([
|
|
281
|
+
z.string(),
|
|
282
|
+
z.array(z.string())
|
|
283
|
+
]),
|
|
284
|
+
context: z.string().optional(),
|
|
285
|
+
problem: z.string().optional(),
|
|
286
|
+
solution: z.string().optional(),
|
|
287
|
+
action: z.string(),
|
|
288
|
+
related: z.array(z.string()).optional(),
|
|
289
|
+
source: z.string(),
|
|
290
|
+
timestamp: z.union([
|
|
291
|
+
z.string(),
|
|
292
|
+
z.number()
|
|
293
|
+
]).describe("ISO 8601 string or epoch number from storage"),
|
|
294
|
+
// Tiering metadata (optional)
|
|
295
|
+
tier: LearningTierSchema.optional(),
|
|
296
|
+
domain: z.string().optional(),
|
|
297
|
+
priority: LearningPrioritySchema.optional(),
|
|
298
|
+
keywords: z.array(z.string()).optional(),
|
|
299
|
+
// Usage tracking (optional)
|
|
300
|
+
accessCount: z.number().int().nonnegative().optional(),
|
|
301
|
+
lastAccessed: z.string().optional(),
|
|
302
|
+
relevanceScore: z.number().min(0).max(1).optional(),
|
|
303
|
+
appliedDate: z.string().optional()
|
|
304
|
+
});
|
|
305
|
+
var ChunkSourceTypeSchema = z.enum([
|
|
306
|
+
"learning",
|
|
307
|
+
"adr",
|
|
308
|
+
"pattern",
|
|
309
|
+
"violation"
|
|
310
|
+
]);
|
|
311
|
+
var ChunkStatusSchema = z.enum([
|
|
312
|
+
"active",
|
|
313
|
+
"deprecated",
|
|
314
|
+
"superseded"
|
|
315
|
+
]);
|
|
316
|
+
z.object({
|
|
317
|
+
id: z.string().describe("Unique chunk identifier"),
|
|
318
|
+
source_type: ChunkSourceTypeSchema.describe("Type of source this chunk came from"),
|
|
319
|
+
source_id: z.string().describe("ID of the source record"),
|
|
320
|
+
chunk_text: z.string().describe("The actual content text"),
|
|
321
|
+
context_text: z.string().optional().describe("Optional context surrounding the chunk"),
|
|
322
|
+
authority: z.number().min(0).max(1).describe("Authority score (0-1)"),
|
|
323
|
+
status: ChunkStatusSchema.describe("Current status of the chunk"),
|
|
324
|
+
created_at: z.string().describe("ISO 8601 creation timestamp"),
|
|
325
|
+
updated_at: z.string().describe("ISO 8601 update timestamp"),
|
|
326
|
+
metadata: z.record(z.unknown()).optional().describe("Optional JSON metadata")
|
|
327
|
+
});
|
|
328
|
+
var OutcomeTypeSchema = z.enum([
|
|
329
|
+
"accepted",
|
|
330
|
+
"ignored",
|
|
331
|
+
"test_pass",
|
|
332
|
+
"test_fail",
|
|
333
|
+
"violation_prevented"
|
|
334
|
+
]);
|
|
335
|
+
z.object({
|
|
336
|
+
id: z.string(),
|
|
337
|
+
chunk_id: z.string(),
|
|
338
|
+
outcome_type: OutcomeTypeSchema,
|
|
339
|
+
context: z.record(z.unknown()).optional(),
|
|
340
|
+
created_at: z.string()
|
|
341
|
+
});
|
|
342
|
+
var LearningApiSchema = z.object({
|
|
343
|
+
id: z.string().min(1).describe("Unique identifier"),
|
|
344
|
+
type: LearningTypeSchema.describe("Categorical classification"),
|
|
345
|
+
trigger: z.string().describe("Normalized trigger condition"),
|
|
346
|
+
action: z.string().describe("Action to take (human-readable)"),
|
|
347
|
+
confidence: z.number().min(0).max(1).describe("Confidence score (0.0-1.0)"),
|
|
348
|
+
created: z.number().int().positive().describe("Creation timestamp (ms since epoch)"),
|
|
349
|
+
source: z.string().describe("Where this learning originated"),
|
|
350
|
+
tags: z.array(z.string()).default([]).describe("Searchable tags"),
|
|
351
|
+
usageCount: z.number().int().nonnegative().default(0).describe("Times applied")
|
|
352
|
+
});
|
|
353
|
+
function normalizeLearningType(type) {
|
|
354
|
+
switch (type) {
|
|
355
|
+
case "pattern":
|
|
356
|
+
return "pattern";
|
|
357
|
+
case "pitfall":
|
|
358
|
+
case "pit":
|
|
359
|
+
return "pitfall";
|
|
360
|
+
case "efficiency":
|
|
361
|
+
case "performance":
|
|
362
|
+
return "efficiency";
|
|
363
|
+
case "workflow":
|
|
364
|
+
case "best-practice":
|
|
365
|
+
return "workflow";
|
|
366
|
+
case "discovery":
|
|
367
|
+
return "discovery";
|
|
368
|
+
case "architecture":
|
|
369
|
+
return "pattern";
|
|
370
|
+
// Architecture patterns map to pattern
|
|
371
|
+
default: {
|
|
372
|
+
return "pattern";
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
__name(normalizeLearningType, "normalizeLearningType");
|
|
377
|
+
function elevateLearningToApi(storage, options) {
|
|
378
|
+
const id = storage.id ?? `learning-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
379
|
+
const normalizedType = normalizeLearningType(storage.type);
|
|
380
|
+
const trigger = Array.isArray(storage.trigger) ? storage.trigger.join(", ") : storage.trigger;
|
|
381
|
+
let created;
|
|
382
|
+
if (typeof storage.timestamp === "string") {
|
|
383
|
+
const parsed = new Date(storage.timestamp);
|
|
384
|
+
created = Number.isNaN(parsed.getTime()) ? Date.now() : parsed.getTime();
|
|
385
|
+
} else {
|
|
386
|
+
created = storage.timestamp;
|
|
387
|
+
}
|
|
388
|
+
const confidence = storage.relevanceScore ?? (options?.relevanceBoost ?? 0.7) * (storage.accessCount ? Math.min(1, storage.accessCount / 10) : 0.5);
|
|
389
|
+
return {
|
|
390
|
+
id,
|
|
391
|
+
type: normalizedType,
|
|
392
|
+
trigger,
|
|
393
|
+
action: storage.action,
|
|
394
|
+
confidence: Math.round(confidence * 1e3) / 1e3,
|
|
395
|
+
created,
|
|
396
|
+
source: storage.source,
|
|
397
|
+
tags: storage.keywords ?? [],
|
|
398
|
+
usageCount: storage.accessCount ?? 0
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
__name(elevateLearningToApi, "elevateLearningToApi");
|
|
402
|
+
LearningStorageSchema.transform((storage) => elevateLearningToApi(storage)).pipe(LearningApiSchema);
|
|
403
|
+
var FileRecord = z.object({
|
|
404
|
+
path: z.string(),
|
|
405
|
+
category: z.enum([
|
|
406
|
+
"config",
|
|
407
|
+
"source",
|
|
408
|
+
"test",
|
|
409
|
+
"build",
|
|
410
|
+
"docs",
|
|
411
|
+
"other"
|
|
412
|
+
]),
|
|
413
|
+
domain: z.string(),
|
|
414
|
+
sizeBytes: z.number(),
|
|
415
|
+
lineCount: z.number(),
|
|
416
|
+
extension: z.string()
|
|
417
|
+
});
|
|
418
|
+
var ChurnRecord = z.object({
|
|
419
|
+
filePath: z.string(),
|
|
420
|
+
changes30d: z.number(),
|
|
421
|
+
changes90d: z.number(),
|
|
422
|
+
lastChangedAt: z.number(),
|
|
423
|
+
uniqueAuthors: z.number()
|
|
424
|
+
});
|
|
425
|
+
var CoChangeCluster = z.object({
|
|
426
|
+
files: z.array(z.string()),
|
|
427
|
+
coOccurrenceRate: z.number().min(0).max(1),
|
|
428
|
+
sampleSize: z.number()
|
|
429
|
+
});
|
|
430
|
+
var FragileFileRecord = z.object({
|
|
431
|
+
path: z.string(),
|
|
432
|
+
compositeScore: z.number().min(0).max(100),
|
|
433
|
+
churnScore: z.number(),
|
|
434
|
+
blastRadiusScore: z.number(),
|
|
435
|
+
rollbackScore: z.number(),
|
|
436
|
+
dependentCount: z.number(),
|
|
437
|
+
rank: z.number()
|
|
438
|
+
});
|
|
439
|
+
var DomainHealthScore = z.object({
|
|
440
|
+
domain: z.string(),
|
|
441
|
+
score: z.number().min(0).max(100),
|
|
442
|
+
fileCount: z.number(),
|
|
443
|
+
avgChurn: z.number(),
|
|
444
|
+
fragileFileCount: z.number(),
|
|
445
|
+
trend: z.enum([
|
|
446
|
+
"improving",
|
|
447
|
+
"stable",
|
|
448
|
+
"degrading",
|
|
449
|
+
"unknown"
|
|
450
|
+
]),
|
|
451
|
+
trendComputedAt: z.number().nullable()
|
|
452
|
+
});
|
|
453
|
+
var BaselineNarrative = z.object({
|
|
454
|
+
domainSummaries: z.record(z.string()),
|
|
455
|
+
topRisks: z.array(z.object({
|
|
456
|
+
file: z.string(),
|
|
457
|
+
reason: z.string(),
|
|
458
|
+
severity: z.enum([
|
|
459
|
+
"high",
|
|
460
|
+
"medium"
|
|
461
|
+
])
|
|
462
|
+
})),
|
|
463
|
+
agentContextTemplate: z.string()
|
|
464
|
+
});
|
|
465
|
+
var DependencyGraph = z.object({
|
|
466
|
+
nodes: z.array(z.string()),
|
|
467
|
+
edges: z.array(z.object({
|
|
468
|
+
from: z.string(),
|
|
469
|
+
to: z.string()
|
|
470
|
+
})),
|
|
471
|
+
blastRadii: z.record(z.number())
|
|
472
|
+
});
|
|
473
|
+
var BaselineRecord = z.object({
|
|
474
|
+
workspacePath: z.string(),
|
|
475
|
+
computedAt: z.number(),
|
|
476
|
+
version: z.string(),
|
|
477
|
+
// Tier 1: Structural
|
|
478
|
+
fileInventory: z.array(FileRecord),
|
|
479
|
+
domainMap: z.record(z.array(z.string())),
|
|
480
|
+
totalFiles: z.number(),
|
|
481
|
+
totalLines: z.number(),
|
|
482
|
+
// Tier 2: Historical
|
|
483
|
+
churnRates: z.record(ChurnRecord),
|
|
484
|
+
coChangeClusters: z.array(CoChangeCluster),
|
|
485
|
+
rollbackHotspots: z.array(z.string()),
|
|
486
|
+
// Tier 3: Computed scores
|
|
487
|
+
fragileFiles: z.array(FragileFileRecord),
|
|
488
|
+
domainHealthScores: z.array(DomainHealthScore),
|
|
489
|
+
overallHealthScore: z.number().min(0).max(100),
|
|
490
|
+
// Dependency graph
|
|
491
|
+
dependencyGraph: DependencyGraph,
|
|
492
|
+
// AI config files (imported from ai-config.ts for enhanced types)
|
|
493
|
+
aiConfigFiles: z.array(z.any()),
|
|
494
|
+
aiConfigConflicts: z.array(z.any()),
|
|
495
|
+
// AI synthesis
|
|
496
|
+
narrative: BaselineNarrative.nullable(),
|
|
497
|
+
narrativeComputedAt: z.number().nullable()
|
|
498
|
+
});
|
|
499
|
+
var BaselineStatus = z.enum([
|
|
500
|
+
"ready",
|
|
501
|
+
"stale",
|
|
502
|
+
"computing",
|
|
503
|
+
"not_computed"
|
|
504
|
+
]);
|
|
505
|
+
z.object({
|
|
506
|
+
status: BaselineStatus,
|
|
507
|
+
progress: z.number().min(0).max(100),
|
|
508
|
+
stage: z.string().optional(),
|
|
509
|
+
error: z.string().optional()
|
|
510
|
+
});
|
|
511
|
+
z.object({
|
|
512
|
+
workspace: z.string()
|
|
513
|
+
});
|
|
514
|
+
z.object({
|
|
515
|
+
workspace: z.string()
|
|
516
|
+
});
|
|
517
|
+
z.object({
|
|
518
|
+
workspace: z.string()
|
|
519
|
+
});
|
|
520
|
+
z.object({
|
|
521
|
+
workspace: z.string()
|
|
522
|
+
});
|
|
523
|
+
z.object({
|
|
524
|
+
workspace: z.string(),
|
|
525
|
+
record: BaselineRecord
|
|
526
|
+
});
|
|
527
|
+
var WorkspaceBase = z.object({
|
|
528
|
+
/** Absolute path to workspace root */
|
|
529
|
+
workspace: z.string().min(1)
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
// ../../packages/contracts/dist/local-service/schemas/context.js
|
|
533
|
+
WorkspaceBase.extend({
|
|
534
|
+
/** Task description */
|
|
535
|
+
task: z.string().min(1),
|
|
536
|
+
/** Files involved */
|
|
537
|
+
files: z.array(z.string()).optional(),
|
|
538
|
+
/** Keywords for context matching */
|
|
539
|
+
keywords: z.array(z.string()).optional()
|
|
540
|
+
});
|
|
541
|
+
WorkspaceBase.extend({
|
|
542
|
+
/** Code to check */
|
|
543
|
+
code: z.string(),
|
|
544
|
+
/** File path */
|
|
545
|
+
filePath: z.string().min(1)
|
|
546
|
+
});
|
|
547
|
+
z.object({});
|
|
548
|
+
z.object({});
|
|
549
|
+
z.object({});
|
|
550
|
+
z.object({});
|
|
551
|
+
z.object({
|
|
552
|
+
/** Absolute path to workspace root */
|
|
553
|
+
workspace: z.string().min(1),
|
|
554
|
+
/** Component type */
|
|
555
|
+
type: z.enum([
|
|
556
|
+
"mcp-stdio",
|
|
557
|
+
"mcp-http"
|
|
558
|
+
]),
|
|
559
|
+
/** Process ID of the component */
|
|
560
|
+
pid: z.number().int().positive(),
|
|
561
|
+
/** Restart strategy */
|
|
562
|
+
restartStrategy: z.enum([
|
|
563
|
+
"one-for-one",
|
|
564
|
+
"one-for-all"
|
|
565
|
+
]).default("one-for-one")
|
|
566
|
+
});
|
|
567
|
+
z.object({
|
|
568
|
+
/** Process ID of the component */
|
|
569
|
+
pid: z.number().int().positive()
|
|
570
|
+
});
|
|
571
|
+
z.object({
|
|
572
|
+
/** Include verbose details */
|
|
573
|
+
verbose: z.boolean().optional()
|
|
574
|
+
});
|
|
575
|
+
z.object({
|
|
576
|
+
/** File path being checked */
|
|
577
|
+
filePath: z.string().min(1),
|
|
578
|
+
/** Current file content */
|
|
579
|
+
content: z.string(),
|
|
580
|
+
/** Previous content for comparison (optional) */
|
|
581
|
+
previousContent: z.string().optional(),
|
|
582
|
+
/** Additional metadata (optional) */
|
|
583
|
+
metadata: z.object({
|
|
584
|
+
/** Editor information string */
|
|
585
|
+
editorInfo: z.string().optional(),
|
|
586
|
+
/** Timestamp in milliseconds since epoch */
|
|
587
|
+
timestamp: z.number().int().positive().optional()
|
|
588
|
+
}).optional()
|
|
589
|
+
});
|
|
590
|
+
z.object({
|
|
591
|
+
/** Unified diff string to analyze */
|
|
592
|
+
diff: z.string(),
|
|
593
|
+
/** Context about the change */
|
|
594
|
+
context: z.object({
|
|
595
|
+
/** File path being changed */
|
|
596
|
+
filePath: z.string(),
|
|
597
|
+
/** Programming language (optional) */
|
|
598
|
+
language: z.string().optional(),
|
|
599
|
+
/** Project type (e.g., "web", "mobile", "backend") (optional) */
|
|
600
|
+
projectType: z.string().optional()
|
|
601
|
+
})
|
|
602
|
+
});
|
|
603
|
+
z.object({
|
|
604
|
+
/** Snapshot IDs to analyze for grouping */
|
|
605
|
+
snapshotIds: z.array(z.string().uuid()).min(1)
|
|
606
|
+
});
|
|
607
|
+
z.object({
|
|
608
|
+
/** Sync direction */
|
|
609
|
+
direction: z.enum([
|
|
610
|
+
"push",
|
|
611
|
+
"pull",
|
|
612
|
+
"both"
|
|
613
|
+
]).default("both"),
|
|
614
|
+
/** Specific snapshot IDs to sync (optional, syncs all if omitted) */
|
|
615
|
+
snapshotIds: z.array(z.string().uuid()).optional()
|
|
616
|
+
});
|
|
617
|
+
z.object({
|
|
618
|
+
/** Workspace root path */
|
|
619
|
+
workspace: z.string().min(1).describe("Workspace root path"),
|
|
620
|
+
/** Force refresh cache */
|
|
621
|
+
force: z.boolean().optional().default(false).describe("Force refresh cache")
|
|
622
|
+
});
|
|
623
|
+
z.object({
|
|
624
|
+
/** Workspace root path */
|
|
625
|
+
workspace: z.string().min(1).describe("Workspace root path")
|
|
626
|
+
});
|
|
627
|
+
z.object({});
|
|
628
|
+
z.string().regex(/^\d+\.\d+\.\d+$/);
|
|
629
|
+
var SnapshotTrigger = z.enum([
|
|
630
|
+
"save",
|
|
631
|
+
"ai_burst",
|
|
632
|
+
"manual",
|
|
633
|
+
"timer",
|
|
634
|
+
"pre_restore",
|
|
635
|
+
"external"
|
|
636
|
+
]);
|
|
637
|
+
var ProtectionLevel = z.enum([
|
|
638
|
+
"watch",
|
|
639
|
+
"warn",
|
|
640
|
+
"block"
|
|
641
|
+
]);
|
|
642
|
+
var RiskLevel = z.enum([
|
|
643
|
+
"low",
|
|
644
|
+
"medium",
|
|
645
|
+
"high",
|
|
646
|
+
"critical"
|
|
647
|
+
]);
|
|
648
|
+
var SessionState = z.enum([
|
|
649
|
+
"active",
|
|
650
|
+
"idle",
|
|
651
|
+
"ended"
|
|
652
|
+
]);
|
|
653
|
+
z.enum([
|
|
654
|
+
"free",
|
|
655
|
+
"pro",
|
|
656
|
+
"enterprise"
|
|
657
|
+
]);
|
|
658
|
+
var LearningType = z.enum([
|
|
659
|
+
"pattern",
|
|
660
|
+
"pitfall",
|
|
661
|
+
"efficiency",
|
|
662
|
+
"discovery",
|
|
663
|
+
"workflow"
|
|
664
|
+
]);
|
|
665
|
+
var TaskIntent = z.enum([
|
|
666
|
+
"implement",
|
|
667
|
+
"debug",
|
|
668
|
+
"refactor",
|
|
669
|
+
"review",
|
|
670
|
+
"explore"
|
|
671
|
+
]);
|
|
672
|
+
var MemoryEntryType = z.enum([
|
|
673
|
+
"learning",
|
|
674
|
+
"pattern",
|
|
675
|
+
"violation",
|
|
676
|
+
"context",
|
|
677
|
+
"task",
|
|
678
|
+
"session"
|
|
679
|
+
]);
|
|
680
|
+
var WarningSeverity = z.enum([
|
|
681
|
+
"info",
|
|
682
|
+
"warning",
|
|
683
|
+
"error"
|
|
684
|
+
]);
|
|
685
|
+
var CoChangeRelationship = z.enum([
|
|
686
|
+
"import_dependency",
|
|
687
|
+
"test_coverage",
|
|
688
|
+
"config_pair",
|
|
689
|
+
"co_change_historical",
|
|
690
|
+
"type_definition"
|
|
691
|
+
]).or(z.string());
|
|
692
|
+
var ClientType = z.enum([
|
|
693
|
+
"vscode",
|
|
694
|
+
"mcp-stdio",
|
|
695
|
+
"mcp-remote",
|
|
696
|
+
"cli",
|
|
697
|
+
"api",
|
|
698
|
+
"unknown"
|
|
699
|
+
]);
|
|
700
|
+
|
|
701
|
+
// ../../packages/contracts/dist/local-service/schemas/entities.js
|
|
702
|
+
var FileConflict = z.object({
|
|
703
|
+
/** The OTHER session ID involved in the conflict */
|
|
704
|
+
sessionId: z.string(),
|
|
705
|
+
/** Client type of the other session */
|
|
706
|
+
clientType: z.enum([
|
|
707
|
+
"vscode",
|
|
708
|
+
"mcp-stdio",
|
|
709
|
+
"mcp-remote",
|
|
710
|
+
"cli",
|
|
711
|
+
"api",
|
|
712
|
+
"unknown"
|
|
713
|
+
]),
|
|
714
|
+
/** Overlapping file paths */
|
|
715
|
+
files: z.array(z.string()),
|
|
716
|
+
/** When the conflict was detected */
|
|
717
|
+
detectedAt: z.number(),
|
|
718
|
+
/** Severity level */
|
|
719
|
+
severity: z.enum([
|
|
720
|
+
"info",
|
|
721
|
+
"warn"
|
|
722
|
+
])
|
|
723
|
+
});
|
|
724
|
+
z.object({
|
|
725
|
+
/** Unique session identifier (UUID v4) */
|
|
726
|
+
id: z.string().uuid(),
|
|
727
|
+
/** Absolute path to the workspace root */
|
|
728
|
+
workspacePath: z.string(),
|
|
729
|
+
/** ISO 8601 timestamp when session started */
|
|
730
|
+
startedAt: z.string().datetime(),
|
|
731
|
+
/** ISO 8601 timestamp of last activity */
|
|
732
|
+
lastActivityAt: z.string().datetime(),
|
|
733
|
+
/** Current session state */
|
|
734
|
+
state: SessionState,
|
|
735
|
+
/** Session metadata */
|
|
736
|
+
metadata: z.object({
|
|
737
|
+
/** AI tools detected during this session */
|
|
738
|
+
aiToolsDetected: z.array(z.string()),
|
|
739
|
+
/** Highest risk level seen in this session */
|
|
740
|
+
highestRiskLevel: RiskLevel,
|
|
741
|
+
/** Count of snapshots by trigger type */
|
|
742
|
+
triggerCounts: z.record(z.string(), z.number())
|
|
743
|
+
}),
|
|
744
|
+
// === Phase 1 Additions ===
|
|
745
|
+
/** Client ID that owns this session (populated from ClientRegistry) */
|
|
746
|
+
clientId: z.string().optional(),
|
|
747
|
+
/** Client type (vscode, mcp-stdio, mcp-remote, cli, api, unknown) */
|
|
748
|
+
clientType: z.enum([
|
|
749
|
+
"vscode",
|
|
750
|
+
"mcp-stdio",
|
|
751
|
+
"mcp-remote",
|
|
752
|
+
"cli",
|
|
753
|
+
"api",
|
|
754
|
+
"unknown"
|
|
755
|
+
]).optional(),
|
|
756
|
+
/** Unix ms timestamp when session ended (null if active) */
|
|
757
|
+
endedAt: z.number().nullable().optional(),
|
|
758
|
+
/** Snapshot IDs created during this session */
|
|
759
|
+
snapshotIds: z.array(z.string()).optional(),
|
|
760
|
+
/** Learning IDs captured during this session */
|
|
761
|
+
learningIds: z.array(z.string()).optional(),
|
|
762
|
+
/** Coherence score computed at session end */
|
|
763
|
+
coherenceScore: z.enum([
|
|
764
|
+
"high",
|
|
765
|
+
"medium",
|
|
766
|
+
"low",
|
|
767
|
+
"scattered"
|
|
768
|
+
]).nullable().optional(),
|
|
769
|
+
/** Maximum risk score observed during session */
|
|
770
|
+
riskPeakScore: z.number().nullable().optional(),
|
|
771
|
+
/** Other active sessions on same workspace */
|
|
772
|
+
concurrentSessionIds: z.array(z.string()).optional(),
|
|
773
|
+
/** Cross-session file overlap detections */
|
|
774
|
+
fileConflicts: z.array(FileConflict).optional(),
|
|
775
|
+
/** Files touched during this session */
|
|
776
|
+
touchedFiles: z.array(z.string()).optional()
|
|
777
|
+
});
|
|
778
|
+
var Snapshot = z.object({
|
|
779
|
+
/** Unique snapshot identifier (UUID v4) */
|
|
780
|
+
id: z.string().uuid(),
|
|
781
|
+
/** Session that created this snapshot */
|
|
782
|
+
sessionId: z.string().min(1),
|
|
783
|
+
/** Absolute path to the file */
|
|
784
|
+
filePath: z.string(),
|
|
785
|
+
/** Path relative to workspace root */
|
|
786
|
+
relativePath: z.string(),
|
|
787
|
+
/** Content hash (SHA-256, prefixed with "sha256:") */
|
|
788
|
+
contentHash: z.string().startsWith("sha256:"),
|
|
789
|
+
/** What triggered this snapshot */
|
|
790
|
+
trigger: SnapshotTrigger,
|
|
791
|
+
/** ISO 8601 timestamp when snapshot was created */
|
|
792
|
+
createdAt: z.string().datetime(),
|
|
793
|
+
/** Snapshot metadata */
|
|
794
|
+
metadata: z.object({
|
|
795
|
+
/** File size in bytes */
|
|
796
|
+
fileSize: z.number().int().nonnegative(),
|
|
797
|
+
/** Number of lines in the file */
|
|
798
|
+
lineCount: z.number().int().nonnegative(),
|
|
799
|
+
/** Programming language (optional) */
|
|
800
|
+
language: z.string().optional(),
|
|
801
|
+
/** AI tool that was active (if detected) */
|
|
802
|
+
aiToolDetected: z.string().optional(),
|
|
803
|
+
/** Confidence score for AI detection (0-1) */
|
|
804
|
+
aiConfidence: z.number().min(0).max(1).optional(),
|
|
805
|
+
/** Risk level assessment (optional) */
|
|
806
|
+
riskLevel: RiskLevel.optional()
|
|
807
|
+
})
|
|
808
|
+
});
|
|
809
|
+
z.object({
|
|
810
|
+
/** Determined protection level */
|
|
811
|
+
level: ProtectionLevel,
|
|
812
|
+
/** Whether this was automatically determined */
|
|
813
|
+
automatic: z.boolean(),
|
|
814
|
+
/** Source of the decision */
|
|
815
|
+
source: z.enum([
|
|
816
|
+
"auto",
|
|
817
|
+
"user",
|
|
818
|
+
"config",
|
|
819
|
+
"default"
|
|
820
|
+
]),
|
|
821
|
+
/** Confidence in the decision (0-1) */
|
|
822
|
+
confidence: z.number().min(0).max(1)
|
|
823
|
+
});
|
|
824
|
+
z.object({
|
|
825
|
+
/** Factor name/description */
|
|
826
|
+
name: z.string(),
|
|
827
|
+
/** Factor score (0-1, higher = more protection needed) */
|
|
828
|
+
score: z.number().min(0).max(1),
|
|
829
|
+
/** Factor weight in overall decision (0-1) */
|
|
830
|
+
weight: z.number().min(0).max(1),
|
|
831
|
+
/** Additional details (optional) */
|
|
832
|
+
details: z.string().optional()
|
|
833
|
+
});
|
|
834
|
+
z.object({
|
|
835
|
+
/** Type of detection signal */
|
|
836
|
+
type: z.enum([
|
|
837
|
+
"pattern",
|
|
838
|
+
"timing",
|
|
839
|
+
"volume",
|
|
840
|
+
"style"
|
|
841
|
+
]),
|
|
842
|
+
/** Human-readable description */
|
|
843
|
+
description: z.string(),
|
|
844
|
+
/** Signal strength (0-1, higher = stronger evidence) */
|
|
845
|
+
strength: z.number().min(0).max(1)
|
|
846
|
+
});
|
|
847
|
+
z.object({
|
|
848
|
+
/** Risk category */
|
|
849
|
+
category: z.enum([
|
|
850
|
+
"security",
|
|
851
|
+
"stability",
|
|
852
|
+
"data",
|
|
853
|
+
"infrastructure"
|
|
854
|
+
]),
|
|
855
|
+
/** Human-readable description */
|
|
856
|
+
description: z.string(),
|
|
857
|
+
/** Severity level */
|
|
858
|
+
severity: z.enum([
|
|
859
|
+
"low",
|
|
860
|
+
"medium",
|
|
861
|
+
"high"
|
|
862
|
+
]),
|
|
863
|
+
/** Location in code (optional) */
|
|
864
|
+
location: z.object({
|
|
865
|
+
/** Starting line number (1-indexed) */
|
|
866
|
+
startLine: z.number().int().positive(),
|
|
867
|
+
/** Ending line number (1-indexed) */
|
|
868
|
+
endLine: z.number().int().positive()
|
|
869
|
+
}).optional()
|
|
870
|
+
});
|
|
871
|
+
z.object({
|
|
872
|
+
/** Overall risk score: 0-100 */
|
|
873
|
+
score: z.number().int().min(0).max(100),
|
|
874
|
+
/** Risk level classification (reuses existing RiskLevel from local-service) */
|
|
875
|
+
level: RiskLevel,
|
|
876
|
+
/** All identified risk factors */
|
|
877
|
+
factors: z.array(z.object({
|
|
878
|
+
/** Factor name */
|
|
879
|
+
name: z.string(),
|
|
880
|
+
/** Score contribution: -100 to 100 */
|
|
881
|
+
score: z.number().min(-100).max(100),
|
|
882
|
+
/** Human-readable description */
|
|
883
|
+
description: z.string(),
|
|
884
|
+
/** Source system */
|
|
885
|
+
source: z.enum([
|
|
886
|
+
"github",
|
|
887
|
+
"context7",
|
|
888
|
+
"sentry",
|
|
889
|
+
"local",
|
|
890
|
+
"ai_detection"
|
|
891
|
+
]),
|
|
892
|
+
/** Optional mitigation suggestion */
|
|
893
|
+
suggestion: z.string().optional()
|
|
894
|
+
})),
|
|
895
|
+
/** Recommended action */
|
|
896
|
+
recommendation: z.enum([
|
|
897
|
+
"proceed",
|
|
898
|
+
"warn",
|
|
899
|
+
"block"
|
|
900
|
+
]),
|
|
901
|
+
/** Confidence in assessment: 0-100 */
|
|
902
|
+
confidence: z.number().int().min(0).max(100),
|
|
903
|
+
/** Human-readable explanation */
|
|
904
|
+
explanation: z.string()
|
|
905
|
+
});
|
|
906
|
+
z.discriminatedUnion("detected", [
|
|
907
|
+
z.object({
|
|
908
|
+
detected: z.literal(false),
|
|
909
|
+
/** Detection confidence: 0-1 (confidence that no AI was involved) */
|
|
910
|
+
confidence: z.number().min(0).max(1),
|
|
911
|
+
/** Detection signals evaluated */
|
|
912
|
+
signals: z.array(z.object({
|
|
913
|
+
type: z.enum([
|
|
914
|
+
"pattern",
|
|
915
|
+
"timing",
|
|
916
|
+
"volume",
|
|
917
|
+
"style"
|
|
918
|
+
]),
|
|
919
|
+
description: z.string(),
|
|
920
|
+
strength: z.number().min(0).max(1)
|
|
921
|
+
}))
|
|
922
|
+
}),
|
|
923
|
+
z.object({
|
|
924
|
+
detected: z.literal(true),
|
|
925
|
+
/** Detected AI tool name */
|
|
926
|
+
toolName: z.string(),
|
|
927
|
+
/** Detection confidence: 0-1 */
|
|
928
|
+
confidence: z.number().min(0).max(1),
|
|
929
|
+
/** Detection signals that contributed to the result */
|
|
930
|
+
signals: z.array(z.object({
|
|
931
|
+
type: z.enum([
|
|
932
|
+
"pattern",
|
|
933
|
+
"timing",
|
|
934
|
+
"volume",
|
|
935
|
+
"style"
|
|
936
|
+
]),
|
|
937
|
+
description: z.string(),
|
|
938
|
+
strength: z.number().min(0).max(1)
|
|
939
|
+
}))
|
|
940
|
+
})
|
|
941
|
+
]);
|
|
942
|
+
z.object({
|
|
943
|
+
/** Relative file path */
|
|
944
|
+
filePath: z.string(),
|
|
945
|
+
/** Fragility score: 0-1 (1 = very fragile) */
|
|
946
|
+
fragilityScore: z.number().min(0).max(1),
|
|
947
|
+
/** Severity classification */
|
|
948
|
+
severity: z.enum([
|
|
949
|
+
"moderate",
|
|
950
|
+
"high",
|
|
951
|
+
"critical"
|
|
952
|
+
]),
|
|
953
|
+
/** Why this file is fragile */
|
|
954
|
+
reason: z.string(),
|
|
955
|
+
/** Suggested action */
|
|
956
|
+
suggestion: z.string(),
|
|
957
|
+
/** Number of rollbacks in recent history */
|
|
958
|
+
rollbackCount: z.number().int().nonnegative(),
|
|
959
|
+
/** Number of AI-triggered modifications */
|
|
960
|
+
aiChurnCount: z.number().int().nonnegative(),
|
|
961
|
+
/** Blast radius (number of dependent files) */
|
|
962
|
+
blastRadius: z.number().int().nonnegative().optional(),
|
|
963
|
+
/** Last modified timestamp (ISO 8601) */
|
|
964
|
+
lastModified: z.string().datetime().optional()
|
|
965
|
+
});
|
|
966
|
+
z.object({
|
|
967
|
+
/** Primary file path */
|
|
968
|
+
fileA: z.string(),
|
|
969
|
+
/** Co-changed file path */
|
|
970
|
+
fileB: z.string(),
|
|
971
|
+
/** Co-occurrence frequency: 0-1 (1 = always changed together) */
|
|
972
|
+
frequency: z.number().min(0).max(1),
|
|
973
|
+
/** Number of times these files were changed together */
|
|
974
|
+
occurrences: z.number().int().positive(),
|
|
975
|
+
/** Relationship type - extensible union */
|
|
976
|
+
relationship: CoChangeRelationship,
|
|
977
|
+
/** Human-readable description of why they co-change */
|
|
978
|
+
reason: z.string(),
|
|
979
|
+
/** When this pattern was last observed (ISO 8601) */
|
|
980
|
+
lastObserved: z.string().datetime()
|
|
981
|
+
});
|
|
982
|
+
z.object({
|
|
983
|
+
/** Relative file path */
|
|
984
|
+
path: z.string().min(1),
|
|
985
|
+
/** Composite fragility score: 0-100 (100 = most fragile) */
|
|
986
|
+
compositeScore: z.number().min(0).max(100),
|
|
987
|
+
/** Weighted churn rate contribution */
|
|
988
|
+
churnScore: z.number().min(0),
|
|
989
|
+
/** Weighted dependency count contribution */
|
|
990
|
+
blastRadiusScore: z.number().min(0),
|
|
991
|
+
/** How often restores involve this file */
|
|
992
|
+
rollbackScore: z.number().min(0),
|
|
993
|
+
/** Files that import this file */
|
|
994
|
+
dependentCount: z.number().int().nonnegative(),
|
|
995
|
+
/** Ranking: 1 = most fragile */
|
|
996
|
+
rank: z.number().int().positive()
|
|
997
|
+
});
|
|
998
|
+
z.object({
|
|
999
|
+
/** Primary file path */
|
|
1000
|
+
fileA: z.string().min(1),
|
|
1001
|
+
/** Co-changed file path */
|
|
1002
|
+
fileB: z.string().min(1),
|
|
1003
|
+
/** Co-occurrence frequency: 0-1 (1 = always changed together) */
|
|
1004
|
+
frequency: z.number().min(0).max(1),
|
|
1005
|
+
/** Number of times these files were changed together */
|
|
1006
|
+
occurrences: z.number().int().positive(),
|
|
1007
|
+
/** Relationship type - extensible string */
|
|
1008
|
+
relationship: z.string().min(1),
|
|
1009
|
+
/** Human-readable description of why they co-change */
|
|
1010
|
+
reason: z.string().min(1),
|
|
1011
|
+
/** When this pattern was last observed (epoch timestamp) */
|
|
1012
|
+
lastObserved: z.number().int().positive()
|
|
1013
|
+
});
|
|
1014
|
+
var RiskFactorStorageSchema = z.object({
|
|
1015
|
+
/** Pillar source */
|
|
1016
|
+
source: z.enum([
|
|
1017
|
+
"git-risk",
|
|
1018
|
+
"rollback-patterns",
|
|
1019
|
+
"fatigue",
|
|
1020
|
+
"annotations",
|
|
1021
|
+
"poisoning",
|
|
1022
|
+
"history",
|
|
1023
|
+
"structural",
|
|
1024
|
+
"co-change"
|
|
1025
|
+
]),
|
|
1026
|
+
/** Risk score contribution */
|
|
1027
|
+
score: z.number(),
|
|
1028
|
+
/** Human-readable description */
|
|
1029
|
+
description: z.string().min(1),
|
|
1030
|
+
/** Severity level */
|
|
1031
|
+
severity: z.enum([
|
|
1032
|
+
"info",
|
|
1033
|
+
"warning",
|
|
1034
|
+
"critical"
|
|
1035
|
+
]),
|
|
1036
|
+
/** Additional metadata */
|
|
1037
|
+
meta: z.record(z.unknown()).optional()
|
|
1038
|
+
});
|
|
1039
|
+
z.object({
|
|
1040
|
+
/** Overall risk score (1.0 = neutral, higher = riskier) */
|
|
1041
|
+
riskScore: z.number().min(0),
|
|
1042
|
+
/** Action recommendation */
|
|
1043
|
+
action: z.enum([
|
|
1044
|
+
"PROCEED",
|
|
1045
|
+
"PROCEED_WITH_SNAPSHOT",
|
|
1046
|
+
"WARN",
|
|
1047
|
+
"BLOCK"
|
|
1048
|
+
]),
|
|
1049
|
+
/** All contributing factors */
|
|
1050
|
+
factors: z.array(RiskFactorStorageSchema),
|
|
1051
|
+
/** Whether write is allowed */
|
|
1052
|
+
allowed: z.boolean(),
|
|
1053
|
+
/** Human-readable recommendation */
|
|
1054
|
+
recommendation: z.string().min(1),
|
|
1055
|
+
/** Alternative actions if blocked */
|
|
1056
|
+
alternativeActions: z.array(z.object({
|
|
1057
|
+
tool: z.string(),
|
|
1058
|
+
description: z.string(),
|
|
1059
|
+
params: z.record(z.unknown()).optional()
|
|
1060
|
+
})).optional(),
|
|
1061
|
+
/** Assessment timestamp (epoch) */
|
|
1062
|
+
timestamp: z.number().int().positive(),
|
|
1063
|
+
/** Correlation ID for tracing */
|
|
1064
|
+
correlationId: z.string().optional()
|
|
1065
|
+
});
|
|
1066
|
+
z.object({
|
|
1067
|
+
/** Total learnings captured for this workspace */
|
|
1068
|
+
learningsCount: z.number().int().nonnegative(),
|
|
1069
|
+
/** Total patterns detected */
|
|
1070
|
+
patternsCount: z.number().int().nonnegative(),
|
|
1071
|
+
/** Number of fragile files identified */
|
|
1072
|
+
fragileFilesCount: z.number().int().nonnegative(),
|
|
1073
|
+
/** Number of co-change relationships detected */
|
|
1074
|
+
coChangePatternsCount: z.number().int().nonnegative(),
|
|
1075
|
+
/** Total sessions recorded (cumulative) */
|
|
1076
|
+
totalSessions: z.number().int().nonnegative(),
|
|
1077
|
+
/** Total lines analyzed (cumulative - retained for Pioneer Program) */
|
|
1078
|
+
linesAnalyzed: z.number().int().nonnegative(),
|
|
1079
|
+
/** Total snapshots created (cumulative) */
|
|
1080
|
+
totalSnapshots: z.number().int().nonnegative(),
|
|
1081
|
+
/** Total restores performed (cumulative) */
|
|
1082
|
+
totalRestores: z.number().int().nonnegative(),
|
|
1083
|
+
// ── Time-windowed counters (v2 - meaningful recency) ──
|
|
1084
|
+
/** Snapshots created in the last 24 hours */
|
|
1085
|
+
snapshotsToday: z.number().int().nonnegative(),
|
|
1086
|
+
/** Snapshots created in the last 7 days */
|
|
1087
|
+
snapshotsThisWeek: z.number().int().nonnegative(),
|
|
1088
|
+
/** Lines analyzed in the last 24 hours */
|
|
1089
|
+
linesAnalyzedToday: z.number().int().nonnegative(),
|
|
1090
|
+
/** Restores performed in the last 7 days */
|
|
1091
|
+
restoresThisWeek: z.number().int().nonnegative(),
|
|
1092
|
+
/** Patterns detected in the last 7 days */
|
|
1093
|
+
patternsThisWeek: z.number().int().nonnegative(),
|
|
1094
|
+
// ── Health summary ──
|
|
1095
|
+
/** Workspace health score: 0-100 */
|
|
1096
|
+
healthScore: z.number().int().min(0).max(100),
|
|
1097
|
+
/** Health trajectory */
|
|
1098
|
+
healthTrajectory: z.enum([
|
|
1099
|
+
"improving",
|
|
1100
|
+
"stable",
|
|
1101
|
+
"declining"
|
|
1102
|
+
])
|
|
1103
|
+
});
|
|
1104
|
+
z.object({
|
|
1105
|
+
/** Warning code (e.g., 'FRAGILE_FILE', 'LOOP_DETECTED') */
|
|
1106
|
+
code: z.string(),
|
|
1107
|
+
/** Severity level (ordered: info < warning < error) */
|
|
1108
|
+
level: WarningSeverity,
|
|
1109
|
+
/** Human-readable message */
|
|
1110
|
+
message: z.string(),
|
|
1111
|
+
/** Affected file (optional) */
|
|
1112
|
+
file: z.string().optional(),
|
|
1113
|
+
/** Suggested action */
|
|
1114
|
+
suggestion: z.string().optional()
|
|
1115
|
+
});
|
|
1116
|
+
z.object({
|
|
1117
|
+
/** Coherence score: 0-100 (100 = highly focused session) */
|
|
1118
|
+
score: z.number().int().min(0).max(100),
|
|
1119
|
+
/** Assessment */
|
|
1120
|
+
assessment: z.enum([
|
|
1121
|
+
"focused",
|
|
1122
|
+
"moderate",
|
|
1123
|
+
"scattered",
|
|
1124
|
+
"chaotic"
|
|
1125
|
+
]),
|
|
1126
|
+
/** Number of distinct file clusters in the session */
|
|
1127
|
+
clusterCount: z.number().int().nonnegative(),
|
|
1128
|
+
/** Primary focus area (most-edited directory or module) */
|
|
1129
|
+
primaryFocus: z.string().nullable(),
|
|
1130
|
+
/** Files that seem unrelated to the main session focus */
|
|
1131
|
+
outlierFiles: z.array(z.string())
|
|
1132
|
+
});
|
|
1133
|
+
var SnapshotAIAttribution = z.discriminatedUnion("detected", [
|
|
1134
|
+
z.object({
|
|
1135
|
+
detected: z.literal(false)
|
|
1136
|
+
}),
|
|
1137
|
+
z.object({
|
|
1138
|
+
detected: z.literal(true),
|
|
1139
|
+
toolName: z.string(),
|
|
1140
|
+
confidence: z.number().min(0).max(1)
|
|
1141
|
+
})
|
|
1142
|
+
]);
|
|
1143
|
+
Snapshot.extend({
|
|
1144
|
+
/** Risk assessment at time of creation */
|
|
1145
|
+
risk: z.object({
|
|
1146
|
+
score: z.number().int().min(0).max(100),
|
|
1147
|
+
level: RiskLevel
|
|
1148
|
+
}).optional(),
|
|
1149
|
+
/** AI tool attribution (absent = not checked, present = checked) */
|
|
1150
|
+
aiAttribution: SnapshotAIAttribution.optional(),
|
|
1151
|
+
/** Session cluster ID (for grouping in timeline) */
|
|
1152
|
+
sessionClusterId: z.string().uuid().nullable(),
|
|
1153
|
+
/** Whether this snapshot has been restored */
|
|
1154
|
+
wasRestored: z.boolean()
|
|
1155
|
+
});
|
|
1156
|
+
z.object({
|
|
1157
|
+
/** Workspace root (absolute path) */
|
|
1158
|
+
workspace: z.string().min(1),
|
|
1159
|
+
/** Workspace-relative file path (I-9) */
|
|
1160
|
+
filePath: z.string().min(1)
|
|
1161
|
+
});
|
|
1162
|
+
z.object({
|
|
1163
|
+
result: z.object({
|
|
1164
|
+
/** 1-hop importers (workspace-relative paths) */
|
|
1165
|
+
direct: z.array(z.string()),
|
|
1166
|
+
/** 2-hop importers, excluding anything in `direct` */
|
|
1167
|
+
transitive: z.array(z.string()),
|
|
1168
|
+
directCount: z.number().int().nonnegative(),
|
|
1169
|
+
transitiveCount: z.number().int().nonnegative(),
|
|
1170
|
+
/** Count of affected files living in a different module */
|
|
1171
|
+
crossPackageCount: z.number().int().nonnegative(),
|
|
1172
|
+
/** Log-scale normalised blast radius score in [0, 1] */
|
|
1173
|
+
score: z.number().min(0).max(1)
|
|
1174
|
+
}).nullable()
|
|
1175
|
+
});
|
|
1176
|
+
var GuardStatus = z.enum([
|
|
1177
|
+
"pass",
|
|
1178
|
+
"warn",
|
|
1179
|
+
"fail"
|
|
1180
|
+
]);
|
|
1181
|
+
var GuardFile = z.object({
|
|
1182
|
+
/** Absolute or workspace-relative path to the flagged file */
|
|
1183
|
+
path: z.string().min(1),
|
|
1184
|
+
/** Line number where the issue was found (optional) */
|
|
1185
|
+
line: z.number().int().positive().optional(),
|
|
1186
|
+
/** Human-readable description of the issue */
|
|
1187
|
+
message: z.string().min(1)
|
|
1188
|
+
});
|
|
1189
|
+
var GuardResult = z.object({
|
|
1190
|
+
/** Guard name (e.g., "console-logs", "test-pollution") */
|
|
1191
|
+
guard: z.string().min(1),
|
|
1192
|
+
/** Execution status */
|
|
1193
|
+
status: GuardStatus,
|
|
1194
|
+
/** Files flagged by this guard (empty array if status is "pass") */
|
|
1195
|
+
files: z.array(GuardFile).default([]),
|
|
1196
|
+
/** Execution duration in milliseconds */
|
|
1197
|
+
durationMs: z.number().nonnegative()
|
|
1198
|
+
});
|
|
1199
|
+
z.object({
|
|
1200
|
+
/** Results from all guards in the run */
|
|
1201
|
+
guards: z.array(GuardResult).default([]),
|
|
1202
|
+
/** Unix timestamp (ms) when this run completed */
|
|
1203
|
+
timestamp: z.number().nonnegative(),
|
|
1204
|
+
/** Age of cached results in milliseconds (Date.now() - timestamp) */
|
|
1205
|
+
staleMs: z.number().nonnegative(),
|
|
1206
|
+
/** Profile used for this run ("fast" or "full") */
|
|
1207
|
+
profile: z.enum([
|
|
1208
|
+
"fast",
|
|
1209
|
+
"full"
|
|
1210
|
+
]),
|
|
1211
|
+
/** Whether a background refresh is in progress */
|
|
1212
|
+
refreshing: z.boolean()
|
|
1213
|
+
});
|
|
1214
|
+
WorkspaceBase.extend({
|
|
1215
|
+
/** Guard profile to run (optional, defaults to "fast") */
|
|
1216
|
+
profile: z.enum([
|
|
1217
|
+
"fast",
|
|
1218
|
+
"full"
|
|
1219
|
+
]).optional().default("fast")
|
|
1220
|
+
});
|
|
1221
|
+
z.object({
|
|
1222
|
+
/** Guards that changed status since last run */
|
|
1223
|
+
changed: z.array(GuardResult),
|
|
1224
|
+
/** Current state of all guards */
|
|
1225
|
+
current: z.array(GuardResult),
|
|
1226
|
+
/** Unix timestamp (ms) when the change was detected */
|
|
1227
|
+
timestamp: z.number().nonnegative()
|
|
1228
|
+
});
|
|
1229
|
+
WorkspaceBase.extend({
|
|
1230
|
+
/** Pattern content */
|
|
1231
|
+
content: z.string().min(1),
|
|
1232
|
+
/** Knowledge domain */
|
|
1233
|
+
domain: z.enum([
|
|
1234
|
+
"architecture",
|
|
1235
|
+
"testing",
|
|
1236
|
+
"documentation",
|
|
1237
|
+
"performance",
|
|
1238
|
+
"security",
|
|
1239
|
+
"workflow",
|
|
1240
|
+
"tooling"
|
|
1241
|
+
]).optional(),
|
|
1242
|
+
/** Pattern type */
|
|
1243
|
+
type: z.enum([
|
|
1244
|
+
"pattern",
|
|
1245
|
+
"anti-pattern",
|
|
1246
|
+
"best-practice",
|
|
1247
|
+
"constraint",
|
|
1248
|
+
"heuristic"
|
|
1249
|
+
]).optional(),
|
|
1250
|
+
/** Severity */
|
|
1251
|
+
severity: z.enum([
|
|
1252
|
+
"info",
|
|
1253
|
+
"warning",
|
|
1254
|
+
"error"
|
|
1255
|
+
]).optional(),
|
|
1256
|
+
/** Related pattern IDs */
|
|
1257
|
+
relatedTo: z.array(z.string()).optional(),
|
|
1258
|
+
/** Gap Fields: Outcome type for dashboard tracking (prevented/recovered/monitored) */
|
|
1259
|
+
outcome: z.enum([
|
|
1260
|
+
"prevented",
|
|
1261
|
+
"recovered",
|
|
1262
|
+
"monitored"
|
|
1263
|
+
]).optional(),
|
|
1264
|
+
/** Gap Fields: File categories involved (for risksPreventedContext) */
|
|
1265
|
+
fileCategories: z.array(z.string()).optional(),
|
|
1266
|
+
/** Gap Fields: Blast radius count for the decision */
|
|
1267
|
+
blastRadius: z.number().int().nonnegative().optional(),
|
|
1268
|
+
/** Gap Fields: File path for the event */
|
|
1269
|
+
filePath: z.string().optional(),
|
|
1270
|
+
/** Gap Fields: AI tool detected (cursor/copilot/claude) */
|
|
1271
|
+
aiTool: z.enum([
|
|
1272
|
+
"cursor",
|
|
1273
|
+
"copilot",
|
|
1274
|
+
"claude"
|
|
1275
|
+
]).optional(),
|
|
1276
|
+
/** Gap Fields: Risk level (high/medium/low) */
|
|
1277
|
+
risk: z.enum([
|
|
1278
|
+
"high",
|
|
1279
|
+
"medium",
|
|
1280
|
+
"low"
|
|
1281
|
+
]).optional()
|
|
1282
|
+
});
|
|
1283
|
+
WorkspaceBase.extend({
|
|
1284
|
+
/** Pattern ID or Decision ID */
|
|
1285
|
+
patternId: z.string().min(1),
|
|
1286
|
+
/**
|
|
1287
|
+
* Outcome type
|
|
1288
|
+
* - resolved/regressed/ignored: Original pattern outcomes
|
|
1289
|
+
* - prevented/recovered/monitored: Gap Fields dashboard outcomes
|
|
1290
|
+
*/
|
|
1291
|
+
outcome: z.enum([
|
|
1292
|
+
"resolved",
|
|
1293
|
+
"regressed",
|
|
1294
|
+
"ignored",
|
|
1295
|
+
"prevented",
|
|
1296
|
+
"recovered",
|
|
1297
|
+
"monitored"
|
|
1298
|
+
]),
|
|
1299
|
+
/** Notes */
|
|
1300
|
+
notes: z.string().optional(),
|
|
1301
|
+
/** Gap Fields: Whether decision was reverted within 5min (for accuracy calc) */
|
|
1302
|
+
revertedWithin5Min: z.boolean().optional(),
|
|
1303
|
+
/** Gap Fields: File categories involved */
|
|
1304
|
+
fileCategories: z.array(z.string()).optional()
|
|
1305
|
+
});
|
|
1306
|
+
WorkspaceBase.extend({
|
|
1307
|
+
/** Unique decision ID */
|
|
1308
|
+
decisionId: z.string().min(1),
|
|
1309
|
+
/** Decision outcome */
|
|
1310
|
+
outcome: z.enum([
|
|
1311
|
+
"prevented",
|
|
1312
|
+
"recovered",
|
|
1313
|
+
"monitored",
|
|
1314
|
+
"reverted"
|
|
1315
|
+
]),
|
|
1316
|
+
/** Whether the decision was reverted within 5 minutes */
|
|
1317
|
+
revertedWithin5Min: z.boolean().optional(),
|
|
1318
|
+
/** File categories involved in the decision */
|
|
1319
|
+
fileCategories: z.array(z.string()).optional(),
|
|
1320
|
+
/** Human-readable action taken */
|
|
1321
|
+
action: z.string().optional(),
|
|
1322
|
+
/** Notes */
|
|
1323
|
+
notes: z.string().optional()
|
|
1324
|
+
});
|
|
1325
|
+
WorkspaceBase.extend({
|
|
1326
|
+
/** Minimum fragility score to include (0-1) */
|
|
1327
|
+
minScore: z.number().min(0).max(1).default(0.5),
|
|
1328
|
+
/** Maximum results */
|
|
1329
|
+
limit: z.number().int().min(1).max(50).default(20)
|
|
1330
|
+
});
|
|
1331
|
+
WorkspaceBase.extend({
|
|
1332
|
+
/** Minimum co-occurrence frequency to include (0-1) */
|
|
1333
|
+
minFrequency: z.number().min(0).max(1).default(0.5),
|
|
1334
|
+
/** Filter to patterns involving this file */
|
|
1335
|
+
filePath: z.string().optional(),
|
|
1336
|
+
/** Maximum results */
|
|
1337
|
+
limit: z.number().int().min(1).max(50).default(20)
|
|
1338
|
+
});
|
|
1339
|
+
WorkspaceBase.extend({
|
|
1340
|
+
/** Filter by minimum severity (uses WARNING_SEVERITY_ORDER for comparison) */
|
|
1341
|
+
minLevel: WarningSeverity.default("info"),
|
|
1342
|
+
/** Maximum results */
|
|
1343
|
+
limit: z.number().int().min(1).max(20).default(10)
|
|
1344
|
+
});
|
|
1345
|
+
WorkspaceBase.extend({
|
|
1346
|
+
/** Days to look back (default: 7) */
|
|
1347
|
+
days: z.number().int().min(1).max(30).default(7)
|
|
1348
|
+
});
|
|
1349
|
+
WorkspaceBase.extend({
|
|
1350
|
+
/** Weeks to look back (default: 8) */
|
|
1351
|
+
weeks: z.number().int().min(1).max(12).default(8)
|
|
1352
|
+
});
|
|
1353
|
+
WorkspaceBase.extend({
|
|
1354
|
+
/** Filter to specific files (omit to scan all files in window) */
|
|
1355
|
+
files: z.array(z.string()).optional(),
|
|
1356
|
+
/** Time window to query from the aggregate store */
|
|
1357
|
+
window: z.enum([
|
|
1358
|
+
"7d",
|
|
1359
|
+
"30d",
|
|
1360
|
+
"90d",
|
|
1361
|
+
"all"
|
|
1362
|
+
]).default("30d"),
|
|
1363
|
+
/** Minimum calibrated confidence floor (default: 0.55 = MIN_SURFACE_SCORE) */
|
|
1364
|
+
minConfidence: z.number().min(0).max(1).default(0.55),
|
|
1365
|
+
/** Maximum candidates to return */
|
|
1366
|
+
limit: z.number().int().min(1).max(20).default(10)
|
|
1367
|
+
});
|
|
1368
|
+
WorkspaceBase.extend({
|
|
1369
|
+
profile: z.any().optional(),
|
|
1370
|
+
fragileFiles: z.array(z.any()).optional(),
|
|
1371
|
+
coChangePairs: z.array(z.any()).optional(),
|
|
1372
|
+
temporalRiskWindows: z.array(z.any()).optional(),
|
|
1373
|
+
weightOverrides: z.any().optional(),
|
|
1374
|
+
lockedInsights: z.array(z.any()).optional(),
|
|
1375
|
+
scanCache: z.any().optional()
|
|
1376
|
+
});
|
|
1377
|
+
WorkspaceBase.extend({
|
|
1378
|
+
insightId: z.string()
|
|
1379
|
+
});
|
|
1380
|
+
WorkspaceBase.extend({
|
|
1381
|
+
/** File path (relative to workspace root) */
|
|
1382
|
+
path: z.string().min(1),
|
|
1383
|
+
/** Lines changed */
|
|
1384
|
+
linesChanged: z.number().int().nonnegative().optional(),
|
|
1385
|
+
/** AI-attributed change */
|
|
1386
|
+
aiAttributed: z.boolean().optional(),
|
|
1387
|
+
/** Optional AI tool name if attributed */
|
|
1388
|
+
aiTool: z.enum([
|
|
1389
|
+
"cursor",
|
|
1390
|
+
"copilot",
|
|
1391
|
+
"claude",
|
|
1392
|
+
"windsurf",
|
|
1393
|
+
"burst-pattern"
|
|
1394
|
+
]).optional()
|
|
1395
|
+
});
|
|
1396
|
+
z.object({
|
|
1397
|
+
workspace: z.string().optional()
|
|
1398
|
+
});
|
|
1399
|
+
WorkspaceBase.extend({
|
|
1400
|
+
/** Factors or signals to index (optional, passed by MCP adapter).
|
|
1401
|
+
* Shape: Array<{ name: string; score: number; source: string; description?: string }>
|
|
1402
|
+
*/
|
|
1403
|
+
factors: z.array(z.object({
|
|
1404
|
+
name: z.string(),
|
|
1405
|
+
score: z.number(),
|
|
1406
|
+
source: z.string(),
|
|
1407
|
+
description: z.string().optional()
|
|
1408
|
+
})).optional()
|
|
1409
|
+
});
|
|
1410
|
+
z.object({
|
|
1411
|
+
/** Indexed patterns (currently an empty stub - full implementation deferred) */
|
|
1412
|
+
patterns: z.array(z.unknown()),
|
|
1413
|
+
/** Total pattern count */
|
|
1414
|
+
total: z.number().int().nonnegative()
|
|
1415
|
+
});
|
|
1416
|
+
z.object({
|
|
1417
|
+
/** Whether the outcome was recorded */
|
|
1418
|
+
recorded: z.boolean(),
|
|
1419
|
+
/** The decision ID */
|
|
1420
|
+
decisionId: z.string(),
|
|
1421
|
+
/** The outcome type */
|
|
1422
|
+
outcome: z.string(),
|
|
1423
|
+
/** Whether the decision was reverted within 5 minutes */
|
|
1424
|
+
revertedWithin5Min: z.boolean().optional(),
|
|
1425
|
+
/** Impact on accuracy metric */
|
|
1426
|
+
accuracyImpact: z.enum([
|
|
1427
|
+
"reduced",
|
|
1428
|
+
"maintained"
|
|
1429
|
+
]),
|
|
1430
|
+
/** Optional notes */
|
|
1431
|
+
notes: z.string().optional()
|
|
1432
|
+
});
|
|
1433
|
+
z.object({
|
|
1434
|
+
/** Number of days in the window */
|
|
1435
|
+
days: z.number().int(),
|
|
1436
|
+
/** Number of risks prevented */
|
|
1437
|
+
risksPrevented: z.number().int(),
|
|
1438
|
+
/** Human-readable context about what was prevented */
|
|
1439
|
+
risksPreventedContext: z.string(),
|
|
1440
|
+
/** Daily prevented counts by day of week */
|
|
1441
|
+
dailyPrevented: z.array(z.object({
|
|
1442
|
+
day: z.string(),
|
|
1443
|
+
prevented: z.number().int()
|
|
1444
|
+
})),
|
|
1445
|
+
/** Timeline events within the window */
|
|
1446
|
+
timelineEvents: z.array(z.object({
|
|
1447
|
+
hour: z.number().int(),
|
|
1448
|
+
type: z.enum([
|
|
1449
|
+
"recovery",
|
|
1450
|
+
"ai_detected",
|
|
1451
|
+
"snapshot"
|
|
1452
|
+
]),
|
|
1453
|
+
tool: z.string().optional(),
|
|
1454
|
+
file: z.string(),
|
|
1455
|
+
risk: z.string(),
|
|
1456
|
+
action: z.string(),
|
|
1457
|
+
blast: z.number().optional()
|
|
1458
|
+
})),
|
|
1459
|
+
/** Total decisions in the window */
|
|
1460
|
+
totalDecisions: z.number().int()
|
|
1461
|
+
});
|
|
1462
|
+
z.object({
|
|
1463
|
+
/** Number of weeks in the window */
|
|
1464
|
+
weeks: z.number().int(),
|
|
1465
|
+
/** Weekly velocity data */
|
|
1466
|
+
velocity: z.array(z.object({
|
|
1467
|
+
week: z.string(),
|
|
1468
|
+
learnings: z.number().int(),
|
|
1469
|
+
accuracy: z.number().int()
|
|
1470
|
+
})),
|
|
1471
|
+
/** Overall accuracy percentage (0-100) */
|
|
1472
|
+
overallAccuracy: z.number().int(),
|
|
1473
|
+
/** Session coherence percentage (0-100) */
|
|
1474
|
+
coherencePercent: z.number().int(),
|
|
1475
|
+
/** Ratio string e.g. "3 : 1" */
|
|
1476
|
+
preventedToRecoveredRatio: z.string(),
|
|
1477
|
+
/** Number of prevented decisions */
|
|
1478
|
+
preventedCount: z.number().int(),
|
|
1479
|
+
/** Number of recovered decisions */
|
|
1480
|
+
recoveredCount: z.number().int(),
|
|
1481
|
+
/** Total decisions in the window */
|
|
1482
|
+
totalDecisions: z.number().int()
|
|
1483
|
+
});
|
|
1484
|
+
var GitRiskFactor = z.object({
|
|
1485
|
+
/** Unique identifier for this risk factor */
|
|
1486
|
+
id: z.string(),
|
|
1487
|
+
/** Human-readable label */
|
|
1488
|
+
label: z.string(),
|
|
1489
|
+
/** Contribution to risk multiplier (additive) */
|
|
1490
|
+
contribution: z.number(),
|
|
1491
|
+
/** Severity level */
|
|
1492
|
+
severity: z.enum([
|
|
1493
|
+
"info",
|
|
1494
|
+
"warning",
|
|
1495
|
+
"critical"
|
|
1496
|
+
])
|
|
1497
|
+
});
|
|
1498
|
+
z.object({
|
|
1499
|
+
/** Multiplicative factor applied to base risk score (1.0 = neutral) */
|
|
1500
|
+
multiplier: z.number(),
|
|
1501
|
+
/** Contributing factors that built up the multiplier */
|
|
1502
|
+
factors: z.array(GitRiskFactor),
|
|
1503
|
+
/** Whether git context was available */
|
|
1504
|
+
hasGitContext: z.boolean(),
|
|
1505
|
+
/** Timestamp of evaluation for caching */
|
|
1506
|
+
evaluatedAt: z.number()
|
|
1507
|
+
});
|
|
1508
|
+
z.object({
|
|
1509
|
+
/** Workspace path to evaluate */
|
|
1510
|
+
workspace: z.string()
|
|
1511
|
+
});
|
|
1512
|
+
z.object({
|
|
1513
|
+
/** AI tool that was active when rollback happened */
|
|
1514
|
+
tool: z.string(),
|
|
1515
|
+
/** File extension involved */
|
|
1516
|
+
fileExt: z.string(),
|
|
1517
|
+
/** Number of lines in the rolled-back change */
|
|
1518
|
+
linesChanged: z.number(),
|
|
1519
|
+
/** Programming language */
|
|
1520
|
+
language: z.string(),
|
|
1521
|
+
/** File category classification */
|
|
1522
|
+
fileCategory: z.enum([
|
|
1523
|
+
"config",
|
|
1524
|
+
"code",
|
|
1525
|
+
"test",
|
|
1526
|
+
"docs",
|
|
1527
|
+
"build",
|
|
1528
|
+
"other"
|
|
1529
|
+
]),
|
|
1530
|
+
/** Was it a multi-file change? */
|
|
1531
|
+
fileCount: z.number(),
|
|
1532
|
+
/** Time of day bucket (0-23) for fatigue correlation */
|
|
1533
|
+
hourBucket: z.number().int().min(0).max(23),
|
|
1534
|
+
/** Session duration at rollback time (minutes) */
|
|
1535
|
+
sessionMinutes: z.number(),
|
|
1536
|
+
/** Workspace where rollback occurred */
|
|
1537
|
+
workspace: z.string(),
|
|
1538
|
+
/** Timestamp of rollback */
|
|
1539
|
+
timestamp: z.number()
|
|
1540
|
+
});
|
|
1541
|
+
z.object({
|
|
1542
|
+
/** Confidence that this matches a known failure pattern (0-1) */
|
|
1543
|
+
confidence: z.number().min(0).max(1),
|
|
1544
|
+
/** Human-readable warning message */
|
|
1545
|
+
message: z.string(),
|
|
1546
|
+
/** Number of similar rollbacks in the cluster */
|
|
1547
|
+
clusterSize: z.number(),
|
|
1548
|
+
/** Dominant factors in the cluster */
|
|
1549
|
+
dominantFactors: z.array(z.string()),
|
|
1550
|
+
/** Risk boost to apply (additive) */
|
|
1551
|
+
riskBoost: z.number()
|
|
1552
|
+
});
|
|
1553
|
+
z.object({
|
|
1554
|
+
/** Workspace where rollback occurred */
|
|
1555
|
+
workspace: z.string(),
|
|
1556
|
+
/** AI tool that was active */
|
|
1557
|
+
tool: z.string(),
|
|
1558
|
+
/** File extension */
|
|
1559
|
+
fileExt: z.string(),
|
|
1560
|
+
/** Lines changed */
|
|
1561
|
+
linesChanged: z.number(),
|
|
1562
|
+
/** Programming language */
|
|
1563
|
+
language: z.string(),
|
|
1564
|
+
/** File category */
|
|
1565
|
+
fileCategory: z.enum([
|
|
1566
|
+
"config",
|
|
1567
|
+
"code",
|
|
1568
|
+
"test",
|
|
1569
|
+
"docs",
|
|
1570
|
+
"build",
|
|
1571
|
+
"other"
|
|
1572
|
+
]),
|
|
1573
|
+
/** File count */
|
|
1574
|
+
fileCount: z.number(),
|
|
1575
|
+
/** Session duration in minutes */
|
|
1576
|
+
sessionMinutes: z.number()
|
|
1577
|
+
});
|
|
1578
|
+
z.object({
|
|
1579
|
+
/** Workspace to check */
|
|
1580
|
+
workspace: z.string(),
|
|
1581
|
+
/** AI tool making the change */
|
|
1582
|
+
tool: z.string(),
|
|
1583
|
+
/** File extension */
|
|
1584
|
+
fileExt: z.string(),
|
|
1585
|
+
/** Lines being changed */
|
|
1586
|
+
linesChanged: z.number(),
|
|
1587
|
+
/** Programming language */
|
|
1588
|
+
language: z.string(),
|
|
1589
|
+
/** File category */
|
|
1590
|
+
fileCategory: z.enum([
|
|
1591
|
+
"config",
|
|
1592
|
+
"code",
|
|
1593
|
+
"test",
|
|
1594
|
+
"docs",
|
|
1595
|
+
"build",
|
|
1596
|
+
"other"
|
|
1597
|
+
]),
|
|
1598
|
+
/** File count in change */
|
|
1599
|
+
fileCount: z.number(),
|
|
1600
|
+
/** Current session duration */
|
|
1601
|
+
sessionMinutes: z.number()
|
|
1602
|
+
});
|
|
1603
|
+
z.object({
|
|
1604
|
+
/** Workspace to get stats for */
|
|
1605
|
+
workspace: z.string()
|
|
1606
|
+
});
|
|
1607
|
+
z.object({
|
|
1608
|
+
/** Total rollbacks recorded */
|
|
1609
|
+
totalRollbacks: z.number(),
|
|
1610
|
+
/** Number of distinct clusters */
|
|
1611
|
+
clusters: z.number(),
|
|
1612
|
+
/** Size of largest cluster */
|
|
1613
|
+
largestCluster: z.number()
|
|
1614
|
+
});
|
|
1615
|
+
z.object({
|
|
1616
|
+
/** Additive risk boost (0.0 - 0.5) */
|
|
1617
|
+
riskBoost: z.number().min(0).max(0.5),
|
|
1618
|
+
/** Human-readable fatigue level */
|
|
1619
|
+
level: z.enum([
|
|
1620
|
+
"rested",
|
|
1621
|
+
"normal",
|
|
1622
|
+
"elevated",
|
|
1623
|
+
"fatigued"
|
|
1624
|
+
]),
|
|
1625
|
+
/** Ratio of rapid accepts in the window (0-1) */
|
|
1626
|
+
rapidAcceptRatio: z.number().min(0).max(1),
|
|
1627
|
+
/** Current accept velocity (accepts per minute) */
|
|
1628
|
+
velocityPerMinute: z.number(),
|
|
1629
|
+
/** Session duration contributing to assessment */
|
|
1630
|
+
sessionMinutes: z.number(),
|
|
1631
|
+
/** Contributing factors to the assessment */
|
|
1632
|
+
factors: z.array(z.string())
|
|
1633
|
+
});
|
|
1634
|
+
z.object({
|
|
1635
|
+
/** Workspace to assess */
|
|
1636
|
+
workspace: z.string()
|
|
1637
|
+
});
|
|
1638
|
+
var AnnotationTag = z.enum([
|
|
1639
|
+
"good_state",
|
|
1640
|
+
"before_refactor",
|
|
1641
|
+
"it_broke_here",
|
|
1642
|
+
"uncertain",
|
|
1643
|
+
"ai_diverged",
|
|
1644
|
+
"manual_recovery",
|
|
1645
|
+
"shipped"
|
|
1646
|
+
]);
|
|
1647
|
+
z.object({
|
|
1648
|
+
/** Snapshot hash (content-addressable ID) */
|
|
1649
|
+
snapshotHash: z.string(),
|
|
1650
|
+
/** Annotation tag */
|
|
1651
|
+
tag: AnnotationTag,
|
|
1652
|
+
/** Optional freeform note (max 280 chars) */
|
|
1653
|
+
note: z.string().max(280).optional(),
|
|
1654
|
+
/** Active AI tool at time of annotation */
|
|
1655
|
+
aiTool: z.string().optional(),
|
|
1656
|
+
/** Files in the snapshot */
|
|
1657
|
+
fileCount: z.number(),
|
|
1658
|
+
/** Risk score at time of annotation */
|
|
1659
|
+
riskScore: z.number().optional(),
|
|
1660
|
+
/** Timestamp */
|
|
1661
|
+
timestamp: z.number(),
|
|
1662
|
+
/** Workspace */
|
|
1663
|
+
workspace: z.string()
|
|
1664
|
+
});
|
|
1665
|
+
z.object({
|
|
1666
|
+
/** Snapshot hash to annotate */
|
|
1667
|
+
snapshotHash: z.string(),
|
|
1668
|
+
/** Annotation tag */
|
|
1669
|
+
tag: AnnotationTag,
|
|
1670
|
+
/** Optional note */
|
|
1671
|
+
note: z.string().max(280).optional(),
|
|
1672
|
+
/** AI tool active */
|
|
1673
|
+
aiTool: z.string().optional(),
|
|
1674
|
+
/** File count */
|
|
1675
|
+
fileCount: z.number(),
|
|
1676
|
+
/** Risk score at time */
|
|
1677
|
+
riskScore: z.number().optional(),
|
|
1678
|
+
/** Workspace */
|
|
1679
|
+
workspace: z.string()
|
|
1680
|
+
});
|
|
1681
|
+
z.object({
|
|
1682
|
+
/** Whether annotation was recorded */
|
|
1683
|
+
recorded: z.boolean(),
|
|
1684
|
+
/** Risk signal from the annotation */
|
|
1685
|
+
riskSignal: z.object({
|
|
1686
|
+
direction: z.enum([
|
|
1687
|
+
"increase",
|
|
1688
|
+
"decrease",
|
|
1689
|
+
"neutral"
|
|
1690
|
+
]),
|
|
1691
|
+
magnitude: z.number()
|
|
1692
|
+
})
|
|
1693
|
+
});
|
|
1694
|
+
z.object({
|
|
1695
|
+
/** Workspace to query */
|
|
1696
|
+
workspace: z.string(),
|
|
1697
|
+
/** Filter by timestamp (ms since epoch) */
|
|
1698
|
+
since: z.number().optional(),
|
|
1699
|
+
/** Filter by tags */
|
|
1700
|
+
tags: z.array(AnnotationTag).optional(),
|
|
1701
|
+
/** Limit number of results */
|
|
1702
|
+
limit: z.number().optional()
|
|
1703
|
+
});
|
|
1704
|
+
z.object({
|
|
1705
|
+
/** Workspace to get calibration for */
|
|
1706
|
+
workspace: z.string()
|
|
1707
|
+
});
|
|
1708
|
+
z.object({
|
|
1709
|
+
/** Net risk adjustment from historical annotations */
|
|
1710
|
+
netAdjustment: z.number().min(-0.5).max(0.5),
|
|
1711
|
+
/** Number of annotations considered */
|
|
1712
|
+
annotationCount: z.number(),
|
|
1713
|
+
/** Breakdown by tag */
|
|
1714
|
+
breakdown: z.record(AnnotationTag, z.number())
|
|
1715
|
+
});
|
|
1716
|
+
z.object({
|
|
1717
|
+
/** Whether poisoning was detected */
|
|
1718
|
+
isPoisoned: z.boolean(),
|
|
1719
|
+
/** How many times this pattern has been rejected */
|
|
1720
|
+
occurrences: z.number(),
|
|
1721
|
+
/** How many distinct sessions it appeared in */
|
|
1722
|
+
distinctSessions: z.number(),
|
|
1723
|
+
/** Risk boost to apply if poisoned */
|
|
1724
|
+
riskBoost: z.number(),
|
|
1725
|
+
/** Human-readable warning */
|
|
1726
|
+
warning: z.string().optional(),
|
|
1727
|
+
/** Structural fingerprint (for debugging) */
|
|
1728
|
+
fingerprint: z.string().optional()
|
|
1729
|
+
});
|
|
1730
|
+
z.object({
|
|
1731
|
+
/** Workspace to check */
|
|
1732
|
+
workspace: z.string(),
|
|
1733
|
+
/** Unified diff of proposed change */
|
|
1734
|
+
diff: z.string()
|
|
1735
|
+
});
|
|
1736
|
+
z.object({
|
|
1737
|
+
/** Workspace where rejection occurred */
|
|
1738
|
+
workspace: z.string(),
|
|
1739
|
+
/** Diff that was rejected */
|
|
1740
|
+
diff: z.string(),
|
|
1741
|
+
/** Session ID */
|
|
1742
|
+
sessionId: z.string(),
|
|
1743
|
+
/** AI tool involved */
|
|
1744
|
+
tool: z.string().optional(),
|
|
1745
|
+
/** File extension */
|
|
1746
|
+
fileExt: z.string().optional()
|
|
1747
|
+
});
|
|
1748
|
+
z.object({
|
|
1749
|
+
/** Workspace to get stats for */
|
|
1750
|
+
workspace: z.string()
|
|
1751
|
+
});
|
|
1752
|
+
z.object({
|
|
1753
|
+
/** Number of patterns being tracked */
|
|
1754
|
+
trackedPatterns: z.number(),
|
|
1755
|
+
/** Number of poisoned patterns (>= threshold) */
|
|
1756
|
+
poisonedPatterns: z.number(),
|
|
1757
|
+
/** Top tools involved in poisoning */
|
|
1758
|
+
topTools: z.array(z.string())
|
|
1759
|
+
});
|
|
1760
|
+
var SafeToWriteAction = z.enum([
|
|
1761
|
+
"PROCEED",
|
|
1762
|
+
"PROCEED_WITH_SNAPSHOT",
|
|
1763
|
+
"WARN",
|
|
1764
|
+
"BLOCK"
|
|
1765
|
+
]);
|
|
1766
|
+
var SafeToWriteFactor = z.object({
|
|
1767
|
+
/** Source of the factor (which pillar) */
|
|
1768
|
+
source: z.string(),
|
|
1769
|
+
/** Score contribution */
|
|
1770
|
+
score: z.number(),
|
|
1771
|
+
/** Description of the factor */
|
|
1772
|
+
description: z.string()
|
|
1773
|
+
});
|
|
1774
|
+
var AlternativeAction = z.object({
|
|
1775
|
+
/** Tool to use instead */
|
|
1776
|
+
tool: z.string(),
|
|
1777
|
+
/** Description of what to do */
|
|
1778
|
+
description: z.string(),
|
|
1779
|
+
/** Optional parameters for the tool */
|
|
1780
|
+
params: z.record(z.string(), z.unknown()).optional()
|
|
1781
|
+
});
|
|
1782
|
+
z.object({
|
|
1783
|
+
/** Whether the write is allowed */
|
|
1784
|
+
allowed: z.boolean(),
|
|
1785
|
+
/** Action to take */
|
|
1786
|
+
action: SafeToWriteAction,
|
|
1787
|
+
/** Composite risk score (capped at 2.5) */
|
|
1788
|
+
riskScore: z.number(),
|
|
1789
|
+
/** Contributing factors from all pillars */
|
|
1790
|
+
factors: z.array(SafeToWriteFactor),
|
|
1791
|
+
/** Human-readable recommendation */
|
|
1792
|
+
recommendation: z.string(),
|
|
1793
|
+
/** Snapshot hash if auto-created */
|
|
1794
|
+
snapshotHash: z.string().optional(),
|
|
1795
|
+
/** Whether the operation can be retried */
|
|
1796
|
+
retryable: z.boolean(),
|
|
1797
|
+
/** Alternative actions to take instead */
|
|
1798
|
+
alternativeActions: z.array(AlternativeAction)
|
|
1799
|
+
});
|
|
1800
|
+
z.object({
|
|
1801
|
+
/** Workspace path */
|
|
1802
|
+
workspace: z.string(),
|
|
1803
|
+
/** File path being written */
|
|
1804
|
+
filePath: z.string(),
|
|
1805
|
+
/** Proposed diff */
|
|
1806
|
+
proposedDiff: z.string(),
|
|
1807
|
+
/** AI tool making the change */
|
|
1808
|
+
tool: z.string().optional(),
|
|
1809
|
+
/** Intent of the change */
|
|
1810
|
+
intent: z.string().optional()
|
|
1811
|
+
});
|
|
1812
|
+
WorkspaceBase.extend({
|
|
1813
|
+
/** Single file path (daemon shape) */
|
|
1814
|
+
filePath: z.string().optional(),
|
|
1815
|
+
/** Array of file paths (MCP shape) */
|
|
1816
|
+
files: z.array(z.string()).optional(),
|
|
1817
|
+
/** Proposed diff content */
|
|
1818
|
+
proposedDiff: z.string().optional(),
|
|
1819
|
+
/** AI tool making the request */
|
|
1820
|
+
tool: z.string().optional(),
|
|
1821
|
+
/** Intent of the change */
|
|
1822
|
+
intent: z.string().optional(),
|
|
1823
|
+
/** Session ID (daemon shape - top-level) */
|
|
1824
|
+
sessionId: z.string().optional(),
|
|
1825
|
+
/** Context object (MCP shape - nested) */
|
|
1826
|
+
context: z.object({
|
|
1827
|
+
task: z.string().optional(),
|
|
1828
|
+
sessionId: z.string().optional()
|
|
1829
|
+
}).optional()
|
|
1830
|
+
});
|
|
1831
|
+
WorkspaceBase.extend({
|
|
1832
|
+
/** Learning type */
|
|
1833
|
+
type: LearningType,
|
|
1834
|
+
/** Trigger condition */
|
|
1835
|
+
trigger: z.string().min(1),
|
|
1836
|
+
/** Action to take */
|
|
1837
|
+
action: z.string().min(1),
|
|
1838
|
+
/** Source of the learning */
|
|
1839
|
+
source: z.string().optional()
|
|
1840
|
+
});
|
|
1841
|
+
WorkspaceBase.extend({
|
|
1842
|
+
/** Keywords to search */
|
|
1843
|
+
keywords: z.array(z.string()).min(1),
|
|
1844
|
+
/** Max results */
|
|
1845
|
+
limit: z.number().int().min(1).max(100).optional()
|
|
1846
|
+
});
|
|
1847
|
+
WorkspaceBase.extend({
|
|
1848
|
+
/** Max results */
|
|
1849
|
+
limit: z.number().int().min(1).max(200).optional()
|
|
1850
|
+
});
|
|
1851
|
+
WorkspaceBase.extend({
|
|
1852
|
+
/** Command being evaluated */
|
|
1853
|
+
commandName: z.string().min(1),
|
|
1854
|
+
/** Command arguments */
|
|
1855
|
+
args: z.record(z.unknown()).optional(),
|
|
1856
|
+
/** Files or paths involved */
|
|
1857
|
+
filesOrPaths: z.array(z.string()).optional(),
|
|
1858
|
+
/** Intent of the command */
|
|
1859
|
+
intent: z.enum([
|
|
1860
|
+
"implement",
|
|
1861
|
+
"debug",
|
|
1862
|
+
"refactor",
|
|
1863
|
+
"review"
|
|
1864
|
+
]).optional(),
|
|
1865
|
+
/** Learning mode */
|
|
1866
|
+
mode: z.enum([
|
|
1867
|
+
"observe",
|
|
1868
|
+
"warn",
|
|
1869
|
+
"apply-safe",
|
|
1870
|
+
"apply-all",
|
|
1871
|
+
"off"
|
|
1872
|
+
]).optional()
|
|
1873
|
+
});
|
|
1874
|
+
WorkspaceBase.extend({
|
|
1875
|
+
/** Session ID */
|
|
1876
|
+
sessionId: z.string().min(1),
|
|
1877
|
+
/** Learning IDs to associate */
|
|
1878
|
+
learningIds: z.array(z.string())
|
|
1879
|
+
});
|
|
1880
|
+
WorkspaceBase.extend({
|
|
1881
|
+
/** GC operation */
|
|
1882
|
+
operation: z.enum([
|
|
1883
|
+
"archive",
|
|
1884
|
+
"delete",
|
|
1885
|
+
"all"
|
|
1886
|
+
]).optional(),
|
|
1887
|
+
/** Dry run (audit only) */
|
|
1888
|
+
dryRun: z.boolean().default(true)
|
|
1889
|
+
});
|
|
1890
|
+
z.object({
|
|
1891
|
+
workspace: z.string().min(1),
|
|
1892
|
+
patternKey: z.string().min(1),
|
|
1893
|
+
patternType: z.string().min(1),
|
|
1894
|
+
confidence: z.number().min(0).max(1)
|
|
1895
|
+
});
|
|
1896
|
+
z.object({
|
|
1897
|
+
workspace: z.string().min(1),
|
|
1898
|
+
maxBatchSize: z.number().int().positive().max(1e3).optional()
|
|
1899
|
+
});
|
|
1900
|
+
z.object({
|
|
1901
|
+
workspace: z.string().min(1),
|
|
1902
|
+
syncedIds: z.array(z.string()),
|
|
1903
|
+
failedIds: z.array(z.string())
|
|
1904
|
+
});
|
|
1905
|
+
z.object({
|
|
1906
|
+
success: z.boolean(),
|
|
1907
|
+
learningId: z.string(),
|
|
1908
|
+
type: z.string(),
|
|
1909
|
+
trigger: z.string(),
|
|
1910
|
+
action: z.string(),
|
|
1911
|
+
confidence: z.number(),
|
|
1912
|
+
captureMethod: z.string()
|
|
1913
|
+
});
|
|
1914
|
+
var LearningEntryItem = z.object({
|
|
1915
|
+
type: z.string(),
|
|
1916
|
+
trigger: z.string(),
|
|
1917
|
+
action: z.string(),
|
|
1918
|
+
relevanceScore: z.number().optional()
|
|
1919
|
+
});
|
|
1920
|
+
z.object({
|
|
1921
|
+
learnings: z.array(LearningEntryItem),
|
|
1922
|
+
total: z.number().int()
|
|
1923
|
+
});
|
|
1924
|
+
z.object({
|
|
1925
|
+
learnings: z.array(z.object({
|
|
1926
|
+
type: z.string(),
|
|
1927
|
+
trigger: z.string(),
|
|
1928
|
+
action: z.string()
|
|
1929
|
+
})),
|
|
1930
|
+
total: z.number().int()
|
|
1931
|
+
});
|
|
1932
|
+
z.object({
|
|
1933
|
+
pruned: z.number().int(),
|
|
1934
|
+
remaining: z.number().int(),
|
|
1935
|
+
categories: z.object({
|
|
1936
|
+
lowConfidence: z.number().int(),
|
|
1937
|
+
stale: z.number().int(),
|
|
1938
|
+
duplicates: z.number().int()
|
|
1939
|
+
})
|
|
1940
|
+
});
|
|
1941
|
+
z.object({
|
|
1942
|
+
operation: z.string(),
|
|
1943
|
+
dryRun: z.boolean(),
|
|
1944
|
+
collected: z.number().int(),
|
|
1945
|
+
remaining: z.number().int(),
|
|
1946
|
+
categories: z.object({
|
|
1947
|
+
malformed: z.number().int(),
|
|
1948
|
+
invalidType: z.number().int(),
|
|
1949
|
+
emptyContent: z.number().int()
|
|
1950
|
+
})
|
|
1951
|
+
});
|
|
1952
|
+
z.object({
|
|
1953
|
+
applicable: z.array(LearningEntryItem),
|
|
1954
|
+
mode: z.string(),
|
|
1955
|
+
commandName: z.string()
|
|
1956
|
+
});
|
|
1957
|
+
z.object({
|
|
1958
|
+
success: z.boolean(),
|
|
1959
|
+
sessionId: z.string(),
|
|
1960
|
+
updated: z.number().int()
|
|
1961
|
+
});
|
|
1962
|
+
z.object({
|
|
1963
|
+
seeded: z.boolean(),
|
|
1964
|
+
learningsAdded: z.number().int(),
|
|
1965
|
+
tiers: z.object({
|
|
1966
|
+
hot: z.number().int(),
|
|
1967
|
+
warm: z.number().int(),
|
|
1968
|
+
cold: z.number().int()
|
|
1969
|
+
}),
|
|
1970
|
+
alreadySeeded: z.boolean(),
|
|
1971
|
+
framework: z.string().nullable()
|
|
1972
|
+
});
|
|
1973
|
+
z.object({
|
|
1974
|
+
success: z.boolean(),
|
|
1975
|
+
originalCount: z.number().int(),
|
|
1976
|
+
consolidatedCount: z.number().int(),
|
|
1977
|
+
duplicatesFound: z.number().int(),
|
|
1978
|
+
reductionPercent: z.number(),
|
|
1979
|
+
archivePath: z.string(),
|
|
1980
|
+
dryRun: z.boolean()
|
|
1981
|
+
});
|
|
1982
|
+
z.object({
|
|
1983
|
+
success: z.boolean(),
|
|
1984
|
+
newConfidence: z.number().optional(),
|
|
1985
|
+
error: z.string().optional()
|
|
1986
|
+
});
|
|
1987
|
+
z.object({
|
|
1988
|
+
promoted: z.boolean(),
|
|
1989
|
+
observationCount: z.number().int(),
|
|
1990
|
+
patternId: z.string()
|
|
1991
|
+
});
|
|
1992
|
+
var CanonicalVerb = z.enum([
|
|
1993
|
+
// File operations
|
|
1994
|
+
"WRITE_FILE",
|
|
1995
|
+
"EDIT_FILE",
|
|
1996
|
+
"DELETE_FILE",
|
|
1997
|
+
"READ_FILE",
|
|
1998
|
+
// Reasoning
|
|
1999
|
+
"PLAN",
|
|
2000
|
+
"REVIEW",
|
|
2001
|
+
"DECIDE",
|
|
2002
|
+
// Verification
|
|
2003
|
+
"VERIFY_GATE",
|
|
2004
|
+
// Session lifecycle
|
|
2005
|
+
"SESSION_START",
|
|
2006
|
+
"SESSION_END",
|
|
2007
|
+
"SESSION_HEARTBEAT",
|
|
2008
|
+
// Snapshot operations
|
|
2009
|
+
"SNAPSHOT_CREATE",
|
|
2010
|
+
"SNAPSHOT_RESTORE",
|
|
2011
|
+
"SNAPSHOT_ROLLBACK",
|
|
2012
|
+
// Phase events
|
|
2013
|
+
"PHASE_START",
|
|
2014
|
+
"PHASE_END",
|
|
2015
|
+
// Catchall for extension
|
|
2016
|
+
"OTHER"
|
|
2017
|
+
]);
|
|
2018
|
+
z.object({
|
|
2019
|
+
/** Surface identifier (e.g. "vscode:session-abc123", "cli:run-xyz") */
|
|
2020
|
+
surfaceId: z.string(),
|
|
2021
|
+
/** Workspace fingerprint: sha256("gitRemote:userId") from sync-client.ts */
|
|
2022
|
+
workspaceFingerprint: z.string(),
|
|
2023
|
+
/** Per-surface monotonic sequence number for ordering (WAL-06 interleave resolution) */
|
|
2024
|
+
seq: z.number().int().min(0),
|
|
2025
|
+
/** Epoch milliseconds */
|
|
2026
|
+
ts: z.number().int().positive(),
|
|
2027
|
+
/** Canonical action verb */
|
|
2028
|
+
verb: CanonicalVerb,
|
|
2029
|
+
/**
|
|
2030
|
+
* Event metadata — NO file content permitted (ARCH-03).
|
|
2031
|
+
* Allowed: file paths (relative), hashes, counts, durations, error codes.
|
|
2032
|
+
*/
|
|
2033
|
+
meta: z.record(z.unknown())
|
|
2034
|
+
});
|
|
2035
|
+
z.object({
|
|
2036
|
+
/** WAL file offset after the appended entry (byte position) */
|
|
2037
|
+
offset: z.number().int().min(0),
|
|
2038
|
+
/** Acknowledged: true if write was confirmed synchronous (appendFileSync) */
|
|
2039
|
+
acked: z.boolean()
|
|
2040
|
+
});
|
|
2041
|
+
z.object({
|
|
2042
|
+
/** Session ID to recover */
|
|
2043
|
+
sessionId: z.string(),
|
|
2044
|
+
/** Workspace fingerprint (routing key to the correct WAL file) */
|
|
2045
|
+
workspaceFingerprint: z.string()
|
|
2046
|
+
});
|
|
2047
|
+
var VerbSummary = z.record(z.number().int().min(0));
|
|
2048
|
+
var LedgerRecoverResult = z.object({
|
|
2049
|
+
/** Session ID that was recovered */
|
|
2050
|
+
sessionId: z.string(),
|
|
2051
|
+
/** Session start timestamp (epoch ms) */
|
|
2052
|
+
sessionStartTs: z.number().int().positive(),
|
|
2053
|
+
/** Handle expiry timestamp (epoch ms) — when the in-memory cursor closed */
|
|
2054
|
+
expiryTs: z.number().int().positive().nullable(),
|
|
2055
|
+
/** Expiry reason */
|
|
2056
|
+
expiryReason: z.enum([
|
|
2057
|
+
"idle-timeout",
|
|
2058
|
+
"daemon-restart",
|
|
2059
|
+
"explicit-end",
|
|
2060
|
+
"unknown"
|
|
2061
|
+
]),
|
|
2062
|
+
/** Timestamp of last heartbeat event in WAL (epoch ms) */
|
|
2063
|
+
lastHeartbeatTs: z.number().int().positive().nullable(),
|
|
2064
|
+
/** Timestamp of last event in WAL (epoch ms) */
|
|
2065
|
+
lastEventTs: z.number().int().positive().nullable(),
|
|
2066
|
+
/** Total event count captured before expiry */
|
|
2067
|
+
eventCount: z.number().int().min(0),
|
|
2068
|
+
/** Per-verb count summary */
|
|
2069
|
+
verbSummary: VerbSummary,
|
|
2070
|
+
/** Whether a ceremony was computed from the recovered events */
|
|
2071
|
+
ceremonyAvailable: z.boolean(),
|
|
2072
|
+
/** Ceremony payload (null if insufficient events for ceremony) */
|
|
2073
|
+
ceremony: z.record(z.unknown()).nullable()
|
|
2074
|
+
});
|
|
2075
|
+
z.object({
|
|
2076
|
+
/** Session ID that may be expired */
|
|
2077
|
+
sessionId: z.string(),
|
|
2078
|
+
/** Surface that is calling end */
|
|
2079
|
+
surfaceId: z.string(),
|
|
2080
|
+
/** Workspace fingerprint */
|
|
2081
|
+
workspaceFingerprint: z.string()
|
|
2082
|
+
});
|
|
2083
|
+
z.object({
|
|
2084
|
+
/** Whether the session was found active, recovered from WAL, or not found at all */
|
|
2085
|
+
disposition: z.enum([
|
|
2086
|
+
"active",
|
|
2087
|
+
"recovered-from-wal",
|
|
2088
|
+
"not-found"
|
|
2089
|
+
]),
|
|
2090
|
+
/** Recovery result if disposition is "recovered-from-wal" */
|
|
2091
|
+
recovery: LedgerRecoverResult.nullable()
|
|
2092
|
+
});
|
|
2093
|
+
WorkspaceBase.extend({
|
|
2094
|
+
/** Snapshot ID */
|
|
2095
|
+
id: z.string().min(1),
|
|
2096
|
+
/** File path */
|
|
2097
|
+
filePath: z.string().optional(),
|
|
2098
|
+
/** Trigger type */
|
|
2099
|
+
trigger: z.enum([
|
|
2100
|
+
"manual",
|
|
2101
|
+
"auto",
|
|
2102
|
+
"ai-detection"
|
|
2103
|
+
]).optional(),
|
|
2104
|
+
/** Source surface */
|
|
2105
|
+
source: z.enum([
|
|
2106
|
+
"mcp",
|
|
2107
|
+
"cli",
|
|
2108
|
+
"extension"
|
|
2109
|
+
]).optional()
|
|
2110
|
+
});
|
|
2111
|
+
WorkspaceBase.extend({
|
|
2112
|
+
/** File path */
|
|
2113
|
+
path: z.string().min(1),
|
|
2114
|
+
/** Lines changed */
|
|
2115
|
+
linesChanged: z.number().int().nonnegative().optional(),
|
|
2116
|
+
/** AI-attributed change */
|
|
2117
|
+
aiAttributed: z.boolean().optional(),
|
|
2118
|
+
/** AI tool that made the change */
|
|
2119
|
+
aiTool: z.enum([
|
|
2120
|
+
"cursor",
|
|
2121
|
+
"copilot",
|
|
2122
|
+
"claude",
|
|
2123
|
+
"windsurf",
|
|
2124
|
+
"burst-pattern"
|
|
2125
|
+
]).optional()
|
|
2126
|
+
});
|
|
2127
|
+
WorkspaceBase.extend({
|
|
2128
|
+
/** Entry type */
|
|
2129
|
+
type: MemoryEntryType,
|
|
2130
|
+
/** Entry data */
|
|
2131
|
+
data: z.record(z.unknown()),
|
|
2132
|
+
/** TTL in days (0 = permanent) */
|
|
2133
|
+
ttlDays: z.number().int().min(0).default(0)
|
|
2134
|
+
});
|
|
2135
|
+
WorkspaceBase.extend({
|
|
2136
|
+
/** Entry IDs to retrieve */
|
|
2137
|
+
ids: z.array(z.string().min(1)).min(1)
|
|
2138
|
+
});
|
|
2139
|
+
WorkspaceBase.extend({
|
|
2140
|
+
/** Filter by type */
|
|
2141
|
+
type: MemoryEntryType.optional(),
|
|
2142
|
+
/** Keywords to match */
|
|
2143
|
+
keywords: z.array(z.string()).optional(),
|
|
2144
|
+
/** Minimum relevance score (0-1) */
|
|
2145
|
+
minRelevance: z.number().min(0).max(1).default(0.3),
|
|
2146
|
+
/** Maximum results */
|
|
2147
|
+
limit: z.number().int().min(1).max(100).default(50),
|
|
2148
|
+
/** Created after timestamp */
|
|
2149
|
+
since: z.number().optional()
|
|
2150
|
+
});
|
|
2151
|
+
WorkspaceBase.extend({
|
|
2152
|
+
/** Preview only (don't modify) */
|
|
2153
|
+
dryRun: z.boolean().default(false)
|
|
2154
|
+
});
|
|
2155
|
+
WorkspaceBase.extend({
|
|
2156
|
+
/** Compare against this commit (default HEAD~10) */
|
|
2157
|
+
since: z.string().optional(),
|
|
2158
|
+
/** Force full re-fit */
|
|
2159
|
+
full: z.boolean().optional()
|
|
2160
|
+
});
|
|
2161
|
+
WorkspaceBase.extend({
|
|
2162
|
+
/** File path to score */
|
|
2163
|
+
filePath: z.string().min(1)
|
|
2164
|
+
});
|
|
2165
|
+
WorkspaceBase.extend({
|
|
2166
|
+
/** Quick mode (git + AST only) */
|
|
2167
|
+
quick: z.boolean().optional()
|
|
2168
|
+
});
|
|
2169
|
+
z.object({
|
|
2170
|
+
/** File path to evaluate */
|
|
2171
|
+
filePath: z.string().min(1),
|
|
2172
|
+
/** Current file content (optional, reads from disk if omitted) */
|
|
2173
|
+
content: z.string().optional(),
|
|
2174
|
+
/** Additional context for evaluation (optional) */
|
|
2175
|
+
context: z.object({
|
|
2176
|
+
/** Number of recent changes to the file */
|
|
2177
|
+
recentChanges: z.number().int().nonnegative().optional(),
|
|
2178
|
+
/** Milliseconds since last save */
|
|
2179
|
+
timeSinceLastSave: z.number().int().nonnegative().optional(),
|
|
2180
|
+
/** Whether an AI tool is currently active */
|
|
2181
|
+
aiToolActive: z.boolean().optional()
|
|
2182
|
+
}).optional()
|
|
2183
|
+
});
|
|
2184
|
+
z.object({
|
|
2185
|
+
/** File paths to get protection levels for */
|
|
2186
|
+
filePaths: z.array(z.string().min(1)).min(1).max(100)
|
|
2187
|
+
});
|
|
2188
|
+
z.object({
|
|
2189
|
+
/** File path to set protection for */
|
|
2190
|
+
filePath: z.string().min(1),
|
|
2191
|
+
/** Protection level to set ("auto" to reset to automatic) */
|
|
2192
|
+
level: z.enum([
|
|
2193
|
+
"watch",
|
|
2194
|
+
"warn",
|
|
2195
|
+
"block",
|
|
2196
|
+
"auto"
|
|
2197
|
+
]),
|
|
2198
|
+
/** Scope of the protection rule */
|
|
2199
|
+
scope: z.enum([
|
|
2200
|
+
"file",
|
|
2201
|
+
"directory",
|
|
2202
|
+
"pattern"
|
|
2203
|
+
]).default("file"),
|
|
2204
|
+
/** Pattern for pattern-based rules (glob syntax) (optional) */
|
|
2205
|
+
pattern: z.string().optional()
|
|
2206
|
+
});
|
|
2207
|
+
WorkspaceBase.extend({
|
|
2208
|
+
/** File path */
|
|
2209
|
+
filePath: z.string().min(1)
|
|
2210
|
+
});
|
|
2211
|
+
WorkspaceBase.extend({
|
|
2212
|
+
/** File path */
|
|
2213
|
+
filePath: z.string().min(1),
|
|
2214
|
+
/** Protection level */
|
|
2215
|
+
level: ProtectionLevel,
|
|
2216
|
+
/** Reason for setting level */
|
|
2217
|
+
reason: z.string().optional()
|
|
2218
|
+
});
|
|
2219
|
+
WorkspaceBase.extend({
|
|
2220
|
+
/** Filter by level */
|
|
2221
|
+
level: ProtectionLevel.optional(),
|
|
2222
|
+
/** Max results */
|
|
2223
|
+
limit: z.number().int().min(1).max(500).optional()
|
|
2224
|
+
});
|
|
2225
|
+
z.object({
|
|
2226
|
+
/** Protection level assigned */
|
|
2227
|
+
level: ProtectionLevel,
|
|
2228
|
+
/** Whether protection was assigned automatically */
|
|
2229
|
+
automatic: z.boolean(),
|
|
2230
|
+
/** Source of the protection decision */
|
|
2231
|
+
source: z.string(),
|
|
2232
|
+
/** Confidence score (0-1) */
|
|
2233
|
+
confidence: z.number().min(0).max(1),
|
|
2234
|
+
/** Risk score (0-100) */
|
|
2235
|
+
riskScore: z.number().min(0).max(100),
|
|
2236
|
+
/** Recommended action */
|
|
2237
|
+
recommendation: z.string(),
|
|
2238
|
+
/** Contributing risk factors */
|
|
2239
|
+
factors: z.array(z.object({
|
|
2240
|
+
name: z.string(),
|
|
2241
|
+
score: z.number(),
|
|
2242
|
+
description: z.string(),
|
|
2243
|
+
source: z.string(),
|
|
2244
|
+
suggestion: z.string().optional()
|
|
2245
|
+
}))
|
|
2246
|
+
});
|
|
2247
|
+
z.object({
|
|
2248
|
+
/** Map of level name to level descriptor */
|
|
2249
|
+
levels: z.record(z.object({
|
|
2250
|
+
description: z.string(),
|
|
2251
|
+
automatic: z.boolean()
|
|
2252
|
+
}))
|
|
2253
|
+
});
|
|
2254
|
+
z.object({
|
|
2255
|
+
/** Whether the protection level was set successfully */
|
|
2256
|
+
success: z.boolean()
|
|
2257
|
+
});
|
|
2258
|
+
z.object({
|
|
2259
|
+
/** Protection level, if retrievable */
|
|
2260
|
+
level: ProtectionLevel.optional()
|
|
2261
|
+
});
|
|
2262
|
+
z.object({
|
|
2263
|
+
/** Whether the level was set */
|
|
2264
|
+
success: z.boolean()
|
|
2265
|
+
});
|
|
2266
|
+
z.array(z.object({
|
|
2267
|
+
filePath: z.string(),
|
|
2268
|
+
level: ProtectionLevel
|
|
2269
|
+
}));
|
|
2270
|
+
WorkspaceBase.extend({
|
|
2271
|
+
/** Optional: specific component ID to assess */
|
|
2272
|
+
targetComponentId: z.string().optional(),
|
|
2273
|
+
/** Optional: minimum test coverage threshold (0.0-1.0) */
|
|
2274
|
+
minTestCoverage: z.number().min(0).max(1).optional(),
|
|
2275
|
+
/** Optional: maximum dependency count threshold */
|
|
2276
|
+
maxDependencyCount: z.number().int().positive().optional(),
|
|
2277
|
+
/** Optional: minimum confidence threshold (0.0-1.0) */
|
|
2278
|
+
minConfidence: z.number().min(0).max(1).optional()
|
|
2279
|
+
});
|
|
2280
|
+
WorkspaceBase.extend({
|
|
2281
|
+
/** Include all candidates in report (not just recommendations) */
|
|
2282
|
+
includeAllCandidates: z.boolean().optional()
|
|
2283
|
+
});
|
|
2284
|
+
WorkspaceBase.extend({
|
|
2285
|
+
/** Maximum number of recommendations to return */
|
|
2286
|
+
limit: z.number().int().positive().optional(),
|
|
2287
|
+
/** Minimum priority level to include */
|
|
2288
|
+
minPriority: z.enum([
|
|
2289
|
+
"critical",
|
|
2290
|
+
"high",
|
|
2291
|
+
"medium",
|
|
2292
|
+
"low"
|
|
2293
|
+
]).optional()
|
|
2294
|
+
});
|
|
2295
|
+
WorkspaceBase.extend({
|
|
2296
|
+
/** Component ID to analyze */
|
|
2297
|
+
componentId: z.string()
|
|
2298
|
+
});
|
|
2299
|
+
WorkspaceBase.extend({
|
|
2300
|
+
/** Component ID to set gate for */
|
|
2301
|
+
componentId: z.string(),
|
|
2302
|
+
/** Gate to set */
|
|
2303
|
+
gate: z.enum([
|
|
2304
|
+
"migrationPlan",
|
|
2305
|
+
"rollbackStrategy",
|
|
2306
|
+
"ownerAssigned",
|
|
2307
|
+
"stakeholderSignoff"
|
|
2308
|
+
]),
|
|
2309
|
+
/** Gate status */
|
|
2310
|
+
status: z.enum([
|
|
2311
|
+
"pass",
|
|
2312
|
+
"fail",
|
|
2313
|
+
"warn",
|
|
2314
|
+
"pending"
|
|
2315
|
+
])
|
|
2316
|
+
});
|
|
2317
|
+
WorkspaceBase.extend({
|
|
2318
|
+
/** Component ID to get gates for */
|
|
2319
|
+
componentId: z.string()
|
|
2320
|
+
});
|
|
2321
|
+
WorkspaceBase.extend({
|
|
2322
|
+
/** Filter by actions */
|
|
2323
|
+
actions: z.array(z.enum([
|
|
2324
|
+
"refactor-now",
|
|
2325
|
+
"schedule",
|
|
2326
|
+
"defer",
|
|
2327
|
+
"monitor",
|
|
2328
|
+
"reject"
|
|
2329
|
+
])).optional(),
|
|
2330
|
+
/** Filter by priorities */
|
|
2331
|
+
priorities: z.array(z.enum([
|
|
2332
|
+
"critical",
|
|
2333
|
+
"high",
|
|
2334
|
+
"medium",
|
|
2335
|
+
"low"
|
|
2336
|
+
])).optional(),
|
|
2337
|
+
/** Minimum confidence threshold */
|
|
2338
|
+
minConfidence: z.number().min(0).max(1).optional()
|
|
2339
|
+
});
|
|
2340
|
+
var BootProfile = z.enum([
|
|
2341
|
+
"VIRGIN",
|
|
2342
|
+
"NEW_WORKSPACE",
|
|
2343
|
+
"COLD_RETURN",
|
|
2344
|
+
"WARM_RETURN",
|
|
2345
|
+
"HOT_RECONNECT"
|
|
2346
|
+
]);
|
|
2347
|
+
z.object({
|
|
2348
|
+
profile: BootProfile,
|
|
2349
|
+
workspaceId: z.string().optional(),
|
|
2350
|
+
lastSessionAge: z.number().nonnegative().optional(),
|
|
2351
|
+
integrityErrors: z.number().nonnegative().optional(),
|
|
2352
|
+
cleanShutdown: z.boolean().optional()
|
|
2353
|
+
});
|
|
2354
|
+
z.object({
|
|
2355
|
+
cleanShutdown: z.literal(true),
|
|
2356
|
+
timestamp: z.string().datetime()
|
|
2357
|
+
});
|
|
2358
|
+
|
|
2359
|
+
// ../../packages/contracts/dist/local-service/schemas/session.js
|
|
2360
|
+
z.object({
|
|
2361
|
+
/** Protocol version the client supports */
|
|
2362
|
+
protocolVersion: z.string().regex(/^\d+\.\d+\.\d+$/),
|
|
2363
|
+
/** Client type identifying the connecting surface */
|
|
2364
|
+
clientType: ClientType.optional().default("unknown"),
|
|
2365
|
+
/** Client version (semantic versioning) */
|
|
2366
|
+
clientVersion: z.string().optional().default("0.0.0"),
|
|
2367
|
+
/** Client identification (legacy field, kept for backward compatibility) */
|
|
2368
|
+
clientInfo: z.object({
|
|
2369
|
+
/** Client name (e.g., "vscode-extension", "cli") */
|
|
2370
|
+
name: z.string().min(1).max(100),
|
|
2371
|
+
/** Client version (semantic versioning) */
|
|
2372
|
+
version: z.string()
|
|
2373
|
+
}).optional(),
|
|
2374
|
+
/** Client capabilities (optional) */
|
|
2375
|
+
capabilities: z.object({
|
|
2376
|
+
/** Client accepts server-sent notifications */
|
|
2377
|
+
notifications: z.boolean().default(true),
|
|
2378
|
+
/** Client can handle base64-encoded binary content */
|
|
2379
|
+
binaryContent: z.boolean().default(false)
|
|
2380
|
+
}).optional()
|
|
2381
|
+
});
|
|
2382
|
+
z.object({
|
|
2383
|
+
protocolVersion: z.string(),
|
|
2384
|
+
serverInfo: z.object({
|
|
2385
|
+
name: z.string(),
|
|
2386
|
+
version: z.string()
|
|
2387
|
+
}),
|
|
2388
|
+
capabilities: z.object({
|
|
2389
|
+
notifications: z.boolean().optional(),
|
|
2390
|
+
binaryContent: z.boolean().optional(),
|
|
2391
|
+
health: z.record(z.boolean()).optional()
|
|
2392
|
+
}).optional(),
|
|
2393
|
+
/** True when the daemon is starting for the first time (VIRGIN boot profile) */
|
|
2394
|
+
isFirstRun: z.boolean().default(false),
|
|
2395
|
+
/** Boot profile selected for this startup */
|
|
2396
|
+
bootProfile: BootProfile.optional()
|
|
2397
|
+
});
|
|
2398
|
+
z.object({
|
|
2399
|
+
/** Include detailed health information */
|
|
2400
|
+
verbose: z.boolean().optional()
|
|
2401
|
+
});
|
|
2402
|
+
z.object({
|
|
2403
|
+
/** Filter by workspace path (optional) */
|
|
2404
|
+
workspacePath: z.string().optional()
|
|
2405
|
+
});
|
|
2406
|
+
var SessionWorkspacePathBase = z.object({
|
|
2407
|
+
/** Absolute path to workspace root */
|
|
2408
|
+
workspacePath: z.string().min(1)
|
|
2409
|
+
});
|
|
2410
|
+
var SessionCreateParamsBase = SessionWorkspacePathBase.extend({
|
|
2411
|
+
/** Optional task description */
|
|
2412
|
+
task: z.string().min(1).optional(),
|
|
2413
|
+
/** Files involved in this task */
|
|
2414
|
+
files: z.array(z.string()).optional(),
|
|
2415
|
+
/** Keywords for context matching */
|
|
2416
|
+
keywords: z.array(z.string()).optional(),
|
|
2417
|
+
/** Files touched during session creation */
|
|
2418
|
+
touchedFiles: z.array(z.string()).optional()
|
|
2419
|
+
});
|
|
2420
|
+
SessionCreateParamsBase.extend({
|
|
2421
|
+
/** Additional session metadata (optional) */
|
|
2422
|
+
metadata: z.object({
|
|
2423
|
+
/** Editor name (e.g., "Visual Studio Code") */
|
|
2424
|
+
editorName: z.string().optional(),
|
|
2425
|
+
/** Editor version */
|
|
2426
|
+
editorVersion: z.string().optional()
|
|
2427
|
+
}).optional()
|
|
2428
|
+
});
|
|
2429
|
+
z.object({
|
|
2430
|
+
/** Session to end (defaults to current session if omitted) */
|
|
2431
|
+
sessionId: z.string().min(1).optional(),
|
|
2432
|
+
/** Reason for ending session */
|
|
2433
|
+
reason: z.enum([
|
|
2434
|
+
"user",
|
|
2435
|
+
"idle",
|
|
2436
|
+
"workspace_closed",
|
|
2437
|
+
"recovered-abandoned"
|
|
2438
|
+
]).optional()
|
|
2439
|
+
});
|
|
2440
|
+
z.object({
|
|
2441
|
+
/** Filter by workspace path (optional) */
|
|
2442
|
+
workspacePath: z.string().optional(),
|
|
2443
|
+
/** Maximum number of sessions to return */
|
|
2444
|
+
limit: z.number().int().min(1).max(100).default(20),
|
|
2445
|
+
/** Pagination cursor (session ID to start after) */
|
|
2446
|
+
before: z.string().min(1).optional(),
|
|
2447
|
+
/** Include ended sessions in results */
|
|
2448
|
+
includeEnded: z.boolean().default(true)
|
|
2449
|
+
});
|
|
2450
|
+
SessionWorkspacePathBase.extend({
|
|
2451
|
+
/** Session to end (optional; defaults to current workspace session) */
|
|
2452
|
+
sessionId: z.string().min(1).optional(),
|
|
2453
|
+
/**
|
|
2454
|
+
* Free-text outcome description - what was accomplished, what remains, decisions made.
|
|
2455
|
+
* Becomes the opening context for the next session briefing.
|
|
2456
|
+
* Do NOT constrain to an enum: the MCP tool description promises free-text paragraphs.
|
|
2457
|
+
*/
|
|
2458
|
+
outcome: z.string().min(1).max(2e3).optional(),
|
|
2459
|
+
/** Additional notes */
|
|
2460
|
+
notes: z.string().optional(),
|
|
2461
|
+
/** Create a snapshot on end */
|
|
2462
|
+
createSnapshot: z.boolean().optional(),
|
|
2463
|
+
/** Learning IDs to accept */
|
|
2464
|
+
acceptLearnings: z.array(z.number()).optional()
|
|
2465
|
+
});
|
|
2466
|
+
SessionWorkspacePathBase.extend({
|
|
2467
|
+
/** Session to inspect (optional; defaults to current workspace session) */
|
|
2468
|
+
sessionId: z.string().min(1).optional()
|
|
2469
|
+
});
|
|
2470
|
+
SessionWorkspacePathBase.extend({
|
|
2471
|
+
/** Session ID to review */
|
|
2472
|
+
sessionId: z.string().min(1).optional(),
|
|
2473
|
+
/** Files to review */
|
|
2474
|
+
files: z.array(z.string()).optional(),
|
|
2475
|
+
/** Include commit message suggestion */
|
|
2476
|
+
includeCommitMessage: z.boolean().optional(),
|
|
2477
|
+
/** Skip pattern checking */
|
|
2478
|
+
skipPatterns: z.boolean().optional()
|
|
2479
|
+
});
|
|
2480
|
+
SessionWorkspacePathBase.extend({
|
|
2481
|
+
/** Session to inspect (optional; defaults to current workspace session) */
|
|
2482
|
+
sessionId: z.string().min(1).optional(),
|
|
2483
|
+
/** Include diff in results */
|
|
2484
|
+
includeDiff: z.boolean().optional(),
|
|
2485
|
+
/** Filter to specific files */
|
|
2486
|
+
filterFiles: z.array(z.string()).optional(),
|
|
2487
|
+
/** Include AI attribution info */
|
|
2488
|
+
includeAIAttribution: z.boolean().default(true)
|
|
2489
|
+
});
|
|
2490
|
+
z.object({
|
|
2491
|
+
/** Filter by workspace path */
|
|
2492
|
+
workspacePath: z.string().min(1),
|
|
2493
|
+
/** Pagination cursor (session ID) */
|
|
2494
|
+
cursor: z.string().optional(),
|
|
2495
|
+
/** Max number of sessions to return (default 20) */
|
|
2496
|
+
limit: z.number().optional()
|
|
2497
|
+
});
|
|
2498
|
+
z.object({
|
|
2499
|
+
/** Pulse level based on file count thresholds */
|
|
2500
|
+
pulse: z.enum([
|
|
2501
|
+
"resting",
|
|
2502
|
+
"elevated",
|
|
2503
|
+
"racing",
|
|
2504
|
+
"critical"
|
|
2505
|
+
]),
|
|
2506
|
+
/** Pressure: ratio of unprotected changes (0-100) */
|
|
2507
|
+
pressure: z.number().min(0).max(100),
|
|
2508
|
+
/** Trajectory based on pressure level */
|
|
2509
|
+
trajectory: z.enum([
|
|
2510
|
+
"stable",
|
|
2511
|
+
"increasing",
|
|
2512
|
+
"decreasing"
|
|
2513
|
+
]),
|
|
2514
|
+
/** Whether a snapshot is recommended */
|
|
2515
|
+
snapshotRecommended: z.boolean(),
|
|
2516
|
+
/** Files modified during session */
|
|
2517
|
+
filesModified: z.number(),
|
|
2518
|
+
/** Snapshots created during session */
|
|
2519
|
+
snapshotsCreated: z.number(),
|
|
2520
|
+
/** Learnings captured during session */
|
|
2521
|
+
learningsCaptured: z.number()
|
|
2522
|
+
});
|
|
2523
|
+
SessionWorkspacePathBase.extend({
|
|
2524
|
+
/** Session to update (optional; defaults to current workspace session) */
|
|
2525
|
+
sessionId: z.string().min(1).optional(),
|
|
2526
|
+
/** New task description */
|
|
2527
|
+
task: z.string().min(1)
|
|
2528
|
+
});
|
|
2529
|
+
z.object({
|
|
2530
|
+
/** Absolute path to the workspace root */
|
|
2531
|
+
workspacePath: z.string().min(1),
|
|
2532
|
+
/** Session to update (optional; defaults to current workspace session) */
|
|
2533
|
+
sessionId: z.string().optional(),
|
|
2534
|
+
/** The AI tool detected */
|
|
2535
|
+
tool: z.enum([
|
|
2536
|
+
"cursor",
|
|
2537
|
+
"copilot",
|
|
2538
|
+
"claude-code",
|
|
2539
|
+
"windsurf",
|
|
2540
|
+
"continue",
|
|
2541
|
+
"other"
|
|
2542
|
+
]),
|
|
2543
|
+
/** Tool version string if available */
|
|
2544
|
+
toolVersion: z.string().optional(),
|
|
2545
|
+
/** ISO 8601 timestamp of detection */
|
|
2546
|
+
detectedAt: z.string().datetime().optional()
|
|
2547
|
+
});
|
|
2548
|
+
z.object({
|
|
2549
|
+
/** Whether the daemon acknowledged and recorded the detection */
|
|
2550
|
+
acknowledged: z.boolean(),
|
|
2551
|
+
/** The session that was updated (null if no active session) */
|
|
2552
|
+
sessionId: z.string().nullable()
|
|
2553
|
+
});
|
|
2554
|
+
var TimingSpan = z.object({
|
|
2555
|
+
/** Name of the span (e.g., "ipc_receive", "service_dispatch", "decision") */
|
|
2556
|
+
name: z.string(),
|
|
2557
|
+
/** Start time in milliseconds relative to request start */
|
|
2558
|
+
startMs: z.number(),
|
|
2559
|
+
/** End time in milliseconds relative to request start */
|
|
2560
|
+
endMs: z.number()
|
|
2561
|
+
});
|
|
2562
|
+
var SavePathMetrics = z.object({
|
|
2563
|
+
/** Unique identifier for this request */
|
|
2564
|
+
requestId: z.string(),
|
|
2565
|
+
/** Total time from request receive to response send */
|
|
2566
|
+
totalMs: z.number(),
|
|
2567
|
+
/** Breakdown of time spent in each phase */
|
|
2568
|
+
spans: z.array(TimingSpan),
|
|
2569
|
+
/** Whether a snapshot was actually created */
|
|
2570
|
+
snapshotCreated: z.boolean()
|
|
2571
|
+
});
|
|
2572
|
+
var ShouldCreateReason = z.enum([
|
|
2573
|
+
"no_previous",
|
|
2574
|
+
"hash_changed",
|
|
2575
|
+
"time_threshold",
|
|
2576
|
+
"size_threshold",
|
|
2577
|
+
"no_change",
|
|
2578
|
+
"cooldown"
|
|
2579
|
+
]);
|
|
2580
|
+
|
|
2581
|
+
// ../../packages/contracts/dist/local-service/schemas/snapshot.js
|
|
2582
|
+
z.object({
|
|
2583
|
+
/** Absolute path to the file */
|
|
2584
|
+
filePath: z.string().min(1),
|
|
2585
|
+
/** File content to snapshot */
|
|
2586
|
+
content: z.string(),
|
|
2587
|
+
/** What triggered this snapshot */
|
|
2588
|
+
trigger: SnapshotTrigger,
|
|
2589
|
+
/** Additional snapshot metadata (optional) */
|
|
2590
|
+
metadata: z.object({
|
|
2591
|
+
/** AI tool that was active */
|
|
2592
|
+
aiToolDetected: z.string().optional(),
|
|
2593
|
+
/** Confidence score for AI detection (0-1) */
|
|
2594
|
+
aiConfidence: z.number().min(0).max(1).optional(),
|
|
2595
|
+
/** Risk level assessment */
|
|
2596
|
+
riskLevel: RiskLevel.optional(),
|
|
2597
|
+
/** Custom tags for organization */
|
|
2598
|
+
customTags: z.array(z.string()).optional()
|
|
2599
|
+
}).optional()
|
|
2600
|
+
});
|
|
2601
|
+
z.object({
|
|
2602
|
+
/** Absolute path to the file being saved */
|
|
2603
|
+
filePath: z.string().min(1),
|
|
2604
|
+
/** SHA-256 hash of the file content (optional, for deduplication) */
|
|
2605
|
+
contentHash: z.string().optional(),
|
|
2606
|
+
/** Last modification timestamp in milliseconds */
|
|
2607
|
+
lastModified: z.number().optional(),
|
|
2608
|
+
/** File size in bytes */
|
|
2609
|
+
byteSize: z.number().optional()
|
|
2610
|
+
});
|
|
2611
|
+
z.object({
|
|
2612
|
+
/** Whether a snapshot should be created */
|
|
2613
|
+
shouldCreate: z.boolean(),
|
|
2614
|
+
/** Reason for the decision */
|
|
2615
|
+
reason: ShouldCreateReason,
|
|
2616
|
+
/** Optional timing metrics for performance analysis */
|
|
2617
|
+
metrics: SavePathMetrics.optional()
|
|
2618
|
+
});
|
|
2619
|
+
z.object({
|
|
2620
|
+
/** Snapshot ID to retrieve */
|
|
2621
|
+
snapshotId: z.string().min(1),
|
|
2622
|
+
/** Include full content in response (expensive) */
|
|
2623
|
+
includeContent: z.boolean().default(false)
|
|
2624
|
+
});
|
|
2625
|
+
var SnapshotListParams = z.object({
|
|
2626
|
+
/** Filter by session ID (optional) */
|
|
2627
|
+
sessionId: z.string().min(1).optional(),
|
|
2628
|
+
/** Filter by file path (optional) */
|
|
2629
|
+
filePath: z.string().optional(),
|
|
2630
|
+
/** Filter by trigger types (optional) */
|
|
2631
|
+
trigger: z.array(SnapshotTrigger).optional(),
|
|
2632
|
+
/** Filter by created after timestamp (ISO 8601) */
|
|
2633
|
+
since: z.string().datetime().optional(),
|
|
2634
|
+
/** Filter by created before timestamp (ISO 8601) */
|
|
2635
|
+
until: z.string().datetime().optional(),
|
|
2636
|
+
/** Maximum number of snapshots to return */
|
|
2637
|
+
limit: z.number().int().min(1).max(200).default(50),
|
|
2638
|
+
/** Pagination cursor (opaque string) */
|
|
2639
|
+
cursor: z.string().optional(),
|
|
2640
|
+
/** Sort field */
|
|
2641
|
+
orderBy: z.enum([
|
|
2642
|
+
"createdAt",
|
|
2643
|
+
"filePath"
|
|
2644
|
+
]).default("createdAt"),
|
|
2645
|
+
/** Sort direction */
|
|
2646
|
+
orderDir: z.enum([
|
|
2647
|
+
"asc",
|
|
2648
|
+
"desc"
|
|
2649
|
+
]).default("desc")
|
|
2650
|
+
});
|
|
2651
|
+
z.object({
|
|
2652
|
+
/** Snapshot ID to restore */
|
|
2653
|
+
snapshotId: z.string().min(1),
|
|
2654
|
+
/** Target path (defaults to original path if omitted) */
|
|
2655
|
+
targetPath: z.string().optional(),
|
|
2656
|
+
/** Create backup snapshot before restoring */
|
|
2657
|
+
createBackup: z.boolean().default(true),
|
|
2658
|
+
/** Preview restore without writing (dry run) */
|
|
2659
|
+
dryRun: z.boolean().default(false)
|
|
2660
|
+
});
|
|
2661
|
+
z.object({
|
|
2662
|
+
/** Base snapshot ID for comparison */
|
|
2663
|
+
baseSnapshotId: z.string().min(1),
|
|
2664
|
+
/** Snapshot to compare against (defaults to current file if omitted) */
|
|
2665
|
+
compareSnapshotId: z.string().min(1).optional(),
|
|
2666
|
+
/** Number of context lines around changes */
|
|
2667
|
+
contextLines: z.number().int().min(0).max(10).default(3),
|
|
2668
|
+
/** Diff output format */
|
|
2669
|
+
format: z.enum([
|
|
2670
|
+
"unified",
|
|
2671
|
+
"split"
|
|
2672
|
+
]).default("unified")
|
|
2673
|
+
});
|
|
2674
|
+
z.object({
|
|
2675
|
+
/** Specific snapshot IDs to delete (optional) */
|
|
2676
|
+
snapshotIds: z.array(z.string().min(1)).optional(),
|
|
2677
|
+
/** Delete all snapshots older than timestamp (ISO 8601) (optional) */
|
|
2678
|
+
olderThan: z.string().datetime().optional(),
|
|
2679
|
+
/** Delete all snapshots in session (optional) */
|
|
2680
|
+
sessionId: z.string().min(1).optional(),
|
|
2681
|
+
/** Preview deletion without removing (dry run) */
|
|
2682
|
+
dryRun: z.boolean().default(false)
|
|
2683
|
+
});
|
|
2684
|
+
WorkspaceBase.extend({
|
|
2685
|
+
/** Files to snapshot (relative paths) */
|
|
2686
|
+
files: z.array(z.string().min(1)).min(1),
|
|
2687
|
+
/** Reason for snapshot */
|
|
2688
|
+
reason: z.string().optional(),
|
|
2689
|
+
/** Snapshot trigger */
|
|
2690
|
+
trigger: z.enum([
|
|
2691
|
+
"manual",
|
|
2692
|
+
"mcp",
|
|
2693
|
+
"ai_assist",
|
|
2694
|
+
"session_end"
|
|
2695
|
+
]).optional()
|
|
2696
|
+
});
|
|
2697
|
+
WorkspaceBase.extend({
|
|
2698
|
+
/** Delete snapshots older than N days */
|
|
2699
|
+
olderThanDays: z.number().int().positive().optional(),
|
|
2700
|
+
/** Keep protected snapshots */
|
|
2701
|
+
keepProtected: z.boolean().default(true)
|
|
2702
|
+
});
|
|
2703
|
+
WorkspaceBase.extend({
|
|
2704
|
+
/** Snapshot ID */
|
|
2705
|
+
snapshotId: z.string().min(1)
|
|
2706
|
+
});
|
|
2707
|
+
WorkspaceBase.extend({
|
|
2708
|
+
/** Snapshot ID */
|
|
2709
|
+
snapshotId: z.string().min(1),
|
|
2710
|
+
/** New name */
|
|
2711
|
+
newName: z.string().min(1)
|
|
2712
|
+
});
|
|
2713
|
+
SnapshotListParams.extend({
|
|
2714
|
+
/** Include risk assessment per snapshot */
|
|
2715
|
+
includeRisk: z.boolean().default(true),
|
|
2716
|
+
/** Include AI attribution per snapshot */
|
|
2717
|
+
includeAttribution: z.boolean().default(true),
|
|
2718
|
+
/** Group by session cluster */
|
|
2719
|
+
groupBySessions: z.boolean().default(false)
|
|
2720
|
+
});
|
|
2721
|
+
WorkspaceBase.extend({
|
|
2722
|
+
/** Optional auth token for platform sync */
|
|
2723
|
+
authToken: z.string().optional()
|
|
2724
|
+
});
|
|
2725
|
+
WorkspaceBase.extend({
|
|
2726
|
+
/** Task summary/description */
|
|
2727
|
+
task: z.string().min(1),
|
|
2728
|
+
/** Files involved in the task */
|
|
2729
|
+
files: z.array(z.string()).optional(),
|
|
2730
|
+
/** Keywords for context matching */
|
|
2731
|
+
keywords: z.array(z.string()).optional(),
|
|
2732
|
+
/** Task intent classification */
|
|
2733
|
+
intent: TaskIntent.optional()
|
|
2734
|
+
});
|
|
2735
|
+
WorkspaceBase.extend({
|
|
2736
|
+
/** Progress message */
|
|
2737
|
+
message: z.string().min(1),
|
|
2738
|
+
/** Files modified in this progress */
|
|
2739
|
+
filesModified: z.array(z.string()).optional(),
|
|
2740
|
+
/** Partial completion percentage */
|
|
2741
|
+
completionPercent: z.number().min(0).max(100).optional()
|
|
2742
|
+
});
|
|
2743
|
+
WorkspaceBase.extend({
|
|
2744
|
+
/**
|
|
2745
|
+
* Free-text outcome. Do NOT constrain to enum - snap_end promises free-text paragraphs.
|
|
2746
|
+
*/
|
|
2747
|
+
outcome: z.string().min(1).max(2e3),
|
|
2748
|
+
/** Outcome notes */
|
|
2749
|
+
notes: z.string().optional(),
|
|
2750
|
+
/** Learnings captured during task */
|
|
2751
|
+
learnings: z.array(z.string()).optional()
|
|
2752
|
+
});
|
|
2753
|
+
WorkspaceBase.extend({
|
|
2754
|
+
/** Single file */
|
|
2755
|
+
file: z.string().optional(),
|
|
2756
|
+
/** Multiple files */
|
|
2757
|
+
files: z.array(z.string()).optional(),
|
|
2758
|
+
/** Run tests */
|
|
2759
|
+
runTests: z.boolean().optional(),
|
|
2760
|
+
/** Skip TypeScript check */
|
|
2761
|
+
skipTypeScript: z.boolean().optional(),
|
|
2762
|
+
/** Skip tests */
|
|
2763
|
+
skipTests: z.boolean().optional(),
|
|
2764
|
+
/** Skip lint */
|
|
2765
|
+
skipLint: z.boolean().optional()
|
|
2766
|
+
});
|
|
2767
|
+
WorkspaceBase.extend({
|
|
2768
|
+
/** Code to validate */
|
|
2769
|
+
code: z.string(),
|
|
2770
|
+
/** File path */
|
|
2771
|
+
filePath: z.string().min(1)
|
|
2772
|
+
});
|
|
2773
|
+
WorkspaceBase.extend({
|
|
2774
|
+
/** Violation type */
|
|
2775
|
+
type: z.string().min(1),
|
|
2776
|
+
/** File where violation occurred */
|
|
2777
|
+
file: z.string().min(1),
|
|
2778
|
+
/** What happened */
|
|
2779
|
+
whatHappened: z.string().min(1),
|
|
2780
|
+
/** Why it happened */
|
|
2781
|
+
whyItHappened: z.string().min(1),
|
|
2782
|
+
/** How to prevent it */
|
|
2783
|
+
prevention: z.string().min(1)
|
|
2784
|
+
});
|
|
2785
|
+
z.object({
|
|
2786
|
+
/** Absolute path to check */
|
|
2787
|
+
path: z.string().min(1),
|
|
2788
|
+
/** Absolute workspace root to check against */
|
|
2789
|
+
workspace: z.string().min(1)
|
|
2790
|
+
});
|
|
2791
|
+
WorkspaceBase.extend({
|
|
2792
|
+
/** Glob patterns to watch */
|
|
2793
|
+
patterns: z.array(z.string()).optional()
|
|
2794
|
+
});
|
|
2795
|
+
WorkspaceBase.extend({
|
|
2796
|
+
/** File that changed */
|
|
2797
|
+
file: z.string().min(1),
|
|
2798
|
+
/** Timestamp of change */
|
|
2799
|
+
timestamp: z.number().int().positive()
|
|
2800
|
+
});
|
|
2801
|
+
WorkspaceBase.extend({
|
|
2802
|
+
/** Skip baseline computation (faster, less complete) */
|
|
2803
|
+
skipBaseline: z.boolean().optional(),
|
|
2804
|
+
/** Skip learning seeding */
|
|
2805
|
+
skipLearnings: z.boolean().optional(),
|
|
2806
|
+
/** Force re-seed learnings even if already seeded */
|
|
2807
|
+
forceSeedLearnings: z.boolean().optional()
|
|
2808
|
+
});
|
|
2809
|
+
WorkspaceBase.extend({
|
|
2810
|
+
/** Optional path to global knowledge DB (defaults to ~/.vreko/knowledge.db) */
|
|
2811
|
+
globalDbPath: z.string().optional()
|
|
2812
|
+
});
|
|
2813
|
+
WorkspaceBase.extend({
|
|
2814
|
+
/** Optional existing user-supplied ID to use as a fallback */
|
|
2815
|
+
fallbackUserId: z.string().optional(),
|
|
2816
|
+
/** Whether to persist the resolved ID back to .vreko/config.json */
|
|
2817
|
+
autoPersist: z.boolean().optional().default(true)
|
|
2818
|
+
});
|
|
2819
|
+
WorkspaceBase.extend({
|
|
2820
|
+
force: z.boolean().optional()
|
|
2821
|
+
});
|
|
2822
|
+
WorkspaceBase.extend({
|
|
2823
|
+
/** Target state to transition to */
|
|
2824
|
+
targetState: z.string().optional(),
|
|
2825
|
+
/** Reason for the transition */
|
|
2826
|
+
reason: z.string().optional()
|
|
2827
|
+
});
|
|
2828
|
+
|
|
2829
|
+
// ../../packages/contracts/dist/local-service/schemas/registry.js
|
|
2830
|
+
var METHOD_NAME_MAP = {
|
|
2831
|
+
"daemon.ping": "daemon/ping",
|
|
2832
|
+
"daemon.status": "daemon/status",
|
|
2833
|
+
"daemon.shutdown": "daemon/shutdown",
|
|
2834
|
+
"daemon.reload": "daemon/reload",
|
|
2835
|
+
"session.end": "session/end-daemon",
|
|
2836
|
+
"session.status": "session/status",
|
|
2837
|
+
"session.review": "session/review",
|
|
2838
|
+
"session.listCeremonies": "session/list-ceremonies",
|
|
2839
|
+
"session.changes": "session/changes",
|
|
2840
|
+
"session.updateTask": "session/update-task",
|
|
2841
|
+
"snapshot.create": "snapshot/create",
|
|
2842
|
+
"snapshot.list": "snapshot/list",
|
|
2843
|
+
"snapshot.restore": "snapshot/restore",
|
|
2844
|
+
"snapshot.delete": "snapshot/delete",
|
|
2845
|
+
"snapshot.bulkDelete": "snapshot/bulk-delete",
|
|
2846
|
+
"snapshot.protect": "snapshot/protect",
|
|
2847
|
+
"snapshot.unprotect": "snapshot/unprotect",
|
|
2848
|
+
"snapshot.rename": "snapshot/rename",
|
|
2849
|
+
"learning.add": "learning/add",
|
|
2850
|
+
"learning.queue": "learning/queue",
|
|
2851
|
+
"learning.queueSync": "learning/queue-sync",
|
|
2852
|
+
"learning.queueSyncComplete": "learning/queue-sync-complete",
|
|
2853
|
+
"learning.search": "learning/search",
|
|
2854
|
+
"learning.list": "learning/list",
|
|
2855
|
+
"learning.prune": "learning/prune",
|
|
2856
|
+
"learning.evaluate": "learning/evaluate",
|
|
2857
|
+
"learning.updateSession": "learning/update-session",
|
|
2858
|
+
"learning.gc": "learning/gc",
|
|
2859
|
+
"sync.status": "sync/status-daemon",
|
|
2860
|
+
"sync.force": "sync/force",
|
|
2861
|
+
"sync.stop": "sync/stop",
|
|
2862
|
+
"sync.start": "sync/start",
|
|
2863
|
+
"sync.queue": "sync/queue",
|
|
2864
|
+
"context.get": "context/get",
|
|
2865
|
+
"context.validate": "context/validate",
|
|
2866
|
+
"context.check_patterns": "context/check-patterns",
|
|
2867
|
+
"validate.quick": "validate/quick",
|
|
2868
|
+
"validate.comprehensive": "validate/comprehensive",
|
|
2869
|
+
"violation.report": "violation/report",
|
|
2870
|
+
"violation.list": "violation/list",
|
|
2871
|
+
"protection.getLevel": "protection/get-level",
|
|
2872
|
+
"protection.setLevel": "protection/set-level",
|
|
2873
|
+
"protection.list": "protection/list-daemon",
|
|
2874
|
+
"watch.subscribe": "watch/subscribe",
|
|
2875
|
+
"watch.unsubscribe": "watch/unsubscribe",
|
|
2876
|
+
"watch.file_changed": "watch/file-changed",
|
|
2877
|
+
"snapshot.created": "mcp/snapshot-created",
|
|
2878
|
+
"file.modified": "mcp/file-modified",
|
|
2879
|
+
"intelligence.capture": "intelligence/capture",
|
|
2880
|
+
"intelligence.outcome": "intelligence/outcome",
|
|
2881
|
+
"intelligence.fragileFiles": "intelligence/fragile-files",
|
|
2882
|
+
"intelligence.recurrenceCandidates": "intelligence/recurrence-candidates",
|
|
2883
|
+
"intelligence.coChanges": "intelligence/co-changes",
|
|
2884
|
+
"intelligence.summary": "intelligence/summary",
|
|
2885
|
+
"intelligence.warnings": "intelligence/warnings",
|
|
2886
|
+
"intelligence.health": "intelligence/health",
|
|
2887
|
+
"intelligence.decisionOutcome": "intelligence/decision-outcome",
|
|
2888
|
+
"intelligence.preventionMetrics": "intelligence/prevention-metrics",
|
|
2889
|
+
"intelligence.accuracyMetrics": "intelligence/accuracy-metrics",
|
|
2890
|
+
"intelligence.snapshot": "intelligence/snapshot",
|
|
2891
|
+
"projectionsRulesFile.status": "projections/rules-file/status",
|
|
2892
|
+
"projectionsRulesFile.enable": "projections/rules-file/enable",
|
|
2893
|
+
"projectionsRulesFile.disable": "projections/rules-file/disable",
|
|
2894
|
+
"projectionsRulesFile.dryRun": "projections/rules-file/dry-run",
|
|
2895
|
+
"supervisor.register": "supervisor/register",
|
|
2896
|
+
"supervisor.heartbeat": "supervisor/heartbeat",
|
|
2897
|
+
"system.health": "system/health",
|
|
2898
|
+
"momentum.refresh": "momentum/refresh",
|
|
2899
|
+
"momentum.score": "momentum/score",
|
|
2900
|
+
"momentum.sync": "momentum/sync",
|
|
2901
|
+
"momentum.status": "momentum/status",
|
|
2902
|
+
"vitals.health": "vitals/health",
|
|
2903
|
+
"vitals.warnings": "vitals/warnings",
|
|
2904
|
+
"workspace.analyze": "workspace/analyze",
|
|
2905
|
+
"workspace.status": "workspace/status",
|
|
2906
|
+
"workspace.seedKnowledge": "workspace/seed-knowledge",
|
|
2907
|
+
"workspace.fingerprint": "workspace/fingerprint",
|
|
2908
|
+
"workspace.hydrate": "workspace/hydrate",
|
|
2909
|
+
"workspace.triggerWorkspaceJsonWrite": "workspace/trigger-workspace-json-write",
|
|
2910
|
+
"workspace.writeFromScanProfile": "workspace/write-from-scan-profile",
|
|
2911
|
+
"dora.recordSnapshot": "dora/record-snapshot",
|
|
2912
|
+
"dora.recordRecovery": "dora/record-recovery",
|
|
2913
|
+
"dora.getMetrics": "dora/get-metrics",
|
|
2914
|
+
"dora.getTrends": "dora/get-trends",
|
|
2915
|
+
"risk.assess": "risk/assess",
|
|
2916
|
+
// Phantom methods: dot-notation entries for documentation; no daemon handler exists yet
|
|
2917
|
+
"intelligence.getDecision": "intelligence/get-decision",
|
|
2918
|
+
"analytics.track": "analytics/track"
|
|
2919
|
+
};
|
|
2920
|
+
function normalizeMethodName(method) {
|
|
2921
|
+
return METHOD_NAME_MAP[method] ?? method;
|
|
2922
|
+
}
|
|
2923
|
+
__name(normalizeMethodName, "normalizeMethodName");
|
|
2924
|
+
({
|
|
2925
|
+
"health/ping": z.object({}),
|
|
2926
|
+
// Sync namespace (original local-service style)
|
|
2927
|
+
"sync/status": z.object({}),
|
|
2928
|
+
// DORA metrics namespace (routed through daemon)
|
|
2929
|
+
"dora/record-snapshot": z.object({
|
|
2930
|
+
workspace: z.string(),
|
|
2931
|
+
event: z.object({
|
|
2932
|
+
snapshotId: z.string(),
|
|
2933
|
+
timestamp: z.number(),
|
|
2934
|
+
timeSinceLastChange: z.number(),
|
|
2935
|
+
isRecoveryTriggered: z.boolean(),
|
|
2936
|
+
trigger: z.enum([
|
|
2937
|
+
"manual",
|
|
2938
|
+
"auto",
|
|
2939
|
+
"ai-detected",
|
|
2940
|
+
"recovery"
|
|
2941
|
+
])
|
|
2942
|
+
})
|
|
2943
|
+
}),
|
|
2944
|
+
"dora/record-recovery": z.object({
|
|
2945
|
+
workspace: z.string(),
|
|
2946
|
+
event: z.object({
|
|
2947
|
+
snapshotId: z.string(),
|
|
2948
|
+
requestTime: z.number(),
|
|
2949
|
+
completionTime: z.number(),
|
|
2950
|
+
success: z.boolean(),
|
|
2951
|
+
filesRestored: z.number(),
|
|
2952
|
+
failureReason: z.string().optional()
|
|
2953
|
+
})
|
|
2954
|
+
}),
|
|
2955
|
+
"dora/get-metrics": z.object({
|
|
2956
|
+
workspace: z.string()
|
|
2957
|
+
}),
|
|
2958
|
+
"dora/get-trends": z.object({
|
|
2959
|
+
workspace: z.string()
|
|
2960
|
+
}),
|
|
2961
|
+
// CTI: Codebase Topology Intelligence namespace (Phase A)
|
|
2962
|
+
"topology/scan": z.object({
|
|
2963
|
+
workspace: z.string(),
|
|
2964
|
+
force: z.boolean().optional().default(false)
|
|
2965
|
+
}),
|
|
2966
|
+
"topology/status": z.object({
|
|
2967
|
+
workspace: z.string()
|
|
2968
|
+
}),
|
|
2969
|
+
"topology/query": z.object({
|
|
2970
|
+
workspace: z.string(),
|
|
2971
|
+
task: z.string().min(1, "task description required for topology query"),
|
|
2972
|
+
max_files: z.number().int().positive().optional().default(15),
|
|
2973
|
+
include_deviations: z.boolean().optional().default(true),
|
|
2974
|
+
include_behavioral: z.boolean().optional().default(true)
|
|
2975
|
+
}),
|
|
2976
|
+
// Provenance namespace (AI attribution via daemon session data)
|
|
2977
|
+
"provenance/query": z.object({
|
|
2978
|
+
workspaceRoot: z.string(),
|
|
2979
|
+
files: z.array(z.string())
|
|
2980
|
+
}),
|
|
2981
|
+
// Knowledge namespace (CONTRACT-04: phantom method handler exists at protocol.ts line 1071)
|
|
2982
|
+
"knowledge/ingest": z.object({
|
|
2983
|
+
workspace: z.string(),
|
|
2984
|
+
text: z.string(),
|
|
2985
|
+
source: z.string(),
|
|
2986
|
+
metadata: z.record(z.unknown()).optional()
|
|
2987
|
+
})});
|
|
2988
|
+
|
|
2989
|
+
// ../../packages/contracts/dist/protocol/METHOD_REGISTRY.js
|
|
2990
|
+
z.object({
|
|
2991
|
+
filePath: z.string(),
|
|
2992
|
+
content: z.string().optional(),
|
|
2993
|
+
trigger: z.enum([
|
|
2994
|
+
"save",
|
|
2995
|
+
"manual",
|
|
2996
|
+
"auto"
|
|
2997
|
+
])
|
|
2998
|
+
});
|
|
2999
|
+
z.object({
|
|
3000
|
+
snapshotId: z.string(),
|
|
3001
|
+
filePath: z.string().optional()
|
|
3002
|
+
});
|
|
3003
|
+
z.object({
|
|
3004
|
+
filePath: z.string().optional(),
|
|
3005
|
+
limit: z.number().optional()
|
|
3006
|
+
});
|
|
3007
|
+
z.object({
|
|
3008
|
+
snapshotId: z.string(),
|
|
3009
|
+
permanent: z.boolean().optional()
|
|
3010
|
+
});
|
|
3011
|
+
z.object({
|
|
3012
|
+
snapshotIds: z.array(z.string())
|
|
3013
|
+
});
|
|
3014
|
+
z.object({
|
|
3015
|
+
snapshotId: z.string()
|
|
3016
|
+
});
|
|
3017
|
+
z.object({
|
|
3018
|
+
snapshotId: z.string()
|
|
3019
|
+
});
|
|
3020
|
+
z.object({
|
|
3021
|
+
snapshotId: z.string(),
|
|
3022
|
+
newName: z.string()
|
|
3023
|
+
});
|
|
3024
|
+
z.object({
|
|
3025
|
+
filePaths: z.array(z.string()),
|
|
3026
|
+
includeDependencies: z.boolean().optional()
|
|
3027
|
+
});
|
|
3028
|
+
z.object({
|
|
3029
|
+
filePaths: z.array(z.string())
|
|
3030
|
+
});
|
|
3031
|
+
z.object({
|
|
3032
|
+
workspace: z.string()
|
|
3033
|
+
});
|
|
3034
|
+
z.object({
|
|
3035
|
+
includeMetrics: z.boolean().optional()
|
|
3036
|
+
});
|
|
3037
|
+
z.object({
|
|
3038
|
+
port: z.number().optional(),
|
|
3039
|
+
configPath: z.string().optional()
|
|
3040
|
+
});
|
|
3041
|
+
z.object({
|
|
3042
|
+
force: z.boolean().optional()
|
|
3043
|
+
});
|
|
3044
|
+
z.object({
|
|
3045
|
+
clientId: z.string(),
|
|
3046
|
+
publicKey: z.string()
|
|
3047
|
+
});
|
|
3048
|
+
z.object({
|
|
3049
|
+
challengeId: z.string(),
|
|
3050
|
+
signature: z.string()
|
|
3051
|
+
});
|
|
3052
|
+
z.object({
|
|
3053
|
+
workspace: z.string(),
|
|
3054
|
+
olderThanDays: z.number().optional()
|
|
3055
|
+
});
|
|
3056
|
+
z.object({
|
|
3057
|
+
workspace: z.string(),
|
|
3058
|
+
operation: z.enum([
|
|
3059
|
+
"all",
|
|
3060
|
+
"stale",
|
|
3061
|
+
"orphaned"
|
|
3062
|
+
]).optional(),
|
|
3063
|
+
dryRun: z.boolean().optional()
|
|
3064
|
+
});
|
|
3065
|
+
z.object({
|
|
3066
|
+
workspace: z.string(),
|
|
3067
|
+
limit: z.number().optional(),
|
|
3068
|
+
type: z.string().optional()
|
|
3069
|
+
});
|
|
3070
|
+
z.object({
|
|
3071
|
+
workspace: z.string(),
|
|
3072
|
+
keywords: z.array(z.string()),
|
|
3073
|
+
limit: z.number().optional()
|
|
3074
|
+
});
|
|
3075
|
+
z.object({
|
|
3076
|
+
workspace: z.string(),
|
|
3077
|
+
learning: z.record(z.unknown())
|
|
3078
|
+
});
|
|
3079
|
+
z.object({
|
|
3080
|
+
workspace: z.string()
|
|
3081
|
+
});
|
|
3082
|
+
z.object({
|
|
3083
|
+
workspace: z.string(),
|
|
3084
|
+
type: z.string(),
|
|
3085
|
+
file: z.string(),
|
|
3086
|
+
whatHappened: z.string(),
|
|
3087
|
+
whyItHappened: z.string(),
|
|
3088
|
+
prevention: z.string()
|
|
3089
|
+
});
|
|
3090
|
+
z.object({
|
|
3091
|
+
config: z.record(z.unknown()).optional()
|
|
3092
|
+
});
|
|
3093
|
+
z.object({
|
|
3094
|
+
includeUptime: z.boolean().optional()
|
|
3095
|
+
});
|
|
3096
|
+
z.object({});
|
|
3097
|
+
z.object({
|
|
3098
|
+
force: z.boolean().optional()
|
|
3099
|
+
});
|
|
3100
|
+
z.object({
|
|
3101
|
+
sessionId: z.string(),
|
|
3102
|
+
since: z.string().optional()
|
|
3103
|
+
});
|
|
3104
|
+
z.object({
|
|
3105
|
+
filePaths: z.array(z.string()),
|
|
3106
|
+
checks: z.array(z.string()).optional()
|
|
3107
|
+
});
|
|
3108
|
+
z.object({
|
|
3109
|
+
filePaths: z.array(z.string()),
|
|
3110
|
+
checks: z.array(z.string()).optional()
|
|
3111
|
+
});
|
|
3112
|
+
z.object({
|
|
3113
|
+
filePath: z.string(),
|
|
3114
|
+
eventType: z.enum([
|
|
3115
|
+
"create",
|
|
3116
|
+
"modify",
|
|
3117
|
+
"delete"
|
|
3118
|
+
]),
|
|
3119
|
+
content: z.string().optional()
|
|
3120
|
+
});
|
|
3121
|
+
z.object({
|
|
3122
|
+
workspace: z.string(),
|
|
3123
|
+
filePaths: z.array(z.string())
|
|
3124
|
+
});
|
|
3125
|
+
z.object({
|
|
3126
|
+
workspace: z.string(),
|
|
3127
|
+
subscriptionId: z.string()
|
|
3128
|
+
});
|
|
3129
|
+
z.object({
|
|
3130
|
+
workspace: z.string(),
|
|
3131
|
+
path: z.string(),
|
|
3132
|
+
linesChanged: z.number().optional(),
|
|
3133
|
+
aiAttributed: z.boolean().optional(),
|
|
3134
|
+
aiTool: z.string().optional()
|
|
3135
|
+
});
|
|
3136
|
+
z.object({
|
|
3137
|
+
workspace: z.string(),
|
|
3138
|
+
path: z.string(),
|
|
3139
|
+
linesChanged: z.number().optional(),
|
|
3140
|
+
aiAttributed: z.boolean().optional(),
|
|
3141
|
+
aiTool: z.string().optional()
|
|
3142
|
+
});
|
|
3143
|
+
z.object({
|
|
3144
|
+
workspace: z.string()
|
|
3145
|
+
});
|
|
3146
|
+
z.object({
|
|
3147
|
+
cacheKey: z.string().optional()
|
|
3148
|
+
});
|
|
3149
|
+
z.object({
|
|
3150
|
+
workspace: z.string(),
|
|
3151
|
+
level: z.enum([
|
|
3152
|
+
"none",
|
|
3153
|
+
"read-only",
|
|
3154
|
+
"full"
|
|
3155
|
+
])
|
|
3156
|
+
});
|
|
3157
|
+
z.object({});
|
|
3158
|
+
z.object({
|
|
3159
|
+
workspace: z.string()
|
|
3160
|
+
});
|
|
3161
|
+
z.object({
|
|
3162
|
+
workspacePath: z.string(),
|
|
3163
|
+
task: z.string().optional(),
|
|
3164
|
+
files: z.array(z.string()).optional(),
|
|
3165
|
+
keywords: z.array(z.string()).optional(),
|
|
3166
|
+
metadata: z.record(z.unknown()).optional(),
|
|
3167
|
+
touchedFiles: z.array(z.string()).optional()
|
|
3168
|
+
});
|
|
3169
|
+
z.object({
|
|
3170
|
+
sessionId: z.string().optional(),
|
|
3171
|
+
reason: z.enum([
|
|
3172
|
+
"user",
|
|
3173
|
+
"idle",
|
|
3174
|
+
"workspace_closed",
|
|
3175
|
+
"recovered-abandoned"
|
|
3176
|
+
]).optional()
|
|
3177
|
+
});
|
|
3178
|
+
z.object({
|
|
3179
|
+
workspacePath: z.string().optional(),
|
|
3180
|
+
limit: z.number().int().min(1).max(100).default(20),
|
|
3181
|
+
before: z.string().optional(),
|
|
3182
|
+
includeEnded: z.boolean().default(true)
|
|
3183
|
+
});
|
|
3184
|
+
z.object({
|
|
3185
|
+
workspacePath: z.string()
|
|
3186
|
+
});
|
|
3187
|
+
z.object({
|
|
3188
|
+
workspacePath: z.string(),
|
|
3189
|
+
sessionId: z.string().optional(),
|
|
3190
|
+
files: z.array(z.string()).optional(),
|
|
3191
|
+
includeCommitMessage: z.boolean().optional(),
|
|
3192
|
+
skipPatterns: z.boolean().optional()
|
|
3193
|
+
});
|
|
3194
|
+
z.object({
|
|
3195
|
+
snapshotId: z.string(),
|
|
3196
|
+
includeContent: z.boolean().default(false)
|
|
3197
|
+
});
|
|
3198
|
+
z.object({
|
|
3199
|
+
baseSnapshotId: z.string(),
|
|
3200
|
+
compareSnapshotId: z.string().optional(),
|
|
3201
|
+
contextLines: z.number().int().min(0).max(10).default(3),
|
|
3202
|
+
format: z.enum([
|
|
3203
|
+
"unified",
|
|
3204
|
+
"split"
|
|
3205
|
+
]).default("unified")
|
|
3206
|
+
});
|
|
3207
|
+
z.object({
|
|
3208
|
+
filePath: z.string().min(1),
|
|
3209
|
+
content: z.string().optional(),
|
|
3210
|
+
context: z.object({
|
|
3211
|
+
recentChanges: z.number().int().nonnegative().optional(),
|
|
3212
|
+
timeSinceLastSave: z.number().int().nonnegative().optional(),
|
|
3213
|
+
aiToolActive: z.boolean().optional()
|
|
3214
|
+
}).optional()
|
|
3215
|
+
});
|
|
3216
|
+
z.object({
|
|
3217
|
+
filePath: z.string().min(1),
|
|
3218
|
+
content: z.string(),
|
|
3219
|
+
previousContent: z.string().optional(),
|
|
3220
|
+
metadata: z.object({
|
|
3221
|
+
editorInfo: z.string().optional(),
|
|
3222
|
+
timestamp: z.number().int().positive().optional()
|
|
3223
|
+
}).optional()
|
|
3224
|
+
});
|
|
3225
|
+
z.object({
|
|
3226
|
+
workspacePath: z.string().optional()
|
|
3227
|
+
});
|
|
3228
|
+
z.object({
|
|
3229
|
+
sessionId: z.string()
|
|
3230
|
+
});
|
|
3231
|
+
z.object({
|
|
3232
|
+
sessionId: z.string()
|
|
3233
|
+
});
|
|
3234
|
+
|
|
3235
|
+
export { JsonRpcMessageSchema, LearningApiSchema, ProtocolErrorCode, normalizeMethodName };
|
|
3236
|
+
//# sourceMappingURL=chunk-VTSNRV3V.js.map
|
|
3237
|
+
//# sourceMappingURL=chunk-VTSNRV3V.js.map
|